5
5
extern "C" {
6
6
#endif
7
7
8
- #define HAVE_STDBOOL_H
8
+ #if !defined(__has_builtin )
9
+ #define __has_builtin (builtin ) 0
10
+ #endif
11
+
12
+ #if !defined(__has_include )
13
+ #define __has_include (include ) 0
14
+ #endif
9
15
10
- #ifdef HAVE_STDBOOL_H
16
+ #if __STDC_VERSION__ - 0 >= 199901l || __has_include (< stdbool .h > )
17
+ #define HAVE_STDBOOL_H
11
18
#include <stdbool.h>
12
19
#elif !defined(__cplusplus )
13
20
typedef char bool ;
14
21
#endif
15
22
16
- #define HAVE___BUILTIN_EXPECT
17
-
18
- #define HAVE___ATTRIBUTE__
23
+ #if __has_builtin ( __builtin_expect )
24
+ #define HAVE___BUILTIN_EXPECT
25
+ #endif
19
26
20
- #ifdef HAVE___ATTRIBUTE__
21
- #define CMARK_ATTRIBUTE (list ) __attribute__ (list)
27
+ #if defined(__GNUC__ )
28
+ #define HAVE___ATTRIBUTE__
29
+ #define CMARK_ATTRIBUTE (list ) __attribute__(list)
22
30
#else
23
31
#define CMARK_ATTRIBUTE (list )
24
32
#endif
@@ -31,44 +39,6 @@ extern "C" {
31
39
#endif
32
40
#endif
33
41
34
- /* snprintf and vsnprintf fallbacks for MSVC before 2015,
35
- due to Valentin Milea http://stackoverflow.com/questions/2915672/
36
- */
37
-
38
- #if defined(_MSC_VER ) && _MSC_VER < 1900
39
-
40
- #include <stdio.h>
41
- #include <stdarg.h>
42
-
43
- #define snprintf c99_snprintf
44
- #define vsnprintf c99_vsnprintf
45
-
46
- CMARK_INLINE int c99_vsnprintf (char * outBuf , size_t size , const char * format , va_list ap )
47
- {
48
- int count = -1 ;
49
-
50
- if (size != 0 )
51
- count = _vsnprintf_s (outBuf , size , _TRUNCATE , format , ap );
52
- if (count == -1 )
53
- count = _vscprintf (format , ap );
54
-
55
- return count ;
56
- }
57
-
58
- CMARK_INLINE int c99_snprintf (char * outBuf , size_t size , const char * format , ...)
59
- {
60
- int count ;
61
- va_list ap ;
62
-
63
- va_start (ap , format );
64
- count = c99_vsnprintf (outBuf , size , format , ap );
65
- va_end (ap );
66
-
67
- return count ;
68
- }
69
-
70
- #endif
71
-
72
42
#ifdef __cplusplus
73
43
}
74
44
#endif
0 commit comments