Skip to content

Commit 9b9965b

Browse files
committed
config, os: add support for Musl libc
According to Musl's FAQ, `__BEGIN_DECLS` and `__END_DECLS` macros come from Glibc private headers. Because of that, we need to define them manually in case those aren't defined. Additionally, for Musl we need to override `HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME`, for which a corresponding `#ifndef` was added in `config.h`.
1 parent 469c8ec commit 9b9965b

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

config/config.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@
4747

4848
/* Define to 1 if you have the declaration of `program_invocation_short_name',
4949
and to 0 if you don't. */
50+
#ifndef HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
5051
#define HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME 0
52+
#endif
5153

5254
/* Define to 1 if you have the declaration of `SIGEMT', and to 0 if you don't.
5355
*/

os/generic_win_base.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,6 @@
2525
typedef int mode_t;
2626
typedef void pthread_attr_t;
2727

28-
#if defined(__cplusplus)
29-
#define __BEGIN_DECLS extern "C" {
30-
#define __END_DECLS }
31-
#else
32-
#define __BEGIN_DECLS
33-
#define __END_DECLS
34-
#endif
35-
3628
#ifndef API_AVAILABLE
3729
#define API_AVAILABLE(...)
3830
#endif

os/object.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@
2121
#ifndef __OS_OBJECT__
2222
#define __OS_OBJECT__
2323

24+
#if !defined(__BEGIN_DECLS) && !defined(__END_DECLS)
25+
#if defined(__cplusplus)
26+
#define __BEGIN_DECLS extern "C" {
27+
#define __END_DECLS }
28+
#else
29+
#define __BEGIN_DECLS
30+
#define __END_DECLS
31+
#endif
32+
#endif
33+
2434
#ifdef __APPLE__
2535
#include <Availability.h>
2636
#include <os/availability.h>

0 commit comments

Comments
 (0)