Skip to content

Commit

Permalink
Merge pull request #220 from jbeich/freebsd
Browse files Browse the repository at this point in the history
Unbreak build on FreeBSD
  • Loading branch information
elFarto authored Feb 11, 2024
2 parents 3eb412e + f0025c4 commit a28ffbb
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/direct/direct-export-buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
#include <sys/ioctl.h>
#include <fcntl.h>
#include <unistd.h>
#ifdef __linux__
#include <sys/sysmacros.h>
#endif
#include <string.h>
#include "../backend-common.h"

Expand Down
8 changes: 8 additions & 0 deletions src/direct/nv-driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@

#include "../vabackend.h"

#if !defined(_IOC_READ) && defined(IOC_OUT)
#define _IOC_READ IOC_OUT
#endif

#if !defined(_IOC_WRITE) && defined(IOC_IN)
#define _IOC_WRITE IOC_IN
#endif

//Technically these can vary per architecture, but all the ones we support have the same values
#define GOB_WIDTH_IN_BYTES 64
#define GOB_HEIGHT_IN_BYTES 8
Expand Down
2 changes: 2 additions & 0 deletions src/export-buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
#include <sys/ioctl.h>
#include <fcntl.h>
#include <unistd.h>
#ifdef __linux__
#include <sys/sysmacros.h>
#endif

#include <drm.h>
#include <drm_fourcc.h>
Expand Down
8 changes: 7 additions & 1 deletion src/hevc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
#include "vabackend.h"
#include <stdlib.h>

#if !defined(__GLIBC__)
#if defined(__FreeBSD__) && __FreeBSD__ < 14
// https://github.com/freebsd/freebsd-src/commit/af3c78886fd8
typedef int (*__old_compar_d_fn_t) (void *, const void *, const void *);
#define qsort_r(base, nmemb, size, compar, thunk) \
qsort_r(base, nmemb, size, thunk, (__old_compar_d_fn_t)compar)

#elif !defined(__GLIBC__)
typedef int (*__compar_d_fn_t) (const void *, const void *, void *);
#endif

Expand Down
11 changes: 10 additions & 1 deletion src/vabackend.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@
#define __has_builtin(x) 0
#endif

#ifndef __has_include
#define __has_include(x) 0
#endif

#if __has_include(<pthread_np.h>)
#include <pthread_np.h>
#define gettid pthread_getthreadid_np
#endif

static pthread_mutex_t concurrency_mutex = PTHREAD_MUTEX_INITIALIZER;
static uint32_t instances;
static uint32_t max_instances;
Expand Down Expand Up @@ -167,7 +176,7 @@ void logger(const char *filename, const char *function, int line, const char *ms
struct timespec tp;
clock_gettime(CLOCK_MONOTONIC, &tp);

fprintf(LOG_OUTPUT, "%10ld.%09ld [%d-%d] %s:%4d %24s %s\n", tp.tv_sec, tp.tv_nsec, getpid(), gettid(), filename, line, function, formattedMessage);
fprintf(LOG_OUTPUT, "%10ld.%09ld [%d-%d] %s:%4d %24s %s\n", (long)tp.tv_sec, tp.tv_nsec, getpid(), gettid(), filename, line, function, formattedMessage);
fflush(LOG_OUTPUT);
}

Expand Down

0 comments on commit a28ffbb

Please sign in to comment.