More fixes for typedef @constinit change

This commit is contained in:
Christoffer Lerno
2026-02-14 01:37:53 +01:00
parent fac9054f1b
commit eb80776988
20 changed files with 199 additions and 176 deletions

View File

@@ -26,7 +26,7 @@ macro foo(a, #b = EMPTY_MACRO_SLOT)
*>
const EmptySlot EMPTY_MACRO_SLOT @builtin @deprecated("Use `#arg = ...` instead.") = null;
typedef EmptySlot = void*;
typedef EmptySlot @constinit = void*;
macro bool @is_empty_macro_slot(#arg) @const @builtin
@deprecated("Use `#arg = ...` to define an optional macro slot, and `$defined(#arg)` to detect whether the argument is set.")
=> $typeof(#arg) == EmptySlot;

View File

@@ -6,22 +6,22 @@ const FULL_LOG = env::COMPILER_SAFE_MODE || $feature(FULL_LOG);
typedef LogCategory = inline char;
typedef LogTag = char[12];
const LogCategory CATEGORY_APPLICATION = 0;
const LogCategory CATEGORY_SYSTEM = 1;
const LogCategory CATEGORY_KERNEL = 2;
const LogCategory CATEGORY_AUDIO = 3;
const LogCategory CATEGORY_VIDEO = 4;
const LogCategory CATEGORY_RENDER = 5;
const LogCategory CATEGORY_INPUT = 6;
const LogCategory CATEGORY_NETWORK = 7;
const LogCategory CATEGORY_SOCKET = 8;
const LogCategory CATEGORY_SECURITY = 9;
const LogCategory CATEGORY_TEST = 10;
const LogCategory CATEGORY_ERROR = 11;
const LogCategory CATEGORY_ASSERT = 12;
const LogCategory CATEGORY_CRASH = 13;
const LogCategory CATEGORY_STATS = 14;
const LogCategory CATEGORY_CUSTOM_START = 100;
const LogCategory CATEGORY_APPLICATION = (LogCategory)0;
const LogCategory CATEGORY_SYSTEM = (LogCategory)1;
const LogCategory CATEGORY_KERNEL = (LogCategory)2;
const LogCategory CATEGORY_AUDIO = (LogCategory)3;
const LogCategory CATEGORY_VIDEO = (LogCategory)4;
const LogCategory CATEGORY_RENDER = (LogCategory)5;
const LogCategory CATEGORY_INPUT = (LogCategory)6;
const LogCategory CATEGORY_NETWORK = (LogCategory)7;
const LogCategory CATEGORY_SOCKET = (LogCategory)8;
const LogCategory CATEGORY_SECURITY = (LogCategory)9;
const LogCategory CATEGORY_TEST = (LogCategory)10;
const LogCategory CATEGORY_ERROR = (LogCategory)11;
const LogCategory CATEGORY_ASSERT = (LogCategory)12;
const LogCategory CATEGORY_CRASH = (LogCategory)13;
const LogCategory CATEGORY_STATS = (LogCategory)14;
const LogCategory CATEGORY_CUSTOM_START = (LogCategory)100;
tlocal LogCategory default_category = CATEGORY_APPLICATION;
tlocal LogTag current_tag;

View File

@@ -2,16 +2,16 @@ module std::core::sanitizer::tsan;
typedef MutexFlags = inline CUInt;
const MutexFlags MUTEX_LINKER_INIT = 1 << 0;
const MutexFlags MUTEX_WRITE_REENTRANT = 1 << 1;
const MutexFlags MUTEX_READ_REENTRANT = 1 << 2;
const MutexFlags MUTEX_NOT_STATIC = 1 << 8;
const MutexFlags MUTEX_READ_LOCK = 1 << 3;
const MutexFlags MUTEX_TRY_LOCK = 1 << 4;
const MutexFlags MUTEX_TRY_LOCK_FAILED = 1 << 5;
const MutexFlags MUTEX_RECURSIVE_LOCK = 1 << 6;
const MutexFlags MUTEX_RECURSIVE_UNLOCK = 1 << 7;
const MutexFlags MUTEX_TRY_READ_LOCK = MUTEX_READ_LOCK | MUTEX_TRY_LOCK;
const MutexFlags MUTEX_LINKER_INIT = (MutexFlags)1 << 0;
const MutexFlags MUTEX_WRITE_REENTRANT = (MutexFlags)1 << 1;
const MutexFlags MUTEX_READ_REENTRANT = (MutexFlags)1 << 2;
const MutexFlags MUTEX_NOT_STATIC = (MutexFlags)1 << 8;
const MutexFlags MUTEX_READ_LOCK = (MutexFlags)1 << 3;
const MutexFlags MUTEX_TRY_LOCK = (MutexFlags)1 << 4;
const MutexFlags MUTEX_TRY_LOCK_FAILED = (MutexFlags)1 << 5;
const MutexFlags MUTEX_RECURSIVE_LOCK = (MutexFlags)1 << 6;
const MutexFlags MUTEX_RECURSIVE_UNLOCK = (MutexFlags)1 << 7;
const MutexFlags MUTEX_TRY_READ_LOCK = MUTEX_READ_LOCK | MUTEX_TRY_LOCK;
const MutexFlags MUTEX_TRY_READ_LOCK_FAILED = MUTEX_TRY_READ_LOCK | MUTEX_TRY_LOCK_FAILED;
macro void mutex_create(void* addr, MutexFlags flags) { $if env::THREAD_SANITIZER: __tsan_mutex_create(addr, flags); $endif }

View File

@@ -4,13 +4,13 @@ import std::core::mem::allocator;
typedef String @if(!$defined(String)) = inline char[];
typedef String @constinit @if(!$defined(String)) = inline char[];
<*
ZString is a pointer to a zero terminated array of chars.
Use ZString when you need to interop with C zero terminated strings.
*>
typedef ZString = inline char*;
typedef ZString @constinit = inline char*;
<*
WString is a pointer to a zero terminated array of Char16.

View File

@@ -332,7 +332,7 @@ fn Projection Projection.mul(&s, char[] n) @operator(*)
module std::crypto::ed25519 @private;
typedef F25519Int = inline char[32];
typedef F25519Int @constinit = inline char[32];
const F25519Int ZERO = {};
const F25519Int ONE = {[0] = 1};
@@ -601,7 +601,7 @@ fn F25519Int F25519Int.sqrt(&s)
module std::crypto::ed25519 @private;
import std::math;
typedef FBaseInt = inline char[32];
typedef FBaseInt @constinit = inline char[32];
// Order of the field : 2^252+0x14def9dea2f79cd65812631a5cf5d3ed
const FBaseInt ORDER = x"edd3f55c1a631258 d69cf7a2def9de14 0000000000000000 0000000000000010";

View File

@@ -242,7 +242,7 @@ const char INVALID @private = 0xff;
const int STD_PADDING = '=';
const int NO_PADDING = -1;
typedef Alphabet = char[32];
typedef Alphabet @constinit = char[32];
// Standard base32 Alphabet
const Alphabet STD_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
// Extended Hex Alphabet

View File

@@ -49,7 +49,7 @@ fn void errno_set(Errno e)
os::errno_set((int)e);
}
typedef Errno = inline CInt;
typedef Errno @constinit = inline CInt;
alias TerminateFunction = fn void();
alias CompareFunction = fn int(void*, void*);
alias JmpBuf = uptr[$$JMP_BUF_SIZE];

View File

@@ -312,65 +312,65 @@ struct Termios
Speed c_ospeed;
}
const Tcactions TCOOFF @deprecated = 0;
const Tcactions TCOON @deprecated = 1;
const Tcactions TCIOFF @deprecated = 2;
const Tcactions TCION @deprecated = 3;
const Tcactions TCIFLUSH @deprecated = 0;
const Tcactions TCOFLUSH @deprecated = 1;
const Tcactions TCIOFLUSH @deprecated = 2;
const Tcactions TCSANOW @deprecated = 0;
const Tcactions TCSADRAIN @deprecated = 1;
const Tcactions TCSAFLUSH @deprecated = 2;
const Speed B0 @deprecated = 0o0000000;
const Speed B50 @deprecated = 0o0000001;
const Speed B75 @deprecated = 0o0000002;
const Speed B110 @deprecated = 0o0000003;
const Speed B134 @deprecated = 0o0000004;
const Speed B150 @deprecated = 0o0000005;
const Speed B200 @deprecated = 0o0000006;
const Speed B300 @deprecated = 0o0000007;
const Speed B600 @deprecated = 0o0000010;
const Speed B1200 @deprecated = 0o0000011;
const Speed B1800 @deprecated = 0o0000012;
const Speed B2400 @deprecated = 0o0000013;
const Speed B4800 @deprecated = 0o0000014;
const Speed B9600 @deprecated = 0o0000015;
const Speed B19200 @deprecated = 0o0000016;
const Speed B38400 @deprecated = 0o0000017;
const Speed B57600 @deprecated = 0o0010001;
const Speed B115200 @deprecated = 0o0010002;
const Speed B230400 @deprecated = 0o0010003;
const Speed B460800 @deprecated = 0o0010004;
const Speed B500000 @deprecated = 0o0010005;
const Speed B576000 @deprecated = 0o0010006;
const Speed B921600 @deprecated = 0o0010007;
const Speed B1000000 @deprecated = 0o0010010;
const Speed B1152000 @deprecated = 0o0010011;
const Speed B1500000 @deprecated = 0o0010012;
const Speed B2000000 @deprecated = 0o0010013;
const Speed B2500000 @deprecated = 0o0010014;
const Speed B3000000 @deprecated = 0o0010015;
const Speed B3500000 @deprecated = 0o0010016;
const Speed B4000000 @deprecated = 0o0010017;
const Speed MAX_BAUD @deprecated = B4000000;
const Cc VINTR @deprecated = 0;
const Cc VQUIT @deprecated = 1;
const Cc VERASE @deprecated = 2;
const Cc VKILL @deprecated = 3;
const Cc VEOF @deprecated = 4;
const Cc VTIME @deprecated = 5;
const Cc VMIN @deprecated = 6;
const Cc VSWTC @deprecated = 7;
const Cc VSTART @deprecated = 8;
const Cc VSTOP @deprecated = 9;
const Cc VSUSP @deprecated = 10;
const Cc VEOL @deprecated = 11;
const Cc VREPRINT @deprecated = 12;
const Cc VDISCARD @deprecated = 13;
const Cc VWERASE @deprecated = 14;
const Cc VLNEXT @deprecated = 15;
const Cc VEOL2 @deprecated = 16;
const Tcactions TCOOFF @deprecated = (Tcactions)0;
const Tcactions TCOON @deprecated = (Tcactions)1;
const Tcactions TCIOFF @deprecated = (Tcactions)2;
const Tcactions TCION @deprecated = (Tcactions)3;
const Tcactions TCIFLUSH @deprecated = (Tcactions)0;
const Tcactions TCOFLUSH @deprecated = (Tcactions)1;
const Tcactions TCIOFLUSH @deprecated = (Tcactions)2;
const Tcactions TCSANOW @deprecated = (Tcactions)0;
const Tcactions TCSADRAIN @deprecated = (Tcactions)1;
const Tcactions TCSAFLUSH @deprecated = (Tcactions)2;
const Speed B0 @deprecated = (Speed)0o0000000;
const Speed B50 @deprecated = (Speed)0o0000001;
const Speed B75 @deprecated = (Speed)0o0000002;
const Speed B110 @deprecated = (Speed)0o0000003;
const Speed B134 @deprecated = (Speed)0o0000004;
const Speed B150 @deprecated = (Speed)0o0000005;
const Speed B200 @deprecated = (Speed)0o0000006;
const Speed B300 @deprecated = (Speed)0o0000007;
const Speed B600 @deprecated = (Speed)0o0000010;
const Speed B1200 @deprecated = (Speed)0o0000011;
const Speed B1800 @deprecated = (Speed)0o0000012;
const Speed B2400 @deprecated = (Speed)0o0000013;
const Speed B4800 @deprecated = (Speed)0o0000014;
const Speed B9600 @deprecated = (Speed)0o0000015;
const Speed B19200 @deprecated = (Speed)0o0000016;
const Speed B38400 @deprecated = (Speed)0o0000017;
const Speed B57600 @deprecated = (Speed)0o0010001;
const Speed B115200 @deprecated = (Speed)0o0010002;
const Speed B230400 @deprecated = (Speed)0o0010003;
const Speed B460800 @deprecated = (Speed)0o0010004;
const Speed B500000 @deprecated = (Speed)0o0010005;
const Speed B576000 @deprecated = (Speed)0o0010006;
const Speed B921600 @deprecated = (Speed)0o0010007;
const Speed B1000000 @deprecated = (Speed)0o0010010;
const Speed B1152000 @deprecated = (Speed)0o0010011;
const Speed B1500000 @deprecated = (Speed)0o0010012;
const Speed B2000000 @deprecated = (Speed)0o0010013;
const Speed B2500000 @deprecated = (Speed)0o0010014;
const Speed B3000000 @deprecated = (Speed)0o0010015;
const Speed B3500000 @deprecated = (Speed)0o0010016;
const Speed B4000000 @deprecated = (Speed)0o0010017;
const Speed MAX_BAUD @deprecated = (Speed)0o0010017;
const Cc VINTR @deprecated = (Cc)0;
const Cc VQUIT @deprecated = (Cc)1;
const Cc VERASE @deprecated = (Cc)2;
const Cc VKILL @deprecated = (Cc)3;
const Cc VEOF @deprecated = (Cc)4;
const Cc VTIME @deprecated = (Cc)5;
const Cc VMIN @deprecated = (Cc)6;
const Cc VSWTC @deprecated = (Cc)7;
const Cc VSTART @deprecated = (Cc)8;
const Cc VSTOP @deprecated = (Cc)9;
const Cc VSUSP @deprecated = (Cc)10;
const Cc VEOL @deprecated = (Cc)11;
const Cc VREPRINT @deprecated = (Cc)12;
const Cc VDISCARD @deprecated = (Cc)13;
const Cc VWERASE @deprecated = (Cc)14;
const Cc VLNEXT @deprecated = (Cc)15;
const Cc VEOL2 @deprecated = (Cc)16;
const Tc_lflags ISIG @deprecated = {.isig};
const Tc_lflags ICANON @deprecated = {.icanon};
const Tc_lflags ECHO @deprecated = {.echo};

View File

@@ -34,22 +34,22 @@ struct AddrInfo
const PLATFORM_O_NONBLOCK @if(!$defined(PLATFORM_O_NONBLOCK)) = 0;
const AISockType SOCK_STREAM = 1; // Stream
const AISockType SOCK_DGRAM = 2; // Datagram
const AISockType SOCK_RAW = 3; // Raw
const AISockType SOCK_RDM = 4; // Reliably delivered
const AISockType SOCK_SEQPACKET = 5; // Sequential packet
const AISockType SOCK_STREAM = (AISockType)1; // Stream
const AISockType SOCK_DGRAM = (AISockType)2; // Datagram
const AISockType SOCK_RAW = (AISockType)3; // Raw
const AISockType SOCK_RDM = (AISockType)4; // Reliably delivered
const AISockType SOCK_SEQPACKET = (AISockType)5; // Sequential packet
const AIFlags AI_PASSIVE = 0x1;
const AIFlags AI_CANONNAME = 0x2;
const AIFlags AI_NUMERICHOST = 0x4;
const AIFlags AI_PASSIVE = (AIFlags)0x1;
const AIFlags AI_CANONNAME = (AIFlags)0x2;
const AIFlags AI_NUMERICHOST = (AIFlags)0x4;
const AIFamily AF_UNSPEC = 0;
const AIFamily AF_UNIX = 1;
const AIFamily AF_INET = 2;
const AIFamily AF_INET6 = PLATFORM_AF_INET6;
const AIFamily AF_IPX = PLATFORM_AF_IPX;
const AIFamily AF_APPLETALK = PLATFORM_AF_APPLETALK;
const AIFamily AF_UNSPEC = (AIFamily)0;
const AIFamily AF_UNIX = (AIFamily)1;
const AIFamily AF_INET = (AIFamily)2;
const AIFamily AF_INET6 = (AIFamily)PLATFORM_AF_INET6;
const AIFamily AF_IPX = (AIFamily)PLATFORM_AF_IPX;
const AIFamily AF_APPLETALK = (AIFamily)PLATFORM_AF_APPLETALK;
const O_NONBLOCK = PLATFORM_O_NONBLOCK;

View File

@@ -1,50 +1,50 @@
module std::net::os @if(env::DARWIN);
import libc;
const AIFlags AI_NUMERICSERV = 0x1000;
const AIFlags AI_ALL = 0x100;
const AIFlags AI_V4MAPPED_CFG = 0x200;
const AIFlags AI_ADDRCONFIG = 0x400;
const AIFlags AI_V4MAPPED = 0x800;
const AIFlags AI_UNUSABLE = 0x10000000;
const AIFlags AI_DEFAULT = AI_V4MAPPED_CFG | AI_ADDRCONFIG;
const AIFlags AI_NUMERICSERV = (AIFlags)0x1000;
const AIFlags AI_ALL = (AIFlags)0x100;
const AIFlags AI_V4MAPPED_CFG = (AIFlags)0x200;
const AIFlags AI_ADDRCONFIG = (AIFlags)0x400;
const AIFlags AI_V4MAPPED = (AIFlags)0x800;
const AIFlags AI_UNUSABLE = (AIFlags)0x10000000;
const AIFlags AI_DEFAULT = AI_V4MAPPED_CFG | AI_ADDRCONFIG;
const AIFamily PLATFORM_AF_IMPLINK = 3;
const AIFamily PLATFORM_AF_PUP = 4;
const AIFamily PLATFORM_AF_CHAOS = 5;
const AIFamily PLATFORM_AF_NS = 6;
const AIFamily PLATFORM_AF_ISO = 7;
const AIFamily PLATFORM_AF_ECMA = 8;
const AIFamily PLATFORM_AF_DATAKIT = 9;
const AIFamily PLATFORM_AF_CCITT = 10;
const AIFamily PLATFORM_AF_SNA = 11;
const AIFamily PLATFORM_AF_DECNET = 12;
const AIFamily PLATFORM_AF_DLI = 13;
const AIFamily PLATFORM_AF_LAT = 14;
const AIFamily PLATFORM_AF_HYLINK = 15;
const AIFamily PLATFORM_AF_APPLETALK = 16;
const AIFamily PLATFORM_AF_ROUTE = 17;
const AIFamily PLATFORM_AF_LINK = 18;
const AIFamily PLATFORM_PSEUDO_AF_XTP = 19;
const AIFamily PLATFORM_AF_COIP = 20;
const AIFamily PLATFORM_AF_CNT = 21;
const AIFamily PLATFORM_PSEUDO_AF_RTIP = 22;
const AIFamily PLATFORM_AF_IPX = 23;
const AIFamily PLATFORM_AF_SIP = 24;
const AIFamily PLATFORM_PSEUDO_AF_PIP = 25;
const AIFamily PLATFORM_AF_NDRV = 27;
const AIFamily PLATFORM_AF_ISDN = 28;
const AIFamily PLATFORM_PSEUDO_AF_KEY = 29;
const AIFamily PLATFORM_AF_INET6 = 30;
const AIFamily PLATFORM_AF_NATM = 31;
const AIFamily PLATFORM_AF_SYSTEM = 32;
const AIFamily PLATFORM_AF_NETBIOS = 33;
const AIFamily PLATFORM_AF_PPP = 34;
const AIFamily PLATFORM_PSEUDO_AF_HDRCMPLT = 35;
const AIFamily PLATFORM_AF_IEEE80211 = 37;
const AIFamily PLATFORM_AF_UTUN = 38;
const AIFamily PLATFORM_AF_VSOCK = 40;
const AIFamily PLATFORM_AF_MAX = 41;
const AIFamily PLATFORM_AF_IMPLINK = (AIFamily)3;
const AIFamily PLATFORM_AF_PUP = (AIFamily)4;
const AIFamily PLATFORM_AF_CHAOS = (AIFamily)5;
const AIFamily PLATFORM_AF_NS = (AIFamily)6;
const AIFamily PLATFORM_AF_ISO = (AIFamily)7;
const AIFamily PLATFORM_AF_ECMA = (AIFamily)8;
const AIFamily PLATFORM_AF_DATAKIT = (AIFamily)9;
const AIFamily PLATFORM_AF_CCITT = (AIFamily)10;
const AIFamily PLATFORM_AF_SNA = (AIFamily)11;
const AIFamily PLATFORM_AF_DECNET = (AIFamily)12;
const AIFamily PLATFORM_AF_DLI = (AIFamily)13;
const AIFamily PLATFORM_AF_LAT = (AIFamily)14;
const AIFamily PLATFORM_AF_HYLINK = (AIFamily)15;
const AIFamily PLATFORM_AF_APPLETALK = (AIFamily)16;
const AIFamily PLATFORM_AF_ROUTE = (AIFamily)17;
const AIFamily PLATFORM_AF_LINK = (AIFamily)18;
const AIFamily PLATFORM_PSEUDO_AF_XTP = (AIFamily)19;
const AIFamily PLATFORM_AF_COIP = (AIFamily)20;
const AIFamily PLATFORM_AF_CNT = (AIFamily)21;
const AIFamily PLATFORM_PSEUDO_AF_RTIP = (AIFamily)22;
const AIFamily PLATFORM_AF_IPX = (AIFamily)23;
const AIFamily PLATFORM_AF_SIP = (AIFamily)24;
const AIFamily PLATFORM_PSEUDO_AF_PIP = (AIFamily)25;
const AIFamily PLATFORM_AF_NDRV = (AIFamily)27;
const AIFamily PLATFORM_AF_ISDN = (AIFamily)28;
const AIFamily PLATFORM_PSEUDO_AF_KEY = (AIFamily)29;
const AIFamily PLATFORM_AF_INET6 = (AIFamily)30;
const AIFamily PLATFORM_AF_NATM = (AIFamily)31;
const AIFamily PLATFORM_AF_SYSTEM = (AIFamily)32;
const AIFamily PLATFORM_AF_NETBIOS = (AIFamily)33;
const AIFamily PLATFORM_AF_PPP = (AIFamily)34;
const AIFamily PLATFORM_PSEUDO_AF_HDRCMPLT = (AIFamily)35;
const AIFamily PLATFORM_AF_IEEE80211 = (AIFamily)37;
const AIFamily PLATFORM_AF_UTUN = (AIFamily)38;
const AIFamily PLATFORM_AF_VSOCK = (AIFamily)40;
const AIFamily PLATFORM_AF_MAX = (AIFamily)41;
const int PLATFORM_O_NONBLOCK = 0x04;

View File

@@ -47,7 +47,7 @@ fn Socket? connect_with_timeout_from_addrinfo(AddrInfo* addrinfo, SocketOption[]
$if env::WIN32:
os::start_wsa()!;
$endif
Clock c = 0;
Clock c;
@loop_over_ai(addrinfo; NativeSocket sockfd, AddrInfo* ai)
{
apply_sockoptions(sockfd, options)!;

View File

@@ -6,21 +6,21 @@ typedef Duration @structlike = long;
typedef Clock @structlike = ulong;
typedef NanoDuration (Printable) @structlike = long;
const Time FAR_FUTURE = long.max;
const Time FAR_PAST = long.min;
const Time FAR_FUTURE = (Time)long.max;
const Time FAR_PAST = (Time)long.min;
const NanoDuration NANO_DURATION_ZERO = 0;
const Duration US = 1;
const Duration MS = 1_000;
const Duration SEC = 1_000_000;
const Duration MIN = 60 * SEC;
const Duration HOUR = 60 * MIN;
const Duration DAY = 24 * HOUR;
const Duration WEEK = 7 * DAY;
const Duration MONTH = 30 * DAY;
const Duration YEAR = 36525 * DAY / 100;
const Duration FOREVER = long.max;
const Duration DURATION_ZERO = 0;
const NanoDuration NANO_DURATION_ZERO = (NanoDuration)0;
const Duration US = (Duration)1;
const Duration MS = (Duration)1_000;
const Duration SEC = (Duration)1_000_000;
const Duration MIN = (Duration)60 * SEC;
const Duration HOUR = (Duration)60 * MIN;
const Duration DAY = (Duration)24 * HOUR;
const Duration WEEK = (Duration)7 * DAY;
const Duration MONTH = (Duration)30 * DAY;
const Duration YEAR = (Duration)36525 * DAY / 100;
const Duration FOREVER = (Duration)long.max;
const Duration DURATION_ZERO = (Duration)0;
fn Duration us(long l) @inline => l * US;
fn Duration ms(long l) @inline => l * MS;