Commit 0b14b8a1 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[cleanup] Remove 'typedef struct' and 'typedef enum'

Just use standard C++ syntax to define structs and enums instead.

R=ahaas@chromium.org

Bug: v8:9183
Change-Id: Ibae1643bd1dc74267cdd14ec45a36fc65bf0ab4b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1631410Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61889}
parent 1276640a
......@@ -55,11 +55,10 @@ CounterType Counter::type() {
return type_;
}
typedef struct {
struct CounterDescriptor {
const char* name;
CounterType type;
} CounterDescriptor;
};
static const CounterDescriptor kCounterList[] = {
{"Instruction", Cumulative},
......
......@@ -859,11 +859,11 @@ enum ShouldThrow {
};
// The Store Buffer (GC).
typedef enum {
enum StoreBufferEvent {
kStoreBufferFullEvent,
kStoreBufferStartScanningPagesEvent,
kStoreBufferScanningPageEvent
} StoreBufferEvent;
};
using StoreBufferCallback = void (*)(Heap* heap, MemoryChunk* page,
StoreBufferEvent event);
......
......@@ -1708,7 +1708,7 @@ static void CreateDWARFSections(CodeDescription* desc, Zone* zone,
// Binary GDB JIT Interface as described in
// http://sourceware.org/gdb/onlinedocs/gdb/Declarations.html
extern "C" {
typedef enum { JIT_NOACTION = 0, JIT_REGISTER_FN, JIT_UNREGISTER_FN } JITAction;
enum JITAction { JIT_NOACTION = 0, JIT_REGISTER_FN, JIT_UNREGISTER_FN };
struct JITCodeEntry {
JITCodeEntry* next_;
......
......@@ -31,23 +31,23 @@ bool RegisterUnwindInfoForExceptionHandlingOnly() {
* From Windows SDK ehdata.h, which does not compile with Clang.
* See https://msdn.microsoft.com/en-us/library/ddssxxy8.aspx.
*/
typedef union _UNWIND_CODE {
union UNWIND_CODE {
struct {
unsigned char CodeOffset;
unsigned char UnwindOp : 4;
unsigned char OpInfo : 4;
};
uint16_t FrameOffset;
} UNWIND_CODE, *PUNWIND_CODE;
};
typedef struct _UNWIND_INFO {
struct UNWIND_INFO {
unsigned char Version : 3;
unsigned char Flags : 5;
unsigned char SizeOfProlog;
unsigned char CountOfCodes;
unsigned char FrameRegister : 4;
unsigned char FrameOffset : 4;
} UNWIND_INFO, *PUNWIND_INFO;
};
struct V8UnwindData {
UNWIND_INFO unwind_info;
......
......@@ -39,12 +39,12 @@ inline int inlineUTF8SequenceLength(char b0) {
static const unsigned char firstByteMark[7] = {0x00, 0x00, 0xC0, 0xE0,
0xF0, 0xF8, 0xFC};
typedef enum {
enum ConversionResult {
conversionOK, // conversion successful
sourceExhausted, // partial character in source, but hit end
targetExhausted, // insuff. room in target for conversion
sourceIllegal // source sequence is illegal/malformed
} ConversionResult;
};
ConversionResult convertUTF16ToUTF8(const UChar** sourceStart,
const UChar* sourceEnd, char** targetStart,
......
......@@ -73,29 +73,29 @@ using zx_thread_state_general_regs_t = zx_arm64_general_regs_t;
using mcontext_t = struct sigcontext;
typedef struct ucontext {
struct ucontext_t {
uint32_t uc_flags;
struct ucontext* uc_link;
stack_t uc_stack;
mcontext_t uc_mcontext;
// Other fields are not used by V8, don't define them here.
} ucontext_t;
};
#elif defined(__aarch64__)
using mcontext_t = struct sigcontext;
typedef struct ucontext {
struct ucontext_t {
uint64_t uc_flags;
struct ucontext *uc_link;
stack_t uc_stack;
mcontext_t uc_mcontext;
// Other fields are not used by V8, don't define them here.
} ucontext_t;
};
#elif defined(__mips__)
// MIPS version of sigcontext, for Android bionic.
typedef struct {
struct mcontext_t {
uint32_t regmask;
uint32_t status;
uint64_t pc;
......@@ -114,50 +114,50 @@ typedef struct {
uint32_t lo2;
uint32_t hi3;
uint32_t lo3;
} mcontext_t;
};
typedef struct ucontext {
struct ucontext_t {
uint32_t uc_flags;
struct ucontext* uc_link;
stack_t uc_stack;
mcontext_t uc_mcontext;
// Other fields are not used by V8, don't define them here.
} ucontext_t;
};
#elif defined(__i386__)
// x86 version for Android.
typedef struct {
struct mcontext_t {
uint32_t gregs[19];
void* fpregs;
uint32_t oldmask;
uint32_t cr2;
} mcontext_t;
};
typedef uint32_t kernel_sigset_t[2]; // x86 kernel uses 64-bit signal masks
typedef struct ucontext {
using kernel_sigset_t = uint32_t[2]; // x86 kernel uses 64-bit signal masks
struct ucontext_t {
uint32_t uc_flags;
struct ucontext* uc_link;
stack_t uc_stack;
mcontext_t uc_mcontext;
// Other fields are not used by V8, don't define them here.
} ucontext_t;
};
enum { REG_EBP = 6, REG_ESP = 7, REG_EIP = 14 };
#elif defined(__x86_64__)
// x64 version for Android.
typedef struct {
struct mcontext_t {
uint64_t gregs[23];
void* fpregs;
uint64_t __reserved1[8];
} mcontext_t;
};
typedef struct ucontext {
struct ucontext_t {
uint64_t uc_flags;
struct ucontext *uc_link;
stack_t uc_stack;
mcontext_t uc_mcontext;
// Other fields are not used by V8, don't define them here.
} ucontext_t;
};
enum { REG_RBP = 10, REG_RSP = 15, REG_RIP = 16 };
#endif
......
......@@ -291,7 +291,7 @@ class Simulator : public SimulatorBase {
// MSA Data Format
enum MSADataFormat { MSA_VECT = 0, MSA_BYTE, MSA_HALF, MSA_WORD, MSA_DWORD };
typedef union {
union msa_reg_t {
int8_t b[kMSALanesByte];
uint8_t ub[kMSALanesByte];
int16_t h[kMSALanesHalf];
......@@ -300,7 +300,7 @@ class Simulator : public SimulatorBase {
uint32_t uw[kMSALanesWord];
int64_t d[kMSALanesDword];
uint64_t ud[kMSALanesDword];
} msa_reg_t;
};
// Read and write memory.
inline uint32_t ReadBU(int32_t addr);
......
......@@ -302,7 +302,7 @@ class Simulator : public SimulatorBase {
// MSA Data Format
enum MSADataFormat { MSA_VECT = 0, MSA_BYTE, MSA_HALF, MSA_WORD, MSA_DWORD };
typedef union {
union msa_reg_t {
int8_t b[kMSALanesByte];
uint8_t ub[kMSALanesByte];
int16_t h[kMSALanesHalf];
......@@ -311,7 +311,7 @@ class Simulator : public SimulatorBase {
uint32_t uw[kMSALanesWord];
int64_t d[kMSALanesDword];
uint64_t ud[kMSALanesDword];
} msa_reg_t;
};
// Read and write memory.
inline uint32_t ReadBU(int64_t addr);
......
......@@ -156,11 +156,11 @@ TEST(3) {
Isolate* isolate = CcTest::i_isolate();
HandleScope scope(isolate);
typedef struct {
struct T {
int i;
char c;
int16_t s;
} T;
};
T t;
Assembler assm(AssemblerOptions{});
......@@ -208,7 +208,7 @@ TEST(4) {
Isolate* isolate = CcTest::i_isolate();
HandleScope scope(isolate);
typedef struct {
struct T {
double a;
double b;
double c;
......@@ -225,7 +225,7 @@ TEST(4) {
float p;
float x;
float y;
} T;
};
T t;
// Create a function that accepts &t, and loads, manipulates, and stores
......@@ -599,7 +599,7 @@ TEST(8) {
Isolate* isolate = CcTest::i_isolate();
HandleScope scope(isolate);
typedef struct {
struct D {
double a;
double b;
double c;
......@@ -608,10 +608,10 @@ TEST(8) {
double f;
double g;
double h;
} D;
};
D d;
typedef struct {
struct F {
float a;
float b;
float c;
......@@ -620,7 +620,7 @@ TEST(8) {
float f;
float g;
float h;
} F;
};
F f;
// Create a function that uses vldm/vstm to move some double and
......@@ -703,7 +703,7 @@ TEST(9) {
Isolate* isolate = CcTest::i_isolate();
HandleScope scope(isolate);
typedef struct {
struct D {
double a;
double b;
double c;
......@@ -712,10 +712,10 @@ TEST(9) {
double f;
double g;
double h;
} D;
};
D d;
typedef struct {
struct F {
float a;
float b;
float c;
......@@ -724,7 +724,7 @@ TEST(9) {
float f;
float g;
float h;
} F;
};
F f;
// Create a function that uses vldm/vstm to move some double and
......@@ -811,7 +811,7 @@ TEST(10) {
Isolate* isolate = CcTest::i_isolate();
HandleScope scope(isolate);
typedef struct {
struct D {
double a;
double b;
double c;
......@@ -820,10 +820,10 @@ TEST(10) {
double f;
double g;
double h;
} D;
};
D d;
typedef struct {
struct F {
float a;
float b;
float c;
......@@ -832,7 +832,7 @@ TEST(10) {
float f;
float g;
float h;
} F;
};
F f;
// Create a function that uses vldm/vstm to move some double and
......@@ -915,12 +915,12 @@ TEST(11) {
Isolate* isolate = CcTest::i_isolate();
HandleScope scope(isolate);
typedef struct {
struct I {
int32_t a;
int32_t b;
int32_t c;
int32_t d;
} I;
};
I i;
i.a = 0xABCD0001;
......@@ -996,7 +996,7 @@ TEST(13) {
return;
}
typedef struct {
struct T {
double a;
double b;
double c;
......@@ -1008,7 +1008,7 @@ TEST(13) {
double k;
uint32_t low;
uint32_t high;
} T;
};
T t;
// Create a function that accepts &t, and loads, manipulates, and stores
......@@ -1114,14 +1114,14 @@ TEST(14) {
Isolate* isolate = CcTest::i_isolate();
HandleScope scope(isolate);
typedef struct {
struct T {
double left;
double right;
double add_result;
double sub_result;
double mul_result;
double div_result;
} T;
};
T t;
// Create a function that makes the four basic operations.
......@@ -1224,7 +1224,7 @@ TEST(15) {
Isolate* isolate = CcTest::i_isolate();
HandleScope scope(isolate);
typedef struct {
struct T {
uint32_t src0;
uint32_t src1;
uint32_t src2;
......@@ -1298,7 +1298,7 @@ TEST(15) {
uint32_t vtrnd8a[2], vtrnd8b[2], vtrnd16a[2], vtrnd16b[2], vtrnd32a[2],
vtrnd32b[2];
uint32_t vtbl[2], vtbx[2];
} T;
};
T t;
// Create a function that accepts &t, and loads, manipulates, and stores
......@@ -2263,7 +2263,7 @@ TEST(16) {
Isolate* isolate = CcTest::i_isolate();
HandleScope scope(isolate);
typedef struct {
struct T {
uint32_t src0;
uint32_t src1;
uint32_t src2;
......@@ -2272,7 +2272,7 @@ TEST(16) {
uint32_t dst2;
uint32_t dst3;
uint32_t dst4;
} T;
};
T t;
// Create a function that accepts &t, and loads, manipulates, and stores
......@@ -2712,10 +2712,10 @@ TEST(rbit) {
if (CpuFeatures::IsSupported(ARMv7)) {
CpuFeatureScope scope(&assm, ARMv7);
typedef struct {
struct T {
uint32_t input;
uint32_t result;
} T;
};
T t;
__ ldr(r1, MemOperand(r0, offsetof(T, input)));
......@@ -2889,14 +2889,14 @@ TEST(ARMv8_float32_vrintX) {
Isolate* isolate = CcTest::i_isolate();
HandleScope scope(isolate);
typedef struct {
struct T {
float input;
float ar;
float nr;
float mr;
float pr;
float zr;
} T;
};
T t;
// Create a function that accepts &t, and loads, manipulates, and stores
......@@ -2989,14 +2989,14 @@ TEST(ARMv8_vrintX) {
Isolate* isolate = CcTest::i_isolate();
HandleScope scope(isolate);
typedef struct {
struct T {
double input;
double ar;
double nr;
double mr;
double pr;
double zr;
} T;
};
T t;
// Create a function that accepts &t, and loads, manipulates, and stores
......@@ -3620,11 +3620,11 @@ TEST(unaligned_loads) {
Isolate* isolate = CcTest::i_isolate();
HandleScope scope(isolate);
typedef struct {
struct T {
uint32_t ldrh;
uint32_t ldrsh;
uint32_t ldr;
} T;
};
T t;
Assembler assm(AssemblerOptions{});
......@@ -3728,14 +3728,14 @@ TEST(vswp) {
HandleScope scope(isolate);
Assembler assm(AssemblerOptions{});
typedef struct {
struct T {
uint64_t vswp_d0;
uint64_t vswp_d1;
uint64_t vswp_d30;
uint64_t vswp_d31;
uint32_t vswp_q4[4];
uint32_t vswp_q5[4];
} T;
};
T t;
__ stm(db_w, sp, r4.bit() | r5.bit() | r6.bit() | r7.bit() | lr.bit());
......
This diff is collapsed.
This diff is collapsed.
......@@ -158,11 +158,11 @@ TEST(3) {
Isolate* isolate = CcTest::i_isolate();
HandleScope scope(isolate);
typedef struct {
struct T {
int i;
char c;
int16_t s;
} T;
};
T t;
Assembler assm(AssemblerOptions{});
......@@ -233,7 +233,7 @@ TEST(4) {
Isolate* isolate = CcTest::i_isolate();
HandleScope scope(isolate);
typedef struct {
struct T {
double a;
double b;
double c;
......@@ -247,7 +247,7 @@ TEST(4) {
double n;
float x;
float y;
} T;
};
T t;
// Create a function that accepts &t, and loads, manipulates, and stores
......@@ -623,7 +623,7 @@ TEST(8) {
Isolate* isolate = CcTest::i_isolate();
HandleScope scope(isolate);
typedef struct {
struct D {
double a;
double b;
double c;
......@@ -632,10 +632,10 @@ TEST(8) {
double f;
double g;
double h;
} D;
};
D d;
typedef struct {
struct F {
float a;
float b;
float c;
......@@ -644,7 +644,7 @@ TEST(8) {
float f;
float g;
float h;
} F;
};
F f;
// Create a function that uses vldm/vstm to move some double and
......@@ -734,7 +734,7 @@ TEST(9) {
Isolate* isolate = CcTest::i_isolate();
HandleScope scope(isolate);
typedef struct {
struct D {
double a;
double b;
double c;
......@@ -743,10 +743,10 @@ TEST(9) {
double f;
double g;
double h;
} D;
};
D d;
typedef struct {
struct F {
float a;
float b;
float c;
......@@ -755,7 +755,7 @@ TEST(9) {
float f;
float g;
float h;
} F;
};
F f;
// Create a function that uses vldm/vstm to move some double and
......@@ -849,7 +849,7 @@ TEST(10) {
Isolate* isolate = CcTest::i_isolate();
HandleScope scope(isolate);
typedef struct {
struct D {
double a;
double b;
double c;
......@@ -858,10 +858,10 @@ TEST(10) {
double f;
double g;
double h;
} D;
};
D d;
typedef struct {
struct F {
float a;
float b;
float c;
......@@ -870,7 +870,7 @@ TEST(10) {
float f;
float g;
float h;
} F;
};
F f;
// Create a function that uses vldm/vstm to move some double and
......@@ -960,12 +960,12 @@ TEST(11) {
Isolate* isolate = CcTest::i_isolate();
HandleScope scope(isolate);
typedef struct {
struct I {
int32_t a;
int32_t b;
int32_t c;
int32_t d;
} I;
};
I i;
i.a = 0xABCD0001;
......
......@@ -58,7 +58,7 @@ TEST(ExtractLane) {
buffer->CreateView());
MacroAssembler* masm = &assembler; // Create a pointer for the __ macro.
typedef struct {
struct T {
int32_t i32x4_low[4];
int32_t i32x4_high[4];
int32_t i16x8_low[8];
......@@ -69,7 +69,7 @@ TEST(ExtractLane) {
int32_t f32x4_high[4];
int32_t i8x16_low_d[16];
int32_t i8x16_high_d[16];
} T;
};
T t;
__ stm(db_w, sp, r4.bit() | r5.bit() | lr.bit());
......@@ -196,7 +196,7 @@ TEST(ReplaceLane) {
buffer->CreateView());
MacroAssembler* masm = &assembler; // Create a pointer for the __ macro.
typedef struct {
struct T {
int32_t i32x4_low[4];
int32_t i32x4_high[4];
int16_t i16x8_low[8];
......@@ -205,7 +205,7 @@ TEST(ReplaceLane) {
int8_t i8x16_high[16];
int32_t f32x4_low[4];
int32_t f32x4_high[4];
} T;
};
T t;
__ stm(db_w, sp, r4.bit() | r5.bit() | r6.bit() | r7.bit() | lr.bit());
......
......@@ -67,10 +67,10 @@ void DecodeIncrementally(const std::vector<byte>& bytes,
TEST(UnicodeTest, Utf16BufferReuse) {
// Not enough continuation bytes before string ends.
typedef struct {
struct TestCase {
std::vector<byte> bytes;
std::vector<unibrow::uchar> unicode_expected;
} TestCase;
};
TestCase data[] = {
{{0x00}, {0x0}},
......@@ -112,10 +112,10 @@ TEST(UnicodeTest, IncrementalUTF8DecodingVsNonIncrementalUtf8Decoding) {
// Unfortunately, V8 has two UTF-8 decoders. This test checks that they
// produce the same result. This test was inspired by
// https://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt .
typedef struct {
struct TestCase {
std::vector<byte> bytes;
std::vector<unibrow::uchar> unicode_expected;
} TestCase;
};
TestCase data[] = {
// Correct UTF-8 text.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment