public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew Pinski <pinskia@physics.uc.edu>
To: "Joseph S. Myers" <joseph@codesourcery.com>
Cc: "gcc-patches@gcc.gnu.org Patches" <gcc-patches@gcc.gnu.org>
Subject: Re: Fix assert.h on darwin (before 8.0)
Date: Mon, 08 Nov 2004 21:43:00 -0000	[thread overview]
Message-ID: <821B45CC-31CD-11D9-9E21-000A95D692F4@physics.uc.edu> (raw)
In-Reply-To: <Pine.LNX.4.61.0411062345490.7728@digraph.polyomino.org.uk>

[-- 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"

      reply	other threads:[~2004-11-08 21:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-07  0:34 Andrew Pinski
2004-11-07  0:35 ` Joseph S. Myers
2004-11-08 21:43   ` Andrew Pinski [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=821B45CC-31CD-11D9-9E21-000A95D692F4@physics.uc.edu \
    --to=pinskia@physics.uc.edu \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=joseph@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).