upstream files

main
Dominik Madarász 2023-08-11 21:59:48 +02:00
parent cb37e1e9f4
commit 1a1683aa29
9 changed files with 215 additions and 111 deletions

View File

@ -0,0 +1,19 @@
uniform int thickness = 2;
uniform vec4 border_color = vec4(1,1,0,1);
void main() {
vec4 texel = texture(iChannel0, uv);
float outline = 0.0;
if( texel.a == 0.0 ) {
for( int x = -thickness; x <= thickness; x++ ) {
for( int y = -thickness;y <= thickness; y++ ) {
float sample = texture(iChannel0, uv+vec2(float(x)/iWidth, float(y)/iHeight)).a;
if( sample > 0.0 ) {
outline = 1.0;
}
}
}
}
FRAGCOLOR = vec4(border_color.rgb, outline * border_color.a); // mix(texel, border_color, outline * border_color.a);
}

View File

@ -915,6 +915,18 @@ ffi.cdef([[
//lcpp INF [0000] vec3: macro name but used as C declaration in:struct { map base; struct { pair p; vec3* key; boid_t** val; } tmp, *ptr; boid_t*** tmpval; int (*typed_cmp)(vec3*, vec3*); uint64_t (*typed_hash)(vec3*); } * voxel_cache_; //lcpp INF [0000] vec3: macro name but used as C declaration in:struct { map base; struct { pair p; vec3* key; boid_t** val; } tmp, *ptr; boid_t*** tmpval; int (*typed_cmp)(vec3*, vec3*); uint64_t (*typed_hash)(vec3*); } * voxel_cache_;
//lcpp INF [0000] vec3: macro name but used as C declaration in:struct { map base; struct { pair p; vec3* key; boid_t** val; } tmp, *ptr; boid_t*** tmpval; int (*typed_cmp)(vec3*, vec3*); uint64_t (*typed_hash)(vec3*); } * voxel_cache_; //lcpp INF [0000] vec3: macro name but used as C declaration in:struct { map base; struct { pair p; vec3* key; boid_t** val; } tmp, *ptr; boid_t*** tmpval; int (*typed_cmp)(vec3*, vec3*); uint64_t (*typed_hash)(vec3*); } * voxel_cache_;
//lcpp INF [0000] vec3: macro name but used as C declaration in:struct { map base; struct { pair p; vec3* key; boid_t** val; } tmp, *ptr; boid_t*** tmpval; int (*typed_cmp)(vec3*, vec3*); uint64_t (*typed_hash)(vec3*); } * voxel_cache_; //lcpp INF [0000] vec3: macro name but used as C declaration in:struct { map base; struct { pair p; vec3* key; boid_t** val; } tmp, *ptr; boid_t*** tmpval; int (*typed_cmp)(vec3*, vec3*); uint64_t (*typed_hash)(vec3*); } * voxel_cache_;
//lcpp INF [0000] map: macro name but used as C declaration in:API int pathfind_astar(int width, int height, const unsigned* map, vec2i src, vec2i dst, vec2i* path, size_t maxpath);
//lcpp INF [0000] vec2i: macro name but used as C declaration in:API int pathfind_astar(int width, int height, const unsigned* map, vec2i src, vec2i dst, vec2i* path, size_t maxpath);
//lcpp INF [0000] vec2i: macro name but used as C declaration in:API int pathfind_astar(int width, int height, const unsigned* map, vec2i src, vec2i dst, vec2i* path, size_t maxpath);
//lcpp INF [0000] vec2i: macro name but used as C declaration in:API int pathfind_astar(int width, int height, const unsigned* map, vec2i src, vec2i dst, vec2i* path, size_t maxpath);
//lcpp INF [0000] map: macro name but used as C declaration in:STATIC int pathfind_astar(int width, int height, const unsigned* map, vec2i src, vec2i dst, vec2i* path, size_t maxpath);
//lcpp INF [0000] vec2i: macro name but used as C declaration in:STATIC int pathfind_astar(int width, int height, const unsigned* map, vec2i src, vec2i dst, vec2i* path, size_t maxpath);
//lcpp INF [0000] vec2i: macro name but used as C declaration in:STATIC int pathfind_astar(int width, int height, const unsigned* map, vec2i src, vec2i dst, vec2i* path, size_t maxpath);
//lcpp INF [0000] vec2i: macro name but used as C declaration in:STATIC int pathfind_astar(int width, int height, const unsigned* map, vec2i src, vec2i dst, vec2i* path, size_t maxpath);
//lcpp INF [0000] map: macro name but used as C declaration in: int pathfind_astar(int width, int height, const unsigned* map, vec2i src, vec2i dst, vec2i* path, size_t maxpath);
//lcpp INF [0000] vec2i: macro name but used as C declaration in: int pathfind_astar(int width, int height, const unsigned* map, vec2i src, vec2i dst, vec2i* path, size_t maxpath);
//lcpp INF [0000] vec2i: macro name but used as C declaration in: int pathfind_astar(int width, int height, const unsigned* map, vec2i src, vec2i dst, vec2i* path, size_t maxpath);
//lcpp INF [0000] vec2i: macro name but used as C declaration in: int pathfind_astar(int width, int height, const unsigned* map, vec2i src, vec2i dst, vec2i* path, size_t maxpath);
//lcpp INF [0000] vec3: macro name but used as C declaration in:vec3 a; //lcpp INF [0000] vec3: macro name but used as C declaration in:vec3 a;
//lcpp INF [0000] vec3: macro name but used as C declaration in:vec3 b; //lcpp INF [0000] vec3: macro name but used as C declaration in:vec3 b;
//lcpp INF [0000] vec3: macro name but used as C declaration in:vec3 a; //lcpp INF [0000] vec3: macro name but used as C declaration in:vec3 a;
@ -1716,6 +1728,7 @@ float blindspot_angledeg_compare_value_;
void swarm_update_acceleration_only(swarm_t *self); void swarm_update_acceleration_only(swarm_t *self);
void swarm_update_acceleration_and_velocity_only(swarm_t *self, float delta); void swarm_update_acceleration_and_velocity_only(swarm_t *self, float delta);
int ui_swarm(swarm_t *self); int ui_swarm(swarm_t *self);
int pathfind_astar(int width, int height, const unsigned* map, vec2i src, vec2i dst, vec2i* path, size_t maxpath);
void midi_send(unsigned midi_msg); void midi_send(unsigned midi_msg);
typedef struct audio_handle* audio_t; typedef struct audio_handle* audio_t;
audio_t audio_clip( const char *pathfile ); audio_t audio_clip( const char *pathfile );
@ -2618,6 +2631,7 @@ int u_coefficients_sh;
void tty_color(unsigned color); void tty_color(unsigned color);
void tty_reset(); void tty_reset();
void tty_attach(); void tty_attach();
void tty_detach();
const char* app_exec(const char *command); const char* app_exec(const char *command);
int app_cores(); int app_cores();
int app_battery(); int app_battery();

View File

@ -15131,6 +15131,10 @@ API void swarm_update_acceleration_only(swarm_t *self); // acc
API void swarm_update_acceleration_and_velocity_only(swarm_t *self, float delta); // acc,vel API void swarm_update_acceleration_and_velocity_only(swarm_t *self, float delta); // acc,vel
API int ui_swarm(swarm_t *self); API int ui_swarm(swarm_t *self);
// pathfinding -----------------------------------------------------------------
API int pathfind_astar(int width, int height, const unsigned* map, vec2i src, vec2i dst, vec2i* path, size_t maxpath);
#line 0 #line 0
#line 1 "v4k_audio.h" #line 1 "v4k_audio.h"
@ -16925,6 +16929,7 @@ API float optionf(const char *commalist, float defaults); // app_option?
API void tty_color(unsigned color); API void tty_color(unsigned color);
API void tty_reset(); API void tty_reset();
API void tty_attach(); API void tty_attach();
API void tty_detach();
API const char* app_exec(const char *command); // returns ("%15d %s", retcode, output_last_line) API const char* app_exec(const char *command); // returns ("%15d %s", retcode, output_last_line)
API int app_cores(); API int app_cores();
@ -252494,7 +252499,8 @@ struct thread_queue_t
} THREADNAME_INFO; } THREADNAME_INFO;
#pragma pack(pop) #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 #ifndef _GNU_SOURCE
#define _GNU_SOURCE //< @r-lyeh: pthread_setname_np() #define _GNU_SOURCE //< @r-lyeh: pthread_setname_np()
#endif #endif
@ -252518,7 +252524,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems #elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
return (void*) pthread_self(); return (void*) pthread_self();
@ -252534,7 +252540,7 @@ void thread_yield( void )
SwitchToThread(); 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(); sched_yield();
@ -252550,7 +252556,7 @@ void thread_exit( int return_code )
ExitThread( (DWORD) 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 ); pthread_exit( (void*)(uintptr_t) return_code );
@ -252591,13 +252597,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems #elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || 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__ ) && !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 ); if( name ) pthread_setname_np( thread, name );
#endif #endif
@ -252616,7 +252622,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems #elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
pthread_join( (pthread_t) thread, NULL ); pthread_join( (pthread_t) thread, NULL );
@ -252635,7 +252641,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems #elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
void* retval; void* retval;
pthread_join( (pthread_t) thread, &retval ); pthread_join( (pthread_t) thread, &retval );
@ -252653,7 +252659,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__ ) || defined( EMSCRIPTEN ) #elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
return pthread_detach( (pthread_t) thread ) == 0; return pthread_detach( (pthread_t) thread ) == 0;
@ -252669,7 +252675,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems #elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
struct sched_param sp; struct sched_param sp;
memset( &sp, 0, sizeof( sp ) ); memset( &sp, 0, sizeof( sp ) );
@ -252694,7 +252700,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems #elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || 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 ); };
@ -252713,7 +252719,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems #elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
pthread_mutex_destroy( (pthread_mutex_t*) mutex ); pthread_mutex_destroy( (pthread_mutex_t*) mutex );
@ -252729,7 +252735,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems #elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
pthread_mutex_lock( (pthread_mutex_t*) mutex ); pthread_mutex_lock( (pthread_mutex_t*) mutex );
@ -252745,7 +252751,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems #elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
pthread_mutex_unlock( (pthread_mutex_t*) mutex ); pthread_mutex_unlock( (pthread_mutex_t*) mutex );
@ -252767,7 +252773,7 @@ struct thread_internal_signal_t
HANDLE event; HANDLE event;
#endif #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_mutex_t mutex;
pthread_cond_t condition; pthread_cond_t condition;
@ -252799,7 +252805,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems #elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || 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 );
@ -252823,7 +252829,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems #elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || 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 );
@ -252849,7 +252855,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems #elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
pthread_mutex_lock( &internal->mutex ); pthread_mutex_lock( &internal->mutex );
internal->value = 1; internal->value = 1;
@ -252884,7 +252890,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems #elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
struct timespec ts; struct timespec ts;
if( timeout_ms >= 0 ) if( timeout_ms >= 0 )
@ -252928,7 +252934,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__ ) || 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 ); return (int)__sync_fetch_and_add( &atomic->i, 0 );
@ -252944,7 +252950,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__ ) || 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_and( &atomic->i, 0 );
__sync_fetch_and_or( &atomic->i, desired ); __sync_fetch_and_or( &atomic->i, desired );
@ -252961,7 +252967,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__ ) || 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 ); return (int)__sync_fetch_and_add( &atomic->i, 1 );
@ -252977,7 +252983,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__ ) || 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 ); return (int)__sync_fetch_and_sub( &atomic->i, 1 );
@ -252993,7 +252999,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__ ) || 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 ); return (int)__sync_fetch_and_add( &atomic->i, value );
@ -253009,7 +253015,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__ ) || 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 ); return (int)__sync_fetch_and_sub( &atomic->i, value );
@ -253025,7 +253031,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__ ) || 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 ); int old = (int)__sync_lock_test_and_set( &atomic->i, desired );
__sync_lock_release( &atomic->i ); __sync_lock_release( &atomic->i );
@ -253043,7 +253049,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__ ) || 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 ); return (int)__sync_val_compare_and_swap( &atomic->i, expected, desired );
@ -253059,7 +253065,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__ ) || 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 ); return __sync_fetch_and_add( &atomic->ptr, 0 );
@ -253081,7 +253087,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__ ) || 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_test_and_set( &atomic->ptr, desired );
__sync_lock_release( &atomic->ptr ); __sync_lock_release( &atomic->ptr );
@ -253103,7 +253109,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__ ) || 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 ); void* old = __sync_lock_test_and_set( &atomic->ptr, desired );
__sync_lock_release( &atomic->ptr ); __sync_lock_release( &atomic->ptr );
@ -253121,7 +253127,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__ ) || 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 ); return __sync_val_compare_and_swap( &atomic->ptr, expected, desired );
@ -253148,7 +253154,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems #elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
// Nothing // Nothing
@ -253168,7 +253174,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems #elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
// Nothing // Nothing
@ -253188,7 +253194,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems #elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
struct timespec rem; struct timespec rem;
struct timespec req; struct timespec req;
@ -253213,7 +253219,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems #elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || 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 )
@ -253233,7 +253239,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__ ) || 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 pthread_key_delete( (pthread_key_t) (uintptr_t) tls ); //< @r-lyeh: uintptr_t
@ -253249,7 +253255,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__ ) || 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 pthread_setspecific( (pthread_key_t) (uintptr_t) tls, value ); //< @r-lyeh: uintptr_t
@ -253265,7 +253271,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__ ) || 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 return pthread_getspecific( (pthread_key_t) (uintptr_t) tls ); //< @r-lyeh: uintptr_t
@ -293614,7 +293620,7 @@ int tls_remote_error(struct TLSContext *context);
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
*/ */
/******************************************************************************** /********************************************************************************
Copyright (c) 2016-2021, Eduard Suica Copyright (c) 2016-2023, Eduard Suica
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, Redistribution and use in source and binary forms, with or without modification,
@ -293724,13 +293730,13 @@ int tls_remote_error(struct TLSContext *context);
// #endif // #endif
#ifndef TLS_MALLOC #ifndef TLS_MALLOC
#define TLS_MALLOC(size) malloc(size) #define TLS_MALLOC MALLOC //< @r-lyeh
#endif #endif
#ifndef TLS_REALLOC #ifndef TLS_REALLOC
#define TLS_REALLOC(ptr, size) realloc(ptr, size) #define TLS_REALLOC REALLOC //< @r-lyeh
#endif #endif
#ifndef TLS_FREE #ifndef TLS_FREE
#define TLS_FREE(ptr) if (ptr) free(ptr) #define TLS_FREE FREE //< @r-lyeh
#endif #endif
#define TLS_ERROR(err, statement) if (err) statement; #define TLS_ERROR(err, statement) if (err) statement;
@ -301040,7 +301046,7 @@ int tls_parse_verify_tls13(struct TLSContext *context, const unsigned char *buf,
unsigned short signature = ntohs(*(unsigned short *)&buf[3]); unsigned short signature = ntohs(*(unsigned short *)&buf[3]);
unsigned short signature_size = ntohs(*(unsigned short *)&buf[5]); unsigned short signature_size = ntohs(*(unsigned short *)&buf[5]);
int valid = 0; int valid = 0;
CHECK_SIZE(7 + size, buf_len, TLS_NEED_MORE_DATA) CHECK_SIZE(7 + signature_size, buf_len, TLS_NEED_MORE_DATA)
switch (signature) { switch (signature) {
#ifdef TLS_ECDSA_SUPPORTED #ifdef TLS_ECDSA_SUPPORTED
case 0x0403: case 0x0403:
@ -304769,15 +304775,14 @@ https_status_t https_process( https_t* https )
#pragma warning( disable: 4548 ) // expression before comma has no effect; expected expression with side-effect #pragma warning( disable: 4548 ) // expression before comma has no effect; expected expression with side-effect
FD_SET( internal->socket, &sockets_to_check ); FD_SET( internal->socket, &sockets_to_check );
#pragma warning( pop ) #pragma warning( pop )
struct timeval timeout; timeout.tv_sec = 0; timeout.tv_usec = 0;
int buflen = 65536 * 1024;//< @r-lyeh heap allocated buffer struct timeval timeout;
static __thread char *buffer = 0; //< @r-lyeh heap allocated buffer while( (timeout.tv_sec = 1, timeout.tv_usec = 0), select( (int)( internal->socket + 1 ), &sockets_to_check, NULL, NULL, &timeout ) == 1 )
if(!buffer) memset(buffer = (char*)HTTPS_MALLOC(internal->memctx, buflen), 0, buflen); //< @r-lyeh heap allocated buffer
while( select( (int)( internal->socket + 1 ), &sockets_to_check, NULL, NULL, &timeout ) == 1 )
{ {
enum { buflen = 4 * 1024 };
char buffer[ buflen ];
int size = recv( internal->socket, buffer, buflen, 0 ); int size = recv( internal->socket, buffer, buflen, 0 );
if( size == -1 ) if( size == -1 )
{ {
@ -304785,8 +304790,9 @@ https_status_t https_process( https_t* https )
return https->status; return https->status;
} }
#if is(tcc) && is(64) #if is(tcc) && is(win32)
// hexdump(buffer, size); //< @r-lyeh // hexdump(buffer, size); //< @r-lyeh
// printf(">+=%d,%d/%d\n", size,internal->data_size,internal->data_capacity);
#endif #endif
tls_consume_stream( internal->tls_context, (unsigned char*) buffer, size, 0 ); tls_consume_stream( internal->tls_context, (unsigned char*) buffer, size, 0 );
@ -304825,7 +304831,6 @@ https_status_t https_process( https_t* https )
else if( size == 0 ) else if( size == 0 )
{ {
char const* status_line = (char const*) internal->data; char const* status_line = (char const*) internal->data;
int header_size = 0; int header_size = 0;
char const* header_end = strstr( status_line, "\r\n\r\n" ); char const* header_end = strstr( status_line, "\r\n\r\n" );
if( header_end ) if( header_end )
@ -330394,7 +330399,7 @@ int audio_queue( const void *samples, int num_samples, int flags ) {
if( audio_queue_voice < 0 ) return 0; if( audio_queue_voice < 0 ) return 0;
} }
audio_queue_t *aq = MALLOC(sizeof(audio_queue_t) + bytes << (channels == 1)); // dupe space if going to be converted from mono to stereo audio_queue_t *aq = MALLOC(sizeof(audio_queue_t) + (bytes << (channels == 1))); // dupe space if going to be converted from mono to stereo
aq->cursor = 0; aq->cursor = 0;
aq->avail = bytes; aq->avail = bytes;
aq->flags = flags; aq->flags = flags;
@ -342122,6 +342127,21 @@ mesh_t mesh() {
return z; return z;
} }
aabb mesh_bounds(mesh_t *m) {
aabb b = {{1e9,1e9,1e9},{-1e9,-1e9,-1e9}};
for( int i = 0; i < array_count(m->in_vertex3); ++i ) {
if( m->in_vertex3[i].x < b.min.x ) b.min.x = m->in_vertex3[i].x;
if( m->in_vertex3[i].x > b.max.x ) b.max.x = m->in_vertex3[i].x;
if( m->in_vertex3[i].y < b.min.y ) b.min.y = m->in_vertex3[i].y;
if( m->in_vertex3[i].y > b.max.y ) b.max.y = m->in_vertex3[i].y;
if( m->in_vertex3[i].z < b.min.z ) b.min.z = m->in_vertex3[i].z;
if( m->in_vertex3[i].z > b.max.z ) b.max.z = m->in_vertex3[i].z;
}
return b;
}
void mesh_update(mesh_t *m, const char *format, int vertex_stride,int vertex_count,const void *vertex_data, int index_count,const void *index_data, int flags) { void mesh_update(mesh_t *m, const char *format, int vertex_stride,int vertex_count,const void *vertex_data, int index_count,const void *index_data, int flags) {
m->flags = flags; m->flags = flags;
@ -346254,6 +346274,9 @@ int tty_cols() {
#endif #endif
return 80; return 80;
} }
void tty_detach() {
ifdef(win32, FreeConsole());
}
void tty_attach() { void tty_attach() {
#if is(win32) #if is(win32)
// in order to have a Windows gui application with console: // in order to have a Windows gui application with console:
@ -348838,6 +348861,9 @@ void (profile_render)() {
if( has_menu ? ui_window("Profiler", 0) : ui_panel("Profiler", 0) ) { if( has_menu ? ui_window("Profiler", 0) : ui_panel("Profiler", 0) ) {
double fps = window_fps();
profile_setstat("Render.num_fps", fps);
if(1) { // @todo: ui_plot() if(1) { // @todo: ui_plot()
// draw fps-meter: 300 samples, [0..70] range each, 70px height plot. // draw fps-meter: 300 samples, [0..70] range each, 70px height plot.
nk_layout_row_dynamic(ui_ctx, 70, 1); nk_layout_row_dynamic(ui_ctx, 70, 1);
@ -348845,7 +348871,7 @@ void (profile_render)() {
enum { COUNT = 300 }; enum { COUNT = 300 };
static float values[COUNT] = {0}; static int offset = 0; static float values[COUNT] = {0}; static int offset = 0;
values[offset=(offset+1)%COUNT] = window_fps(); values[offset=(offset+1)%COUNT] = fps;
int index = -1; int index = -1;
if( nk_chart_begin(ui_ctx, NK_CHART_LINES, COUNT, 0.f, 70.f) ) { if( nk_chart_begin(ui_ctx, NK_CHART_LINES, COUNT, 0.f, 70.f) ) {
@ -350801,7 +350827,6 @@ int ui_swarm(swarm_t *self) {
// pathfinding ----------------------------------------------------------------- // pathfinding -----------------------------------------------------------------
static
int pathfind_astar(int width, int height, const unsigned* map, vec2i src, vec2i dst, vec2i* path, size_t maxpath) { int pathfind_astar(int width, int height, const unsigned* map, vec2i src, vec2i dst, vec2i* path, size_t maxpath) {
#define ALLOW_DIAGONAL_MOVEMENT 1 #define ALLOW_DIAGONAL_MOVEMENT 1

View File

@ -257,7 +257,6 @@ int ui_swarm(swarm_t *self) {
// pathfinding ----------------------------------------------------------------- // pathfinding -----------------------------------------------------------------
static
int pathfind_astar(int width, int height, const unsigned* map, vec2i src, vec2i dst, vec2i* path, size_t maxpath) { int pathfind_astar(int width, int height, const unsigned* map, vec2i src, vec2i dst, vec2i* path, size_t maxpath) {
#define ALLOW_DIAGONAL_MOVEMENT 1 #define ALLOW_DIAGONAL_MOVEMENT 1

View File

@ -44,3 +44,7 @@ API void swarm_update_acceleration_only(swarm_t *self); // acc
API void swarm_update_acceleration_and_velocity_only(swarm_t *self, float delta); // acc,vel API void swarm_update_acceleration_and_velocity_only(swarm_t *self, float delta); // acc,vel
API int ui_swarm(swarm_t *self); API int ui_swarm(swarm_t *self);
// pathfinding -----------------------------------------------------------------
API int pathfind_astar(int width, int height, const unsigned* map, vec2i src, vec2i dst, vec2i* path, size_t maxpath);

View File

@ -235250,7 +235250,8 @@ struct thread_queue_t
} THREADNAME_INFO; } THREADNAME_INFO;
#pragma pack(pop) #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 #ifndef _GNU_SOURCE
#define _GNU_SOURCE //< @r-lyeh: pthread_setname_np() #define _GNU_SOURCE //< @r-lyeh: pthread_setname_np()
#endif #endif
@ -235274,7 +235275,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems #elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
return (void*) pthread_self(); return (void*) pthread_self();
@ -235290,7 +235291,7 @@ void thread_yield( void )
SwitchToThread(); 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(); sched_yield();
@ -235306,7 +235307,7 @@ void thread_exit( int return_code )
ExitThread( (DWORD) 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 ); pthread_exit( (void*)(uintptr_t) return_code );
@ -235347,13 +235348,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems #elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || 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__ ) && !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 ); if( name ) pthread_setname_np( thread, name );
#endif #endif
@ -235372,7 +235373,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems #elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
pthread_join( (pthread_t) thread, NULL ); pthread_join( (pthread_t) thread, NULL );
@ -235391,7 +235392,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems #elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
void* retval; void* retval;
pthread_join( (pthread_t) thread, &retval ); pthread_join( (pthread_t) thread, &retval );
@ -235409,7 +235410,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__ ) || defined( EMSCRIPTEN ) #elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
return pthread_detach( (pthread_t) thread ) == 0; return pthread_detach( (pthread_t) thread ) == 0;
@ -235425,7 +235426,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems #elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
struct sched_param sp; struct sched_param sp;
memset( &sp, 0, sizeof( sp ) ); memset( &sp, 0, sizeof( sp ) );
@ -235450,7 +235451,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems #elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || 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 ); };
@ -235469,7 +235470,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems #elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
pthread_mutex_destroy( (pthread_mutex_t*) mutex ); pthread_mutex_destroy( (pthread_mutex_t*) mutex );
@ -235485,7 +235486,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems #elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
pthread_mutex_lock( (pthread_mutex_t*) mutex ); pthread_mutex_lock( (pthread_mutex_t*) mutex );
@ -235501,7 +235502,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems #elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
pthread_mutex_unlock( (pthread_mutex_t*) mutex ); pthread_mutex_unlock( (pthread_mutex_t*) mutex );
@ -235523,7 +235524,7 @@ struct thread_internal_signal_t
HANDLE event; HANDLE event;
#endif #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_mutex_t mutex;
pthread_cond_t condition; pthread_cond_t condition;
@ -235555,7 +235556,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems #elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || 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 );
@ -235579,7 +235580,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems #elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || 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 );
@ -235605,7 +235606,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems #elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
pthread_mutex_lock( &internal->mutex ); pthread_mutex_lock( &internal->mutex );
internal->value = 1; internal->value = 1;
@ -235640,7 +235641,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems #elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
struct timespec ts; struct timespec ts;
if( timeout_ms >= 0 ) if( timeout_ms >= 0 )
@ -235684,7 +235685,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__ ) || 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 ); return (int)__sync_fetch_and_add( &atomic->i, 0 );
@ -235700,7 +235701,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__ ) || 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_and( &atomic->i, 0 );
__sync_fetch_and_or( &atomic->i, desired ); __sync_fetch_and_or( &atomic->i, desired );
@ -235717,7 +235718,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__ ) || 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 ); return (int)__sync_fetch_and_add( &atomic->i, 1 );
@ -235733,7 +235734,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__ ) || 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 ); return (int)__sync_fetch_and_sub( &atomic->i, 1 );
@ -235749,7 +235750,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__ ) || 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 ); return (int)__sync_fetch_and_add( &atomic->i, value );
@ -235765,7 +235766,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__ ) || 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 ); return (int)__sync_fetch_and_sub( &atomic->i, value );
@ -235781,7 +235782,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__ ) || 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 ); int old = (int)__sync_lock_test_and_set( &atomic->i, desired );
__sync_lock_release( &atomic->i ); __sync_lock_release( &atomic->i );
@ -235799,7 +235800,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__ ) || 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 ); return (int)__sync_val_compare_and_swap( &atomic->i, expected, desired );
@ -235815,7 +235816,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__ ) || 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 ); return __sync_fetch_and_add( &atomic->ptr, 0 );
@ -235837,7 +235838,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__ ) || 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_test_and_set( &atomic->ptr, desired );
__sync_lock_release( &atomic->ptr ); __sync_lock_release( &atomic->ptr );
@ -235859,7 +235860,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__ ) || 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 ); void* old = __sync_lock_test_and_set( &atomic->ptr, desired );
__sync_lock_release( &atomic->ptr ); __sync_lock_release( &atomic->ptr );
@ -235877,7 +235878,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__ ) || 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 ); return __sync_val_compare_and_swap( &atomic->ptr, expected, desired );
@ -235904,7 +235905,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems #elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
// Nothing // Nothing
@ -235924,7 +235925,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems #elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
// Nothing // Nothing
@ -235944,7 +235945,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems #elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || defined( __EMSCRIPTEN__ ) //< @r-lyeh, ems
struct timespec rem; struct timespec rem;
struct timespec req; struct timespec req;
@ -235969,7 +235970,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__ ) || defined( EMSCRIPTEN ) //< @r-lyeh, ems #elif defined( __linux__ ) || defined( __APPLE__ ) || defined( __ANDROID__ ) || 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 )
@ -235989,7 +235990,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__ ) || 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 pthread_key_delete( (pthread_key_t) (uintptr_t) tls ); //< @r-lyeh: uintptr_t
@ -236005,7 +236006,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__ ) || 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 pthread_setspecific( (pthread_key_t) (uintptr_t) tls, value ); //< @r-lyeh: uintptr_t
@ -236021,7 +236022,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__ ) || 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 return pthread_getspecific( (pthread_key_t) (uintptr_t) tls ); //< @r-lyeh: uintptr_t
@ -276370,7 +276371,7 @@ int tls_remote_error(struct TLSContext *context);
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
*/ */
/******************************************************************************** /********************************************************************************
Copyright (c) 2016-2021, Eduard Suica Copyright (c) 2016-2023, Eduard Suica
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, Redistribution and use in source and binary forms, with or without modification,
@ -276480,13 +276481,13 @@ int tls_remote_error(struct TLSContext *context);
// #endif // #endif
#ifndef TLS_MALLOC #ifndef TLS_MALLOC
#define TLS_MALLOC(size) malloc(size) #define TLS_MALLOC MALLOC //< @r-lyeh
#endif #endif
#ifndef TLS_REALLOC #ifndef TLS_REALLOC
#define TLS_REALLOC(ptr, size) realloc(ptr, size) #define TLS_REALLOC REALLOC //< @r-lyeh
#endif #endif
#ifndef TLS_FREE #ifndef TLS_FREE
#define TLS_FREE(ptr) if (ptr) free(ptr) #define TLS_FREE FREE //< @r-lyeh
#endif #endif
#define TLS_ERROR(err, statement) if (err) statement; #define TLS_ERROR(err, statement) if (err) statement;
@ -283796,7 +283797,7 @@ int tls_parse_verify_tls13(struct TLSContext *context, const unsigned char *buf,
unsigned short signature = ntohs(*(unsigned short *)&buf[3]); unsigned short signature = ntohs(*(unsigned short *)&buf[3]);
unsigned short signature_size = ntohs(*(unsigned short *)&buf[5]); unsigned short signature_size = ntohs(*(unsigned short *)&buf[5]);
int valid = 0; int valid = 0;
CHECK_SIZE(7 + size, buf_len, TLS_NEED_MORE_DATA) CHECK_SIZE(7 + signature_size, buf_len, TLS_NEED_MORE_DATA)
switch (signature) { switch (signature) {
#ifdef TLS_ECDSA_SUPPORTED #ifdef TLS_ECDSA_SUPPORTED
case 0x0403: case 0x0403:
@ -287525,15 +287526,14 @@ https_status_t https_process( https_t* https )
#pragma warning( disable: 4548 ) // expression before comma has no effect; expected expression with side-effect #pragma warning( disable: 4548 ) // expression before comma has no effect; expected expression with side-effect
FD_SET( internal->socket, &sockets_to_check ); FD_SET( internal->socket, &sockets_to_check );
#pragma warning( pop ) #pragma warning( pop )
struct timeval timeout; timeout.tv_sec = 0; timeout.tv_usec = 0;
int buflen = 65536 * 1024;//< @r-lyeh heap allocated buffer struct timeval timeout;
static __thread char *buffer = 0; //< @r-lyeh heap allocated buffer while( (timeout.tv_sec = 1, timeout.tv_usec = 0), select( (int)( internal->socket + 1 ), &sockets_to_check, NULL, NULL, &timeout ) == 1 )
if(!buffer) memset(buffer = (char*)HTTPS_MALLOC(internal->memctx, buflen), 0, buflen); //< @r-lyeh heap allocated buffer
while( select( (int)( internal->socket + 1 ), &sockets_to_check, NULL, NULL, &timeout ) == 1 )
{ {
enum { buflen = 4 * 1024 };
char buffer[ buflen ];
int size = recv( internal->socket, buffer, buflen, 0 ); int size = recv( internal->socket, buffer, buflen, 0 );
if( size == -1 ) if( size == -1 )
{ {
@ -287541,8 +287541,9 @@ https_status_t https_process( https_t* https )
return https->status; return https->status;
} }
#if is(tcc) && is(64) #if is(tcc) && is(win32)
// hexdump(buffer, size); //< @r-lyeh // hexdump(buffer, size); //< @r-lyeh
// printf(">+=%d,%d/%d\n", size,internal->data_size,internal->data_capacity);
#endif #endif
tls_consume_stream( internal->tls_context, (unsigned char*) buffer, size, 0 ); tls_consume_stream( internal->tls_context, (unsigned char*) buffer, size, 0 );
@ -287581,7 +287582,6 @@ https_status_t https_process( https_t* https )
else if( size == 0 ) else if( size == 0 )
{ {
char const* status_line = (char const*) internal->data; char const* status_line = (char const*) internal->data;
int header_size = 0; int header_size = 0;
char const* header_end = strstr( status_line, "\r\n\r\n" ); char const* header_end = strstr( status_line, "\r\n\r\n" );
if( header_end ) if( header_end )

View File

@ -1469,7 +1469,7 @@ int audio_queue( const void *samples, int num_samples, int flags ) {
if( audio_queue_voice < 0 ) return 0; if( audio_queue_voice < 0 ) return 0;
} }
audio_queue_t *aq = MALLOC(sizeof(audio_queue_t) + bytes << (channels == 1)); // dupe space if going to be converted from mono to stereo audio_queue_t *aq = MALLOC(sizeof(audio_queue_t) + (bytes << (channels == 1))); // dupe space if going to be converted from mono to stereo
aq->cursor = 0; aq->cursor = 0;
aq->avail = bytes; aq->avail = bytes;
aq->flags = flags; aq->flags = flags;
@ -13197,6 +13197,21 @@ mesh_t mesh() {
return z; return z;
} }
aabb mesh_bounds(mesh_t *m) {
aabb b = {{1e9,1e9,1e9},{-1e9,-1e9,-1e9}};
for( int i = 0; i < array_count(m->in_vertex3); ++i ) {
if( m->in_vertex3[i].x < b.min.x ) b.min.x = m->in_vertex3[i].x;
if( m->in_vertex3[i].x > b.max.x ) b.max.x = m->in_vertex3[i].x;
if( m->in_vertex3[i].y < b.min.y ) b.min.y = m->in_vertex3[i].y;
if( m->in_vertex3[i].y > b.max.y ) b.max.y = m->in_vertex3[i].y;
if( m->in_vertex3[i].z < b.min.z ) b.min.z = m->in_vertex3[i].z;
if( m->in_vertex3[i].z > b.max.z ) b.max.z = m->in_vertex3[i].z;
}
return b;
}
void mesh_update(mesh_t *m, const char *format, int vertex_stride,int vertex_count,const void *vertex_data, int index_count,const void *index_data, int flags) { void mesh_update(mesh_t *m, const char *format, int vertex_stride,int vertex_count,const void *vertex_data, int index_count,const void *index_data, int flags) {
m->flags = flags; m->flags = flags;
@ -17329,6 +17344,9 @@ int tty_cols() {
#endif #endif
return 80; return 80;
} }
void tty_detach() {
ifdef(win32, FreeConsole());
}
void tty_attach() { void tty_attach() {
#if is(win32) #if is(win32)
// in order to have a Windows gui application with console: // in order to have a Windows gui application with console:
@ -19913,6 +19931,9 @@ void (profile_render)() {
if( has_menu ? ui_window("Profiler", 0) : ui_panel("Profiler", 0) ) { if( has_menu ? ui_window("Profiler", 0) : ui_panel("Profiler", 0) ) {
double fps = window_fps();
profile_setstat("Render.num_fps", fps);
if(1) { // @todo: ui_plot() if(1) { // @todo: ui_plot()
// draw fps-meter: 300 samples, [0..70] range each, 70px height plot. // draw fps-meter: 300 samples, [0..70] range each, 70px height plot.
nk_layout_row_dynamic(ui_ctx, 70, 1); nk_layout_row_dynamic(ui_ctx, 70, 1);
@ -19920,7 +19941,7 @@ void (profile_render)() {
enum { COUNT = 300 }; enum { COUNT = 300 };
static float values[COUNT] = {0}; static int offset = 0; static float values[COUNT] = {0}; static int offset = 0;
values[offset=(offset+1)%COUNT] = window_fps(); values[offset=(offset+1)%COUNT] = fps;
int index = -1; int index = -1;
if( nk_chart_begin(ui_ctx, NK_CHART_LINES, COUNT, 0.f, 70.f) ) { if( nk_chart_begin(ui_ctx, NK_CHART_LINES, COUNT, 0.f, 70.f) ) {
@ -21876,7 +21897,6 @@ int ui_swarm(swarm_t *self) {
// pathfinding ----------------------------------------------------------------- // pathfinding -----------------------------------------------------------------
static
int pathfind_astar(int width, int height, const unsigned* map, vec2i src, vec2i dst, vec2i* path, size_t maxpath) { int pathfind_astar(int width, int height, const unsigned* map, vec2i src, vec2i dst, vec2i* path, size_t maxpath) {
#define ALLOW_DIAGONAL_MOVEMENT 1 #define ALLOW_DIAGONAL_MOVEMENT 1

View File

@ -1214,6 +1214,10 @@ API void swarm_update_acceleration_only(swarm_t *self); // acc
API void swarm_update_acceleration_and_velocity_only(swarm_t *self, float delta); // acc,vel API void swarm_update_acceleration_and_velocity_only(swarm_t *self, float delta); // acc,vel
API int ui_swarm(swarm_t *self); API int ui_swarm(swarm_t *self);
// pathfinding -----------------------------------------------------------------
API int pathfind_astar(int width, int height, const unsigned* map, vec2i src, vec2i dst, vec2i* path, size_t maxpath);
#line 0 #line 0
#line 1 "v4k_audio.h" #line 1 "v4k_audio.h"
@ -3008,6 +3012,7 @@ API float optionf(const char *commalist, float defaults); // app_option?
API void tty_color(unsigned color); API void tty_color(unsigned color);
API void tty_reset(); API void tty_reset();
API void tty_attach(); API void tty_attach();
API void tty_detach();
API const char* app_exec(const char *command); // returns ("%15d %s", retcode, output_last_line) API const char* app_exec(const char *command); // returns ("%15d %s", retcode, output_last_line)
API int app_cores(); API int app_cores();

File diff suppressed because one or more lines are too long