public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Fix assert.h on darwin (before 8.0)
@ 2004-11-07  0:34 Andrew Pinski
  2004-11-07  0:35 ` Joseph S. Myers
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Pinski @ 2004-11-07  0:34 UTC (permalink / raw)
  To: gcc-patches@gcc.gnu.org Patches

[-- Attachment #1: Type: text/plain, Size: 502 bytes --]

Darwin (before 8) has a very messed up assert.h and uses __eprintf
which is very wrong.  This patch fixes that by adding an assert.h
which does not use __eprintf at all.

OK? Bootstrapped and tested on powerpc-darwin7.6.0 and fixes the
last two libjava failures.

Thanks,
Andrew Pinski

ChangeLog:
	* config.gcc (*-*-darwin*): Add t-darwin-pre8 for pre
	darwin 8 targets.
	* config/t-darwin-pre8: New file. Add assert.h to the	EXTRA_HEADERS.
	* config/darwin-assert.h: New file. Assert.h for darwin.



[-- Attachment #2: fixDarwin-Assert.diff.txt --]
[-- Type: text/plain, Size: 1887 bytes --]

Index: config.gcc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config.gcc,v
retrieving revision 1.495
diff -u -p -r1.495 config.gcc
--- config.gcc	21 Oct 2004 22:28:22 -0000	1.495
+++ config.gcc	6 Nov 2004 20:02:50 -0000
@@ -338,6 +338,10 @@ case ${target} in
   tm_file="${tm_file} darwin.h"
   tm_p_file="${tm_p_file} darwin-protos.h"
   tmake_file="t-darwin t-slibgcc-darwin"
+  case ${target} in
+    *-darwin[0-7]*) tmake_file="${tmake_file} t-darwin-pre8";;
+    *) ;;
+  esac
   target_gtfiles="\$(srcdir)/config/darwin.c"
   c_target_objs="darwin-c.o"
   cxx_target_objs="darwin-c.o"
Index: config/t-darwin-pre8
===================================================================
RCS file: config/t-darwin-pre8
diff -N config/t-darwin-pre8
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ config/t-darwin-pre8	6 Nov 2004 20:03:25 -0000
@@ -0,0 +1,5 @@
+EXTRA_HEADERS += $(objdir)/darwininclude/assert.h
+$(objdir)/darwininclude/assert.h: $(srcdir)/config/darwin-assert.h
+        mkdir -p $(objdir)/darwininclude
+        cp $(srcdir)/config/darwin-assert.h $(objdir)/darwininclude/assert.h
+
Index: config/darwin-assert.h
===================================================================
RCS file: config/darwin-assert.h
diff -N config/darwin-assert.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ config/darwin-assert.h	6 Nov 2004 20:03:25 -0000
@@ -0,0 +1,20 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+/* Allow this file to be included multiple times
+   with different settings of NDEBUG.  */
+#undef assert
+#undef __assert
+
+#ifdef NDEBUG
+#define assert(ignore) ((void) 0)
+#else
+
+#define assert(expression)  \
+  ((void) ((expression) ? 0 : __assert (expression, __FILE__, __LINE__)))
+
+#define __assert(expression, file, lineno)  \
+  (printf ("%s:%u: failed assertion\n", file, lineno),	\
+   abort (), 0)
+
+#endif

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Fix assert.h on darwin (before 8.0)
  2004-11-07  0:34 Fix assert.h on darwin (before 8.0) Andrew Pinski
@ 2004-11-07  0:35 ` Joseph S. Myers
  2004-11-08 21:43   ` Andrew Pinski
  0 siblings, 1 reply; 3+ messages in thread
From: Joseph S. Myers @ 2004-11-07  0:35 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: gcc-patches@gcc.gnu.org Patches

On Sat, 6 Nov 2004, Andrew Pinski wrote:

> Darwin (before 8) has a very messed up assert.h and uses __eprintf
> which is very wrong.  This patch fixes that by adding an assert.h
> which does not use __eprintf at all.

Your assert.h doesn't seem to print either the text of the asserted 
expression or the name of the current function in the message, though C99 
requires both.

-- 
Joseph S. Myers               http://www.srcf.ucam.org/~jsm28/gcc/
    jsm@polyomino.org.uk (personal mail)
    joseph@codesourcery.com (CodeSourcery mail)
    jsm28@gcc.gnu.org (Bugzilla assignments and CCs)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Fix assert.h on darwin (before 8.0)
  2004-11-07  0:35 ` Joseph S. Myers
