diff --git a/lib/std/core/private/main_stub.c3 b/lib/std/core/private/main_stub.c3 index 1226702de..6b27a4709 100644 --- a/lib/std/core/private/main_stub.c3 +++ b/lib/std/core/private/main_stub.c3 @@ -52,7 +52,7 @@ macro int @main_to_void_main_args(#m, int argc, char** argv) $if (env::OS_TYPE == OsType.WIN32): -extern fn Char16** _win_command_line_to_argv_w(ushort* cmd_line, int* argc_ptr) @extname("CommandLineToArgvW"); +extern fn Char16** _win_command_line_to_argv_w(ushort* cmd_line, int* argc_ptr) @extern("CommandLineToArgvW"); private macro String[] win_command_line_to_strings(ushort* cmd_line) { diff --git a/lib/std/core/runtime.c3 b/lib/std/core/runtime.c3 index b7ed3632d..af2ec9d04 100644 --- a/lib/std/core/runtime.c3 +++ b/lib/std/core/runtime.c3 @@ -101,7 +101,7 @@ fn bool __run_default_test_runner() $if (!env::COMPILER_LIBC_AVAILABLE && env::ARCH_TYPE == ArchType.WASM32 || env::ARCH_TYPE == ArchType.WASM64): extern fn void __wasm_call_ctors(); -fn void wasm_initialize() @extname("_initialize") @wasm +fn void wasm_initialize() @extern("_initialize") @wasm { // The linker synthesizes this to call constructors. __wasm_call_ctors(); diff --git a/lib/std/io/io_fileinfo.c3 b/lib/std/io/io_fileinfo.c3 index 7bfcca28e..187839b83 100644 --- a/lib/std/io/io_fileinfo.c3 +++ b/lib/std/io/io_fileinfo.c3 @@ -37,7 +37,7 @@ private struct Darwin64Stat int st_lspare; long[2] st_qspare; } -extern fn int _stat(ZString str, Darwin64Stat* stat) @extname("stat64"); +extern fn int _stat(ZString str, Darwin64Stat* stat) @extern("stat64"); fn void! FileInfo.read(FileInfo* info, Path path) { @pool() diff --git a/lib/std/io/os/getcwd.c3 b/lib/std/io/os/getcwd.c3 index cfe8f123d..e14b24ad5 100644 --- a/lib/std/io/os/getcwd.c3 +++ b/lib/std/io/os/getcwd.c3 @@ -32,7 +32,7 @@ macro String! getcwd(Allocator* allocator = mem::default_allocator()) $else: -extern fn ZString _getcwd(char* pwd, usz len) @extname("getcwd"); +extern fn ZString _getcwd(char* pwd, usz len) @extern("getcwd"); macro String! getcwd(Allocator* allocator = mem::default_allocator()) { const usz DEFAULT_BUFFER = 256; diff --git a/lib/std/libc/libc.c3 b/lib/std/libc/libc.c3 index 6168b8eb8..69aa23d47 100644 --- a/lib/std/libc/libc.c3 +++ b/lib/std/libc/libc.c3 @@ -98,46 +98,46 @@ extern fn void* realloc(void* ptr, usz size); $else: -fn void longjmp(JmpBuf* buffer, CInt value) @weak @extname("longjmp") +fn void longjmp(JmpBuf* buffer, CInt value) @weak @extern("longjmp") { unreachable("longjmp unavailable"); } -fn CInt setjmp(JmpBuf* buffer) @weak @extname("setjmp") +fn CInt setjmp(JmpBuf* buffer) @weak @extern("setjmp") { unreachable("setjmp unavailable"); } -fn void* malloc(usz size) @weak @extname("malloc") +fn void* malloc(usz size) @weak @extern("malloc") { unreachable("malloc unavailable"); } -fn void* calloc(usz count, usz size) @weak @extname("calloc") +fn void* calloc(usz count, usz size) @weak @extern("calloc") { unreachable("calloc unavailable"); } -fn void* free(void*) @weak @extname("free") +fn void* free(void*) @weak @extern("free") { unreachable("free unavailable"); } -fn void* realloc(void* ptr, usz size) @weak @extname("realloc") +fn void* realloc(void* ptr, usz size) @weak @extern("realloc") { unreachable("realloc unavailable"); } -fn void* memcpy(void* dest, void* src, usz n) @weak @extname("memcpy") +fn void* memcpy(void* dest, void* src, usz n) @weak @extern("memcpy") { for (usz i = 0; i < n; i++) ((char*)dest)[i] = ((char*)src)[i]; return dest; } -fn void* memmove(void* dest, void* src, usz n) @weak @extname("memmove") +fn void* memmove(void* dest, void* src, usz n) @weak @extern("memmove") { return memcpy(dest, src, n) @inline; } -fn void* memset(void* dest, CInt value, usz n) @weak @extname("memset") +fn void* memset(void* dest, CInt value, usz n) @weak @extern("memset") { for (usz i = 0; i < n; i++) ((char*)dest)[i] = (char)value; return dest; @@ -151,9 +151,9 @@ define Fpos = long; define CFile = void*; $if (env::COMPILER_LIBC_AVAILABLE && env::OS_TYPE == OsType.LINUX): - extern CFile __stdin @extname("stdin"); - extern CFile __stdout @extname("stdout"); - extern CFile __stderr @extname("stderr"); + extern CFile __stdin @extern("stdin"); + extern CFile __stdout @extern("stdout"); + extern CFile __stderr @extern("stderr"); extern fn usz malloc_usable_size(void* ptr); macro usz malloc_size(void* ptr) { return malloc_usable_size(ptr); } extern fn void* aligned_alloc(usz align, usz size); @@ -245,64 +245,64 @@ extern fn isz getline(char** linep, usz* linecapp, CFile stream); $else: -fn int fseek(CFile stream, SeekIndex offset, int whence) @weak @extname("fseek") +fn int fseek(CFile stream, SeekIndex offset, int whence) @weak @extern("fseek") { unreachable("'fseek' not available."); } -fn CFile fopen(char* filename, char* mode) @weak @extname("fopen") +fn CFile fopen(char* filename, char* mode) @weak @extern("fopen") { unreachable("'fopen' not available."); } -fn usz fwrite(void* ptr, usz size, usz nmemb, CFile stream) @weak @extname("fwrite") +fn usz fwrite(void* ptr, usz size, usz nmemb, CFile stream) @weak @extern("fwrite") { unreachable("'fwrite' not available."); } -fn usz fread(void* ptr, usz size, usz nmemb, CFile stream) @weak @extname("fread") +fn usz fread(void* ptr, usz size, usz nmemb, CFile stream) @weak @extern("fread") { unreachable("'fread' not available."); } -fn CFile fclose(CFile) @weak @extname("fclose") +fn CFile fclose(CFile) @weak @extern("fclose") { unreachable("'fclose' not available."); } -fn int fflush(CFile stream) @weak @extname("fflush") +fn int fflush(CFile stream) @weak @extern("fflush") { unreachable("'fflush' not available."); } -fn int fputc(int c, CFile stream) @weak @extname("fputc") +fn int fputc(int c, CFile stream) @weak @extern("fputc") { unreachable("'fputc' not available."); } -fn char* fgets(char* str, int n, CFile stream) @weak @extname("fgets") +fn char* fgets(char* str, int n, CFile stream) @weak @extern("fgets") { unreachable("'fgets' not available."); } -fn int fgetc(CFile stream) @weak @extname("fgetc") +fn int fgetc(CFile stream) @weak @extern("fgetc") { unreachable("'fgetc' not available."); } -fn int feof(CFile stream) @weak @extname("feof") +fn int feof(CFile stream) @weak @extern("feof") { unreachable("'feof' not available."); } -fn int putc(int c, CFile stream) @weak @extname("putc") +fn int putc(int c, CFile stream) @weak @extern("putc") { unreachable("'putc' not available."); } -fn int putchar(int c) @weak @extname("putchar") +fn int putchar(int c) @weak @extern("putchar") { unreachable("'putchar' not available."); } -fn int puts(char* str) @weak @extname("puts") +fn int puts(char* str) @weak @extern("puts") { unreachable("'puts' not available."); } diff --git a/lib/std/math/math.c3 b/lib/std/math/math.c3 index 4c3e1ab29..8a0e7a937 100644 --- a/lib/std/math/math.c3 +++ b/lib/std/math/math.c3 @@ -635,11 +635,11 @@ macro is_nan(x) } -extern fn double _atan(double x) @extname("atan"); -extern fn float _atanf(float x) @extname("atanf"); -extern fn double _atan2(double, double) @extname("atan2"); -extern fn float _atan2f(float, float) @extname("atan2f"); -extern fn void _sincos(double, double*) @extname("sincos"); -extern fn void _sincosf(float, float*) @extname("sincosf"); +extern fn double _atan(double x) @extern("atan"); +extern fn float _atanf(float x) @extern("atanf"); +extern fn double _atan2(double, double) @extern("atan2"); +extern fn float _atan2f(float, float) @extern("atan2f"); +extern fn void _sincos(double, double*) @extern("sincos"); +extern fn void _sincosf(float, float*) @extern("sincosf"); extern fn void _tan(double x, double y) @extern("tan"); extern fn void _tanf(double x, double y) @extern("tanf"); \ No newline at end of file diff --git a/lib/std/math/math_builtin.c3 b/lib/std/math/math_builtin.c3 index 908e88c03..9ea8a8cd2 100644 --- a/lib/std/math/math_builtin.c3 +++ b/lib/std/math/math_builtin.c3 @@ -1,12 +1,12 @@ module std::math; -fn float __roundevenf(float f) @extname("roundevenf") @weak +fn float __roundevenf(float f) @extern("roundevenf") @weak { // Slow implementation return round(f / 2) * 2; } -fn double __roundeven(double d) @extname("roundeven") @weak +fn double __roundeven(double d) @extern("roundeven") @weak { // Slow implementation return round(d / 2) * 2; diff --git a/lib/std/math/math_i128.c3 b/lib/std/math/math_i128.c3 index 33412c56b..81b27a14b 100644 --- a/lib/std/math/math_i128.c3 +++ b/lib/std/math/math_i128.c3 @@ -1,6 +1,6 @@ module std::math; -fn int128 __divti3(int128 a, int128 b) @extname("__divti3") @weak +fn int128 __divti3(int128 a, int128 b) @extern("__divti3") @weak { int128 sign_a = a >> 127; // -1 : 0 int128 sign_b = b >> 127; // -1 : 0 @@ -10,7 +10,7 @@ fn int128 __divti3(int128 a, int128 b) @extname("__divti3") @weak return __udivti3(unsigned_a, unsigned_b) @inline ^ sign_a + (-sign_a); } -fn uint128 __umodti3(uint128 n, uint128 d) @extname("__umodti3") @weak +fn uint128 __umodti3(uint128 n, uint128 d) @extern("__umodti3") @weak { // Ignore d = 0 uint128 sr = (d ? $$clz(d) : 128) - (n ? $$clz(n) : 128); @@ -34,7 +34,7 @@ fn uint128 __umodti3(uint128 n, uint128 d) @extname("__umodti3") @weak return r; } -fn uint128 __udivti3(uint128 n, uint128 d) @extname("__udivti3") @weak +fn uint128 __udivti3(uint128 n, uint128 d) @extern("__udivti3") @weak { // Ignore d = 0 uint128 sr = (d ? $$clz(d) : 128) - (n ? $$clz(n) : 128); @@ -60,7 +60,7 @@ fn uint128 __udivti3(uint128 n, uint128 d) @extname("__udivti3") @weak return n; } -fn int128 __modti3(int128 a, int128 b) @extname("__modti3") @weak +fn int128 __modti3(int128 a, int128 b) @extern("__modti3") @weak { int128 sign = b >> 127; uint128 unsigned_b = (uint128)(b ^ sign) + (-sign); @@ -83,7 +83,7 @@ private union Int128bits uint128 all; } -fn uint128 __lshrti3(uint128 a, uint b) @extname("__lshrti3") @weak +fn uint128 __lshrti3(uint128 a, uint b) @extern("__lshrti3") @weak { Int128bits result; result.all = a; @@ -167,14 +167,14 @@ fn int128 __multi3(int128 a, int128 b) @extern("__multi3") @weak return r.all; } -fn float __floattisf(int128 a) @extname("__floattisf") @weak => float_from_i128(float, a); -fn double __floattidf(int128 a) @extname("__floattidf") @weak => float_from_i128(double, a); -fn float __floatuntisf(uint128 a) @extname("__floatuntisf") @weak => float_from_u128(float, a); -fn double __floatuntidf(uint128 a) @extname("__floatuntidf") @weak => float_from_u128(double, a); -fn uint128 __fixunsdfti(double a) @weak @extname("__fixunsdfti") => fixuint(a); -fn uint128 __fixunssfti(float a) @weak @extname("__fixunssfti") => fixuint(a); -fn int128 __fixdfti(double a) @weak @extname("__fixdfti") => fixint(a); -fn int128 __fixsfti(float a) @weak @extname("__fixsfti") => fixint(a); +fn float __floattisf(int128 a) @extern("__floattisf") @weak => float_from_i128(float, a); +fn double __floattidf(int128 a) @extern("__floattidf") @weak => float_from_i128(double, a); +fn float __floatuntisf(uint128 a) @extern("__floatuntisf") @weak => float_from_u128(float, a); +fn double __floatuntidf(uint128 a) @extern("__floatuntidf") @weak => float_from_u128(double, a); +fn uint128 __fixunsdfti(double a) @weak @extern("__fixunsdfti") => fixuint(a); +fn uint128 __fixunssfti(float a) @weak @extern("__fixunssfti") => fixuint(a); +fn int128 __fixdfti(double a) @weak @extern("__fixdfti") => fixint(a); +fn int128 __fixsfti(float a) @weak @extern("__fixsfti") => fixint(a); private macro float_from_i128($Type, a) diff --git a/lib/std/math/math_nolibc/atan.c3 b/lib/std/math/math_nolibc/atan.c3 index 4be905c7e..a015d531e 100644 --- a/lib/std/math/math_nolibc/atan.c3 +++ b/lib/std/math/math_nolibc/atan.c3 @@ -30,7 +30,7 @@ private const double[*] AT = { 1.62858201153657823623e-02, /* 0x3F90AD3A, 0xE322DA11 */ }; -fn double _atan(double x) @weak @extname("atan") +fn double _atan(double x) @weak @extern("atan") { int id = void; uint ix = x.high_word(); @@ -113,7 +113,7 @@ private const float[*] ATF = { 6.1687607318e-02, }; -fn float _atanf(float x) @weak @extname("atanf") +fn float _atanf(float x) @weak @extern("atanf") { int id = void; uint ix = x.word(); @@ -186,7 +186,7 @@ private macro void extract_words(double d, uint* hi, uint* lo) *lo = (uint)rep; } -fn double _atan2(double y, double x) @weak @extname("atan2") +fn double _atan2(double y, double x) @weak @extern("atan2") { if (math::is_nan(x) || math::is_nan(y)) return x + y; @@ -257,7 +257,7 @@ fn double _atan2(double y, double x) @weak @extname("atan2") private const float PI_F = 3.1415927410e+00; /* 0x40490fdb */ private const float PI_LO_F = -8.7422776573e-08; /* 0xb3bbbd2e */ -fn float _atan2f(float y, float x) @weak @extname("atan2f") +fn float _atan2f(float y, float x) @weak @extern("atan2f") { if (math::is_nan(x) || math::is_nan(y)) return x + y; uint ix = bitcast(x, uint); diff --git a/lib/std/math/math_nolibc/ceil.c3 b/lib/std/math/math_nolibc/ceil.c3 index 91645ab5d..3f648b196 100644 --- a/lib/std/math/math_nolibc/ceil.c3 +++ b/lib/std/math/math_nolibc/ceil.c3 @@ -2,7 +2,7 @@ module std::math::nolibc; $if (!env::COMPILER_LIBC_AVAILABLE): -fn double _ceil(double x) @weak @extname("ceil") +fn double _ceil(double x) @weak @extern("ceil") { ulong ui = bitcast(x, ulong); int e = (int)((ui >> 52) & 0x7ff); @@ -19,7 +19,7 @@ fn double _ceil(double x) @weak @extname("ceil") } -fn float _ceilf(float x) @weak @extname("ceilf") +fn float _ceilf(float x) @weak @extern("ceilf") { uint u = bitcast(x, uint); int e = (int)((u >> 23) & 0xff) - 0x7f; diff --git a/lib/std/math/math_nolibc/floor.c3 b/lib/std/math/math_nolibc/floor.c3 index f79a31d92..9c9f5be32 100644 --- a/lib/std/math/math_nolibc/floor.c3 +++ b/lib/std/math/math_nolibc/floor.c3 @@ -2,7 +2,7 @@ module std::math::nolibc; $if (!env::COMPILER_LIBC_AVAILABLE): -fn double _floor(double x) @weak @extname("floor") +fn double _floor(double x) @weak @extern("floor") { ulong ui = bitcast(x, ulong); int e = (int)((ui >> 52) & 0x7ff); @@ -19,7 +19,7 @@ fn double _floor(double x) @weak @extname("floor") } -fn float _floorf(float x) @weak @extname("floorf") +fn float _floorf(float x) @weak @extern("floorf") { uint u = bitcast(x, uint); int e = (int)((u >> 23) & 0xff) - 0x7f; diff --git a/lib/std/math/math_nolibc/pow.c3 b/lib/std/math/math_nolibc/pow.c3 index 0bce44d17..c64cd6392 100644 --- a/lib/std/math/math_nolibc/pow.c3 +++ b/lib/std/math/math_nolibc/pow.c3 @@ -2,12 +2,12 @@ module std::math::nolibc; $if (!env::COMPILER_LIBC_AVAILABLE): -fn float powf_broken(float x, float f) @extname("powf") @weak +fn float powf_broken(float x, float f) @extern("powf") @weak { unreachable("'powf' not supported"); } -fn double pow_broken(double x, double y) @extname("pow") @weak +fn double pow_broken(double x, double y) @extern("pow") @weak { unreachable("'pow' not supported"); } diff --git a/lib/std/math/math_nolibc/round.c3 b/lib/std/math/math_nolibc/round.c3 index a527f019b..e320d227a 100644 --- a/lib/std/math/math_nolibc/round.c3 +++ b/lib/std/math/math_nolibc/round.c3 @@ -2,7 +2,7 @@ module std::math::nolibc; $if (!env::COMPILER_LIBC_AVAILABLE): -fn double _round(double x) @extname("round") @weak +fn double _round(double x) @extern("round") @weak { ulong u = bitcast(x, ulong); int e = (int)((u >> 52) & 0x7ff); @@ -28,7 +28,7 @@ fn double _round(double x) @extname("round") @weak return y; } -fn float _roundf(float x) @extname("roundf") @weak +fn float _roundf(float x) @extern("roundf") @weak { uint u = bitcast(x, uint); int e = (u >> 23) & 0xff; diff --git a/lib/std/math/math_nolibc/scalbn.c3 b/lib/std/math/math_nolibc/scalbn.c3 index 32a310790..a8c390934 100644 --- a/lib/std/math/math_nolibc/scalbn.c3 +++ b/lib/std/math/math_nolibc/scalbn.c3 @@ -2,7 +2,7 @@ module std::math::nolibc; $if (!env::COMPILER_LIBC_AVAILABLE): -fn double _scalbn(double x, int n) @weak @extname("scalbn") +fn double _scalbn(double x, int n) @weak @extern("scalbn") { switch { diff --git a/lib/std/math/math_nolibc/sin.c3 b/lib/std/math/math_nolibc/sin.c3 index 2e642fb6c..1d75fd301 100644 --- a/lib/std/math/math_nolibc/sin.c3 +++ b/lib/std/math/math_nolibc/sin.c3 @@ -18,7 +18,7 @@ $if (!env::COMPILER_LIBC_AVAILABLE): * ==================================================== */ -fn float _sinf(float x) @weak @extname("sinf") +fn float _sinf(float x) @weak @extern("sinf") { uint ix = bitcast(x, uint); int sign = ix >> 31; diff --git a/lib/std/math/math_nolibc/trig.c3 b/lib/std/math/math_nolibc/trig.c3 index 77b46caff..39aa6b131 100644 --- a/lib/std/math/math_nolibc/trig.c3 +++ b/lib/std/math/math_nolibc/trig.c3 @@ -2,7 +2,7 @@ module std::math::nolibc::trig; $if (!env::COMPILER_LIBC_AVAILABLE): -fn double sincos_broken(double x) @extname("sincos") @weak +fn double sincos_broken(double x) @extern("sincos") @weak { unreachable("'sinccos' not supported"); } diff --git a/lib/std/math/math_nolibc/trunc.c3 b/lib/std/math/math_nolibc/trunc.c3 index c72a9c7e0..e108a6359 100644 --- a/lib/std/math/math_nolibc/trunc.c3 +++ b/lib/std/math/math_nolibc/trunc.c3 @@ -2,7 +2,7 @@ module std::math::nolibc; $if (!env::COMPILER_LIBC_AVAILABLE): -fn double _trunc(double x) @weak @extname("trunc") +fn double _trunc(double x) @weak @extern("trunc") { ulong i = bitcast(x, ulong); int e = (int)((i >> 52) & 0x7ff) - 0x3ff + 12; @@ -15,7 +15,7 @@ fn double _trunc(double x) @weak @extname("trunc") return bitcast(i, double); } -fn float _truncf(float x) @weak @extname("truncf") +fn float _truncf(float x) @weak @extern("truncf") { uint i = bitcast(x, uint); int e = (int)((i >> 23) & 0xff) - 0x7f + 9; diff --git a/lib/std/net/os/posix.c3 b/lib/std/net/os/posix.c3 index 8f0971f4e..2d3341541 100644 --- a/lib/std/net/os/posix.c3 +++ b/lib/std/net/os/posix.c3 @@ -8,11 +8,11 @@ const int F_SETFL = 4; define NativeSocket = distinct int; -extern fn NativeSocket socket(int af, int type, int protocol) @extname("socket"); +extern fn NativeSocket socket(int af, int type, int protocol) @extern("socket"); extern fn int getaddrinfo(ZString nodename, ZString servname, AddrInfo* hints, AddrInfo** res); extern fn void freeaddrinfo(AddrInfo* addr); extern fn int connect(NativeSocket, void*, usz); -extern fn int fcntl(NativeSocket socket, int cmd, ...) @extname("fcntl"); +extern fn int fcntl(NativeSocket socket, int cmd, ...) @extern("fcntl"); extern fn int close(NativeSocket); macro void! NativeSocket.close(NativeSocket this) diff --git a/lib/std/net/os/win32.c3 b/lib/std/net/os/win32.c3 index 162572a66..3965c2171 100644 --- a/lib/std/net/os/win32.c3 +++ b/lib/std/net/os/win32.c3 @@ -24,7 +24,7 @@ struct AddrInfo define NativeSocket = distinct uptr; -extern fn int wsa_startup(int, void*) @extname("WSAStartup"); +extern fn int wsa_startup(int, void*) @extern("WSAStartup"); extern fn int ioctlsocket(NativeSocket, long cmd, ulong *argp); extern fn int closesocket(NativeSocket); diff --git a/lib/std/os/macos/cf_allocator.c3 b/lib/std/os/macos/cf_allocator.c3 index a2372cfeb..2c7e11e2b 100644 --- a/lib/std/os/macos/cf_allocator.c3 +++ b/lib/std/os/macos/cf_allocator.c3 @@ -12,10 +12,10 @@ macro void* CFAllocatorRef.alloc(CFAllocatorRef allocator, usz size) => _macos_C macro usz CFAllocatorRef.get_preferred_size(CFAllocatorRef allocator, usz req_size) => _macos_CFAllocatorGetPreferredSizeForSize(allocator, req_size, 0); macro void CFAllocatorRef.set_default(CFAllocatorRef allocator) => _macos_CFAllocatorSetDefault(allocator); -extern fn CFAllocatorRef _macos_CFAllocatorCreate(CFAllocatorRef allocator, CFAllocatorContextRef context) @extname("CFAllocatorCreate"); -extern fn void _macos_CFAllocatorDeallocate(CFAllocatorRef allocator, void* ptr) @extname("CFAllocatorDeallocate"); -extern fn CFAllocatorRef _macos_CFAllocatorGetDefault() @extname("CFAllocatorGetDefault"); -extern fn void _macos_CFAllocatorSetDefault(CFAllocatorRef allocator) @extname("CFAllocatorSetDefault"); -extern fn void* _macos_CFAllocatorAllocate(CFAllocatorRef allocator, CFIndex size, CFOptionFlags hint) @extname("CFAllocatorAllocate"); -extern fn CFIndex _macos_CFAllocatorGetPreferredSizeForSize(CFAllocatorRef allocator, CFIndex size, CFOptionFlags hint) @extname("CFAllocatorGetPreferredSizeForSize"); +extern fn CFAllocatorRef _macos_CFAllocatorCreate(CFAllocatorRef allocator, CFAllocatorContextRef context) @extern("CFAllocatorCreate"); +extern fn void _macos_CFAllocatorDeallocate(CFAllocatorRef allocator, void* ptr) @extern("CFAllocatorDeallocate"); +extern fn CFAllocatorRef _macos_CFAllocatorGetDefault() @extern("CFAllocatorGetDefault"); +extern fn void _macos_CFAllocatorSetDefault(CFAllocatorRef allocator) @extern("CFAllocatorSetDefault"); +extern fn void* _macos_CFAllocatorAllocate(CFAllocatorRef allocator, CFIndex size, CFOptionFlags hint) @extern("CFAllocatorAllocate"); +extern fn CFIndex _macos_CFAllocatorGetPreferredSizeForSize(CFAllocatorRef allocator, CFIndex size, CFOptionFlags hint) @extern("CFAllocatorGetPreferredSizeForSize"); $endif; \ No newline at end of file diff --git a/lib/std/os/macos/cf_array.c3 b/lib/std/os/macos/cf_array.c3 index 3eef22ec8..fe39b456a 100644 --- a/lib/std/os/macos/cf_array.c3 +++ b/lib/std/os/macos/cf_array.c3 @@ -5,10 +5,10 @@ $if (env::OS_TYPE == OsType.MACOSX): define CFArrayRef = distinct void*; define CFArrayCallBacksRef = distinct void*; define CFMutableArrayRef = distinct void*; -extern fn CFArrayRef _macos_CFArrayCreate(CFAllocatorRef allocator, void** values, CFIndex num_values, CFArrayCallBacksRef callBacks) @extname("CFArrayCreate"); -extern fn CFArrayRef _macos_CFArrayCopy(CFAllocatorRef allocator, CFArrayRef array) @extname("CFArrayCopy"); -extern fn CFIndex _macos_CFArrayGetCount(CFArrayRef array) @extname("CFArrayGetCount"); -extern fn void _macos_CFArrayAppendArray(CFMutableArrayRef theArray, CFArrayRef otherArray, CFRange otherRange) @extname("CFArrayAppendArray"); -extern fn CFMutableArrayRef _macos_CFArrayCreateMutable(CFAllocatorRef allocator, CFIndex capacity, CFArrayCallBacksRef callBacks) @extname("CFArrayCreateMutable"); -extern fn void _macos_CFArrayAppendValue(CFMutableArrayRef theArray, void *value) @extname("CFArrayAppendValue"); +extern fn CFArrayRef _macos_CFArrayCreate(CFAllocatorRef allocator, void** values, CFIndex num_values, CFArrayCallBacksRef callBacks) @extern("CFArrayCreate"); +extern fn CFArrayRef _macos_CFArrayCopy(CFAllocatorRef allocator, CFArrayRef array) @extern("CFArrayCopy"); +extern fn CFIndex _macos_CFArrayGetCount(CFArrayRef array) @extern("CFArrayGetCount"); +extern fn void _macos_CFArrayAppendArray(CFMutableArrayRef theArray, CFArrayRef otherArray, CFRange otherRange) @extern("CFArrayAppendArray"); +extern fn CFMutableArrayRef _macos_CFArrayCreateMutable(CFAllocatorRef allocator, CFIndex capacity, CFArrayCallBacksRef callBacks) @extern("CFArrayCreateMutable"); +extern fn void _macos_CFArrayAppendValue(CFMutableArrayRef theArray, void *value) @extern("CFArrayAppendValue"); $endif; \ No newline at end of file diff --git a/lib/std/os/macos/core_foundation.c3 b/lib/std/os/macos/core_foundation.c3 index f562bbb24..f44dd114c 100644 --- a/lib/std/os/macos/core_foundation.c3 +++ b/lib/std/os/macos/core_foundation.c3 @@ -10,7 +10,7 @@ struct CFRange CFIndex length; } -extern fn CFTypeRef _macos_CFRetain(CFTypeRef cf) @extname("CFRetain"); -extern fn void _macos_CFRelease(CFTypeRef cf) @extname("CFRelease"); +extern fn CFTypeRef _macos_CFRetain(CFTypeRef cf) @extern("CFRetain"); +extern fn void _macos_CFRelease(CFTypeRef cf) @extern("CFRelease"); $endif; \ No newline at end of file diff --git a/lib/std/os/macos/objc.c3 b/lib/std/os/macos/objc.c3 index 784a78859..d80d3d1ad 100644 --- a/lib/std/os/macos/objc.c3 +++ b/lib/std/os/macos/objc.c3 @@ -37,13 +37,13 @@ macro Class[] class_get_list(Allocator *allocator = mem::current_allocator()) return entries; } -extern fn Class _macos_objc_getClass(char* name) @extname("objc_getClass"); -extern fn int _macos_objc_getClassList(Class* buffer, int buffer_count) @extname("objc_getClassList"); -extern fn char* _macos_class_getName(Class cls) @extname("class_getName"); -extern fn Class _macos_class_getSuperclass(Class cls) @extname("class_getSuperclass"); -extern fn Method _macos_class_getClassMethod(Class cls, Selector name) @extname("class_getClassMethod"); -extern fn bool _macos_class_respondsToSelector(Class cls, Selector name) @extname("class_respondsToSelector"); -extern fn Selector _macos_sel_registerName(char* str) @extname("sel_registerName"); -extern fn Class _macos_objc_lookUpClass(char* name) @extname("objc_lookUpClass"); +extern fn Class _macos_objc_getClass(char* name) @extern("objc_getClass"); +extern fn int _macos_objc_getClassList(Class* buffer, int buffer_count) @extern("objc_getClassList"); +extern fn char* _macos_class_getName(Class cls) @extern("class_getName"); +extern fn Class _macos_class_getSuperclass(Class cls) @extern("class_getSuperclass"); +extern fn Method _macos_class_getClassMethod(Class cls, Selector name) @extern("class_getClassMethod"); +extern fn bool _macos_class_respondsToSelector(Class cls, Selector name) @extern("class_respondsToSelector"); +extern fn Selector _macos_sel_registerName(char* str) @extern("sel_registerName"); +extern fn Class _macos_objc_lookUpClass(char* name) @extern("objc_lookUpClass"); $endif; diff --git a/lib/std/os/win32/error.c3 b/lib/std/os/win32/error.c3 index 31d9eee70..e2720f03e 100644 --- a/lib/std/os/win32/error.c3 +++ b/lib/std/os/win32/error.c3 @@ -1,8 +1,8 @@ module std::os::win32::wsa; $if (env::OS_TYPE == OsType.WIN32): -extern fn int get_last_error() @extname("WSAGetLastError"); -extern fn void set_last_error(int error) @extname("WSASetLastError"); +extern fn int get_last_error() @extern("WSAGetLastError"); +extern fn void set_last_error(int error) @extern("WSASetLastError"); const int INVALID_HANDLE = 6; const int NOT_ENOUGHT_MEMORY = 8; diff --git a/lib/std/os/win32/files.c3 b/lib/std/os/win32/files.c3 index ac545ac65..b23841b72 100644 --- a/lib/std/os/win32/files.c3 +++ b/lib/std/os/win32/files.c3 @@ -2,11 +2,11 @@ module std::os::win32::files; $if (env::OS_TYPE == OsType.WIN32): /* -private extern ulong _win32_GetCurrentDirectoryW(ulong, Char16* buffer) @extname("GetCurrentDirectoryW"); -private extern bool _win32_CreateSymbolicLinkW(Char16* symlink_file, Char16* target_file, ulong flags) @extname("CreateSymbolicLinkW"); -private extern bool _win32_CreateDirectoryW(Char16* path_name, void* security_attributes) @extname("CreateDirectoryW"); -private extern bool _win32_DeleteFileW(Char16* file) @extname("DeleteFileW"); -private extern bool _win32_CopyFileW(Char16* from_file, Char16* to_file, bool no_overwrite) @extname("CopyFileW"); -private extern ulong _win32_GetFullPathNameW(Char16* file_name, ulong buffer_len, Char16* buffer, Char16** file_part) @extname("GetFullPathNameW"); +private extern ulong _win32_GetCurrentDirectoryW(ulong, Char16* buffer) @extern("GetCurrentDirectoryW"); +private extern bool _win32_CreateSymbolicLinkW(Char16* symlink_file, Char16* target_file, ulong flags) @extern("CreateSymbolicLinkW"); +private extern bool _win32_CreateDirectoryW(Char16* path_name, void* security_attributes) @extern("CreateDirectoryW"); +private extern bool _win32_DeleteFileW(Char16* file) @extern("DeleteFileW"); +private extern bool _win32_CopyFileW(Char16* from_file, Char16* to_file, bool no_overwrite) @extern("CopyFileW"); +private extern ulong _win32_GetFullPathNameW(Char16* file_name, ulong buffer_len, Char16* buffer, Char16** file_part) @extern("GetFullPathNameW"); */ $endif; \ No newline at end of file diff --git a/lib/std/threads/os/thread_win32.c3 b/lib/std/threads/os/thread_win32.c3 index b9b24cb36..73c4f9146 100644 --- a/lib/std/threads/os/thread_win32.c3 +++ b/lib/std/threads/os/thread_win32.c3 @@ -39,27 +39,27 @@ struct NativeConditionVariable Win32_CRITICAL_SECTION waiters_count_lock; } -extern fn void win32_InitializeCriticalSection(Win32_CRITICAL_SECTION* section) @extname("InitializeCriticalSection"); -extern fn void win32_DeleteCriticalSection(Win32_CRITICAL_SECTION* section) @extname("DeleteCriticalSection"); -extern fn Win32_HANDLE win32_CreateMutex(void*, bool, void*) @extname("CreateMutexA"); -extern fn bool win32_CloseHandle(Win32_HANDLE) @extname("CloseHandle"); -extern fn bool win32_ReleaseMutex(Win32_HANDLE) @extname("ReleaseMutex"); -extern fn void win32_EnterCriticalSection(Win32_CRITICAL_SECTION* section) @extname("EnterCriticalSection"); -extern fn void win32_LeaveCriticalSection(Win32_CRITICAL_SECTION* section) @extname("LeaveCriticalSection"); -extern fn bool win32_TryEnterCriticalSection(Win32_CRITICAL_SECTION* section) @extname("TryEnterCriticalSection"); -extern fn uint win32_WaitForSingleObject(Win32_HANDLE, uint milliseconds) @extname("WaitForSingleObject"); -extern fn void win32_Sleep(uint ms) @extname("Sleep"); -extern fn uint win32_WaitForMultipleObjects(uint count, Win32_HANDLE* handles, bool wait_all, uint ms) @extname("WaitForMultipleObjects"); -extern fn Win32_HANDLE win32_CreateEventA(void* attributes, bool manual_reset, bool initial_state, char* name) @extname("CreateEventA"); -extern fn bool win32_ResetEvent(Win32_HANDLE event) @extname("ResetEvent"); -extern fn bool win32_SetEvent(Win32_HANDLE handle) @extname("SetEvent"); -extern fn long win32_InterlockedCompareExchange(int* dest, int exchange, int comperand) @extname("InterlockedCompareExchange"); -extern fn uint win32_SleepEx(uint ms, bool alertable) @extname("SleepEx"); -extern fn Win32_HANDLE win32_CreateThread(void* attributes, usz stack, ThreadFn func, void* arg, uint flags, uint* thread_id) @extname("CreateThread"); -extern fn bool win32_GetExitCodeThread(Win32_HANDLE handle, uint* exit_code) @extname("GetExitCodeThread"); -extern fn uint win32_GetThreadId(Win32_HANDLE) @extname("GetThreadId"); -extern fn void win32_ExitThread(uint res) @noreturn @extname("ExitThread"); -extern fn Win32_HANDLE win32_GetCurrentThread() @extname("GetCurrentThread"); +extern fn void win32_InitializeCriticalSection(Win32_CRITICAL_SECTION* section) @extern("InitializeCriticalSection"); +extern fn void win32_DeleteCriticalSection(Win32_CRITICAL_SECTION* section) @extern("DeleteCriticalSection"); +extern fn Win32_HANDLE win32_CreateMutex(void*, bool, void*) @extern("CreateMutexA"); +extern fn bool win32_CloseHandle(Win32_HANDLE) @extern("CloseHandle"); +extern fn bool win32_ReleaseMutex(Win32_HANDLE) @extern("ReleaseMutex"); +extern fn void win32_EnterCriticalSection(Win32_CRITICAL_SECTION* section) @extern("EnterCriticalSection"); +extern fn void win32_LeaveCriticalSection(Win32_CRITICAL_SECTION* section) @extern("LeaveCriticalSection"); +extern fn bool win32_TryEnterCriticalSection(Win32_CRITICAL_SECTION* section) @extern("TryEnterCriticalSection"); +extern fn uint win32_WaitForSingleObject(Win32_HANDLE, uint milliseconds) @extern("WaitForSingleObject"); +extern fn void win32_Sleep(uint ms) @extern("Sleep"); +extern fn uint win32_WaitForMultipleObjects(uint count, Win32_HANDLE* handles, bool wait_all, uint ms) @extern("WaitForMultipleObjects"); +extern fn Win32_HANDLE win32_CreateEventA(void* attributes, bool manual_reset, bool initial_state, char* name) @extern("CreateEventA"); +extern fn bool win32_ResetEvent(Win32_HANDLE event) @extern("ResetEvent"); +extern fn bool win32_SetEvent(Win32_HANDLE handle) @extern("SetEvent"); +extern fn long win32_InterlockedCompareExchange(int* dest, int exchange, int comperand) @extern("InterlockedCompareExchange"); +extern fn uint win32_SleepEx(uint ms, bool alertable) @extern("SleepEx"); +extern fn Win32_HANDLE win32_CreateThread(void* attributes, usz stack, ThreadFn func, void* arg, uint flags, uint* thread_id) @extern("CreateThread"); +extern fn bool win32_GetExitCodeThread(Win32_HANDLE handle, uint* exit_code) @extern("GetExitCodeThread"); +extern fn uint win32_GetThreadId(Win32_HANDLE) @extern("GetThreadId"); +extern fn void win32_ExitThread(uint res) @noreturn @extern("ExitThread"); +extern fn Win32_HANDLE win32_GetCurrentThread() @extern("GetCurrentThread"); const uint WAIT_OBJECT_0 = 0; const uint WAIT_ABANDONED = 128; diff --git a/resources/testfragments/sdl2.c3 b/resources/testfragments/sdl2.c3 index dfe349d17..2cf6a93b6 100644 --- a/resources/testfragments/sdl2.c3 +++ b/resources/testfragments/sdl2.c3 @@ -26,11 +26,11 @@ void* gWindow = null; void* gScreenSurface = null; -extern fn int init(uint flags) @extname("SDL_Init"); -extern fn int initSubSystem(uint flags) @extname("SDL_InitSubSystem"); -extern fn void quitSubSystem(uint flags) @extname("SDL_QuitSubSystem"); -extern fn uint wasInit(uint flags) @extname("SDL_WasInit"); -extern fn void quit() @extname("SDL_Quit"); +extern fn int init(uint flags) @extern("SDL_Init"); +extern fn int initSubSystem(uint flags) @extern("SDL_InitSubSystem"); +extern fn void quitSubSystem(uint flags) @extern("SDL_QuitSubSystem"); +extern fn uint wasInit(uint flags) @extern("SDL_WasInit"); +extern fn void quit() @extern("SDL_Quit"); enum SDLWindowFlags : c_int { @@ -59,8 +59,8 @@ enum SDLWindowFlags : c_int VULKAN = 0x10000000 /**< window usable for Vulkan surface */ } -extern fn void* createWindow(char *title, uint x, uint y, int w, int h, uint flags) @extname("SDL_CreateWindow"); -extern fn void* getWindowSurface(void *window) @extname("SDL_GetWindowSurface"); +extern fn void* createWindow(char *title, uint x, uint y, int w, int h, uint flags) @extern("SDL_CreateWindow"); +extern fn void* getWindowSurface(void *window) @extern("SDL_GetWindowSurface"); const uint WINDOWPOS_UNDEFINED_MASK = 0x1FFF0000; extern fn int exit(int code); extern fn int printf(char *mess, ...); @@ -96,8 +96,8 @@ fn void close() quit(); } -extern fn int pollEvent(SDL_Event *event) @extname("SDL_PollEvent"); -extern fn int updateWindowSurface(void *window) @extname("SDL_UpdateWindowSurface"); +extern fn int pollEvent(SDL_Event *event) @extern("SDL_PollEvent"); +extern fn int updateWindowSurface(void *window) @extern("SDL_UpdateWindowSurface"); enum SDLEventType : uint { diff --git a/resources/testfragments/sdl_video.c3 b/resources/testfragments/sdl_video.c3 index 3ffbcb607..b29103aab 100644 --- a/resources/testfragments/sdl_video.c3 +++ b/resources/testfragments/sdl_video.c3 @@ -73,11 +73,11 @@ enum WindowEventID : cint } -extern int getNumVideoDrivers() @extname("SDL_GetNumVideoDrivers"); -extern char* getVideoDriver(int index) @extname("SDL_GetVideoDriver"); -extern SdlWindow* createWindowFrom(void* data) @extname("SDL_CreateWindowFrom"); -extern int getWindowDisplayMode(SdlWindow* window, DisplayMode *mode) @extname("SDL_GetWindowDisplayMode"); -extern uint getWindowFlags(SdlWindow* window) @extname("SDL_GetWindowFlags"); +extern int getNumVideoDrivers() @extern("SDL_GetNumVideoDrivers"); +extern char* getVideoDriver(int index) @extern("SDL_GetVideoDriver"); +extern SdlWindow* createWindowFrom(void* data) @extern("SDL_CreateWindowFrom"); +extern int getWindowDisplayMode(SdlWindow* window, DisplayMode *mode) @extern("SDL_GetWindowDisplayMode"); +extern uint getWindowFlags(SdlWindow* window) @extern("SDL_GetWindowFlags"); const uint WINDOWPOS_UNDEFINED_MASK = 0x1FFF0000; diff --git a/test/test_suite/globals/global_extname.c3t b/test/test_suite/globals/global_extname.c3t index 6de9b442d..25809eb13 100644 --- a/test/test_suite/globals/global_extname.c3t +++ b/test/test_suite/globals/global_extname.c3t @@ -1,6 +1,6 @@ module foo; -int baz @extname("foobar") = 123; +int baz @extern("foobar") = 123; // #expect: foo.ll