improve rpc
parent
6fe631b5d5
commit
654bf9ff5b
|
@ -713,8 +713,7 @@ struct thread_queue_t
|
|||
} THREADNAME_INFO;
|
||||
#pragma pack(pop)
|
||||
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
|
||||
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE //< @r-lyeh: pthread_setname_np()
|
||||
#endif
|
||||
|
@ -738,7 +737,7 @@ thread_id_t thread_current_thread_id( void )
|
|||
|
||||
return (void*) (uintptr_t)GetCurrentThreadId();
|
||||
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
|
||||
|
||||
return (void*) pthread_self();
|
||||
|
||||
|
@ -754,7 +753,7 @@ void thread_yield( void )
|
|||
|
||||
SwitchToThread();
|
||||
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
|
||||
|
||||
sched_yield();
|
||||
|
||||
|
@ -770,7 +769,7 @@ void thread_exit( int return_code )
|
|||
|
||||
ExitThread( (DWORD) return_code );
|
||||
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
|
||||
|
||||
pthread_exit( (void*)(uintptr_t) return_code );
|
||||
|
||||
|
@ -811,13 +810,13 @@ thread_ptr_t thread_init( int (*thread_proc)( void* ), void* user_data, char con
|
|||
|
||||
return (thread_ptr_t) handle;
|
||||
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
|
||||
|
||||
pthread_t thread;
|
||||
if( 0 != pthread_create( &thread, NULL, ( void* (*)( void * ) ) thread_proc, user_data ) )
|
||||
return NULL;
|
||||
|
||||
#if !defined( __APPLE__ ) && !defined( __EMSCRIPTEN__ ) // max doesn't support pthread_setname_np. alternatives? //< @r-lyeh, ems
|
||||
#if !defined( __APPLE__ ) && !defined( __EMSCRIPTEN__ ) && !defined( EMSCRIPTEN ) // max doesn't support pthread_setname_np. alternatives? //< @r-lyeh, ems
|
||||
if( name ) pthread_setname_np( thread, name );
|
||||
#endif
|
||||
|
||||
|
@ -836,7 +835,7 @@ void thread_term( thread_ptr_t thread )
|
|||
WaitForSingleObject( (HANDLE) thread, INFINITE );
|
||||
CloseHandle( (HANDLE) thread );
|
||||
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
|
||||
|
||||
pthread_join( (pthread_t) thread, NULL );
|
||||
|
||||
|
@ -855,7 +854,7 @@ int thread_join( thread_ptr_t thread )
|
|||
GetExitCodeThread( (HANDLE) thread, &retval );
|
||||
return (int) retval;
|
||||
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
|
||||
|
||||
void* retval;
|
||||
pthread_join( (pthread_t) thread, &retval );
|
||||
|
@ -873,7 +872,7 @@ int thread_detach( thread_ptr_t thread )
|
|||
|
||||
return CloseHandle( (HANDLE) thread ) != 0;
|
||||
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN )
|
||||
|
||||
return pthread_detach( (pthread_t) thread ) == 0;
|
||||
|
||||
|
@ -889,7 +888,7 @@ void thread_set_high_priority( void )
|
|||
|
||||
SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_HIGHEST );
|
||||
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
|
||||
|
||||
struct sched_param sp;
|
||||
memset( &sp, 0, sizeof( sp ) );
|
||||
|
@ -914,7 +913,7 @@ void thread_mutex_init( thread_mutex_t* mutex )
|
|||
|
||||
InitializeCriticalSectionAndSpinCount( (CRITICAL_SECTION*) mutex, 32 );
|
||||
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
|
||||
|
||||
// Compile-time size check
|
||||
struct x { char thread_mutex_type_too_small : ( sizeof( thread_mutex_t ) < sizeof( pthread_mutex_t ) ? 0 : 1 ); };
|
||||
|
@ -933,7 +932,7 @@ void thread_mutex_term( thread_mutex_t* mutex )
|
|||
|
||||
DeleteCriticalSection( (CRITICAL_SECTION*) mutex );
|
||||
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
|
||||
|
||||
pthread_mutex_destroy( (pthread_mutex_t*) mutex );
|
||||
|
||||
|
@ -949,7 +948,7 @@ void thread_mutex_lock( thread_mutex_t* mutex )
|
|||
|
||||
EnterCriticalSection( (CRITICAL_SECTION*) mutex );
|
||||
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
|
||||
|
||||
pthread_mutex_lock( (pthread_mutex_t*) mutex );
|
||||
|
||||
|
@ -965,7 +964,7 @@ void thread_mutex_unlock( thread_mutex_t* mutex )
|
|||
|
||||
LeaveCriticalSection( (CRITICAL_SECTION*) mutex );
|
||||
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
|
||||
|
||||
pthread_mutex_unlock( (pthread_mutex_t*) mutex );
|
||||
|
||||
|
@ -987,7 +986,7 @@ struct thread_internal_signal_t
|
|||
HANDLE event;
|
||||
#endif
|
||||
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
|
||||
|
||||
pthread_mutex_t mutex;
|
||||
pthread_cond_t condition;
|
||||
|
@ -1019,7 +1018,7 @@ void thread_signal_init( thread_signal_t* signal )
|
|||
internal->event = CreateEvent( NULL, FALSE, FALSE, NULL );
|
||||
#endif
|
||||
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
|
||||
|
||||
pthread_mutex_init( &internal->mutex, NULL );
|
||||
pthread_cond_init( &internal->condition, NULL );
|
||||
|
@ -1043,7 +1042,7 @@ void thread_signal_init( thread_signal_t* signal )
|
|||
CloseHandle( internal->event );
|
||||
#endif
|
||||
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
|
||||
|
||||
pthread_mutex_destroy( &internal->mutex );
|
||||
pthread_cond_destroy( &internal->condition );
|
||||
|
@ -1069,7 +1068,7 @@ void thread_signal_raise( thread_signal_t* signal )
|
|||
SetEvent( internal->event );
|
||||
#endif
|
||||
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
|
||||
|
||||
pthread_mutex_lock( &internal->mutex );
|
||||
internal->value = 1;
|
||||
|
@ -1104,7 +1103,7 @@ int thread_signal_wait( thread_signal_t* signal, int timeout_ms )
|
|||
return !failed;
|
||||
#endif
|
||||
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
|
||||
|
||||
struct timespec ts;
|
||||
if( timeout_ms >= 0 )
|
||||
|
@ -1148,7 +1147,7 @@ int thread_atomic_int_load( thread_atomic_int_t* atomic )
|
|||
|
||||
return InterlockedCompareExchange( &atomic->i, 0, 0 );
|
||||
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
|
||||
|
||||
return (int)__sync_fetch_and_add( &atomic->i, 0 );
|
||||
|
||||
|
@ -1164,7 +1163,7 @@ void thread_atomic_int_store( thread_atomic_int_t* atomic, int desired )
|
|||
|
||||
InterlockedExchange( &atomic->i, desired );
|
||||
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
|
||||
|
||||
__sync_fetch_and_and( &atomic->i, 0 );
|
||||
__sync_fetch_and_or( &atomic->i, desired );
|
||||
|
@ -1181,7 +1180,7 @@ int thread_atomic_int_inc( thread_atomic_int_t* atomic )
|
|||
|
||||
return InterlockedIncrement( &atomic->i ) - 1;
|
||||
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
|
||||
|
||||
return (int)__sync_fetch_and_add( &atomic->i, 1 );
|
||||
|
||||
|
@ -1197,7 +1196,7 @@ int thread_atomic_int_dec( thread_atomic_int_t* atomic )
|
|||
|
||||
return InterlockedDecrement( &atomic->i ) + 1;
|
||||
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
|
||||
|
||||
return (int)__sync_fetch_and_sub( &atomic->i, 1 );
|
||||
|
||||
|
@ -1213,7 +1212,7 @@ int thread_atomic_int_add( thread_atomic_int_t* atomic, int value )
|
|||
|
||||
return InterlockedExchangeAdd ( &atomic->i, value );
|
||||
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
|
||||
|
||||
return (int)__sync_fetch_and_add( &atomic->i, value );
|
||||
|
||||
|
@ -1229,7 +1228,7 @@ int thread_atomic_int_sub( thread_atomic_int_t* atomic, int value )
|
|||
|
||||
return InterlockedExchangeAdd( &atomic->i, -value );
|
||||
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
|
||||
|
||||
return (int)__sync_fetch_and_sub( &atomic->i, value );
|
||||
|
||||
|
@ -1245,7 +1244,7 @@ int thread_atomic_int_swap( thread_atomic_int_t* atomic, int desired )
|
|||
|
||||
return InterlockedExchange( &atomic->i, desired );
|
||||
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
|
||||
|
||||
int old = (int)__sync_lock_test_and_set( &atomic->i, desired );
|
||||
__sync_lock_release( &atomic->i );
|
||||
|
@ -1263,7 +1262,7 @@ int thread_atomic_int_compare_and_swap( thread_atomic_int_t* atomic, int expecte
|
|||
|
||||
return InterlockedCompareExchange( &atomic->i, desired, expected );
|
||||
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
|
||||
|
||||
return (int)__sync_val_compare_and_swap( &atomic->i, expected, desired );
|
||||
|
||||
|
@ -1279,7 +1278,7 @@ void* thread_atomic_ptr_load( thread_atomic_ptr_t* atomic )
|
|||
|
||||
return InterlockedCompareExchangePointer( &atomic->ptr, 0, 0 );
|
||||
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
|
||||
|
||||
return __sync_fetch_and_add( &atomic->ptr, 0 );
|
||||
|
||||
|
@ -1301,7 +1300,7 @@ void thread_atomic_ptr_store( thread_atomic_ptr_t* atomic, void* desired )
|
|||
#pragma warning( pop )
|
||||
|
||||
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
|
||||
|
||||
__sync_lock_test_and_set( &atomic->ptr, desired );
|
||||
__sync_lock_release( &atomic->ptr );
|
||||
|
@ -1323,7 +1322,7 @@ void* thread_atomic_ptr_swap( thread_atomic_ptr_t* atomic, void* desired )
|
|||
return InterlockedExchangePointer( &atomic->ptr, desired );
|
||||
#pragma warning( pop )
|
||||
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
|
||||
|
||||
void* old = __sync_lock_test_and_set( &atomic->ptr, desired );
|
||||
__sync_lock_release( &atomic->ptr );
|
||||
|
@ -1341,7 +1340,7 @@ void* thread_atomic_ptr_compare_and_swap( thread_atomic_ptr_t* atomic, void* exp
|
|||
|
||||
return InterlockedCompareExchangePointer( &atomic->ptr, desired, expected );
|
||||
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
|
||||
|
||||
return __sync_val_compare_and_swap( &atomic->ptr, expected, desired );
|
||||
|
||||
|
@ -1368,7 +1367,7 @@ void thread_timer_init( thread_timer_t* timer )
|
|||
|
||||
*(HANDLE*)timer = CreateWaitableTimer( NULL, TRUE, NULL );
|
||||
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
|
||||
|
||||
// Nothing
|
||||
|
||||
|
@ -1388,7 +1387,7 @@ void thread_timer_term( thread_timer_t* timer )
|
|||
if( timeGetDevCaps( &tc, sizeof( TIMECAPS ) ) == TIMERR_NOERROR )
|
||||
timeEndPeriod( tc.wPeriodMin );
|
||||
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
|
||||
|
||||
// Nothing
|
||||
|
||||
|
@ -1408,7 +1407,7 @@ void thread_timer_wait( thread_timer_t* timer, THREAD_U64 nanoseconds )
|
|||
(void) b;
|
||||
WaitForSingleObject( *(HANDLE*)timer, INFINITE );
|
||||
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
|
||||
|
||||
struct timespec rem;
|
||||
struct timespec req;
|
||||
|
@ -1433,7 +1432,7 @@ thread_tls_t thread_tls_create( void )
|
|||
else
|
||||
return (thread_tls_t) (uintptr_t) tls;
|
||||
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
|
||||
|
||||
pthread_key_t tls;
|
||||
if( pthread_key_create( &tls, NULL ) == 0 )
|
||||
|
@ -1453,7 +1452,7 @@ void thread_tls_destroy( thread_tls_t tls )
|
|||
|
||||
TlsFree( (DWORD) (uintptr_t) tls );
|
||||
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
|
||||
|
||||
pthread_key_delete( (pthread_key_t) (uintptr_t) tls ); //< @r-lyeh: uintptr_t
|
||||
|
||||
|
@ -1469,7 +1468,7 @@ void thread_tls_set( thread_tls_t tls, void* value )
|
|||
|
||||
TlsSetValue( (DWORD) (uintptr_t) tls, value );
|
||||
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
|
||||
|
||||
pthread_setspecific( (pthread_key_t) (uintptr_t) tls, value ); //< @r-lyeh: uintptr_t
|
||||
|
||||
|
@ -1485,7 +1484,7 @@ void* thread_tls_get( thread_tls_t tls )
|
|||
|
||||
return TlsGetValue( (DWORD) (uintptr_t) tls );
|
||||
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
|
||||
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
|
||||
|
||||
return pthread_getspecific( (pthread_key_t) (uintptr_t) tls ); //< @r-lyeh: uintptr_t
|
||||
|
||||
|
|
|
@ -639,15 +639,21 @@ void network_rpc(const char *signature, void *function) {
|
|||
|
||||
void network_rpc_send_to(int64_t rank, unsigned id, const char *cmdline) {
|
||||
assert(network_get(NETWORK_RANK) == 0); /* must be a host */
|
||||
char *msg = va("%*.s%s", 8, "", cmdline);
|
||||
unsigned sz = strlen(cmdline) + 8;
|
||||
char *msg = MALLOC(sz);
|
||||
*(uint32_t*)&msg[0] = MSG_RPC;
|
||||
*(uint32_t*)&msg[4] = id;
|
||||
memcpy(&msg[8], cmdline, sz-8);
|
||||
server_send_bin(rank, msg, sz);
|
||||
FREE(msg);
|
||||
}
|
||||
|
||||
void network_rpc_send(unsigned id, const char *cmdline) {
|
||||
char *msg = va("%*.s%s", 8, "", cmdline);
|
||||
unsigned sz = strlen(cmdline) + 8;
|
||||
char *msg = MALLOC(sz);
|
||||
*(uint32_t*)&msg[0] = MSG_RPC;
|
||||
*(uint32_t*)&msg[4] = id;
|
||||
memcpy(&msg[8], cmdline, sz-8);
|
||||
server_broadcast_bin(msg, sz);
|
||||
FREE(msg);
|
||||
}
|
||||
|
|
|
@ -596,7 +596,7 @@ details > summary::-webkit-details-marker {
|
|||
|Version: | 2023.7 |
|
||||
|:--------------|:------------|
|
||||
|Branch: | main |
|
||||
|Commit: | 9 |
|
||||
|Commit: | 13 |
|
||||
<!--| Documentation last modified | { {LAST_MODIFIED} } |-->
|
||||
|
||||
# [V·4·K 2023.7 ](https://dev.v4.games/zaklaus/v4k)
|
||||
|
|
Loading…
Reference in New Issue