|
@ -37,35 +37,13 @@ |
|
|
#include <sys/select.h> |
|
|
#include <sys/select.h> |
|
|
#include <pthread.h> |
|
|
#include <pthread.h> |
|
|
|
|
|
|
|
|
#ifdef __APPLE__ |
|
|
|
|
|
#include <mach-o/dyld.h> /* _NSGetExecutablePath */ |
|
|
|
|
|
|
|
|
|
|
|
static void get_executable_path() { |
|
|
|
|
|
uint32_t bufsize = sizeof(executable_path); |
|
|
|
|
|
_NSGetExecutablePath(executable_path, &bufsize); |
|
|
|
|
|
} |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#ifdef __linux__ |
|
|
|
|
|
static void get_executable_path() { |
|
|
|
|
|
if (!executable_path[0]) { |
|
|
|
|
|
readlink("/proc/self/exe", executable_path, PATHMAX - 1); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Do platform-specific initialization. */ |
|
|
/* Do platform-specific initialization. */ |
|
|
void platform_init(int argc, char **argv) { |
|
|
void platform_init(int argc, char **argv) { |
|
|
/* Disable stdio output buffering. */ |
|
|
/* Disable stdio output buffering. */ |
|
|
setvbuf(stdout, NULL, _IONBF, 0); |
|
|
setvbuf(stdout, NULL, _IONBF, 0); |
|
|
setvbuf(stderr, NULL, _IONBF, 0); |
|
|
setvbuf(stderr, NULL, _IONBF, 0); |
|
|
#ifdef get_executable_path |
|
|
|
|
|
get_executable_path(); |
|
|
|
|
|
#else |
|
|
|
|
|
strcpy(executable_path, argv[0]); |
|
|
strcpy(executable_path, argv[0]); |
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
signal(SIGPIPE, SIG_IGN); |
|
|
signal(SIGPIPE, SIG_IGN); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|