As reported in https://bugs.freebsd.org/271234, recent versions of FreeBSD have adjusted the prototype for qsort_r() to match the POSIX interface. This causes libgit2's CMake configuration check to fail to detect qsort_r(), making it fall back to qsort_s(), which in libgit2 also has an incompatible interface. With recent versions of clang this results in a "incompatible function pointer types" compile error. Summarizing, there are four variations of 'qsort-with-context': * old style BSD qsort_r(), used in FreeBSD 13 and earlier, where the comparison function has the context parameter first * GNU or POSIX qsort_r(), also used in FreeBSD 14 and later, where the comparison function has the context parameter last * C11 qsort_s(), where the comparison function has the context parameter last * Microsoft qsort_s(), where the comparison function has the context parameter first Add explicit detections for all these variants, so they get detected as (in the same order as above): * `GIT_QSORT_R_BSD` * `GIT_QSORT_R_GNU` * `GIT_QSORT_S_C11` * `GIT_QSORT_S_MSC` An additional complication is that on FreeBSD 14 and later, <stdlib.h> uses the C11 _Generic() macro mechanism to automatically select the correct qsort_r() prototype, depending on the caller's comparison function argument. This breaks CMake's check_prototype_definition() functionality, since it tries to redefine the function, and _Generic macro is expanded inline causing a compile error. Work around that problem by putting the function names in parentheses, to prevent the preprocessor from using a macro to replace the function name. Also, in `git__qsort_r()`, change the `#if` order so the variants that do not have to use glue are preferred.
Name |
Last commit
|
Last update |
---|---|---|
.. | ||
allocators | Loading commit data... | |
hash | Loading commit data... | |
unix | Loading commit data... | |
win32 | Loading commit data... | |
CMakeLists.txt | Loading commit data... | |
alloc.c | Loading commit data... | |
alloc.h | Loading commit data... | |
array.h | Loading commit data... | |
assert_safe.h | Loading commit data... | |
bitvec.h | Loading commit data... | |
cc-compat.h | Loading commit data... | |
date.c | Loading commit data... | |
date.h | Loading commit data... | |
filebuf.c | Loading commit data... | |
filebuf.h | Loading commit data... | |
fs_path.c | Loading commit data... | |
fs_path.h | Loading commit data... | |
futils.c | Loading commit data... | |
futils.h | Loading commit data... | |
git2_features.h.in | Loading commit data... | |
git2_util.h | Loading commit data... | |
hash.c | Loading commit data... | |
hash.h | Loading commit data... | |
integer.h | Loading commit data... | |
khash.h | Loading commit data... | |
map.h | Loading commit data... | |
net.c | Loading commit data... | |
net.h | Loading commit data... | |
pool.c | Loading commit data... | |
pool.h | Loading commit data... | |
posix.c | Loading commit data... | |
posix.h | Loading commit data... | |
pqueue.c | Loading commit data... | |
pqueue.h | Loading commit data... | |
rand.c | Loading commit data... | |
rand.h | Loading commit data... | |
regexp.c | Loading commit data... | |
regexp.h | Loading commit data... | |
runtime.c | Loading commit data... | |
runtime.h | Loading commit data... | |
sortedcache.c | Loading commit data... | |
sortedcache.h | Loading commit data... | |
str.c | Loading commit data... | |
str.h | Loading commit data... | |
strmap.c | Loading commit data... | |
strmap.h | Loading commit data... | |
strnlen.h | Loading commit data... | |
thread.c | Loading commit data... | |
thread.h | Loading commit data... | |
tsort.c | Loading commit data... | |
utf8.c | Loading commit data... | |
utf8.h | Loading commit data... | |
util.c | Loading commit data... | |
util.h | Loading commit data... | |
varint.c | Loading commit data... | |
varint.h | Loading commit data... | |
vector.c | Loading commit data... | |
vector.h | Loading commit data... | |
wildmatch.c | Loading commit data... | |
wildmatch.h | Loading commit data... | |
zstream.c | Loading commit data... | |
zstream.h | Loading commit data... |