Skip to content
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

Add a musl compatible fallback for libc detection on Linux #1072

Closed
wants to merge 4 commits into from
Closed
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
10 changes: 5 additions & 5 deletions ACE/ace/Dev_Poll_Reactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1122,10 +1122,10 @@ ACE_Dev_Poll_Reactor::dispatch_io_event (Token_Guard &guard)

// Define bits to check for while dispatching.
#if defined (ACE_HAS_EVENT_POLL)
const __uint32_t out_event = EPOLLOUT;
drandreas marked this conversation as resolved.
Show resolved Hide resolved
const __uint32_t exc_event = EPOLLPRI;
const __uint32_t in_event = EPOLLIN;
const __uint32_t err_event = EPOLLHUP | EPOLLERR;
const ACE_UINT32 out_event = EPOLLOUT;
const ACE_UINT32 exc_event = EPOLLPRI;
const ACE_UINT32 in_event = EPOLLIN;
const ACE_UINT32 err_event = EPOLLHUP | EPOLLERR;
#else
const short out_event = POLLOUT;
const short exc_event = POLLPRI;
Expand All @@ -1138,7 +1138,7 @@ ACE_Dev_Poll_Reactor::dispatch_io_event (Token_Guard &guard)
// is invalid, there's no event there. Else process it. In any event, we
// have the event, so clear event_ for the next thread.
const ACE_HANDLE handle = this->event_.data.fd;
__uint32_t revents = this->event_.events;
ACE_UINT32 revents = this->event_.events;
this->event_.data.fd = ACE_INVALID_HANDLE;
this->event_.events = 0;
if (handle != ACE_INVALID_HANDLE)
Expand Down
42 changes: 42 additions & 0 deletions ACE/ace/config-linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,48 @@

#endif /* __UCLIBC__ */

// To support musl (note: musl devs refuse to add a __MUSL__)
#if defined (ACE_HAS_MUSL)

// Enable stuff that musl definitly has
#define ACE_HAS_UCONTEXT_T
#define ACE_HAS_SIGTIMEDWAIT
#define ACE_HAS_PTHREADS
#define ACE_HAS_RECURSIVE_MUTEXES
#define ACE_HAS_PTHREADS_UNIX98_EXT
#define ACE_HAS_CPU_SET_T
#define ACE_HAS_SIGINFO_T
#define ACE_HAS_SOCKLEN_T

// Mask some features musl lacks
#define ACE_LACKS_SIGINFO_H
#define ACE_LACKS_SYS_SYSCTL_H
#define ACE_LACKS_ISCTYPE
#define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS

// Following the example set by uclib undef some festures
Copy link
Member

Choose a reason for hiding this comment

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

I think would be better to actually fix these instead, which would benefit the ulibc support too. For example ACE_SCANDIR_CMP_USES_VOIDPTR up on line 112 looks like it's just assuming __GLIBC__ is defined, so that could be fixed by adding an check for defined (__GLIBC__) before trying to use it.

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 do not feel competent enough to perform this task. I would be thankful if this could be handled in another PR by someone else.

Copy link
Member

Choose a reason for hiding this comment

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

That's understandable. ACE is a labyrinth of macros.

# if defined (ACE_SCANDIR_CMP_USES_VOIDPTR)
# undef ACE_SCANDIR_CMP_USES_VOIDPTR
# endif /* ACE_SCANDIR_CMP_USES_VOIDPTR */

# if defined (ACE_SCANDIR_CMP_USES_CONST_VOIDPTR)
# undef ACE_SCANDIR_CMP_USES_CONST_VOIDPTR
# endif /* ACE_SCANDIR_CMP_USES_CONST_VOIDPTR */

# if defined(__GLIBC__)
# undef __GLIBC__
# endif /* __GLIBC__ */

# if defined(ACE_HAS_SEMUN)
# undef ACE_HAS_SEMUN
# endif /* ACE_HAS_SEMUN */

#endif /* ACE_HAS_MUSL */

#if !defined (__GLIBC__) && !defined (__UCLIBC__) && !defined (ACE_HAS_MUSL)
# error "Could not determine C Standard Library"
#endif /* !defined (__GLIBC__) && !defined (__UCLIBC__) && !defined (ACE_HAS_MUSL) */

#include /**/ "ace/post.h"

#endif /* ACE_CONFIG_LINUX_H */
2 changes: 1 addition & 1 deletion ACE/ace/os_include/sys/os_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ typedef double ACE_timer_t;
#if defined (ACE_SIZEOF_LONG) && ACE_SIZEOF_LONG == 8
typedef off_t ACE_LOFF_T;
#elif defined (ACE_HAS_RTEMS) || defined (__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__) || defined (__APPLE__) || defined(__INTERIX) || \
(defined (ACE_OPENVMS) && defined (_LARGEFILE))
(defined (ACE_OPENVMS) && defined (_LARGEFILE)) || defined (ACE_HAS_MUSL)
typedef off_t ACE_LOFF_T;
#elif defined (AIX) || defined (HPUX) || defined (__QNX__)
typedef off64_t ACE_LOFF_T;
Expand Down