Browse Source

Mac OS X build fixes.

Georgi Chorbadzhiyski 12 years ago
parent
commit
0d9c2e1bcf
3 changed files with 19 additions and 2 deletions
  1. 2
    2
      Makefile
  2. 1
    0
      process.c
  3. 16
    0
      util.c

+ 2
- 2
Makefile View File

@@ -45,11 +45,11 @@ tsdecrypt_SRC = data.c \
45 45
  tables.c \
46 46
  notify.c \
47 47
  tsdecrypt.c
48
-tsdecrypt_LIBS = -lcrypto -ldvbcsa -lpthread -lrt
48
+tsdecrypt_LIBS = -lcrypto -ldvbcsa -lpthread
49 49
 tsdecrypt_OBJS = $(FUNCS_LIB) $(TS_LIB) $(tsdecrypt_SRC:.c=.o)
50 50
 
51 51
 ifeq "$(shell uname -s)" "Linux"
52
-tsdecrypt_LIBS += -lcrypt
52
+tsdecrypt_LIBS += -lcrypt -lrt
53 53
 endif
54 54
 
55 55
 CLEAN_OBJS = tsdecrypt $(tsdecrypt_SRC:.c=.{o,d})

+ 1
- 0
process.c View File

@@ -17,6 +17,7 @@
17 17
  */
18 18
 #include <unistd.h>
19 19
 #include <string.h>
20
+#include <sys/uio.h>
20 21
 
21 22
 #include "data.h"
22 23
 #include "tables.h"

+ 16
- 0
util.c View File

@@ -157,9 +157,25 @@ int decode_hex_string(char *hex, uint8_t *bin, int asc_len) {
157 157
 	return asc_len / 2;
158 158
 }
159 159
 
160
+#ifdef __MACH__
161
+#include <mach/clock.h>
162
+#include <mach/mach.h>
163
+#endif
164
+
160 165
 int64_t get_time(void) {
161 166
 	struct timespec ts;
167
+#ifdef __MACH__
168
+// OS X does not have clock_gettime, use clock_get_time
169
+	clock_serv_t cclock;
170
+	mach_timespec_t mts;
171
+	host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
172
+	clock_get_time(cclock, &mts);
173
+	mach_port_deallocate(mach_task_self(), cclock);
174
+	ts.tv_sec = mts.tv_sec;
175
+	ts.tv_nsec = mts.tv_nsec;
176
+#else
162 177
 	if (clock_gettime(CLOCK_MONOTONIC, &ts) == EINVAL) // Shouldn't happen on modern Linux
163 178
 		clock_gettime(CLOCK_REALTIME, &ts);
179
+#endif
164 180
 	return ts.tv_sec * 1000000ll + ts.tv_nsec / 1000;
165 181
 }

Loading…
Cancel
Save