From 39eb2f81c62232c19b685e1808f6584851d4c27a Mon Sep 17 00:00:00 2001 From: Ralf Fuest Date: Sun, 30 Mar 2025 16:23:23 +0200 Subject: [PATCH 1/3] Fix build with FST_WRITER_PARALLEL enabled --- meson.build | 13 +++++++++++++ src/fstapi.c | 15 +++++++++------ src/meson.build | 3 ++- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/meson.build b/meson.build index e938537..a524228 100644 --- a/meson.build +++ b/meson.build @@ -26,5 +26,18 @@ endif glib_dep = dependency('glib-2.0', version: glib_req, required: false) +thread_dep = dependency('threads', required: false) + +# Generate config.h + +config = configuration_data() +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..abfa1ce 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" @@ -1748,8 +1747,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 +5964,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( From 356c2a5ae3eed90d514182b3f72ee553a9daff76 Mon Sep 17 00:00:00 2001 From: Ralf Fuest Date: Sun, 30 Mar 2025 16:25:07 +0200 Subject: [PATCH 2/3] Remove unused alloca imports --- src/fstapi.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/fstapi.c b/src/fstapi.c index abfa1ce..465845d 100644 --- a/src/fstapi.c +++ b/src/fstapi.c @@ -59,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 From 56176de896607633ec33a0abd3aca3a6f09b9f98 Mon Sep 17 00:00:00 2001 From: Ralf Fuest Date: Sun, 30 Mar 2025 16:44:56 +0200 Subject: [PATCH 3/3] Check if fseeko and realpath exist --- meson.build | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index a524228..6c77471 100644 --- a/meson.build +++ b/meson.build @@ -28,16 +28,33 @@ glib_dep = dependency('glib-2.0', version: glib_req, required: false) thread_dep = dependency('threads', required: false) -# Generate config.h +# 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') +add_project_arguments('-DFST_INCLUDE_CONFIG', language: 'c') subdir('src') subdir('tests') \ No newline at end of file