* Problems with <setjmp.h> and libguile/__scm.h on HP-UX/IA64
@ 2009-03-25 22:10 Albert Chin
2009-03-26 23:22 ` Neil Jerram
0 siblings, 1 reply; 5+ messages in thread
From: Albert Chin @ 2009-03-25 22:10 UTC (permalink / raw)
To: guile-devel
libguile/__scm.h has:
# if defined (__ia64__)
/* For IA64, emulate the setjmp API using getcontext. */
# include <signal.h>
# include <ucontext.h>
typedef struct {
ucontext_t ctx;
int fresh;
} jmp_buf;
# define setjmp(JB) \
( (JB).fresh = 1, \
getcontext (&((JB).ctx)), \
((JB).fresh ? ((JB).fresh = 0, 0) : 1) )
# define longjmp(JB,VAL) scm_ia64_longjmp (&(JB), VAL)
void scm_ia64_longjmp (jmp_buf *, int);
But, on HP-UX/IA64, <setjmp.h> has a conflicting declaration of jmp_buf.
So, on this platform, how do you use <setjmp.h> and libguile/__scm.h?
Autogen-5.9.7 fails to compile on this platform because of this:
cc -AC99 -DHAVE_CONFIG_H -I. -I.. -I.. -I../autoopts
-I/opt/TWWfsw/libxml26/include/libxml2 -I/opt/TWWfsw/guile18/include
-I/opt/TWWfsw/libgmp42/include -D_REENTRANT -D_REENTRANT -mt -z +O1
+Ofltacc +Olit=all +Oentrysched +Odataprefetch -c -o autogen-ag.o `test
-f 'ag.c' || echo './'`ag.c
"/opt/TWWfsw/guile18/include/libguile/__scm.h", line 412: error #2256: invalid
redeclaration of type name "jmp_buf" (declared at line 22 of
"/usr/include/setjmp.h")
} jmp_buf;
^
1 error detected in the compilation of "ag.c".
gmake[3]: *** [autogen-ag.o] Error 2
gmake[3]: Leaving directory `/opt/build/autogen-5.9.7/agen5'
--
albert chin (china@thewrittenword.com)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Problems with <setjmp.h> and libguile/__scm.h on HP-UX/IA64
2009-03-25 22:10 Problems with <setjmp.h> and libguile/__scm.h on HP-UX/IA64 Albert Chin
@ 2009-03-26 23:22 ` Neil Jerram
2009-08-14 16:50 ` Neil Jerram
0 siblings, 1 reply; 5+ messages in thread
From: Neil Jerram @ 2009-03-26 23:22 UTC (permalink / raw)
To: guile-devel
Albert Chin <guile-devel@mlists.thewrittenword.com> writes:
> libguile/__scm.h has:
> # if defined (__ia64__)
> /* For IA64, emulate the setjmp API using getcontext. */
> # include <signal.h>
> # include <ucontext.h>
> typedef struct {
> ucontext_t ctx;
> int fresh;
> } jmp_buf;
> # define setjmp(JB) \
> ( (JB).fresh = 1, \
> getcontext (&((JB).ctx)), \
> ((JB).fresh ? ((JB).fresh = 0, 0) : 1) )
> # define longjmp(JB,VAL) scm_ia64_longjmp (&(JB), VAL)
> void scm_ia64_longjmp (jmp_buf *, int);
>
> But, on HP-UX/IA64, <setjmp.h> has a conflicting declaration of jmp_buf.
Thanks for the report. This is also a Debian bug [1], and their patch
is [2].
[1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=506684
[2] http://patch-tracking.debian.net/patch/series/view/guile-1.8/1.8.5+1-4.1/dont-redefine-jmp_buf.diff
I will work on this soon. I expect my fix to be similar to Debian's -
i.e. introducing scm_jmp_buf, scm_setjmp and scm_longjmp - but not
identical.
Regards,
Neil
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Problems with <setjmp.h> and libguile/__scm.h on HP-UX/IA64
2009-03-26 23:22 ` Neil Jerram
@ 2009-08-14 16:50 ` Neil Jerram
2009-08-14 18:20 ` Ludovic Courtès
0 siblings, 1 reply; 5+ messages in thread
From: Neil Jerram @ 2009-08-14 16:50 UTC (permalink / raw)
To: guile-devel
[-- Attachment #1: Type: text/plain, Size: 543 bytes --]
Neil Jerram <neil@ossau.uklinux.net> writes:
> Albert Chin <guile-devel@mlists.thewrittenword.com> writes:
>> But, on HP-UX/IA64, <setjmp.h> has a conflicting declaration of jmp_buf.
>
> Thanks for the report. This is also a Debian bug [1], and their patch
> is [2].
>
> [1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=506684
> [2] http://patch-tracking.debian.net/patch/series/view/guile-1.8/1.8.5+1-4.1/dont-redefine-jmp_buf.diff
Here's my proposed fix for this, for 1.8 and master. Please let me
know of any comments.
Neil
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Avoid-clash-with-system-setjmp-longjmp-on-IA64.patch --]
[-- Type: text/x-diff, Size: 7151 bytes --]
From 26adbdf1ea98e20124f44960a8e0dfa302306991 Mon Sep 17 00:00:00 2001
From: Neil Jerram <neil@ossau.uklinux.net>
Date: Wed, 5 Aug 2009 16:13:28 +0100
Subject: [PATCH] Avoid clash with system setjmp/longjmp on IA64
Problem was that if an application includes both libguile.h and the
system's setjmp.h, and is compiled on IA64, it gets compile errors
because of jmp_buf, setjmp and longjmp being multiply defined.
* libguile/__scm.h (__ia64__): Define scm_i_jmp_buf, SCM_I_SETJMP and
SCM_I_LONGJMP instead of jmp_buf, setjmp and longjmp.
(all other platforms): Map scm_i_jmp_buf, SCM_I_SETJMP and
SCM_I_LONGJMP to jmp_buf, setjmp and longjmp.
* libguile/continuations.c (scm_make_continuation): Use `SCM_I_SETJMP'
instead of `setjmp'.
(copy_stack_and_call): Use `SCM_I_LONJMP' instead of `longjmp'.
(scm_ia64_longjmp): Use type `scm_i_jmp_buf' instead of `jmp_buf'.
* libguile/continuations.h (scm_t_contregs): Use type `scm_i_jmp_buf'
instead of `jmp_buf'.
* libguile/threads.c (suspend): Use `SCM_I_SETJMP' instead of
`setjmp'.
* libguile/threads.h (scm_i_thread): Use type `scm_i_jmp_buf' instead
of `jmp_buf'.
* libguile/throw.c (JBJMPBUF, make_jmpbuf, jmp_buf_and_retval): Use
type `scm_i_jmp_buf' instead of `jmp_buf'.
(scm_c_catch): Use `SCM_I_SETJMP' instead of `setjmp'.
(scm_ithrow): Use `SCM_I_LONGJMP' instead of `longjmp'.
---
libguile/__scm.h | 17 +++++++++++++----
libguile/continuations.c | 6 +++---
libguile/continuations.h | 2 +-
libguile/threads.c | 6 +++---
libguile/threads.h | 2 +-
libguile/throw.c | 10 +++++-----
6 files changed, 26 insertions(+), 17 deletions(-)
diff --git a/libguile/__scm.h b/libguile/__scm.h
index 29b371d..6782654 100644
--- a/libguile/__scm.h
+++ b/libguile/__scm.h
@@ -423,19 +423,28 @@
typedef struct {
ucontext_t ctx;
int fresh;
- } jmp_buf;
-# define setjmp(JB) \
+ } scm_i_jmp_buf;
+# define SCM_I_SETJMP(JB) \
( (JB).fresh = 1, \
getcontext (&((JB).ctx)), \
((JB).fresh ? ((JB).fresh = 0, 0) : 1) )
-# define longjmp(JB,VAL) scm_ia64_longjmp (&(JB), VAL)
- void scm_ia64_longjmp (jmp_buf *, int);
+# define SCM_I_LONGJMP(JB,VAL) scm_ia64_longjmp (&(JB), VAL)
+ void scm_ia64_longjmp (scm_i_jmp_buf *, int);
# else /* ndef __ia64__ */
# include <setjmp.h>
# endif /* ndef __ia64__ */
# endif /* ndef _CRAY1 */
#endif /* ndef vms */
+/* For any platform where SCM_I_SETJMP hasn't been defined in some
+ special way above, map SCM_I_SETJMP, SCM_I_LONGJMP and
+ scm_i_jmp_buf to setjmp, longjmp and jmp_buf. */
+#ifndef SCM_I_SETJMP
+#define scm_i_jmp_buf jmp_buf
+#define SCM_I_SETJMP setjmp
+#define SCM_I_LONGJMP longjmp
+#endif
+
/* James Clark came up with this neat one instruction fix for
* continuations on the SPARC. It flushes the register windows so
* that all the state of the process is contained in the stack.
diff --git a/libguile/continuations.c b/libguile/continuations.c
index f856476..347bd80 100644
--- a/libguile/continuations.c
+++ b/libguile/continuations.c
@@ -131,7 +131,7 @@ scm_make_continuation (int *first)
SCM_NEWSMOB (cont, scm_tc16_continuation, continuation);
- *first = !setjmp (continuation->jmpbuf);
+ *first = !SCM_I_SETJMP (continuation->jmpbuf);
if (*first)
{
#ifdef __ia64__
@@ -229,12 +229,12 @@ copy_stack_and_call (scm_t_contregs *continuation, SCM val,
scm_i_set_last_debug_frame (continuation->dframe);
continuation->throw_value = val;
- longjmp (continuation->jmpbuf, 1);
+ SCM_I_LONGJMP (continuation->jmpbuf, 1);
}
#ifdef __ia64__
void
-scm_ia64_longjmp (jmp_buf *JB, int VAL)
+scm_ia64_longjmp (scm_i_jmp_buf *JB, int VAL)
{
scm_i_thread *t = SCM_I_CURRENT_THREAD;
diff --git a/libguile/continuations.h b/libguile/continuations.h
index 08eec8f..82cf178 100644
--- a/libguile/continuations.h
+++ b/libguile/continuations.h
@@ -44,7 +44,7 @@ SCM_API scm_t_bits scm_tc16_continuation;
typedef struct
{
SCM throw_value;
- jmp_buf jmpbuf;
+ scm_i_jmp_buf jmpbuf;
SCM dynenv;
#ifdef __ia64__
void *backing_store;
diff --git a/libguile/threads.c b/libguile/threads.c
index 9589336..1721e0b 100644
--- a/libguile/threads.c
+++ b/libguile/threads.c
@@ -312,7 +312,7 @@ unblock_from_queue (SCM queue)
var 't'
// save registers.
SCM_FLUSH_REGISTER_WINDOWS; // sparc only
- setjmp (t->regs); // here's most of the magic
+ SCM_I_SETJMP (t->regs); // here's most of the magic
... and returns.
@@ -366,7 +366,7 @@ unblock_from_queue (SCM queue)
t->top = SCM_STACK_PTR (&t);
// save registers.
SCM_FLUSH_REGISTER_WINDOWS;
- setjmp (t->regs);
+ SCM_I_SETJMP (t->regs);
res = func(data);
scm_enter_guile (t);
@@ -425,7 +425,7 @@ suspend (void)
t->top = SCM_STACK_PTR (&t);
/* save registers. */
SCM_FLUSH_REGISTER_WINDOWS;
- setjmp (t->regs);
+ SCM_I_SETJMP (t->regs);
return t;
}
diff --git a/libguile/threads.h b/libguile/threads.h
index 32b0ea6..9a1b6f0 100644
--- a/libguile/threads.h
+++ b/libguile/threads.h
@@ -123,7 +123,7 @@ typedef struct scm_i_thread {
SCM vm;
SCM_STACKITEM *base;
SCM_STACKITEM *top;
- jmp_buf regs;
+ scm_i_jmp_buf regs;
#ifdef __ia64__
void *register_backing_store_base;
scm_t_contregs *pending_rbs_continuation;
diff --git a/libguile/throw.c b/libguile/throw.c
index b48bea1..4413efa 100644
--- a/libguile/throw.c
+++ b/libguile/throw.c
@@ -59,7 +59,7 @@ static scm_t_bits tc16_jmpbuffer;
#define DEACTIVATEJB(x) \
(SCM_SET_CELL_WORD_0 ((x), (SCM_CELL_WORD_0 (x) & ~(1L << 16L))))
-#define JBJMPBUF(OBJ) ((jmp_buf *) SCM_CELL_WORD_1 (OBJ))
+#define JBJMPBUF(OBJ) ((scm_i_jmp_buf *) SCM_CELL_WORD_1 (OBJ))
#define SETJBJMPBUF(x, v) (SCM_SET_CELL_WORD_1 ((x), (scm_t_bits) (v)))
#define SCM_JBDFRAME(x) ((scm_t_debug_frame *) SCM_CELL_WORD_2 (x))
#define SCM_SETJBDFRAME(x, v) (SCM_SET_CELL_WORD_2 ((x), (scm_t_bits) (v)))
@@ -81,7 +81,7 @@ make_jmpbuf (void)
{
SCM answer;
SCM_NEWSMOB2 (answer, tc16_jmpbuffer, 0, 0);
- SETJBJMPBUF(answer, (jmp_buf *)0);
+ SETJBJMPBUF(answer, (scm_i_jmp_buf *)0);
DEACTIVATEJB(answer);
return answer;
}
@@ -91,7 +91,7 @@ make_jmpbuf (void)
struct jmp_buf_and_retval /* use only on the stack, in scm_catch */
{
- jmp_buf buf; /* must be first */
+ scm_i_jmp_buf buf; /* must be first */
SCM throw_tag;
SCM retval;
};
@@ -194,7 +194,7 @@ scm_c_catch (SCM tag,
pre_unwind.lazy_catch_p = 0;
SCM_SETJBPREUNWIND(jmpbuf, &pre_unwind);
- if (setjmp (jbr.buf))
+ if (SCM_I_SETJMP (jbr.buf))
{
SCM throw_tag;
SCM throw_args;
@@ -884,7 +884,7 @@ scm_ithrow (SCM key, SCM args, int noreturn SCM_UNUSED)
jbr->throw_tag = key;
jbr->retval = args;
scm_i_set_last_debug_frame (SCM_JBDFRAME (jmpbuf));
- longjmp (*JBJMPBUF (jmpbuf), 1);
+ SCM_I_LONGJMP (*JBJMPBUF (jmpbuf), 1);
}
/* Otherwise, it's some random piece of junk. */
--
1.5.6.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: Problems with <setjmp.h> and libguile/__scm.h on HP-UX/IA64
2009-08-14 16:50 ` Neil Jerram
@ 2009-08-14 18:20 ` Ludovic Courtès
2009-08-14 21:06 ` Neil Jerram
0 siblings, 1 reply; 5+ messages in thread
From: Ludovic Courtès @ 2009-08-14 18:20 UTC (permalink / raw)
To: guile-devel
Neil Jerram <neil@ossau.uklinux.net> writes:
> Neil Jerram <neil@ossau.uklinux.net> writes:
>
>> Albert Chin <guile-devel@mlists.thewrittenword.com> writes:
>
>>> But, on HP-UX/IA64, <setjmp.h> has a conflicting declaration of jmp_buf.
>>
>> Thanks for the report. This is also a Debian bug [1], and their patch
>> is [2].
>>
>> [1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=506684
>> [2] http://patch-tracking.debian.net/patch/series/view/guile-1.8/1.8.5+1-4.1/dont-redefine-jmp_buf.diff
>
> Here's my proposed fix for this, for 1.8 and master. Please let me
> know of any comments.
Looks good to me (you can still commit it for 1.9.2 if you want).
Thanks!
Ludo'.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Problems with <setjmp.h> and libguile/__scm.h on HP-UX/IA64
2009-08-14 18:20 ` Ludovic Courtès
@ 2009-08-14 21:06 ` Neil Jerram
0 siblings, 0 replies; 5+ messages in thread
From: Neil Jerram @ 2009-08-14 21:06 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: guile-devel
ludo@gnu.org (Ludovic Courtès) writes:
> Looks good to me (you can still commit it for 1.9.2 if you want).
Thanks, but I think it's OK to wait. Even if we lose out on some
testing, and eventually release 2.0 with a bug, it's still only a bug
fix needed that we can add later.
Neil
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-08-14 21:06 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-25 22:10 Problems with <setjmp.h> and libguile/__scm.h on HP-UX/IA64 Albert Chin
2009-03-26 23:22 ` Neil Jerram
2009-08-14 16:50 ` Neil Jerram
2009-08-14 18:20 ` Ludovic Courtès
2009-08-14 21:06 ` Neil Jerram
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).