improve rpc

main
Dominik Madarász 2023-08-10 21:27:16 +02:00
parent 6fe631b5d5
commit 654bf9ff5b
3 changed files with 47 additions and 42 deletions

View File

@ -713,8 +713,7 @@ struct thread_queue_t
} THREADNAME_INFO; } THREADNAME_INFO;
#pragma pack(pop) #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 #ifndef _GNU_SOURCE
#define _GNU_SOURCE //< @r-lyeh: pthread_setname_np() #define _GNU_SOURCE //< @r-lyeh: pthread_setname_np()
#endif #endif
@ -738,7 +737,7 @@ thread_id_t thread_current_thread_id( void )
return (void*) (uintptr_t)GetCurrentThreadId(); 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(); return (void*) pthread_self();
@ -754,7 +753,7 @@ void thread_yield( void )
SwitchToThread(); 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(); sched_yield();
@ -770,7 +769,7 @@ void thread_exit( int return_code )
ExitThread( (DWORD) 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 ); 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; 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; pthread_t thread;
if( 0 != pthread_create( &thread, NULL, ( void* (*)( void * ) ) thread_proc, user_data ) ) if( 0 != pthread_create( &thread, NULL, ( void* (*)( void * ) ) thread_proc, user_data ) )
return NULL; 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 ); if( name ) pthread_setname_np( thread, name );
#endif #endif
@ -836,7 +835,7 @@ void thread_term( thread_ptr_t thread )
WaitForSingleObject( (HANDLE) thread, INFINITE ); WaitForSingleObject( (HANDLE) thread, INFINITE );
CloseHandle( (HANDLE) thread ); 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 ); pthread_join( (pthread_t) thread, NULL );
@ -855,7 +854,7 @@ int thread_join( thread_ptr_t thread )
GetExitCodeThread( (HANDLE) thread, &retval ); GetExitCodeThread( (HANDLE) thread, &retval );
return (int) 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; void* retval;
pthread_join( (pthread_t) thread, &retval ); pthread_join( (pthread_t) thread, &retval );
@ -873,7 +872,7 @@ int thread_detach( thread_ptr_t thread )
return CloseHandle( (HANDLE) thread ) != 0; 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; return pthread_detach( (pthread_t) thread ) == 0;
@ -889,7 +888,7 @@ void thread_set_high_priority( void )
SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_HIGHEST ); 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; struct sched_param sp;
memset( &sp, 0, sizeof( sp ) ); memset( &sp, 0, sizeof( sp ) );
@ -914,7 +913,7 @@ void thread_mutex_init( thread_mutex_t* mutex )
InitializeCriticalSectionAndSpinCount( (CRITICAL_SECTION*) mutex, 32 ); 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 // Compile-time size check
struct x { char thread_mutex_type_too_small : ( sizeof( thread_mutex_t ) < sizeof( pthread_mutex_t ) ? 0 : 1 ); }; 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 ); 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 ); pthread_mutex_destroy( (pthread_mutex_t*) mutex );
@ -949,7 +948,7 @@ void thread_mutex_lock( thread_mutex_t* mutex )
EnterCriticalSection( (CRITICAL_SECTION*) 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 ); pthread_mutex_lock( (pthread_mutex_t*) mutex );
@ -965,7 +964,7 @@ void thread_mutex_unlock( thread_mutex_t* mutex )
LeaveCriticalSection( (CRITICAL_SECTION*) 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 ); pthread_mutex_unlock( (pthread_mutex_t*) mutex );
@ -987,7 +986,7 @@ struct thread_internal_signal_t
HANDLE event; HANDLE event;
#endif #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_mutex_t mutex;
pthread_cond_t condition; pthread_cond_t condition;
@ -1019,7 +1018,7 @@ void thread_signal_init( thread_signal_t* signal )
internal->event = CreateEvent( NULL, FALSE, FALSE, NULL ); internal->event = CreateEvent( NULL, FALSE, FALSE, NULL );
#endif #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_mutex_init( &internal->mutex, NULL );
pthread_cond_init( &internal->condition, NULL ); pthread_cond_init( &internal->condition, NULL );
@ -1043,7 +1042,7 @@ void thread_signal_init( thread_signal_t* signal )
CloseHandle( internal->event ); CloseHandle( internal->event );
#endif #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_mutex_destroy( &internal->mutex );
pthread_cond_destroy( &internal->condition ); pthread_cond_destroy( &internal->condition );
@ -1069,7 +1068,7 @@ void thread_signal_raise( thread_signal_t* signal )
SetEvent( internal->event ); SetEvent( internal->event );
#endif #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 ); pthread_mutex_lock( &internal->mutex );
internal->value = 1; internal->value = 1;
@ -1104,7 +1103,7 @@ int thread_signal_wait( thread_signal_t* signal, int timeout_ms )
return !failed; return !failed;
#endif #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; struct timespec ts;
if( timeout_ms >= 0 ) if( timeout_ms >= 0 )
@ -1148,7 +1147,7 @@ int thread_atomic_int_load( thread_atomic_int_t* atomic )
return InterlockedCompareExchange( &atomic->i, 0, 0 ); 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 ); 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 ); 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_and( &atomic->i, 0 );
__sync_fetch_and_or( &atomic->i, desired ); __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; 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 ); 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; 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 ); 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 ); 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 ); 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 ); 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 ); 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 ); 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 ); int old = (int)__sync_lock_test_and_set( &atomic->i, desired );
__sync_lock_release( &atomic->i ); __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 ); 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 ); 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 ); 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 ); 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 ) #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_test_and_set( &atomic->ptr, desired );
__sync_lock_release( &atomic->ptr ); __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 ); return InterlockedExchangePointer( &atomic->ptr, desired );
#pragma warning( pop ) #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 ); void* old = __sync_lock_test_and_set( &atomic->ptr, desired );
__sync_lock_release( &atomic->ptr ); __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 ); 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 ); 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 ); *(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 // Nothing
@ -1388,7 +1387,7 @@ void thread_timer_term( thread_timer_t* timer )
if( timeGetDevCaps( &tc, sizeof( TIMECAPS ) ) == TIMERR_NOERROR ) if( timeGetDevCaps( &tc, sizeof( TIMECAPS ) ) == TIMERR_NOERROR )
timeEndPeriod( tc.wPeriodMin ); 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 // Nothing
@ -1408,7 +1407,7 @@ void thread_timer_wait( thread_timer_t* timer, THREAD_U64 nanoseconds )
(void) b; (void) b;
WaitForSingleObject( *(HANDLE*)timer, INFINITE ); 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 rem;
struct timespec req; struct timespec req;
@ -1433,7 +1432,7 @@ thread_tls_t thread_tls_create( void )
else else
return (thread_tls_t) (uintptr_t) tls; 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; pthread_key_t tls;
if( pthread_key_create( &tls, NULL ) == 0 ) if( pthread_key_create( &tls, NULL ) == 0 )
@ -1453,7 +1452,7 @@ void thread_tls_destroy( thread_tls_t tls )
TlsFree( (DWORD) (uintptr_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 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 ); 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 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 ); 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 return pthread_getspecific( (pthread_key_t) (uintptr_t) tls ); //< @r-lyeh: uintptr_t

View File

@ -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) { void network_rpc_send_to(int64_t rank, unsigned id, const char *cmdline) {
assert(network_get(NETWORK_RANK) == 0); /* must be a host */ 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[0] = MSG_RPC;
*(uint32_t*)&msg[4] = id; *(uint32_t*)&msg[4] = id;
memcpy(&msg[8], cmdline, sz-8);
server_send_bin(rank, msg, sz); server_send_bin(rank, msg, sz);
FREE(msg);
} }
void network_rpc_send(unsigned id, const char *cmdline) { 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[0] = MSG_RPC;
*(uint32_t*)&msg[4] = id; *(uint32_t*)&msg[4] = id;
memcpy(&msg[8], cmdline, sz-8);
server_broadcast_bin(msg, sz); server_broadcast_bin(msg, sz);
FREE(msg);
} }

View File

@ -596,7 +596,7 @@ details > summary::-webkit-details-marker {
|Version: | 2023.7 | |Version: | 2023.7 |
|:--------------|:------------| |:--------------|:------------|
|Branch: | main | |Branch: | main |
|Commit: | 9 | |Commit: | 13 |
<!--| Documentation last modified | { {LAST_MODIFIED} } |--> <!--| Documentation last modified | { {LAST_MODIFIED} } |-->
# [V·4·K 2023.7 ](https://dev.v4.games/zaklaus/v4k) # [V·4·K 2023.7 ](https://dev.v4.games/zaklaus/v4k)