[uclibc-ng-devel] ucontext on PowerPC, broken header logic?
thomas.petazzoni at free-electrons.com
Thu Aug 11 22:55:57 CEST 2016
According to getcontext(3), the *context functions and the ucontext_t
structure are defined in <ucontext.h>.
If you take this simple program:
and build it with a uClibc-ng PowerPC toolchain, it will fail with:
foo.c: In function 'main':
foo.c:5:2: error: unknown type name 'ucontext_t'
And indeed <ucontext.h> in uClibc-ng only includes <sys/ucontext.h> if
__UCLIBC_HAS_CONTEXT_FUNCS__ is defined, which is not the case on
PowerPC. And since <sys/ucontext.h> is where ucontext_t is defined, the
build failure is expected.
However, now, change the program to:
i.e with just <signal.h> included. And now, it builds fine!
Indeed <signal.h> includes <sys/ucontext.h> unconditionally, without
taking care of __UCLIBC_HAS_CONTEXT_FUNCS__. This seems broken to me,
as-is the fact that some ucontext structures are defined in a header
file even if the platform doesn't support context functions.
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
More information about the devel