Linux fixes (#3)
This commit is contained in:
parent
7216822064
commit
9b4aa025ef
4 changed files with 15 additions and 24 deletions
5
.github/workflows/build.yml
vendored
5
.github/workflows/build.yml
vendored
|
|
@ -2,10 +2,7 @@
|
|||
name: CI Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
BUILD_TYPE: Debug
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
#include <algorithm>
|
||||
#include <assert.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <vector>
|
||||
|
||||
|
|
|
|||
21
src/simd.h
21
src/simd.h
|
|
@ -59,22 +59,13 @@ static inline b3V32 b3NegV( b3V32 a )
|
|||
return _mm_sub_ps( _mm_setzero_ps(), a );
|
||||
}
|
||||
|
||||
// Unaligned loads are much faster on recent hardware with little to no penalty
|
||||
// Note: This may read one extra float beyond a b3Vec3 for performance. Address sanitizer
|
||||
// is disabled for this function as the extra read is intentional and safe.
|
||||
#if defined( __linux__ ) || defined( __APPLE__ ) || defined( __clang__ )
|
||||
__attribute__( ( no_sanitize_address ) )
|
||||
#elif defined( _MSC_VER )
|
||||
__declspec( no_sanitize_address )
|
||||
#endif
|
||||
static inline b3V32
|
||||
b3LoadV( const float* src )
|
||||
static inline b3V32 b3LoadV( const float* src )
|
||||
{
|
||||
const __m128i masK3 = _mm_setr_epi32( 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0 );
|
||||
|
||||
// Read an extra float which gets zeroed (to avoid NaN or Inf)
|
||||
b3V32 a = _mm_loadu_ps( src );
|
||||
return _mm_and_ps( a, _mm_castsi128_ps( masK3 ) );
|
||||
// Loads exactly 12 bytes: 8 via movsd, 4 via movss.
|
||||
// Result lane 3 is implicitly zero from the partial loads.
|
||||
__m128 xy = _mm_castpd_ps( _mm_load_sd( (const double*)( src ) ) );
|
||||
__m128 z = _mm_load_ss( src + 2 );
|
||||
return _mm_movelh_ps( xy, z ); // { src[0], src[1], src[2], 0.0f }
|
||||
}
|
||||
|
||||
static inline b3V32 b3ZeroV( void )
|
||||
|
|
|
|||
12
src/timer.c
12
src/timer.c
|
|
@ -15,6 +15,8 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#define NAME_LENGTH 16
|
||||
|
||||
#if defined( _WIN32 )
|
||||
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
|
|
@ -139,7 +141,7 @@ typedef struct b3Thread
|
|||
HANDLE thread;
|
||||
b3ThreadFunction* function;
|
||||
void* context;
|
||||
char name[32];
|
||||
char name[NAME_LENGTH];
|
||||
} b3Thread;
|
||||
|
||||
typedef HRESULT( WINAPI* b3SetThreadDescriptionFn )( HANDLE, PCWSTR );
|
||||
|
|
@ -176,7 +178,7 @@ static void b3SetCurrentThreadName( const char* name )
|
|||
return;
|
||||
}
|
||||
|
||||
wchar_t wide[32];
|
||||
wchar_t wide[NAME_LENGTH];
|
||||
int n = MultiByteToWideChar( CP_UTF8, 0, name, -1, wide, (int)( sizeof( wide ) / sizeof( wide[0] ) ) );
|
||||
if ( n > 0 )
|
||||
{
|
||||
|
|
@ -314,7 +316,7 @@ typedef struct b3Thread
|
|||
pthread_t thread;
|
||||
b3ThreadFunction* function;
|
||||
void* context;
|
||||
char name[32];
|
||||
char name[NAME_LENGTH];
|
||||
} b3Thread;
|
||||
|
||||
static void b3SetCurrentThreadName( const char* name )
|
||||
|
|
@ -326,7 +328,7 @@ static void b3SetCurrentThreadName( const char* name )
|
|||
|
||||
#if defined( __linux__ )
|
||||
// Linux caps thread names at 15 chars + null terminator.
|
||||
char truncated[16];
|
||||
char truncated[NAME_LENGTH];
|
||||
snprintf( truncated, sizeof( truncated ), "%s", name );
|
||||
pthread_setname_np( pthread_self(), truncated );
|
||||
#else
|
||||
|
|
@ -490,7 +492,7 @@ typedef struct b3Thread
|
|||
pthread_t thread;
|
||||
b3ThreadFunction* function;
|
||||
void* context;
|
||||
char name[32];
|
||||
char name[NAME_LENGTH];
|
||||
} b3Thread;
|
||||
|
||||
// macOS pthread_setname_np takes only the name — it always names the calling thread.
|
||||
|
|
|
|||
Loading…
Reference in a new issue