-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 support for Musl libc #4779
base: main
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,6 +69,7 @@ | |
#include <features.h> | ||
#include <termios.h> | ||
|
||
#if defined(__GLIBC_PREREQ) | ||
#if __GLIBC_PREREQ(2, 28) == 0 | ||
// required for statx() system call, glibc >=2.28 wraps the kernel function | ||
#include <sys/syscall.h> | ||
|
@@ -78,6 +79,7 @@ | |
#include <linux/fs.h> | ||
#define AT_STATX_SYNC_AS_STAT 0x0000 /* - Do whatever stat() does */ | ||
#endif //__GLIBC_PREREQ(2. 28) | ||
#endif // defined(__GLIBC_PREREQ) | ||
|
||
#ifndef __NR_statx | ||
#include <sys/stat.h> | ||
|
@@ -562,7 +564,7 @@ CF_CROSS_PLATFORM_EXPORT int _CFOpenFile(const char *path, int opts); | |
static inline int _direntNameLength(struct dirent *entry) { | ||
#ifdef _D_EXACT_NAMLEN // defined on Linux | ||
return _D_EXACT_NAMLEN(entry); | ||
#elif TARGET_OS_ANDROID | ||
#elif TARGET_OS_ANDROID || !defined(__GLIBC__) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Won't this activate this line for the BSDs and all other libcs? No way to just enable this for Musl alone? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Musl provides no macro we could reliably check for. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to add one in this repo then, something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Couldn't we just write We could even do
which would then mean if Musl or Android added There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't particularly like the attempts at detecting Musl in that Stack Overflow answer; Musl should probably define some macros of its own — it should ideally be possible to test not just for Musl but to check the Musl version as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That would work and be fine here, but I was trying to come up with a more general solution. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the general solution is to get musl to add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmm: https://www.openwall.com/lists/musl/2013/03/29/13 doesn't sound good. |
||
return strlen(entry->d_name); | ||
#else | ||
return entry->d_namlen; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Glibc isn't defined on Android, so you can remove the Android check.