#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include uint64_t __test_size_int8_t(void) { return sizeof(int8_t); } uint64_t __test_align_int8_t(void) { typedef struct { unsigned char c; int8_t v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint32_t __test_signed_int8_t(void) { return (((int8_t) -1) < 0); } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif int8_t __test_roundtrip_int8_t( int8_t value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(int8_t); if (size != rust_size) { fprintf( stderr, "size of int8_t is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"int8_t\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"int8_t\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_int16_t(void) { return sizeof(int16_t); } uint64_t __test_align_int16_t(void) { typedef struct { unsigned char c; int16_t v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint32_t __test_signed_int16_t(void) { return (((int16_t) -1) < 0); } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif int16_t __test_roundtrip_int16_t( int16_t value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(int16_t); if (size != rust_size) { fprintf( stderr, "size of int16_t is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"int16_t\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"int16_t\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_int32_t(void) { return sizeof(int32_t); } uint64_t __test_align_int32_t(void) { typedef struct { unsigned char c; int32_t v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint32_t __test_signed_int32_t(void) { return (((int32_t) -1) < 0); } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif int32_t __test_roundtrip_int32_t( int32_t value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(int32_t); if (size != rust_size) { fprintf( stderr, "size of int32_t is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"int32_t\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"int32_t\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_int64_t(void) { return sizeof(int64_t); } uint64_t __test_align_int64_t(void) { typedef struct { unsigned char c; int64_t v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint32_t __test_signed_int64_t(void) { return (((int64_t) -1) < 0); } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif int64_t __test_roundtrip_int64_t( int64_t value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(int64_t); if (size != rust_size) { fprintf( stderr, "size of int64_t is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"int64_t\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"int64_t\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_uint8_t(void) { return sizeof(uint8_t); } uint64_t __test_align_uint8_t(void) { typedef struct { unsigned char c; uint8_t v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint32_t __test_signed_uint8_t(void) { return (((uint8_t) -1) < 0); } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif uint8_t __test_roundtrip_uint8_t( uint8_t value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(uint8_t); if (size != rust_size) { fprintf( stderr, "size of uint8_t is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"uint8_t\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"uint8_t\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_uint16_t(void) { return sizeof(uint16_t); } uint64_t __test_align_uint16_t(void) { typedef struct { unsigned char c; uint16_t v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint32_t __test_signed_uint16_t(void) { return (((uint16_t) -1) < 0); } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif uint16_t __test_roundtrip_uint16_t( uint16_t value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(uint16_t); if (size != rust_size) { fprintf( stderr, "size of uint16_t is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"uint16_t\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"uint16_t\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_uint32_t(void) { return sizeof(uint32_t); } uint64_t __test_align_uint32_t(void) { typedef struct { unsigned char c; uint32_t v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint32_t __test_signed_uint32_t(void) { return (((uint32_t) -1) < 0); } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif uint32_t __test_roundtrip_uint32_t( uint32_t value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(uint32_t); if (size != rust_size) { fprintf( stderr, "size of uint32_t is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"uint32_t\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"uint32_t\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_uint64_t(void) { return sizeof(uint64_t); } uint64_t __test_align_uint64_t(void) { typedef struct { unsigned char c; uint64_t v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint32_t __test_signed_uint64_t(void) { return (((uint64_t) -1) < 0); } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif uint64_t __test_roundtrip_uint64_t( uint64_t value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(uint64_t); if (size != rust_size) { fprintf( stderr, "size of uint64_t is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"uint64_t\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"uint64_t\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_c_schar(void) { return sizeof(signed char); } uint64_t __test_align_c_schar(void) { typedef struct { unsigned char c; signed char v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint32_t __test_signed_c_schar(void) { return (((signed char) -1) < 0); } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif signed char __test_roundtrip_c_schar( signed char value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(signed char); if (size != rust_size) { fprintf( stderr, "size of signed char is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"c_schar\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"c_schar\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_c_uchar(void) { return sizeof(unsigned char); } uint64_t __test_align_c_uchar(void) { typedef struct { unsigned char c; unsigned char v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint32_t __test_signed_c_uchar(void) { return (((unsigned char) -1) < 0); } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif unsigned char __test_roundtrip_c_uchar( unsigned char value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(unsigned char); if (size != rust_size) { fprintf( stderr, "size of unsigned char is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"c_uchar\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"c_uchar\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_c_short(void) { return sizeof(short); } uint64_t __test_align_c_short(void) { typedef struct { unsigned char c; short v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint32_t __test_signed_c_short(void) { return (((short) -1) < 0); } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif short __test_roundtrip_c_short( short value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(short); if (size != rust_size) { fprintf( stderr, "size of short is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"c_short\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"c_short\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_c_ushort(void) { return sizeof(unsigned short); } uint64_t __test_align_c_ushort(void) { typedef struct { unsigned char c; unsigned short v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint32_t __test_signed_c_ushort(void) { return (((unsigned short) -1) < 0); } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif unsigned short __test_roundtrip_c_ushort( unsigned short value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(unsigned short); if (size != rust_size) { fprintf( stderr, "size of unsigned short is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"c_ushort\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"c_ushort\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_c_int(void) { return sizeof(int); } uint64_t __test_align_c_int(void) { typedef struct { unsigned char c; int v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint32_t __test_signed_c_int(void) { return (((int) -1) < 0); } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif int __test_roundtrip_c_int( int value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(int); if (size != rust_size) { fprintf( stderr, "size of int is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"c_int\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"c_int\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_c_uint(void) { return sizeof(unsigned int); } uint64_t __test_align_c_uint(void) { typedef struct { unsigned char c; unsigned int v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint32_t __test_signed_c_uint(void) { return (((unsigned int) -1) < 0); } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif unsigned int __test_roundtrip_c_uint( unsigned int value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(unsigned int); if (size != rust_size) { fprintf( stderr, "size of unsigned int is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"c_uint\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"c_uint\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_c_float(void) { return sizeof(float); } uint64_t __test_align_c_float(void) { typedef struct { unsigned char c; float v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif float __test_roundtrip_c_float( float value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(float); if (size != rust_size) { fprintf( stderr, "size of float is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"c_float\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"c_float\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_c_double(void) { return sizeof(double); } uint64_t __test_align_c_double(void) { typedef struct { unsigned char c; double v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif double __test_roundtrip_c_double( double value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(double); if (size != rust_size) { fprintf( stderr, "size of double is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"c_double\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"c_double\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_c_longlong(void) { return sizeof( long long); } uint64_t __test_align_c_longlong(void) { typedef struct { unsigned char c; long long v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint32_t __test_signed_c_longlong(void) { return ((( long long) -1) < 0); } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif long long __test_roundtrip_c_longlong( long long value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof( long long); if (size != rust_size) { fprintf( stderr, "size of long long is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"c_longlong\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"c_longlong\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_c_ulonglong(void) { return sizeof(unsigned long long); } uint64_t __test_align_c_ulonglong(void) { typedef struct { unsigned char c; unsigned long long v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint32_t __test_signed_c_ulonglong(void) { return (((unsigned long long) -1) < 0); } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif unsigned long long __test_roundtrip_c_ulonglong( unsigned long long value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(unsigned long long); if (size != rust_size) { fprintf( stderr, "size of unsigned long long is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"c_ulonglong\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"c_ulonglong\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_intmax_t(void) { return sizeof(intmax_t); } uint64_t __test_align_intmax_t(void) { typedef struct { unsigned char c; intmax_t v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint32_t __test_signed_intmax_t(void) { return (((intmax_t) -1) < 0); } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif intmax_t __test_roundtrip_intmax_t( intmax_t value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(intmax_t); if (size != rust_size) { fprintf( stderr, "size of intmax_t is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"intmax_t\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"intmax_t\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_uintmax_t(void) { return sizeof(uintmax_t); } uint64_t __test_align_uintmax_t(void) { typedef struct { unsigned char c; uintmax_t v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint32_t __test_signed_uintmax_t(void) { return (((uintmax_t) -1) < 0); } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif uintmax_t __test_roundtrip_uintmax_t( uintmax_t value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(uintmax_t); if (size != rust_size) { fprintf( stderr, "size of uintmax_t is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"uintmax_t\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"uintmax_t\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_size_t(void) { return sizeof(size_t); } uint64_t __test_align_size_t(void) { typedef struct { unsigned char c; size_t v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint32_t __test_signed_size_t(void) { return (((size_t) -1) < 0); } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif size_t __test_roundtrip_size_t( size_t value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(size_t); if (size != rust_size) { fprintf( stderr, "size of size_t is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"size_t\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"size_t\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_ptrdiff_t(void) { return sizeof(ptrdiff_t); } uint64_t __test_align_ptrdiff_t(void) { typedef struct { unsigned char c; ptrdiff_t v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint32_t __test_signed_ptrdiff_t(void) { return (((ptrdiff_t) -1) < 0); } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif ptrdiff_t __test_roundtrip_ptrdiff_t( ptrdiff_t value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(ptrdiff_t); if (size != rust_size) { fprintf( stderr, "size of ptrdiff_t is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"ptrdiff_t\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"ptrdiff_t\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_intptr_t(void) { return sizeof(intptr_t); } uint64_t __test_align_intptr_t(void) { typedef struct { unsigned char c; intptr_t v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint32_t __test_signed_intptr_t(void) { return (((intptr_t) -1) < 0); } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif intptr_t __test_roundtrip_intptr_t( intptr_t value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(intptr_t); if (size != rust_size) { fprintf( stderr, "size of intptr_t is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"intptr_t\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"intptr_t\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_uintptr_t(void) { return sizeof(uintptr_t); } uint64_t __test_align_uintptr_t(void) { typedef struct { unsigned char c; uintptr_t v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint32_t __test_signed_uintptr_t(void) { return (((uintptr_t) -1) < 0); } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif uintptr_t __test_roundtrip_uintptr_t( uintptr_t value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(uintptr_t); if (size != rust_size) { fprintf( stderr, "size of uintptr_t is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"uintptr_t\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"uintptr_t\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_ssize_t(void) { return sizeof(SSIZE_T); } uint64_t __test_align_ssize_t(void) { typedef struct { unsigned char c; SSIZE_T v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint32_t __test_signed_ssize_t(void) { return (((SSIZE_T) -1) < 0); } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif SSIZE_T __test_roundtrip_ssize_t( SSIZE_T value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(SSIZE_T); if (size != rust_size) { fprintf( stderr, "size of SSIZE_T is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"ssize_t\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"ssize_t\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_sighandler_t(void) { return sizeof(__p_sig_fn_t); } uint64_t __test_align_sighandler_t(void) { typedef struct { unsigned char c; __p_sig_fn_t v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif __p_sig_fn_t __test_roundtrip_sighandler_t( __p_sig_fn_t value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(__p_sig_fn_t); if (size != rust_size) { fprintf( stderr, "size of __p_sig_fn_t is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"sighandler_t\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"sighandler_t\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_c_char(void) { return sizeof(char); } uint64_t __test_align_c_char(void) { typedef struct { unsigned char c; char v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint32_t __test_signed_c_char(void) { return (((char) -1) < 0); } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif char __test_roundtrip_c_char( char value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(char); if (size != rust_size) { fprintf( stderr, "size of char is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"c_char\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"c_char\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_c_long(void) { return sizeof( long); } uint64_t __test_align_c_long(void) { typedef struct { unsigned char c; long v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint32_t __test_signed_c_long(void) { return ((( long) -1) < 0); } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif long __test_roundtrip_c_long( long value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof( long); if (size != rust_size) { fprintf( stderr, "size of long is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"c_long\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"c_long\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_c_ulong(void) { return sizeof(unsigned long); } uint64_t __test_align_c_ulong(void) { typedef struct { unsigned char c; unsigned long v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint32_t __test_signed_c_ulong(void) { return (((unsigned long) -1) < 0); } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif unsigned long __test_roundtrip_c_ulong( unsigned long value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(unsigned long); if (size != rust_size) { fprintf( stderr, "size of unsigned long is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"c_ulong\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"c_ulong\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_wchar_t(void) { return sizeof(wchar_t); } uint64_t __test_align_wchar_t(void) { typedef struct { unsigned char c; wchar_t v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint32_t __test_signed_wchar_t(void) { return (((wchar_t) -1) < 0); } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif wchar_t __test_roundtrip_wchar_t( wchar_t value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(wchar_t); if (size != rust_size) { fprintf( stderr, "size of wchar_t is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"wchar_t\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"wchar_t\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_clock_t(void) { return sizeof(clock_t); } uint64_t __test_align_clock_t(void) { typedef struct { unsigned char c; clock_t v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint32_t __test_signed_clock_t(void) { return (((clock_t) -1) < 0); } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif clock_t __test_roundtrip_clock_t( clock_t value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(clock_t); if (size != rust_size) { fprintf( stderr, "size of clock_t is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"clock_t\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"clock_t\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_time_t(void) { return sizeof(time_t); } uint64_t __test_align_time_t(void) { typedef struct { unsigned char c; time_t v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint32_t __test_signed_time_t(void) { return (((time_t) -1) < 0); } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif time_t __test_roundtrip_time_t( time_t value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(time_t); if (size != rust_size) { fprintf( stderr, "size of time_t is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"time_t\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"time_t\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_off_t(void) { return sizeof(off_t); } uint64_t __test_align_off_t(void) { typedef struct { unsigned char c; off_t v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint32_t __test_signed_off_t(void) { return (((off_t) -1) < 0); } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif off_t __test_roundtrip_off_t( off_t value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(off_t); if (size != rust_size) { fprintf( stderr, "size of off_t is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"off_t\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"off_t\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_dev_t(void) { return sizeof(dev_t); } uint64_t __test_align_dev_t(void) { typedef struct { unsigned char c; dev_t v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint32_t __test_signed_dev_t(void) { return (((dev_t) -1) < 0); } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif dev_t __test_roundtrip_dev_t( dev_t value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(dev_t); if (size != rust_size) { fprintf( stderr, "size of dev_t is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"dev_t\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"dev_t\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_ino_t(void) { return sizeof(ino_t); } uint64_t __test_align_ino_t(void) { typedef struct { unsigned char c; ino_t v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint32_t __test_signed_ino_t(void) { return (((ino_t) -1) < 0); } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif ino_t __test_roundtrip_ino_t( ino_t value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(ino_t); if (size != rust_size) { fprintf( stderr, "size of ino_t is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"ino_t\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"ino_t\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_time64_t(void) { return sizeof(__time64_t); } uint64_t __test_align_time64_t(void) { typedef struct { unsigned char c; __time64_t v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint32_t __test_signed_time64_t(void) { return (((__time64_t) -1) < 0); } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif __time64_t __test_roundtrip_time64_t( __time64_t value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(__time64_t); if (size != rust_size) { fprintf( stderr, "size of __time64_t is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"time64_t\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"time64_t\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_SOCKET(void) { return sizeof(SOCKET); } uint64_t __test_align_SOCKET(void) { typedef struct { unsigned char c; SOCKET v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint32_t __test_signed_SOCKET(void) { return (((SOCKET) -1) < 0); } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif SOCKET __test_roundtrip_SOCKET( SOCKET value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(SOCKET); if (size != rust_size) { fprintf( stderr, "size of SOCKET is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"SOCKET\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"SOCKET\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_stat(void) { return sizeof(struct __stat64); } uint64_t __test_align_stat(void) { typedef struct { unsigned char c; struct __stat64 v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint64_t __test_offset_stat_st_dev(void) { return offsetof(struct __stat64, st_dev); } uint64_t __test_fsize_stat_st_dev(void) { struct __stat64* foo = NULL; return sizeof(foo->st_dev); } dev_t* __test_field_type_stat_st_dev(struct __stat64* b) { return &b->st_dev; } uint64_t __test_offset_stat_st_ino(void) { return offsetof(struct __stat64, st_ino); } uint64_t __test_fsize_stat_st_ino(void) { struct __stat64* foo = NULL; return sizeof(foo->st_ino); } ino_t* __test_field_type_stat_st_ino(struct __stat64* b) { return &b->st_ino; } uint64_t __test_offset_stat_st_mode(void) { return offsetof(struct __stat64, st_mode); } uint64_t __test_fsize_stat_st_mode(void) { struct __stat64* foo = NULL; return sizeof(foo->st_mode); } uint16_t* __test_field_type_stat_st_mode(struct __stat64* b) { return &b->st_mode; } uint64_t __test_offset_stat_st_nlink(void) { return offsetof(struct __stat64, st_nlink); } uint64_t __test_fsize_stat_st_nlink(void) { struct __stat64* foo = NULL; return sizeof(foo->st_nlink); } short* __test_field_type_stat_st_nlink(struct __stat64* b) { return &b->st_nlink; } uint64_t __test_offset_stat_st_uid(void) { return offsetof(struct __stat64, st_uid); } uint64_t __test_fsize_stat_st_uid(void) { struct __stat64* foo = NULL; return sizeof(foo->st_uid); } short* __test_field_type_stat_st_uid(struct __stat64* b) { return &b->st_uid; } uint64_t __test_offset_stat_st_gid(void) { return offsetof(struct __stat64, st_gid); } uint64_t __test_fsize_stat_st_gid(void) { struct __stat64* foo = NULL; return sizeof(foo->st_gid); } short* __test_field_type_stat_st_gid(struct __stat64* b) { return &b->st_gid; } uint64_t __test_offset_stat_st_rdev(void) { return offsetof(struct __stat64, st_rdev); } uint64_t __test_fsize_stat_st_rdev(void) { struct __stat64* foo = NULL; return sizeof(foo->st_rdev); } dev_t* __test_field_type_stat_st_rdev(struct __stat64* b) { return &b->st_rdev; } uint64_t __test_offset_stat_st_size(void) { return offsetof(struct __stat64, st_size); } uint64_t __test_fsize_stat_st_size(void) { struct __stat64* foo = NULL; return sizeof(foo->st_size); } int64_t* __test_field_type_stat_st_size(struct __stat64* b) { return &b->st_size; } uint64_t __test_offset_stat_st_atime(void) { return offsetof(struct __stat64, st_atime); } uint64_t __test_fsize_stat_st_atime(void) { struct __stat64* foo = NULL; return sizeof(foo->st_atime); } __time64_t* __test_field_type_stat_st_atime(struct __stat64* b) { return &b->st_atime; } uint64_t __test_offset_stat_st_mtime(void) { return offsetof(struct __stat64, st_mtime); } uint64_t __test_fsize_stat_st_mtime(void) { struct __stat64* foo = NULL; return sizeof(foo->st_mtime); } __time64_t* __test_field_type_stat_st_mtime(struct __stat64* b) { return &b->st_mtime; } uint64_t __test_offset_stat_st_ctime(void) { return offsetof(struct __stat64, st_ctime); } uint64_t __test_fsize_stat_st_ctime(void) { struct __stat64* foo = NULL; return sizeof(foo->st_ctime); } __time64_t* __test_field_type_stat_st_ctime(struct __stat64* b) { return &b->st_ctime; } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif struct __stat64 __test_roundtrip_stat( struct __stat64 value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(struct __stat64); if (size != rust_size) { fprintf( stderr, "size of struct __stat64 is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"stat\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"stat\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_utimbuf(void) { return sizeof(struct __utimbuf64); } uint64_t __test_align_utimbuf(void) { typedef struct { unsigned char c; struct __utimbuf64 v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint64_t __test_offset_utimbuf_actime(void) { return offsetof(struct __utimbuf64, actime); } uint64_t __test_fsize_utimbuf_actime(void) { struct __utimbuf64* foo = NULL; return sizeof(foo->actime); } __time64_t* __test_field_type_utimbuf_actime(struct __utimbuf64* b) { return &b->actime; } uint64_t __test_offset_utimbuf_modtime(void) { return offsetof(struct __utimbuf64, modtime); } uint64_t __test_fsize_utimbuf_modtime(void) { struct __utimbuf64* foo = NULL; return sizeof(foo->modtime); } __time64_t* __test_field_type_utimbuf_modtime(struct __utimbuf64* b) { return &b->modtime; } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif struct __utimbuf64 __test_roundtrip_utimbuf( struct __utimbuf64 value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(struct __utimbuf64); if (size != rust_size) { fprintf( stderr, "size of struct __utimbuf64 is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"utimbuf\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"utimbuf\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_tm(void) { return sizeof(struct tm); } uint64_t __test_align_tm(void) { typedef struct { unsigned char c; struct tm v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint64_t __test_offset_tm_tm_sec(void) { return offsetof(struct tm, tm_sec); } uint64_t __test_fsize_tm_tm_sec(void) { struct tm* foo = NULL; return sizeof(foo->tm_sec); } int* __test_field_type_tm_tm_sec(struct tm* b) { return &b->tm_sec; } uint64_t __test_offset_tm_tm_min(void) { return offsetof(struct tm, tm_min); } uint64_t __test_fsize_tm_tm_min(void) { struct tm* foo = NULL; return sizeof(foo->tm_min); } int* __test_field_type_tm_tm_min(struct tm* b) { return &b->tm_min; } uint64_t __test_offset_tm_tm_hour(void) { return offsetof(struct tm, tm_hour); } uint64_t __test_fsize_tm_tm_hour(void) { struct tm* foo = NULL; return sizeof(foo->tm_hour); } int* __test_field_type_tm_tm_hour(struct tm* b) { return &b->tm_hour; } uint64_t __test_offset_tm_tm_mday(void) { return offsetof(struct tm, tm_mday); } uint64_t __test_fsize_tm_tm_mday(void) { struct tm* foo = NULL; return sizeof(foo->tm_mday); } int* __test_field_type_tm_tm_mday(struct tm* b) { return &b->tm_mday; } uint64_t __test_offset_tm_tm_mon(void) { return offsetof(struct tm, tm_mon); } uint64_t __test_fsize_tm_tm_mon(void) { struct tm* foo = NULL; return sizeof(foo->tm_mon); } int* __test_field_type_tm_tm_mon(struct tm* b) { return &b->tm_mon; } uint64_t __test_offset_tm_tm_year(void) { return offsetof(struct tm, tm_year); } uint64_t __test_fsize_tm_tm_year(void) { struct tm* foo = NULL; return sizeof(foo->tm_year); } int* __test_field_type_tm_tm_year(struct tm* b) { return &b->tm_year; } uint64_t __test_offset_tm_tm_wday(void) { return offsetof(struct tm, tm_wday); } uint64_t __test_fsize_tm_tm_wday(void) { struct tm* foo = NULL; return sizeof(foo->tm_wday); } int* __test_field_type_tm_tm_wday(struct tm* b) { return &b->tm_wday; } uint64_t __test_offset_tm_tm_yday(void) { return offsetof(struct tm, tm_yday); } uint64_t __test_fsize_tm_tm_yday(void) { struct tm* foo = NULL; return sizeof(foo->tm_yday); } int* __test_field_type_tm_tm_yday(struct tm* b) { return &b->tm_yday; } uint64_t __test_offset_tm_tm_isdst(void) { return offsetof(struct tm, tm_isdst); } uint64_t __test_fsize_tm_tm_isdst(void) { struct tm* foo = NULL; return sizeof(foo->tm_isdst); } int* __test_field_type_tm_tm_isdst(struct tm* b) { return &b->tm_isdst; } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif struct tm __test_roundtrip_tm( struct tm value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(struct tm); if (size != rust_size) { fprintf( stderr, "size of struct tm is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"tm\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"tm\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_timeval(void) { return sizeof(struct timeval); } uint64_t __test_align_timeval(void) { typedef struct { unsigned char c; struct timeval v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint64_t __test_offset_timeval_tv_sec(void) { return offsetof(struct timeval, tv_sec); } uint64_t __test_fsize_timeval_tv_sec(void) { struct timeval* foo = NULL; return sizeof(foo->tv_sec); } long* __test_field_type_timeval_tv_sec(struct timeval* b) { return &b->tv_sec; } uint64_t __test_offset_timeval_tv_usec(void) { return offsetof(struct timeval, tv_usec); } uint64_t __test_fsize_timeval_tv_usec(void) { struct timeval* foo = NULL; return sizeof(foo->tv_usec); } long* __test_field_type_timeval_tv_usec(struct timeval* b) { return &b->tv_usec; } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif struct timeval __test_roundtrip_timeval( struct timeval value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(struct timeval); if (size != rust_size) { fprintf( stderr, "size of struct timeval is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"timeval\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"timeval\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_timespec(void) { return sizeof(struct timespec); } uint64_t __test_align_timespec(void) { typedef struct { unsigned char c; struct timespec v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint64_t __test_offset_timespec_tv_sec(void) { return offsetof(struct timespec, tv_sec); } uint64_t __test_fsize_timespec_tv_sec(void) { struct timespec* foo = NULL; return sizeof(foo->tv_sec); } time_t* __test_field_type_timespec_tv_sec(struct timespec* b) { return &b->tv_sec; } uint64_t __test_offset_timespec_tv_nsec(void) { return offsetof(struct timespec, tv_nsec); } uint64_t __test_fsize_timespec_tv_nsec(void) { struct timespec* foo = NULL; return sizeof(foo->tv_nsec); } long* __test_field_type_timespec_tv_nsec(struct timespec* b) { return &b->tv_nsec; } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif struct timespec __test_roundtrip_timespec( struct timespec value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(struct timespec); if (size != rust_size) { fprintf( stderr, "size of struct timespec is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"timespec\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"timespec\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif uint64_t __test_size_sockaddr(void) { return sizeof(struct sockaddr); } uint64_t __test_align_sockaddr(void) { typedef struct { unsigned char c; struct sockaddr v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } uint64_t __test_offset_sockaddr_sa_family(void) { return offsetof(struct sockaddr, sa_family); } uint64_t __test_fsize_sockaddr_sa_family(void) { struct sockaddr* foo = NULL; return sizeof(foo->sa_family); } unsigned short* __test_field_type_sockaddr_sa_family(struct sockaddr* b) { return &b->sa_family; } uint64_t __test_offset_sockaddr_sa_data(void) { return offsetof(struct sockaddr, sa_data); } uint64_t __test_fsize_sockaddr_sa_data(void) { struct sockaddr* foo = NULL; return sizeof(foo->sa_data); } char(*__test_field_type_sockaddr_sa_data(struct sockaddr* b))[14] { return &b->sa_data; } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif struct sockaddr __test_roundtrip_sockaddr( struct sockaddr value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(struct sockaddr); if (size != rust_size) { fprintf( stderr, "size of struct sockaddr is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"sockaddr\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"sockaddr\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif static const int __test_const_INT_MIN_val = INT_MIN; const int* __test_const_INT_MIN(void) { return &__test_const_INT_MIN_val; } static const int __test_const_INT_MAX_val = INT_MAX; const int* __test_const_INT_MAX(void) { return &__test_const_INT_MAX_val; } static const int __test_const_EXIT_FAILURE_val = EXIT_FAILURE; const int* __test_const_EXIT_FAILURE(void) { return &__test_const_EXIT_FAILURE_val; } static const int __test_const_EXIT_SUCCESS_val = EXIT_SUCCESS; const int* __test_const_EXIT_SUCCESS(void) { return &__test_const_EXIT_SUCCESS_val; } static const int __test_const_RAND_MAX_val = RAND_MAX; const int* __test_const_RAND_MAX(void) { return &__test_const_RAND_MAX_val; } static const int __test_const_EOF_val = EOF; const int* __test_const_EOF(void) { return &__test_const_EOF_val; } static const int __test_const_SEEK_SET_val = SEEK_SET; const int* __test_const_SEEK_SET(void) { return &__test_const_SEEK_SET_val; } static const int __test_const_SEEK_CUR_val = SEEK_CUR; const int* __test_const_SEEK_CUR(void) { return &__test_const_SEEK_CUR_val; } static const int __test_const_SEEK_END_val = SEEK_END; const int* __test_const_SEEK_END(void) { return &__test_const_SEEK_END_val; } static const int __test_const__IOFBF_val = _IOFBF; const int* __test_const__IOFBF(void) { return &__test_const__IOFBF_val; } static const int __test_const__IONBF_val = _IONBF; const int* __test_const__IONBF(void) { return &__test_const__IONBF_val; } static const int __test_const__IOLBF_val = _IOLBF; const int* __test_const__IOLBF(void) { return &__test_const__IOLBF_val; } static const unsigned int __test_const_BUFSIZ_val = BUFSIZ; const unsigned int* __test_const_BUFSIZ(void) { return &__test_const_BUFSIZ_val; } static const unsigned int __test_const_FOPEN_MAX_val = FOPEN_MAX; const unsigned int* __test_const_FOPEN_MAX(void) { return &__test_const_FOPEN_MAX_val; } static const unsigned int __test_const_FILENAME_MAX_val = FILENAME_MAX; const unsigned int* __test_const_FILENAME_MAX(void) { return &__test_const_FILENAME_MAX_val; } static const int __test_const_O_RDONLY_val = O_RDONLY; const int* __test_const_O_RDONLY(void) { return &__test_const_O_RDONLY_val; } static const int __test_const_O_WRONLY_val = O_WRONLY; const int* __test_const_O_WRONLY(void) { return &__test_const_O_WRONLY_val; } static const int __test_const_O_RDWR_val = O_RDWR; const int* __test_const_O_RDWR(void) { return &__test_const_O_RDWR_val; } static const int __test_const_O_APPEND_val = O_APPEND; const int* __test_const_O_APPEND(void) { return &__test_const_O_APPEND_val; } static const int __test_const_O_CREAT_val = O_CREAT; const int* __test_const_O_CREAT(void) { return &__test_const_O_CREAT_val; } static const int __test_const_O_EXCL_val = O_EXCL; const int* __test_const_O_EXCL(void) { return &__test_const_O_EXCL_val; } static const int __test_const_O_TEXT_val = O_TEXT; const int* __test_const_O_TEXT(void) { return &__test_const_O_TEXT_val; } static const int __test_const_O_BINARY_val = O_BINARY; const int* __test_const_O_BINARY(void) { return &__test_const_O_BINARY_val; } static const int __test_const_O_NOINHERIT_val = O_NOINHERIT; const int* __test_const_O_NOINHERIT(void) { return &__test_const_O_NOINHERIT_val; } static const int __test_const_O_TRUNC_val = O_TRUNC; const int* __test_const_O_TRUNC(void) { return &__test_const_O_TRUNC_val; } static const int __test_const_S_IFCHR_val = S_IFCHR; const int* __test_const_S_IFCHR(void) { return &__test_const_S_IFCHR_val; } static const int __test_const_S_IFDIR_val = S_IFDIR; const int* __test_const_S_IFDIR(void) { return &__test_const_S_IFDIR_val; } static const int __test_const_S_IFREG_val = S_IFREG; const int* __test_const_S_IFREG(void) { return &__test_const_S_IFREG_val; } static const int __test_const_S_IFMT_val = S_IFMT; const int* __test_const_S_IFMT(void) { return &__test_const_S_IFMT_val; } static const int __test_const_S_IEXEC_val = S_IEXEC; const int* __test_const_S_IEXEC(void) { return &__test_const_S_IEXEC_val; } static const int __test_const_S_IWRITE_val = S_IWRITE; const int* __test_const_S_IWRITE(void) { return &__test_const_S_IWRITE_val; } static const int __test_const_S_IREAD_val = S_IREAD; const int* __test_const_S_IREAD(void) { return &__test_const_S_IREAD_val; } static const int __test_const_LC_ALL_val = LC_ALL; const int* __test_const_LC_ALL(void) { return &__test_const_LC_ALL_val; } static const int __test_const_LC_COLLATE_val = LC_COLLATE; const int* __test_const_LC_COLLATE(void) { return &__test_const_LC_COLLATE_val; } static const int __test_const_LC_CTYPE_val = LC_CTYPE; const int* __test_const_LC_CTYPE(void) { return &__test_const_LC_CTYPE_val; } static const int __test_const_LC_MONETARY_val = LC_MONETARY; const int* __test_const_LC_MONETARY(void) { return &__test_const_LC_MONETARY_val; } static const int __test_const_LC_NUMERIC_val = LC_NUMERIC; const int* __test_const_LC_NUMERIC(void) { return &__test_const_LC_NUMERIC_val; } static const int __test_const_LC_TIME_val = LC_TIME; const int* __test_const_LC_TIME(void) { return &__test_const_LC_TIME_val; } static const int __test_const_EPERM_val = EPERM; const int* __test_const_EPERM(void) { return &__test_const_EPERM_val; } static const int __test_const_ENOENT_val = ENOENT; const int* __test_const_ENOENT(void) { return &__test_const_ENOENT_val; } static const int __test_const_ESRCH_val = ESRCH; const int* __test_const_ESRCH(void) { return &__test_const_ESRCH_val; } static const int __test_const_EINTR_val = EINTR; const int* __test_const_EINTR(void) { return &__test_const_EINTR_val; } static const int __test_const_EIO_val = EIO; const int* __test_const_EIO(void) { return &__test_const_EIO_val; } static const int __test_const_ENXIO_val = ENXIO; const int* __test_const_ENXIO(void) { return &__test_const_ENXIO_val; } static const int __test_const_E2BIG_val = E2BIG; const int* __test_const_E2BIG(void) { return &__test_const_E2BIG_val; } static const int __test_const_ENOEXEC_val = ENOEXEC; const int* __test_const_ENOEXEC(void) { return &__test_const_ENOEXEC_val; } static const int __test_const_EBADF_val = EBADF; const int* __test_const_EBADF(void) { return &__test_const_EBADF_val; } static const int __test_const_ECHILD_val = ECHILD; const int* __test_const_ECHILD(void) { return &__test_const_ECHILD_val; } static const int __test_const_EAGAIN_val = EAGAIN; const int* __test_const_EAGAIN(void) { return &__test_const_EAGAIN_val; } static const int __test_const_ENOMEM_val = ENOMEM; const int* __test_const_ENOMEM(void) { return &__test_const_ENOMEM_val; } static const int __test_const_EACCES_val = EACCES; const int* __test_const_EACCES(void) { return &__test_const_EACCES_val; } static const int __test_const_EFAULT_val = EFAULT; const int* __test_const_EFAULT(void) { return &__test_const_EFAULT_val; } static const int __test_const_EBUSY_val = EBUSY; const int* __test_const_EBUSY(void) { return &__test_const_EBUSY_val; } static const int __test_const_EEXIST_val = EEXIST; const int* __test_const_EEXIST(void) { return &__test_const_EEXIST_val; } static const int __test_const_EXDEV_val = EXDEV; const int* __test_const_EXDEV(void) { return &__test_const_EXDEV_val; } static const int __test_const_ENODEV_val = ENODEV; const int* __test_const_ENODEV(void) { return &__test_const_ENODEV_val; } static const int __test_const_ENOTDIR_val = ENOTDIR; const int* __test_const_ENOTDIR(void) { return &__test_const_ENOTDIR_val; } static const int __test_const_EISDIR_val = EISDIR; const int* __test_const_EISDIR(void) { return &__test_const_EISDIR_val; } static const int __test_const_EINVAL_val = EINVAL; const int* __test_const_EINVAL(void) { return &__test_const_EINVAL_val; } static const int __test_const_ENFILE_val = ENFILE; const int* __test_const_ENFILE(void) { return &__test_const_ENFILE_val; } static const int __test_const_EMFILE_val = EMFILE; const int* __test_const_EMFILE(void) { return &__test_const_EMFILE_val; } static const int __test_const_ENOTTY_val = ENOTTY; const int* __test_const_ENOTTY(void) { return &__test_const_ENOTTY_val; } static const int __test_const_EFBIG_val = EFBIG; const int* __test_const_EFBIG(void) { return &__test_const_EFBIG_val; } static const int __test_const_ENOSPC_val = ENOSPC; const int* __test_const_ENOSPC(void) { return &__test_const_ENOSPC_val; } static const int __test_const_ESPIPE_val = ESPIPE; const int* __test_const_ESPIPE(void) { return &__test_const_ESPIPE_val; } static const int __test_const_EROFS_val = EROFS; const int* __test_const_EROFS(void) { return &__test_const_EROFS_val; } static const int __test_const_EMLINK_val = EMLINK; const int* __test_const_EMLINK(void) { return &__test_const_EMLINK_val; } static const int __test_const_EPIPE_val = EPIPE; const int* __test_const_EPIPE(void) { return &__test_const_EPIPE_val; } static const int __test_const_EDOM_val = EDOM; const int* __test_const_EDOM(void) { return &__test_const_EDOM_val; } static const int __test_const_ERANGE_val = ERANGE; const int* __test_const_ERANGE(void) { return &__test_const_ERANGE_val; } static const int __test_const_EDEADLK_val = EDEADLK; const int* __test_const_EDEADLK(void) { return &__test_const_EDEADLK_val; } static const int __test_const_EDEADLOCK_val = EDEADLOCK; const int* __test_const_EDEADLOCK(void) { return &__test_const_EDEADLOCK_val; } static const int __test_const_ENAMETOOLONG_val = ENAMETOOLONG; const int* __test_const_ENAMETOOLONG(void) { return &__test_const_ENAMETOOLONG_val; } static const int __test_const_ENOLCK_val = ENOLCK; const int* __test_const_ENOLCK(void) { return &__test_const_ENOLCK_val; } static const int __test_const_ENOSYS_val = ENOSYS; const int* __test_const_ENOSYS(void) { return &__test_const_ENOSYS_val; } static const int __test_const_ENOTEMPTY_val = ENOTEMPTY; const int* __test_const_ENOTEMPTY(void) { return &__test_const_ENOTEMPTY_val; } static const int __test_const_EILSEQ_val = EILSEQ; const int* __test_const_EILSEQ(void) { return &__test_const_EILSEQ_val; } static const int __test_const_STRUNCATE_val = STRUNCATE; const int* __test_const_STRUNCATE(void) { return &__test_const_STRUNCATE_val; } static const int __test_const_EADDRINUSE_val = EADDRINUSE; const int* __test_const_EADDRINUSE(void) { return &__test_const_EADDRINUSE_val; } static const int __test_const_EADDRNOTAVAIL_val = EADDRNOTAVAIL; const int* __test_const_EADDRNOTAVAIL(void) { return &__test_const_EADDRNOTAVAIL_val; } static const int __test_const_EAFNOSUPPORT_val = EAFNOSUPPORT; const int* __test_const_EAFNOSUPPORT(void) { return &__test_const_EAFNOSUPPORT_val; } static const int __test_const_EALREADY_val = EALREADY; const int* __test_const_EALREADY(void) { return &__test_const_EALREADY_val; } static const int __test_const_EBADMSG_val = EBADMSG; const int* __test_const_EBADMSG(void) { return &__test_const_EBADMSG_val; } static const int __test_const_ECANCELED_val = ECANCELED; const int* __test_const_ECANCELED(void) { return &__test_const_ECANCELED_val; } static const int __test_const_ECONNABORTED_val = ECONNABORTED; const int* __test_const_ECONNABORTED(void) { return &__test_const_ECONNABORTED_val; } static const int __test_const_ECONNREFUSED_val = ECONNREFUSED; const int* __test_const_ECONNREFUSED(void) { return &__test_const_ECONNREFUSED_val; } static const int __test_const_ECONNRESET_val = ECONNRESET; const int* __test_const_ECONNRESET(void) { return &__test_const_ECONNRESET_val; } static const int __test_const_EDESTADDRREQ_val = EDESTADDRREQ; const int* __test_const_EDESTADDRREQ(void) { return &__test_const_EDESTADDRREQ_val; } static const int __test_const_EHOSTUNREACH_val = EHOSTUNREACH; const int* __test_const_EHOSTUNREACH(void) { return &__test_const_EHOSTUNREACH_val; } static const int __test_const_EIDRM_val = EIDRM; const int* __test_const_EIDRM(void) { return &__test_const_EIDRM_val; } static const int __test_const_EINPROGRESS_val = EINPROGRESS; const int* __test_const_EINPROGRESS(void) { return &__test_const_EINPROGRESS_val; } static const int __test_const_EISCONN_val = EISCONN; const int* __test_const_EISCONN(void) { return &__test_const_EISCONN_val; } static const int __test_const_ELOOP_val = ELOOP; const int* __test_const_ELOOP(void) { return &__test_const_ELOOP_val; } static const int __test_const_EMSGSIZE_val = EMSGSIZE; const int* __test_const_EMSGSIZE(void) { return &__test_const_EMSGSIZE_val; } static const int __test_const_ENETDOWN_val = ENETDOWN; const int* __test_const_ENETDOWN(void) { return &__test_const_ENETDOWN_val; } static const int __test_const_ENETRESET_val = ENETRESET; const int* __test_const_ENETRESET(void) { return &__test_const_ENETRESET_val; } static const int __test_const_ENETUNREACH_val = ENETUNREACH; const int* __test_const_ENETUNREACH(void) { return &__test_const_ENETUNREACH_val; } static const int __test_const_ENOBUFS_val = ENOBUFS; const int* __test_const_ENOBUFS(void) { return &__test_const_ENOBUFS_val; } static const int __test_const_ENODATA_val = ENODATA; const int* __test_const_ENODATA(void) { return &__test_const_ENODATA_val; } static const int __test_const_ENOLINK_val = ENOLINK; const int* __test_const_ENOLINK(void) { return &__test_const_ENOLINK_val; } static const int __test_const_ENOMSG_val = ENOMSG; const int* __test_const_ENOMSG(void) { return &__test_const_ENOMSG_val; } static const int __test_const_ENOPROTOOPT_val = ENOPROTOOPT; const int* __test_const_ENOPROTOOPT(void) { return &__test_const_ENOPROTOOPT_val; } static const int __test_const_ENOSR_val = ENOSR; const int* __test_const_ENOSR(void) { return &__test_const_ENOSR_val; } static const int __test_const_ENOSTR_val = ENOSTR; const int* __test_const_ENOSTR(void) { return &__test_const_ENOSTR_val; } static const int __test_const_ENOTCONN_val = ENOTCONN; const int* __test_const_ENOTCONN(void) { return &__test_const_ENOTCONN_val; } static const int __test_const_ENOTRECOVERABLE_val = ENOTRECOVERABLE; const int* __test_const_ENOTRECOVERABLE(void) { return &__test_const_ENOTRECOVERABLE_val; } static const int __test_const_ENOTSOCK_val = ENOTSOCK; const int* __test_const_ENOTSOCK(void) { return &__test_const_ENOTSOCK_val; } static const int __test_const_ENOTSUP_val = ENOTSUP; const int* __test_const_ENOTSUP(void) { return &__test_const_ENOTSUP_val; } static const int __test_const_EOPNOTSUPP_val = EOPNOTSUPP; const int* __test_const_EOPNOTSUPP(void) { return &__test_const_EOPNOTSUPP_val; } static const int __test_const_EOVERFLOW_val = EOVERFLOW; const int* __test_const_EOVERFLOW(void) { return &__test_const_EOVERFLOW_val; } static const int __test_const_EOWNERDEAD_val = EOWNERDEAD; const int* __test_const_EOWNERDEAD(void) { return &__test_const_EOWNERDEAD_val; } static const int __test_const_EPROTO_val = EPROTO; const int* __test_const_EPROTO(void) { return &__test_const_EPROTO_val; } static const int __test_const_EPROTONOSUPPORT_val = EPROTONOSUPPORT; const int* __test_const_EPROTONOSUPPORT(void) { return &__test_const_EPROTONOSUPPORT_val; } static const int __test_const_EPROTOTYPE_val = EPROTOTYPE; const int* __test_const_EPROTOTYPE(void) { return &__test_const_EPROTOTYPE_val; } static const int __test_const_ETIME_val = ETIME; const int* __test_const_ETIME(void) { return &__test_const_ETIME_val; } static const int __test_const_ETIMEDOUT_val = ETIMEDOUT; const int* __test_const_ETIMEDOUT(void) { return &__test_const_ETIMEDOUT_val; } static const int __test_const_ETXTBSY_val = ETXTBSY; const int* __test_const_ETXTBSY(void) { return &__test_const_ETXTBSY_val; } static const int __test_const_EWOULDBLOCK_val = EWOULDBLOCK; const int* __test_const_EWOULDBLOCK(void) { return &__test_const_EWOULDBLOCK_val; } static const int __test_const_SIGINT_val = SIGINT; const int* __test_const_SIGINT(void) { return &__test_const_SIGINT_val; } static const int __test_const_SIGILL_val = SIGILL; const int* __test_const_SIGILL(void) { return &__test_const_SIGILL_val; } static const int __test_const_SIGFPE_val = SIGFPE; const int* __test_const_SIGFPE(void) { return &__test_const_SIGFPE_val; } static const int __test_const_SIGSEGV_val = SIGSEGV; const int* __test_const_SIGSEGV(void) { return &__test_const_SIGSEGV_val; } static const int __test_const_SIGTERM_val = SIGTERM; const int* __test_const_SIGTERM(void) { return &__test_const_SIGTERM_val; } static const int __test_const_SIGABRT_val = SIGABRT; const int* __test_const_SIGABRT(void) { return &__test_const_SIGABRT_val; } static const int __test_const_NSIG_val = NSIG; const int* __test_const_NSIG(void) { return &__test_const_NSIG_val; } int (*__test_fn_isalnum(void))(int) { return isalnum; } int (*__test_fn_isalpha(void))(int) { return isalpha; } int (*__test_fn_iscntrl(void))(int) { return iscntrl; } int (*__test_fn_isdigit(void))(int) { return isdigit; } int (*__test_fn_isgraph(void))(int) { return isgraph; } int (*__test_fn_islower(void))(int) { return islower; } int (*__test_fn_isprint(void))(int) { return isprint; } int (*__test_fn_ispunct(void))(int) { return ispunct; } int (*__test_fn_isspace(void))(int) { return isspace; } int (*__test_fn_isupper(void))(int) { return isupper; } int (*__test_fn_isxdigit(void))(int) { return isxdigit; } int (*__test_fn_isblank(void))(int) { return isblank; } int (*__test_fn_tolower(void))(int) { return tolower; } int (*__test_fn_toupper(void))(int) { return toupper; } FILE* (*__test_fn_fopen(void))(const char*, const char*) { return fopen; } FILE* (*__test_fn_freopen(void))(const char*, const char*, FILE*) { return freopen; } int (*__test_fn_fflush(void))(FILE*) { return fflush; } int (*__test_fn_fclose(void))(FILE*) { return fclose; } int (*__test_fn_remove(void))(const char*) { return remove; } int (*__test_fn_rename(void))(const char*, const char*) { return rename; } FILE* (*__test_fn_tmpfile(void))(void) { return tmpfile; } int (*__test_fn_setvbuf(void))(FILE*, char*, int, size_t) { return setvbuf; } void (*__test_fn_setbuf(void))(FILE*, char*) { return setbuf; } int (*__test_fn_getchar(void))(void) { return getchar; } int (*__test_fn_putchar(void))(int) { return putchar; } int (*__test_fn_fgetc(void))(FILE*) { return fgetc; } char* (*__test_fn_fgets(void))(char*, int, FILE*) { return fgets; } int (*__test_fn_fputc(void))(int, FILE*) { return fputc; } int (*__test_fn_fputs(void))(const char*, FILE*) { return fputs; } int (*__test_fn_puts(void))(const char*) { return puts; } int (*__test_fn_ungetc(void))(int, FILE*) { return ungetc; } size_t (*__test_fn_fread(void))(void*, size_t, size_t, FILE*) { return fread; } size_t (*__test_fn_fwrite(void))(const void*, size_t, size_t, FILE*) { return fwrite; } int (*__test_fn_fseek(void))(FILE*, long, int) { return fseek; } long (*__test_fn_ftell(void))(FILE*) { return ftell; } void (*__test_fn_rewind(void))(FILE*) { return rewind; } int (*__test_fn_fgetpos(void))(FILE*, fpos_t*) { return fgetpos; } int (*__test_fn_fsetpos(void))(FILE*, const fpos_t*) { return fsetpos; } int (*__test_fn_feof(void))(FILE*) { return feof; } int (*__test_fn_ferror(void))(FILE*) { return ferror; } void (*__test_fn_perror(void))(const char*) { return perror; } int (*__test_fn_atoi(void))(const char*) { return atoi; } double (*__test_fn_strtod(void))(const char*, char* *) { return strtod; } long (*__test_fn_strtol(void))(const char*, char* *, int) { return strtol; } unsigned long (*__test_fn_strtoul(void))(const char*, char* *, int) { return strtoul; } void* (*__test_fn_calloc(void))(size_t, size_t) { return calloc; } void* (*__test_fn_malloc(void))(size_t) { return malloc; } void* (*__test_fn_realloc(void))(void*, size_t) { return realloc; } void (*__test_fn_free(void))(void*) { return free; } void (*__test_fn_abort(void))(void) { return abort; } void (*__test_fn_exit(void))(int) { return exit; } void (*__test_fn__exit(void))(int) { return _exit; } int (*__test_fn_atexit(void))(void(*)(void)) { return atexit; } int (*__test_fn_system(void))(const char*) { return system; } char* (*__test_fn_getenv(void))(const char*) { return getenv; } char* (*__test_fn_strcpy(void))(char*, const char*) { return strcpy; } char* (*__test_fn_strncpy(void))(char*, const char*, size_t) { return strncpy; } char* (*__test_fn_strcat(void))(char*, const char*) { return strcat; } char* (*__test_fn_strncat(void))(char*, const char*, size_t) { return strncat; } int (*__test_fn_strcmp(void))(const char*, const char*) { return strcmp; } int (*__test_fn_strncmp(void))(const char*, const char*, size_t) { return strncmp; } int (*__test_fn_strcoll(void))(const char*, const char*) { return strcoll; } char* (*__test_fn_strchr(void))(const char*, int) { return strchr; } char* (*__test_fn_strrchr(void))(const char*, int) { return strrchr; } size_t (*__test_fn_strspn(void))(const char*, const char*) { return strspn; } size_t (*__test_fn_strcspn(void))(const char*, const char*) { return strcspn; } char* (*__test_fn_strdup(void))(const char*) { return strdup; } char* (*__test_fn_strpbrk(void))(const char*, const char*) { return strpbrk; } char* (*__test_fn_strstr(void))(const char*, const char*) { return strstr; } size_t (*__test_fn_strlen(void))(const char*) { return strlen; } size_t (*__test_fn_strnlen(void))(const char*, size_t) { return strnlen; } char* (*__test_fn_strerror(void))(int) { return strerror; } char* (*__test_fn_strtok(void))(char*, const char*) { return strtok; } size_t (*__test_fn_strxfrm(void))(char*, const char*, size_t) { return strxfrm; } size_t (*__test_fn_wcslen(void))(const wchar_t*) { return wcslen; } size_t (*__test_fn_wcstombs(void))(char*, const wchar_t*, size_t) { return wcstombs; } void* (*__test_fn_memchr(void))(const void*, int, size_t) { return memchr; } int (*__test_fn_memcmp(void))(const void*, const void*, size_t) { return memcmp; } void* (*__test_fn_memcpy(void))(void*, const void*, size_t) { return memcpy; } void* (*__test_fn_memmove(void))(void*, const void*, size_t) { return memmove; } void* (*__test_fn_memset(void))(void*, int, size_t) { return memset; } int (*__test_fn_abs(void))(int) { return abs; } double (*__test_fn_atof(void))(const char*) { return atof; } long (*__test_fn_labs(void))( long) { return labs; } int (*__test_fn_rand(void))(void) { return rand; } void (*__test_fn_srand(void))(unsigned int) { return srand; } __p_sig_fn_t (*__test_fn_signal(void))(int, __p_sig_fn_t) { return signal; } int (*__test_fn_raise(void))(int) { return raise; } int (*__test_fn_gmtime_s(void))(struct tm*, const int64_t*) { return _gmtime64_s; } int64_t (*__test_fn_time(void))(int64_t*) { return _time64; } int (*__test_fn_chmod(void))(const char*, int) { return _chmod; } int (*__test_fn_wchmod(void))(const wchar_t*, int) { return _wchmod; } int (*__test_fn_mkdir(void))(const char*) { return _mkdir; } int (*__test_fn_wrmdir(void))(const wchar_t*) { return _wrmdir; } int (*__test_fn_fstat(void))(int, struct __stat64*) { return _fstat64; } int (*__test_fn_stat(void))(const char*, struct __stat64*) { return _stat64; } int (*__test_fn_wstat(void))(const wchar_t*, struct __stat64*) { return _wstat64; } int (*__test_fn_wutime(void))(const wchar_t*, struct __utimbuf64*) { return _wutime64; } FILE* (*__test_fn_popen(void))(const char*, const char*) { return _popen; } int (*__test_fn_pclose(void))(FILE*) { return _pclose; } FILE* (*__test_fn_fdopen(void))(int, const char*) { return _fdopen; } int (*__test_fn_fileno(void))(FILE*) { return _fileno; } int (*__test_fn_open(void))(const char*, int, ...) { return _open; } int (*__test_fn_wopen(void))(const wchar_t*, int, ...) { return _wopen; } int (*__test_fn_creat(void))(const char*, int) { return _creat; } int (*__test_fn_access(void))(const char*, int) { return _access; } int (*__test_fn_chdir(void))(const char*) { return _chdir; } int (*__test_fn_close(void))(int) { return _close; } int (*__test_fn_dup(void))(int) { return _dup; } int (*__test_fn_dup2(void))(int, int) { return _dup2; } char* (*__test_fn_getcwd(void))(char*, int) { return _getcwd; } int (*__test_fn_getpid(void))(void) { return _getpid; } int (*__test_fn_isatty(void))(int) { return _isatty; } long (*__test_fn_lseek(void))(int, long, int) { return _lseek; } long long (*__test_fn_lseek64(void))(int, long long, int) { return _lseeki64; } int (*__test_fn_pipe(void))(int*, unsigned int, int) { return _pipe; } int (*__test_fn_read(void))(int, void*, unsigned int) { return _read; } int (*__test_fn_rmdir(void))(const char*) { return _rmdir; } int (*__test_fn_unlink(void))(const char*) { return _unlink; } int (*__test_fn_write(void))(int, const void*, unsigned int) { return _write; } int (*__test_fn_commit(void))(int) { return _commit; } intptr_t (*__test_fn_get_osfhandle(void))(int) { return _get_osfhandle; } int (*__test_fn_open_osfhandle(void))(intptr_t, int) { return _open_osfhandle; } char* (*__test_fn_setlocale(void))(int, const char*) { return setlocale; } wchar_t* (*__test_fn_wsetlocale(void))(int, const wchar_t*) { return _wsetlocale; } int (__stdcall *__test_fn_listen(void))(SOCKET, int) { return listen; } SOCKET (__stdcall *__test_fn_accept(void))(SOCKET, struct sockaddr*, int*) { return accept; } int (__stdcall *__test_fn_bind(void))(SOCKET, const struct sockaddr*, int) { return bind; } int (__stdcall *__test_fn_connect(void))(SOCKET, const struct sockaddr*, int) { return connect; } int (__stdcall *__test_fn_getpeername(void))(SOCKET, struct sockaddr*, int*) { return getpeername; } int (__stdcall *__test_fn_getsockname(void))(SOCKET, struct sockaddr*, int*) { return getsockname; } int (__stdcall *__test_fn_getsockopt(void))(SOCKET, int, int, char*, int*) { return getsockopt; } int (__stdcall *__test_fn_recvfrom(void))(SOCKET, char*, int, int, struct sockaddr*, int*) { return recvfrom; } int (__stdcall *__test_fn_sendto(void))(SOCKET, const char*, int, int, const struct sockaddr*, int) { return sendto; } int (__stdcall *__test_fn_setsockopt(void))(SOCKET, int, int, const char*, int) { return setsockopt; } SOCKET (__stdcall *__test_fn_socket(void))(int, int, int) { return socket; } static const unsigned int __test_const_L_tmpnam_val = L_tmpnam; const unsigned int* __test_const_L_tmpnam(void) { return &__test_const_L_tmpnam_val; } static const unsigned int __test_const_TMP_MAX_val = TMP_MAX; const unsigned int* __test_const_TMP_MAX(void) { return &__test_const_TMP_MAX_val; } static const int __test_const_STDIN_FILENO_val = STDIN_FILENO; const int* __test_const_STDIN_FILENO(void) { return &__test_const_STDIN_FILENO_val; } static const int __test_const_STDOUT_FILENO_val = STDOUT_FILENO; const int* __test_const_STDOUT_FILENO(void) { return &__test_const_STDOUT_FILENO_val; } static const int __test_const_STDERR_FILENO_val = STDERR_FILENO; const int* __test_const_STDERR_FILENO(void) { return &__test_const_STDERR_FILENO_val; } int (*__test_fn_strcasecmp(void))(const char*, const char*) { return strcasecmp; } int (*__test_fn_strncasecmp(void))(const char*, const char*, size_t) { return strncasecmp; } wchar_t* (*__test_fn_wmemchr(void))(const wchar_t*, wchar_t, size_t) { return wmemchr; } uint64_t __test_size_max_align_t(void) { return sizeof(max_align_t); } uint64_t __test_align_max_align_t(void) { typedef struct { unsigned char c; max_align_t v; } type; type t; size_t t_addr = (size_t)(unsigned char*)(&t); size_t v_addr = (size_t)(unsigned char*)(&t.v); return t_addr >= v_addr? t_addr - v_addr : v_addr - t_addr; } #ifdef _MSC_VER // Disable signed/unsigned conversion warnings on MSVC. // These trigger even if the conversion is explicit. # pragma warning(disable:4365) #endif max_align_t __test_roundtrip_max_align_t( max_align_t value, int32_t rust_size, int* error, unsigned char* pad ) { volatile unsigned char* p = (volatile unsigned char*)&value; int size = (int)sizeof(max_align_t); if (size != rust_size) { fprintf( stderr, "size of max_align_t is %d in C and %d in Rust\n", (int)size, (int)rust_size ); *error = 1; return value; } int i = 0; for (i = 0; i < size; ++i) { if (pad[i]) { continue; } // fprintf(stdout, "C testing byte %d of %d of \"max_align_t\"\n", i, size); unsigned char c = (unsigned char)(i % 256); c = c == 0? 42 : c; if (p[i] != c) { *error = 1; fprintf( stderr, "rust[%d] = %d != %d (C): Rust \"max_align_t\" -> C\n", i, (int)p[i], (int)c ); } unsigned char d = (unsigned char)(255) - (unsigned char)(i % 256); d = d == 0? 42: d; p[i] = d; } return value; } #ifdef _MSC_VER # pragma warning(default:4365) #endif