Merge remote-tracking branch 'fwk/main'

main
Dominik Madarász 2023-08-10 21:20:34 +02:00
commit 6fe631b5d5
7 changed files with 51 additions and 170 deletions

View File

@ -15,16 +15,18 @@ popd
## cook art
if [ "$(uname)" = "Darwin" ]; then
chmod +x ../../../tools/cook.osx
../../../tools/cook.osx
chmod +x ../../tools/cook.osx
../../tools/cook.osx --cook-jobs=1 --cook-ini=../../tools/cook.ini
cp .art[00].zip index.data
else
chmod +x ../../../tools/cook.linux
../../../tools/cook.linux
chmod +x ../../tools/cook.linux
../../tools/cook.linux --cook-jobs=1 --cook-ini=../../tools/cook.ini
cp .art[00].zip index.data
fi
## host webserver, compile and launch
python -m http.server --bind 127.0.0.1 8000 1> /dev/null 2> /dev/null &
emcc $@ -g ../../../code/v4k.c -I../../../code -o index.html -s FULL_ES3 -s USE_GLFW=3 -s SINGLE_FILE=1 -s PRECISE_F32=1 -s TOTAL_MEMORY=256mb -s ENVIRONMENT=worker,web --shell-file template.html -Wfatal-errors --preload-file .art[00].zip -s ALLOW_MEMORY_GROWTH=1 -lidbfs.js && xdg-open http://localhost:8000/index.html
emcc $@ -g ../../engine/v4k.c -I../../engine -o index.html -s FULL_ES3 -s USE_PTHREADS -s USE_GLFW=3 -s SINGLE_FILE=1 -s PRECISE_F32=1 -s TOTAL_MEMORY=256mb -s ENVIRONMENT=worker,web --shell-file template.html -Wfatal-errors --preload-file .art[00].zip -s ALLOW_MEMORY_GROWTH=1 -lidbfs.js && xdg-open http://localhost:8000/index.html
exit

View File

@ -8,6 +8,7 @@
- [x] No input (fixed)
- [x] No gamepads (fixed)
- [x] No multi-touch (fixed)
- [x] No threads (fixed)
- [ ] No audio
- [ ] No file writing (untested)
- [ ] No glTexture1D()

View File

@ -1,118 +0,0 @@
/*! coi-serviceworker v0.1.7 - Guido Zuidhof and contributors, licensed under MIT */
let coepCredentialless = false;
if (typeof window === 'undefined') {
self.addEventListener("install", () => self.skipWaiting());
self.addEventListener("activate", (event) => event.waitUntil(self.clients.claim()));
self.addEventListener("message", (ev) => {
if (!ev.data) {
return;
} else if (ev.data.type === "deregister") {
self.registration
.unregister()
.then(() => {
return self.clients.matchAll();
})
.then(clients => {
clients.forEach((client) => client.navigate(client.url));
});
} else if (ev.data.type === "coepCredentialless") {
coepCredentialless = ev.data.value;
}
});
self.addEventListener("fetch", function (event) {
const r = event.request;
if (r.cache === "only-if-cached" && r.mode !== "same-origin") {
return;
}
const request = (coepCredentialless && r.mode === "no-cors")
? new Request(r, {
credentials: "omit",
})
: r;
event.respondWith(
fetch(request)
.then((response) => {
if (response.status === 0) {
return response;
}
const newHeaders = new Headers(response.headers);
newHeaders.set("Cross-Origin-Embedder-Policy",
coepCredentialless ? "credentialless" : "require-corp"
);
if (!coepCredentialless) {
newHeaders.set("Cross-Origin-Resource-Policy", "cross-origin");
}
newHeaders.set("Cross-Origin-Opener-Policy", "same-origin");
return new Response(response.body, {
status: response.status,
statusText: response.statusText,
headers: newHeaders,
});
})
.catch((e) => console.error(e))
);
});
} else {
(() => {
// You can customize the behavior of this script through a global `coi` variable.
const coi = {
shouldRegister: () => true,
shouldDeregister: () => false,
coepCredentialless: () => (window.chrome !== undefined || window.netscape !== undefined),
doReload: () => window.location.reload(),
quiet: false,
...window.coi
};
const n = navigator;
if (n.serviceWorker && n.serviceWorker.controller) {
n.serviceWorker.controller.postMessage({
type: "coepCredentialless",
value: coi.coepCredentialless(),
});
if (coi.shouldDeregister()) {
n.serviceWorker.controller.postMessage({ type: "deregister" });
}
}
// If we're already coi: do nothing. Perhaps it's due to this script doing its job, or COOP/COEP are
// already set from the origin server. Also if the browser has no notion of crossOriginIsolated, just give up here.
if (window.crossOriginIsolated !== false || !coi.shouldRegister()) return;
if (!window.isSecureContext) {
!coi.quiet && console.log("COOP/COEP Service Worker not registered, a secure context is required.");
return;
}
// In some environments (e.g. Chrome incognito mode) this won't be available
if (n.serviceWorker) {
n.serviceWorker.register(window.document.currentScript.src).then(
(registration) => {
!coi.quiet && console.log("COOP/COEP Service Worker registered", registration.scope);
registration.addEventListener("updatefound", () => {
!coi.quiet && console.log("Reloading page to make use of updated COOP/COEP Service Worker.");
coi.doReload();
});
// If the registration is active, but it's not controlling the page
if (registration.active && !n.serviceWorker.controller) {
!coi.quiet && console.log("Reloading page to make use of COOP/COEP Service Worker.");
coi.doReload();
}
},
(err) => {
!coi.quiet && console.error("COOP/COEP Service Worker failed to register:", err);
}
);
}
})();
}

