From af8ecb86328e93f56a75bfcda6019015962999e0 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Tue, 19 Nov 2024 18:03:22 +0100 Subject: [PATCH] [meson] check for open_memstream --- config2.h.in | 3 +++ meson.build | 4 ++++ src/js/quickjs.c | 2 ++ 3 files changed, 9 insertions(+) diff --git a/config2.h.in b/config2.h.in index b0b932deb..da26a3d03 100644 --- a/config2.h.in +++ b/config2.h.in @@ -548,6 +548,9 @@ /* Define if you have off_t */ #mesondefine HAVE_OFF_T +/* Define if you have the `open_memstream' function. */ +#mesondefine HAVE_OPEN_MEMSTREAM + /* Define to 1 if you have the `poll' function. */ #mesondefine HAVE_POLL diff --git a/meson.build b/meson.build index 6afdcf9db..c27051386 100644 --- a/meson.build +++ b/meson.build @@ -1116,6 +1116,10 @@ if compiler.has_function('strtoul', prefix: '#include ') conf_data.set('HAVE_STRTOUL', 1) endif +if compiler.has_function('open_memstream', prefix: '#include ') + conf_data.set('HAVE_OPEN_MEMSTREAM', 1) +endif + if compiler.compiles('int a; typeof(a) b;', name: 'typeof') conf_data.set('HAVE_TYPEOF', 1) endif diff --git a/src/js/quickjs.c b/src/js/quickjs.c index b3a41562c..a649391e4 100644 --- a/src/js/quickjs.c +++ b/src/js/quickjs.c @@ -80,6 +80,7 @@ void *map_interp; static void quickjs_get_version(char *quickjs_version) { +#ifdef HAVE_OPEN_MEMSTREAM char *ptr = NULL; size_t size = 0; FILE *f = open_memstream(&ptr, &size); @@ -108,6 +109,7 @@ quickjs_get_version(char *quickjs_version) } free(ptr); } +#endif } static const char *