diff options
author | echristo <echristo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-04-27 22:53:23 +0000 |
---|---|---|
committer | echristo <echristo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-04-27 22:53:23 +0000 |
commit | f5c68723fdde7f0a8ffa70f5c920d74641ebafe1 (patch) | |
tree | 7544c1d5db81412c38f591c7b266ee7291942b52 /gcc/config | |
parent | c937e9d4f4dc729a89946d12295569b7e085f452 (diff) | |
download | gcc-f5c68723fdde7f0a8ffa70f5c920d74641ebafe1.tar.gz |
2006-04-27 Eric Christopher <echristo@apple.com>
* target-def.h (TARGET_SET_DEFAULT_TYPE_ATTRIBUTES): Bracket
with #ifndef/#endif.
* config/darwin-c.c (darwin_ms_struct): New.
(darwin_pragma_ms_struct): Ditto.
(darwin_set_default_type_attributes): Ditto.
* config/darwin-protos.h (darwin_pragma_ms_struct): Declare.
* config/darwin.h (DARWIN_REGISTER_TARGET_PRAGMAS):
Register ms_struct pragma.
* config/i386/darwin.h (REGISTER_TARGET_PRAGMAS): Declare.
(TARGET_SET_DEFAULT_TYPE_ATTRIBUTES): Ditto.
* config/rs6000/rs6000.c (rs6000_set_default_type_attributes): Call
darwin_set_default_type_attributes if TARGET_MACHO.
2006-04-27 Eric Christopher <echristo@apple.com>
* gcc.dg/pragma-ms_struct.c: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@113327 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/config')
-rw-r--r-- | gcc/config/darwin-c.c | 72 | ||||
-rw-r--r-- | gcc/config/darwin-protos.h | 2 | ||||
-rw-r--r-- | gcc/config/darwin.h | 3 | ||||
-rw-r--r-- | gcc/config/i386/darwin.h | 6 | ||||
-rw-r--r-- | gcc/config/rs6000/rs6000.c | 4 |
5 files changed, 68 insertions, 19 deletions
diff --git a/gcc/config/darwin-c.c b/gcc/config/darwin-c.c index 30de35d47a6..6f263f4eeba 100644 --- a/gcc/config/darwin-c.c +++ b/gcc/config/darwin-c.c @@ -41,6 +41,9 @@ Boston, MA 02110-1301, USA. */ static bool using_frameworks = false; +/* True if we're setting __attribute__ ((ms_struct)). */ +static bool darwin_ms_struct = false; + /* Maintain a small stack of alignments. This is similar to pragma pack's stack, but simpler. */ @@ -159,6 +162,39 @@ darwin_pragma_unused (cpp_reader *pfile ATTRIBUTE_UNUSED) warning (0, "junk at end of '#pragma unused'"); } +/* Parse the ms_struct pragma. */ +void +darwin_pragma_ms_struct (cpp_reader *pfile ATTRIBUTE_UNUSED) +{ + const char *arg; + tree t; + + if (pragma_lex (&t) != CPP_NAME) + BAD ("malformed '#pragma ms_struct', ignoring"); + arg = IDENTIFIER_POINTER (t); + + if (!strcmp (arg, "on")) + darwin_ms_struct = true; + else if (!strcmp (arg, "off") || !strcmp (arg, "reset")) + darwin_ms_struct = false; + else + warning (OPT_Wpragmas, "malformed '#pragma ms_struct {on|off|reset}', ignoring"); + + if (pragma_lex (&t) != CPP_EOF) + warning (OPT_Wpragmas, "junk at end of '#pragma ms_struct'"); +} + +/* Set the darwin specific attributes on TYPE. */ +void +darwin_set_default_type_attributes (tree type) +{ + if (darwin_ms_struct + && TREE_CODE (type) == RECORD_TYPE) + TYPE_ATTRIBUTES (type) = tree_cons (get_identifier ("ms_struct"), + NULL_TREE, + TYPE_ATTRIBUTES (type)); +} + static struct { size_t len; const char *name; @@ -295,7 +331,7 @@ framework_construct_pathname (const char *fname, cpp_dir *dir) /* Append framework_header_dirs and header file name */ for (i = 0; framework_header_dirs[i].dirName; i++) { - strncpy (&frname[frname_len], + strncpy (&frname[frname_len], framework_header_dirs[i].dirName, framework_header_dirs[i].dirNameLen); strcpy (&frname[frname_len + framework_header_dirs[i].dirNameLen], @@ -318,8 +354,8 @@ find_subframework_file (const char *fname, const char *pname) { char *sfrname; const char *dot_framework = ".framework/"; - char *bufptr; - int sfrname_len, i, fname_len; + char *bufptr; + int sfrname_len, i, fname_len; struct cpp_dir *fast_dir; static struct cpp_dir subframe_dir; struct stat st; @@ -329,7 +365,7 @@ find_subframework_file (const char *fname, const char *pname) /* Subframework files must have / in the name. */ if (bufptr == 0) return 0; - + fname_len = bufptr - fname; fast_dir = find_framework (fname, fname_len); @@ -344,7 +380,7 @@ find_subframework_file (const char *fname, const char *pname) return 0; /* Now translate. For example, +- bufptr - fname = CarbonCore/OSUtils.h | + fname = CarbonCore/OSUtils.h | pname = /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h into sfrname = /System/Library/Frameworks/Foundation.framework/Frameworks/CarbonCore.framework/Headers/OSUtils.h */ @@ -352,10 +388,10 @@ find_subframework_file (const char *fname, const char *pname) sfrname = XNEWVEC (char, strlen (pname) + strlen (fname) + 2 + strlen ("Frameworks/") + strlen (".framework/") + strlen ("PrivateHeaders")); - + bufptr += strlen (dot_framework); - sfrname_len = bufptr - pname; + sfrname_len = bufptr - pname; strncpy (&sfrname[0], pname, sfrname_len); @@ -371,12 +407,12 @@ find_subframework_file (const char *fname, const char *pname) /* Append framework_header_dirs and header file name */ for (i = 0; framework_header_dirs[i].dirName; i++) { - strncpy (&sfrname[sfrname_len], + strncpy (&sfrname[sfrname_len], framework_header_dirs[i].dirName, framework_header_dirs[i].dirNameLen); strcpy (&sfrname[sfrname_len + framework_header_dirs[i].dirNameLen], &fname[fname_len]); - + if (stat (sfrname, &st) == 0) { if (fast_dir != &subframe_dir) @@ -433,7 +469,7 @@ add_framework_path (char *path) add_cpp_dir_path (p, BRACKET); } -static const char *framework_defaults [] = +static const char *framework_defaults [] = { "/System/Library/Frameworks", "/Library/Frameworks", @@ -450,9 +486,9 @@ darwin_register_objc_includes (const char *sysroot, const char *iprefix, /* We do not do anything if we do not want the standard includes. */ if (!stdinc) return; - + fname = GCC_INCLUDE_DIR "-gnu-runtime"; - + /* Register the GNU OBJC runtime include path if we are compiling OBJC with GNU-runtime. */ @@ -469,13 +505,13 @@ darwin_register_objc_includes (const char *sysroot, const char *iprefix, /* FIXME: wrap the headers for C++awareness. */ add_path (str, SYSTEM, /*c++aware=*/false, false); } - + /* Should this directory start with the sysroot? */ if (sysroot) str = concat (sysroot, fname, NULL); else str = update_path (fname, ""); - + add_path (str, SYSTEM, /*c++aware=*/false, false); } } @@ -546,13 +582,13 @@ find_subframework_header (cpp_reader *pfile, const char *header, cpp_dir **dirp) /* Return the value of darwin_macosx_version_min suitable for the __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ macro, - so '10.4.2' becomes 1042. + so '10.4.2' becomes 1042. Print a warning if the version number is not known. */ static const char * version_as_macro (void) { static char result[] = "1000"; - + if (strncmp (darwin_macosx_version_min, "10.", 3) != 0) goto fail; if (! ISDIGIT (darwin_macosx_version_min[3])) @@ -570,9 +606,9 @@ version_as_macro (void) } else result[3] = '0'; - + return result; - + fail: error ("Unknown value %qs of -mmacosx-version-min", darwin_macosx_version_min); diff --git a/gcc/config/darwin-protos.h b/gcc/config/darwin-protos.h index abcb172b926..14da36d4da9 100644 --- a/gcc/config/darwin-protos.h +++ b/gcc/config/darwin-protos.h @@ -46,6 +46,7 @@ extern void machopic_asm_out_destructor (rtx, int); extern void machopic_define_symbol (rtx); extern void darwin_encode_section_info (tree, rtx, int); +extern void darwin_set_default_type_attributes (tree); #endif /* TREE_CODE */ @@ -65,6 +66,7 @@ extern void darwin_emit_except_table_label (FILE *); extern void darwin_pragma_ignore (struct cpp_reader *); extern void darwin_pragma_options (struct cpp_reader *); extern void darwin_pragma_unused (struct cpp_reader *); +extern void darwin_pragma_ms_struct (struct cpp_reader *); extern void darwin_file_start (void); extern void darwin_file_end (void); diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h index 21ed7da0b9e..c73ff60da41 100644 --- a/gcc/config/darwin.h +++ b/gcc/config/darwin.h @@ -439,7 +439,7 @@ Boston, MA 02110-1301, USA. */ #define TARGET_USES_WEAK_UNWIND_INFO 1 /* We need to use a nonlocal label for the start of an EH frame: the - Darwin linker requires that a coalesced section start with a label. + Darwin linker requires that a coalesced section start with a label. Unfortunately, it also requires that 'debug' sections don't contain labels. */ #undef FRAME_BEGIN_LABEL @@ -830,6 +830,7 @@ enum machopic_addr_class { c_register_pragma (0, "options", darwin_pragma_options); \ c_register_pragma (0, "segment", darwin_pragma_ignore); \ c_register_pragma (0, "unused", darwin_pragma_unused); \ + c_register_pragma (0, "ms_struct", darwin_pragma_ms_struct); \ } while (0) #undef ASM_APP_ON diff --git a/gcc/config/i386/darwin.h b/gcc/config/i386/darwin.h index 7481ea886e4..63e7bfde542 100644 --- a/gcc/config/i386/darwin.h +++ b/gcc/config/i386/darwin.h @@ -217,3 +217,9 @@ __enable_execute_stack (void *addr) \ /* 7 == PROT_READ | PROT_WRITE | PROT_EXEC */ \ (void) mprotect (page, end - page, 7); \ } + +#undef REGISTER_TARGET_PRAGMAS +#define REGISTER_TARGET_PRAGMAS() DARWIN_REGISTER_TARGET_PRAGMAS() + +#undef TARGET_SET_DEFAULT_TYPE_ATTRIBUTES +#define TARGET_SET_DEFAULT_TYPE_ATTRIBUTES darwin_set_default_type_attributes diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 780a44cfcca..0bb68109efa 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -17527,6 +17527,10 @@ rs6000_set_default_type_attributes (tree type) TYPE_ATTRIBUTES (type) = tree_cons (get_identifier ("longcall"), NULL_TREE, TYPE_ATTRIBUTES (type)); + +#if TARGET_MACHO + darwin_set_default_type_attributes (type); +#endif } /* Return a reference suitable for calling a function with the |