From 94706763e55f1545ba7996d37b793f4bafbbd3ad Mon Sep 17 00:00:00 2001 From: Jon Williams Date: Thu, 31 Mar 2016 13:25:32 -0400 Subject: [PATCH] fix compilation on OpenBSD --- Makefile | 4 ++++ compat/clock_nanosleep/clock_nanosleep.c | 5 ++++- compat/clock_nanosleep/clock_nanosleep.h | 6 +++--- compat/compat.h | 16 ++++++++++++++-- net_io.c | 2 +- 5 files changed, 26 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 384d2d4..e8e0f49 100644 --- a/Makefile +++ b/Makefile @@ -31,6 +31,10 @@ CFLAGS+=-std=c11 COMPAT+=compat/clock_gettime/clock_gettime.o compat/clock_nanosleep/clock_nanosleep.o endif +ifeq ($(UNAME), OpenBSD) +COMPAT+= compat/clock_nanosleep/clock_nanosleep.o +endif + all: dump1090 view1090 %.o: %.c *.h diff --git a/compat/clock_nanosleep/clock_nanosleep.c b/compat/clock_nanosleep/clock_nanosleep.c index 9cbd1e4..f6e3d84 100644 --- a/compat/clock_nanosleep/clock_nanosleep.c +++ b/compat/clock_nanosleep/clock_nanosleep.c @@ -19,10 +19,13 @@ * http://www.gnu.org/copyleft/gpl.html * ***********************************************************************/ -#include "clock_nanosleep.h" #include // for errno, EINVAL #include // for nanosleep, NULL + +#include "clock_nanosleep.h" +#ifdef MISSING_GETTIME #include "../clock_gettime/clock_gettime.h" // for clock_gettime +#endif int clock_nanosleep(clockid_t id, int flags, const struct timespec *ts, struct timespec *ots) { diff --git a/compat/clock_nanosleep/clock_nanosleep.h b/compat/clock_nanosleep/clock_nanosleep.h index 5f91915..f736409 100644 --- a/compat/clock_nanosleep/clock_nanosleep.h +++ b/compat/clock_nanosleep/clock_nanosleep.h @@ -1,8 +1,8 @@ #ifndef CLOCK_NANOSLEEP_H #define CLOCK_NANOSLEEP_H -#ifndef CLOCKID_T -#define CLOCKID_T +#ifndef _CLOCK_T_DEFINED_ +#define _CLOCK_T_DEFINED_ typedef enum { CLOCK_REALTIME, @@ -10,7 +10,7 @@ typedef enum CLOCK_PROCESS_CPUTIME_ID, CLOCK_THREAD_CPUTIME_ID } clockid_t; -#endif // CLOCKID_T +#endif // _CLOCK_T_DEFINED_ #ifndef TIMER_ABSTIME #define TIMER_ABSTIME 1 diff --git a/compat/compat.h b/compat/compat.h index c8bb5fb..4c5fadb 100644 --- a/compat/compat.h +++ b/compat/compat.h @@ -9,8 +9,8 @@ /* implementations of clock_gettime, clock_nanosleep */ -#include "clock_gettime/clock_gettime.h" -#include "clock_nanosleep/clock_nanosleep.h" +#define MISSING_NANOSLEEP +#define MISSING_GETTIME /* * Mach endian conversion @@ -29,4 +29,16 @@ #endif +#if defined(__OpenBSD__) +#define MISSING_NANOSLEEP +#endif + +#ifdef MISSING_NANOSLEEP +#include "clock_nanosleep/clock_nanosleep.h" +#endif + +#ifdef MISSING_GETTIME +#include "clock_nanosleep/clock_gettime.h" +#endif + #endif //COMPAT_UTIL_H diff --git a/net_io.c b/net_io.c index 9b3facc..70e9901 100644 --- a/net_io.c +++ b/net_io.c @@ -1316,7 +1316,7 @@ static int handleHTTPRequest(struct client *c, char *p) { const char *statusmsg = "Internal Server Error"; char *url, *content = NULL; char *ext; - char *content_type; + char *content_type = NULL; int i; if (Modes.debug & MODES_DEBUG_NET)