diff --git a/meson.build b/meson.build index e938537..6c77471 100644 --- a/meson.build +++ b/meson.build @@ -26,5 +26,35 @@ endif glib_dep = dependency('glib-2.0', version: glib_req, required: false) +thread_dep = dependency('threads', required: false) + +# Check if functions exist + +config = configuration_data() + +functions = { + 'fseeko': 'stdio.h', + 'realpath': 'stdlib.h', +} + +foreach function, include_file : functions + exists = cc.has_function( + function, + args: '-D_GNU_SOURCE', + prefix: '#include <@0@>'.format(include_file), + ) + config.set('HAVE_' + function.to_upper(), exists) +endforeach + +# Generate config.h + +config.set('FST_WRITER_PARALLEL', thread_dep.found()) +config.set('HAVE_LIBPTHREAD', thread_dep.found()) + +configure_file(output: 'config.h', configuration: config) +config_inc = include_directories('.') + +add_project_arguments('-DFST_INCLUDE_CONFIG', language: 'c') + subdir('src') subdir('tests') \ No newline at end of file diff --git a/src/fstapi.c b/src/fstapi.c index 197b907..465845d 100644 --- a/src/fstapi.c +++ b/src/fstapi.c @@ -37,10 +37,9 @@ * */ -// #ifndef FST_CONFIG_INCLUDE -// # define FST_CONFIG_INCLUDE -// #endif -// #include FST_CONFIG_INCLUDE +#ifdef FST_INCLUDE_CONFIG +#include +#endif #include "fstapi.h" #include "fastlz.h" @@ -60,21 +59,6 @@ #include #endif -#ifdef HAVE_ALLOCA_H -#include -#elif defined(__GNUC__) -#ifndef __MINGW32__ -#ifndef alloca -#define alloca __builtin_alloca -#endif -#else -#include -#endif -#elif defined(_MSC_VER) -#include -#define alloca _alloca -#endif - #ifndef PATH_MAX #define PATH_MAX (4096) #endif @@ -1748,8 +1732,9 @@ static void fstWriterFlushContextPrivate(fstWriterContext *xc) } #ifdef FST_WRITER_PARALLEL -static void *fstWriterFlushContextPrivate1(fstWriterContext *xc) +static void *fstWriterFlushContextPrivate1(void *ctx) { + struct fstWriterContext *xc = (struct fstWriterContext *)ctx; struct fstWriterContext *xc_parent; pthread_mutex_lock(&(xc->xc_parent->mutex)); @@ -5964,7 +5949,10 @@ static char *fstExtractRvatDataFromFrame(fstReaderContext *xc, fstHandle facidx, return (buf); } -char *fstReaderGetValueFromHandleAtTime(fstReaderContext *xc, uint64_t tim, fstHandle facidx, char *buf) +char *fstReaderGetValueFromHandleAtTime(fstReaderContext *xc, + uint64_t tim, + fstHandle facidx, + char *buf) { fst_off_t blkpos = 0, prev_blkpos; uint64_t beg_tim, end_tim, beg_tim2, end_tim2; diff --git a/src/meson.build b/src/meson.build index 208ba85..1987fa5 100644 --- a/src/meson.build +++ b/src/meson.build @@ -11,7 +11,7 @@ libfst_headers = [ libfst_dependencies = [ zlib_dep, bzip2_dep, - # thread_dep, + thread_dep, ] libfst = library( @@ -20,6 +20,7 @@ libfst = library( dependencies: libfst_dependencies, version: meson.project_version(), install: true, + include_directories: config_inc, ) libfst_dep = declare_dependency(