mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 03:51:18 +00:00
- Rename @extern to @cname, deprecating the old name #2493.
This commit is contained in:
@@ -64,7 +64,7 @@ macro int @main_to_void_main_args(#m, int argc, char** argv)
|
||||
|
||||
module std::core::main_stub @if(env::WIN32);
|
||||
|
||||
extern fn Char16** _win_command_line_to_argv_w(ushort* cmd_line, int* argc_ptr) @extern("CommandLineToArgvW");
|
||||
extern fn Char16** _win_command_line_to_argv_w(ushort* cmd_line, int* argc_ptr) @cname("CommandLineToArgvW");
|
||||
|
||||
macro String[] win_command_line_to_strings(ushort* cmd_line) @private
|
||||
{
|
||||
|
||||
@@ -42,7 +42,7 @@ macro @enum_lookup_new($Type, $name, value)
|
||||
module std::core::runtime @if(env::FREESTANDING_WASM);
|
||||
|
||||
extern fn void __wasm_call_ctors();
|
||||
fn void wasm_initialize() @extern("_initialize") @wasm
|
||||
fn void wasm_initialize() @cname("_initialize") @wasm
|
||||
{
|
||||
// The linker synthesizes this to call constructors.
|
||||
__wasm_call_ctors();
|
||||
|
||||
@@ -100,7 +100,7 @@ extern fn CInt close(CInt fd) @if(!env::WIN32);
|
||||
extern fn double difftime(Time_t time1, Time_t time2) @if(!env::WIN32);
|
||||
extern fn DivResult div(CInt numer, CInt denom);
|
||||
extern fn void exit(CInt status);
|
||||
extern fn void _exit(CInt status) @extern("_Exit");
|
||||
extern fn void _exit(CInt status) @cname("_Exit");
|
||||
extern fn CInt fclose(CFile stream);
|
||||
extern fn CFile fdopen(CInt fd, ZString mode) @if(!env::WIN32);
|
||||
extern fn CInt feof(CFile stream);
|
||||
@@ -211,9 +211,9 @@ const CInt STDOUT_FD = 1;
|
||||
const CInt STDERR_FD = 2;
|
||||
|
||||
module libc @if(env::LINUX || env::ANDROID);
|
||||
extern CFile __stdin @extern("stdin");
|
||||
extern CFile __stdout @extern("stdout");
|
||||
extern CFile __stderr @extern("stderr");
|
||||
extern CFile __stdin @cname("stdin");
|
||||
extern CFile __stdout @cname("stdout");
|
||||
extern CFile __stderr @cname("stderr");
|
||||
extern fn usz malloc_usable_size(void* ptr);
|
||||
macro usz malloc_size(void* ptr) => malloc_usable_size(ptr);
|
||||
extern fn void* aligned_alloc(usz align, usz size);
|
||||
@@ -262,30 +262,30 @@ module libc @if(!env::LIBC);
|
||||
import std::core::mem;
|
||||
|
||||
|
||||
fn void longjmp(JmpBuf* buffer, CInt value) @weak @extern("longjmp") @nostrip
|
||||
fn void longjmp(JmpBuf* buffer, CInt value) @weak @cname("longjmp") @nostrip
|
||||
{
|
||||
unreachable("longjmp unavailable");
|
||||
}
|
||||
|
||||
fn CInt setjmp(JmpBuf* buffer) @weak @extern("setjmp") @nostrip
|
||||
fn CInt setjmp(JmpBuf* buffer) @weak @cname("setjmp") @nostrip
|
||||
{
|
||||
unreachable("setjmp unavailable");
|
||||
}
|
||||
|
||||
fn void* malloc(usz size) @weak @extern("malloc") @nostrip
|
||||
fn void* malloc(usz size) @weak @cname("malloc") @nostrip
|
||||
{
|
||||
unreachable("malloc unavailable");
|
||||
}
|
||||
fn void* calloc(usz count, usz size) @weak @extern("calloc") @nostrip
|
||||
fn void* calloc(usz count, usz size) @weak @cname("calloc") @nostrip
|
||||
{
|
||||
unreachable("calloc unavailable");
|
||||
}
|
||||
fn void* free(void*) @weak @extern("free")
|
||||
fn void* free(void*) @weak @cname("free")
|
||||
{
|
||||
unreachable("free unavailable");
|
||||
}
|
||||
|
||||
fn void* realloc(void* ptr, usz size) @weak @extern("realloc") @nostrip
|
||||
fn void* realloc(void* ptr, usz size) @weak @cname("realloc") @nostrip
|
||||
{
|
||||
unreachable("realloc unavailable");
|
||||
}
|
||||
@@ -294,69 +294,69 @@ alias memcpy = mem::__memcpy;
|
||||
alias memmove = mem::__memcpy;
|
||||
alias memset = mem::__memset;
|
||||
|
||||
fn int fseek(CFile stream, SeekIndex offset, int whence) @weak @extern("fseek") @nostrip
|
||||
fn int fseek(CFile stream, SeekIndex offset, int whence) @weak @cname("fseek") @nostrip
|
||||
{
|
||||
unreachable("'fseek' not available.");
|
||||
}
|
||||
fn CFile fopen(ZString filename, ZString mode) @weak @extern("fopen") @nostrip
|
||||
fn CFile fopen(ZString filename, ZString mode) @weak @cname("fopen") @nostrip
|
||||
{
|
||||
unreachable("'fopen' not available.");
|
||||
}
|
||||
|
||||
fn CFile freopen(ZString filename, ZString mode, CFile stream) @weak @extern("fopen") @nostrip
|
||||
fn CFile freopen(ZString filename, ZString mode, CFile stream) @weak @cname("fopen") @nostrip
|
||||
{
|
||||
unreachable("'freopen' not available.");
|
||||
}
|
||||
|
||||
fn usz fwrite(void* ptr, usz size, usz nmemb, CFile stream) @weak @extern("fwrite") @nostrip
|
||||
fn usz fwrite(void* ptr, usz size, usz nmemb, CFile stream) @weak @cname("fwrite") @nostrip
|
||||
{
|
||||
unreachable("'fwrite' not available.");
|
||||
}
|
||||
|
||||
fn usz fread(void* ptr, usz size, usz nmemb, CFile stream) @weak @extern("fread") @nostrip
|
||||
fn usz fread(void* ptr, usz size, usz nmemb, CFile stream) @weak @cname("fread") @nostrip
|
||||
{
|
||||
unreachable("'fread' not available.");
|
||||
}
|
||||
|
||||
fn CFile fclose(CFile) @weak @extern("fclose") @nostrip
|
||||
fn CFile fclose(CFile) @weak @cname("fclose") @nostrip
|
||||
{
|
||||
unreachable("'fclose' not available.");
|
||||
}
|
||||
|
||||
fn int fflush(CFile stream) @weak @extern("fflush") @nostrip
|
||||
fn int fflush(CFile stream) @weak @cname("fflush") @nostrip
|
||||
{
|
||||
unreachable("'fflush' not available.");
|
||||
}
|
||||
|
||||
fn int fputc(int c, CFile stream) @weak @extern("fputc") @nostrip
|
||||
fn int fputc(int c, CFile stream) @weak @cname("fputc") @nostrip
|
||||
{
|
||||
unreachable("'fputc' not available.");
|
||||
}
|
||||
|
||||
fn char* fgets(ZString str, int n, CFile stream) @weak @extern("fgets") @nostrip
|
||||
fn char* fgets(ZString str, int n, CFile stream) @weak @cname("fgets") @nostrip
|
||||
{
|
||||
unreachable("'fgets' not available.");
|
||||
}
|
||||
|
||||
fn int fgetc(CFile stream) @weak @extern("fgetc") @nostrip
|
||||
fn int fgetc(CFile stream) @weak @cname("fgetc") @nostrip
|
||||
{
|
||||
unreachable("'fgetc' not available.");
|
||||
}
|
||||
|
||||
fn int feof(CFile stream) @weak @extern("feof") @nostrip
|
||||
fn int feof(CFile stream) @weak @cname("feof") @nostrip
|
||||
{
|
||||
unreachable("'feof' not available.");
|
||||
}
|
||||
|
||||
fn int putc(int c, CFile stream) @weak @extern("putc") @nostrip
|
||||
fn int putc(int c, CFile stream) @weak @cname("putc") @nostrip
|
||||
{
|
||||
unreachable("'putc' not available.");
|
||||
}
|
||||
fn int putchar(int c) @weak @extern("putchar") @nostrip
|
||||
fn int putchar(int c) @weak @cname("putchar") @nostrip
|
||||
{
|
||||
unreachable("'putchar' not available.");
|
||||
}
|
||||
fn int puts(ZString str) @weak @extern("puts") @nostrip
|
||||
fn int puts(ZString str) @weak @cname("puts") @nostrip
|
||||
{
|
||||
unreachable("'puts' not available.");
|
||||
}
|
||||
|
||||
@@ -41,6 +41,6 @@ struct Stat
|
||||
long[2] st_qspare;
|
||||
}
|
||||
|
||||
extern fn int stat(ZString str, Stat* stat) @extern("stat64");
|
||||
extern fn int stat(ZString str, Stat* stat) @cname("stat64");
|
||||
|
||||
extern fn CInt sysctl(CInt *name, CUInt namelen, void *oldp, usz *oldlenp, void *newp, usz newlen);
|
||||
|
||||
@@ -62,7 +62,7 @@ struct SystemInfo
|
||||
ushort wProcessorRevision;
|
||||
}
|
||||
|
||||
extern fn CInt get_system_info(SystemInfo*) @extern("GetSystemInfo");
|
||||
extern fn CInt get_system_info(SystemInfo*) @cname("GetSystemInfo");
|
||||
|
||||
// Aliases to simplify libc use
|
||||
macro Tm* localtime_r(Time_t* timer, Tm* buf) => _localtime64_s(buf, timer);
|
||||
|
||||
@@ -6,7 +6,7 @@ import std::math::complex;
|
||||
import std::math::matrix;
|
||||
import std::math::quaternion;
|
||||
|
||||
attrdef @MathLibc(name) = @extern(name), @link(env::POSIX, "m");
|
||||
attrdef @MathLibc(name) = @cname(name), @link(env::POSIX, "m");
|
||||
|
||||
const E = 2.718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166427427466;
|
||||
const LOG2E = 1.44269504088896340735992468100189214; // log2(e)
|
||||
@@ -1047,8 +1047,8 @@ extern fn void _sincosf(float, float*, float*) @MathLibc("__sincosf") @if(env::D
|
||||
extern fn void _sincos(double, double*, double*) @MathLibc("sincos") @if(!env::DARWIN && !env::WIN32);
|
||||
extern fn void _sincosf(float, float*, float*) @MathLibc("sincosf") @if(!env::DARWIN && !env::WIN32);
|
||||
|
||||
fn void _sincos(double a, double* s, double* c) @extern("sincos") @if(env::WIN32) { *s = sin(a); *c = cos(a); }
|
||||
fn void _sincosf(float a, float* s, float* c) @extern("sincosf") @if(env::WIN32) { *s = sin(a); *c = cos(a); }
|
||||
fn void _sincos(double a, double* s, double* c) @cname("sincos") @if(env::WIN32) { *s = sin(a); *c = cos(a); }
|
||||
fn void _sincosf(float a, float* s, float* c) @cname("sincosf") @if(env::WIN32) { *s = sin(a); *c = cos(a); }
|
||||
|
||||
extern fn double _tan(double x) @MathLibc("tan");
|
||||
extern fn float _tanf(float x) @MathLibc("tanf");
|
||||
|
||||
@@ -12,7 +12,7 @@ module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
|
||||
* ====================================================
|
||||
*/
|
||||
|
||||
fn double __cos(double x, double y) @extern("__cos") @weak @nostrip
|
||||
fn double __cos(double x, double y) @cname("__cos") @weak @nostrip
|
||||
{
|
||||
const C1 = 4.16666666666666019037e-02; /* 0x3FA55555, 0x5555554C */
|
||||
const C2 = -1.38888888888741095749e-03; /* 0xBF56C16C, 0x16C15177 */
|
||||
|
||||
@@ -22,7 +22,7 @@ const double C1 @private = 0x155553e1053a42.0p-57; /* 0.0416666233237390631894
|
||||
const double C2 @private = -0x16c087e80f1e27.0p-62; /* -0.00138867637746099294692 */
|
||||
const double C3 @private = 0x199342e0ee5069.0p-68; /* 0.0000243904487962774090654 */
|
||||
|
||||
fn float __cosdf(double x) @extern("__cosdf") @weak @nostrip
|
||||
fn float __cosdf(double x) @cname("__cosdf") @weak @nostrip
|
||||
{
|
||||
/* Try to optimize for parallel evaluation as in __tandf.c. */
|
||||
double z = x * x;
|
||||
|
||||
@@ -13,7 +13,7 @@ union FloatInternal
|
||||
}
|
||||
|
||||
// Based on the musl implementation
|
||||
fn double fmod(double x, double y) @extern("fmod") @weak @nostrip
|
||||
fn double fmod(double x, double y) @cname("fmod") @weak @nostrip
|
||||
{
|
||||
DoubleInternal ux = { .f = x };
|
||||
DoubleInternal uy = { .f = y };
|
||||
@@ -83,7 +83,7 @@ fn double fmod(double x, double y) @extern("fmod") @weak @nostrip
|
||||
return ux.f;
|
||||
}
|
||||
|
||||
fn float fmodf(float x, float y) @extern("fmodf") @weak @nostrip
|
||||
fn float fmodf(float x, float y) @cname("fmodf") @weak @nostrip
|
||||
{
|
||||
FloatInternal ux = { .f = x };
|
||||
FloatInternal uy = { .f = y };
|
||||
|
||||
@@ -11,7 +11,7 @@ module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
|
||||
* is preserved.
|
||||
* ====================================================
|
||||
*/
|
||||
fn double __sin(double x, double y, int iy) @extern("__sin") @weak @nostrip
|
||||
fn double __sin(double x, double y, int iy) @cname("__sin") @weak @nostrip
|
||||
{
|
||||
|
||||
const S1 = -1.66666666666666324348e-01; /* 0xBFC55555, 0x55555549 */
|
||||
|
||||
@@ -16,7 +16,7 @@ module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
|
||||
* ====================================================
|
||||
*/
|
||||
// |sin(x)/x - s(x)| < 2**-37.5 (~[-4.89e-12, 4.824e-12]).
|
||||
fn float __sindf(double x) @extern("__sindf") @weak @nostrip
|
||||
fn float __sindf(double x) @cname("__sindf") @weak @nostrip
|
||||
{
|
||||
const S1F = -0x15555554cbac77.0p-55; /* -0.166666666416265235595 */
|
||||
const S2F = 0x111110896efbb2.0p-59; /* 0.0083333293858894631756 */
|
||||
|
||||
@@ -27,7 +27,7 @@ const double[*] TAN_T = {
|
||||
2.59073051863633712884e-05, /* 3EFB2A70, 74BF7AD4 */
|
||||
};
|
||||
|
||||
fn double __tan(double x, double y, int odd) @extern("__tan") @weak @nostrip
|
||||
fn double __tan(double x, double y, int odd) @cname("__tan") @weak @nostrip
|
||||
{
|
||||
const double PIO4 = 7.85398163397448278999e-01; /* 3FE921FB, 54442D18 */
|
||||
const double PIO4LO = 3.06161699786838301793e-17; /* 3C81A626, 33145C07 */
|
||||
|
||||
@@ -25,7 +25,7 @@ const double[*] TANDF = {
|
||||
0x1362b9bf971bcd.0p-59, /* 0.00946564784943673166728 */
|
||||
};
|
||||
|
||||
fn float __tandf(double x, int odd) @extern("__tandf") @weak @nostrip
|
||||
fn float __tandf(double x, int odd) @cname("__tandf") @weak @nostrip
|
||||
{
|
||||
double z = x * x;
|
||||
/*
|
||||
|
||||
@@ -32,7 +32,7 @@ fn double _r(double z) @local
|
||||
return p / q;
|
||||
}
|
||||
|
||||
fn double _acos(double x) @weak @extern("acos") @nostrip
|
||||
fn double _acos(double x) @weak @cname("acos") @nostrip
|
||||
{
|
||||
uint hx = x.high_word();
|
||||
uint ix = hx & 0x7fffffff;
|
||||
@@ -100,7 +100,7 @@ fn float _r_f(float z) @local
|
||||
return p / q;
|
||||
}
|
||||
|
||||
fn float _acosf(float x) @weak @extern("acosf") @nostrip
|
||||
fn float _acosf(float x) @weak @cname("acosf") @nostrip
|
||||
{
|
||||
uint hx = bitcast(x, uint);
|
||||
uint ix = hx & 0x7fffffff;
|
||||
|
||||
@@ -32,7 +32,7 @@ fn double _r(double z) @local
|
||||
return p / q;
|
||||
}
|
||||
|
||||
fn double _asin(double x) @weak @extern("asin") @nostrip
|
||||
fn double _asin(double x) @weak @cname("asin") @nostrip
|
||||
{
|
||||
uint hx = x.high_word();
|
||||
uint ix = hx & 0x7fffffff;
|
||||
@@ -102,7 +102,7 @@ fn float _r_f(float z) @local
|
||||
return p / q;
|
||||
}
|
||||
|
||||
fn float _asinf(float x) @weak @extern("asinf") @nostrip
|
||||
fn float _asinf(float x) @weak @cname("asinf") @nostrip
|
||||
{
|
||||
uint hx = bitcast(x, uint);
|
||||
uint ix = hx & 0x7fffffff;
|
||||
|
||||
@@ -40,7 +40,7 @@ const double[*] AT @private = {
|
||||
1.62858201153657823623e-02, /* 0x3F90AD3A, 0xE322DA11 */
|
||||
};
|
||||
|
||||
fn double _atan(double x) @weak @extern("atan") @nostrip
|
||||
fn double _atan(double x) @weak @cname("atan") @nostrip
|
||||
{
|
||||
int id @noinit;
|
||||
uint ix = x.high_word();
|
||||
@@ -138,7 +138,7 @@ const float[*] ATF @private = {
|
||||
6.1687607318e-02,
|
||||
};
|
||||
|
||||
fn float _atanf(float x) @weak @extern("atanf") @nostrip
|
||||
fn float _atanf(float x) @weak @cname("atanf") @nostrip
|
||||
{
|
||||
int id @noinit;
|
||||
uint ix = x.word();
|
||||
@@ -217,7 +217,7 @@ fn float _atanf(float x) @weak @extern("atanf") @nostrip
|
||||
|
||||
const PI_LO @private = 1.2246467991473531772E-16; /* 0x3CA1A626, 0x33145C07 */
|
||||
|
||||
fn double _atan2(double y, double x) @weak @extern("atan2") @nostrip
|
||||
fn double _atan2(double y, double x) @weak @cname("atan2") @nostrip
|
||||
{
|
||||
if (math::is_nan(x) || math::is_nan(y)) return x + y;
|
||||
|
||||
@@ -301,7 +301,7 @@ fn double _atan2(double y, double x) @weak @extern("atan2") @nostrip
|
||||
const float PI_F @private = 3.1415927410e+00; /* 0x40490fdb */
|
||||
const float PI_LO_F @private = -8.7422776573e-08; /* 0xb3bbbd2e */
|
||||
|
||||
fn float _atan2f(float y, float x) @weak @extern("atan2f") @nostrip
|
||||
fn float _atan2f(float y, float x) @weak @cname("atan2f") @nostrip
|
||||
{
|
||||
if (math::is_nan(x) || math::is_nan(y)) return x + y;
|
||||
uint ix = x.word();
|
||||
|
||||
@@ -12,7 +12,7 @@ module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
|
||||
* ====================================================
|
||||
*/
|
||||
|
||||
fn double _atanh(double x) @weak @extern("atanh") @nostrip
|
||||
fn double _atanh(double x) @weak @cname("atanh") @nostrip
|
||||
{
|
||||
double t @noinit;
|
||||
uint hx = x.high_word();
|
||||
@@ -61,7 +61,7 @@ fn double _atanh(double x) @weak @extern("atanh") @nostrip
|
||||
* ====================================================
|
||||
*/
|
||||
|
||||
fn float _atanhf(float x) @weak @extern("atanhf") @nostrip
|
||||
fn float _atanhf(float x) @weak @cname("atanhf") @nostrip
|
||||
{
|
||||
float t @noinit;
|
||||
uint hx = bitcast(x, uint);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
|
||||
|
||||
fn double _ceil(double x) @weak @extern("ceil") @nostrip
|
||||
fn double _ceil(double x) @weak @cname("ceil") @nostrip
|
||||
{
|
||||
ulong ui = bitcast(x, ulong);
|
||||
int e = (int)((ui >> 52) & 0x7ff);
|
||||
@@ -17,7 +17,7 @@ fn double _ceil(double x) @weak @extern("ceil") @nostrip
|
||||
}
|
||||
|
||||
|
||||
fn float _ceilf(float x) @weak @extern("ceilf") @nostrip
|
||||
fn float _ceilf(float x) @weak @cname("ceilf") @nostrip
|
||||
{
|
||||
uint u = bitcast(x, uint);
|
||||
int e = (int)((u >> 23) & 0xff) - 0x7f;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
|
||||
|
||||
fn float _cosf(float x) @extern("cosf") @weak @nostrip
|
||||
fn float _cosf(float x) @cname("cosf") @weak @nostrip
|
||||
{
|
||||
uint ix = x.word();
|
||||
uint sign = ix >> 31;
|
||||
@@ -51,7 +51,7 @@ fn float _cosf(float x) @extern("cosf") @weak @nostrip
|
||||
* ====================================================
|
||||
*/
|
||||
|
||||
fn double _cos(double x) @extern("cos") @weak @nostrip
|
||||
fn double _cos(double x) @cname("cos") @weak @nostrip
|
||||
{
|
||||
// High word of x.
|
||||
uint ix = x.high_word() & 0x7fffffff;
|
||||
|
||||
@@ -17,7 +17,7 @@ const float EXPF_P2 = -2.7777778450e-03f;
|
||||
const float EXPF_P3 = 6.6137559770e-05f;
|
||||
const float EXPF_P4 = -1.6533901999e-06f;
|
||||
|
||||
fn double exp(double x) @extern("exp") @nostrip @weak
|
||||
fn double exp(double x) @cname("exp") @nostrip @weak
|
||||
{
|
||||
if (x != x) return x;
|
||||
if (x == double.inf) return double.inf;
|
||||
@@ -38,7 +38,7 @@ fn double exp(double x) @extern("exp") @nostrip @weak
|
||||
return ldexp(exp_r, (int)k);
|
||||
}
|
||||
|
||||
fn float expf(float x) @extern("expf") @nostrip @weak
|
||||
fn float expf(float x) @cname("expf") @nostrip @weak
|
||||
{
|
||||
if (x != x) return x;
|
||||
if (x == float.inf) return float.inf;
|
||||
|
||||
@@ -3,7 +3,7 @@ module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
|
||||
macro uint _top12f(float x) @private => bitcast(x, uint) >> 20;
|
||||
|
||||
|
||||
fn float _exp2f(float x) @extern("exp2f") @weak @nostrip
|
||||
fn float _exp2f(float x) @cname("exp2f") @weak @nostrip
|
||||
{
|
||||
double xd = x;
|
||||
uint abstop = _top12f(x) & 0x7ff;
|
||||
@@ -80,7 +80,7 @@ macro uint _top12d(double x) @private
|
||||
return (uint)(bitcast(x, ulong) >> 52);
|
||||
}
|
||||
|
||||
fn double _exp2(double x) @extern("exp2") @weak @nostrip
|
||||
fn double _exp2(double x) @cname("exp2") @weak @nostrip
|
||||
{
|
||||
uint abstop = _top12d(x) & 0x7ff;
|
||||
ulong u = bitcast(x, ulong);
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
|
||||
|
||||
fn double _fabs(double x) @weak @extern("fabs") @nostrip
|
||||
fn double _fabs(double x) @weak @cname("fabs") @nostrip
|
||||
{
|
||||
ulong ix = bitcast(x, ulong);
|
||||
ix &= ~(1ul << 63);
|
||||
return bitcast(ix, double);
|
||||
}
|
||||
|
||||
fn float _fabsf(float x) @weak @extern("fabsf") @nostrip
|
||||
fn float _fabsf(float x) @weak @cname("fabsf") @nostrip
|
||||
{
|
||||
uint ix = bitcast(x, uint);
|
||||
ix &= 0x7fffffff;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
|
||||
|
||||
fn double _floor(double x) @weak @extern("floor") @nostrip
|
||||
fn double _floor(double x) @weak @cname("floor") @nostrip
|
||||
{
|
||||
ulong ui = bitcast(x, ulong);
|
||||
int e = (int)((ui >> 52) & 0x7ff);
|
||||
@@ -17,7 +17,7 @@ fn double _floor(double x) @weak @extern("floor") @nostrip
|
||||
}
|
||||
|
||||
|
||||
fn float _floorf(float x) @weak @extern("floorf") @nostrip
|
||||
fn float _floorf(float x) @weak @cname("floorf") @nostrip
|
||||
{
|
||||
uint u = bitcast(x, uint);
|
||||
int e = (int)((u >> 23) & 0xff) - 0x7f;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
|
||||
|
||||
fn double frexp(double x, int* exp) @extern("frexp")
|
||||
fn double frexp(double x, int* exp) @cname("frexp")
|
||||
{
|
||||
uint hx = x.high_word();
|
||||
uint ix = hx & 0x7fffffff;
|
||||
@@ -31,7 +31,7 @@ fn double frexp(double x, int* exp) @extern("frexp")
|
||||
}
|
||||
}
|
||||
|
||||
fn float frexpf(float x, int* exp) @extern("frexpf")
|
||||
fn float frexpf(float x, int* exp) @cname("frexpf")
|
||||
{
|
||||
uint ix = x.word();
|
||||
uint hx = ix & 0x7fffffff;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
|
||||
|
||||
fn double ldexp(double x, int exp) @extern("ldexp")
|
||||
fn double ldexp(double x, int exp) @cname("ldexp")
|
||||
{
|
||||
uint hx = x.high_word();
|
||||
int hexp = (int)((hx & 0x7ff00000) >> 20);
|
||||
@@ -35,7 +35,7 @@ fn double ldexp(double x, int exp) @extern("ldexp")
|
||||
}
|
||||
}
|
||||
|
||||
fn float ldexpf(float x, int exp) @extern("ldexpf")
|
||||
fn float ldexpf(float x, int exp) @cname("ldexpf")
|
||||
{
|
||||
uint ix = x.word();
|
||||
int hexp = (int)((ix & 0x7f800000) >> 23);
|
||||
|
||||
@@ -19,7 +19,7 @@ const float LOGF_L4 = 2.4279078841e-01f;
|
||||
const double SQRT2 = 1.41421356237309504880;
|
||||
const float SQRT2F = 1.41421356237309504880f;
|
||||
|
||||
fn double log(double x) @extern("log") @nostrip @weak
|
||||
fn double log(double x) @cname("log") @nostrip @weak
|
||||
{
|
||||
if (x != x) return x;
|
||||
if (x < 0.0) return double.nan;
|
||||
@@ -50,7 +50,7 @@ fn double log(double x) @extern("log") @nostrip @weak
|
||||
return k * LOG_LN2_HI - ((hfsq - (s * (hfsq + r) + k * LOG_LN2_LO)) - f);
|
||||
}
|
||||
|
||||
fn float logf(float x) @extern("logf") @nostrip @weak
|
||||
fn float logf(float x) @cname("logf") @nostrip @weak
|
||||
{
|
||||
if (x != x) return x;
|
||||
if (x < 0.0f) return float.nan;
|
||||
|
||||
@@ -48,7 +48,7 @@ const LG5 @local = 1.818357216161805012e-01; /* 3FC74664 96CB03DE */
|
||||
const LG6 @local = 1.531383769920937332e-01; /* 3FC39A09 D078C69F */
|
||||
const LG7 @local = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */
|
||||
|
||||
fn double _log1p(double x) @weak @extern("log1p") @nostrip
|
||||
fn double _log1p(double x) @weak @cname("log1p") @nostrip
|
||||
{
|
||||
uint hx = x.high_word();
|
||||
int k = 1;
|
||||
@@ -162,7 +162,7 @@ const float LG2_F @local = 0xccce13.0p-25; /* 0.40000972152 */
|
||||
const float LG3_F @local = 0x91e9ee.0p-25; /* 0.28498786688 */
|
||||
const float LG4_F @local = 0xf89e26.0p-26; /* 0.24279078841 */
|
||||
|
||||
fn float _log1pf(float x) @weak @extern("log1pf") @nostrip
|
||||
fn float _log1pf(float x) @weak @cname("log1pf") @nostrip
|
||||
{
|
||||
uint ix = x.word();
|
||||
int k = 1;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
|
||||
|
||||
fn double pow(double x, double y) @extern("pow")
|
||||
fn double pow(double x, double y) @cname("pow")
|
||||
{
|
||||
if (x != x || y != y) return double.nan;
|
||||
|
||||
@@ -54,7 +54,7 @@ fn double pow(double x, double y) @extern("pow")
|
||||
return result;
|
||||
}
|
||||
|
||||
fn float powf(float x, float y) @extern("powf")
|
||||
fn float powf(float x, float y) @cname("powf")
|
||||
{
|
||||
if (x != x || y != y) return float.nan;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
|
||||
|
||||
fn double _round(double x) @extern("round") @weak @nostrip
|
||||
fn double _round(double x) @cname("round") @weak @nostrip
|
||||
{
|
||||
ulong u = bitcast(x, ulong);
|
||||
int e = (int)((u >> 52) & 0x7ff);
|
||||
@@ -26,7 +26,7 @@ fn double _round(double x) @extern("round") @weak @nostrip
|
||||
return y;
|
||||
}
|
||||
|
||||
fn float _roundf(float x) @extern("roundf") @weak @nostrip
|
||||
fn float _roundf(float x) @cname("roundf") @weak @nostrip
|
||||
{
|
||||
uint u = bitcast(x, uint);
|
||||
int e = (u >> 23) & 0xff;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
|
||||
|
||||
fn double _scalbn(double x, int n) @weak @extern("scalbn") @nostrip
|
||||
fn double _scalbn(double x, int n) @weak @cname("scalbn") @nostrip
|
||||
{
|
||||
switch
|
||||
{
|
||||
|
||||
@@ -16,7 +16,7 @@ module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
|
||||
* ====================================================
|
||||
*/
|
||||
|
||||
fn float _sinf(float x) @weak @extern("sinf") @nostrip
|
||||
fn float _sinf(float x) @weak @cname("sinf") @nostrip
|
||||
{
|
||||
uint ix = x.word();
|
||||
int sign = ix >> 31;
|
||||
@@ -84,7 +84,7 @@ fn float _sinf(float x) @weak @extern("sinf") @nostrip
|
||||
* ====================================================
|
||||
*/
|
||||
|
||||
fn double sin(double x) @extern("sin") @weak @nostrip
|
||||
fn double sin(double x) @cname("sin") @weak @nostrip
|
||||
{
|
||||
// High word of x.
|
||||
uint ix = x.high_word() & 0x7fffffff;
|
||||
|
||||
@@ -16,7 +16,7 @@ module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
|
||||
* ====================================================
|
||||
*/
|
||||
|
||||
fn void sincosf(float x, float *sin, float *cos) @extern("__sincosf") @weak @nostrip
|
||||
fn void sincosf(float x, float *sin, float *cos) @cname("__sincosf") @weak @nostrip
|
||||
{
|
||||
uint ix = x.word();
|
||||
uint sign = ix >> 31;
|
||||
@@ -104,7 +104,7 @@ fn void sincosf(float x, float *sin, float *cos) @extern("__sincosf") @weak @nos
|
||||
|
||||
}
|
||||
|
||||
fn void sincos(double x, double *sin, double *cos) @extern("__sincos") @weak @nostrip
|
||||
fn void sincos(double x, double *sin, double *cos) @cname("__sincos") @weak @nostrip
|
||||
{
|
||||
// High word of x.
|
||||
uint ix = x.high_word() & 0x7fffffff;
|
||||
|
||||
@@ -12,7 +12,7 @@ module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
|
||||
* ====================================================
|
||||
*/
|
||||
|
||||
fn double tan(double x) @extern("tan") @weak @nostrip
|
||||
fn double tan(double x) @cname("tan") @weak @nostrip
|
||||
{
|
||||
uint ix = x.high_word();
|
||||
ix &= 0x7fffffff;
|
||||
@@ -57,7 +57,7 @@ fn double tan(double x) @extern("tan") @weak @nostrip
|
||||
* ====================================================
|
||||
*/
|
||||
|
||||
fn float tanf(float x) @extern("tanf") @weak @nostrip
|
||||
fn float tanf(float x) @cname("tanf") @weak @nostrip
|
||||
{
|
||||
uint ix = x.word();
|
||||
uint sign = ix >> 31;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
|
||||
|
||||
fn double sincos_broken(double x) @extern("sincos") @weak @nostrip
|
||||
fn double sincos_broken(double x) @cname("sincos") @weak @nostrip
|
||||
{
|
||||
unreachable("'sinccos' not supported");
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
|
||||
|
||||
fn double _trunc(double x) @weak @extern("trunc") @nostrip
|
||||
fn double _trunc(double x) @weak @cname("trunc") @nostrip
|
||||
{
|
||||
ulong i = bitcast(x, ulong);
|
||||
int e = (int)((i >> 52) & 0x7ff) - 0x3ff + 12;
|
||||
@@ -13,7 +13,7 @@ fn double _trunc(double x) @weak @extern("trunc") @nostrip
|
||||
return bitcast(i, double);
|
||||
}
|
||||
|
||||
fn float _truncf(float x) @weak @extern("truncf") @nostrip
|
||||
fn float _truncf(float x) @weak @cname("truncf") @nostrip
|
||||
{
|
||||
uint i = bitcast(x, uint);
|
||||
int e = (int)((i >> 23) & 0xff) - 0x7f + 9;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module std::math::math_rt;
|
||||
|
||||
fn int128 __divti3(int128 a, int128 b) @extern("__divti3") @weak @nostrip
|
||||
fn int128 __divti3(int128 a, int128 b) @cname("__divti3") @weak @nostrip
|
||||
{
|
||||
int128 sign_a = a >> 127; // -1 : 0
|
||||
int128 sign_b = b >> 127; // -1 : 0
|
||||
@@ -182,17 +182,17 @@ macro uint128 @__udivmodti4(uint128 a, uint128 b, bool $return_rem)
|
||||
$endif
|
||||
}
|
||||
|
||||
fn uint128 __umodti3(uint128 n, uint128 d) @extern("__umodti3") @weak @nostrip
|
||||
fn uint128 __umodti3(uint128 n, uint128 d) @cname("__umodti3") @weak @nostrip
|
||||
{
|
||||
return @__udivmodti4(n, d, true);
|
||||
}
|
||||
|
||||
fn uint128 __udivti3(uint128 n, uint128 d) @extern("__udivti3") @weak @nostrip
|
||||
fn uint128 __udivti3(uint128 n, uint128 d) @cname("__udivti3") @weak @nostrip
|
||||
{
|
||||
return @__udivmodti4(n, d, false);
|
||||
}
|
||||
|
||||
fn int128 __modti3(int128 a, int128 b) @extern("__modti3") @weak @nostrip
|
||||
fn int128 __modti3(int128 a, int128 b) @cname("__modti3") @weak @nostrip
|
||||
{
|
||||
int128 sign = b >> 127;
|
||||
uint128 unsigned_b = (uint128)(b ^ sign) + (-sign);
|
||||
@@ -212,7 +212,7 @@ union Int128bits @private
|
||||
uint128 all;
|
||||
}
|
||||
|
||||
fn uint128 __lshrti3(uint128 a, uint b) @extern("__lshrti3") @weak @nostrip
|
||||
fn uint128 __lshrti3(uint128 a, uint b) @cname("__lshrti3") @weak @nostrip
|
||||
{
|
||||
Int128bits result;
|
||||
result.all = a;
|
||||
@@ -230,7 +230,7 @@ fn uint128 __lshrti3(uint128 a, uint b) @extern("__lshrti3") @weak @nostrip
|
||||
return result.all;
|
||||
}
|
||||
|
||||
fn int128 __ashrti3(int128 a, uint b) @extern("__ashrti3") @weak @nostrip
|
||||
fn int128 __ashrti3(int128 a, uint b) @cname("__ashrti3") @weak @nostrip
|
||||
{
|
||||
Int128bits result;
|
||||
result.all = a;
|
||||
@@ -248,7 +248,7 @@ fn int128 __ashrti3(int128 a, uint b) @extern("__ashrti3") @weak @nostrip
|
||||
return result.all;
|
||||
}
|
||||
|
||||
fn int128 __ashlti3(int128 a, uint b) @extern("__ashlti3") @weak @nostrip
|
||||
fn int128 __ashlti3(int128 a, uint b) @cname("__ashlti3") @weak @nostrip
|
||||
{
|
||||
Int128bits result;
|
||||
result.all = a;
|
||||
@@ -287,7 +287,7 @@ fn int128 __mulddi3(ulong a, ulong b) @private
|
||||
return r.all;
|
||||
}
|
||||
|
||||
fn int128 __multi3(int128 a, int128 b) @extern("__multi3") @weak @nostrip
|
||||
fn int128 __multi3(int128 a, int128 b) @cname("__multi3") @weak @nostrip
|
||||
{
|
||||
Int128bits x = { .all = a };
|
||||
Int128bits y = { .all = b };
|
||||
@@ -296,14 +296,14 @@ fn int128 __multi3(int128 a, int128 b) @extern("__multi3") @weak @nostrip
|
||||
return r.all;
|
||||
}
|
||||
|
||||
fn float __floattisf(int128 a) @extern("__floattisf") @weak @nostrip => float_from_i128(float, a);
|
||||
fn double __floattidf(int128 a) @extern("__floattidf") @weak @nostrip => float_from_i128(double, a);
|
||||
fn float __floatuntisf(uint128 a) @extern("__floatuntisf") @weak @nostrip => float_from_u128(float, a);
|
||||
fn double __floatuntidf(uint128 a) @extern("__floatuntidf") @weak @nostrip => float_from_u128(double, a);
|
||||
fn uint128 __fixunsdfti(double a) @weak @extern("__fixunsdfti") @nostrip => fixuint(a);
|
||||
fn uint128 __fixunssfti(float a) @weak @extern("__fixunssfti") @nostrip => fixuint(a);
|
||||
fn int128 __fixdfti(double a) @weak @extern("__fixdfti") @nostrip => fixint(a);
|
||||
fn int128 __fixsfti(float a) @weak @extern("__fixsfti") @nostrip => fixint(a);
|
||||
fn float __floattisf(int128 a) @cname("__floattisf") @weak @nostrip => float_from_i128(float, a);
|
||||
fn double __floattidf(int128 a) @cname("__floattidf") @weak @nostrip => float_from_i128(double, a);
|
||||
fn float __floatuntisf(uint128 a) @cname("__floatuntisf") @weak @nostrip => float_from_u128(float, a);
|
||||
fn double __floatuntidf(uint128 a) @cname("__floatuntidf") @weak @nostrip => float_from_u128(double, a);
|
||||
fn uint128 __fixunsdfti(double a) @weak @cname("__fixunsdfti") @nostrip => fixuint(a);
|
||||
fn uint128 __fixunssfti(float a) @weak @cname("__fixunssfti") @nostrip => fixuint(a);
|
||||
fn int128 __fixdfti(double a) @weak @cname("__fixdfti") @nostrip => fixint(a);
|
||||
fn int128 __fixsfti(float a) @weak @cname("__fixsfti") @nostrip => fixint(a);
|
||||
|
||||
|
||||
macro float_from_i128($Type, a) @private
|
||||
|
||||
@@ -8,7 +8,7 @@ macro force_eval_add(x, v)
|
||||
@volatile_store(temp, x + v);
|
||||
}
|
||||
|
||||
fn double __roundeven(double x) @extern("roundeven") @weak @nostrip
|
||||
fn double __roundeven(double x) @cname("roundeven") @weak @nostrip
|
||||
{
|
||||
ulong u = bitcast(x, ulong);
|
||||
int e = (int)((u >> 52) & 0x7ff);
|
||||
@@ -42,7 +42,7 @@ fn double __roundeven(double x) @extern("roundeven") @weak @nostrip
|
||||
return y;
|
||||
}
|
||||
|
||||
fn float __roundevenf(float x) @extern("roundevenf") @weak @nostrip
|
||||
fn float __roundevenf(float x) @cname("roundevenf") @weak @nostrip
|
||||
{
|
||||
uint u = bitcast(x, uint);
|
||||
int e = (u >> 23) & 0xff;
|
||||
@@ -75,7 +75,7 @@ fn float __roundevenf(float x) @extern("roundevenf") @weak @nostrip
|
||||
return y;
|
||||
}
|
||||
|
||||
fn double __powidf2(double a, int b) @extern("__powidf2") @weak @nostrip
|
||||
fn double __powidf2(double a, int b) @cname("__powidf2") @weak @nostrip
|
||||
{
|
||||
bool recip = b < 0;
|
||||
double r = 1;
|
||||
|
||||
@@ -40,30 +40,30 @@ struct LogMessage @packed
|
||||
ZString message;
|
||||
}
|
||||
|
||||
extern fn CInt log_write(LogPriority prio, ZString tag, ZString text) @extern("__android_log_write");
|
||||
extern fn CInt log_print(LogPriority prio, ZString tag, ZString fmt, ...) @extern("__android_log_print");
|
||||
extern fn void log_assert(ZString cond, ZString tag, ZString fmt, ...) @extern("__android_log_assert");
|
||||
extern fn CInt log_write(LogPriority prio, ZString tag, ZString text) @cname("__android_log_write");
|
||||
extern fn CInt log_print(LogPriority prio, ZString tag, ZString fmt, ...) @cname("__android_log_print");
|
||||
extern fn void log_assert(ZString cond, ZString tag, ZString fmt, ...) @cname("__android_log_assert");
|
||||
|
||||
fn bool log_id_is_valid(LogId id)
|
||||
{
|
||||
return id >= LOG_ID_MIN && id < LOG_ID_MAX;
|
||||
}
|
||||
|
||||
extern fn CInt log_buf_write(CInt bufID, CInt prio, ZString tag, ZString text) @extern("__android_log_buf_write");
|
||||
extern fn CInt log_buf_print(CInt bufID, CInt prio, ZString tag, ZString fmt, ...) @extern("__android_log_buf_print");
|
||||
extern fn CInt log_buf_write(CInt bufID, CInt prio, ZString tag, ZString text) @cname("__android_log_buf_write");
|
||||
extern fn CInt log_buf_print(CInt bufID, CInt prio, ZString tag, ZString fmt, ...) @cname("__android_log_buf_print");
|
||||
|
||||
alias LoggerFunction = fn void(LogMessage* log_message);
|
||||
alias AborterFunction = fn void(ZString abort_message);
|
||||
|
||||
extern fn void log_write_log_message(LogMessage log_message) @extern("__android_log_write_log_message");
|
||||
extern fn void log_set_logger(LoggerFunction logger) @extern("__android_log_set_logger");
|
||||
extern fn void log_logd_logger(LogMessage log_message) @extern("__android_log_logd_logger");
|
||||
extern fn void log_stderr_logger(LogMessage log_message) @extern("__android_log_stderr_logger");
|
||||
extern fn void log_set_aborter(AborterFunction aborter) @extern("__android_log_set_aborter");
|
||||
extern fn void log_call_aborter(ZString abort_message) @extern("__android_log_call_aborter");
|
||||
extern fn void log_default_aborter(ZString abort_message) @extern("__android_log_default_aborter");
|
||||
extern fn CInt log_is_loggable(CInt prio, ZString tag, CInt default_prio) @extern("__android_log_is_loggable");
|
||||
extern fn CInt log_is_loggable_len(CInt prio, ZString tag, isz len, CInt default_prio) @extern("__android_log_is_loggable_len");
|
||||
extern fn CInt log_set_minimum_priority(CInt priority) @extern("__android_log_set_minimum_priority");
|
||||
extern fn CInt log_get_minimum_priority() @extern("__android_log_get_minimum_priority");
|
||||
extern fn void log_set_default_tag(ZString tag) @extern("__android_log_set_default_tag");
|
||||
extern fn void log_write_log_message(LogMessage log_message) @cname("__android_log_write_log_message");
|
||||
extern fn void log_set_logger(LoggerFunction logger) @cname("__android_log_set_logger");
|
||||
extern fn void log_logd_logger(LogMessage log_message) @cname("__android_log_logd_logger");
|
||||
extern fn void log_stderr_logger(LogMessage log_message) @cname("__android_log_stderr_logger");
|
||||
extern fn void log_set_aborter(AborterFunction aborter) @cname("__android_log_set_aborter");
|
||||
extern fn void log_call_aborter(ZString abort_message) @cname("__android_log_call_aborter");
|
||||
extern fn void log_default_aborter(ZString abort_message) @cname("__android_log_default_aborter");
|
||||
extern fn CInt log_is_loggable(CInt prio, ZString tag, CInt default_prio) @cname("__android_log_is_loggable");
|
||||
extern fn CInt log_is_loggable_len(CInt prio, ZString tag, isz len, CInt default_prio) @cname("__android_log_is_loggable_len");
|
||||
extern fn CInt log_set_minimum_priority(CInt priority) @cname("__android_log_set_minimum_priority");
|
||||
extern fn CInt log_get_minimum_priority() @cname("__android_log_get_minimum_priority");
|
||||
extern fn void log_set_default_tag(ZString tag) @cname("__android_log_set_default_tag");
|
||||
|
||||
@@ -10,9 +10,9 @@ macro void* CFAllocatorRef.alloc(CFAllocatorRef allocator, usz size) => macos_CF
|
||||
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) @extern("CFAllocatorCreate") @builtin;
|
||||
extern fn void macos_CFAllocatorDeallocate(CFAllocatorRef allocator, void* ptr) @extern("CFAllocatorDeallocate") @builtin;
|
||||
extern fn CFAllocatorRef macos_CFAllocatorGetDefault() @extern("CFAllocatorGetDefault") @builtin;
|
||||
extern fn void macos_CFAllocatorSetDefault(CFAllocatorRef allocator) @extern("CFAllocatorSetDefault") @builtin;
|
||||
extern fn void* macos_CFAllocatorAllocate(CFAllocatorRef allocator, CFIndex size, CFOptionFlags hint) @extern("CFAllocatorAllocate") @builtin;
|
||||
extern fn CFIndex macos_CFAllocatorGetPreferredSizeForSize(CFAllocatorRef allocator, CFIndex size, CFOptionFlags hint) @extern("CFAllocatorGetPreferredSizeForSize") @builtin;
|
||||
extern fn CFAllocatorRef macos_CFAllocatorCreate(CFAllocatorRef allocator, CFAllocatorContextRef context) @cname("CFAllocatorCreate") @builtin;
|
||||
extern fn void macos_CFAllocatorDeallocate(CFAllocatorRef allocator, void* ptr) @cname("CFAllocatorDeallocate") @builtin;
|
||||
extern fn CFAllocatorRef macos_CFAllocatorGetDefault() @cname("CFAllocatorGetDefault") @builtin;
|
||||
extern fn void macos_CFAllocatorSetDefault(CFAllocatorRef allocator) @cname("CFAllocatorSetDefault") @builtin;
|
||||
extern fn void* macos_CFAllocatorAllocate(CFAllocatorRef allocator, CFIndex size, CFOptionFlags hint) @cname("CFAllocatorAllocate") @builtin;
|
||||
extern fn CFIndex macos_CFAllocatorGetPreferredSizeForSize(CFAllocatorRef allocator, CFIndex size, CFOptionFlags hint) @cname("CFAllocatorGetPreferredSizeForSize") @builtin;
|
||||
|
||||
@@ -6,13 +6,13 @@ typedef CFArrayCallBacksRef = void*;
|
||||
typedef CFMutableArray = inline CFArray;
|
||||
typedef CFMutableArrayRef = CFMutableArray*;
|
||||
|
||||
extern fn CFIndex CFArray.getCount(&self) @extern("CFArrayGetCount");
|
||||
extern fn void* CFArray.getValueAtIndex(&self, CFIndex i) @extern("CFArrayGetValueAtIndex");
|
||||
extern fn CFIndex CFArray.getCount(&self) @cname("CFArrayGetCount");
|
||||
extern fn void* CFArray.getValueAtIndex(&self, CFIndex i) @cname("CFArrayGetValueAtIndex");
|
||||
|
||||
extern fn CFArrayRef macos_CFArrayCreate(CFAllocatorRef allocator, void** values, CFIndex num_values, CFArrayCallBacksRef callBacks) @extern("CFArrayCreate") @builtin;
|
||||
extern fn CFArrayRef macos_CFArrayCopy(CFAllocatorRef allocator, CFArrayRef array) @extern("CFArrayCopy") @builtin;
|
||||
extern fn void CFMutableArray.appendArray(&self, CFArrayRef otherArray, CFRange otherRange) @extern("CFArrayAppendArray");
|
||||
extern fn void CFMutableArray.appendValue(&self, void *value) @extern("CFArrayAppendValue");
|
||||
extern fn CFArrayRef macos_CFArrayCreate(CFAllocatorRef allocator, void** values, CFIndex num_values, CFArrayCallBacksRef callBacks) @cname("CFArrayCreate") @builtin;
|
||||
extern fn CFArrayRef macos_CFArrayCopy(CFAllocatorRef allocator, CFArrayRef array) @cname("CFArrayCopy") @builtin;
|
||||
extern fn void CFMutableArray.appendArray(&self, CFArrayRef otherArray, CFRange otherRange) @cname("CFArrayAppendArray");
|
||||
extern fn void CFMutableArray.appendValue(&self, void *value) @cname("CFArrayAppendValue");
|
||||
|
||||
extern fn CFMutableArrayRef macos_CFArrayCreateMutable(CFAllocatorRef allocator, CFIndex capacity, CFArrayCallBacksRef callBacks) @extern("CFArrayCreateMutable") @builtin;
|
||||
extern fn CFMutableArrayRef macos_CFArrayCreateMutable(CFAllocatorRef allocator, CFIndex capacity, CFArrayCallBacksRef callBacks) @cname("CFArrayCreateMutable") @builtin;
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
module std::os::darwin::cocoa @if(env::OS_TYPE == MACOS) @link("Cocoa.framework");
|
||||
|
||||
extern fn int nsApplicationMain(int argc, char **argv) @extern("NSApplicationMain");
|
||||
extern fn int nsApplicationMain(int argc, char **argv) @cname("NSApplicationMain");
|
||||
|
||||
@@ -13,12 +13,12 @@ struct CFRange
|
||||
CFIndex length;
|
||||
}
|
||||
|
||||
extern fn ZString CFString.getCStringPtr(&self, CFStringEncoding encoding) @extern("CFStringGetCStringPtr");
|
||||
extern fn ZString CFString.getCString(&self, char* buffer, usz len, CFStringEncoding encoding) @extern("CFStringGetCString");
|
||||
extern fn ZString CFString.getCStringPtr(&self, CFStringEncoding encoding) @cname("CFStringGetCStringPtr");
|
||||
extern fn ZString CFString.getCString(&self, char* buffer, usz len, CFStringEncoding encoding) @cname("CFStringGetCString");
|
||||
|
||||
extern fn CFTypeRef CFType.retain(&self) @extern("CFRetain");
|
||||
extern fn void CFType.release(&self) @extern("CFRelease");
|
||||
extern fn CFIndex CFType.getRetainCount(&self) @extern("CFGetRetainCount");
|
||||
extern fn CFTypeRef CFType.retain(&self) @cname("CFRetain");
|
||||
extern fn void CFType.release(&self) @cname("CFRelease");
|
||||
extern fn CFIndex CFType.getRetainCount(&self) @cname("CFGetRetainCount");
|
||||
|
||||
enum CFStringEncoding : const uint
|
||||
{
|
||||
|
||||
@@ -37,7 +37,7 @@ const HW_L3CACHESIZE = 22; /* int: L3 Cache Size in Bytes */
|
||||
const HW_MAXID = 23; /* number of valid hw ids */
|
||||
|
||||
extern fn CInt sysctl(CInt *name, CUInt namelen, void *oldp, usz *oldlenp, void *newp, usz newlen);
|
||||
extern fn CInt darwin_NSGetExecutablePath(char* buffer, uint *size) @extern("_NSGetExecutablePath") @builtin;
|
||||
extern fn CInt darwin_NSGetExecutablePath(char* buffer, uint *size) @cname("_NSGetExecutablePath") @builtin;
|
||||
extern fn Darwin_segment_command_64* getsegbyname(ZString segname);
|
||||
extern fn uint _dyld_image_count();
|
||||
extern fn ZString _dyld_get_image_name(uint image_index);
|
||||
|
||||
@@ -42,7 +42,7 @@ enum NSSearchPathDirectory : const NSUInteger
|
||||
}
|
||||
|
||||
// real signature in Foundation
|
||||
extern fn CFArrayRef nsSearchPathForDirectoriesInDomains(NSSearchPathDirectory directory, NSSearchPathDomainMask domainMask, bool expandTilde) @extern("NSSearchPathForDirectoriesInDomains");
|
||||
extern fn CFArrayRef nsSearchPathForDirectoriesInDomains(NSSearchPathDirectory directory, NSSearchPathDomainMask domainMask, bool expandTilde) @cname("NSSearchPathForDirectoriesInDomains");
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ macro ObjcClass[] class_get_list(Allocator allocator)
|
||||
return entries;
|
||||
}
|
||||
|
||||
extern fn void msgSend(...) @extern("objc_msgSend") @builtin;
|
||||
extern fn void msgSend(...) @cname("objc_msgSend") @builtin;
|
||||
extern fn ObjcSelector sel_getUid(ZString);
|
||||
|
||||
macro msg_send(id, $FunctionType, ZString $selector, ...)
|
||||
@@ -55,9 +55,9 @@ macro void @autoreleasepool(;@body())
|
||||
|
||||
extern fn void* objc_autoreleasePoolPush();
|
||||
extern fn void objc_autoreleasePoolPop(void* context);
|
||||
extern fn ObjcClass getClass(ZString name) @extern("objc_getClass");
|
||||
extern fn int getClassList(ObjcClass* buffer, int buffer_count) @extern("objc_getClassList");
|
||||
extern fn ObjcClass lookUpClass(ZString name) @extern("objc_lookUpClass") @builtin;
|
||||
extern fn ObjcClass getClass(ZString name) @cname("objc_getClass");
|
||||
extern fn int getClassList(ObjcClass* buffer, int buffer_count) @cname("objc_getClassList");
|
||||
extern fn ObjcClass lookUpClass(ZString name) @cname("objc_lookUpClass") @builtin;
|
||||
|
||||
extern fn ZString class_getName(ObjcClass cls);
|
||||
extern fn ObjcClass class_getSuperclass(ObjcClass cls);
|
||||
@@ -67,9 +67,9 @@ extern fn ObjcSelector sel_registerName(ZString str);
|
||||
extern fn bool class_addIvar(ObjcClass cls, ZString name, int size, double alignment, ZString types);
|
||||
extern fn bool class_addMethod(ObjcClass cls, ObjcSelector name, void* imp, ZString types);
|
||||
|
||||
extern fn ObjcIvar getInstanceVariable(ObjcId id, ZString name, void* outValue) @extern("object_getInstanceVariable");
|
||||
extern fn ObjcIvar setInstanceVariable(ObjcId id, ZString name, void* value) @extern("object_setInstanceVariable");
|
||||
extern fn ObjcClass allocateClassPair(ObjcClass cls, ZString name, uint extraBytes) @extern("objc_allocateClassPair");
|
||||
extern fn ObjcIvar getInstanceVariable(ObjcId id, ZString name, void* outValue) @cname("object_getInstanceVariable");
|
||||
extern fn ObjcIvar setInstanceVariable(ObjcId id, ZString name, void* value) @cname("object_setInstanceVariable");
|
||||
extern fn ObjcClass allocateClassPair(ObjcClass cls, ZString name, uint extraBytes) @cname("objc_allocateClassPair");
|
||||
|
||||
enum StatusItemLength : (double val)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module std::math::nolibc @if(env::NO_LIBC);
|
||||
|
||||
fn void __stack_chk_fail() @extern("__stack_chk_fail") @nostrip @noreturn @weak
|
||||
fn void __stack_chk_fail() @cname("__stack_chk_fail") @nostrip @noreturn @weak
|
||||
{
|
||||
$$trap();
|
||||
}
|
||||
@@ -32,7 +32,7 @@ extern fn ZString getcwd(char* pwd, usz len);
|
||||
extern fn CInt pipe(CInt[2]* pipes);
|
||||
extern fn CFile fdopen(CInt fd, ZString mode);
|
||||
extern fn CInt access(ZString path, CInt mode);
|
||||
extern fn Posix_dirent* readdir(DIRPtr) @extern("readdir") @if(!USE_DARWIN_INODE64) ;
|
||||
extern fn Posix_dirent* readdir(DIRPtr) @cname("readdir") @if(!USE_DARWIN_INODE64) ;
|
||||
extern fn DIRPtr opendir(ZString);
|
||||
extern fn void closedir(DIRPtr);
|
||||
|
||||
@@ -47,4 +47,4 @@ const DT_SOCK = 12;
|
||||
const DT_WHT = 14;
|
||||
|
||||
const USE_DARWIN_INODE64 = env::DARWIN && env::X86_64;
|
||||
extern fn Posix_dirent* readdir(DIRPtr) @extern("readdir$INODE64") @if(USE_DARWIN_INODE64);
|
||||
extern fn Posix_dirent* readdir(DIRPtr) @cname("readdir$INODE64") @if(USE_DARWIN_INODE64);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module std::os::win32 @if(env::WIN32);
|
||||
import std::math;
|
||||
|
||||
extern fn void getSystemTimeAsFileTime(Win32_FILETIME* time) @extern("GetSystemTimeAsFileTime");
|
||||
extern fn Win32_BOOL queryPerformanceFrequency(Win32_LARGE_INTEGER* lpFrequency) @extern("QueryPerformanceFrequency");
|
||||
extern fn Win32_BOOL queryPerformanceCounter(Win32_LARGE_INTEGER* lpPerformanceCount) @extern("QueryPerformanceCounter");
|
||||
extern fn void getSystemTimeAsFileTime(Win32_FILETIME* time) @cname("GetSystemTimeAsFileTime");
|
||||
extern fn Win32_BOOL queryPerformanceFrequency(Win32_LARGE_INTEGER* lpFrequency) @cname("QueryPerformanceFrequency");
|
||||
extern fn Win32_BOOL queryPerformanceCounter(Win32_LARGE_INTEGER* lpPerformanceCount) @cname("QueryPerformanceCounter");
|
||||
|
||||
@@ -41,18 +41,18 @@ struct Win32_WIN32_FIND_DATAW
|
||||
|
||||
alias Win32_LPWIN32_FIND_DATAW = Win32_WIN32_FIND_DATAW*;
|
||||
|
||||
extern fn Win32_BOOL closeHandle(Win32_HANDLE) @extern("CloseHandle");
|
||||
extern fn Win32_BOOL createPipe(Win32_PHANDLE hReadPipe, Win32_PHANDLE hWritePipe, Win32_LPSECURITY_ATTRIBUTES lpPipeAttributes, Win32_DWORD nSize) @extern("CreatePipe");
|
||||
extern fn Win32_BOOL getFileAttributesExW(Win32_LPCWSTR, Win32_GET_FILEEX_INFO_LEVELS, Win32_LPVOID) @extern("GetFileAttributesExW");
|
||||
extern fn Win32_BOOL pathFileExistsW(Win32_LPCWSTR) @extern("PathFileExistsW");
|
||||
extern fn Win32_DWORD getTempPathW(Win32_DWORD nBufferLength, Win32_LPWSTR lpBuffer) @extern("GetTempPathW");
|
||||
extern fn Win32_BOOL setCurrentDirectoryW(Win32_LPCTSTR buffer) @extern("SetCurrentDirectoryW");
|
||||
extern fn Win32_BOOL removeDirectoryW(Win32_LPCWSTR lpPathName) @extern("RemoveDirectoryW");
|
||||
extern fn Win32_BOOL createDirectoryW(Win32_LPCWSTR lpPathName, Win32_LPSECURITY_ATTRIBUTES lpPipeAttributes) @extern("CreateDirectoryW");
|
||||
extern fn Win32_BOOL deleteFileW(Win32_LPCWSTR lpFileName) @extern("DeleteFileW");
|
||||
extern fn Win32_HANDLE findFirstFileW(Win32_LPCWSTR lpFileName, Win32_LPWIN32_FIND_DATAW lpFindFileData) @extern("FindFirstFileW");
|
||||
extern fn Win32_BOOL findNextFileW(Win32_HANDLE hFindFile, Win32_LPWIN32_FIND_DATAW lpFindFileData) @extern("FindNextFileW");
|
||||
extern fn Win32_BOOL findClose(Win32_HANDLE hFindFile) @extern("FindClose");
|
||||
extern fn Win32_BOOL closeHandle(Win32_HANDLE) @cname("CloseHandle");
|
||||
extern fn Win32_BOOL createPipe(Win32_PHANDLE hReadPipe, Win32_PHANDLE hWritePipe, Win32_LPSECURITY_ATTRIBUTES lpPipeAttributes, Win32_DWORD nSize) @cname("CreatePipe");
|
||||
extern fn Win32_BOOL getFileAttributesExW(Win32_LPCWSTR, Win32_GET_FILEEX_INFO_LEVELS, Win32_LPVOID) @cname("GetFileAttributesExW");
|
||||
extern fn Win32_BOOL pathFileExistsW(Win32_LPCWSTR) @cname("PathFileExistsW");
|
||||
extern fn Win32_DWORD getTempPathW(Win32_DWORD nBufferLength, Win32_LPWSTR lpBuffer) @cname("GetTempPathW");
|
||||
extern fn Win32_BOOL setCurrentDirectoryW(Win32_LPCTSTR buffer) @cname("SetCurrentDirectoryW");
|
||||
extern fn Win32_BOOL removeDirectoryW(Win32_LPCWSTR lpPathName) @cname("RemoveDirectoryW");
|
||||
extern fn Win32_BOOL createDirectoryW(Win32_LPCWSTR lpPathName, Win32_LPSECURITY_ATTRIBUTES lpPipeAttributes) @cname("CreateDirectoryW");
|
||||
extern fn Win32_BOOL deleteFileW(Win32_LPCWSTR lpFileName) @cname("DeleteFileW");
|
||||
extern fn Win32_HANDLE findFirstFileW(Win32_LPCWSTR lpFileName, Win32_LPWIN32_FIND_DATAW lpFindFileData) @cname("FindFirstFileW");
|
||||
extern fn Win32_BOOL findNextFileW(Win32_HANDLE hFindFile, Win32_LPWIN32_FIND_DATAW lpFindFileData) @cname("FindNextFileW");
|
||||
extern fn Win32_BOOL findClose(Win32_HANDLE hFindFile) @cname("FindClose");
|
||||
|
||||
const Win32_DWORD GENERIC_WRITE = 0x40000000;
|
||||
const Win32_DWORD OPEN_EXISTING = 3;
|
||||
@@ -87,10 +87,10 @@ extern fn Win32_HANDLE createFileA(
|
||||
Win32_DWORD dwCreationDisposition,
|
||||
Win32_DWORD dwFlagsAndAttributes,
|
||||
Win32_HANDLE hTemplateFile
|
||||
) @extern("CreateFileA");
|
||||
) @cname("CreateFileA");
|
||||
extern fn Win32_BOOL readFile(Win32_HANDLE hFile, Win32_LPVOID lpBuffer, Win32_DWORD nNumberOfBytesToRead,
|
||||
Win32_LPDWORD lpNumberOfBytesRead, Win32_LPOVERLAPPED lpOverlapped
|
||||
) @extern("ReadFile");
|
||||
) @cname("ReadFile");
|
||||
|
||||
extern fn WString _wgetcwd(Char16* buffer, int maxlen);
|
||||
extern fn usz wcslen(WString str);
|
||||
@@ -104,8 +104,8 @@ extern fn CInt _waccess(WString path, CInt mode);
|
||||
extern fn WString _wfullpath(WString absPath, WString relPath, usz maxLength);
|
||||
|
||||
/*
|
||||
extern ulong _win32_GetCurrentDirectoryW(ulong, Char16* buffer) @extern("GetCurrentDirectoryW");
|
||||
extern bool _win32_CreateSymbolicLinkW(WString symlink_file, WString target_file, ulong flags) @extern("CreateSymbolicLinkW");
|
||||
extern bool _win32_CopyFileW(WString from_file, WString to_file, bool no_overwrite) @extern("CopyFileW");
|
||||
extern ulong _win32_GetFullPathNameW(WString file_name, ulong buffer_len, Char16* buffer, WString* file_part) @extern("GetFullPathNameW");
|
||||
extern ulong _win32_GetCurrentDirectoryW(ulong, Char16* buffer) @cname("GetCurrentDirectoryW");
|
||||
extern bool _win32_CreateSymbolicLinkW(WString symlink_file, WString target_file, ulong flags) @cname("CreateSymbolicLinkW");
|
||||
extern bool _win32_CopyFileW(WString from_file, WString to_file, bool no_overwrite) @cname("CopyFileW");
|
||||
extern ulong _win32_GetFullPathNameW(WString file_name, ulong buffer_len, Char16* buffer, WString* file_part) @cname("GetFullPathNameW");
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module std::os::win32 @if(env::WIN32);
|
||||
|
||||
extern fn Win32_HBRUSH createSolidBrush(Win32_COLORREF) @extern("CreateSolidBrush");
|
||||
extern fn Win32_COLORREF setTextColor(Win32_HDC, Win32_COLORREF) @extern("SetTextColor");
|
||||
extern fn CInt setBkMode(Win32_HDC, CInt) @extern("SetBkMode");
|
||||
extern fn Win32_BOOL textOut(Win32_HDC, CInt, CInt, Win32_LPCWSTR, CInt) @extern("TextOutW");
|
||||
extern fn Win32_HBRUSH createSolidBrush(Win32_COLORREF) @cname("CreateSolidBrush");
|
||||
extern fn Win32_COLORREF setTextColor(Win32_HDC, Win32_COLORREF) @cname("SetTextColor");
|
||||
extern fn CInt setBkMode(Win32_HDC, CInt) @cname("SetBkMode");
|
||||
extern fn Win32_BOOL textOut(Win32_HDC, CInt, CInt, Win32_LPCWSTR, CInt) @cname("TextOutW");
|
||||
@@ -1,6 +1,6 @@
|
||||
module std::os::win32 @if(env::WIN32);
|
||||
|
||||
extern fn Win32_DWORD getLastError() @extern("GetLastError");
|
||||
extern fn Win32_DWORD getLastError() @cname("GetLastError");
|
||||
|
||||
const Win32_DWORD ERROR_INVALID_FUNCTION = 0x1;
|
||||
const Win32_DWORD ERROR_FILE_NOT_FOUND = 0x2;
|
||||
|
||||
@@ -3,25 +3,25 @@ module std::os::win32 @if(env::WIN32);
|
||||
typedef Win32_DLL_DIRECTORY_COOKIE = void*;
|
||||
alias Win32_PDLL_DIRECTORY_COOKIE = Win32_DLL_DIRECTORY_COOKIE*;
|
||||
|
||||
extern fn Win32_HMODULE loadLibraryA(Win32_LPCSTR lpLibFileName) @extern("LoadLibraryA");
|
||||
extern fn Win32_HMODULE loadLibraryW(Win32_LPCWSTR lpLibFileName) @extern("LoadLibraryW");
|
||||
extern fn Win32_HMODULE loadLibraryExA(Win32_LPCSTR lpLibFileName, Win32_HANDLE hFile, Win32_DWORD dwFlags) @extern("LoadLibraryExA");
|
||||
extern fn Win32_HMODULE loadLibraryExW(Win32_LPCWSTR lpLibFileName, Win32_HANDLE hFile, Win32_DWORD dwFlags) @extern("LoadLibraryExW");
|
||||
extern fn Win32_HMODULE loadLibraryA(Win32_LPCSTR lpLibFileName) @cname("LoadLibraryA");
|
||||
extern fn Win32_HMODULE loadLibraryW(Win32_LPCWSTR lpLibFileName) @cname("LoadLibraryW");
|
||||
extern fn Win32_HMODULE loadLibraryExA(Win32_LPCSTR lpLibFileName, Win32_HANDLE hFile, Win32_DWORD dwFlags) @cname("LoadLibraryExA");
|
||||
extern fn Win32_HMODULE loadLibraryExW(Win32_LPCWSTR lpLibFileName, Win32_HANDLE hFile, Win32_DWORD dwFlags) @cname("LoadLibraryExW");
|
||||
|
||||
extern fn Win32_BOOL freeLibrary(Win32_HMODULE hLibModule) @extern("FreeLibrary");
|
||||
extern fn void freeLibraryAndExitThread(Win32_HMODULE hLibModule, Win32_DWORD dwExitCode) @extern("FreeLibraryAndExitThread");
|
||||
extern fn Win32_BOOL freeLibrary(Win32_HMODULE hLibModule) @cname("FreeLibrary");
|
||||
extern fn void freeLibraryAndExitThread(Win32_HMODULE hLibModule, Win32_DWORD dwExitCode) @cname("FreeLibraryAndExitThread");
|
||||
|
||||
extern fn Win32_DWORD getModuleFileNameA(Win32_HMODULE hModule, Win32_LPSTR lpFilename, Win32_DWORD nSize) @extern("GetModuleFileNameA");
|
||||
extern fn Win32_DWORD getModuleFileNameW(Win32_HMODULE hModule, Win32_LPWSTR lpFilename, Win32_DWORD nSize) @extern("GetModuleFileNameW");
|
||||
extern fn Win32_DWORD getModuleFileNameA(Win32_HMODULE hModule, Win32_LPSTR lpFilename, Win32_DWORD nSize) @cname("GetModuleFileNameA");
|
||||
extern fn Win32_DWORD getModuleFileNameW(Win32_HMODULE hModule, Win32_LPWSTR lpFilename, Win32_DWORD nSize) @cname("GetModuleFileNameW");
|
||||
|
||||
extern fn Win32_HMODULE getModuleHandleA(Win32_LPCSTR lpModuleName) @extern("GetModuleHandleA");
|
||||
extern fn Win32_HMODULE getModuleHandleW(Win32_LPCWSTR lpModuleName) @extern("GetModuleHandleW");
|
||||
extern fn Win32_BOOL getModuleHandleExA(Win32_DWORD dwFlags, Win32_LPCSTR lpModuleName, Win32_HMODULE* phModule) @extern("GetModuleHandleExA");
|
||||
extern fn Win32_BOOL getModuleHandleExW(Win32_DWORD dwFlags, Win32_LPCWSTR lpModuleName, Win32_HMODULE* phModule) @extern("GetModuleHandleExW");
|
||||
extern fn Win32_HMODULE getModuleHandleA(Win32_LPCSTR lpModuleName) @cname("GetModuleHandleA");
|
||||
extern fn Win32_HMODULE getModuleHandleW(Win32_LPCWSTR lpModuleName) @cname("GetModuleHandleW");
|
||||
extern fn Win32_BOOL getModuleHandleExA(Win32_DWORD dwFlags, Win32_LPCSTR lpModuleName, Win32_HMODULE* phModule) @cname("GetModuleHandleExA");
|
||||
extern fn Win32_BOOL getModuleHandleExW(Win32_DWORD dwFlags, Win32_LPCWSTR lpModuleName, Win32_HMODULE* phModule) @cname("GetModuleHandleExW");
|
||||
|
||||
extern fn Win32_BOOL disableThreadLibraryCalls(Win32_HMODULE hLibModule) @extern("DisableThreadLibraryCalls");
|
||||
extern fn Win32_BOOL disableThreadLibraryCalls(Win32_HMODULE hLibModule) @cname("DisableThreadLibraryCalls");
|
||||
|
||||
extern fn Win32_FARPROC getProcAddress(Win32_HMODULE hModule, Win32_LPCSTR lpProcName) @extern("GetProcAddress");
|
||||
extern fn Win32_DLL_DIRECTORY_COOKIE addDllDirectory(Win32_PCWSTR newDirectory) @extern("AddDllDirectory");
|
||||
extern fn Win32_BOOL removeDllDirectory(Win32_DLL_DIRECTORY_COOKIE cookie) @extern("RemoveDllDirectory");
|
||||
extern fn Win32_BOOL setDefaultDllDirectories(Win32_DWORD directoryFlags) @extern("SetDefaultDllDirectories");
|
||||
extern fn Win32_FARPROC getProcAddress(Win32_HMODULE hModule, Win32_LPCSTR lpProcName) @cname("GetProcAddress");
|
||||
extern fn Win32_DLL_DIRECTORY_COOKIE addDllDirectory(Win32_PCWSTR newDirectory) @cname("AddDllDirectory");
|
||||
extern fn Win32_BOOL removeDllDirectory(Win32_DLL_DIRECTORY_COOKIE cookie) @cname("RemoveDllDirectory");
|
||||
extern fn Win32_BOOL setDefaultDllDirectories(Win32_DWORD directoryFlags) @cname("SetDefaultDllDirectories");
|
||||
@@ -36,10 +36,10 @@ enum Win32_FreeType : const Win32_DWORD
|
||||
MEM_COALESCE_PLACEHOLDERS = 0x00000001,
|
||||
MEM_PRESERVE_PLACEHOLDER = 0x00000002,
|
||||
}
|
||||
extern fn Win32_LPVOID virtualAlloc(Win32_LPVOID lpAddress, Win32_SIZE_T dwSize, Win32_AllocationType flAllocationType, Win32_Protect flProtect) @extern("VirtualAlloc");
|
||||
extern fn Win32_PVOID virtualAlloc2(Win32_HANDLE process, Win32_PVOID baseAddress, Win32_SIZE_T size, Win32_AllocationType allocationType, Win32_ULONG pageProtection, Win32_MEM_EXTENDED_PARAMETER* extendedParameters, Win32_ULONG parameterCount) @extern("VirtualAlloc2");
|
||||
extern fn Win32_BOOL virtualFree(Win32_LPVOID lpAddress, Win32_SIZE_T dwSize, Win32_FreeType dwFreeType) @extern("VirtualFree");
|
||||
extern fn Win32_BOOL virtualProtect(Win32_LPVOID lpAddress, Win32_SIZE_T dwSize, Win32_Protect flNewProtect, Win32_Protect* lpflOldProtect) @extern("VirtualProtect");
|
||||
extern fn Win32_LPVOID virtualAlloc(Win32_LPVOID lpAddress, Win32_SIZE_T dwSize, Win32_AllocationType flAllocationType, Win32_Protect flProtect) @cname("VirtualAlloc");
|
||||
extern fn Win32_PVOID virtualAlloc2(Win32_HANDLE process, Win32_PVOID baseAddress, Win32_SIZE_T size, Win32_AllocationType allocationType, Win32_ULONG pageProtection, Win32_MEM_EXTENDED_PARAMETER* extendedParameters, Win32_ULONG parameterCount) @cname("VirtualAlloc2");
|
||||
extern fn Win32_BOOL virtualFree(Win32_LPVOID lpAddress, Win32_SIZE_T dwSize, Win32_FreeType dwFreeType) @cname("VirtualFree");
|
||||
extern fn Win32_BOOL virtualProtect(Win32_LPVOID lpAddress, Win32_SIZE_T dwSize, Win32_Protect flNewProtect, Win32_Protect* lpflOldProtect) @cname("VirtualProtect");
|
||||
|
||||
fn usz allocation_granularity()
|
||||
{
|
||||
|
||||
@@ -48,76 +48,76 @@ const UNDNAME_COMPLETE = 0x0000;
|
||||
|
||||
alias Win32_INIT_ONCE_FN = fn Win32_BOOL(Win32_INIT_ONCE* initOnce, void* parameter, void** context);
|
||||
|
||||
extern fn void initializeCriticalSection(Win32_CRITICAL_SECTION* section) @extern("InitializeCriticalSection");
|
||||
extern fn void deleteCriticalSection(Win32_CRITICAL_SECTION* section) @extern("DeleteCriticalSection");
|
||||
extern fn Win32_HANDLE createMutex(void*, Win32_BOOL, void*) @extern("CreateMutexA");
|
||||
extern fn Win32_BOOL releaseMutex(Win32_HANDLE) @extern("ReleaseMutex");
|
||||
extern fn void enterCriticalSection(Win32_CRITICAL_SECTION* section) @extern("EnterCriticalSection");
|
||||
extern fn void leaveCriticalSection(Win32_CRITICAL_SECTION* section) @extern("LeaveCriticalSection");
|
||||
extern fn Win32_BOOL tryEnterCriticalSection(Win32_CRITICAL_SECTION* section) @extern("TryEnterCriticalSection");
|
||||
extern fn void initializeSRWLock(Win32_SRWLOCK* lock) @extern("InitializeSRWLock");
|
||||
extern fn void acquireSRWLockExclusive(Win32_SRWLOCK* lock) @extern("AcquireSRWLockExclusive");
|
||||
extern fn void acquireSRWLockShared(Win32_SRWLOCK* lock) @extern("AcquireSRWLockShared");
|
||||
extern fn void releaseSRWLockExclusive(Win32_SRWLOCK* lock) @extern("ReleaseSRWLockExclusive");
|
||||
extern fn void releaseSRWLockShared(Win32_SRWLOCK* lock) @extern("ReleaseSRWLockShared");
|
||||
extern fn Win32_BOOL tryAcquireSRWLockExclusive(Win32_SRWLOCK* lock) @extern("TryAcquireSRWLockExclusive");
|
||||
extern fn Win32_BOOL tryAcquireSRWLockShared(Win32_SRWLOCK* lock) @extern("TryAcquireSRWLockShared");
|
||||
extern fn void initializeConditionVariable(Win32_CONDITION_VARIABLE* conditionVariable) @extern("InitializeConditionVariable");
|
||||
extern fn void wakeConditionVariable(Win32_CONDITION_VARIABLE* conditionVariable) @extern("WakeConditionVariable");
|
||||
extern fn void wakeAllConditionVariable(Win32_CONDITION_VARIABLE* conditionVariable) @extern("WakeAllConditionVariable");
|
||||
extern fn Win32_BOOL sleepConditionVariableCS(Win32_CONDITION_VARIABLE* conditionVariable, Win32_CRITICAL_SECTION* section, Win32_DWORD dwMilliseconds) @extern("SleepConditionVariableCS");
|
||||
extern fn Win32_BOOL sleepConditionVariableSRW(Win32_CONDITION_VARIABLE* conditionVariable, Win32_SRWLOCK* lock, Win32_DWORD dwMilliseconds, Win32_ULONG flags) @extern("SleepConditionVariableSRW");
|
||||
extern fn Win32_BOOL initOnceExecuteOnce(Win32_INIT_ONCE* initOnce, Win32_INIT_ONCE_FN initFn, void* parameter, void** context) @extern("InitOnceExecuteOnce");
|
||||
extern fn Win32_DWORD waitForSingleObject(Win32_HANDLE hHandle, Win32_DWORD dwMilliseconds) @extern("WaitForSingleObject");
|
||||
extern fn Win32_DWORD waitForSingleObjectEx(Win32_HANDLE hHandle, Win32_DWORD dwMilliseconds, Win32_BOOL bAlertable) @extern("WaitForSingleObjectEx");
|
||||
extern fn Win32_DWORD waitForMultipleObjects(Win32_DWORD nCount, Win32_HANDLE* lpHandles, Win32_BOOL bWaitAll, Win32_DWORD dwMilliseconds) @extern("WaitForMultipleObjects");
|
||||
extern fn Win32_DWORD waitForMultipleObjectsEx(Win32_DWORD nCount, Win32_HANDLE* lpHandles, Win32_BOOL bWaitAll, Win32_DWORD dwMilliseconds, Win32_BOOL bAlertable) @extern("WaitForMultipleObjectsEx");
|
||||
extern fn void sleep(uint ms) @extern("Sleep");
|
||||
extern fn Win32_BOOL resetEvent(Win32_HANDLE event) @extern("ResetEvent");
|
||||
extern fn Win32_BOOL setEvent(Win32_HANDLE handle) @extern("SetEvent");
|
||||
extern fn long interlockedCompareExchange(int* dest, int exchange, int comperand) @extern("InterlockedCompareExchange");
|
||||
extern fn Win32_DWORD sleepEx(Win32_DWORD ms, Win32_BOOL alertable) @extern("SleepEx");
|
||||
extern fn Win32_HANDLE createThread(void* attributes, usz stack, ThreadFn func, Win32_LPVOID arg, Win32_DWORD flags, Win32_LPDWORD thread_id) @extern("CreateThread");
|
||||
extern fn Win32_BOOL getExitCodeThread(Win32_HANDLE handle, Win32_LPDWORD exit_code) @extern("GetExitCodeThread");
|
||||
extern fn Win32_BOOL getExitCodeProcess(Win32_HANDLE hProcess, Win32_LPDWORD lpExitCode) @extern("GetExitCodeProcess");
|
||||
extern fn Win32_DWORD getThreadId(Win32_HANDLE) @extern("GetThreadId");
|
||||
extern fn void exitThread(Win32_DWORD dwExitCode) @noreturn @extern("ExitThread");
|
||||
extern fn Win32_HANDLE getCurrentThread() @extern("GetCurrentThread");
|
||||
extern fn Win32_BOOL terminateProcess(Win32_HANDLE hProcess, Win32_UINT uExitCode) @extern("TerminateProcess");
|
||||
extern fn Win32_DWORD getCurrentProcessId() @extern("GetCurrentProcessId");
|
||||
extern fn Win32_HANDLE getCurrentProcess() @extern("GetCurrentProcess");
|
||||
extern fn Win32_DWORD getCurrentThreadId() @extern("GetCurrentThreadId");
|
||||
extern fn Win32_BOOL setHandleInformation(Win32_HANDLE hObject, Win32_DWORD dwMask, Win32_DWORD dwFlags) @extern("SetHandleInformation");
|
||||
extern fn Win32_HANDLE createEventA(Win32_LPSECURITY_ATTRIBUTES lpEventAttributes, Win32_BOOL bManualReset, Win32_BOOL bInitialState, Win32_LPCSTR lpName) @extern("CreateEventA");
|
||||
extern fn Win32_BOOL createProcessW(Win32_LPCWSTR lpApplicationName, Win32_LPWSTR lpCommandLine, Win32_LPSECURITY_ATTRIBUTES lpProcessAttributes, Win32_LPSECURITY_ATTRIBUTES lpThreadAttributes, Win32_BOOL bInheritHandles, Win32_DWORD dwCreationFlags, Win32_LPVOID lpEnvironment, Win32_LPCWSTR lpCurrentDirectory, Win32_LPSTARTUPINFOW lpStartupInfo, Win32_LPPROCESS_INFORMATION lpProcessInformation) @extern("CreateProcessW");
|
||||
extern fn Win32_HANDLE createNamedPipeA(Win32_LPCSTR lpName, Win32_DWORD dwOpenMode, Win32_DWORD dwPipeMode, Win32_DWORD nMaxInstances, Win32_DWORD nOutBufferSize, Win32_DWORD nInBufferSize, Win32_DWORD nDefaultTimeOut, Win32_LPSECURITY_ATTRIBUTES lpSecurityAttributes) @extern("CreateNamedPipeA");
|
||||
extern fn Win32_BOOL getOverlappedResult(Win32_HANDLE hFile, Win32_LPOVERLAPPED lpOverlapped, Win32_LPDWORD lpNumberOfBytesTransferred, Win32_BOOL bWait) @extern("GetOverlappedResult");
|
||||
extern fn Win32_DWORD getEnvironmentVariableW(Win32_LPCWSTR lpName, Win32_LPWSTR lpBuffer, Win32_DWORD nSize) @extern("GetEnvironmentVariableW");
|
||||
extern fn Win32_BOOL setEnvironmentVariableW(Win32_LPCWSTR lpName, Win32_LPCWSTR lpValue) @extern("SetEnvironmentVariableW");
|
||||
extern fn void getSystemInfo(Win32_LPSYSTEM_INFO lpSystemInfo) @extern("GetSystemInfo");
|
||||
extern fn Win32_BOOL enumProcessModules(Win32_HANDLE hProcess, Win32_HMODULE* lphModule, Win32_DWORD cb, Win32_LPDWORD lpcbNeeded) @extern("K32EnumProcessModules");
|
||||
extern fn Win32_BOOL getModuleInformation(Win32_HANDLE hProcess, Win32_HMODULE hModule, Win32_LPMODULEINFO lpmodinfo, Win32_DWORD cb) @extern("K32GetModuleInformation");
|
||||
extern fn Win32_DWORD symAddrIncludeInlineTrace(Win32_HANDLE hProcess, Win32_DWORD64 address) @extern("SymAddrIncludeInlineTrace");
|
||||
extern fn Win32_BOOL symQueryInlineTrace(Win32_HANDLE hProcess, Win32_DWORD64 startAddress, Win32_DWORD startContext, Win32_DWORD64 startRetAddress, Win32_DWORD64 curAddress, Win32_LPDWORD curContext, Win32_LPDWORD curFrameIndex) @extern("SymQueryInlineTrace");
|
||||
extern fn Win32_BOOL symFromInlineContext(Win32_HANDLE hProcess, Win32_DWORD64 address, Win32_ULONG inlineContext, Win32_PDWORD64 displacement, Win32_PSYMBOL_INFO symbol) @extern("SymFromInlineContext");
|
||||
extern fn Win32_BOOL symGetLineFromInlineContext(Win32_HANDLE hProcess, Win32_DWORD64 qwAddr, Win32_ULONG inlineContext, Win32_DWORD64 qwModuleBaseAddress, Win32_PDWORD pdwDisplacement, Win32_PIMAGEHLP_LINE64 line64) @extern("SymGetLineFromInlineContext");
|
||||
extern fn Win32_ULONG rtlWalkFrameChain(Win32_PVOID*, Win32_ULONG, Win32_ULONG) @extern("RtlWalkFrameChain");
|
||||
extern fn Win32_BOOL symInitialize(Win32_HANDLE hProcess, Win32_PCSTR userSearchPath, Win32_BOOL fInvadeProcess) @extern("SymInitialize");
|
||||
extern fn Win32_BOOL symCleanup(Win32_HANDLE hProcess) @extern("SymCleanup");
|
||||
extern fn Win32_DWORD64 symLoadModuleEx(Win32_HANDLE hProcess, Win32_HANDLE hFile, Win32_PCSTR imageName, Win32_PCSTR moduleName, Win32_DWORD64 baseOfDll, Win32_DWORD dllSize, Win32_PMODLOAD_DATA data, Win32_DWORD flags) @extern("SymLoadModule");
|
||||
extern fn Win32_BOOL stackWalk64(Win32_DWORD machineType, Win32_HANDLE hProcess, Win32_HANDLE hThread, Win32_LPSTACKFRAME64 stackFrame, Win32_PVOID contextRecord, Win32_PREAD_PROCESS_MEMORY_ROUTINE64 readMemoryRoutine, Win32_PFUNCTION_TABLE_ACCESS_ROUTINE64 functionTableAccessRoutine, Win32_PGET_MODULE_BASE_ROUTINE64 getModuleBaseRoutine, Win32_PTRANSLATE_ADDRESS_ROUTINE64 translateAddress) @extern("StackWalk64");
|
||||
extern fn void rtlCaptureContext(Win32_PCONTEXT contextRecord) @extern("RtlCaptureContext");
|
||||
extern fn void* symFunctionTableAccess64(Win32_HANDLE hProcess, Win32_DWORD64 addrBase) @extern("SymFunctionTableAccess64");
|
||||
extern fn Win32_DWORD64 symGetModuleBase64(Win32_HANDLE hProcess, Win32_DWORD64 qwAddr) @extern("SymGetModuleBase64");
|
||||
extern fn Win32_DWORD getModuleBaseNameA(Win32_HANDLE hProcess, Win32_HMODULE hModule, Win32_LPSTR lpBaseName, Win32_DWORD nSize) @extern("K32GetModuleBaseNameA");
|
||||
extern fn Win32_DWORD symGetOptions() @extern("SymGetOptions");
|
||||
extern fn Win32_DWORD symSetOptions(Win32_DWORD symOptions) @extern("SymSetOptions");
|
||||
extern fn Win32_PIMAGE_NT_HEADERS imageNtHeader(Win32_PVOID base) @extern("ImageNtHeader");
|
||||
extern fn Win32_DWORD unDecorateSymbolName(Win32_PCSTR name, Win32_PSTR outputString, Win32_DWORD maxStringLength, Win32_DWORD flags) @extern("UnDecorateSymbolName");
|
||||
extern fn Win32_BOOL symFromAddr(Win32_HANDLE hProcess, Win32_DWORD64 address, Win32_PDWORD64 displacement, Win32_PSYMBOL_INFO symbol) @extern("SymFromAddr");
|
||||
extern fn Win32_BOOL symGetLineFromAddr64(Win32_HANDLE hProcess, Win32_DWORD64 dwAddr, Win32_PDWORD pdwDisplacement, Win32_PIMAGEHLP_LINE64 line) @extern("SymGetLineFromAddr64");
|
||||
extern fn Win32_WORD rtlCaptureStackBackTrace(Win32_DWORD framesToSkip, Win32_DWORD framesToCapture, Win32_PVOID *backTrace, Win32_PDWORD backTraceHash) @extern("RtlCaptureStackBackTrace");
|
||||
extern fn Win32_BOOL symGetModuleInfo64(Win32_HANDLE hProcess, Win32_DWORD64 qwAddr, Win32_PIMAGEHLP_MODULE64 moduleInfo) @extern("SymGetModuleInfo64");
|
||||
extern fn void initializeCriticalSection(Win32_CRITICAL_SECTION* section) @cname("InitializeCriticalSection");
|
||||
extern fn void deleteCriticalSection(Win32_CRITICAL_SECTION* section) @cname("DeleteCriticalSection");
|
||||
extern fn Win32_HANDLE createMutex(void*, Win32_BOOL, void*) @cname("CreateMutexA");
|
||||
extern fn Win32_BOOL releaseMutex(Win32_HANDLE) @cname("ReleaseMutex");
|
||||
extern fn void enterCriticalSection(Win32_CRITICAL_SECTION* section) @cname("EnterCriticalSection");
|
||||
extern fn void leaveCriticalSection(Win32_CRITICAL_SECTION* section) @cname("LeaveCriticalSection");
|
||||
extern fn Win32_BOOL tryEnterCriticalSection(Win32_CRITICAL_SECTION* section) @cname("TryEnterCriticalSection");
|
||||
extern fn void initializeSRWLock(Win32_SRWLOCK* lock) @cname("InitializeSRWLock");
|
||||
extern fn void acquireSRWLockExclusive(Win32_SRWLOCK* lock) @cname("AcquireSRWLockExclusive");
|
||||
extern fn void acquireSRWLockShared(Win32_SRWLOCK* lock) @cname("AcquireSRWLockShared");
|
||||
extern fn void releaseSRWLockExclusive(Win32_SRWLOCK* lock) @cname("ReleaseSRWLockExclusive");
|
||||
extern fn void releaseSRWLockShared(Win32_SRWLOCK* lock) @cname("ReleaseSRWLockShared");
|
||||
extern fn Win32_BOOL tryAcquireSRWLockExclusive(Win32_SRWLOCK* lock) @cname("TryAcquireSRWLockExclusive");
|
||||
extern fn Win32_BOOL tryAcquireSRWLockShared(Win32_SRWLOCK* lock) @cname("TryAcquireSRWLockShared");
|
||||
extern fn void initializeConditionVariable(Win32_CONDITION_VARIABLE* conditionVariable) @cname("InitializeConditionVariable");
|
||||
extern fn void wakeConditionVariable(Win32_CONDITION_VARIABLE* conditionVariable) @cname("WakeConditionVariable");
|
||||
extern fn void wakeAllConditionVariable(Win32_CONDITION_VARIABLE* conditionVariable) @cname("WakeAllConditionVariable");
|
||||
extern fn Win32_BOOL sleepConditionVariableCS(Win32_CONDITION_VARIABLE* conditionVariable, Win32_CRITICAL_SECTION* section, Win32_DWORD dwMilliseconds) @cname("SleepConditionVariableCS");
|
||||
extern fn Win32_BOOL sleepConditionVariableSRW(Win32_CONDITION_VARIABLE* conditionVariable, Win32_SRWLOCK* lock, Win32_DWORD dwMilliseconds, Win32_ULONG flags) @cname("SleepConditionVariableSRW");
|
||||
extern fn Win32_BOOL initOnceExecuteOnce(Win32_INIT_ONCE* initOnce, Win32_INIT_ONCE_FN initFn, void* parameter, void** context) @cname("InitOnceExecuteOnce");
|
||||
extern fn Win32_DWORD waitForSingleObject(Win32_HANDLE hHandle, Win32_DWORD dwMilliseconds) @cname("WaitForSingleObject");
|
||||
extern fn Win32_DWORD waitForSingleObjectEx(Win32_HANDLE hHandle, Win32_DWORD dwMilliseconds, Win32_BOOL bAlertable) @cname("WaitForSingleObjectEx");
|
||||
extern fn Win32_DWORD waitForMultipleObjects(Win32_DWORD nCount, Win32_HANDLE* lpHandles, Win32_BOOL bWaitAll, Win32_DWORD dwMilliseconds) @cname("WaitForMultipleObjects");
|
||||
extern fn Win32_DWORD waitForMultipleObjectsEx(Win32_DWORD nCount, Win32_HANDLE* lpHandles, Win32_BOOL bWaitAll, Win32_DWORD dwMilliseconds, Win32_BOOL bAlertable) @cname("WaitForMultipleObjectsEx");
|
||||
extern fn void sleep(uint ms) @cname("Sleep");
|
||||
extern fn Win32_BOOL resetEvent(Win32_HANDLE event) @cname("ResetEvent");
|
||||
extern fn Win32_BOOL setEvent(Win32_HANDLE handle) @cname("SetEvent");
|
||||
extern fn long interlockedCompareExchange(int* dest, int exchange, int comperand) @cname("InterlockedCompareExchange");
|
||||
extern fn Win32_DWORD sleepEx(Win32_DWORD ms, Win32_BOOL alertable) @cname("SleepEx");
|
||||
extern fn Win32_HANDLE createThread(void* attributes, usz stack, ThreadFn func, Win32_LPVOID arg, Win32_DWORD flags, Win32_LPDWORD thread_id) @cname("CreateThread");
|
||||
extern fn Win32_BOOL getExitCodeThread(Win32_HANDLE handle, Win32_LPDWORD exit_code) @cname("GetExitCodeThread");
|
||||
extern fn Win32_BOOL getExitCodeProcess(Win32_HANDLE hProcess, Win32_LPDWORD lpExitCode) @cname("GetExitCodeProcess");
|
||||
extern fn Win32_DWORD getThreadId(Win32_HANDLE) @cname("GetThreadId");
|
||||
extern fn void exitThread(Win32_DWORD dwExitCode) @noreturn @cname("ExitThread");
|
||||
extern fn Win32_HANDLE getCurrentThread() @cname("GetCurrentThread");
|
||||
extern fn Win32_BOOL terminateProcess(Win32_HANDLE hProcess, Win32_UINT uExitCode) @cname("TerminateProcess");
|
||||
extern fn Win32_DWORD getCurrentProcessId() @cname("GetCurrentProcessId");
|
||||
extern fn Win32_HANDLE getCurrentProcess() @cname("GetCurrentProcess");
|
||||
extern fn Win32_DWORD getCurrentThreadId() @cname("GetCurrentThreadId");
|
||||
extern fn Win32_BOOL setHandleInformation(Win32_HANDLE hObject, Win32_DWORD dwMask, Win32_DWORD dwFlags) @cname("SetHandleInformation");
|
||||
extern fn Win32_HANDLE createEventA(Win32_LPSECURITY_ATTRIBUTES lpEventAttributes, Win32_BOOL bManualReset, Win32_BOOL bInitialState, Win32_LPCSTR lpName) @cname("CreateEventA");
|
||||
extern fn Win32_BOOL createProcessW(Win32_LPCWSTR lpApplicationName, Win32_LPWSTR lpCommandLine, Win32_LPSECURITY_ATTRIBUTES lpProcessAttributes, Win32_LPSECURITY_ATTRIBUTES lpThreadAttributes, Win32_BOOL bInheritHandles, Win32_DWORD dwCreationFlags, Win32_LPVOID lpEnvironment, Win32_LPCWSTR lpCurrentDirectory, Win32_LPSTARTUPINFOW lpStartupInfo, Win32_LPPROCESS_INFORMATION lpProcessInformation) @cname("CreateProcessW");
|
||||
extern fn Win32_HANDLE createNamedPipeA(Win32_LPCSTR lpName, Win32_DWORD dwOpenMode, Win32_DWORD dwPipeMode, Win32_DWORD nMaxInstances, Win32_DWORD nOutBufferSize, Win32_DWORD nInBufferSize, Win32_DWORD nDefaultTimeOut, Win32_LPSECURITY_ATTRIBUTES lpSecurityAttributes) @cname("CreateNamedPipeA");
|
||||
extern fn Win32_BOOL getOverlappedResult(Win32_HANDLE hFile, Win32_LPOVERLAPPED lpOverlapped, Win32_LPDWORD lpNumberOfBytesTransferred, Win32_BOOL bWait) @cname("GetOverlappedResult");
|
||||
extern fn Win32_DWORD getEnvironmentVariableW(Win32_LPCWSTR lpName, Win32_LPWSTR lpBuffer, Win32_DWORD nSize) @cname("GetEnvironmentVariableW");
|
||||
extern fn Win32_BOOL setEnvironmentVariableW(Win32_LPCWSTR lpName, Win32_LPCWSTR lpValue) @cname("SetEnvironmentVariableW");
|
||||
extern fn void getSystemInfo(Win32_LPSYSTEM_INFO lpSystemInfo) @cname("GetSystemInfo");
|
||||
extern fn Win32_BOOL enumProcessModules(Win32_HANDLE hProcess, Win32_HMODULE* lphModule, Win32_DWORD cb, Win32_LPDWORD lpcbNeeded) @cname("K32EnumProcessModules");
|
||||
extern fn Win32_BOOL getModuleInformation(Win32_HANDLE hProcess, Win32_HMODULE hModule, Win32_LPMODULEINFO lpmodinfo, Win32_DWORD cb) @cname("K32GetModuleInformation");
|
||||
extern fn Win32_DWORD symAddrIncludeInlineTrace(Win32_HANDLE hProcess, Win32_DWORD64 address) @cname("SymAddrIncludeInlineTrace");
|
||||
extern fn Win32_BOOL symQueryInlineTrace(Win32_HANDLE hProcess, Win32_DWORD64 startAddress, Win32_DWORD startContext, Win32_DWORD64 startRetAddress, Win32_DWORD64 curAddress, Win32_LPDWORD curContext, Win32_LPDWORD curFrameIndex) @cname("SymQueryInlineTrace");
|
||||
extern fn Win32_BOOL symFromInlineContext(Win32_HANDLE hProcess, Win32_DWORD64 address, Win32_ULONG inlineContext, Win32_PDWORD64 displacement, Win32_PSYMBOL_INFO symbol) @cname("SymFromInlineContext");
|
||||
extern fn Win32_BOOL symGetLineFromInlineContext(Win32_HANDLE hProcess, Win32_DWORD64 qwAddr, Win32_ULONG inlineContext, Win32_DWORD64 qwModuleBaseAddress, Win32_PDWORD pdwDisplacement, Win32_PIMAGEHLP_LINE64 line64) @cname("SymGetLineFromInlineContext");
|
||||
extern fn Win32_ULONG rtlWalkFrameChain(Win32_PVOID*, Win32_ULONG, Win32_ULONG) @cname("RtlWalkFrameChain");
|
||||
extern fn Win32_BOOL symInitialize(Win32_HANDLE hProcess, Win32_PCSTR userSearchPath, Win32_BOOL fInvadeProcess) @cname("SymInitialize");
|
||||
extern fn Win32_BOOL symCleanup(Win32_HANDLE hProcess) @cname("SymCleanup");
|
||||
extern fn Win32_DWORD64 symLoadModuleEx(Win32_HANDLE hProcess, Win32_HANDLE hFile, Win32_PCSTR imageName, Win32_PCSTR moduleName, Win32_DWORD64 baseOfDll, Win32_DWORD dllSize, Win32_PMODLOAD_DATA data, Win32_DWORD flags) @cname("SymLoadModule");
|
||||
extern fn Win32_BOOL stackWalk64(Win32_DWORD machineType, Win32_HANDLE hProcess, Win32_HANDLE hThread, Win32_LPSTACKFRAME64 stackFrame, Win32_PVOID contextRecord, Win32_PREAD_PROCESS_MEMORY_ROUTINE64 readMemoryRoutine, Win32_PFUNCTION_TABLE_ACCESS_ROUTINE64 functionTableAccessRoutine, Win32_PGET_MODULE_BASE_ROUTINE64 getModuleBaseRoutine, Win32_PTRANSLATE_ADDRESS_ROUTINE64 translateAddress) @cname("StackWalk64");
|
||||
extern fn void rtlCaptureContext(Win32_PCONTEXT contextRecord) @cname("RtlCaptureContext");
|
||||
extern fn void* symFunctionTableAccess64(Win32_HANDLE hProcess, Win32_DWORD64 addrBase) @cname("SymFunctionTableAccess64");
|
||||
extern fn Win32_DWORD64 symGetModuleBase64(Win32_HANDLE hProcess, Win32_DWORD64 qwAddr) @cname("SymGetModuleBase64");
|
||||
extern fn Win32_DWORD getModuleBaseNameA(Win32_HANDLE hProcess, Win32_HMODULE hModule, Win32_LPSTR lpBaseName, Win32_DWORD nSize) @cname("K32GetModuleBaseNameA");
|
||||
extern fn Win32_DWORD symGetOptions() @cname("SymGetOptions");
|
||||
extern fn Win32_DWORD symSetOptions(Win32_DWORD symOptions) @cname("SymSetOptions");
|
||||
extern fn Win32_PIMAGE_NT_HEADERS imageNtHeader(Win32_PVOID base) @cname("ImageNtHeader");
|
||||
extern fn Win32_DWORD unDecorateSymbolName(Win32_PCSTR name, Win32_PSTR outputString, Win32_DWORD maxStringLength, Win32_DWORD flags) @cname("UnDecorateSymbolName");
|
||||
extern fn Win32_BOOL symFromAddr(Win32_HANDLE hProcess, Win32_DWORD64 address, Win32_PDWORD64 displacement, Win32_PSYMBOL_INFO symbol) @cname("SymFromAddr");
|
||||
extern fn Win32_BOOL symGetLineFromAddr64(Win32_HANDLE hProcess, Win32_DWORD64 dwAddr, Win32_PDWORD pdwDisplacement, Win32_PIMAGEHLP_LINE64 line) @cname("SymGetLineFromAddr64");
|
||||
extern fn Win32_WORD rtlCaptureStackBackTrace(Win32_DWORD framesToSkip, Win32_DWORD framesToCapture, Win32_PVOID *backTrace, Win32_PDWORD backTraceHash) @cname("RtlCaptureStackBackTrace");
|
||||
extern fn Win32_BOOL symGetModuleInfo64(Win32_HANDLE hProcess, Win32_DWORD64 qwAddr, Win32_PIMAGEHLP_MODULE64 moduleInfo) @cname("SymGetModuleInfo64");
|
||||
|
||||
fn Win32_DWORD? load_modules()
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@ module std::os::win32 @if(env::WIN32) @link("shell32");
|
||||
|
||||
typedef Win32_REFKNOWNFOLDERID = Win32_KNOWNFOLDERID*;
|
||||
typedef Win32_KNOWNFOLDERID = Win32_GUID;
|
||||
extern fn Win32_HRESULT shGetKnownFolderPath(Win32_REFKNOWNFOLDERID rfid, Win32_DWORD dwFlags, Win32_HANDLE hToken, Win32_PWSTR* ppszPath) @extern("SHGetKnownFolderPath");
|
||||
extern fn Win32_HRESULT shGetKnownFolderPath(Win32_REFKNOWNFOLDERID rfid, Win32_DWORD dwFlags, Win32_HANDLE hToken, Win32_PWSTR* ppszPath) @cname("SHGetKnownFolderPath");
|
||||
|
||||
const Win32_KNOWNFOLDERID FOLDERID_PROFILE = { 0x5E6C858F, 0x0E22, 0x4760, x"9AFEEA3317B67173" };
|
||||
const Win32_KNOWNFOLDERID FOLDERID_DESKTOP = { 0xB4BFCC3A, 0xDB2C, 0x424C, x"B0297FE99A87C641" };
|
||||
|
||||
@@ -110,26 +110,26 @@ const GWLP_HWNDPARENT = -8;
|
||||
const GWLP_USERDATA = -21;
|
||||
const GWLP_ID = -12;
|
||||
|
||||
extern fn Win32_HDC beginPaint(Win32_HWND, Win32_LPPAINTSTRUCT) @extern("BeginPaint");
|
||||
extern fn Win32_LRESULT callWindowProcW(Win32_WNDPROC lpPrevWndFunc, Win32_HWND hWnd, Win32_UINT msg, Win32_WPARAM wParam, Win32_LPARAM lParam) @extern("CallWindowProcW");
|
||||
extern fn Win32_HWND createWindowExW(Win32_DWORD, Win32_LPCWSTR, Win32_LPCWSTR, Win32_DWORD, CInt, CInt, CInt, CInt, Win32_HWND, Win32_HMENU, Win32_HINSTANCE, Win32_LPVOID) @extern("CreateWindowExW");
|
||||
extern fn Win32_LRESULT defWindowProcW(Win32_HWND, Win32_UINT, Win32_WPARAM, Win32_LPARAM) @extern("DefWindowProcW");
|
||||
extern fn Win32_BOOL dispatchMessage(Win32_MSG* lpMsg) @extern("DispatchMessageW");
|
||||
extern fn Win32_BOOL endPaint(Win32_HWND, Win32_LPPAINTSTRUCT) @extern("EndPaint");
|
||||
extern fn Win32_BOOL getMessageW(Win32_LPMSG, Win32_HWND, Win32_UINT, Win32_UINT) @extern("GetMessageW");
|
||||
extern fn Win32_BOOL getUpdateRect(Win32_HWND hWnd, Win32_LPRECT lpRect, Win32_BOOL bErase) @extern("GetUpdateRect");
|
||||
extern fn Win32_LONG_PTR getWindowLongPtrW(Win32_HWND hWnd, CInt nIndex) @extern("GetWindowLongPtrW");
|
||||
extern fn Win32_LONG getWindowLongW(Win32_HWND hWnd, CInt nIndex) @extern("GetWindowLongW");
|
||||
extern fn Win32_HCURSOR loadCursorW(Win32_HINSTANCE instance, Win32_LPCWSTR cursorName) @extern("LoadCursorW");
|
||||
extern fn Win32_HICON loadIconW(Win32_HINSTANCE instance, Win32_LPCWSTR iconName) @extern("LoadIconW");
|
||||
extern fn int messageBoxW(Win32_HWND hWnd, Win32_LPCWSTR lpText, Win32_LPCWSTR lpCaption, Win32_UINT uType) @extern("MessageBoxW");
|
||||
extern fn void postQuitMessage(CInt) @extern("PostQuitMessage");
|
||||
extern fn Win32_ATOM registerClassExW(Win32_WNDCLASSEXW*) @extern("RegisterClassExW");
|
||||
extern fn Win32_LONG_PTR setWindowLongPtrW(Win32_HWND hWnd, CInt nIndex, Win32_LONG_PTR dwNewLong) @extern("SetWindowLongPtrW");
|
||||
extern fn Win32_LONG setWindowLongW(Win32_HWND hWnd, CInt nIndex, Win32_LONG dwNewLong) @extern("SetWindowLongW");
|
||||
extern fn Win32_BOOL showWindow(Win32_HWND, CInt) @extern("ShowWindow");
|
||||
extern fn Win32_BOOL translateMessage(Win32_MSG* lpMsg) @extern("TranslateMessage");
|
||||
extern fn Win32_BOOL updateWindow(Win32_HWND) @extern("UpdateWindow");
|
||||
extern fn Win32_HDC beginPaint(Win32_HWND, Win32_LPPAINTSTRUCT) @cname("BeginPaint");
|
||||
extern fn Win32_LRESULT callWindowProcW(Win32_WNDPROC lpPrevWndFunc, Win32_HWND hWnd, Win32_UINT msg, Win32_WPARAM wParam, Win32_LPARAM lParam) @cname("CallWindowProcW");
|
||||
extern fn Win32_HWND createWindowExW(Win32_DWORD, Win32_LPCWSTR, Win32_LPCWSTR, Win32_DWORD, CInt, CInt, CInt, CInt, Win32_HWND, Win32_HMENU, Win32_HINSTANCE, Win32_LPVOID) @cname("CreateWindowExW");
|
||||
extern fn Win32_LRESULT defWindowProcW(Win32_HWND, Win32_UINT, Win32_WPARAM, Win32_LPARAM) @cname("DefWindowProcW");
|
||||
extern fn Win32_BOOL dispatchMessage(Win32_MSG* lpMsg) @cname("DispatchMessageW");
|
||||
extern fn Win32_BOOL endPaint(Win32_HWND, Win32_LPPAINTSTRUCT) @cname("EndPaint");
|
||||
extern fn Win32_BOOL getMessageW(Win32_LPMSG, Win32_HWND, Win32_UINT, Win32_UINT) @cname("GetMessageW");
|
||||
extern fn Win32_BOOL getUpdateRect(Win32_HWND hWnd, Win32_LPRECT lpRect, Win32_BOOL bErase) @cname("GetUpdateRect");
|
||||
extern fn Win32_LONG_PTR getWindowLongPtrW(Win32_HWND hWnd, CInt nIndex) @cname("GetWindowLongPtrW");
|
||||
extern fn Win32_LONG getWindowLongW(Win32_HWND hWnd, CInt nIndex) @cname("GetWindowLongW");
|
||||
extern fn Win32_HCURSOR loadCursorW(Win32_HINSTANCE instance, Win32_LPCWSTR cursorName) @cname("LoadCursorW");
|
||||
extern fn Win32_HICON loadIconW(Win32_HINSTANCE instance, Win32_LPCWSTR iconName) @cname("LoadIconW");
|
||||
extern fn int messageBoxW(Win32_HWND hWnd, Win32_LPCWSTR lpText, Win32_LPCWSTR lpCaption, Win32_UINT uType) @cname("MessageBoxW");
|
||||
extern fn void postQuitMessage(CInt) @cname("PostQuitMessage");
|
||||
extern fn Win32_ATOM registerClassExW(Win32_WNDCLASSEXW*) @cname("RegisterClassExW");
|
||||
extern fn Win32_LONG_PTR setWindowLongPtrW(Win32_HWND hWnd, CInt nIndex, Win32_LONG_PTR dwNewLong) @cname("SetWindowLongPtrW");
|
||||
extern fn Win32_LONG setWindowLongW(Win32_HWND hWnd, CInt nIndex, Win32_LONG dwNewLong) @cname("SetWindowLongW");
|
||||
extern fn Win32_BOOL showWindow(Win32_HWND, CInt) @cname("ShowWindow");
|
||||
extern fn Win32_BOOL translateMessage(Win32_MSG* lpMsg) @cname("TranslateMessage");
|
||||
extern fn Win32_BOOL updateWindow(Win32_HWND) @cname("UpdateWindow");
|
||||
|
||||
macro getWindowLongPtr(Win32_HWND hWnd, CInt nIndex)
|
||||
{
|
||||
|
||||
@@ -122,11 +122,11 @@ const SD_RECEIVE = 0x00;
|
||||
const SD_SEND = 0x01;
|
||||
const SD_BOTH = 0x02;
|
||||
|
||||
extern fn CInt wsaPoll(Win32_LPWSAPOLLFD fdArray, Win32_ULONG fds, Win32_INT timeout) @extern("WSAPoll");
|
||||
extern fn WSAError wsaGetLastError() @extern("WSAGetLastError");
|
||||
extern fn void wsaSetLastError(WSAError error) @extern("WSASetLastError");
|
||||
extern fn CInt wsaStartup(Win32_WORD, void*) @extern("WSAStartup");
|
||||
extern fn CInt wsaCleanup() @extern("WSACleanup");
|
||||
extern fn CInt wsaPoll(Win32_LPWSAPOLLFD fdArray, Win32_ULONG fds, Win32_INT timeout) @cname("WSAPoll");
|
||||
extern fn WSAError wsaGetLastError() @cname("WSAGetLastError");
|
||||
extern fn void wsaSetLastError(WSAError error) @cname("WSASetLastError");
|
||||
extern fn CInt wsaStartup(Win32_WORD, void*) @cname("WSAStartup");
|
||||
extern fn CInt wsaCleanup() @cname("WSACleanup");
|
||||
|
||||
const int FIONBIO = -2147195266;
|
||||
const int FIONREAD = 1074030207;
|
||||
|
||||
@@ -12,9 +12,10 @@
|
||||
- Add `--max-macro-iterations` to set macro iteration limit.
|
||||
- Improved generic inference in initializers #2541.
|
||||
- "Maybe-deref" subscripting `foo.[i] += 1` #2540.
|
||||
- ABI change for vectors: store and pass them as arrays #2542
|
||||
- Add @simd and @align attributes to typedef #2543
|
||||
-
|
||||
- ABI change for vectors: store and pass them as arrays #2542.
|
||||
- Add @simd and @align attributes to typedef #2543.
|
||||
- Rename `@extern` to `@cname`, deprecating the old name #2493.
|
||||
|
||||
### Fixes
|
||||
- Bug in `io::write_using_write_byte`.
|
||||
- Bitstruct value cannot be used to index a const array in compile time. #2512
|
||||
|
||||
@@ -23,14 +23,14 @@ enum Primitive : int (int value)
|
||||
POLYGON = 9,
|
||||
}
|
||||
|
||||
extern fn void clear(BitField mask) @extern("glClear") @public;
|
||||
extern fn void clear(BitField mask) @cname("glClear") @public;
|
||||
|
||||
extern fn void begin(BitField mask) @extern("glBegin") @public;
|
||||
extern fn void begin(BitField mask) @cname("glBegin") @public;
|
||||
|
||||
extern fn void end() @extern("glEnd") @public;
|
||||
extern fn void end() @cname("glEnd") @public;
|
||||
|
||||
extern fn void flush() @extern("glFlush") @public;
|
||||
extern fn void flush() @cname("glFlush") @public;
|
||||
|
||||
extern fn void color3f(float r, float g, float b) @extern("glColor3f") @public;
|
||||
extern fn void color3f(float r, float g, float b) @cname("glColor3f") @public;
|
||||
|
||||
extern fn void vertex3f(float x, float y, float z) @extern("glVertex3f") @public;
|
||||
extern fn void vertex3f(float x, float y, float z) @cname("glVertex3f") @public;
|
||||
@@ -31,21 +31,21 @@ fn void Window.makeContextCurrent(self) @public
|
||||
return _glfwMakeContextCurrent((_Window*)self);
|
||||
}
|
||||
|
||||
extern fn void initialize() @extern("glfwInit") @public;
|
||||
extern fn void initialize() @cname("glfwInit") @public;
|
||||
|
||||
extern fn void terminate() @extern("glfwTerminate") @public;
|
||||
extern fn void terminate() @cname("glfwTerminate") @public;
|
||||
|
||||
extern fn void pollEvents() @extern("glfwPollEvents") @public;
|
||||
extern fn void pollEvents() @cname("glfwPollEvents") @public;
|
||||
|
||||
typedef _Window @private = void;
|
||||
typedef _Monitor @private = void;
|
||||
|
||||
extern fn _Window* _glfwCreateWindow(int width, int height, char* title, _Monitor* monitor, _Window* share) @extern("glfwCreateWindow") @private;
|
||||
extern fn _Window* _glfwCreateWindow(int width, int height, char* title, _Monitor* monitor, _Window* share) @cname("glfwCreateWindow") @private;
|
||||
|
||||
extern fn bool _glfwWindowShouldClose(_Window* window) @extern("glfwWindowShouldClose") @private;
|
||||
extern fn bool _glfwWindowShouldClose(_Window* window) @cname("glfwWindowShouldClose") @private;
|
||||
|
||||
extern fn void _glfwDestroyWindow(_Window* window) @extern("glfwDestroyWindow") @private;
|
||||
extern fn void _glfwDestroyWindow(_Window* window) @cname("glfwDestroyWindow") @private;
|
||||
|
||||
extern fn void _glfwSwapBuffers(_Window* window) @extern("glfwSwapBuffers") @private;
|
||||
extern fn void _glfwSwapBuffers(_Window* window) @cname("glfwSwapBuffers") @private;
|
||||
|
||||
extern fn void _glfwMakeContextCurrent(_Window* window) @extern("glfwMakeContextCurrent") @private;
|
||||
extern fn void _glfwMakeContextCurrent(_Window* window) @cname("glfwMakeContextCurrent") @private;
|
||||
@@ -48,11 +48,11 @@ const SYSTEM_HIDE_GAMEPAD_OVERLAY = 2;
|
||||
// └───────────────────────────────────────────────────────────────────────────┘
|
||||
|
||||
/* Copies pixels to the framebuffer. */
|
||||
extern fn void blit(char* data, int x, int y, uint width, uint height, uint flags) @extern("blit");
|
||||
extern fn void blit(char* data, int x, int y, uint width, uint height, uint flags) @cname("blit");
|
||||
|
||||
/* Copies a subregion within a larger sprite atlas to the framebuffer. */
|
||||
extern fn void blit_sub(char* data, int x, int y, uint width, uint height,
|
||||
uint src_x, uint src_y, uint stride, uint flags) @extern("blitSub");
|
||||
uint src_x, uint src_y, uint stride, uint flags) @cname("blitSub");
|
||||
|
||||
const BLIT_2BPP = 1;
|
||||
const BLIT_1BPP = 0;
|
||||
@@ -76,7 +76,7 @@ extern fn void oval(int x, int y, uint width, uint height);
|
||||
extern fn void rect(int x, int y, uint width, uint height);
|
||||
|
||||
/* Draws text using the built-in system font. */
|
||||
extern fn void text(char* text, int x, int y) @extern("text");
|
||||
extern fn void text(char* text, int x, int y) @cname("text");
|
||||
|
||||
// ┌───────────────────────────────────────────────────────────────────────────┐
|
||||
// │ │
|
||||
@@ -127,10 +127,10 @@ char[8] smiley = {
|
||||
0b11000011,
|
||||
};
|
||||
|
||||
fn void start() @extern("start")
|
||||
fn void start() @cname("start")
|
||||
{}
|
||||
|
||||
fn void update() @extern("update")
|
||||
fn void update() @cname("update")
|
||||
{
|
||||
DRAW_COLORS[0] = 2;
|
||||
text("Hello from C3", 10, 10);
|
||||
|
||||
@@ -270,6 +270,7 @@ typedef enum
|
||||
ATTRIBUTE_BIGENDIAN,
|
||||
ATTRIBUTE_BUILTIN,
|
||||
ATTRIBUTE_CALLCONV,
|
||||
ATTRIBUTE_CNAME,
|
||||
ATTRIBUTE_COMPACT,
|
||||
ATTRIBUTE_CONST,
|
||||
ATTRIBUTE_DEPRECATED,
|
||||
|
||||
@@ -205,7 +205,7 @@ static inline bool parse_optional_module_params(ParseContext *c, const char ***t
|
||||
}
|
||||
}
|
||||
/**
|
||||
* module ::= MODULE module_path ('{' module_params '}')? (@public|@private|@local|@test|@export|@extern) EOS
|
||||
* module ::= MODULE module_path ('{' module_params '}')? (@public|@private|@local|@test|@export|@cname) EOS
|
||||
*/
|
||||
bool parse_module(ParseContext *c, AstId contracts)
|
||||
{
|
||||
@@ -330,6 +330,24 @@ bool parse_module(ParseContext *c, AstId contracts)
|
||||
"External name for the module may only be declared in one location.");
|
||||
}
|
||||
c->unit->module->extname = expr->const_expr.bytes.ptr;
|
||||
SEMA_DEPRECATED(attr, "'@extern' is deprecated, use '@cname' instead.");
|
||||
continue;
|
||||
}
|
||||
case ATTRIBUTE_CNAME:
|
||||
{
|
||||
if (vec_size(attr->exprs) != 1)
|
||||
{
|
||||
RETURN_PRINT_ERROR_AT(false, attr, "Expected 1 argument to '@cname(..), not %d'.",
|
||||
vec_size(attr->exprs));
|
||||
}
|
||||
Expr *expr = attr->exprs[0];
|
||||
if (!expr_is_const_string(expr)) RETURN_PRINT_ERROR_AT(false, expr, "Expected a constant string.");
|
||||
if (c->unit->module->extname)
|
||||
{
|
||||
RETURN_PRINT_ERROR_AT(false, attr,
|
||||
"External name for the module may only be declared in one location.");
|
||||
}
|
||||
c->unit->module->extname = expr->const_expr.bytes.ptr;
|
||||
continue;
|
||||
}
|
||||
default:
|
||||
|
||||
@@ -3106,6 +3106,7 @@ static bool sema_analyse_attribute(SemaContext *context, ResolvedAttrData *attr_
|
||||
[ATTRIBUTE_BIGENDIAN] = ATTR_BITSTRUCT,
|
||||
[ATTRIBUTE_BUILTIN] = ATTR_MACRO | ATTR_FUNC | ATTR_GLOBAL | ATTR_CONST,
|
||||
[ATTRIBUTE_CALLCONV] = ATTR_FUNC | ATTR_INTERFACE_METHOD | ATTR_FNTYPE,
|
||||
[ATTRIBUTE_CNAME] = ATTR_FUNC | ATTR_GLOBAL | ATTR_CONST | USER_DEFINED_TYPES,
|
||||
[ATTRIBUTE_COMPACT] = ATTR_STRUCT | ATTR_UNION,
|
||||
[ATTRIBUTE_CONST] = ATTR_MACRO,
|
||||
[ATTRIBUTE_DEPRECATED] = USER_DEFINED_TYPES | CALLABLE_TYPE | ATTR_CONST | ATTR_GLOBAL | ATTR_MEMBER | ATTR_BITSTRUCT_MEMBER | ATTR_INTERFACE | ATTR_ALIAS,
|
||||
@@ -3354,7 +3355,7 @@ static bool sema_analyse_attribute(SemaContext *context, ResolvedAttrData *attr_
|
||||
}
|
||||
if (decl->has_extname)
|
||||
{
|
||||
RETURN_SEMA_ERROR(expr, "An external name is already defined, please use '@extern` without an argument.");
|
||||
RETURN_SEMA_ERROR(expr, "An external name is already defined, please use '@export` without an argument.");
|
||||
}
|
||||
decl->has_extname = true;
|
||||
decl->extname = expr->const_expr.bytes.ptr;
|
||||
@@ -3453,6 +3454,7 @@ static bool sema_analyse_attribute(SemaContext *context, ResolvedAttrData *attr_
|
||||
case ATTRIBUTE_SIMD:
|
||||
RETURN_SEMA_ERROR(attr, "'@simd' is only allowed on typedef types.");
|
||||
case ATTRIBUTE_SECTION:
|
||||
case ATTRIBUTE_CNAME:
|
||||
case ATTRIBUTE_EXTERN:
|
||||
if (context->unit->module->is_generic)
|
||||
{
|
||||
@@ -3473,6 +3475,7 @@ static bool sema_analyse_attribute(SemaContext *context, ResolvedAttrData *attr_
|
||||
if (!sema_check_section(context, attr)) return false;
|
||||
attr_data->section = expr->const_expr.bytes.ptr;
|
||||
break;
|
||||
case ATTRIBUTE_CNAME:
|
||||
case ATTRIBUTE_EXTERN:
|
||||
decl->has_extname = true;
|
||||
decl->extname = expr->const_expr.bytes.ptr;
|
||||
|
||||
@@ -342,6 +342,7 @@ void symtab_init(uint32_t capacity)
|
||||
attribute_list[ATTRIBUTE_BIGENDIAN] = KW_DEF("@bigendian");
|
||||
attribute_list[ATTRIBUTE_BUILTIN] = KW_DEF("@builtin");
|
||||
attribute_list[ATTRIBUTE_CALLCONV] = KW_DEF("@callconv");
|
||||
attribute_list[ATTRIBUTE_CNAME] = KW_DEF("@cname");
|
||||
attribute_list[ATTRIBUTE_COMPACT] = KW_DEF("@compact");
|
||||
attribute_list[ATTRIBUTE_CONST] = KW_DEF("@const");
|
||||
attribute_list[ATTRIBUTE_DEPRECATED] = KW_DEF("@deprecated");
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
module test;
|
||||
import std;
|
||||
|
||||
extern fn Features query_features() @extern("sg_query_features");
|
||||
extern fn Features query_features() @cname("sg_query_features");
|
||||
extern fn void set_features(Features);
|
||||
|
||||
struct Features
|
||||
|
||||
@@ -5,12 +5,12 @@ struct Vector2 {
|
||||
float x;
|
||||
float y;
|
||||
}
|
||||
fn Vector2 vector2_zero() @extern("vector2_zero") { return {}; }
|
||||
fn Vector2 vector2_one() @extern("vector2_one") { return {}; }
|
||||
fn Vector2 vector2_add(Vector2 v1, Vector2 v2) @extern("vector2_add") { return {}; }
|
||||
fn Vector2 vector2_add_value(Vector2 v, float add) @extern("vector2_add_value") { return {}; }
|
||||
fn Vector2 vector2_subtract(Vector2 v1, Vector2 v2) @extern("vector2_subtract") { return {}; }
|
||||
fn Vector2 vector2_subtract_value(Vector2 v, float sub) @extern("vector2_subtract_value") { return {}; }
|
||||
fn Vector2 vector2_zero() @cname("vector2_zero") { return {}; }
|
||||
fn Vector2 vector2_one() @cname("vector2_one") { return {}; }
|
||||
fn Vector2 vector2_add(Vector2 v1, Vector2 v2) @cname("vector2_add") { return {}; }
|
||||
fn Vector2 vector2_add_value(Vector2 v, float add) @cname("vector2_add_value") { return {}; }
|
||||
fn Vector2 vector2_subtract(Vector2 v1, Vector2 v2) @cname("vector2_subtract") { return {}; }
|
||||
fn Vector2 vector2_subtract_value(Vector2 v, float sub) @cname("vector2_subtract_value") { return {}; }
|
||||
|
||||
|
||||
/* #expect: abi.ll
|
||||
|
||||
@@ -5,12 +5,12 @@ struct Vector2 {
|
||||
float x;
|
||||
float y;
|
||||
}
|
||||
fn Vector2 vector2_zero() @extern("vector2_zero") { return {}; }
|
||||
fn Vector2 vector2_one() @extern("vector2_one") { return {}; }
|
||||
fn Vector2 vector2_add(Vector2 v1, Vector2 v2) @extern("vector2_add") { return {}; }
|
||||
fn Vector2 vector2_add_value(Vector2 v, float add) @extern("vector2_add_value") { return {}; }
|
||||
fn Vector2 vector2_subtract(Vector2 v1, Vector2 v2) @extern("vector2_subtract") { return {}; }
|
||||
fn Vector2 vector2_subtract_value(Vector2 v, float sub) @extern("vector2_subtract_value") { return {}; }
|
||||
fn Vector2 vector2_zero() @cname("vector2_zero") { return {}; }
|
||||
fn Vector2 vector2_one() @cname("vector2_one") { return {}; }
|
||||
fn Vector2 vector2_add(Vector2 v1, Vector2 v2) @cname("vector2_add") { return {}; }
|
||||
fn Vector2 vector2_add_value(Vector2 v, float add) @cname("vector2_add_value") { return {}; }
|
||||
fn Vector2 vector2_subtract(Vector2 v1, Vector2 v2) @cname("vector2_subtract") { return {}; }
|
||||
fn Vector2 vector2_subtract_value(Vector2 v, float sub) @cname("vector2_subtract_value") { return {}; }
|
||||
|
||||
/* #expect: abi.ll
|
||||
|
||||
|
||||
@@ -5,12 +5,12 @@ struct Vector2 {
|
||||
float x;
|
||||
float y;
|
||||
}
|
||||
fn Vector2 vector2_zero() @extern("vector2_zero") { return {}; }
|
||||
fn Vector2 vector2_one() @extern("vector2_one") { return {}; }
|
||||
fn Vector2 vector2_add(Vector2 v1, Vector2 v2) @extern("vector2_add") { return {}; }
|
||||
fn Vector2 vector2_add_value(Vector2 v, float add) @extern("vector2_add_value") { return {}; }
|
||||
fn Vector2 vector2_subtract(Vector2 v1, Vector2 v2) @extern("vector2_subtract") { return {}; }
|
||||
fn Vector2 vector2_subtract_value(Vector2 v, float sub) @extern("vector2_subtract_value") { return {}; }
|
||||
fn Vector2 vector2_zero() @cname("vector2_zero") { return {}; }
|
||||
fn Vector2 vector2_one() @cname("vector2_one") { return {}; }
|
||||
fn Vector2 vector2_add(Vector2 v1, Vector2 v2) @cname("vector2_add") { return {}; }
|
||||
fn Vector2 vector2_add_value(Vector2 v, float add) @cname("vector2_add_value") { return {}; }
|
||||
fn Vector2 vector2_subtract(Vector2 v1, Vector2 v2) @cname("vector2_subtract") { return {}; }
|
||||
fn Vector2 vector2_subtract_value(Vector2 v, float sub) @cname("vector2_subtract_value") { return {}; }
|
||||
|
||||
/* #expect: abi.ll
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// #target: macos-aarch64
|
||||
module test;
|
||||
|
||||
attrdef @Test(x) = @extern("Foo" +++ x);
|
||||
attrdef @Test(x) = @cname("Foo" +++ x);
|
||||
|
||||
fn void hello_world() @Test("Megaman")
|
||||
{}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
fn void test() @wasm("hello", "world") { } // #error: Specifying a wasm import module
|
||||
extern fn void test2() @wasm("a", "b", "c"); // #error: Too many arguments to
|
||||
extern fn void test3() @extern("hello") @wasm("a"); // #error: An external name
|
||||
extern fn void test4() @extern("hello") @wasm("a", "b"); // #error: An external name
|
||||
extern fn void test3() @cname("hello") @wasm("a"); // #error: An external name
|
||||
extern fn void test4() @cname("hello") @wasm("a", "b"); // #error: An external name
|
||||
@@ -1,7 +1,7 @@
|
||||
// #target: macos-x64
|
||||
module test;
|
||||
|
||||
extern const int FOO @extern("foo1");
|
||||
extern const int FOO @cname("foo1");
|
||||
fn int main()
|
||||
{
|
||||
return FOO;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// #target: macos-x64
|
||||
module foo;
|
||||
|
||||
int baz @extern("foobar") = 123;
|
||||
int baz @cname("foobar") = 123;
|
||||
|
||||
/* #expect: foo.ll
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// #target: macos-x64
|
||||
|
||||
module test @extern("TEST");
|
||||
module test @cname("TEST");
|
||||
|
||||
fn void hello() @private {}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ union Vec4f @export @align(16) {
|
||||
float[<4>] v;
|
||||
}
|
||||
|
||||
extern fn void foo(Vec4f) @extern("foo");
|
||||
extern fn void foo(Vec4f) @cname("foo");
|
||||
|
||||
/* #expect: test.ll
|
||||
|
||||
|
||||
@@ -404,9 +404,9 @@ fn void malloc_free() @test
|
||||
// const CInt STDERR_FD = 2;
|
||||
//
|
||||
// module libc @if(env::LINUX);
|
||||
// extern CFile __stdin @extern("stdin");
|
||||
// extern CFile __stdout @extern("stdout");
|
||||
// extern CFile __stderr @extern("stderr");
|
||||
// extern CFile __stdin @cname("stdin");
|
||||
// extern CFile __stdout @cname("stdout");
|
||||
// extern CFile __stderr @cname("stderr");
|
||||
// extern fn usz malloc_usable_size(void* ptr);
|
||||
// macro usz malloc_size(void* ptr) => malloc_usable_size(ptr);
|
||||
// extern fn void* aligned_alloc(usz align, usz size);
|
||||
@@ -453,114 +453,114 @@ fn void malloc_free() @test
|
||||
//
|
||||
// module libc @if(!env::LIBC);
|
||||
//
|
||||
// fn void longjmp(JmpBuf* buffer, CInt value) @weak @extern("longjmp") @nostrip
|
||||
// fn void longjmp(JmpBuf* buffer, CInt value) @weak @cname("longjmp") @nostrip
|
||||
// {
|
||||
// unreachable("longjmp unavailable");
|
||||
// }
|
||||
//
|
||||
// fn CInt setjmp(JmpBuf* buffer) @weak @extern("setjmp") @nostrip
|
||||
// fn CInt setjmp(JmpBuf* buffer) @weak @cname("setjmp") @nostrip
|
||||
// {
|
||||
// unreachable("setjmp unavailable");
|
||||
// }
|
||||
//
|
||||
// fn void* malloc(usz size) @weak @extern("malloc") @nostrip
|
||||
// fn void* malloc(usz size) @weak @cname("malloc") @nostrip
|
||||
// {
|
||||
// unreachable("malloc unavailable");
|
||||
// }
|
||||
// fn void* calloc(usz count, usz size) @weak @extern("calloc") @nostrip
|
||||
// fn void* calloc(usz count, usz size) @weak @cname("calloc") @nostrip
|
||||
// {
|
||||
// unreachable("calloc unavailable");
|
||||
// }
|
||||
// fn void* free(void*) @weak @extern("free")
|
||||
// fn void* free(void*) @weak @cname("free")
|
||||
// {
|
||||
// unreachable("free unavailable");
|
||||
// }
|
||||
//
|
||||
// fn void* realloc(void* ptr, usz size) @weak @extern("realloc") @nostrip
|
||||
// fn void* realloc(void* ptr, usz size) @weak @cname("realloc") @nostrip
|
||||
// {
|
||||
// unreachable("realloc unavailable");
|
||||
// }
|
||||
//
|
||||
// fn void* memcpy(void* dest, void* src, usz n) @weak @extern("memcpy") @nostrip
|
||||
// fn void* memcpy(void* dest, void* src, usz n) @weak @cname("memcpy") @nostrip
|
||||
// {
|
||||
// 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 @extern("memmove") @nostrip
|
||||
// fn void* memmove(void* dest, void* src, usz n) @weak @cname("memmove") @nostrip
|
||||
// {
|
||||
// return memcpy(dest, src, n) @inline;
|
||||
// }
|
||||
//
|
||||
// fn void* memset(void* dest, CInt value, usz n) @weak @extern("memset") @nostrip
|
||||
// fn void* memset(void* dest, CInt value, usz n) @weak @cname("memset") @nostrip
|
||||
// {
|
||||
// for (usz i = 0; i < n; i++) ((char*)dest)[i] = (char)value;
|
||||
// return dest;
|
||||
// }
|
||||
//
|
||||
// fn int fseek(CFile stream, SeekIndex offset, int whence) @weak @extern("fseek") @nostrip
|
||||
// fn int fseek(CFile stream, SeekIndex offset, int whence) @weak @cname("fseek") @nostrip
|
||||
// {
|
||||
// unreachable("'fseek' not available.");
|
||||
// }
|
||||
// fn CFile fopen(ZString filename, ZString mode) @weak @extern("fopen") @nostrip
|
||||
// fn CFile fopen(ZString filename, ZString mode) @weak @cname("fopen") @nostrip
|
||||
// {
|
||||
// unreachable("'fopen' not available.");
|
||||
// }
|
||||
//
|
||||
// fn CFile freopen(ZString filename, ZString mode, CFile stream) @weak @extern("fopen") @nostrip
|
||||
// fn CFile freopen(ZString filename, ZString mode, CFile stream) @weak @cname("fopen") @nostrip
|
||||
// {
|
||||
// unreachable("'freopen' not available.");
|
||||
// }
|
||||
//
|
||||
// fn usz fwrite(void* ptr, usz size, usz nmemb, CFile stream) @weak @extern("fwrite") @nostrip
|
||||
// fn usz fwrite(void* ptr, usz size, usz nmemb, CFile stream) @weak @cname("fwrite") @nostrip
|
||||
// {
|
||||
// unreachable("'fwrite' not available.");
|
||||
// }
|
||||
//
|
||||
// fn usz fread(void* ptr, usz size, usz nmemb, CFile stream) @weak @extern("fread") @nostrip
|
||||
// fn usz fread(void* ptr, usz size, usz nmemb, CFile stream) @weak @cname("fread") @nostrip
|
||||
// {
|
||||
// unreachable("'fread' not available.");
|
||||
// }
|
||||
//
|
||||
// fn CFile fclose(CFile) @weak @extern("fclose") @nostrip
|
||||
// fn CFile fclose(CFile) @weak @cname("fclose") @nostrip
|
||||
// {
|
||||
// unreachable("'fclose' not available.");
|
||||
// }
|
||||
//
|
||||
// fn int fflush(CFile stream) @weak @extern("fflush") @nostrip
|
||||
// fn int fflush(CFile stream) @weak @cname("fflush") @nostrip
|
||||
// {
|
||||
// unreachable("'fflush' not available.");
|
||||
// }
|
||||
//
|
||||
// fn int fputc(int c, CFile stream) @weak @extern("fputc") @nostrip
|
||||
// fn int fputc(int c, CFile stream) @weak @cname("fputc") @nostrip
|
||||
// {
|
||||
// unreachable("'fputc' not available.");
|
||||
// }
|
||||
//
|
||||
// fn char* fgets(ZString str, int n, CFile stream) @weak @extern("fgets") @nostrip
|
||||
// fn char* fgets(ZString str, int n, CFile stream) @weak @cname("fgets") @nostrip
|
||||
// {
|
||||
// unreachable("'fgets' not available.");
|
||||
// }
|
||||
//
|
||||
// fn int fgetc(CFile stream) @weak @extern("fgetc") @nostrip
|
||||
// fn int fgetc(CFile stream) @weak @cname("fgetc") @nostrip
|
||||
// {
|
||||
// unreachable("'fgetc' not available.");
|
||||
// }
|
||||
//
|
||||
// fn int feof(CFile stream) @weak @extern("feof") @nostrip
|
||||
// fn int feof(CFile stream) @weak @cname("feof") @nostrip
|
||||
// {
|
||||
// unreachable("'feof' not available.");
|
||||
// }
|
||||
//
|
||||
// fn int putc(int c, CFile stream) @weak @extern("putc") @nostrip
|
||||
// fn int putc(int c, CFile stream) @weak @cname("putc") @nostrip
|
||||
// {
|
||||
// unreachable("'putc' not available.");
|
||||
// }
|
||||
// fn int putchar(int c) @weak @extern("putchar") @nostrip
|
||||
// fn int putchar(int c) @weak @cname("putchar") @nostrip
|
||||
// {
|
||||
// unreachable("'putchar' not available.");
|
||||
// }
|
||||
// fn int puts(ZString str) @weak @extern("puts") @nostrip
|
||||
// fn int puts(ZString str) @weak @cname("puts") @nostrip
|
||||
// {
|
||||
// unreachable("'puts' not available.");
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user