fix macOS build
This commit is contained in:
parent
359657e174
commit
0c0aa792c1
5 changed files with 107 additions and 9 deletions
|
|
@ -4,17 +4,26 @@
|
|||
|
||||
#include "pxl8_types.h"
|
||||
|
||||
#if defined(__x86_64__) || defined(_M_X64)
|
||||
#include <xmmintrin.h>
|
||||
#elif defined(__aarch64__) || defined(_M_ARM64)
|
||||
#include <arm_neon.h>
|
||||
#ifndef PXL8_NO_SIMD
|
||||
#if defined(__x86_64__) || defined(_M_X64)
|
||||
#include <xmmintrin.h>
|
||||
#elif defined(__aarch64__) || defined(_M_ARM64)
|
||||
#include <arm_neon.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define PXL8_PI 3.14159265358979323846f
|
||||
#define PXL8_TAU (PXL8_PI * 2.0f)
|
||||
|
||||
static inline f32 pxl8_fast_inv_sqrt(f32 x) {
|
||||
#if defined(__x86_64__) || defined(_M_X64)
|
||||
#if defined(PXL8_NO_SIMD)
|
||||
f32 half = 0.5f * x;
|
||||
i32 i = *(i32*)&x;
|
||||
i = 0x5f3759df - (i >> 1);
|
||||
x = *(f32*)&i;
|
||||
x = x * (1.5f - half * x * x);
|
||||
return x;
|
||||
#elif defined(__x86_64__) || defined(_M_X64)
|
||||
__m128 v = _mm_set_ss(x);
|
||||
v = _mm_rsqrt_ss(v);
|
||||
return _mm_cvtss_f32(v);
|
||||
|
|
@ -34,7 +43,9 @@ static inline f32 pxl8_fast_inv_sqrt(f32 x) {
|
|||
}
|
||||
|
||||
static inline f32 pxl8_fast_rcp(f32 x) {
|
||||
#if defined(__x86_64__) || defined(_M_X64)
|
||||
#if defined(PXL8_NO_SIMD)
|
||||
return 1.0f / x;
|
||||
#elif defined(__x86_64__) || defined(_M_X64)
|
||||
__m128 v = _mm_set_ss(x);
|
||||
__m128 rcp = _mm_rcp_ss(v);
|
||||
rcp = _mm_add_ss(rcp, _mm_mul_ss(rcp, _mm_sub_ss(_mm_set_ss(1.0f), _mm_mul_ss(v, rcp))));
|
||||
|
|
|
|||
|
|
@ -110,6 +110,9 @@ pxl8_result pxl8_net_connect(pxl8_net* net) {
|
|||
#endif
|
||||
|
||||
memset(&net->server_addr, 0, sizeof(net->server_addr));
|
||||
#ifdef __APPLE__
|
||||
net->server_addr.sin_len = sizeof(net->server_addr);
|
||||
#endif
|
||||
net->server_addr.sin_family = AF_INET;
|
||||
net->server_addr.sin_port = htons(net->port);
|
||||
inet_pton(AF_INET, net->address, &net->server_addr.sin_addr);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue