public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* Fix ia64/sys/ucontext.h für g++ 3.5
@ 2004-09-01  9:32 Andreas Schwab
  2004-09-01 17:25 ` Richard Henderson
  2004-09-02  3:40 ` Ulrich Drepper
  0 siblings, 2 replies; 7+ messages in thread
From: Andreas Schwab @ 2004-09-01  9:32 UTC (permalink / raw)
  To: libc-hacker

G++ 3.5 no longer treats _SC_GR0_OFFSET as an integral constant expression.

2004-09-01  Andreas Schwab  <schwab@suse.de>

	* sysdeps/unix/sysv/linux/ia64/sys/ucontext.h [g++ >= 3.5]: Use
	__builtin_offsetof.

--- sysdeps/unix/sysv/linux/ia64/sys/ucontext.h.~1.7.~	2003-01-16 11:33:48.000000000 +0100
+++ sysdeps/unix/sysv/linux/ia64/sys/ucontext.h	2004-09-01 11:26:14.058657019 +0200
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 2000, 2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -32,7 +32,10 @@
 
 typedef struct sigcontext mcontext_t;
 
-#ifdef __GNUC__
+#if defined __cplusplus && __GNUC_PREREQ (3, 5)
+# define _SC_GR0_OFFSET	\
+	__builtin_offsetof (struct sigcontext, sc_gr[0])
+#elif defined __GNUC__
 # define _SC_GR0_OFFSET	\
 	(((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)
 #else

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

* Re: Fix ia64/sys/ucontext.h für g++ 3.5
  2004-09-01  9:32 Fix ia64/sys/ucontext.h für g++ 3.5 Andreas Schwab
@ 2004-09-01 17:25 ` Richard Henderson
  2004-09-01 20:56   ` Andreas Schwab
  2004-09-02  3:40 ` Ulrich Drepper
  1 sibling, 1 reply; 7+ messages in thread
From: Richard Henderson @ 2004-09-01 17:25 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: libc-hacker

On Wed, Sep 01, 2004 at 11:32:21AM +0200, Andreas Schwab wrote:
> 	* sysdeps/unix/sysv/linux/ia64/sys/ucontext.h [g++ >= 3.5]: Use
> 	__builtin_offsetof.

Perhaps include stddef.h and use offsetof properly?


r~

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

* Re: Fix ia64/sys/ucontext.h für g++ 3.5
  2004-09-01 17:25 ` Richard Henderson
@ 2004-09-01 20:56   ` Andreas Schwab
  2004-09-01 21:07     ` Ulrich Drepper
  0 siblings, 1 reply; 7+ messages in thread
From: Andreas Schwab @ 2004-09-01 20:56 UTC (permalink / raw)
  To: libc-hacker

Richard Henderson <rth@twiddle.net> writes:

> On Wed, Sep 01, 2004 at 11:32:21AM +0200, Andreas Schwab wrote:
>> 	* sysdeps/unix/sysv/linux/ia64/sys/ucontext.h [g++ >= 3.5]: Use
>> 	__builtin_offsetof.
>
> Perhaps include stddef.h and use offsetof properly?

If it's ok to include that here, sure.

2004-09-01  Andreas Schwab  <schwab@suse.de>

	* sysdeps/unix/sysv/linux/ia64/sys/ucontext.h: Repace
	_SC_GR0_OFFSET by offsetof.

--- sysdeps/unix/sysv/linux/ia64/sys/ucontext.h	16 Jan 2003 11:33:48 +0100	1.7
+++ sysdeps/unix/sysv/linux/ia64/sys/ucontext.h	01 Sep 2004 22:41:55 +0200	
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 2000, 2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -21,6 +21,7 @@
 
 #include <features.h>
 #include <signal.h>
+#include <stddef.h>
 
 #include <bits/sigcontext.h>
 
@@ -32,13 +33,6 @@
 
 typedef struct sigcontext mcontext_t;
 
-#ifdef __GNUC__
-# define _SC_GR0_OFFSET	\
-	(((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)
-#else
-# define _SC_GR0_OFFSET	0xc8	/* pray that this is correct... */
-#endif
-
 typedef struct ucontext
   {
     union
@@ -46,7 +40,7 @@ typedef struct ucontext
 	mcontext_t _mc;
 	struct
 	  {
-	    unsigned long _pad[_SC_GR0_OFFSET/8];
+	    unsigned long _pad[offsetof (struct sigcontext, sc_gr[0]) / 8];
 	    struct ucontext *_link;	/* this should overlay sc_gr[0] */
 	  }
 	_uc;

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

* Re: Fix ia64/sys/ucontext.h für g++ 3.5
  2004-09-01 20:56   ` Andreas Schwab
@ 2004-09-01 21:07     ` Ulrich Drepper
  2004-09-01 21:11       ` Jakub Jelinek
  0 siblings, 1 reply; 7+ messages in thread
From: Ulrich Drepper @ 2004-09-01 21:07 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: libc-hacker

Andreas Schwab wrote:

> If it's ok to include that here, sure.

It's not OK, POSIX does not allow this.

-- 
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖

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

* Re: Fix ia64/sys/ucontext.h für g++ 3.5
  2004-09-01 21:07     ` Ulrich Drepper
@ 2004-09-01 21:11       ` Jakub Jelinek
  2004-09-04  1:58         ` Richard Henderson
  0 siblings, 1 reply; 7+ messages in thread
From: Jakub Jelinek @ 2004-09-01 21:11 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: Andreas Schwab, libc-hacker

On Wed, Sep 01, 2004 at 02:06:53PM -0700, Ulrich Drepper wrote:
> Andreas Schwab wrote:
> 
> > If it's ok to include that here, sure.
> 
> It's not OK, POSIX does not allow this.

Can't it just use the hardcoded value (0xc8 or what was it) and
do a glibc compile time check somewhere that it is the correct value?
I mean, struct sigcontext shouldn't be changing at all, otherwise we're in
big trouble compatibility wise.

	Jakub

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

* Re: Fix ia64/sys/ucontext.h für g++ 3.5
  2004-09-01  9:32 Fix ia64/sys/ucontext.h für g++ 3.5 Andreas Schwab
  2004-09-01 17:25 ` Richard Henderson
@ 2004-09-02  3:40 ` Ulrich Drepper
  1 sibling, 0 replies; 7+ messages in thread
From: Ulrich Drepper @ 2004-09-02  3:40 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: libc-hacker

I applied the original patch.

-- 
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖

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

* Re: Fix ia64/sys/ucontext.h für g++ 3.5
  2004-09-01 21:11       ` Jakub Jelinek
@ 2004-09-04  1:58         ` Richard Henderson
  0 siblings, 0 replies; 7+ messages in thread
From: Richard Henderson @ 2004-09-04  1:58 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Ulrich Drepper, Andreas Schwab, libc-hacker

On Wed, Sep 01, 2004 at 08:53:38PM +0200, Jakub Jelinek wrote:
> Can't it just use the hardcoded value (0xc8 or what was it) and
> do a glibc compile time check somewhere that it is the correct value?

That does seem the best solution.

If you can't use offsetof, then eventually this code will break in C,
with -pedantic, as soon as Joseph Myers gets around to fixing the 
parser wrt integer constant expressions.


r~

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

end of thread, other threads:[~2004-09-04  1:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-01  9:32 Fix ia64/sys/ucontext.h für g++ 3.5 Andreas Schwab
2004-09-01 17:25 ` Richard Henderson
2004-09-01 20:56   ` Andreas Schwab
2004-09-01 21:07     ` Ulrich Drepper
2004-09-01 21:11       ` Jakub Jelinek
2004-09-04  1:58         ` Richard Henderson
2004-09-02  3:40 ` Ulrich Drepper

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).