]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
Linux: Fix USE_UCONTEXT detection
authorSimon Wilkinson <sxw@your-file-system.com>
Fri, 1 Apr 2011 15:37:32 +0000 (16:37 +0100)
committerDerrick Brashear <shadow@dementix.org>
Fri, 16 Dec 2011 10:57:33 +0000 (02:57 -0800)
On Linux, afs/param.h determines whether to use the ucontext()
function based on the glibc version. However, the glibc version
macros aren't available until a C library header has been included.

There have been a couple of attempts to fix this. The first included
afs_sysnames.h before the C library check, but this wasn't sufficient
to pull in a header for all builds. The second included stdio.h before
including afs/param.h in process.c.

Whilst the second approach works, it has the drawback that it breaks
our convention that afsconfig.h and afs/param.h must always be the first
includes in a file. More seriously, it means that the behaviour of
afs/param.h is different depending on where it appears in the include
order - which is especially dangerous for 3rd party user.

So, this patch tries to resolve all of this by explicitly including
features.h before doing the glibc version checks. The only danger I
can see here is that Linux platforms without glibc may lack a
features.h, but I suspect we have trouble building on such platforms
in any case.

Reviewed-on: http://gerrit.openafs.org/4389
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
(cherry picked from commit f5f0ce525a63264098cd0625769d642fe6f106ba)

Change-Id: Ia94487f35ad0fc3143faafd2fa12a6c71d40f116
Reviewed-on: http://gerrit.openafs.org/6278
Tested-by: Derrick Brashear <shadow@dementix.org>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
src/config/param.linux24.h
src/config/param.linux26.h
src/lwp/process.c

index 9f81afb08b12a153357140a11d12d43610b6dde4..19839b2b1330c9c62101666b95a2d0535ef8b964 100644 (file)
 
 #endif /* !defined(UKERNEL) */
 
-/* needed so glibc version will be defined */
-#include <afs/afs_sysnames.h>
+#if defined(UKERNEL) || !defined(KERNEL)
+#include <features.h>
+#endif
 
 #ifdef __GLIBC__
 #if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 3)
 #endif
 #endif
 
+#include <afs/afs_sysnames.h>
+
 #endif /* AFS_PARAM_COMMON_H */
index aba4a98434dfb1eda2c00245bf00b17958c95e24..8f6382be43b1a46286fb1b7582f2d84241cf8f14 100644 (file)
@@ -95,8 +95,9 @@
 
 #endif /* !defined(UKERNEL) */
 
-/* needed so glibc version will be defined */
-#include <afs/afs_sysnames.h>
+#if defined(UKERNEL) || !defined(KERNEL)
+#include <features.h>
+#endif
 
 #ifdef __GLIBC__
 #if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 3)
 #endif
 #endif
 
+#include <afs/afs_sysnames.h>
+
 #endif /* AFS_PARAM_COMMON_H */
index 06efcfb3c5daa10843268a9b95421f066c5be63e..bd18de6e04824729dc1d7a2e80377e28a7719e7e 100644 (file)
 /* 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>
 #ifdef HAVE_STDLIB_H
 # include <stdlib.h>
 #endif
 
-#include <afs/param.h>
 
 #include "lwp.h"