Skip to content

config, os: add support for Musl libc #771

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 3 commits into from
Jan 18, 2023
Merged
Show file tree
Hide file tree
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
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the unix and windows base.h versions just import generic_base.h?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see that they already do that. So we shouldn't need this additional install step then? Either way, doesn't hurt I guess.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this new header needs to be installed to be importable at the expected install location.

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this instead just be added to os/generic_unix_base.h instead? This seems a platform specific thing instead of moving it to os/object.h - this declaration has nothing to do with os objects.

Copy link
Contributor Author

@MaxDesiatov MaxDesiatov Jan 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was previously only needed for Windows, now it's needed for Musl-based Linux too. I moved it to a new <os/generic_base.h> header, I hope that addresses your feedback.

#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