Skip to content

Commit

Permalink
Merge pull request #771 from apple/maxd/musl-support
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MaxDesiatov authored Jan 18, 2023
2 parents 469c8ec + ca40df0 commit 6242e80
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 10 deletions.
2 changes: 1 addition & 1 deletion dispatch/source.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#endif

#if !defined(_WIN32)
#include <sys/signal.h>
#include <signal.h>
#endif

DISPATCH_ASSUME_NONNULL_BEGIN
Expand Down
3 changes: 2 additions & 1 deletion os/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
# voucher_private.h are included in the source tarball

install(FILES
object.h
generic_base.h
generic_unix_base.h
generic_win_base.h
object.h
DESTINATION
"${INSTALL_OS_HEADERS_DIR}")

34 changes: 34 additions & 0 deletions os/generic_base.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2011-2014 Apple Inc. All rights reserved.
*
* @APPLE_APACHE_LICENSE_HEADER_START@
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @APPLE_APACHE_LICENSE_HEADER_END@
*/

#ifndef __OS_GENERIC_BASE__
#define __OS_GENERIC_BASE__

#if !defined(__BEGIN_DECLS) && !defined(__END_DECLS)
#if defined(__cplusplus)
#define __BEGIN_DECLS extern "C" {
#define __END_DECLS }
#else
#define __BEGIN_DECLS
#define __END_DECLS
#endif
#endif

#endif /* __OS_GENERIC_BASE__ */
2 changes: 2 additions & 0 deletions os/generic_unix_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#ifndef __OS_GENERIC_UNIX_BASE__
#define __OS_GENERIC_UNIX_BASE__

#include <os/generic_base.h>

#if __has_include(<sys/sysmacros.h>)
#include <sys/sysmacros.h>
#endif
Expand Down
10 changes: 2 additions & 8 deletions os/generic_win_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#ifndef __OS_GENERIC_WIN_BASE__
#define __OS_GENERIC_WIN_BASE__

#include <os/generic_base.h>

// Unices provide `roundup` via sys/param.h
#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
// Unices provide `MAX` via sys/param.h
Expand All @@ -25,14 +27,6 @@
typedef int mode_t;
typedef void pthread_attr_t;

#if defined(__cplusplus)
#define __BEGIN_DECLS extern "C" {
#define __END_DECLS }
#else
#define __BEGIN_DECLS
#define __END_DECLS
#endif

#ifndef API_AVAILABLE
#define API_AVAILABLE(...)
#endif
Expand Down

0 comments on commit 6242e80

Please sign in to comment.