[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] setjmp.h and csetjmp



> Hello Vincent!

Hello Frank !

> You patch looks good. I suggest to surround it for more modern gcc
> versions by a #ifdef _GCC_VERSION_ (or however this is called) so the
> MiNTLib stays backward compatible with older gcc and other C
> compilers.

This time, I think it is good !
For C programs, longjmp() will remain a macro.
For C++ programs, longjmp() will be an standard inline function.
I can't see any compatibility issue with that.

Anyone agrees ?

Vincent

--- mintlib-CVS/include/setjmp.h	2007-12-09 22:29:12.187500000 +0100
+++ mintlib-CVS-patch-20071209/include/setjmp.h	2007-12-10 21:57:12.296875000 +0100
@@ -24,7 +24,18 @@
 #define _setjmp(__jb)		(sigsetjmp(__jb, 0))
 #define _longjmp(__jb,__v)	(siglongjmp(__jb, __v))
 #define setjmp(__jb)		(sigsetjmp(__jb, 1))
+
+#ifndef __cplusplus
 #define longjmp(__jb,__v)	(siglongjmp(__jb, __v))
+#else /* __cplusplus */
+// <csetjmp> needs a real function instead of a macro.
+static inline void
+longjmp (sigjmp_buf env, int val)
+{
+	siglongjmp(env, val);
+}
+#endif /* __cplusplus */
+
 #endif /* __USE_BSD */
 
 #endif /* __STRICT_ANSI__ */