View File

@ -136,6 +136,7 @@
}
}
</script>
<script src="coi-serviceworker.min.js"></script>
<script src="index.worker.coi.min.js"></script>
</body>
</html>

View File

@ -713,7 +713,8 @@ struct thread_queue_t
} THREADNAME_INFO;
#pragma pack(pop)
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
#ifndef _GNU_SOURCE
#define _GNU_SOURCE //< @r-lyeh: pthread_setname_np()
#endif
@ -737,7 +738,7 @@ thread_id_t thread_current_thread_id( void )
return (void*) (uintptr_t)GetCurrentThreadId();
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
return (void*) pthread_self();
@ -753,7 +754,7 @@ void thread_yield( void )
SwitchToThread();
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
sched_yield();
@ -769,7 +770,7 @@ void thread_exit( int return_code )
ExitThread( (DWORD) return_code );
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
pthread_exit( (void*)(uintptr_t) return_code );
@ -810,13 +811,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || 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__ ) && !defined( EMSCRIPTEN ) // max doesn't support pthread_setname_np. alternatives? //< @r-lyeh, ems
#if !defined( __APPLE__ ) && !defined( __EMSCRIPTEN__ ) // max doesn't support pthread_setname_np. alternatives? //< @r-lyeh, ems
if( name ) pthread_setname_np( thread, name );
#endif
@ -835,7 +836,7 @@ void thread_term( thread_ptr_t thread )
WaitForSingleObject( (HANDLE) thread, INFINITE );
CloseHandle( (HANDLE) thread );
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
pthread_join( (pthread_t) thread, NULL );
@ -854,7 +855,7 @@ int thread_join( thread_ptr_t thread )
GetExitCodeThread( (HANDLE) thread, &retval );
return (int) retval;
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
void* retval;
pthread_join( (pthread_t) thread, &retval );
@ -872,7 +873,7 @@ int thread_detach( thread_ptr_t thread )
return CloseHandle( (HANDLE) thread ) != 0;
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN )
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
return pthread_detach( (pthread_t) thread ) == 0;
@ -888,7 +889,7 @@ void thread_set_high_priority( void )
SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_HIGHEST );
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
struct sched_param sp;
memset( &sp, 0, sizeof( sp ) );
@ -913,7 +914,7 @@ void thread_mutex_init( thread_mutex_t* mutex )
InitializeCriticalSectionAndSpinCount( (CRITICAL_SECTION*) mutex, 32 );
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || 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 ); };
@ -932,7 +933,7 @@ void thread_mutex_term( thread_mutex_t* mutex )
DeleteCriticalSection( (CRITICAL_SECTION*) mutex );
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
pthread_mutex_destroy( (pthread_mutex_t*) mutex );
@ -948,7 +949,7 @@ void thread_mutex_lock( thread_mutex_t* mutex )
EnterCriticalSection( (CRITICAL_SECTION*) mutex );
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
pthread_mutex_lock( (pthread_mutex_t*) mutex );
@ -964,7 +965,7 @@ void thread_mutex_unlock( thread_mutex_t* mutex )
LeaveCriticalSection( (CRITICAL_SECTION*) mutex );
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
pthread_mutex_unlock( (pthread_mutex_t*) mutex );
@ -986,7 +987,7 @@ struct thread_internal_signal_t
HANDLE event;
#endif
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
pthread_mutex_t mutex;
pthread_cond_t condition;
@ -1018,7 +1019,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
pthread_mutex_init( &internal->mutex, NULL );
pthread_cond_init( &internal->condition, NULL );
@ -1042,7 +1043,7 @@ void thread_signal_init( thread_signal_t* signal )
CloseHandle( internal->event );
#endif
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
pthread_mutex_destroy( &internal->mutex );
pthread_cond_destroy( &internal->condition );
@ -1068,7 +1069,7 @@ void thread_signal_raise( thread_signal_t* signal )
SetEvent( internal->event );
#endif
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
pthread_mutex_lock( &internal->mutex );
internal->value = 1;
@ -1103,7 +1104,7 @@ int thread_signal_wait( thread_signal_t* signal, int timeout_ms )
return !failed;
#endif
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
struct timespec ts;
if( timeout_ms >= 0 )
@ -1147,7 +1148,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
return (int)__sync_fetch_and_add( &atomic->i, 0 );
@ -1163,7 +1164,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
__sync_fetch_and_and( &atomic->i, 0 );
__sync_fetch_and_or( &atomic->i, desired );
@ -1180,7 +1181,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
return (int)__sync_fetch_and_add( &atomic->i, 1 );
@ -1196,7 +1197,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
return (int)__sync_fetch_and_sub( &atomic->i, 1 );
@ -1212,7 +1213,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
return (int)__sync_fetch_and_add( &atomic->i, value );
@ -1228,7 +1229,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
return (int)__sync_fetch_and_sub( &atomic->i, value );
@ -1244,7 +1245,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
int old = (int)__sync_lock_test_and_set( &atomic->i, desired );
__sync_lock_release( &atomic->i );
@ -1262,7 +1263,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
return (int)__sync_val_compare_and_swap( &atomic->i, expected, desired );
@ -1278,7 +1279,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
return __sync_fetch_and_add( &atomic->ptr, 0 );
@ -1300,7 +1301,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
__sync_lock_test_and_set( &atomic->ptr, desired );
__sync_lock_release( &atomic->ptr );
@ -1322,7 +1323,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
void* old = __sync_lock_test_and_set( &atomic->ptr, desired );
__sync_lock_release( &atomic->ptr );
@ -1340,7 +1341,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
return __sync_val_compare_and_swap( &atomic->ptr, expected, desired );
@ -1367,7 +1368,7 @@ void thread_timer_init( thread_timer_t* timer )
*(HANDLE*)timer = CreateWaitableTimer( NULL, TRUE, NULL );
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
// Nothing
@ -1387,7 +1388,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
// Nothing
@ -1407,7 +1408,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
struct timespec rem;
struct timespec req;
@ -1432,7 +1433,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
pthread_key_t tls;
if( pthread_key_create( &tls, NULL ) == 0 )
@ -1452,7 +1453,7 @@ void thread_tls_destroy( thread_tls_t tls )
TlsFree( (DWORD) (uintptr_t) tls );
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
pthread_key_delete( (pthread_key_t) (uintptr_t) tls ); //< @r-lyeh: uintptr_t
@ -1468,7 +1469,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
pthread_setspecific( (pthread_key_t) (uintptr_t) tls, value ); //< @r-lyeh: uintptr_t
@ -1484,7 +1485,7 @@ void* thread_tls_get( thread_tls_t tls )
return TlsGetValue( (DWORD) (uintptr_t) tls );
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems
#elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
return pthread_getspecific( (pthread_key_t) (uintptr_t) tls ); //< @r-lyeh: uintptr_t

View File

@ -639,21 +639,15 @@ 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 */
unsigned sz = strlen(cmdline) + 8;
char *msg = MALLOC(sz);
char *msg = va("%*.s%s", 8, "", cmdline);
*(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) {
unsigned sz = strlen(cmdline) + 8;
char *msg = MALLOC(sz);
char *msg = va("%*.s%s", 8, "", cmdline);
*(uint32_t*)&msg[0] = MSG_RPC;
*(uint32_t*)&msg[4] = id;
memcpy(&msg[8], cmdline, sz-8);
server_broadcast_bin(msg, sz);
FREE(msg);
}