mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Better lowering of distinct types. Noreturn function call expr recognized as a "jump" for escape analysis. Preferring "def" in libs. To upper / to lower for ascii. Initial dynlib support.
This commit is contained in:
committed by
Christoffer Lerno
parent
a877d4458c
commit
ddd0497922
@@ -4,7 +4,7 @@
|
||||
module std::collections::list<Type>;
|
||||
import std::math;
|
||||
|
||||
typedef ElementPredicate = fn bool(Type *type);
|
||||
def ElementPredicate = fn bool(Type *type);
|
||||
|
||||
struct List
|
||||
{
|
||||
|
||||
@@ -472,7 +472,7 @@ fn Object* Object.get_or_create_obj(Object* o, String key)
|
||||
return container;
|
||||
}
|
||||
|
||||
typedef ObjectInternalMap @private = HashMap<String, Object*>;
|
||||
typedef ObjectInternalList @private = List<Object*>;
|
||||
typedef ObjectInternalMapEntry @private = Entry<String, Object*>;
|
||||
def ObjectInternalMap @private = HashMap<String, Object*>;
|
||||
def ObjectInternalList @private = List<Object*>;
|
||||
def ObjectInternalMapEntry @private = Entry<String, Object*>;
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
module std::collections::priorityqueue<Type>;
|
||||
import std::collections::list;
|
||||
|
||||
typedef Heap = List<Type>;
|
||||
def Heap = List<Type>;
|
||||
|
||||
struct PriorityQueue
|
||||
{
|
||||
|
||||
@@ -103,7 +103,7 @@ fn void*! ArenaAllocator._alloc(ArenaAllocator* this, usz size, usz alignment, u
|
||||
usz end = (usz)(aligned_pointer_to_offset - this.data.ptr) + size - offset;
|
||||
if (end > total_len) return AllocationFailure.OUT_OF_MEMORY?;
|
||||
this.used = end;
|
||||
void *mem = aligned_pointer_to_offset - offset;
|
||||
void* mem = aligned_pointer_to_offset - offset;
|
||||
ArenaAllocatorHeader* header = mem - ArenaAllocatorHeader.sizeof;
|
||||
header.size = size;
|
||||
return mem;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
module std::core::mem::allocator;
|
||||
|
||||
typedef MemoryAllocFn = fn char[]!(usz);
|
||||
def MemoryAllocFn = fn char[]!(usz);
|
||||
|
||||
struct SimpleHeapAllocator
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
module std::core::mem::allocator;
|
||||
import std::collections::map;
|
||||
|
||||
typedef PtrMap = HashMap<uptr, usz>;
|
||||
def PtrMap = HashMap<uptr, usz>;
|
||||
|
||||
// A simple tracking allocator.
|
||||
// It tracks allocations using a hash map but
|
||||
|
||||
@@ -104,7 +104,7 @@ fn void default_panic(String message, String file, String function, uint line)
|
||||
$$trap();
|
||||
}
|
||||
|
||||
typedef PanicFn = fn void(String message, String file, String function, uint line);
|
||||
def PanicFn = fn void(String message, String file, String function, uint line);
|
||||
|
||||
PanicFn panic = &default_panic;
|
||||
|
||||
|
||||
@@ -18,70 +18,70 @@ $assert C_LONG_SIZE <= C_LONG_LONG_SIZE;
|
||||
|
||||
$switch ($$C_INT_SIZE)
|
||||
$case 64:
|
||||
typedef CInt = long;
|
||||
typedef CUInt = ulong;
|
||||
def CInt = long;
|
||||
def CUInt = ulong;
|
||||
$case 32:
|
||||
typedef CInt = int;
|
||||
typedef CUInt = uint;
|
||||
def CInt = int;
|
||||
def CUInt = uint;
|
||||
$case 16:
|
||||
typedef CInt = short;
|
||||
typedef CUInt = ushort;
|
||||
def CInt = short;
|
||||
def CUInt = ushort;
|
||||
$default:
|
||||
$error "Invalid C int size";
|
||||
$endswitch
|
||||
|
||||
$switch ($$C_LONG_SIZE)
|
||||
$case 64:
|
||||
typedef CLong = long;
|
||||
typedef CULong = ulong;
|
||||
def CLong = long;
|
||||
def CULong = ulong;
|
||||
$case 32:
|
||||
typedef CLong = int;
|
||||
typedef CULong = uint;
|
||||
def CLong = int;
|
||||
def CULong = uint;
|
||||
$case 16:
|
||||
typedef CLong = short;
|
||||
typedef CULong = ushort;
|
||||
def CLong = short;
|
||||
def CULong = ushort;
|
||||
$default:
|
||||
$error "Invalid C long size";
|
||||
$endswitch
|
||||
|
||||
$switch ($$C_SHORT_SIZE)
|
||||
$case 32:
|
||||
typedef CShort = int;
|
||||
typedef CUShort = uint;
|
||||
def CShort = int;
|
||||
def CUShort = uint;
|
||||
$case 16:
|
||||
typedef CShort = short;
|
||||
typedef CUShort = ushort;
|
||||
def CShort = short;
|
||||
def CUShort = ushort;
|
||||
$case 8:
|
||||
typedef CShort = ichar;
|
||||
typedef CUShort = char;
|
||||
def CShort = ichar;
|
||||
def CUShort = char;
|
||||
$default:
|
||||
$error "Invalid C short size";
|
||||
$endswitch
|
||||
|
||||
$switch ($$C_LONG_LONG_SIZE)
|
||||
$case 128:
|
||||
typedef CLongLong = int128;
|
||||
typedef CULongLong = uint128;
|
||||
def CLongLong = int128;
|
||||
def CULongLong = uint128;
|
||||
$case 64:
|
||||
typedef CLongLong = long;
|
||||
typedef CULongLong = ulong;
|
||||
def CLongLong = long;
|
||||
def CULongLong = ulong;
|
||||
$case 32:
|
||||
typedef CLongLong = int;
|
||||
typedef CULongLong = uint;
|
||||
def CLongLong = int;
|
||||
def CULongLong = uint;
|
||||
$case 16:
|
||||
typedef CLongLong = short;
|
||||
typedef CULongLong = ushort;
|
||||
def CLongLong = short;
|
||||
def CULongLong = ushort;
|
||||
$default:
|
||||
$error "Invalid C long long size";
|
||||
$endswitch
|
||||
|
||||
|
||||
|
||||
typedef CSChar = ichar;
|
||||
typedef CUChar = char;
|
||||
def CSChar = ichar;
|
||||
def CUChar = char;
|
||||
|
||||
$if $$C_CHAR_IS_SIGNED:
|
||||
typedef CChar = ichar;
|
||||
def CChar = ichar;
|
||||
$else
|
||||
typedef CChar = char;
|
||||
def CChar = char;
|
||||
$endif
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module std::core::dstring;
|
||||
|
||||
typedef DString = distinct void*;
|
||||
def DString = distinct void*;
|
||||
|
||||
const usz MIN_CAPACITY @private = 16;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ const DEFAULT_SIZE_PREFIX_ALIGNMENT = usz.alignof;
|
||||
const Allocator* NULL_ALLOCATOR = &_NULL_ALLOCATOR;
|
||||
const Allocator* LIBC_ALLOCATOR = &_SYSTEM_ALLOCATOR;
|
||||
|
||||
typedef AllocatorFunction = fn void*!(Allocator* allocator, usz new_size, usz alignment, usz offset, void* old_pointer, AllocationKind kind);
|
||||
def AllocatorFunction = fn void*!(Allocator* allocator, usz new_size, usz alignment, usz offset, void* old_pointer, AllocationKind kind);
|
||||
|
||||
struct Allocator
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ struct SubArrayContainer
|
||||
usz len;
|
||||
}
|
||||
|
||||
typedef TestFn = fn void!();
|
||||
def TestFn = fn void!();
|
||||
|
||||
struct TestRunner
|
||||
{
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
module std::core::string;
|
||||
import std::ascii;
|
||||
|
||||
typedef ZString = distinct inline char*;
|
||||
typedef Char32 = uint;
|
||||
typedef Char16 = ushort;
|
||||
def ZString = distinct inline char*;
|
||||
def Char32 = uint;
|
||||
def Char16 = ushort;
|
||||
|
||||
fault UnicodeResult
|
||||
{
|
||||
@@ -361,6 +361,30 @@ fn Char32[]! String.to_utf32(String s, Allocator* using = mem::heap())
|
||||
return data[:codepoints];
|
||||
}
|
||||
|
||||
fn void String.convert_ascii_to_lower(String s)
|
||||
{
|
||||
foreach (&c : s) if (*c >= 'A' && *c <= 'Z') *c += 'a' - 'A';
|
||||
}
|
||||
|
||||
fn String String.ascii_to_lower(String s, Allocator* using = mem::heap())
|
||||
{
|
||||
String copy = s.copy(using);
|
||||
copy.convert_ascii_to_lower();
|
||||
return copy;
|
||||
}
|
||||
|
||||
fn void String.convert_ascii_to_upper(String s)
|
||||
{
|
||||
foreach (&c : s) if (*c >= 'a' && *c <= 'z') *c -= 'a' - 'A';
|
||||
}
|
||||
|
||||
fn String String.ascii_to_upper(String s, Allocator* using = mem::heap())
|
||||
{
|
||||
String copy = s.copy(using);
|
||||
copy.convert_ascii_to_upper();
|
||||
return copy;
|
||||
}
|
||||
|
||||
fn String! from_utf32(Char32[] utf32, Allocator* using = mem::heap())
|
||||
{
|
||||
usz len = conv::utf8len_for_utf32(utf32);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// a copy of which can be found in the LICENSE_STDLIB file.
|
||||
module std::hash::fnv32a;
|
||||
|
||||
typedef Fnv32a = distinct uint;
|
||||
def Fnv32a = distinct uint;
|
||||
|
||||
const FNV32A_START @private = 0x811c9dc5;
|
||||
const FNV32A_MUL @private = 0x01000193;
|
||||
|
||||
@@ -21,10 +21,10 @@ fault FormattingFault
|
||||
INVALID_FORMAT_TYPE,
|
||||
}
|
||||
|
||||
typedef OutputFn = fn void!(char c, void* buffer);
|
||||
typedef ToStringFunction = fn String(void* value, Allocator *using);
|
||||
typedef ToFormatFunction = fn void!(void* value, Formatter* formatter);
|
||||
typedef FloatType = double;
|
||||
def OutputFn = fn void!(char c, void* buffer);
|
||||
def ToStringFunction = fn String(void* value, Allocator *using);
|
||||
def ToFormatFunction = fn void!(void* value, Formatter* formatter);
|
||||
def FloatType = double;
|
||||
|
||||
fn usz! printf(String format, args...) @maydiscard
|
||||
{
|
||||
@@ -472,8 +472,8 @@ fn usz! Formatter.vprintf(Formatter* this, String format, any[] anys)
|
||||
return this.idx;
|
||||
}
|
||||
|
||||
typedef StringFunctionMap @private = HashMap<typeid, ToStringFunction>;
|
||||
typedef FormatterFunctionMap @private = HashMap<typeid, ToFormatFunction>;
|
||||
def StringFunctionMap @private = HashMap<typeid, ToStringFunction>;
|
||||
def FormatterFunctionMap @private = HashMap<typeid, ToFormatFunction>;
|
||||
|
||||
FormatterFunctionMap toformat_functions @private;
|
||||
StringFunctionMap tostring_functions @private;
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
module std::io;
|
||||
|
||||
typedef CloseStreamFn = fn void!(Stream*);
|
||||
typedef FlushStreamFn = fn void!(Stream*);
|
||||
typedef SeekStreamFn = fn usz!(Stream*, isz offset, Seek seek);
|
||||
typedef LenStreamFn = fn usz(Stream*);
|
||||
typedef AvailableStreamFn = fn usz(Stream*);
|
||||
typedef ReadStreamFn = fn usz!(Stream*, char[] bytes);
|
||||
typedef ReadFromStreamFn = fn usz!(Stream*, Stream*);
|
||||
typedef ReadByteStreamFn = fn char!(Stream*);
|
||||
typedef PushbackByteStreamFn = fn void!(Stream*);
|
||||
typedef WriteStreamFn = fn usz!(Stream*, char[] bytes);
|
||||
typedef WriteToStreamFn = fn usz!(Stream*, Stream* out);
|
||||
typedef WriteByteStreamFn = fn void!(Stream*, char c);
|
||||
typedef DestroyStreamFn = fn void!(Stream*);
|
||||
def CloseStreamFn = fn void!(Stream*);
|
||||
def FlushStreamFn = fn void!(Stream*);
|
||||
def SeekStreamFn = fn usz!(Stream*, isz offset, Seek seek);
|
||||
def LenStreamFn = fn usz(Stream*);
|
||||
def AvailableStreamFn = fn usz(Stream*);
|
||||
def ReadStreamFn = fn usz!(Stream*, char[] bytes);
|
||||
def ReadFromStreamFn = fn usz!(Stream*, Stream*);
|
||||
def ReadByteStreamFn = fn char!(Stream*);
|
||||
def PushbackByteStreamFn = fn void!(Stream*);
|
||||
def WriteStreamFn = fn usz!(Stream*, char[] bytes);
|
||||
def WriteToStreamFn = fn usz!(Stream*, Stream* out);
|
||||
def WriteByteStreamFn = fn void!(Stream*, char c);
|
||||
def DestroyStreamFn = fn void!(Stream*);
|
||||
|
||||
struct StreamInterface
|
||||
{
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
module std::io::os;
|
||||
import libc;
|
||||
|
||||
typedef FopenFn = fn void*!(String, String);
|
||||
typedef FreopenFn = fn void*!(void*, String, String);
|
||||
typedef FcloseFn = fn void!(void*);
|
||||
typedef FseekFn = fn void!(void*, isz, Seek);
|
||||
typedef FtellFn = fn usz!(void*);
|
||||
typedef FwriteFn = fn usz!(void*, char[] buffer);
|
||||
typedef FreadFn = fn usz!(void*, char[] buffer);
|
||||
def FopenFn = fn void*!(String, String);
|
||||
def FreopenFn = fn void*!(void*, String, String);
|
||||
def FcloseFn = fn void!(void*);
|
||||
def FseekFn = fn void!(void*, isz, Seek);
|
||||
def FtellFn = fn usz!(void*);
|
||||
def FwriteFn = fn usz!(void*, char[] buffer);
|
||||
def FreadFn = fn usz!(void*, char[] buffer);
|
||||
|
||||
$if !$defined(native_fopen_fn):
|
||||
FopenFn native_fopen_fn @weak;
|
||||
|
||||
@@ -6,7 +6,7 @@ const char PREFERRED_SEPARATOR_WIN32 = '\\';
|
||||
const char PREFERRED_SEPARATOR_POSIX = '/';
|
||||
const char PREFERRED_SEPARATOR = env::os_is_win32() ? PREFERRED_SEPARATOR_WIN32 : PREFERRED_SEPARATOR_POSIX;
|
||||
|
||||
typedef PathList = List<Path>;
|
||||
def PathList = List<Path>;
|
||||
|
||||
fault PathResult
|
||||
{
|
||||
|
||||
@@ -31,9 +31,9 @@ fn void errno_set(Errno e)
|
||||
os::errno_set((int)e);
|
||||
}
|
||||
|
||||
typedef TerminateFunction = fn void();
|
||||
typedef CompareFunction = fn int(void*, void*);
|
||||
typedef JmpBuf = uptr[$$JMP_BUF_SIZE];
|
||||
def TerminateFunction = fn void();
|
||||
def CompareFunction = fn int(void*, void*);
|
||||
def JmpBuf = uptr[$$JMP_BUF_SIZE];
|
||||
|
||||
$if env::COMPILER_LIBC_AVAILABLE:
|
||||
|
||||
@@ -148,8 +148,8 @@ $endif
|
||||
|
||||
// stdio
|
||||
|
||||
typedef Fpos = long;
|
||||
typedef CFile = void*;
|
||||
def Fpos = long;
|
||||
def CFile = void*;
|
||||
|
||||
$switch
|
||||
$case env::COMPILER_LIBC_AVAILABLE && env::OS_TYPE == LINUX:
|
||||
@@ -202,8 +202,8 @@ const int EOF = -1;
|
||||
const int FOPEN_MAX = 20;
|
||||
const int FILENAME_MAX = 1024;
|
||||
|
||||
typedef Errno = distinct CInt;
|
||||
typedef SeekIndex = CLong;
|
||||
def Errno = distinct CInt;
|
||||
def SeekIndex = CLong;
|
||||
|
||||
$if env::COMPILER_LIBC_AVAILABLE:
|
||||
|
||||
@@ -338,11 +338,11 @@ $switch (env::OS_TYPE)
|
||||
|
||||
$case WIN32:
|
||||
|
||||
typedef Tm = TmCommon;
|
||||
def Tm = TmCommon;
|
||||
|
||||
$case WASI:
|
||||
|
||||
typedef TimeOffset = int;
|
||||
def TimeOffset = int;
|
||||
struct Tm
|
||||
{
|
||||
inline TmCommon common;
|
||||
@@ -359,7 +359,7 @@ $case OPENBSD:
|
||||
$case FREEBSD:
|
||||
$default:
|
||||
|
||||
typedef TimeOffset = CLong;
|
||||
def TimeOffset = CLong;
|
||||
struct Tm
|
||||
{
|
||||
inline TmCommon common;
|
||||
@@ -378,8 +378,8 @@ struct TimeSpec
|
||||
ulong ns;
|
||||
}
|
||||
|
||||
typedef Time_t = long;
|
||||
typedef Clock_t = ulong;
|
||||
def Time_t = long;
|
||||
def Clock_t = ulong;
|
||||
|
||||
$else
|
||||
|
||||
@@ -389,8 +389,8 @@ struct TimeSpec
|
||||
CLong ns;
|
||||
}
|
||||
|
||||
typedef Time_t = CLong;
|
||||
typedef Clock_t = CULong;
|
||||
def Time_t = CLong;
|
||||
def Clock_t = CULong;
|
||||
|
||||
$endif
|
||||
|
||||
@@ -432,7 +432,7 @@ extern fn usz strftime(char* str, usz maxsize, char* format, Tm *timeptr);
|
||||
extern fn Time_t time(Time_t *timer);
|
||||
|
||||
// signal
|
||||
typedef SignalFunction = fn void(int);
|
||||
def SignalFunction = fn void(int);
|
||||
extern fn SignalFunction signal(int sig, SignalFunction function);
|
||||
// Incomplete
|
||||
|
||||
|
||||
@@ -85,33 +85,33 @@ fault MatrixError
|
||||
MATRIX_INVERSE_DOESNT_EXIST,
|
||||
}
|
||||
|
||||
typedef Complexf = Complex<float>;
|
||||
typedef Complex = Complex<double>;
|
||||
define complexf_identity = complex::identity<float>;
|
||||
define complex_identity = complex::identity<double>;
|
||||
def Complexf = Complex<float>;
|
||||
def Complex = Complex<double>;
|
||||
def complexf_identity = complex::identity<float>;
|
||||
def complex_identity = complex::identity<double>;
|
||||
|
||||
typedef Quaternionf = Quaternion<float>;
|
||||
typedef Quaternion = Quaternion<double>;
|
||||
define quaternionf_identity = quaternion::identity<float>;
|
||||
define quaternion_identity = quaternion::identity<double>;
|
||||
def Quaternionf = Quaternion<float>;
|
||||
def Quaternion = Quaternion<double>;
|
||||
def quaternionf_identity = quaternion::identity<float>;
|
||||
def quaternion_identity = quaternion::identity<double>;
|
||||
|
||||
typedef Matrix2f = Matrix2x2<float>;
|
||||
typedef Matrix2 = Matrix2x2<double>;
|
||||
typedef Matrix3f = Matrix3x3<float>;
|
||||
typedef Matrix3 = Matrix3x3<double>;
|
||||
typedef Matrix4f = Matrix4x4<float>;
|
||||
typedef Matrix4 = Matrix4x4<double>;
|
||||
define matrix4_ortho = matrix::ortho<double>;
|
||||
define matrix4_perspective = matrix::perspective<double>;
|
||||
define matrix4f_ortho = matrix::ortho<float>;
|
||||
define matrix4f_perspective = matrix::perspective<float>;
|
||||
def Matrix2f = Matrix2x2<float>;
|
||||
def Matrix2 = Matrix2x2<double>;
|
||||
def Matrix3f = Matrix3x3<float>;
|
||||
def Matrix3 = Matrix3x3<double>;
|
||||
def Matrix4f = Matrix4x4<float>;
|
||||
def Matrix4 = Matrix4x4<double>;
|
||||
def matrix4_ortho = matrix::ortho<double>;
|
||||
def matrix4_perspective = matrix::perspective<double>;
|
||||
def matrix4f_ortho = matrix::ortho<float>;
|
||||
def matrix4f_perspective = matrix::perspective<float>;
|
||||
|
||||
define MATRIX2_IDENTITY = matrix::IDENTITY2<double>;
|
||||
define MATRIX2F_IDENTITY = matrix::IDENTITY2<float>;
|
||||
define MATRIX3_IDENTITY = matrix::IDENTITY3<double>;
|
||||
define MATRIX3F_IDENTITY = matrix::IDENTITY3<float>;
|
||||
define MATRIX4_IDENTITY = matrix::IDENTITY4<double>;
|
||||
define MATRIX4F_IDENTITY = matrix::IDENTITY4<float>;
|
||||
def MATRIX2_IDENTITY = matrix::IDENTITY2<double>;
|
||||
def MATRIX2F_IDENTITY = matrix::IDENTITY2<float>;
|
||||
def MATRIX3_IDENTITY = matrix::IDENTITY3<double>;
|
||||
def MATRIX3F_IDENTITY = matrix::IDENTITY3<float>;
|
||||
def MATRIX4_IDENTITY = matrix::IDENTITY4<double>;
|
||||
def MATRIX4F_IDENTITY = matrix::IDENTITY4<float>;
|
||||
|
||||
/**
|
||||
* @require types::is_numerical($typeof(x)) `The input must be a numerical value or numerical vector`
|
||||
|
||||
@@ -6,9 +6,9 @@ struct Random
|
||||
void* state;
|
||||
}
|
||||
|
||||
typedef RandomSeedFn = fn void(Random*, char[] seed);
|
||||
typedef RandomNextBytesFn = fn void(Random*, char[] buffer);
|
||||
typedef RandomNextFn = fn uint(Random*, int bits);
|
||||
def RandomSeedFn = fn void(Random*, char[] seed);
|
||||
def RandomNextBytesFn = fn void(Random*, char[] buffer);
|
||||
def RandomNextFn = fn uint(Random*, int bits);
|
||||
|
||||
struct RandomInterface
|
||||
{
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
module std::math::vector;
|
||||
import std::math;
|
||||
|
||||
typedef Vec2f = float[<2>];
|
||||
typedef Vec3f = float[<3>];
|
||||
typedef Vec4f = float[<4>];
|
||||
def Vec2f = float[<2>];
|
||||
def Vec3f = float[<3>];
|
||||
def Vec4f = float[<4>];
|
||||
|
||||
typedef Vec2 = double[<2>];
|
||||
typedef Vec3 = double[<3>];
|
||||
typedef Vec4 = double[<4>];
|
||||
def Vec2 = double[<2>];
|
||||
def Vec3 = double[<3>];
|
||||
def Vec4 = double[<4>];
|
||||
|
||||
macro Vec2f.length_sq(Vec2f v) => v.dot(v);
|
||||
macro Vec3f.length_sq(Vec3f v) => v.dot(v);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module std::math;
|
||||
|
||||
typedef SimpleRandom = distinct ulong;
|
||||
def SimpleRandom = distinct ulong;
|
||||
|
||||
const long SIMPLE_RANDOM_MULTIPLIER @local = 0x5DEECE66D;
|
||||
const long SIMPLE_RANDOM_ADDEND @local = 0xB;
|
||||
|
||||
@@ -6,7 +6,7 @@ $if !env::os_is_win32() && $defined(AddrInfo):
|
||||
const int F_GETFL = 3;
|
||||
const int F_SETFL = 4;
|
||||
|
||||
typedef NativeSocket = distinct int;
|
||||
def NativeSocket = distinct int;
|
||||
|
||||
extern fn NativeSocket socket(int af, int type, int protocol) @extern("socket");
|
||||
extern fn int getaddrinfo(ZString nodename, ZString servname, AddrInfo* hints, AddrInfo** res);
|
||||
|
||||
@@ -22,7 +22,7 @@ struct AddrInfo
|
||||
AddrInfo* ai_next;
|
||||
}
|
||||
|
||||
typedef NativeSocket = distinct uptr;
|
||||
def NativeSocket = distinct uptr;
|
||||
|
||||
extern fn int wsa_startup(int, void*) @extern("WSAStartup");
|
||||
extern fn int ioctlsocket(NativeSocket, long cmd, ulong *argp);
|
||||
|
||||
@@ -2,9 +2,9 @@ module std::os::macos::cf;
|
||||
|
||||
$if env::os_is_darwin():
|
||||
|
||||
typedef CFAllocatorRef = distinct void*;
|
||||
typedef CFAllocatorContextRef = distinct void*;
|
||||
typedef CFOptionFlags = usz;
|
||||
def CFAllocatorRef = distinct void*;
|
||||
def CFAllocatorContextRef = distinct void*;
|
||||
def CFOptionFlags = usz;
|
||||
|
||||
macro CFAllocatorRef default_allocator() => _macos_CFAllocatorGetDefault();
|
||||
macro void CFAllocatorRef.dealloc(CFAllocatorRef allocator, void* ptr) => _macos_CFAllocatorDeallocate(allocator, ptr);
|
||||
|
||||
@@ -2,9 +2,9 @@ module std::os::macos::cf;
|
||||
|
||||
$if env::os_is_darwin():
|
||||
|
||||
typedef CFArrayRef = distinct void*;
|
||||
typedef CFArrayCallBacksRef = distinct void*;
|
||||
typedef CFMutableArrayRef = distinct void*;
|
||||
def CFArrayRef = distinct void*;
|
||||
def CFArrayCallBacksRef = distinct void*;
|
||||
def CFMutableArrayRef = distinct void*;
|
||||
extern fn CFArrayRef _macos_CFArrayCreate(CFAllocatorRef allocator, void** values, CFIndex num_values, CFArrayCallBacksRef callBacks) @extern("CFArrayCreate");
|
||||
extern fn CFArrayRef _macos_CFArrayCopy(CFAllocatorRef allocator, CFArrayRef array) @extern("CFArrayCopy");
|
||||
extern fn CFIndex _macos_CFArrayGetCount(CFArrayRef array) @extern("CFArrayGetCount");
|
||||
|
||||
@@ -2,8 +2,8 @@ module std::os::macos::cf;
|
||||
|
||||
$if env::os_is_darwin():
|
||||
|
||||
typedef CFTypeRef = distinct void*;
|
||||
typedef CFIndex = isz;
|
||||
def CFTypeRef = distinct void*;
|
||||
def CFIndex = isz;
|
||||
struct CFRange
|
||||
{
|
||||
CFIndex location;
|
||||
|
||||
@@ -2,10 +2,10 @@ module std::os::macos::objc;
|
||||
|
||||
$if env::os_is_darwin():
|
||||
|
||||
typedef Class = distinct void*;
|
||||
typedef Method = distinct void*;
|
||||
typedef Ivar = distinct void*;
|
||||
typedef Selector = distinct void*;
|
||||
def Class = distinct void*;
|
||||
def Method = distinct void*;
|
||||
def Ivar = distinct void*;
|
||||
def Selector = distinct void*;
|
||||
|
||||
fault ObjcFailure
|
||||
{
|
||||
|
||||
@@ -39,7 +39,7 @@ struct Win32_WIN32_FIND_DATAW
|
||||
Win32_WORD wFinderFlags; // Obsolete. Do not use
|
||||
}
|
||||
|
||||
typedef Win32_LPWIN32_FIND_DATAW = Win32_WIN32_FIND_DATAW*;
|
||||
def Win32_LPWIN32_FIND_DATAW = Win32_WIN32_FIND_DATAW*;
|
||||
|
||||
extern fn Win32_BOOL win32_CloseHandle(Win32_HANDLE) @extern("CloseHandle");
|
||||
extern fn Win32_BOOL win32_CreatePipe(Win32_PHANDLE hReadPipe, Win32_PHANDLE hWritePipe, Win32_LPSECURITY_ATTRIBUTES lpPipeAttributes, Win32_DWORD nSize) @extern("CreatePipe");
|
||||
|
||||
@@ -1,172 +1,172 @@
|
||||
module std::os::win32;
|
||||
|
||||
typedef Win32_BOOL = int;
|
||||
typedef Win32_BOOLEAN = Win32_BYTE;
|
||||
typedef Win32_BYTE = char;
|
||||
typedef Win32_CCHAR = cinterop::CChar;
|
||||
typedef Win32_CHAR = cinterop::CChar;
|
||||
typedef Win32_COLORREF = Win32_DWORD;
|
||||
typedef Win32_DWORD = uint;
|
||||
typedef Win32_DWORDLONG = ulong;
|
||||
typedef Win32_DWORD_PTR = Win32_ULONG_PTR;
|
||||
typedef Win32_DWORD32 = uint;
|
||||
typedef Win32_DWORD64 = ulong;
|
||||
typedef Win32_FLOAT = float;
|
||||
typedef Win32_HACCEL = Win32_HANDLE;
|
||||
typedef Win32_HALF_PTR = int;
|
||||
typedef Win32_HANDLE = Win32_PVOID;
|
||||
typedef Win32_HBITMAP = Win32_HANDLE;
|
||||
typedef Win32_HBRUSH = Win32_HANDLE;
|
||||
typedef Win32_HCOLORSPACE = Win32_HANDLE;
|
||||
typedef Win32_HCONV = Win32_HANDLE;
|
||||
typedef Win32_HCONVLIST = Win32_HANDLE;
|
||||
typedef Win32_HCURSOR = Win32_HICON;
|
||||
typedef Win32_HDC = Win32_HANDLE;
|
||||
typedef Win32_HDDEDATA = Win32_HANDLE;
|
||||
typedef Win32_HDESK = Win32_HANDLE;
|
||||
typedef Win32_HDROP = Win32_HANDLE;
|
||||
typedef Win32_HDWP = Win32_HANDLE;
|
||||
typedef Win32_HFILE = int;
|
||||
typedef Win32_HFONT = Win32_HANDLE;
|
||||
typedef Win32_HGDIOBJ = Win32_HANDLE;
|
||||
typedef Win32_HGLOBAL = Win32_HANDLE;
|
||||
typedef Win32_HHOOK = Win32_HANDLE;
|
||||
typedef Win32_HICON = Win32_HANDLE;
|
||||
typedef Win32_HINSTANCE = Win32_HANDLE;
|
||||
typedef Win32_HKEY = Win32_HANDLE;
|
||||
typedef Win32_HKL = Win32_HANDLE;
|
||||
typedef Win32_HLOCAL = Win32_HANDLE;
|
||||
typedef Win32_HMENU = Win32_HANDLE;
|
||||
typedef Win32_HMETAFILE = Win32_HANDLE;
|
||||
typedef Win32_HMODULE = Win32_HANDLE;
|
||||
typedef Win32_HMONITOR = Win32_HANDLE;
|
||||
typedef Win32_HPALETTE = Win32_HANDLE;
|
||||
typedef Win32_HPEN = Win32_HANDLE;
|
||||
typedef Win32_HRESULT = Win32_LONG;
|
||||
typedef Win32_HRGN = Win32_HANDLE;
|
||||
typedef Win32_HRSRC = Win32_HANDLE;
|
||||
typedef Win32_HSZ = Win32_HANDLE;
|
||||
typedef Win32_HWINSTA = Win32_HANDLE;
|
||||
typedef Win32_HWND = Win32_HANDLE;
|
||||
typedef Win32_INT = int;
|
||||
typedef Win32_INT_PTR = iptr;
|
||||
typedef Win32_INT8 = ichar;
|
||||
typedef Win32_INT16 = short;
|
||||
typedef Win32_INT32 = int;
|
||||
typedef Win32_INT64 = long;
|
||||
typedef Win32_LANGID = Win32_WORD;
|
||||
typedef Win32_LCID = Win32_DWORD;
|
||||
typedef Win32_LCTYPE = Win32_DWORD;
|
||||
typedef Win32_LGRPID = Win32_DWORD;
|
||||
typedef Win32_LONG = int;
|
||||
typedef Win32_LONGLONG = long;
|
||||
typedef Win32_LONG_PTR = iptr;
|
||||
typedef Win32_LONG32 = int;
|
||||
typedef Win32_LONG64 = long;
|
||||
typedef Win32_LPARAM = Win32_LONG_PTR;
|
||||
typedef Win32_LPBOOL = Win32_BOOL*;
|
||||
typedef Win32_LPBYTE = Win32_BYTE*;
|
||||
typedef Win32_LPCOLORREF = Win32_DWORD*;
|
||||
typedef Win32_LPCSTR = Win32_CCHAR*;
|
||||
typedef Win32_LPCTSTR = Win32_LPCWSTR;
|
||||
typedef Win32_LPCVOID = void*;
|
||||
typedef Win32_LPCWSTR = Win32_WCHAR*;
|
||||
typedef Win32_LPDWORD = Win32_DWORD*;
|
||||
typedef Win32_LPHANDLE = Win32_HANDLE*;
|
||||
typedef Win32_LPINT = int*;
|
||||
typedef Win32_LPLONG = int*;
|
||||
typedef Win32_LPSTR = Win32_CCHAR*;
|
||||
typedef Win32_LPTSTR = Win32_LPWSTR;
|
||||
typedef Win32_LPVOID = void*;
|
||||
typedef Win32_LPWORD = Win32_WORD*;
|
||||
typedef Win32_LPWSTR = Win32_WCHAR*;
|
||||
typedef Win32_LRESULT = Win32_LONG_PTR;
|
||||
typedef Win32_PBOOL = Win32_BOOL*;
|
||||
typedef Win32_PBOOLEAN = Win32_BOOLEAN*;
|
||||
typedef Win32_PBYTE = Win32_BYTE*;
|
||||
typedef Win32_PCHAR = Win32_CHAR*;
|
||||
typedef Win32_PCSTR = Win32_CHAR*;
|
||||
typedef Win32_PCTSTR = Win32_LPCWSTR;
|
||||
typedef Win32_PCUNICODE_STRING = Win32_UNICODE_STRING*;
|
||||
typedef Win32_PCWSTR = Char16*;
|
||||
typedef Win32_PDWORD = Win32_DWORD*;
|
||||
typedef Win32_PDWORDLONG = Win32_DWORDLONG*;
|
||||
typedef Win32_PDWORDPTR = Win32_DWORD_PTR*;
|
||||
typedef Win32_PDWORD32 = Win32_DWORD32*;
|
||||
typedef Win32_PDWORD64 = Win32_DWORD64*;
|
||||
typedef Win32_PFLOAT = Win32_FLOAT*;
|
||||
typedef Win32_PHALFPTR = Win32_HALF_PTR*;
|
||||
typedef Win32_PHANDLE = Win32_HANDLE*;
|
||||
typedef Win32_PHKEY = Win32_HKEY*;
|
||||
typedef Win32_PINT = int*;
|
||||
typedef Win32_PINTPTR = Win32_INT_PTR*;
|
||||
typedef Win32_PINT8 = Win32_INT8*;
|
||||
typedef Win32_PINT16 = Win32_INT16*;
|
||||
typedef Win32_PINT32 = Win32_INT32*;
|
||||
typedef Win32_PINT64 = Win32_INT64*;
|
||||
typedef Win32_PLCID = Win32_PDWORD;
|
||||
typedef Win32_PLONG = Win32_LONG*;
|
||||
typedef Win32_PLONGLONG = Win32_LONGLONG*;
|
||||
typedef Win32_PLONG_PTR = Win32_LONG_PTR*;
|
||||
typedef Win32_PLONG32 = Win32_LONG32*;
|
||||
typedef Win32_PLONG64 = Win32_LONG64*;
|
||||
typedef Win32_POINTER_32 = uint;
|
||||
typedef Win32_POINTER_64 = uptr;
|
||||
typedef Win32_POINTER_SIGNED = iptr;
|
||||
typedef Win32_POINTER_UNSIGNED = uptr;
|
||||
typedef Win32_PSHORT = Win32_SHORT*;
|
||||
typedef Win32_PSIZE_T = usz*;
|
||||
typedef Win32_PSSIZE_T = isz*;
|
||||
typedef Win32_PSTR = Win32_CHAR*;
|
||||
typedef Win32_PTBYTE = Win32_TBYTE*;
|
||||
typedef Win32_PTCHAR = Win32_TCHAR*;
|
||||
typedef Win32_PTSTR = Win32_LPWSTR;
|
||||
typedef Win32_PUCHAR = Win32_UCHAR*;
|
||||
typedef Win32_PUHALFPTR = Win32_UHALF_PTR*;
|
||||
typedef Win32_PUINT = Win32_UINT*;
|
||||
typedef Win32_PUINTPTR = Win32_UINT_PTR*;
|
||||
typedef Win32_PUINT8 = Win32_UINT8*;
|
||||
typedef Win32_PUINT16 = Win32_UINT16*;
|
||||
typedef Win32_PUINT32 = Win32_UINT32*;
|
||||
typedef Win32_PUINT64 = Win32_UINT64*;
|
||||
typedef Win32_PULONG = Win32_ULONG*;
|
||||
typedef Win32_PULONGLONG = Win32_ULONGLONG*;
|
||||
typedef Win32_PULONG_PTR = Win32_ULONG_PTR*;
|
||||
typedef Win32_PULONG32 = Win32_ULONG32*;
|
||||
typedef Win32_PULONG64 = Win32_ULONG64*;
|
||||
typedef Win32_PUNICODE_STRING = Win32_UNICODE_STRING*;
|
||||
typedef Win32_PUSHORT = Win32_USHORT*;
|
||||
typedef Win32_PVOID = void*;
|
||||
typedef Win32_PWCHAR = Win32_WCHAR*;
|
||||
typedef Win32_PWORD = Win32_WORD*;
|
||||
typedef Win32_PWSTR = Win32_WCHAR*;
|
||||
typedef Win32_QWORD = ulong;
|
||||
typedef Win32_SC_HANDLE = Win32_HANDLE;
|
||||
typedef Win32_SC_LOCK = Win32_LPVOID;
|
||||
typedef Win32_SERVICE_STATUS_HANDLE = Win32_HANDLE;
|
||||
typedef Win32_SHORT = short;
|
||||
typedef Win32_SIZE_T = usz;
|
||||
typedef Win32_SSIZE_T = isz;
|
||||
typedef Win32_TBYTE = Win32_WCHAR;
|
||||
typedef Win32_TCHAR = Win32_WCHAR;
|
||||
typedef Win32_UCHAR = char;
|
||||
typedef Win32_UHALF_PTR = uint;
|
||||
typedef Win32_UINT = uint;
|
||||
typedef Win32_UINT_PTR = uptr;
|
||||
typedef Win32_UINT8 = char;
|
||||
typedef Win32_UINT16 = ushort;
|
||||
typedef Win32_UINT32 = uint;
|
||||
typedef Win32_UINT64 = ulong;
|
||||
typedef Win32_ULONG = uint;
|
||||
typedef Win32_ULONGLONG = ulong;
|
||||
typedef Win32_ULONG_PTR = ulong;
|
||||
typedef Win32_ULONG32 = uint;
|
||||
typedef Win32_ULONG64 = ulong;
|
||||
typedef Win32_USHORT = ushort;
|
||||
typedef Win32_USN = Win32_LONGLONG;
|
||||
typedef Win32_WCHAR = Char16;
|
||||
typedef Win32_WORD = ushort;
|
||||
typedef Win32_WPARAM = Win32_UINT_PTR;
|
||||
def Win32_BOOL = int;
|
||||
def Win32_BOOLEAN = Win32_BYTE;
|
||||
def Win32_BYTE = char;
|
||||
def Win32_CCHAR = cinterop::CChar;
|
||||
def Win32_CHAR = cinterop::CChar;
|
||||
def Win32_COLORREF = Win32_DWORD;
|
||||
def Win32_DWORD = uint;
|
||||
def Win32_DWORDLONG = ulong;
|
||||
def Win32_DWORD_PTR = Win32_ULONG_PTR;
|
||||
def Win32_DWORD32 = uint;
|
||||
def Win32_DWORD64 = ulong;
|
||||
def Win32_FLOAT = float;
|
||||
def Win32_HACCEL = Win32_HANDLE;
|
||||
def Win32_HALF_PTR = int;
|
||||
def Win32_HANDLE = Win32_PVOID;
|
||||
def Win32_HBITMAP = Win32_HANDLE;
|
||||
def Win32_HBRUSH = Win32_HANDLE;
|
||||
def Win32_HCOLORSPACE = Win32_HANDLE;
|
||||
def Win32_HCONV = Win32_HANDLE;
|
||||
def Win32_HCONVLIST = Win32_HANDLE;
|
||||
def Win32_HCURSOR = Win32_HICON;
|
||||
def Win32_HDC = Win32_HANDLE;
|
||||
def Win32_HDDEDATA = Win32_HANDLE;
|
||||
def Win32_HDESK = Win32_HANDLE;
|
||||
def Win32_HDROP = Win32_HANDLE;
|
||||
def Win32_HDWP = Win32_HANDLE;
|
||||
def Win32_HFILE = int;
|
||||
def Win32_HFONT = Win32_HANDLE;
|
||||
def Win32_HGDIOBJ = Win32_HANDLE;
|
||||
def Win32_HGLOBAL = Win32_HANDLE;
|
||||
def Win32_HHOOK = Win32_HANDLE;
|
||||
def Win32_HICON = Win32_HANDLE;
|
||||
def Win32_HINSTANCE = Win32_HANDLE;
|
||||
def Win32_HKEY = Win32_HANDLE;
|
||||
def Win32_HKL = Win32_HANDLE;
|
||||
def Win32_HLOCAL = Win32_HANDLE;
|
||||
def Win32_HMENU = Win32_HANDLE;
|
||||
def Win32_HMETAFILE = Win32_HANDLE;
|
||||
def Win32_HMODULE = Win32_HANDLE;
|
||||
def Win32_HMONITOR = Win32_HANDLE;
|
||||
def Win32_HPALETTE = Win32_HANDLE;
|
||||
def Win32_HPEN = Win32_HANDLE;
|
||||
def Win32_HRESULT = Win32_LONG;
|
||||
def Win32_HRGN = Win32_HANDLE;
|
||||
def Win32_HRSRC = Win32_HANDLE;
|
||||
def Win32_HSZ = Win32_HANDLE;
|
||||
def Win32_HWINSTA = Win32_HANDLE;
|
||||
def Win32_HWND = Win32_HANDLE;
|
||||
def Win32_INT = int;
|
||||
def Win32_INT_PTR = iptr;
|
||||
def Win32_INT8 = ichar;
|
||||
def Win32_INT16 = short;
|
||||
def Win32_INT32 = int;
|
||||
def Win32_INT64 = long;
|
||||
def Win32_LANGID = Win32_WORD;
|
||||
def Win32_LCID = Win32_DWORD;
|
||||
def Win32_LCTYPE = Win32_DWORD;
|
||||
def Win32_LGRPID = Win32_DWORD;
|
||||
def Win32_LONG = int;
|
||||
def Win32_LONGLONG = long;
|
||||
def Win32_LONG_PTR = iptr;
|
||||
def Win32_LONG32 = int;
|
||||
def Win32_LONG64 = long;
|
||||
def Win32_LPARAM = Win32_LONG_PTR;
|
||||
def Win32_LPBOOL = Win32_BOOL*;
|
||||
def Win32_LPBYTE = Win32_BYTE*;
|
||||
def Win32_LPCOLORREF = Win32_DWORD*;
|
||||
def Win32_LPCSTR = Win32_CCHAR*;
|
||||
def Win32_LPCTSTR = Win32_LPCWSTR;
|
||||
def Win32_LPCVOID = void*;
|
||||
def Win32_LPCWSTR = Win32_WCHAR*;
|
||||
def Win32_LPDWORD = Win32_DWORD*;
|
||||
def Win32_LPHANDLE = Win32_HANDLE*;
|
||||
def Win32_LPINT = int*;
|
||||
def Win32_LPLONG = int*;
|
||||
def Win32_LPSTR = Win32_CCHAR*;
|
||||
def Win32_LPTSTR = Win32_LPWSTR;
|
||||
def Win32_LPVOID = void*;
|
||||
def Win32_LPWORD = Win32_WORD*;
|
||||
def Win32_LPWSTR = Win32_WCHAR*;
|
||||
def Win32_LRESULT = Win32_LONG_PTR;
|
||||
def Win32_PBOOL = Win32_BOOL*;
|
||||
def Win32_PBOOLEAN = Win32_BOOLEAN*;
|
||||
def Win32_PBYTE = Win32_BYTE*;
|
||||
def Win32_PCHAR = Win32_CHAR*;
|
||||
def Win32_PCSTR = Win32_CHAR*;
|
||||
def Win32_PCTSTR = Win32_LPCWSTR;
|
||||
def Win32_PCUNICODE_STRING = Win32_UNICODE_STRING*;
|
||||
def Win32_PCWSTR = Char16*;
|
||||
def Win32_PDWORD = Win32_DWORD*;
|
||||
def Win32_PDWORDLONG = Win32_DWORDLONG*;
|
||||
def Win32_PDWORDPTR = Win32_DWORD_PTR*;
|
||||
def Win32_PDWORD32 = Win32_DWORD32*;
|
||||
def Win32_PDWORD64 = Win32_DWORD64*;
|
||||
def Win32_PFLOAT = Win32_FLOAT*;
|
||||
def Win32_PHALFPTR = Win32_HALF_PTR*;
|
||||
def Win32_PHANDLE = Win32_HANDLE*;
|
||||
def Win32_PHKEY = Win32_HKEY*;
|
||||
def Win32_PINT = int*;
|
||||
def Win32_PINTPTR = Win32_INT_PTR*;
|
||||
def Win32_PINT8 = Win32_INT8*;
|
||||
def Win32_PINT16 = Win32_INT16*;
|
||||
def Win32_PINT32 = Win32_INT32*;
|
||||
def Win32_PINT64 = Win32_INT64*;
|
||||
def Win32_PLCID = Win32_PDWORD;
|
||||
def Win32_PLONG = Win32_LONG*;
|
||||
def Win32_PLONGLONG = Win32_LONGLONG*;
|
||||
def Win32_PLONG_PTR = Win32_LONG_PTR*;
|
||||
def Win32_PLONG32 = Win32_LONG32*;
|
||||
def Win32_PLONG64 = Win32_LONG64*;
|
||||
def Win32_POINTER_32 = uint;
|
||||
def Win32_POINTER_64 = uptr;
|
||||
def Win32_POINTER_SIGNED = iptr;
|
||||
def Win32_POINTER_UNSIGNED = uptr;
|
||||
def Win32_PSHORT = Win32_SHORT*;
|
||||
def Win32_PSIZE_T = usz*;
|
||||
def Win32_PSSIZE_T = isz*;
|
||||
def Win32_PSTR = Win32_CHAR*;
|
||||
def Win32_PTBYTE = Win32_TBYTE*;
|
||||
def Win32_PTCHAR = Win32_TCHAR*;
|
||||
def Win32_PTSTR = Win32_LPWSTR;
|
||||
def Win32_PUCHAR = Win32_UCHAR*;
|
||||
def Win32_PUHALFPTR = Win32_UHALF_PTR*;
|
||||
def Win32_PUINT = Win32_UINT*;
|
||||
def Win32_PUINTPTR = Win32_UINT_PTR*;
|
||||
def Win32_PUINT8 = Win32_UINT8*;
|
||||
def Win32_PUINT16 = Win32_UINT16*;
|
||||
def Win32_PUINT32 = Win32_UINT32*;
|
||||
def Win32_PUINT64 = Win32_UINT64*;
|
||||
def Win32_PULONG = Win32_ULONG*;
|
||||
def Win32_PULONGLONG = Win32_ULONGLONG*;
|
||||
def Win32_PULONG_PTR = Win32_ULONG_PTR*;
|
||||
def Win32_PULONG32 = Win32_ULONG32*;
|
||||
def Win32_PULONG64 = Win32_ULONG64*;
|
||||
def Win32_PUNICODE_STRING = Win32_UNICODE_STRING*;
|
||||
def Win32_PUSHORT = Win32_USHORT*;
|
||||
def Win32_PVOID = void*;
|
||||
def Win32_PWCHAR = Win32_WCHAR*;
|
||||
def Win32_PWORD = Win32_WORD*;
|
||||
def Win32_PWSTR = Win32_WCHAR*;
|
||||
def Win32_QWORD = ulong;
|
||||
def Win32_SC_HANDLE = Win32_HANDLE;
|
||||
def Win32_SC_LOCK = Win32_LPVOID;
|
||||
def Win32_SERVICE_STATUS_HANDLE = Win32_HANDLE;
|
||||
def Win32_SHORT = short;
|
||||
def Win32_SIZE_T = usz;
|
||||
def Win32_SSIZE_T = isz;
|
||||
def Win32_TBYTE = Win32_WCHAR;
|
||||
def Win32_TCHAR = Win32_WCHAR;
|
||||
def Win32_UCHAR = char;
|
||||
def Win32_UHALF_PTR = uint;
|
||||
def Win32_UINT = uint;
|
||||
def Win32_UINT_PTR = uptr;
|
||||
def Win32_UINT8 = char;
|
||||
def Win32_UINT16 = ushort;
|
||||
def Win32_UINT32 = uint;
|
||||
def Win32_UINT64 = ulong;
|
||||
def Win32_ULONG = uint;
|
||||
def Win32_ULONGLONG = ulong;
|
||||
def Win32_ULONG_PTR = ulong;
|
||||
def Win32_ULONG32 = uint;
|
||||
def Win32_ULONG64 = ulong;
|
||||
def Win32_USHORT = ushort;
|
||||
def Win32_USN = Win32_LONGLONG;
|
||||
def Win32_WCHAR = Char16;
|
||||
def Win32_WORD = ushort;
|
||||
def Win32_WPARAM = Win32_UINT_PTR;
|
||||
|
||||
const INVALID_HANDLE_VALUE = (Win32_HANDLE)(uptr)-1;
|
||||
|
||||
@@ -187,7 +187,7 @@ union Win32_LARGE_INTEGER
|
||||
ulong quadPart;
|
||||
}
|
||||
|
||||
typedef Win32_CRITICAL_SECTION = distinct ulong[5];
|
||||
def Win32_CRITICAL_SECTION = distinct ulong[5];
|
||||
|
||||
struct Win32_SECURITY_ATTRIBUTES
|
||||
{
|
||||
@@ -196,8 +196,8 @@ struct Win32_SECURITY_ATTRIBUTES
|
||||
Win32_BOOL bInheritHandle;
|
||||
}
|
||||
|
||||
typedef Win32_LPSECURITY_ATTRIBUTES = Win32_SECURITY_ATTRIBUTES*;
|
||||
typedef Win32_PSECURITY_ATTRIBUTES = Win32_SECURITY_ATTRIBUTES*;
|
||||
def Win32_LPSECURITY_ATTRIBUTES = Win32_SECURITY_ATTRIBUTES*;
|
||||
def Win32_PSECURITY_ATTRIBUTES = Win32_SECURITY_ATTRIBUTES*;
|
||||
|
||||
struct Win32_STARTUPINFOW
|
||||
{
|
||||
@@ -221,7 +221,7 @@ struct Win32_STARTUPINFOW
|
||||
Win32_HANDLE hStdError;
|
||||
}
|
||||
|
||||
typedef Win32_LPSTARTUPINFOW = Win32_STARTUPINFOW*;
|
||||
def Win32_LPSTARTUPINFOW = Win32_STARTUPINFOW*;
|
||||
|
||||
struct Win32_STARTUPINFOEXW
|
||||
{
|
||||
@@ -229,8 +229,8 @@ struct Win32_STARTUPINFOEXW
|
||||
Win32_LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList;
|
||||
}
|
||||
|
||||
typedef Win32_LPPROC_THREAD_ATTRIBUTE_LIST = void*;
|
||||
typedef Win32_LPSTARTUPINFOEXW = Win32_STARTUPINFOEXW*;
|
||||
def Win32_LPPROC_THREAD_ATTRIBUTE_LIST = void*;
|
||||
def Win32_LPSTARTUPINFOEXW = Win32_STARTUPINFOEXW*;
|
||||
|
||||
struct Win32_FILETIME
|
||||
{
|
||||
@@ -246,5 +246,5 @@ struct Win32_PROCESS_INFORMATION
|
||||
Win32_DWORD dwThreadId;
|
||||
}
|
||||
|
||||
typedef Win32_PPROCESS_INFORMATION = Win32_PROCESS_INFORMATION*;
|
||||
typedef Win32_LPPROCESS_INFORMATION = Win32_PROCESS_INFORMATION*;
|
||||
def Win32_PPROCESS_INFORMATION = Win32_PROCESS_INFORMATION*;
|
||||
def Win32_LPPROCESS_INFORMATION = Win32_PROCESS_INFORMATION*;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module std::os::win32;
|
||||
|
||||
typedef WSAError = distinct int;
|
||||
def WSAError = distinct int;
|
||||
|
||||
$if env::os_is_win32():
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module std::thread;
|
||||
|
||||
typedef NativeMutex = distinct int;
|
||||
typedef NativeConditionVariable = distinct int;
|
||||
typedef NativeOnceFlag = distinct int;
|
||||
typedef NativeThread = distinct int;
|
||||
def NativeMutex = distinct int;
|
||||
def NativeConditionVariable = distinct int;
|
||||
def NativeOnceFlag = distinct int;
|
||||
def NativeThread = distinct int;
|
||||
@@ -7,30 +7,30 @@ const PTHREAD_MUTEX_NORMAL = 0;
|
||||
const PTHREAD_MUTEX_ERRORCHECK = 1;
|
||||
const PTHREAD_MUTEX_RECURSIVE = 2;
|
||||
|
||||
typedef NativeMutex = PthreadMutex;
|
||||
typedef NativeConditionVariable = PthreadCond;
|
||||
typedef NativeThread = Pthread;
|
||||
typedef NativeOnceFlag = PthreadOnce;
|
||||
def NativeMutex = PthreadMutex;
|
||||
def NativeConditionVariable = PthreadCond;
|
||||
def NativeThread = Pthread;
|
||||
def NativeOnceFlag = PthreadOnce;
|
||||
|
||||
typedef Pthread = distinct void*;
|
||||
def Pthread = distinct void*;
|
||||
|
||||
$if env::OS_TYPE == LINUX:
|
||||
typedef PthreadMutex = distinct ulong[5];
|
||||
typedef PthreadAttribute = distinct ulong[7];
|
||||
typedef PthreadMutexAttribute = distinct uint;
|
||||
typedef PthreadCondAttribute = distinct uint;
|
||||
typedef PthreadCond = distinct ulong[6];
|
||||
typedef PthreadOnce = distinct uint;
|
||||
def PthreadMutex = distinct ulong[5];
|
||||
def PthreadAttribute = distinct ulong[7];
|
||||
def PthreadMutexAttribute = distinct uint;
|
||||
def PthreadCondAttribute = distinct uint;
|
||||
def PthreadCond = distinct ulong[6];
|
||||
def PthreadOnce = distinct uint;
|
||||
$else
|
||||
typedef PthreadMutex = distinct ulong[8];
|
||||
typedef PthreadMutexAttribute = distinct ulong[2];
|
||||
typedef PthreadAttribute = distinct ulong[8];
|
||||
typedef PthreadCond = distinct ulong[6];
|
||||
typedef PthreadCondAttribute = distinct ulong[8];
|
||||
typedef PthreadOnce = distinct ulong[2];
|
||||
def PthreadMutex = distinct ulong[8];
|
||||
def PthreadMutexAttribute = distinct ulong[2];
|
||||
def PthreadAttribute = distinct ulong[8];
|
||||
def PthreadCond = distinct ulong[6];
|
||||
def PthreadCondAttribute = distinct ulong[8];
|
||||
def PthreadOnce = distinct ulong[2];
|
||||
$endif
|
||||
|
||||
typedef PosixThreadFn = fn void*(void*);
|
||||
def PosixThreadFn = fn void*(void*);
|
||||
|
||||
extern fn int pthread_attr_destroy(PthreadAttribute*);
|
||||
extern fn int pthread_attr_getdetachstate(PthreadAttribute*, int*);
|
||||
|
||||
@@ -11,19 +11,19 @@ const ThreadModel THREAD_MODEL = env::COMPILER_LIBC_AVAILABLE
|
||||
? (env::os_is_win32() ? ThreadModel.WIN32 : ThreadModel.POSIX)
|
||||
: ThreadModel.NONE;
|
||||
|
||||
typedef MutexType = distinct int;
|
||||
def MutexType = distinct int;
|
||||
|
||||
const MutexType MUTEX_PLAIN = 0;
|
||||
const MutexType MUTEX_TIMED = 1;
|
||||
const MutexType MUTEX_RECURSIVE = 2;
|
||||
|
||||
typedef Mutex = distinct NativeMutex;
|
||||
typedef ConditionVariable = distinct NativeConditionVariable;
|
||||
typedef Thread = distinct NativeThread;
|
||||
typedef OnceFlag = distinct NativeOnceFlag;
|
||||
typedef OnceFn = fn void();
|
||||
def Mutex = distinct NativeMutex;
|
||||
def ConditionVariable = distinct NativeConditionVariable;
|
||||
def Thread = distinct NativeThread;
|
||||
def OnceFlag = distinct NativeOnceFlag;
|
||||
def OnceFn = fn void();
|
||||
|
||||
typedef ThreadFn = fn int(void* arg);
|
||||
def ThreadFn = fn int(void* arg);
|
||||
|
||||
fault ThreadFault
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user