[Toybox] _GNU_SOURCE definition problem
Georgi Chorbadzhiyski
gf at unixsol.org
Fri Mar 9 14:39:21 PST 2012
On 3/9/12 7:47 PM, Rob Landley wrote:
> On 03/09/2012 08:14 AM, Georgi Chorbadzhiyski wrote:
>> Removing _GNU_SOURCE breaks toys/unshare compilation.
>
> Building under what?
>
> In /usr/include/features.h:
>
> #if defined _BSD_SOURCE || defined _SVID_SOURCE
> # define __USE_MISC 1
> #endif
>
> sched.h includes bits/sched.h, and in /usr/include/bits/sched.h the
> CLONE_NEW* defines are all in #ifdef __USE_MISC
>
> So... works for me? (Just did a test build...)
From /usr/include/bits/sched.h [1] on my desktop (glibc-2.14.1, slack-current)
#ifdef __USE_GNU
...
# define CLONE_NEWUTS 0x04000000 /* New utsname group. */
# define CLONE_NEWIPC 0x08000000 /* New ipcs. */
# define CLONE_NEWUSER 0x10000000 /* New user namespace. */
# define CLONE_NEWPID 0x20000000 /* New pid namespace. */
# define CLONE_NEWNET 0x40000000 /* New network namespace. */
# define CLONE_IO 0x80000000 /* Clone I/O context. */
...
#endif
...
#ifdef __USE_GNU
/* Clone current process. */
extern int clone (int (*__fn) (void *__arg), void *__child_stack,
int __flags, void *__arg, ...) __THROW;
/* Unshare the specified resources. */
extern int unshare (int __flags) __THROW;
...
#endif
Resulting in:
toys/unshare.c: In function ‘unshare_main’:
toys/unshare.c:32:20: error: ‘CLONE_NEWNS’ undeclared (first use in this function)
toys/unshare.c:32:20: note: each undeclared identifier is reported only once for each function it appears in
toys/unshare.c:32:33: error: ‘CLONE_NEWUTS’ undeclared (first use in this function)
toys/unshare.c:32:47: error: ‘CLONE_NEWIPC’ undeclared (first use in this function)
toys/unshare.c:32:61: error: ‘CLONE_NEWNET’ undeclared (first use in this function)
toys/unshare.c:40:2: warning: implicit declaration of function ‘unshare’ [-Wimplicit-function-declaration]
make: *** [toybox] Error 1
glibc insists that this Linux only functionality is behind __USE_GNU
which is declared in features.h if _GNU_SOURCE is declared [2].
Beautiful :(
[1]: http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/bits/sched.h
[2]: http://sourceware.org/git/?p=glibc.git;a=blob;f=include/features.h;hb=HEAD
--
Georgi Chorbadzhiyski
http://georgi.unixsol.org/
More information about the Toybox
mailing list