Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Define unshare() macro to avoid dependence on __GNU_SOURCE
unshare() is a linux syscall that we need. Unfortunately, access to it depends on __GNU_SOURCE, which we would like to avoid. As such, we define a macro to invoke it by its syscall code. This is necessary to avoid the following warning from Clang: implicit declaration of function 'unshare' is invalid in C99 [-Wimplicit-function-declaration] Signed-off-by: Richard Yao <ryao@gentoo.org>
- Loading branch information
189d09a
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.
Nak this is ugly, utilize __GNU_SOURCE for things that are __GNU_SOURCE in this case it's needed
189d09a
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.
Also doing this allows me to send random crap to the syscall instead of an int
189d09a
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.
__GNU_SOURCE is a glibcism. Using it would cause problems for issue #9, which requests that we remove glibcisms.
189d09a
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.
What? glibcisms are global (not feature macored) functions that don't follow / are not in POSIX standards or are just plain broken. Do not make a syscall macro, that is ugly as sin.
189d09a
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.
The issue is that the glibc authors decided to declare that a Linux kernel feature to be a GNU extension. If a feature test macro existed that did not require enabling GNU extensions, we could use that.
189d09a
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.
As it should be it's an non-standard function the feature macro could be called anything that doesn't matter.
189d09a
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.
The distinction is that __GNU_SOURCE should apply to extensions specific to the GNU operating system whose userland is often used with Linux. Since unshare() is a Linux syscall, it should not depend on __GNU_SOURCE. Setting it would enable things that we do not want.