Merge pull request #111 from WIZARDISHUNGRY/mutability-openbsd

Fix compilation on OpenBSD
This commit is contained in:
Oliver Jowett 2016-03-31 19:46:20 +01:00
commit 5417fa6a53
6 changed files with 31 additions and 11 deletions

View file

@ -27,10 +27,15 @@ LIBS+=-lrt
endif endif
ifeq ($(UNAME), Darwin) ifeq ($(UNAME), Darwin)
# TODO: Putting GCC in C11 mode breaks things. # TODO: Putting GCC in C11 mode breaks things.
CFLAGS+=-std=c11 CFLAGS+=-std=c11 -DMISSING_GETTIME -DMISSING_NANOSLEEP
COMPAT+=compat/clock_gettime/clock_gettime.o compat/clock_nanosleep/clock_nanosleep.o COMPAT+=compat/clock_gettime/clock_gettime.o compat/clock_nanosleep/clock_nanosleep.o
endif endif
ifeq ($(UNAME), OpenBSD)
CFLAGS+= -DMISSING_NANOSLEEP
COMPAT+= compat/clock_nanosleep/clock_nanosleep.o
endif
all: dump1090 view1090 all: dump1090 view1090
%.o: %.c *.h %.o: %.c *.h

View file

@ -1,7 +1,11 @@
#ifndef CLOCK_GETTIME_H #ifndef CLOCK_GETTIME_H
#define CLOCK_GETTIME_H #define CLOCK_GETTIME_H
#include <mach/mach_time.h> #include <mach/mach_time.h> // Apple-only, but this isn't inclued on other BSDs
#ifdef _CLOCKID_T_DEFINED_
#define CLOCKID_T
#endif
#ifndef CLOCKID_T #ifndef CLOCKID_T
#define CLOCKID_T #define CLOCKID_T
@ -12,7 +16,7 @@ typedef enum
CLOCK_PROCESS_CPUTIME_ID, CLOCK_PROCESS_CPUTIME_ID,
CLOCK_THREAD_CPUTIME_ID CLOCK_THREAD_CPUTIME_ID
} clockid_t; } clockid_t;
#endif // CLOCKID_T #endif // ifndef CLOCKID_T
struct timespec; struct timespec;

View file

@ -19,10 +19,13 @@
* http://www.gnu.org/copyleft/gpl.html * * http://www.gnu.org/copyleft/gpl.html *
***********************************************************************/ ***********************************************************************/
#include "clock_nanosleep.h"
#include <errno.h> // for errno, EINVAL #include <errno.h> // for errno, EINVAL
#include <time.h> // for nanosleep, NULL #include <time.h> // for nanosleep, NULL
#include "clock_nanosleep.h"
#ifdef MISSING_GETTIME
#include "../clock_gettime/clock_gettime.h" // for clock_gettime #include "../clock_gettime/clock_gettime.h" // for clock_gettime
#endif
int clock_nanosleep(clockid_t id, int flags, const struct timespec *ts, int clock_nanosleep(clockid_t id, int flags, const struct timespec *ts,
struct timespec *ots) { struct timespec *ots) {

View file

@ -1,6 +1,10 @@
#ifndef CLOCK_NANOSLEEP_H #ifndef CLOCK_NANOSLEEP_H
#define CLOCK_NANOSLEEP_H #define CLOCK_NANOSLEEP_H
#ifdef _CLOCKID_T_DEFINED_
#define CLOCKID_T
#endif
#ifndef CLOCKID_T #ifndef CLOCKID_T
#define CLOCKID_T #define CLOCKID_T
typedef enum typedef enum
@ -10,7 +14,8 @@ typedef enum
CLOCK_PROCESS_CPUTIME_ID, CLOCK_PROCESS_CPUTIME_ID,
CLOCK_THREAD_CPUTIME_ID CLOCK_THREAD_CPUTIME_ID
} clockid_t; } clockid_t;
#endif // CLOCKID_T #endif // ifndef CLOCKID_T
#ifndef TIMER_ABSTIME #ifndef TIMER_ABSTIME
#define TIMER_ABSTIME 1 #define TIMER_ABSTIME 1

View file

@ -7,11 +7,6 @@
#if defined(__APPLE__) #if defined(__APPLE__)
/* implementations of clock_gettime, clock_nanosleep */
#include "clock_gettime/clock_gettime.h"
#include "clock_nanosleep/clock_nanosleep.h"
/* /*
* Mach endian conversion * Mach endian conversion
*/ */
@ -29,4 +24,12 @@
#endif #endif
#ifdef MISSING_NANOSLEEP
#include "clock_nanosleep/clock_nanosleep.h"
#endif
#ifdef MISSING_GETTIME
#include "clock_gettime/clock_gettime.h"
#endif
#endif //COMPAT_UTIL_H #endif //COMPAT_UTIL_H

View file

@ -1316,7 +1316,7 @@ static int handleHTTPRequest(struct client *c, char *p) {
const char *statusmsg = "Internal Server Error"; const char *statusmsg = "Internal Server Error";
char *url, *content = NULL; char *url, *content = NULL;
char *ext; char *ext;
char *content_type; char *content_type = NULL;
int i; int i;
if (Modes.debug & MODES_DEBUG_NET) if (Modes.debug & MODES_DEBUG_NET)