[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Libunwind-devel] Fix compilation on non-glibc machines.
From: |
Konstantin Belousov |
Subject: |
Re: [Libunwind-devel] Fix compilation on non-glibc machines. |
Date: |
Mon, 28 Nov 2011 11:44:25 +0200 |
User-agent: |
Mutt/1.4.2.3i |
On Sun, Nov 27, 2011 at 07:07:44PM -0800, Arun Sharma wrote:
> On Sat, Nov 26, 2011 at 9:30 AM, Konstantin Belousov
> <address@hidden> wrote:
>
> > Trying to hide __GLIBC_PREREQ under #ifdef __GLIBC would require
> > either code duplication, or moving the longjmp implementation into
> > the separate file, which is included twice. In fact, I am not sure
> > in any use of the __GLIBC_PREREQ at the compile time, because the
> > compiled code can be run on the later version of glibc.
>
> Why #if defined(__GLIBC_PREREQ) in siglongjmp.c, but #if
> defined(__GLIBC__) in longjmp.c?
Due to my sloppiness. Updated patch attached.
diff --git a/src/setjmp/longjmp.c b/src/setjmp/longjmp.c
index 00a58c2..bf2df4c 100644
--- a/src/setjmp/longjmp.c
+++ b/src/setjmp/longjmp.c
@@ -35,7 +35,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. */
#include "jmpbuf.h"
#include "setjmp_i.h"
-#if defined(__GLIBC__) && __GLIBC_PREREQ(2, 4)
+#if defined(__GLIBC__)
+#if __GLIBC_PREREQ(2, 4)
/* Starting with glibc-2.4, {sig,}setjmp in GLIBC obfuscates the
register values in jmp_buf by XORing them with a "random"
@@ -46,8 +47,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. */
Doing so is possible, but doesn't appear to be worth the trouble,
so we simply defer to glibc longjmp here. */
-
-#else
+#define _longjmp __nonworking__longjmp
+#define longjmp __nonworking_longjmp
+static void _longjmp (jmp_buf env, int val);
+static void longjmp (jmp_buf env, int val);
+#endif
+#endif
void
_longjmp (jmp_buf env, int val)
@@ -95,7 +100,9 @@ _longjmp (jmp_buf env, int val)
}
#ifdef __GNUC__
-void longjmp (jmp_buf env, int val) __attribute__ ((alias ("_longjmp")));
+#define STRINGIFY1(x) #x
+#define STRINGIFY(x) STRINGIFY1(x)
+void longjmp (jmp_buf env, int val) __attribute__ ((alias
(STRINGIFY(_longjmp))));
#else
void
@@ -104,6 +111,4 @@ longjmp (jmp_buf env, int val)
_longjmp (env, val);
}
-#endif /* __GLIBC__ */
-
#endif
diff --git a/src/setjmp/siglongjmp.c b/src/setjmp/siglongjmp.c
index bfe148b..af417fb 100644
--- a/src/setjmp/siglongjmp.c
+++ b/src/setjmp/siglongjmp.c
@@ -35,7 +35,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. */
# define _NSIG (_SIG_MAXSIG - 1)
#endif
-#if defined(__GLIBC__) && __GLIBC_PREREQ(2, 4)
+#if defined(__GLIBC__)
+#if __GLIBC_PREREQ(2, 4)
/* Starting with glibc-2.4, {sig,}setjmp in GLIBC obfuscates the
register values in jmp_buf by XORing them with a "random"
@@ -47,7 +48,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. */
Doing so is possible, but doesn't appear to be worth the trouble,
so we simply defer to glibc siglongjmp here. */
-#else
+#define siglongjmp __nonworking_siglongjmp
+static void siglongjmp (sigjmp_buf env, int val);
+#endif
+#endif
void
siglongjmp (sigjmp_buf env, int val)
@@ -114,5 +120,3 @@ siglongjmp (sigjmp_buf env, int val)
abort ();
}
-
-#endif /* __GLIBC__ */
pgpRdnDXsIPhu.pgp
Description: PGP signature