Skip to content

Commit 5c78fb6

Browse files
check for unistd.h during CMake or with more-compatible checks
1 parent 3292c3a commit 5c78fb6

File tree

5 files changed

+14
-6
lines changed

5 files changed

+14
-6
lines changed

extensions/CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,10 @@ include(CheckIncludeFile)
9898
include(CheckCSourceCompiles)
9999
include(CheckCSourceRuns)
100100
include(CheckSymbolExists)
101-
CHECK_INCLUDE_FILE(stdbool.h HAVE_STDBOOL_H)
101+
CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H)
102102
CHECK_C_SOURCE_COMPILES(
103103
"int main() { __builtin_expect(0,0); return 0; }"
104104
HAVE___BUILTIN_EXPECT)
105-
CHECK_C_SOURCE_COMPILES("
106-
int f(void) __attribute__ (());
107-
int main() { return 0; }
108-
" HAVE___ATTRIBUTE__)
109105

110106
# Always compile with warnings
111107
if(MSVC)

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ include(CheckIncludeFile)
178178
include(CheckCSourceCompiles)
179179
include(CheckCSourceRuns)
180180
include(CheckSymbolExists)
181+
CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H)
181182
CHECK_C_SOURCE_COMPILES(
182183
"int main() { __builtin_expect(0,0); return 0; }"
183184
HAVE___BUILTIN_EXPECT)

src/config.h.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ extern "C" {
1111
typedef char bool;
1212
#endif
1313

14+
#cmakedefine HAVE_UNISTD_H
15+
1416
#cmakedefine HAVE___BUILTIN_EXPECT
1517

1618
#cmakedefine CMARK_THREADING

src/include/cmark-gfm_config.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ extern "C" {
1515
typedef char bool;
1616
#endif
1717

18+
#if defined(__has_include)
19+
# if __has_include(<unistd.h>)
20+
# define HAVE_UNISTD_H
21+
# endif
22+
#elif defined(unix) || defined(__unix__) || defined(__unix) || defined(__APPLE__)
23+
// Apple Clang does not define any of the unix symbols, even though it provides unistd.h
24+
# define HAVE_UNISTD_H
25+
#endif
26+
1827
#define HAVE___BUILTIN_EXPECT
1928

2029
#define CMARK_THREADING

src/include/mutex.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
#ifdef CMARK_THREADING
77

8-
#if __has_include(<unistd.h>)
8+
#ifdef HAVE_UNISTD_H
99
#include <unistd.h>
1010
#endif
1111

0 commit comments

Comments
 (0)