@@ -1133,11 +1133,6 @@ else
1133
1133
build_options_config.set(' NO_UNIX_SOCKETS' , ' 1' )
1134
1134
endif
1135
1135
1136
- if not compiler.has_function(' pread' )
1137
- libgit_c_args += ' -DNO_PREAD'
1138
- libgit_sources += ' compat/pread.c'
1139
- endif
1140
-
1141
1136
if host_machine .system() == ' darwin'
1142
1137
libgit_sources += ' compat/precompose_utf8.c'
1143
1138
libgit_c_args += ' -DPRECOMPOSE_UNICODE'
@@ -1290,77 +1285,55 @@ if not compiler.has_member('struct passwd', 'pw_gecos', prefix: '#include <pwd.h
1290
1285
libgit_c_args += ' -DNO_GECOS_IN_PWENT'
1291
1286
endif
1292
1287
1293
- if compiler.has_function(' sync_file_range' )
1294
- libgit_c_args += ' -DHAVE_SYNC_FILE_RANGE'
1295
- endif
1288
+ checkfuncs = {
1289
+ ' strcasestr' : [' strcasestr.c' ],
1290
+ ' memmem' : [' memmem.c' ],
1291
+ ' strlcpy' : [' strlcpy.c' ],
1292
+ ' strtoull' : [],
1293
+ ' setenv' : [' setenv.c' ],
1294
+ ' mkdtemp' : [' mkdtemp.c' ],
1295
+ ' initgroups' : [],
1296
+ ' strtoumax' : [' strtoumax.c' , ' strtoimax.c' ],
1297
+ ' pread' : [' pread.c' ],
1298
+ }
1296
1299
1297
- if not compiler.has_function(' strcasestr' )
1298
- libgit_c_args += ' -DNO_STRCASESTR'
1299
- libgit_sources += ' compat/strcasestr.c'
1300
+ if host_machine .system() == ' windows'
1301
+ libgit_c_args += ' -DUSE_WIN32_MMAP'
1302
+ else
1303
+ checkfuncs += {
1304
+ ' mmap' : [' mmap.c' ],
1305
+ # provided by compat/mingw.c.
1306
+ ' unsetenv' : [' unsetenv.c' ],
1307
+ }
1300
1308
endif
1301
1309
1302
- if not compiler.has_function(' memmem' )
1303
- libgit_c_args += ' -DNO_MEMMEM'
1304
- libgit_sources += ' compat/memmem.c'
1305
- endif
1310
+ foreach func, impls : checkfuncs
1311
+ if not compiler.has_function(func)
1312
+ libgit_c_args += ' -DNO_' + func.to_upper()
1313
+ foreach impl : impls
1314
+ libgit_sources += ' compat/' + impl
1315
+ endforeach
1316
+ endif
1317
+ endforeach
1306
1318
1307
- if not compiler.has_function(' strlcpy' )
1308
- libgit_c_args += ' -DNO_STRLCPY'
1309
- libgit_sources += ' compat/strlcpy.c'
1319
+ if compiler.has_function(' sync_file_range' )
1320
+ libgit_c_args += ' -DHAVE_SYNC_FILE_RANGE'
1310
1321
endif
1311
1322
1312
1323
if not compiler.has_function(' strdup' )
1313
1324
libgit_c_args += ' -DOVERRIDE_STRDUP'
1314
1325
libgit_sources += ' compat/strdup.c'
1315
1326
endif
1316
1327
1317
- if not compiler.has_function(' strtoumax' )
1318
- libgit_c_args += ' -DNO_STRTOUMAX'
1319
- libgit_sources += [
1320
- ' compat/strtoumax.c' ,
1321
- ' compat/strtoimax.c' ,
1322
- ]
1323
- endif
1324
-
1325
- if not compiler.has_function(' strtoull' )
1326
- libgit_c_args += ' -DNO_STRTOULL'
1327
- endif
1328
-
1329
- if not compiler.has_function(' setenv' )
1330
- libgit_c_args += ' -DNO_SETENV'
1331
- libgit_sources += ' compat/setenv.c'
1332
- endif
1333
-
1334
1328
if not compiler.has_function(' qsort' )
1335
1329
libgit_c_args += ' -DINTERNAL_QSORT'
1336
1330
endif
1337
1331
libgit_sources += ' compat/qsort_s.c'
1338
1332
1339
- # unsetenv is provided by compat/mingw.c.
1340
- if host_machine .system() != ' windows' and not compiler.has_function(' unsetenv' )
1341
- libgit_c_args += ' -DNO_UNSETENV'
1342
- libgit_sources += ' compat/unsetenv.c'
1343
- endif
1344
-
1345
- if not compiler.has_function(' mkdtemp' )
1346
- libgit_c_args += ' -DNO_MKDTEMP'
1347
- libgit_sources += ' compat/mkdtemp.c'
1348
- endif
1349
-
1350
- if not compiler.has_function(' initgroups' )
1351
- libgit_c_args += ' -DNO_INITGROUPS'
1352
- endif
1353
-
1354
1333
if compiler.has_function(' getdelim' )
1355
1334
libgit_c_args += ' -DHAVE_GETDELIM'
1356
1335
endif
1357
1336
1358
- if host_machine .system() == ' windows'
1359
- libgit_c_args += ' -DUSE_WIN32_MMAP'
1360
- elif not compiler.has_function(' mmap' )
1361
- libgit_c_args += ' -DNO_MMAP'
1362
- libgit_sources += ' compat/mmap.c'
1363
- endif
1364
1337
1365
1338
if compiler.has_function(' clock_gettime' )
1366
1339
libgit_c_args += ' -DHAVE_CLOCK_GETTIME'
0 commit comments