Hi,
Building ltp testsuite it fails when try to build signal_test_04.c with the
the following error:

In file included from signal_test_04.c:85:0:
/usr/include/sys/wait.h:116:22: error: unknown type name '__WAIT_STATUS'
In file included from signal_test_04.c:85:0:
/usr/include/sys/wait.h:169:23: error: unknown type name '__WAIT_STATUS'
/usr/include/sys/wait.h:175:38: error: unknown type name '__WAIT_STATUS'
signal_test_04.c: In function 'main':
signal_test_04.c:203:2: warning: implicit declaration of function 'wait' [-W
signal_test_04.c:205:2: warning: implicit declaration of function 'WIFSIGNAL
signal_test_04.c:206:3: warning: implicit declaration of function 'WTERMSIG'
make[4]: *** [signal_test_04] Error 1

I try to explain what happening.
When stdlib.h is included by the test to get the needed stuff it isn't included because it has been silently included, by bits/sched.h, in the inclusion chain of stdio.h.
Follow the header included by the test:

#include <stdio.h>
#include <string.h>
#ifdef _LINUX_
#define __USE_XOPEN
#endif
#include <unistd.h>
#include <stdlib.h>
#include <sys/signal.h>
#include <sys/wait.h>
#include <errno.h>

To note it defines __USE_XOPEN after include stdio.h and before to include stdlib.h,
then when stdlib.h is included the first time it isn't taken into account.
Using __need_malloc_and_calloc macro before include stdlib.h in bits/sched.h avoid to define _STDLIB_H guard (but declaring malloc/calloc) the first time it is included, then the application can successfully include stdlib.h to get what it needs, and the test build successfully. On the other hand "# include <stdlib.h>" has been added in sched.h to include malloc stuff only,
avoiding implicit declaration.
I mean:

diff --git a/libc/sysdeps/linux/common/bits/sched.h b/libc/sysdeps/linux/common/
index 878550d..d2d152e 100644
--- a/libc/sysdeps/linux/common/bits/sched.h
+++ b/libc/sysdeps/linux/common/bits/sched.h
@@ -109,6 +109,7 @@ struct __sched_param
 /* Size definition for CPU sets.  */
 # define __CPU_SETSIZE 1024
 # define __NCPUBITS    (8 * sizeof (__cpu_mask))
+#define __need_malloc_and_calloc
 # include <stdlib.h>

 /* Type for array elements in 'cpu_set_t'.  */

However, in this way the free function isn't declared so when use CPU_FREE (i.e. unistd/tst-cpuset.c)
we get an implicit declaration for free function.
I added a new macro __need_free to use the free function similarly to __need_malloc_and_calloc
that fixes both problems.
If you agree I can provide the proper patch.
Any feedback are welcome.

Filippo Arcidiacono
_______________________________________________
uClibc mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/uclibc

Reply via email to