setjmp

any idea why the following code fails?

#include <setjmp.h>
#include <stdlib.h>

struct JumpBuffer {
jmp_buf buf;
};

inline int
mysetjmp( JumpBuffer *j )
{
return ::setjmp( j->buf );
}

g++ complains at the “return” line with a message:
parse error before `(’

(this code is from xf86 4.1)

frank

Frank Liu <liug@mama.indstate.edu> wrote:

any idea why the following code fails?

#include <setjmp.h
#include <stdlib.h

struct JumpBuffer {
jmp_buf buf;
};

inline int
mysetjmp( JumpBuffer *j )
{
return ::setjmp( j->buf );
}

g++ complains at the “return” line with a message:
parse error before `(’

(this code is from xf86 4.1)

frank

It’s getting expanded to

return :: (__sigjmp_prolog(( j->buf ), ( 1 )), _setjmp( j->buf )) ;

This looks to be a bug in our header file.


cburgess@qnx.com

Thanks Colin,

do you have a quick fix that I can just modify the header file, to
get my port going.
Frank

On 27 Sep 2001, Colin Burgess wrote:

Frank Liu <> liug@mama.indstate.edu> > wrote:

any idea why the following code fails?

#include <setjmp.h
#include <stdlib.h

struct JumpBuffer {
jmp_buf buf;
};

inline int
mysetjmp( JumpBuffer *j )
{
return ::setjmp( j->buf );
}

g++ complains at the “return” line with a message:
parse error before `(’

(this code is from xf86 4.1)

frank

It’s getting expanded to

return :: (__sigjmp_prolog(( j->buf ), ( 1 )), _setjmp( j->buf )) ;

This looks to be a bug in our header file.


cburgess@qnx.com

Frank Liu <liug@mama.indstate.edu> wrote:

Thanks Colin,

do you have a quick fix that I can just modify the header file, to
get my port going.
Frank

Try this diff to setjmp.h

Index: setjmp.h

RCS file: /usr/cvs/product/lib/c/public/setjmp.h,v
retrieving revision 1.18
diff -c -r1.18 setjmp.h
*** setjmp.h 2001/02/28 20:36:27 1.18
— setjmp.h 2001/09/27 18:45:49


*** 41,47 ****
— 41,51 ----
typedef _CSTD jmp_buf sigjmp_buf;
extern void __sigjmp_prolog(sigjmp_buf __env, int __msk);
extern void siglongjmp(sigjmp_buf __env, int __val) attribute((noreturn));

  • #ifdef __cplusplus
  • inline int sigsetjmp(_CSTD jmp_buf __env, int __msk) { return __sigjmp_prolog(__env, __msk), _setjmp(__env); }
  • #else
    #define sigsetjmp(__env, __msk) (__sigjmp_prolog((__env), (__msk)), _setjmp(__env))
  • #endif

#define setjmp(__env) sigsetjmp(__env, 1)
#define longjmp(__env, __val) siglongjmp((__env), (__val))

On 27 Sep 2001, Colin Burgess wrote:

Frank Liu <> liug@mama.indstate.edu> > wrote:

any idea why the following code fails?

#include <setjmp.h
#include <stdlib.h

struct JumpBuffer {
jmp_buf buf;
};

inline int
mysetjmp( JumpBuffer *j )
{
return ::setjmp( j->buf );
}

g++ complains at the “return” line with a message:
parse error before `(’

(this code is from xf86 4.1)

frank

It’s getting expanded to

return :: (__sigjmp_prolog(( j->buf ), ( 1 )), _setjmp( j->buf )) ;

This looks to be a bug in our header file.


cburgess@qnx.com


cburgess@qnx.com

Thanks Colin, it works! You are good man.

On 27 Sep 2001, Colin Burgess wrote:

Frank Liu <> liug@mama.indstate.edu> > wrote:

Thanks Colin,

do you have a quick fix that I can just modify the header file, to
get my port going.
Frank

Try this diff to setjmp.h

Index: setjmp.h

RCS file: /usr/cvs/product/lib/c/public/setjmp.h,v
retrieving revision 1.18
diff -c -r1.18 setjmp.h
*** setjmp.h 2001/02/28 20:36:27 1.18
— setjmp.h 2001/09/27 18:45:49


*** 41,47 ****
— 41,51 ----
typedef _CSTD jmp_buf sigjmp_buf;
extern void __sigjmp_prolog(sigjmp_buf __env, int __msk);
extern void siglongjmp(sigjmp_buf __env, int __val) attribute((noreturn));

  • #ifdef __cplusplus
  • inline int sigsetjmp(_CSTD jmp_buf __env, int __msk) { return __sigjmp_prolog(__env, __msk), _setjmp(__env); }
  • #else
    #define sigsetjmp(__env, __msk) (__sigjmp_prolog((__env), (__msk)), _setjmp(__env))
  • #endif

#define setjmp(__env) sigsetjmp(__env, 1)
#define longjmp(__env, __val) siglongjmp((__env), (__val))

On 27 Sep 2001, Colin Burgess wrote:

Frank Liu <> liug@mama.indstate.edu> > wrote:

any idea why the following code fails?

#include <setjmp.h
#include <stdlib.h

struct JumpBuffer {
jmp_buf buf;
};

inline int
mysetjmp( JumpBuffer *j )
{
return ::setjmp( j->buf );
}

g++ complains at the “return” line with a message:
parse error before `(’

(this code is from xf86 4.1)

frank

It’s getting expanded to

return :: (__sigjmp_prolog(( j->buf ), ( 1 )), _setjmp( j->buf )) ;

This looks to be a bug in our header file.


cburgess@qnx.com


\

cburgess@qnx.com