aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMatt Austern <austern@apple.com>2004-07-28 23:57:28 +0000
committerMatt Austern <austern@gcc.gnu.org>2004-07-28 23:57:28 +0000
commit8f4220dc9270f29f40fe5d7f3647eaa10511934b (patch)
tree7316f0b087b8604c3dce7b83450841f30b955588 /gcc
parent9f63daea379c0d0c8a30b8f6ea6d8dc6c4ffa415 (diff)
downloadgcc-8f4220dc9270f29f40fe5d7f3647eaa10511934b.zip
gcc-8f4220dc9270f29f40fe5d7f3647eaa10511934b.tar.gz
gcc-8f4220dc9270f29f40fe5d7f3647eaa10511934b.tar.bz2
darwin.c (darwin_one_byte_bool): New global variable.
* config/darwin.c (darwin_one_byte_bool): New global variable. * config/darwin.h (darwin_one_byte_bool): Declare. (SUBTARGET_OPTIONS): Define macro. (for -mone-byte-bool flag.) * config/rs6000/darwin.h (BOOL_TYPE_SIZE): Conditionalize on value of darwin_one_byte_bool. * doc/invoke.texi: Document -mone-byte-bool flag. * testsuite/gcc.dg/darwin-bool-1.c: New test. * testsuite/gcc.dg/darwin-bool-2.c: New test. From-SVN: r85277
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/config/darwin.c4
-rw-r--r--gcc/config/darwin.h11
-rw-r--r--gcc/config/rs6000/darwin.h6
-rw-r--r--gcc/doc/invoke.texi15
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/darwin-bool-1.c11
-rw-r--r--gcc/testsuite/gcc.dg/darwin-bool-2.c12
8 files changed, 70 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 4bd3a7d..3c21172 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2004-07-28 Matt Austern <austern@apple.com>
+
+ * config/darwin.c (darwin_one_byte_bool): New global variable.
+ * config/darwin.h (darwin_one_byte_bool): Declare.
+ (SUBTARGET_OPTIONS): Define macro. (for -mone-byte-bool flag.)
+ * config/rs6000/darwin.h (BOOL_TYPE_SIZE): Conditionalize on
+ value of darwin_one_byte_bool.
+ * doc/invoke.texi: Document -mone-byte-bool flag.
+
2004-07-28 Eric Christopher <echristo@redhat.com>
* c-common.c (c_common_unsafe_for_reeval): Delete.
diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index e3bf3a2..111abfc 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -44,6 +44,10 @@ Boston, MA 02111-1307, USA. */
#include "errors.h"
#include "hashtab.h"
+/* Nonzero if the user passes the -mone-byte-bool switch, which forces
+ sizeof(bool) to be 1. */
+const char *darwin_one_byte_bool = 0;
+
int
name_needs_quotes (const char *name)
{
diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index 14fa7a1..cb84eb1 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -130,7 +130,18 @@ Boston, MA 02111-1307, USA. */
{ "-single_module", "-Zsingle_module" }, \
{ "-unexported_symbols_list", "-Zunexported_symbols_list" }, \
SUBTARGET_OPTION_TRANSLATE_TABLE
+
+/* Nonzero if the user has chosen to force sizeof(bool) to be 1
+ by providing the -mone-byte-bool switch. It would be better
+ to use SUBTARGET_SWITCHES for this instead of SUBTARGET_OPTIONS,
+ but there are no more bits in rs6000 TARGET_SWITCHES. Note
+ that this switch has no "no-" variant. */
+extern const char *darwin_one_byte_bool;
+#undef SUBTARGET_OPTIONS
+#define SUBTARGET_OPTIONS \
+ {"one-byte-bool", &darwin_one_byte_bool, N_("Set sizeof(bool) to 1"), 0 }
+
/* These compiler options take n arguments. */
#undef WORD_SWITCH_TAKES_ARG
diff --git a/gcc/config/rs6000/darwin.h b/gcc/config/rs6000/darwin.h
index ae65eb2..e09e86b 100644
--- a/gcc/config/rs6000/darwin.h
+++ b/gcc/config/rs6000/darwin.h
@@ -321,8 +321,10 @@ do { \
#define DOUBLE_INT_ASM_OP "\t.quad\t"
/* For binary compatibility with 2.95; Darwin C APIs use bool from
- stdbool.h, which was an int-sized enum in 2.95. */
-#define BOOL_TYPE_SIZE INT_TYPE_SIZE
+ stdbool.h, which was an int-sized enum in 2.95. Users can explicitly
+ choose to have sizeof(bool)==1 with the -mone-byte-bool switch. */
+extern const char *darwin_one_byte_bool;
+#define BOOL_TYPE_SIZE (darwin_one_byte_bool ? CHAR_TYPE_SIZE : INT_TYPE_SIZE)
#undef REGISTER_TARGET_PRAGMAS
#define REGISTER_TARGET_PRAGMAS DARWIN_REGISTER_TARGET_PRAGMAS
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 204c27b..58eaaa3 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -423,7 +423,7 @@ in the following sections.
-single_module -static -sub_library -sub_umbrella @gol
-twolevel_namespace -umbrella -undefined @gol
-unexported_symbols_list -weak_reference_mismatches @gol
--whatsloaded -F -gused -gfull}
+-whatsloaded -F -gused -gfull -mone-byte-bool}
@emph{DEC Alpha Options}
@gccoptlist{-mno-fp-regs -msoft-float -malpha-as -mgas @gol
@@ -6931,6 +6931,19 @@ This is by default ON.
@opindex -gfull
Emit debugging information for all symbols and types.
+@item -mone-byte-bool
+@opindex -mone-byte-bool
+Override the defaults for @samp{bool} so that @samp{sizeof(bool)==1}.
+By default @samp{sizeof(bool)} is @samp{4} when compiling for
+Darwin/PowerPC and @samp{1} when compiling for Darwin/x86, so this
+option has no effect on x86.
+
+@strong{Warning:} The @option{-mone-byte-bool} switch causes GCC
+to generate code that is not binary compatible with code generated
+without that switch. Using this switch may require recompiling all
+other modules in a program, including system libraries. Use this
+switch to conform to a non-default data model.
+
@item -all_load
@opindex all_load
Loads all members of static archive libraries.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8cbd3dd..2bb5259 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2004-07-27 Matt Austern <austern@apple.com>
+
+ * gcc.dg/darwin-bool-1.c: New test.
+ * gcc.dg/darwin-bool-2.c: New test.
+
2004-07-28 Richard Henderson <rth@redhat.com>
* gfortran.fortran-torture/execute/intrinsic_spacing.f90: Pass
diff --git a/gcc/testsuite/gcc.dg/darwin-bool-1.c b/gcc/testsuite/gcc.dg/darwin-bool-1.c
new file mode 100644
index 0000000..ef1e98b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/darwin-bool-1.c
@@ -0,0 +1,11 @@
+/* Check that sizeof(bool) is 4 if we don't use special options. */
+/* Matt Austern <austern@apple.com> */
+/* { dg-do run { target powerpc*-*-darwin* } } */
+
+int dummy1[sizeof(_Bool) - 3];
+int dummy2[5 - sizeof(_Bool)];
+
+int main()
+{
+ return sizeof(_Bool) == 4 ? 0 : 1;
+}
diff --git a/gcc/testsuite/gcc.dg/darwin-bool-2.c b/gcc/testsuite/gcc.dg/darwin-bool-2.c
new file mode 100644
index 0000000..fdbe1a2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/darwin-bool-2.c
@@ -0,0 +1,12 @@
+/* Check that sizeof(bool) is 1 if we use the -mone-byte-bool option. */
+/* Matt Austern <austern@apple.com> */
+/* { dg-do run { target powerpc*-*-darwin* } } */
+/* { dg-options "-mone-byte-bool" } */
+
+int dummy1[sizeof(_Bool)];
+int dummy2[2 - sizeof(_Bool)];
+
+int main()
+{
+ return sizeof(_Bool) == 1 ? 0 : 1;
+}