mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Support "typedef"
This commit is contained in:
committed by
Christoffer Lerno
parent
b7e19b75d0
commit
df77b692d6
@@ -1,6 +1,6 @@
|
||||
module std::thread;
|
||||
|
||||
define NativeMutex = distinct int;
|
||||
define NativeConditionVariable = distinct int;
|
||||
define NativeOnceFlag = distinct int;
|
||||
define NativeThread = distinct int;
|
||||
typedef NativeMutex = distinct int;
|
||||
typedef NativeConditionVariable = distinct int;
|
||||
typedef NativeOnceFlag = distinct int;
|
||||
typedef NativeThread = distinct int;
|
||||
@@ -7,30 +7,30 @@ const PTHREAD_MUTEX_NORMAL = 0;
|
||||
const PTHREAD_MUTEX_ERRORCHECK = 1;
|
||||
const PTHREAD_MUTEX_RECURSIVE = 2;
|
||||
|
||||
define NativeMutex = PthreadMutex;
|
||||
define NativeConditionVariable = PthreadCond;
|
||||
define NativeThread = Pthread;
|
||||
define NativeOnceFlag = PthreadOnce;
|
||||
typedef NativeMutex = PthreadMutex;
|
||||
typedef NativeConditionVariable = PthreadCond;
|
||||
typedef NativeThread = Pthread;
|
||||
typedef NativeOnceFlag = PthreadOnce;
|
||||
|
||||
define Pthread = distinct void*;
|
||||
typedef Pthread = distinct void*;
|
||||
|
||||
$if (env::OS_TYPE == OsType.LINUX):
|
||||
define PthreadMutex = distinct ulong[5];
|
||||
define PthreadAttribute = distinct ulong[7];
|
||||
define PthreadMutexAttribute = distinct uint;
|
||||
define PthreadCondAttribute = distinct uint;
|
||||
define PthreadCond = distinct ulong[6];
|
||||
define PthreadOnce = distinct uint;
|
||||
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;
|
||||
$else:
|
||||
define PthreadMutex = distinct ulong[8];
|
||||
define PthreadMutexAttribute = distinct ulong[2];
|
||||
define PthreadAttribute = distinct ulong[8];
|
||||
define PthreadCond = distinct ulong[6];
|
||||
define PthreadCondAttribute = distinct ulong[8];
|
||||
define PthreadOnce = distinct ulong[2];
|
||||
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];
|
||||
$endif;
|
||||
|
||||
define PosixThreadFn = fn void*(void*);
|
||||
typedef PosixThreadFn = fn void*(void*);
|
||||
|
||||
extern fn int pthread_attr_destroy(PthreadAttribute*);
|
||||
extern fn int pthread_attr_getdetachstate(PthreadAttribute*, int*);
|
||||
|
||||
@@ -2,9 +2,9 @@ module std::thread::os;
|
||||
|
||||
$if (thread::THREAD_MODEL == ThreadModel.WIN32):
|
||||
|
||||
define NativeThread = Win32_HANDLE;
|
||||
define Win32_CRITICAL_SECTION = distinct ulong[5];
|
||||
define Win32_HANDLE = distinct ulong;
|
||||
typedef NativeThread = Win32_HANDLE;
|
||||
typedef Win32_CRITICAL_SECTION = distinct ulong[5];
|
||||
typedef Win32_HANDLE = distinct ulong;
|
||||
|
||||
struct NativeMutex
|
||||
{
|
||||
|
||||
@@ -11,19 +11,19 @@ const ThreadModel THREAD_MODEL = env::COMPILER_LIBC_AVAILABLE
|
||||
? (env::OS_TYPE == OsType.WIN32 ? ThreadModel.WIN32 : ThreadModel.POSIX)
|
||||
: ThreadModel.NONE;
|
||||
|
||||
define MutexType = distinct int;
|
||||
typedef MutexType = distinct int;
|
||||
|
||||
const MutexType MUTEX_PLAIN = 0;
|
||||
const MutexType MUTEX_TIMED = 1;
|
||||
const MutexType MUTEX_RECURSIVE = 2;
|
||||
|
||||
define Mutex = distinct NativeMutex;
|
||||
define ConditionVariable = distinct NativeConditionVariable;
|
||||
define Thread = distinct NativeThread;
|
||||
define OnceFlag = distinct NativeOnceFlag;
|
||||
define OnceFn = fn void();
|
||||
typedef Mutex = distinct NativeMutex;
|
||||
typedef ConditionVariable = distinct NativeConditionVariable;
|
||||
typedef Thread = distinct NativeThread;
|
||||
typedef OnceFlag = distinct NativeOnceFlag;
|
||||
typedef OnceFn = fn void();
|
||||
|
||||
define ThreadFn = fn int(void* arg);
|
||||
typedef ThreadFn = fn int(void* arg);
|
||||
|
||||
fault ThreadFault
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user