Skip to content

Commit 8341d6c

Browse files
committed
cmake: move regcomp and futimens checks to "features.h"
In our CMakeLists.txt, we have to check multiple functions in order to determine if we have to use our own or whether we can use the platform-provided one. For two of these functions, namely `regcomp_l()` and `futimens`, the defined macro is actually used inside of the header file "src/unix/posix.h". As such, these macros are not only required by the library, but also by our test suite, which is makes use of internal headers. To prepare for the CMakeLists.txt split, move these two defines inside of the "features.h" header.
1 parent a390a84 commit 8341d6c

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,12 +520,12 @@ ENDIF()
520520

521521
CHECK_SYMBOL_EXISTS(regcomp_l "regex.h;xlocale.h" HAVE_REGCOMP_L)
522522
IF (HAVE_REGCOMP_L)
523-
ADD_DEFINITIONS(-DHAVE_REGCOMP_L)
523+
SET(GIT_USE_REGCOMP_L 1)
524524
ENDIF ()
525525

526526
CHECK_FUNCTION_EXISTS(futimens HAVE_FUTIMENS)
527527
IF (HAVE_FUTIMENS)
528-
ADD_DEFINITIONS(-DHAVE_FUTIMENS)
528+
SET(GIT_USE_FUTIMENS 1)
529529
ENDIF ()
530530

531531
CHECK_FUNCTION_EXISTS(qsort_r HAVE_QSORT_R)

src/features.h.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#cmakedefine GIT_USE_STAT_MTIM 1
1515
#cmakedefine GIT_USE_STAT_MTIMESPEC 1
1616
#cmakedefine GIT_USE_STAT_MTIME_NSEC 1
17+
#cmakedefine GIT_USE_FUTIMENS 1
18+
#cmakedefine GIT_USE_REGCOMP_L 1
1719

1820
#cmakedefine GIT_SSH 1
1921
#cmakedefine GIT_SSH_MEMORY_CREDENTIALS 1

src/unix/posix.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ GIT_INLINE(int) p_fsync(int fd)
7272

7373
#define p_timeval timeval
7474

75-
#ifdef HAVE_FUTIMENS
75+
#ifdef GIT_USE_FUTIMENS
7676
GIT_INLINE(int) p_futimes(int f, const struct p_timeval t[2])
7777
{
7878
struct timespec s[2];
@@ -86,7 +86,7 @@ GIT_INLINE(int) p_futimes(int f, const struct p_timeval t[2])
8686
# define p_futimes futimes
8787
#endif
8888

89-
#ifdef HAVE_REGCOMP_L
89+
#ifdef GIT_USE_REGCOMP_L
9090
#include <xlocale.h>
9191
GIT_INLINE(int) p_regcomp(regex_t *preg, const char *pattern, int cflags)
9292
{

0 commit comments

Comments
 (0)