Skip to content

Commit 6242e80

Browse files
authored
Merge pull request #771 from apple/maxd/musl-support
config, os: add support for Musl libc According to Musl's FAQ document, `__BEGIN_DECLS` and `__END_DECLS` macros come from Glibc private headers, thus we need to define them manually in case those aren't defined.
2 parents 469c8ec + ca40df0 commit 6242e80

File tree

5 files changed

+41
-10
lines changed

5 files changed

+41
-10
lines changed

dispatch/source.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#endif
3333

3434
#if !defined(_WIN32)
35-
#include <sys/signal.h>
35+
#include <signal.h>
3636
#endif
3737

3838
DISPATCH_ASSUME_NONNULL_BEGIN

os/CMakeLists.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
# voucher_private.h are included in the source tarball
44

55
install(FILES
6-
object.h
6+
generic_base.h
77
generic_unix_base.h
88
generic_win_base.h
9+
object.h
910
DESTINATION
1011
"${INSTALL_OS_HEADERS_DIR}")
1112

os/generic_base.h

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (c) 2011-2014 Apple Inc. All rights reserved.
3+
*
4+
* @APPLE_APACHE_LICENSE_HEADER_START@
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* @APPLE_APACHE_LICENSE_HEADER_END@
19+
*/
20+
21+
#ifndef __OS_GENERIC_BASE__
22+
#define __OS_GENERIC_BASE__
23+
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+
34+
#endif /* __OS_GENERIC_BASE__ */

os/generic_unix_base.h

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#ifndef __OS_GENERIC_UNIX_BASE__
1414
#define __OS_GENERIC_UNIX_BASE__
1515

16+
#include <os/generic_base.h>
17+
1618
#if __has_include(<sys/sysmacros.h>)
1719
#include <sys/sysmacros.h>
1820
#endif

os/generic_win_base.h

+2-8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#ifndef __OS_GENERIC_WIN_BASE__
1414
#define __OS_GENERIC_WIN_BASE__
1515

16+
#include <os/generic_base.h>
17+
1618
// Unices provide `roundup` via sys/param.h
1719
#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
1820
// Unices provide `MAX` via sys/param.h
@@ -25,14 +27,6 @@
2527
typedef int mode_t;
2628
typedef void pthread_attr_t;
2729

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-
3630
#ifndef API_AVAILABLE
3731
#define API_AVAILABLE(...)
3832
#endif

0 commit comments

Comments
 (0)