Skip to content
Merged
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
4 changes: 4 additions & 0 deletions system/lib/libc/musl/include/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,11 @@ pid_t gettid(void);

#define _POSIX_VDISABLE 0

#if defined(__EMSCRIPTEN__) && !defined(_REENTRANT) /* XXX Emscripten doesn't always support pthreads */
#define _POSIX_THREADS -1

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is -1 some kind of POSIX convention? I tried to look for it, and the docs I found all suggest "is defined when threads are enabled", so I'd expect us to not define it in that case? That seems to be what search results on github expect:

https://github.com/search?q=%22_POSIX_THREADS%22&type=code

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I noticed that we used -1 elsewhere in this file to mean "no available". And I was confused too. But it looks like -1 does mean "not available".

See the discussion in the original PR: #9452

As an example, here is hurd declaring that it doesn't support stuff: https://codebrowser.dev/glibc/glibc/sysdeps/mach/hurd/bits/posix_opt.h.html#163

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Interesting... not sure how that works with those github results that do check for definition..? Perhaps this just isn't depended on in practice? Anyhow, it seems low risk and worst case we can revert.

#else
#define _POSIX_THREADS _POSIX_VERSION
#endif
#define _POSIX_THREAD_PROCESS_SHARED _POSIX_VERSION
#define _POSIX_THREAD_SAFE_FUNCTIONS _POSIX_VERSION
#define _POSIX_THREAD_ATTR_STACKADDR _POSIX_VERSION
Expand Down