* 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
+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.
#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)
{
{ "-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
#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
-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
@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.
+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
--- /dev/null
+/* 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;
+}
--- /dev/null
+/* 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;
+}