forked from gjedeer/tuntox
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: Possibility to compile on Mac OS platform
- Loading branch information
Dawid 'nCore' Opis
committed
Sep 16, 2015
1 parent
83790e5
commit 1997879
Showing
7 changed files
with
91 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,3 +27,7 @@ | |
*.i*86 | ||
*.x86_64 | ||
*.hex | ||
|
||
# tuntox related, not needed in repo | ||
tuntox | ||
gitversion.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
SOURCES = $(wildcard *.c) | ||
DEPS=libtoxcore | ||
CC=gcc | ||
CFLAGS=-g #-std=c99 | ||
CFLAGS += $(shell pkg-config --cflags $(DEPS)) | ||
LDFLAGS=-g -lm | ||
LDFLAGS += $(shell pkg-config --libs $(DEPS)) | ||
OBJECTS=$(SOURCES:.c=.o) | ||
INCLUDES = $(wildcard *.h) | ||
|
||
all: cscope.out tuntox | ||
|
||
gitversion.h: .git/HEAD .git/index | ||
echo "#define GITVERSION \"$(shell git rev-parse HEAD)\"" > $@ | ||
|
||
gitversion.c: gitversion.h | ||
|
||
.c.o: $(INCLUDES) | ||
$(CC) $(CFLAGS) $< -c -o $@ | ||
|
||
tuntox: $(OBJECTS) $(INCLUDES) | ||
$(CC) -o $@ $(OBJECTS) -ltoxcore $(LDFLAGS) /usr/local/lib/libsodium.a /usr/local/lib/libtoxcore.a | ||
|
||
cscope.out: | ||
cscope -bv ./*.[ch] | ||
|
||
clean: | ||
rm -rf *.o tuntox gitversion.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include "mach.h" | ||
|
||
/* there is no clock_gettime on MacOS platform */ | ||
int clock_gettime(int clk_id, struct timespec *t) | ||
{ | ||
mach_timebase_info_data_t timebase; | ||
mach_timebase_info(&timebase); | ||
|
||
uint64_t time; | ||
|
||
time = mach_absolute_time(); | ||
|
||
double nseconds = ((double)time * (double)timebase.numer) / ((double)timebase.denom); | ||
double seconds = ((double)time * (double)timebase.numer) / ((double)timebase.denom * 1e9); | ||
|
||
t->tv_sec = seconds; | ||
t->tv_nsec = nseconds; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#ifndef _MACH_H | ||
#define _MACH_H | ||
|
||
#include <time.h> | ||
#include <mach/mach_time.h> | ||
|
||
// there is no CLOCK_REALTIME or CLOCK_MONOTONIC on MacOS platform | ||
#define CLOCK_REALTIME 0 | ||
#define CLOCK_MONOTONIC 0 | ||
|
||
// MacOS doesn't support the flag MSG_NOSIGNAL | ||
#define MSG_NOSIGNAL SO_NOSIGPIPE | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters