[m-rev.] diff: port to FreeBSD
Fergus Henderson
fjh at cs.mu.OZ.AU
Wed Mar 14 04:32:11 AEDT 2001
Estimated hours taken: 2
Branches: main release
Apply Samuel Tardieu <sam at inf.enst.fr>'s fixes for FreeBSD
(with some additional documentation).
configure.in:
runtime/mercury_conf.h.in:
Check for <sys/signal.h>.
runtime/mercury_memory_zones.c:
runtime/mercury_memory_handlers.c:
Include <sys/signal.h> (if present) before <ucontext.h>.
This is needed on FREEBSD because <ucontext.h> refers to
sigset_t without defining it.
configure.in:
runtime/mercury_memory_handlers.c:
Change the autoconf test for siginfo_t so that it doesn't use macros
like BUS_ADRALN etc. Instead, surround all uses of such macros
with #ifdef BUS_ADRALN ... #endif.
boehm_gc/dyn_load.c:
Enable support for ELF shared libraries on FREEBSD
(using the same code as on Linux).
Workspace: /home/venus/fjh/ws-venus/mercury
Index: boehm_gc/dyn_load.c
===================================================================
RCS file: /home/mercury1/repository/mercury/boehm_gc/dyn_load.c,v
retrieving revision 1.11
diff -u -d -r1.11 dyn_load.c
--- boehm_gc/dyn_load.c 2000/09/18 11:08:50 1.11
+++ boehm_gc/dyn_load.c 2001/03/13 17:18:54
@@ -50,7 +50,7 @@
#if !defined(SUNOS4) && !defined(SUNOS5DL) && !defined(IRIX5) && \
!defined(MSWIN32) && !(defined(ALPHA) && defined(OSF1)) && \
!defined(HPUX) && !(defined(LINUX) && defined(__ELF__)) && \
- !defined(RS6000) && !defined(SCO_ELF)
+ !defined(RS6000) && !defined(SCO_ELF) && !defined(FREEBSD)
--> We only know how to find data segments of dynamic libraries for the
--> above. Additional SVR4 variants might not be too
--> hard to add.
@@ -297,7 +297,7 @@
# endif /* !USE_PROC ... */
# endif /* SUNOS */
-#if defined(LINUX) && defined(__ELF__) || defined(SCO_ELF)
+#if defined(LINUX) && defined(__ELF__) || defined(SCO_ELF) || defined(FREEBSD)
/* Dynamic loading code for Linux running ELF. Somewhat tested on
* Linux/x86, untested but hopefully should work on Linux/Alpha.
Index: configure.in
===================================================================
RCS file: /home/mercury1/repository/mercury/configure.in,v
retrieving revision 1.247.4.2
diff -u -d -r1.247.4.2 configure.in
--- configure.in 2001/02/28 13:05:52 1.247.4.2
+++ configure.in 2001/03/13 17:16:59
@@ -474,6 +474,11 @@
AC_DEFINE(HAVE_SYS_SIGINFO)
fi
#-----------------------------------------------------------------------------#
+AC_CHECK_HEADER(sys/signal.h, HAVE_SYS_SIGNAL_H=1)
+if test "$HAVE_SYS_SIGNAL_H" = 1; then
+ AC_DEFINE(HAVE_SYS_SIGNAL)
+fi
+#-----------------------------------------------------------------------------#
AC_CHECK_HEADER(ucontext.h, HAVE_UCONTEXT_H=1)
if test "$HAVE_UCONTEXT_H" = 1; then
AC_DEFINE(HAVE_UCONTEXT)
@@ -749,6 +754,9 @@
#ifdef HAVE_SYS_SIGINFO
#include <sys/siginfo.h>
#endif
+ #ifdef HAVE_SYS_SIGNAL
+ #include <sys/signal.h>
+ #endif
#ifdef HAVE_UCONTEXT
#include <ucontext.h>
#endif
@@ -775,20 +783,6 @@
}
void handler(int signum, siginfo_t *info, void *context) {
save_signum = signum;
- switch (info->si_code) {
- case SEGV_MAPERR: save_cause = info->si_code;
- break;
- case SEGV_ACCERR: save_cause = info->si_code;
- break;
- }
- switch (info->si_code) {
- case BUS_ADRALN: save_cause = info->si_code;
- break;
- case BUS_ADRERR: save_cause = info->si_code;
- break;
- case BUS_OBJERR: save_cause = info->si_code;
- break;
- }
save_cause = info->si_code;
}], [mercury_cv_siginfo_t=yes], [true], [true]))
AC_MSG_RESULT($mercury_cv_siginfo_t)
Index: runtime/mercury_conf.h.in
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_conf.h.in,v
retrieving revision 1.33
diff -u -d -r1.33 mercury_conf.h.in
--- runtime/mercury_conf.h.in 2000/11/20 13:39:16 1.33
+++ runtime/mercury_conf.h.in 2001/03/13 17:17:07
@@ -99,6 +99,7 @@
** is available:
**
** HAVE_SYS_SIGINFO we have <sys/siginfo.h>
+** HAVE_SYS_SIGNAL we have <sys/signal.h>
** HAVE_UCONTEXT we have <ucontext.h>
** HAVE_SYS_UCONTEXT we have <sys/ucontext.h>
** HAVE_ASM_SIGCONTEXT we have <asm/sigcontext.h> (e.g. i386 Linux)
@@ -112,6 +113,7 @@
** HAVE_DLFCN_H we have <dlfcn.h>
*/
#undef HAVE_SYS_SIGINFO
+#undef HAVE_SYS_SIGNAL
#undef HAVE_UCONTEXT
#undef HAVE_SYS_UCONTEXT
#undef HAVE_ASM_SIGCONTEXT
Index: runtime/mercury_memory_handlers.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_memory_handlers.c,v
retrieving revision 1.19
diff -u -d -r1.19 mercury_memory_handlers.c
--- runtime/mercury_memory_handlers.c 2000/11/27 13:18:07 1.19
+++ runtime/mercury_memory_handlers.c 2001/03/13 17:27:16
@@ -59,6 +59,11 @@
#include <sys/siginfo.h>
#endif
+#ifdef HAVE_SYS_SIGNAL
+ /* on FREEBSD we need to include <sys/signal.h> before <ucontext.h> */
+ #include <sys/signal.h>
+#endif
+
#ifdef HAVE_MPROTECT
#include <sys/mman.h>
#endif
@@ -425,18 +430,48 @@
fprintf(stderr, "cause: ");
switch (info->si_code)
{
+#ifdef BUS_ADRALN
case BUS_ADRALN:
fprintf(stderr, "invalid address alignment\n");
break;
+#endif
+#ifdef BUS_ADRERR
case BUS_ADRERR:
fprintf(stderr, "non-existent physical address\n");
break;
+#endif
+#ifdef BUS_OBJERR
case BUS_OBJERR:
fprintf(stderr, "object specific hardware error\n");
break;
+#endif
+
+#ifdef BUS_PAGE_FAULT
+ case BUS_PAGE_FAULT:
+ fprintf(stderr, "page fault protection base\n");
+ break;
+#endif
+#ifdef BUS_SEGNP_FAULT
+ case BUS_SEGNP_FAULT:
+ fprintf(stderr, "segment not present\n");
+ break;
+#endif
+
+#ifdef BUS_STK_FAULT
+ case BUS_STK_FAULT:
+ fprintf(stderr, "stack segment\n");
+ break;
+#endif
+
+#ifdef BUS_SEGM_FAULT
+ case BUS_SEGM_FAULT:
+ fprintf(stderr, "segment protection base\n");
+ break;
+#endif
+
default:
fprintf(stderr, "unknown\n");
break;
@@ -471,13 +506,17 @@
fprintf(stderr, "cause: ");
switch (info->si_code)
{
+#ifdef SEGV_MAPERR
case SEGV_MAPERR:
fprintf(stderr, "address not mapped to object\n");
break;
+#endif
+#ifdef SEGV_ACCERR
case SEGV_ACCERR:
fprintf(stderr, "bad permissions for mapped object\n");
break;
+#endif
default:
fprintf(stderr, "unknown\n");
Index: runtime/mercury_memory_zones.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_memory_zones.c,v
retrieving revision 1.15
diff -u -d -r1.15 mercury_memory_zones.c
--- runtime/mercury_memory_zones.c 2000/11/23 02:00:35 1.15
+++ runtime/mercury_memory_zones.c 2001/03/13 17:26:01
@@ -35,6 +35,11 @@
#include <sys/siginfo.h>
#endif
+#ifdef HAVE_SYS_SIGNAL
+ /* on FREEBSD we need to include <sys/signal.h> before <ucontext.h> */
+ #include <sys/signal.h>
+#endif
+
#ifdef HAVE_MPROTECT
#include <sys/mman.h>
#endif
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
| of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list