summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2013-04-03 01:18:52 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2013-04-03 01:19:31 +0200
commit24a9d76641168bd1e91722dfc5221a36a2ea561f (patch)
treed262f3e6293de6fcd9102e4bd280ba8fe1d4beaf
parentInitial commit. (diff)
downloadalmamater-24a9d76641168bd1e91722dfc5221a36a2ea561f.tar.xz
almamater-24a9d76641168bd1e91722dfc5221a36a2ea561f.zip
Add OSX support.
-rw-r--r--Makefile2
-rw-r--r--almamater.c29
2 files changed, 28 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 07f3e4c..e73e375 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
CFLAGS += -std=c99 -O3 -march=native -Iskein -lcurl -lpthread
-almamater: almamater.c $(wildcard skein/*)
+almamater: almamater.c skein/skein.c skein/skein_block.c
all: almamater
diff --git a/almamater.c b/almamater.c
index 9dfe506..fe86901 100644
--- a/almamater.c
+++ b/almamater.c
@@ -6,7 +6,6 @@
#include <stdlib.h>
#include <pthread.h>
#include <sys/time.h>
-#include <sys/sysinfo.h>
#include <curl/curl.h>
#include "skein.h"
@@ -15,6 +14,32 @@
#define STR_MAX 64
#define DOMAIN "columbia.edu"
+
+#ifdef __linux__
+#include <sys/sysinfo.h>
+#else
+#include <sys/sysctl.h>
+static inline int get_nprocs()
+{
+ int nproc;
+ int mib[4];
+ size_t len = sizeof(nproc);
+
+ mib[0] = CTL_HW;
+ mib[1] = HW_AVAILCPU;
+ sysctl(mib, 2, &nproc, &len, NULL, 0);
+
+ if (nproc < 1) {
+ mib[1] = HW_NCPU;
+ sysctl(mib, 2, &nproc, &len, NULL, 0);
+ if (nproc < 1)
+ nproc = 1;
+ }
+
+ return nproc;
+}
+#endif
+
static const uint8_t xkcd_hash[] = {
0x5b, 0x4d, 0xa9, 0x5f, 0x5f, 0xa0, 0x82, 0x80, 0xfc, 0x98, 0x79, 0xdf,
0x44, 0xf4, 0x18, 0xc8, 0xf9, 0xf1, 0x2b, 0xa4, 0x24, 0xb7, 0x75, 0x7d,
@@ -98,7 +123,7 @@ static void submit_to_xkcd(uint8_t *str, size_t len, unsigned long score)
printf("[-] Could not init curl.\n");
goto unlock_mutex;
}
- escaped_str = curl_easy_escape(curl, str, len);
+ escaped_str = curl_easy_escape(curl, (char *)str, len);
if (!escaped_str) {
printf("[-] Could not escape string.\n");
goto free_curl;