Compiling on linux.
This commit is contained in:
parent
3cae7ed714
commit
bfda368ab5
|
@ -95,7 +95,7 @@
|
||||||
],
|
],
|
||||||
|
|
||||||
'cflags': [
|
'cflags': [
|
||||||
'-std=c99',
|
#'-std=c99',
|
||||||
],
|
],
|
||||||
|
|
||||||
'configurations': {
|
'configurations': {
|
||||||
|
|
|
@ -69,7 +69,16 @@ XEFORCEINLINE void* xe_atomic_stack_dequeue(xe_atomic_stack_t* stack,
|
||||||
|
|
||||||
#elif XE_LIKE(POSIX)
|
#elif XE_LIKE(POSIX)
|
||||||
|
|
||||||
#error TODO(benvanik): POSIX atomic primitives
|
#define xe_atomic_inc_32(value) \
|
||||||
|
__sync_add_and_fetch(value, 1)
|
||||||
|
#define xe_atomic_dec_32(value) \
|
||||||
|
__sync_sub_and_fetch(value, 1)
|
||||||
|
#define xe_atomic_add_32(amount, value) \
|
||||||
|
__sync_fetch_and_add(value, amount)
|
||||||
|
#define xe_atomic_sub_32(amount, value) \
|
||||||
|
__sync_fetch_and_sub(value, amount)
|
||||||
|
#define xe_atomic_cas_32(oldValue, newValue, value) \
|
||||||
|
__sync_bool_compare_and_swap(value, oldValue, newValue)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
|
@ -24,9 +24,9 @@
|
||||||
#define XESWAP32 OSSwapInt32
|
#define XESWAP32 OSSwapInt32
|
||||||
#define XESWAP64 OSSwapInt64
|
#define XESWAP64 OSSwapInt64
|
||||||
#else
|
#else
|
||||||
#define XESWAP16 bswap_16
|
#define XESWAP16 __bswap_16
|
||||||
#define XESWAP32 bswap_32
|
#define XESWAP32 __bswap_32
|
||||||
#define XESWAP64 bswap_64
|
#define XESWAP64 __bswap_64
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -185,7 +185,7 @@ int xe_socket_loop_poll(xe_socket_loop_t* loop,
|
||||||
XEIGNORE(recv(loop->notify_rd_id, &dummy, 1, 0));
|
XEIGNORE(recv(loop->notify_rd_id, &dummy, 1, 0));
|
||||||
}
|
}
|
||||||
loop->events[1].revents = 0;
|
loop->events[1].revents = 0;
|
||||||
loop->events[1].events = POLL_IN;
|
loop->events[1].events = POLLIN;
|
||||||
|
|
||||||
// Check send/recv.
|
// Check send/recv.
|
||||||
loop->pending_recv = (loop->events[0].revents & POLLIN) != 0;
|
loop->pending_recv = (loop->events[0].revents & POLLIN) != 0;
|
||||||
|
|
|
@ -109,7 +109,11 @@ int xe_thread_start(xe_thread_ref thread) {
|
||||||
|
|
||||||
static void* xe_thread_callback_pthreads(void* param) {
|
static void* xe_thread_callback_pthreads(void* param) {
|
||||||
xe_thread_t* thread = reinterpret_cast<xe_thread_t*>(param);
|
xe_thread_t* thread = reinterpret_cast<xe_thread_t*>(param);
|
||||||
|
#if XE_LIKE(OSX)
|
||||||
XEIGNORE(pthread_setname_np(thread->name));
|
XEIGNORE(pthread_setname_np(thread->name));
|
||||||
|
#else
|
||||||
|
pthread_setname_np(pthread_self(), thread->name);
|
||||||
|
#endif // OSX
|
||||||
thread->callback(thread->callback_param);
|
thread->callback(thread->callback_param);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#if XE_PLATFORM(WIN32)
|
#if XE_PLATFORM(WIN32)
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#else
|
#else
|
||||||
|
#include <arpa/inet.h>
|
||||||
#endif // WIN32
|
#endif // WIN32
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -186,11 +186,16 @@ X_STATUS XThread::PlatformCreate() {
|
||||||
|
|
||||||
int result_code;
|
int result_code;
|
||||||
if (creation_params_.creation_flags & X_CREATE_SUSPENDED) {
|
if (creation_params_.creation_flags & X_CREATE_SUSPENDED) {
|
||||||
|
#if XE_PLATFORM(OSX)
|
||||||
result_code = pthread_create_suspended_np(
|
result_code = pthread_create_suspended_np(
|
||||||
reinterpret_cast<pthread_t*>(&thread_handle_),
|
reinterpret_cast<pthread_t*>(&thread_handle_),
|
||||||
&attr,
|
&attr,
|
||||||
&XThreadStartCallbackPthreads,
|
&XThreadStartCallbackPthreads,
|
||||||
this);
|
this);
|
||||||
|
#else
|
||||||
|
// TODO(benvanik): pthread_create_suspended_np on linux
|
||||||
|
XEASSERTALWAYS();
|
||||||
|
#endif // OSX
|
||||||
} else {
|
} else {
|
||||||
result_code = pthread_create(
|
result_code = pthread_create(
|
||||||
reinterpret_cast<pthread_t*>(&thread_handle_),
|
reinterpret_cast<pthread_t*>(&thread_handle_),
|
||||||
|
|
|
@ -153,7 +153,7 @@ int xe_main_thunk(
|
||||||
void* user_main, const char* usage);
|
void* user_main, const char* usage);
|
||||||
#define XE_MAIN_THUNK(NAME, USAGE) \
|
#define XE_MAIN_THUNK(NAME, USAGE) \
|
||||||
int main(int argc, char **argv) { \
|
int main(int argc, char **argv) { \
|
||||||
return xe_main_thunk(argc, argv, NAME, USAGE); \
|
return xe_main_thunk(argc, argv, (void*)NAME, USAGE); \
|
||||||
}
|
}
|
||||||
#endif // WIN32
|
#endif // WIN32
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,11 @@
|
||||||
#pragma warning(disable : 4068)
|
#pragma warning(disable : 4068)
|
||||||
#endif // MSVC
|
#endif // MSVC
|
||||||
|
|
||||||
|
#if XE_LIKE(POSIX)
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <endian.h>
|
||||||
|
#endif // POSIX
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
Loading…
Reference in New Issue