Skip to content

Commit 19e99de

Browse files
committed
cmake: qsort detection in features.h
1 parent d3a7a35 commit 19e99de

File tree

3 files changed

+15
-20
lines changed

3 files changed

+15
-20
lines changed

src/CMakeLists.txt

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,22 +50,13 @@ add_feature_info(futimens GIT_USE_FUTIMENS "futimens support")
5050

5151
check_prototype_definition(qsort_r
5252
"void qsort_r(void *base, size_t nmemb, size_t size, void *thunk, int (*compar)(void *, const void *, const void *))"
53-
"" "stdlib.h" HAVE_QSORT_R_BSD)
54-
if(HAVE_QSORT_R_BSD)
55-
target_compile_definitions(git2internal PRIVATE HAVE_QSORT_R_BSD)
56-
endif()
53+
"" "stdlib.h" GIT_QSORT_R_BSD)
5754

5855
check_prototype_definition(qsort_r
5956
"void qsort_r(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *, void *), void *arg)"
60-
"" "stdlib.h" HAVE_QSORT_R_GNU)
61-
if(HAVE_QSORT_R_GNU)
62-
target_compile_definitions(git2internal PRIVATE HAVE_QSORT_R_GNU)
63-
endif()
57+
"" "stdlib.h" GIT_QSORT_R_GNU)
6458

65-
check_function_exists(qsort_s HAVE_QSORT_S)
66-
if(HAVE_QSORT_S)
67-
target_compile_definitions(git2internal PRIVATE HAVE_QSORT_S)
68-
endif()
59+
check_function_exists(qsort_s GIT_QSORT_S)
6960

7061
# Find required dependencies
7162

src/features.h.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
#cmakedefine GIT_REGEX_PCRE2
2525
#cmakedefine GIT_REGEX_BUILTIN 1
2626

27+
#cmakedefine GIT_QSORT_R_BSD
28+
#cmakedefine GIT_QSORT_R_GNU
29+
#cmakedefine GIT_QSORT_S
30+
2731
#cmakedefine GIT_SSH 1
2832
#cmakedefine GIT_SSH_MEMORY_CREDENTIALS 1
2933

src/util.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# endif
1919
# include <windows.h>
2020

21-
# ifdef HAVE_QSORT_S
21+
# ifdef GIT_QSORT_S
2222
# include <search.h>
2323
# endif
2424
#endif
@@ -673,7 +673,7 @@ size_t git__unescape(char *str)
673673
return (pos - str);
674674
}
675675

676-
#if defined(HAVE_QSORT_S) || defined(HAVE_QSORT_R_BSD)
676+
#if defined(GIT_QSORT_S) || defined(GIT_QSORT_R_BSD)
677677
typedef struct {
678678
git__sort_r_cmp cmp;
679679
void *payload;
@@ -688,9 +688,9 @@ static int GIT_LIBGIT2_CALL git__qsort_r_glue_cmp(
688688
#endif
689689

690690

691-
#if !defined(HAVE_QSORT_R_BSD) && \
692-
!defined(HAVE_QSORT_R_GNU) && \
693-
!defined(HAVE_QSORT_S)
691+
#if !defined(GIT_QSORT_R_BSD) && \
692+
!defined(GIT_QSORT_R_GNU) && \
693+
!defined(GIT_QSORT_S)
694694
static void swap(uint8_t *a, uint8_t *b, size_t elsize)
695695
{
696696
char tmp[256];
@@ -721,12 +721,12 @@ static void insertsort(
721721
void git__qsort_r(
722722
void *els, size_t nel, size_t elsize, git__sort_r_cmp cmp, void *payload)
723723
{
724-
#if defined(HAVE_QSORT_R_BSD)
724+
#if defined(GIT_QSORT_R_BSD)
725725
git__qsort_r_glue glue = { cmp, payload };
726726
qsort_r(els, nel, elsize, &glue, git__qsort_r_glue_cmp);
727-
#elif defined(HAVE_QSORT_R_GNU)
727+
#elif defined(GIT_QSORT_R_GNU)
728728
qsort_r(els, nel, elsize, cmp, payload);
729-
#elif defined(HAVE_QSORT_S)
729+
#elif defined(GIT_QSORT_S)
730730
git__qsort_r_glue glue = { cmp, payload };
731731
qsort_s(els, nel, elsize, git__qsort_r_glue_cmp, &glue);
732732
#else

0 commit comments

Comments
 (0)