@ 2004-11-08 21:43   ` Andrew Pinski
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Pinski @ 2004-11-08 21:43 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: gcc-patches@gcc.gnu.org Patches

[-- Attachment #1: Type: text/plain, Size: 1110 bytes --]


On Nov 6, 2004, at 6:46 PM, Joseph S. Myers wrote:

> On Sat, 6 Nov 2004, Andrew Pinski wrote:
>
>> Darwin (before 8) has a very messed up assert.h and uses __eprintf
>> which is very wrong.  This patch fixes that by adding an assert.h
>> which does not use __eprintf at all.
>
> Your assert.h doesn't seem to print either the text of the asserted
> expression or the name of the current function in the message, though 
> C99 requires both.

Looks like most asserts don't include the current function either
but what the hack, if doing an assert.h, better to do it right.
Also fixed in this version of the patch is making sure that we
don't match darwin10 which should have a fixed up assert.h already.

OK? Bootstrapped and tested on powerpc-darwin7.6.0.

This is now also known as PR 18383.

Thanks,
Andrew Pinski

ChangeLog:

	* config.gcc (*-*-darwin*): Add t-darwin-pre8 for pre
	darwin 8 targets.  Also fix matching for post darwin 7
	targets for the header file darwin7.h
	* config/t-darwin-pre8: New file. Add assert.h to the	EXTRA_HEADERS.
	* config/darwin-assert.h: New file. Assert.h for darwin.


[-- Attachment #2: fixPR18383.diff.txt --]
[-- Type: text/plain, Size: 2118 bytes --]

Index: config/darwin-assert.h
===================================================================
RCS file: config/darwin-assert.h
diff -N config/darwin-assert.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ config/darwin-assert.h	8 Nov 2004 21:26:04 -0000
@@ -0,0 +1,21 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+/* Allow this file to be included multiple times
+   with different settings of NDEBUG.  */
+#undef assert
+#undef __assert
+
+#ifdef NDEBUG
+#define assert(ignore) ((void) 0)
+#else
+
+#define assert(expression)  \
+  ((void) ((expression) ? 0 : __assert (#expression, __FUNCTION__, __FILE__, __LINE__)))
+
+#define __assert(expression, function, file, lineno)  \
+  (printf ("%s:%u: In `%s' failed assertion `%s'\n",		\
+	      file, lineno, function, expression),	\
+   abort (), 0)
+
+#endif
Index: config/t-darwin-pre8
===================================================================
RCS file: config/t-darwin-pre8
diff -N config/t-darwin-pre8
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ config/t-darwin-pre8	8 Nov 2004 21:26:04 -0000
@@ -0,0 +1,5 @@
+EXTRA_HEADERS += $(objdir)/darwininclude/assert.h
+$(objdir)/darwininclude/assert.h: $(srcdir)/config/darwin-assert.h
+	mkdir -p $(objdir)/darwininclude
+	cp $(srcdir)/config/darwin-assert.h $(objdir)/darwininclude/assert.h
+
Index: config.gcc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config.gcc,v
retrieving revision 1.495
diff -u -p -r1.495 config.gcc
--- config.gcc	21 Oct 2004 22:28:22 -0000	1.495
+++ config.gcc	8 Nov 2004 21:26:04 -0000
@@ -332,12 +332,16 @@ esac
 case ${target} in
 *-*-darwin*)
   case ${target} in
-    *-darwin[0-6]*) ;;
+    *-darwin[0-6] | *-darwin[0-6].*) ;;
     *) tm_file="${tm_file} darwin7.h" ;;
   esac
   tm_file="${tm_file} darwin.h"
   tm_p_file="${tm_p_file} darwin-protos.h"
   tmake_file="t-darwin t-slibgcc-darwin"
+  case ${target} in
+    *-darwin[0-7] | *-darwin[0-7].*) tmake_file="${tmake_file} t-darwin-pre8";;
+    *) ;;
+  esac
   target_gtfiles="\$(srcdir)/config/darwin.c"
   c_target_objs="darwin-c.o"
   cxx_target_objs="darwin-c.o"

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-11-08 21:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-07  0:34 Fix assert.h on darwin (before 8.0) Andrew Pinski
2004-11-07  0:35 ` Joseph S. Myers
2004-11-08 21:43   ` Andrew Pinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).