From af084de6f97fa24f49e527eeb8e18e16c541d827 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Mon, 1 Jul 2024 13:30:20 +0300 Subject: [PATCH] Add 'extern' statements to public headers for C++ compatibility --- cutils.h | 10 +++++++++- libbf.h | 8 ++++++++ libregexp.h | 8 ++++++++ libunicode.h | 8 ++++++++ list.h | 8 ++++++++ 5 files changed, 41 insertions(+), 1 deletion(-) diff --git a/cutils.h b/cutils.h index 26436d4..540deff 100644 --- a/cutils.h +++ b/cutils.h @@ -29,6 +29,10 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + #if defined(_WIN32) #include #endif @@ -212,7 +216,7 @@ static inline int clz64(uint64_t a) return clz32((unsigned)(a >> 32)); else return clz32((unsigned)a) + 32; -#endif +#endif #else return __builtin_clzll(a); #endif @@ -527,4 +531,8 @@ int js_cond_timedwait(js_cond_t *cond, js_mutex_t *mutex, uint64_t timeout); #endif /* !defined(EMSCRIPTEN) && !defined(__wasi__) */ +#ifdef __cplusplus +} /* extern "C" { */ +#endif + #endif /* CUTILS_H */ diff --git a/libbf.h b/libbf.h index d89d09c..bf797b3 100644 --- a/libbf.h +++ b/libbf.h @@ -27,6 +27,10 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + #if INTPTR_MAX >= INT64_MAX && !defined(_WIN32) && !defined(__TINYC__) #define LIMB_LOG2_BITS 6 #else @@ -532,4 +536,8 @@ static inline int bfdec_resize(bfdec_t *r, limb_t len) } int bfdec_normalize_and_round(bfdec_t *r, limb_t prec1, bf_flags_t flags); +#ifdef __cplusplus +} /* extern "C" { */ +#endif + #endif /* LIBBF_H */ diff --git a/libregexp.h b/libregexp.h index 1822f93..c2e664a 100644 --- a/libregexp.h +++ b/libregexp.h @@ -28,6 +28,10 @@ #include "libunicode.h" +#ifdef __cplusplus +extern "C" { +#endif + #define LRE_BOOL int /* for documentation purposes */ #define LRE_FLAG_GLOBAL (1 << 0) @@ -84,4 +88,8 @@ static inline int lre_js_is_ident_next(int c) #undef LRE_BOOL +#ifdef __cplusplus +} /* extern "C" { */ +#endif + #endif /* LIBREGEXP_H */ diff --git a/libunicode.h b/libunicode.h index 91cfbee..337ffdc 100644 --- a/libunicode.h +++ b/libunicode.h @@ -27,6 +27,10 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + #define LRE_BOOL int /* for documentation purposes */ #define LRE_CC_RES_LEN_MAX 3 @@ -115,4 +119,8 @@ int unicode_prop(CharRange *cr, const char *prop_name); #undef LRE_BOOL +#ifdef __cplusplus +} /* extern "C" { */ +#endif + #endif /* LIBUNICODE_H */ diff --git a/list.h b/list.h index 8098311..b8dd716 100644 --- a/list.h +++ b/list.h @@ -28,6 +28,10 @@ #include #endif +#ifdef __cplusplus +extern "C" { +#endif + struct list_head { struct list_head *prev; struct list_head *next; @@ -96,4 +100,8 @@ static inline int list_empty(struct list_head *el) for(el = (head)->prev, el1 = el->prev; el != (head); \ el = el1, el1 = el->prev) +#ifdef __cplusplus +} /* extern "C" { */ +#endif + #endif /* LIST_H */