This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[RFA] work around sigsetjmp/siglongjmp macro problems


[NOTE: reply-to set to gdb-patches]
On Mon, Aug 13, 2001 at 08:11:16PM -0700, Daniel Jacobowitz wrote:
>> Doh.  Now that you mention it, Cygwin actually already has a mechanism
>> for this.  We bump a minor version number when there are api changes,
>> such as this.  Then we usually define a macro like
>> "CYGWIN_VERSION_SIGSEJMP_IS_OK" based on the API.  It is a little
>> tricky, though, since the actual header file is in newlib not cygwin.
>
>On the other hand, it should be very straightforward to write an
>autoconf test for this.  You said that the code in question looked like
>env[36] instead of (env)[36];  just use an argument that would not be
>valid to subscript.  env + 1[36], for instance, should generally not
>compile.

Luckily, as Andrew has pointed out, there is no reason to go to this
trouble.

My proposed patch is below.  It may even be an obvious fix.

Keith, could you try this out and verify that it fixes the problem?

cgf

2001-08-13  Christopher Faylor  <cgf@cygnus.com>

	* top.c (SIGSETJMP): Protect macro argument with parentheses.
	(SIGLONGJMP): Protect macro argument with parentheses.

Index: top.c
===================================================================
RCS file: /cvs/uberbaum/gdb/top.c,v
retrieving revision 1.42
diff -p -r1.42 top.c
*** top.c	2001/08/01 18:39:23	1.42
--- top.c	2001/08/14 03:05:50
*************** NORETURN void (*error_hook) (void) ATTR_
*** 299,310 ****
     directly.  */
  #if defined(HAVE_SIGSETJMP)
  #define SIGJMP_BUF		sigjmp_buf
! #define SIGSETJMP(buf)		sigsetjmp(buf, 1)
! #define SIGLONGJMP(buf,val)	siglongjmp(buf,val)
  #else
  #define SIGJMP_BUF		jmp_buf
  #define SIGSETJMP(buf)		setjmp(buf)
! #define SIGLONGJMP(buf,val)	longjmp(buf,val)
  #endif
  
  /* Where to go for return_to_top_level.  */
--- 299,310 ----
     directly.  */
  #if defined(HAVE_SIGSETJMP)
  #define SIGJMP_BUF		sigjmp_buf
! #define SIGSETJMP(buf)		sigsetjmp((buf), 1)
! #define SIGLONGJMP(buf,val)	siglongjmp((buf), (val))
  #else
  #define SIGJMP_BUF		jmp_buf
  #define SIGSETJMP(buf)		setjmp(buf)
! #define SIGLONGJMP(buf,val)	longjmp((buf), (val))
  #endif
  
  /* Where to go for return_to_top_level.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]