Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions testdata/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
BasedOnStyle: LLVM
IndentWidth: 4
ColumnLimit: 0
SortIncludes: Never
SpaceAfterCStyleCast: true
AllowShortBlocksOnASingleLine: Always
AllowShortFunctionsOnASingleLine: None
AlignConsecutiveDeclarations:
Enabled: true
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: true
AlignFunctionPointers: true
PadOperators: true
4 changes: 2 additions & 2 deletions testdata/abitest/abi_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <stdio.h>
#include <string.h>

uint32_t stack_uint8_t(uint32_t a, uint32_t b, uint32_t c, uint32_t d, uint32_t e, uint32_t f, uint32_t g, uint32_t h, uint8_t i, uint8_t j, uint32_t k ) {
uint32_t stack_uint8_t(uint32_t a, uint32_t b, uint32_t c, uint32_t d, uint32_t e, uint32_t f, uint32_t g, uint32_t h, uint8_t i, uint8_t j, uint32_t k) {
assert(i == 1);
assert(j == 2);
assert(k == 1024);
Expand All @@ -20,7 +20,7 @@ uint32_t reg_uint8_t(uint8_t a, uint8_t b, uint32_t c) {
return a | b | c;
}

uint32_t stack_string(uint32_t a, uint32_t b, uint32_t c, uint32_t d, uint32_t e, uint32_t f, uint32_t g, uint32_t h, const char * i) {
uint32_t stack_string(uint32_t a, uint32_t b, uint32_t c, uint32_t d, uint32_t e, uint32_t f, uint32_t g, uint32_t h, const char *i) {
assert(i != 0);
assert(strcmp(i, "test") == 0);
return a | b | c | d | e | f | g | h;
Expand Down
2 changes: 1 addition & 1 deletion testdata/libcbtest/callback_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ typedef int (*callback)(const char *, int);
int callCallback(const void *fp, const char *s) {
// If the callback corrupts FP, this local variable on the stack will have incorrect value.
int sentinel = 10101;
((callback)(fp))(s, strlen(s));
((callback) (fp))(s, strlen(s));
return sentinel;
}
58 changes: 31 additions & 27 deletions testdata/structtest/struct_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "stdint.h"

#if defined(__x86_64__) || defined(__aarch64__)
typedef int64_t GoInt;
typedef int64_t GoInt;
typedef uint64_t GoUint;
#endif

Expand All @@ -30,7 +30,7 @@ unsigned long EmptyEmptyWithReg(unsigned int x, struct EmptyEmpty e, unsigned in

// GreaterThan16Bytes is 24 bytes on 64 bit systems
struct GreaterThan16Bytes {
long *x, *y, *z;
long *x, *y, *z;
};

// GreaterThan16Bytes is a basic test for structs bigger than 16 bytes
Expand All @@ -41,7 +41,7 @@ unsigned long GreaterThan16Bytes(struct GreaterThan16Bytes g) {
// AfterRegisters tests to make sure that structs placed on the stack work properly
unsigned long AfterRegisters(long a, long b, long c, long d, long e, long f, long g, long h, struct GreaterThan16Bytes bytes) {
long registers = a + b + c + d + e + f + g + h;
long stack = *bytes.x + *bytes.y + *bytes.z;
long stack = *bytes.x + *bytes.y + *bytes.z;
if (registers != stack) {
return 0xbadbad;
}
Expand All @@ -57,8 +57,8 @@ unsigned long BeforeRegisters(struct GreaterThan16Bytes bytes, long a, long b) {

struct GreaterThan16BytesStruct {
struct {
long *x, *y, *z;
} a ;
long *x, *y, *z;
} a;
};

unsigned long GreaterThan16BytesStruct(struct GreaterThan16BytesStruct g) {
Expand Down Expand Up @@ -173,7 +173,7 @@ struct UnsignedChar4Bytes {
};

unsigned int UnsignedChar4Bytes(struct UnsignedChar4Bytes b) {
return (((int)b.a)<<24) | (((int)b.b)<<16) | (((int)b.c)<<8) | (((int)b.d)<<0);
return (((int) b.a) << 24) | (((int) b.b) << 16) | (((int) b.c) << 8) | (((int) b.d) << 0);
}

struct UnsignedChar4BytesStruct {
Expand All @@ -192,23 +192,23 @@ struct UnsignedChar4BytesStruct {
};

unsigned int UnsignedChar4BytesStruct(struct UnsignedChar4BytesStruct b) {
return (((int)b.x.a)<<24) | (((int)b.y.b)<<16) | (((int)b.z.c)<<8) | (((int)b.w.d)<<0);
return (((int) b.x.a) << 24) | (((int) b.y.b) << 16) | (((int) b.z.c) << 8) | (((int) b.w.d) << 0);
}

struct Short {
unsigned short a, b, c, d;
};

unsigned long Short(struct Short s) {
return (long)s.a << 48 | (long)s.b << 32 | (long)s.c << 16 | (long)s.d << 0;
return (long) s.a << 48 | (long) s.b << 32 | (long) s.c << 16 | (long) s.d << 0;
}

struct Int {
unsigned int a, b;
};

unsigned long Int(struct Int i) {
return (long)i.a << 32 | (long)i.b << 0;
return (long) i.a << 32 | (long) i.b << 0;
}

struct Long {
Expand All @@ -224,28 +224,28 @@ struct Char8Bytes {
};

int Char8Bytes(struct Char8Bytes b) {
return (int)b.a + (int)b.b + (int)b.c + (int)b.d + (int)b.e + (int)b.f + (int)b.g + (int)b.h;
return (int) b.a + (int) b.b + (int) b.c + (int) b.d + (int) b.e + (int) b.f + (int) b.g + (int) b.h;
}

struct Odd {
unsigned char a, b, c;
};

int Odd(struct Odd o) {
return (int)o.a + (int)o.b + (int)o.c;
return (int) o.a + (int) o.b + (int) o.c;
}

struct Char2Short1 {
unsigned char a, b;
unsigned char a, b;
unsigned short c;
};

int Char2Short1s(struct Char2Short1 s) {
return (int)s.a + (int)s.b + (int)s.c;
return (int) s.a + (int) s.b + (int) s.c;
}

struct SignedChar2Short1 {
signed char a, b;
signed char a, b;
signed short c;
};

Expand All @@ -258,47 +258,47 @@ struct Array4UnsignedChars {
};

unsigned int Array4UnsignedChars(struct Array4UnsignedChars a) {
return (((int)a.a[0])<<24) | (((int)a.a[1])<<16) | (((int)a.a[2])<<8) | (((int)a.a[3])<<0);
return (((int) a.a[0]) << 24) | (((int) a.a[1]) << 16) | (((int) a.a[2]) << 8) | (((int) a.a[3]) << 0);
}

struct Array3UnsignedChar {
unsigned char a[3];
};

unsigned int Array3UnsignedChars(struct Array3UnsignedChar a) {
return (((int)a.a[0])<<24) | (((int)a.a[1])<<16) | (((int)a.a[2])<<8) | 0xef;
return (((int) a.a[0]) << 24) | (((int) a.a[1]) << 16) | (((int) a.a[2]) << 8) | 0xef;
}

struct Array2UnsignedShort {
unsigned short a[2];
};

unsigned int Array2UnsignedShorts(struct Array2UnsignedShort a) {
return (((int)a.a[0])<<16) | (((int)a.a[1])<<0);
return (((int) a.a[0]) << 16) | (((int) a.a[1]) << 0);
}

struct Array4Chars {
char a[4];
};

int Array4Chars(struct Array4Chars a) {
return (int)a.a[0] + (int)a.a[1] + (int)a.a[2] + (int)a.a[3];
return (int) a.a[0] + (int) a.a[1] + (int) a.a[2] + (int) a.a[3];
}

struct Array2Short {
short a[2];
};

int Array2Shorts(struct Array2Short a) {
return (int)a.a[0] + (int)a.a[1];
return (int) a.a[0] + (int) a.a[1];
}

struct Array3Short {
short a[3];
};

int Array3Shorts(struct Array3Short a) {
return (int)a.a[0] + (int)a.a[1] + (int)a.a[2];
return (int) a.a[0] + (int) a.a[1] + (int) a.a[2];
}

struct BoolStruct {
Expand All @@ -321,16 +321,20 @@ float BoolFloat(struct BoolFloat s) {
}

struct Content {
struct { double x, y; } point;
struct { double width, height; } size;
struct {
double x, y;
} point;
struct {
double width, height;
} size;
};

unsigned long InitWithContentRect(int *win, struct Content c, int style, int backing, _Bool flag) {
if (win == 0)
return 0xBAD;
if (!flag)
return 0xF1A6; // FLAG
return (unsigned long)(c.point.x + c.point.y + c.size.width + c.size.height) / (style - backing);
if (win == 0)
return 0xBAD;
if (!flag)
return 0xF1A6; // FLAG
return (unsigned long) (c.point.x + c.point.y + c.size.width + c.size.height) / (style - backing);
}

struct GoInt4 {
Expand Down
Loading