From: Eli Schwartz Date: Fri, 25 Apr 2025 05:25:40 GMT Subject: [PATCH v3 1/6] meson: simplify and parameterize various standard function checks Message-ID: <20250425053345.17288-2-eschwartz@gentoo.org> In-Reply-To: <20250425053345.17288-1-eschwartz@gentoo.org> This is repetitive logic. We either want to use some -lc function, or if it is not available we define it as -DNO_XXX and usually (but not always) provide some custom compatibility impl instead. Checking the intent of each block when reading through the file is slow and not very DRY. Switch to taking an array of checkable functions instead. Not all functions are straightforward to move, since different macro prefixes are used. Signed-off-by: Eli Schwartz --- v3: - use a dictionary for checkfuncs, and list the filenames - now we can handle strtoumax too, so, do that - pread was overlooked previously; move it down and handle it with the other function checks meson.build | 85 ++++++++++++++++++----------------------------------- 1 file changed, 29 insertions(+), 56 deletions(-) diff --git a/meson.build b/meson.build index c47cb79af0..ed0359b9c9 100644 --- a/meson.build +++ b/meson.build @@ -1133,11 +1133,6 @@ else build_options_config.set('NO_UNIX_SOCKETS', '1') endif -if not compiler.has_function('pread') - libgit_c_args += '-DNO_PREAD' - libgit_sources += 'compat/pread.c' -endif - if host_machine.system() == 'darwin' libgit_sources += 'compat/precompose_utf8.c' libgit_c_args += '-DPRECOMPOSE_UNICODE' @@ -1290,23 +1285,39 @@ if not compiler.has_member('struct passwd', 'pw_gecos', prefix: '#include