From 3c48eff73029b522a2b1af7652bab5e7afdc8784 Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Thu, 23 May 2013 19:35:47 +0100 Subject: On platform lii6gc, the mps needs a bunch of symbols which are not defined if the -ansi option is given to gcc. these can be enabled by defining features like _gnu_source, but all headers share a common set of features (via ) and so all sources in the same compilation unit must turn on the same set of features. make sure this happens by turning on the features in config.h (not mpstd.h). Remove from mpsi.h (not needed). Copied from Perforce Change: 182124 ServerID: perforce.ravenbrook.com --- mps/code/config.h | 31 +++++++++++++++++++++++++++++++ mps/code/lockli.c | 6 +++--- mps/code/mpsi.c | 1 - mps/code/mpstd.h | 14 +------------- mps/code/prmci3li.c | 9 +++++---- mps/code/prmci6li.c | 9 +++++---- mps/code/prmcix.h | 7 ++++--- mps/code/pthrdext.c | 6 +++--- mps/code/vmix.c | 19 ++++++++----------- 9 files changed, 60 insertions(+), 42 deletions(-) (limited to 'mps/code') diff --git a/mps/code/config.h b/mps/code/config.h index 5172f57a9da..fefd57ed266 100644 --- a/mps/code/config.h +++ b/mps/code/config.h @@ -330,6 +330,37 @@ #define VMParamSize (sizeof(Word)) +/* .feature.li: Linux feature specification + * + * The MPS needs the following symbols which are not defined if the + * -ansi option is given to GCC: + * + * Source Symbols Header Feature + * =========== ========================= ============= ==================== + * lockli.c pthread_mutexattr_settype _XOPEN_SOURCE >= 500 + * prmci3li.c REG_EAX etc. _GNU_SOURCE + * prmci6li.c REG_RAX etc. _GNU_SOURCE + * prmcix.h stack_t, siginfo_t _XOPEN_SOURCE + * pthrdext.c sigaction etc. _XOPEN_SOURCE + * vmix.c MAP_ANON _GNU_SOURCE + * + * Unfortunately it's not possible to localize these feature + * specifications around the individual headers: all headers share a + * common set of features (via ) and so all sources in the + * same compilation unit must turn on the same set of features. + * + * See "Feature Test Macros" in the GCC Manual: + * + */ + +#if defined(MPS_OS_LI) + +#define _XOPEN_SOURCE 500 +#define _GNU_SOURCE + +#endif + + /* Protection Configuration see For each architecture/OS that uses protix.c or protsgix.c, we need to diff --git a/mps/code/lockli.c b/mps/code/lockli.c index 8bd03649bbf..06437b5b531 100644 --- a/mps/code/lockli.c +++ b/mps/code/lockli.c @@ -1,7 +1,7 @@ /* lockli.c: RECURSIVE LOCKS FOR POSIX SYSTEMS * * $Id$ - * Copyright (c) 2001 Ravenbrook Limited. See end of file for license. + * Copyright (c) 2001-2013 Ravenbrook Limited. See end of file for license. * * .linux: This implementation currently just supports LinuxThreads * (platform MPS_OS_LI), Single Unix i/f. @@ -26,7 +26,7 @@ #include "lock.h" #include "config.h" -#include +#include /* see .feature.li in config.h */ #include #include @@ -259,7 +259,7 @@ void LockReleaseGlobal(void) /* C. COPYRIGHT AND LICENSE * - * Copyright (C) 2001-2002 Ravenbrook Limited . + * Copyright (C) 2001-2013 Ravenbrook Limited . * All rights reserved. This is an open source license. Contact * Ravenbrook for commercial licensing options. * diff --git a/mps/code/mpsi.c b/mps/code/mpsi.c index 746ba3e712d..e89577f9c67 100644 --- a/mps/code/mpsi.c +++ b/mps/code/mpsi.c @@ -53,7 +53,6 @@ #include "mpsavm.h" #include -#include SRCID(mpsi, "$Id$"); diff --git a/mps/code/mpstd.h b/mps/code/mpstd.h index 8298e98be26..410d7690f3b 100644 --- a/mps/code/mpstd.h +++ b/mps/code/mpstd.h @@ -1,7 +1,7 @@ /* mpstd.h: RAVENBROOK MEMORY POOL SYSTEM TARGET DETECTION * * $Id$ - * Copyright (c) 2001 Ravenbrook Limited. See end of file for license. + * Copyright (c) 2001-2013 Ravenbrook Limited. See end of file for license. * Portions copyright (C) 2001 Global Graphics Software. * * Detect the target platform using predefined preprocessor symbols @@ -156,12 +156,6 @@ #define MPS_WORD_SHIFT 5 #define MPS_PF_ALIGN 4 -#ifndef _REENTRANT /* it's also defined by cc -pthread */ -#define _REENTRANT /* defines, e.g., pthread_mutexattr_settype */ -#endif -#define _XOPEN_SOURCE 500 /* to get POSIX signal handling */ -#define _GNU_SOURCE /* to get register numbers for prmci3li.c */ - /* GCC 4.6.3, gcc -E -dM */ @@ -180,12 +174,6 @@ #define MPS_WORD_SHIFT 6 #define MPS_PF_ALIGN 8 -#ifndef _REENTRANT /* it's also defined by cc -pthread */ -#define _REENTRANT /* defines, e.g., pthread_mutexattr_settype */ -#endif -#define _XOPEN_SOURCE 500 /* to get POSIX signal handling */ -#define _GNU_SOURCE /* to get register numbers for prmci3li.c */ - /* GCC 2.95.3, gcc -E -dM */ diff --git a/mps/code/prmci3li.c b/mps/code/prmci3li.c index 5418a2ccd35..894df50e5f2 100644 --- a/mps/code/prmci3li.c +++ b/mps/code/prmci3li.c @@ -1,7 +1,7 @@ /* prmci3li.c: PROTECTION MUTATOR CONTEXT INTEL 386 (LINUX) * * $Id$ - * Copyright (c) 2001 Ravenbrook Limited. See end of file for license. + * Copyright (c) 2001-2013 Ravenbrook Limited. See end of file for license. * * .purpose: This module implements the part of the protection module * that decodes the MutatorFaultContext. @@ -41,8 +41,9 @@ MRef Prmci3AddressHoldingReg(MutatorFaultContext mfc, unsigned int regnum) /* .source.i486 */ /* .assume.regref */ - /* The REG_EAX etc. symbols are only present if _GNU_SOURCE is defined. - Currently this is in lii3gc.gmk in PFMDEFS. */ + /* The register numbers (REG_EAX etc.) are defined in + but only if _GNU_SOURCE is defined: see .feature.li in + config.h. */ /* TODO: The current arrangement of the fix operation (taking a Ref *) forces us to pun these registers (actually `int` on LII3GC). We can suppress the warning my casting through `char *` and this might make @@ -106,7 +107,7 @@ Res MutatorFaultContextScan(ScanState ss, MutatorFaultContext mfc) /* C. COPYRIGHT AND LICENSE * - * Copyright (C) 2001-2002 Ravenbrook Limited . + * Copyright (C) 2001-2013 Ravenbrook Limited . * All rights reserved. This is an open source license. Contact * Ravenbrook for commercial licensing options. * diff --git a/mps/code/prmci6li.c b/mps/code/prmci6li.c index 48312e55aaa..6bba840928e 100644 --- a/mps/code/prmci6li.c +++ b/mps/code/prmci6li.c @@ -1,7 +1,7 @@ /* prmci6li.c: PROTECTION MUTATOR CONTEXT x64 (LINUX) * * $Id$ - * Copyright (c) 2001 Ravenbrook Limited. See end of file for license. + * Copyright (c) 2001-2013 Ravenbrook Limited. See end of file for license. * * .purpose: This module implements the part of the protection module * that decodes the MutatorFaultContext. @@ -41,8 +41,9 @@ MRef Prmci6AddressHoldingReg(MutatorFaultContext mfc, unsigned int regnum) gregs = (Word *)&mfc->ucontext->uc_mcontext.gregs; /* .assume.regref */ - /* The REG_EAX etc. symbols are only present if _GNU_SOURCE is defined. - * Currently this is in lii6gc.gmk in PFMDEFS. */ + /* The register numbers (REG_RAX etc.) are defined in + but only if _GNU_SOURCE is defined: see .feature.li in + config.h. */ switch (regnum) { case 0: return &gregs[REG_RAX]; case 1: return &gregs[REG_RCX]; @@ -110,7 +111,7 @@ Res MutatorFaultContextScan(ScanState ss, MutatorFaultContext mfc) /* C. COPYRIGHT AND LICENSE * - * Copyright (C) 2001-2002 Ravenbrook Limited . + * Copyright (C) 2001-2013 Ravenbrook Limited . * All rights reserved. This is an open source license. Contact * Ravenbrook for commercial licensing options. * diff --git a/mps/code/prmcix.h b/mps/code/prmcix.h index a5781118607..684be0d452e 100644 --- a/mps/code/prmcix.h +++ b/mps/code/prmcix.h @@ -1,7 +1,7 @@ /* prmcix.h: PROTECTION MUTATOR CONTEXT (UNIX) * * $Id$ - * Copyright (c) 2001 Ravenbrook Limited. See end of file for license. + * Copyright (c) 2001-2013 Ravenbrook Limited. See end of file for license. * * .readership: MPS developers. */ @@ -11,7 +11,8 @@ #include "mpm.h" -#include +#include /* siginfo_t -- see .feature.li in config.h */ +#include /* ucontext_t */ typedef struct MutatorFaultContextStruct { /* Protection fault context data */ siginfo_t *info; @@ -24,7 +25,7 @@ typedef struct MutatorFaultContextStruct { /* Protection fault context data */ /* C. COPYRIGHT AND LICENSE * - * Copyright (C) 2001-2002 Ravenbrook Limited . + * Copyright (C) 2001-2013 Ravenbrook Limited . * All rights reserved. This is an open source license. Contact * Ravenbrook for commercial licensing options. * diff --git a/mps/code/pthrdext.c b/mps/code/pthrdext.c index 934a0a646a0..8a027edb3b7 100644 --- a/mps/code/pthrdext.c +++ b/mps/code/pthrdext.c @@ -1,7 +1,7 @@ /* pthreadext.c: POSIX THREAD EXTENSIONS * * $Id$ - * Copyright (c) 2001 Ravenbrook Limited. See end of file for license. + * Copyright (c) 2001-2013 Ravenbrook Limited. See end of file for license. * * .purpose: Provides extension to Pthreads. * @@ -17,7 +17,7 @@ #include #include -#include +#include /* see .feature.li in config.h */ #include #include #include @@ -365,7 +365,7 @@ unlock: /* C. COPYRIGHT AND LICENSE * - * Copyright (C) 2001-2002 Ravenbrook Limited . + * Copyright (C) 2001-2013 Ravenbrook Limited . * All rights reserved. This is an open source license. Contact * Ravenbrook for commercial licensing options. * diff --git a/mps/code/vmix.c b/mps/code/vmix.c index 2b7afb514c2..9b06f09b032 100644 --- a/mps/code/vmix.c +++ b/mps/code/vmix.c @@ -18,11 +18,11 @@ * (MAP_PRIVATE) mapping with the flag MAP_ANON. * * .non-standard: Note that the MAP_ANON flag is non-standard; it is - * available on Darwin and FreeBSD. .non-standard.linux: Linux - * seems to use MAP_ANONYMOUS instead. Some Linux systems make MAP_ANON - * available and deprecate it. .non-standard.sesame: On Linux getting - * a definition of MAP_ANON requires a macro to be defined prior to - * . + * available on Darwin and FreeBSD. .non-standard.linux: Linux seems + * to use MAP_ANONYMOUS instead. Some Linux systems make MAP_ANON + * available and deprecate it. .non-standard.sesame: On Linux getting + * a definition of MAP_ANON requires a _BSD_SOURCE to be defined prior + * to ; see config.h. * * .assume.not-last: The implementation of VMCreate assumes that * mmap() will not choose a region which contains the last page @@ -38,12 +38,11 @@ * seem to be a problem. */ -/* .non-standard.sesame */ -#define _BSD_SOURCE 1 +#include "mpm.h" /* for mmap(2), munmap(2) */ #include -#include +#include /* see .feature.li in config.h */ /* for errno(2) */ #include @@ -51,8 +50,6 @@ /* for getpagesize(3) */ #include -#include "mpm.h" - #if !defined(MPS_OS_FR) && !defined(MPS_OS_XC) && !defined(MPS_OS_LI) #error "vmix.c is Unix-like specific, currently MPS_OS_FR XC LI" @@ -322,7 +319,7 @@ void VMUnmap(VM vm, Addr base, Addr limit) /* C. COPYRIGHT AND LICENSE * - * Copyright (C) 2001-2007 Ravenbrook Limited . + * Copyright (C) 2001-2013 Ravenbrook Limited . * All rights reserved. This is an open source license. Contact * Ravenbrook for commercial licensing options. * -- cgit v1.2.1