param.linux26.h defines USE_UCONTEXT for all Linux platforms for
glibc 2.4 and higher, but it does this by testing __GLIBC__ and
__GLIBC_MINOR__. These are defined by features.h, which is included
by any system header. At least one system header must be included
before those are defined. lwp/process.c was including <afsconfig.h>
and <afs/param.h> before any other headers, leading to those macros
being undefined. Most of the Linux architectures either have their
own implementation or were explicitly defining USE_UCONTEXT in the
per-architecture param file, but ppc_linux26 was relying on the
default.
Fix this by reordering the includes to include the various system
headers before <afs/param.h> and add a comment explaining why.
This previously worked in earlier versions because the old
param.ppc_linux26.h file included <afs/afs_sysnames.h>, which
included "stds.h", which included a system header prior to the check
for ucontext. The new generic param file reverses that order.
Change-Id: I214e54f684afdef07e6e2dec5b6e6e4d255ab4ec
Reviewed-on: http://gerrit.openafs.org/1791
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
/* process.c - manage lwp context switches be means of setjmp/longjmp. */
#include <afsconfig.h>
-#include <afs/param.h>
-
+/*
+ * We must include at least one system header on Linux prior to including
+ * afs/param.h, or the __GLIBC__ and __GLIBC_MINOR__ macros will not yet be
+ * defined and we won't know whether we're using ucontext.
+ */
#include <stdio.h>
#include <assert.h>
-#include "lwp.h"
#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
+# include <stdlib.h>
#endif
+#include <afs/param.h>
+
+#include "lwp.h"
+
#if defined(AFS_OSF_ENV) || defined(AFS_S390_LINUX20_ENV)
extern int PRE_Block; /* used in lwp.c and process.s */
#else