Skip to content

config: generalise more things to be detected #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 10, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 15 additions & 45 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,28 @@
extern "C" {
#endif

#define HAVE_STDBOOL_H
#if !defined(__has_builtin)
#define __has_builtin(builtin) 0
#endif

#if !defined(__has_include)
#define __has_include(include) 0
#endif

#ifdef HAVE_STDBOOL_H
#if __STDC_VERSION__-0 >= 199901l || __has_include(<stdbool.h>)
#define HAVE_STDBOOL_H
#include <stdbool.h>
#elif !defined(__cplusplus)
typedef char bool;
#endif

#define HAVE___BUILTIN_EXPECT

#define HAVE___ATTRIBUTE__
#if __has_builtin(__builtin_expect)
#define HAVE___BUILTIN_EXPECT
#endif

#ifdef HAVE___ATTRIBUTE__
#define CMARK_ATTRIBUTE(list) __attribute__ (list)
#if defined(__GNUC__)
#define HAVE___ATTRIBUTE__
#define CMARK_ATTRIBUTE(list) __attribute__(list)
#else
#define CMARK_ATTRIBUTE(list)
#endif
Expand All @@ -31,44 +39,6 @@ extern "C" {
#endif
#endif

/* snprintf and vsnprintf fallbacks for MSVC before 2015,
due to Valentin Milea http://stackoverflow.com/questions/2915672/
*/

#if defined(_MSC_VER) && _MSC_VER < 1900

#include <stdio.h>
#include <stdarg.h>

#define snprintf c99_snprintf
#define vsnprintf c99_vsnprintf

CMARK_INLINE int c99_vsnprintf(char *outBuf, size_t size, const char *format, va_list ap)
{
int count = -1;

if (size != 0)
count = _vsnprintf_s(outBuf, size, _TRUNCATE, format, ap);
if (count == -1)
count = _vscprintf(format, ap);

return count;
}

CMARK_INLINE int c99_snprintf(char *outBuf, size_t size, const char *format, ...)
{
int count;
va_list ap;

va_start(ap, format);
count = c99_vsnprintf(outBuf, size, format, ap);
va_end(ap);

return count;
}

#endif

#ifdef __cplusplus
}
#endif
Expand Down