Merge pull request #444 from zenwheel/master Compile UNIX conditionals on Mac OS X
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
diff --git a/.gitignore b/.gitignore
index 7ab4ca0..2920e45 100644
--- a/.gitignore
+++ b/.gitignore
@@ -38,6 +38,7 @@ lib/c++defs.h
lib/libgnu.a
lib/signal.h
lib/string.h
+lib/stdint.h
lib/warn-on-use.h
mkinstalldirs
diff --git a/cgminer.c b/cgminer.c
index 4e38082..7ee5e5c 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -56,7 +56,7 @@
#include "driver-avalon.h"
#endif
-#if defined(unix)
+#if defined(unix) || defined(__APPLE__)
#include <errno.h>
#include <fcntl.h>
#include <sys/wait.h>
@@ -287,7 +287,7 @@ static int include_count;
#define JSON_MAX_DEPTH 10
#define JSON_MAX_DEPTH_ERR "Too many levels of JSON includes (limit 10) or a loop"
-#if defined(unix)
+#if defined(unix) || defined(__APPLE__)
static char *opt_stderr_cmd = NULL;
static int forkpid;
#endif // defined(unix)
@@ -1057,7 +1057,7 @@ static struct opt_table opt_config_table[] = {
OPT_WITHOUT_ARG("--lowmem",
opt_set_bool, &opt_lowmem,
"Minimise caching of shares for low memory applications"),
-#if defined(unix)
+#if defined(unix) || defined(__APPLE__)
OPT_WITH_ARG("--monitor|-m",
opt_set_charp, NULL, &opt_stderr_cmd,
"Use custom pipe cmd for output messages"),
@@ -2971,7 +2971,7 @@ void app_restart(void)
__kill_work();
clean_up();
-#if defined(unix)
+#if defined(unix) || defined(__APPLE__)
if (forkpid > 0) {
kill(forkpid, SIGTERM);
forkpid = 0;
@@ -4068,7 +4068,7 @@ void write_config(FILE *fcfg)
fputs(",\n\"round-robin\" : true", fcfg);
if (pool_strategy == POOL_ROTATE)
fprintf(fcfg, ",\n\"rotate\" : \"%d\"", opt_rotate_period);
-#if defined(unix)
+#if defined(unix) || defined(__APPLE__)
if (opt_stderr_cmd && *opt_stderr_cmd)
fprintf(fcfg, ",\n\"monitor\" : \"%s\"", json_escape(opt_stderr_cmd));
#endif // defined(unix)
@@ -4446,7 +4446,7 @@ void default_save_file(char *filename)
return;
}
-#if defined(unix)
+#if defined(unix) || defined(__APPLE__)
if (getenv("HOME") && *getenv("HOME")) {
strcpy(filename, getenv("HOME"));
strcat(filename, "/");
@@ -6741,7 +6741,7 @@ void quit(int status, const char *format, ...)
clean_up();
-#if defined(unix)
+#if defined(unix) || defined(__APPLE__)
if (forkpid > 0) {
kill(forkpid, SIGTERM);
forkpid = 0;
@@ -6882,7 +6882,7 @@ out:
}
#endif
-#if defined(unix)
+#if defined(unix) || defined(__APPLE__)
static void fork_monitor()
{
// Make a pipe: [readFD, writeFD]
@@ -7610,7 +7610,7 @@ int main(int argc, char *argv[])
openlog(PACKAGE, LOG_PID, LOG_USER);
#endif
- #if defined(unix)
+ #if defined(unix) || defined(__APPLE__)
if (opt_stderr_cmd)
fork_monitor();
#endif // defined(unix)