1 |
/* GCL config file for Mac OS X v10.2 (aurelienDOTchanudetATm4xDOTorg) */ |
/* GCL config file for Mac OS X v10.2 |
2 |
|
|
3 |
/* ./configure --enable-debug --enable-machine=powerpc-macosx --enable-dlopen=no |
To be used with the following configure switches : |
4 |
--enable-statsysbfd=no --enable-dynsysbfd=no --enable-custreloc=yes */ |
--enable-debug (optional) |
5 |
|
--enable-machine=powerpc-macosx |
6 |
|
--disable-statsysbfd |
7 |
|
--enable-custreloc |
8 |
|
|
9 |
|
Contributed by aurelien.chanudet (at) m4x.org. |
10 |
|
*/ |
11 |
|
|
12 |
#include "bsd.h" |
#include "bsd.h" |
13 |
|
|
14 |
|
#include <sys/param.h> |
15 |
|
|
16 |
#define DARWIN |
#define DARWIN |
17 |
|
|
18 |
/* Mac OS X has its own executable file format (Mach-O). */ |
/* Mac OS X has its own executable file format (Mach-O). */ |
19 |
#undef HAVE_AOUT |
#undef HAVE_AOUT |
20 |
#undef HAVE_ELF |
#undef HAVE_ELF |
21 |
|
|
|
/* #undef WANT_VALLOC */ |
|
|
/* #define DONT_NEED_MALLOC */ |
|
|
/* #define GNU_MALLOC */ |
|
22 |
|
|
23 |
/* correct value for ppc (we should detect this automatically) */ |
/** sbrk(2) emulation */ |
24 |
/* alternatively, we could use the global variable vm_page_size */ |
|
25 |
|
/* Alternatively, we could use the global variable vm_page_size. */ |
26 |
#define PAGEWIDTH 12 |
#define PAGEWIDTH 12 |
|
/* correct value for i386 */ |
|
|
/* #define PAGEWIDTH 13 */ |
|
27 |
|
|
28 |
/* The following value determines the running process size. */ |
/* The following value determines the running process heap size. */ |
29 |
#define BIG_HEAP_SIZE 0x50000000 |
#define BIG_HEAP_SIZE 0x50000000 |
30 |
|
|
31 |
extern char *mach_mapstart; |
extern char *mach_mapstart; |
32 |
extern char *mach_maplimit; |
extern char *mach_maplimit; |
33 |
extern char *mach_brkpt; |
extern char *mach_brkpt; |
34 |
|
|
|
/* based on NeXT32-m68k.h */ |
|
35 |
#undef SET_REAL_MAXPAGE |
#undef SET_REAL_MAXPAGE |
36 |
#define SET_REAL_MAXPAGE \ |
#define SET_REAL_MAXPAGE { my_sbrk(0); real_maxpage = (int) mach_maplimit/PAGESIZE; } |
|
{ my_sbrk(0); real_maxpage = (int) mach_maplimit/PAGESIZE; } |
|
37 |
|
|
38 |
#define sbrk my_sbrk |
#define sbrk my_sbrk |
39 |
extern char *my_sbrk(int incr); |
extern char *my_sbrk(int incr); |
40 |
|
|
41 |
/* The implementation of unexec for GCL is based on Andrew Choi's work |
|
42 |
for Emacs. Previous pioneering implementation of unexec for Mac OS X |
/** (si::save-system "...") a.k.a. unexec implementation */ |
43 |
by Steve Nygard. */ |
|
44 |
|
/* The implementation of unexec for GCL is based on Andrew Choi's work for Emacs. |
45 |
|
Previous pioneering implementation of unexec for Mac OS X by Steve Nygard. */ |
46 |
#define UNIXSAVE "unexmacosx.c" |
#define UNIXSAVE "unexmacosx.c" |
47 |
|
|
48 |
/* sfaslbfd.c is included from sfasl.c */ |
#undef malloc |
49 |
|
#define malloc my_malloc |
50 |
|
|
51 |
|
#undef free |
52 |
|
#define free my_free |
53 |
|
|
54 |
|
#undef realloc |
55 |
|
#define realloc my_realloc |
56 |
|
|
57 |
|
#undef valloc |
58 |
|
#define valloc my_valloc |
59 |
|
|
60 |
|
#undef calloc |
61 |
|
#define calloc my_calloc |
62 |
|
|
63 |
|
|
64 |
|
/** Dynamic loading implementation */ |
65 |
|
|
66 |
|
/* The sfasl{bfd,macosx,macho}.c files are included from sfasl.c. */ |
67 |
#ifdef HAVE_LIBBFD |
#ifdef HAVE_LIBBFD |
68 |
#define SEPARATE_SFASL_FILE "sfaslbfd.c" |
#define SEPARATE_SFASL_FILE "sfaslbfd.c" |
69 |
#else |
#else |
70 |
/* #ifdef USE_DLOPEN */ |
/* Decrepacted, does not provide sufficiently fine grained information. */ |
71 |
#define SPECIAL_RSYM "rsym_macosx.c" |
#define SPECIAL_RSYM "rsym_macosx.c" |
|
/* #define SEPARATE_SFASL_FILE "fasldlsym.c" */ |
|
72 |
#define SEPARATE_SFASL_FILE "sfaslmacosx.c" |
#define SEPARATE_SFASL_FILE "sfaslmacosx.c" |
73 |
#endif |
#endif |
74 |
|
|
75 |
/* Mac OS X has sigaction (this is needed in o/usig.c), */ |
/* The file has non Mach-O stuff appended. We need to know where the Mach-O stuff ends. */ |
76 |
|
#define SEEK_TO_END_OFILE(fp) seek_to_end_ofile(fp) |
77 |
|
|
78 |
|
/* Processor cache synchronization code. This is based on powerpc-linux.h (Debian ppc). |
79 |
|
See equivalent code in dyld. See also vm_msync declared in <mach/vm_maps.h>. */ |
80 |
|
#define CLEAR_CACHE_LINE_SIZE 32 |
81 |
|
#define CLEAR_CACHE \ |
82 |
|
do { \ |
83 |
|
void *v=memory->cfd.cfd_start,*ve=v+memory->cfd.cfd_size; \ |
84 |
|
v=(void *)((unsigned long)v & ~(CLEAR_CACHE_LINE_SIZE - 1)); \ |
85 |
|
for (;v<ve;v+=CLEAR_CACHE_LINE_SIZE) \ |
86 |
|
asm __volatile__ \ |
87 |
|
("dcbst 0,%0\n\tsync\n\ticbi 0,%0\n\tsync\n\tisync": : "r" (v) : "memory"); \ |
88 |
|
} while(0) |
89 |
|
|
90 |
|
|
91 |
|
/** Stratified garbage collection implementation */ |
92 |
|
|
93 |
|
/* Mac OS X has sigaction (this is needed in o/usig.c) */ |
94 |
#define HAVE_SIGACTION |
#define HAVE_SIGACTION |
|
/* and we have sigvec too but this is defined in bsd.h. */ |
|
95 |
|
|
96 |
/* make this a noop */ |
/* make this a noop */ |
97 |
/* #define SETUP_SIG_STACK */ |
/* #define SETUP_SIG_STACK */ |
98 |
|
|
99 |
/* copied from {Net,Free,Open}BSD.h */ |
/* Copied from {Net,Free,Open}BSD.h */ |
100 |
#define HAVE_SIGPROCMASK |
#define HAVE_SIGPROCMASK |
101 |
#define SIG_STACK_SIZE (SIGSTKSZ/sizeof(double)) |
#define SIG_STACK_SIZE (SIGSTKSZ/sizeof(double)) |
102 |
#define SETUP_SIG_STACK \ |
#define SETUP_SIG_STACK \ |
103 |
{ \ |
{ \ |
104 |
static struct sigaltstack estack; \ |
static struct sigaltstack estack; \ |
105 |
if ((estack.ss_sp = malloc(SIGSTKSZ)) == NULL) \ |
if ((estack.ss_sp = malloc(SIGSTKSZ)) == NULL) \ |
106 |
perror("malloc"); \ |
perror("malloc"); \ |
107 |
estack.ss_size = SIGSTKSZ; \ |
estack.ss_size = SIGSTKSZ; \ |
108 |
estack.ss_flags = 0; \ |
estack.ss_flags = 0; \ |
109 |
if (sigaltstack(&estack, 0) < 0) \ |
if (sigaltstack(&estack, 0) < 0) \ |
110 |
perror("sigaltstack"); \ |
perror("sigaltstack"); \ |
111 |
} |
} |
112 |
|
|
113 |
#define INSTALL_SEGMENTATION_CATCHER \ |
#define INSTALL_SEGMENTATION_CATCHER \ |
114 |
(void) gcl_signal(SIGSEGV, segmentation_catcher); \ |
(void) gcl_signal(SIGSEGV, segmentation_catcher); \ |
115 |
(void) gcl_signal(SIGBUS, segmentation_catcher) |
(void) gcl_signal(SIGBUS, segmentation_catcher) |
116 |
|
|
|
#define IEEEFLOAT |
|
|
|
|
|
/* how to check for input */ |
|
|
/* Mac OS X does not have _fileno as in linux.h. Nor does it have _cnt as in bsd.h. */ |
|
|
/* Let us see what we can do with this declaration found in {Net,Free,Open}BSD.h. */ |
|
|
#undef LISTEN_FOR_INPUT |
|
|
#define LISTEN_FOR_INPUT(fp) \ |
|
|
do {int c=0;\ |
|
|
if ((fp)->_r <=0 && (c=0, ioctl((fp)->_file, FIONREAD, &c), c<=0))\ |
|
|
return(FALSE);\ |
|
|
} while(0) |
|
|
|
|
|
/* (I hope) we dont need to worry about zeroing fp->_base */ |
|
|
#define FCLOSE_SETBUF_OK |
|
|
|
|
|
|
|
|
/** enable stratified garbage collection */ |
|
|
|
|
117 |
#define SGC |
#define SGC |
|
|
|
|
/* |
|
|
#define INSTALL_MPROTECT_HANDLER \ |
|
|
do { \ |
|
|
struct sigaction sact; \ |
|
|
sigfillset(&(sact.sa_mask)); \ |
|
|
sact.sa_flags = SA_SIGINFO; \ |
|
|
sact.sa_sigaction = (void (*)()) memprotect_handler; \ |
|
|
sigaction (SIGSEGV, &sact, 0); \ |
|
|
sigaction (SIGBUS, &sact, 0); \ |
|
|
} while (0); |
|
|
*/ |
|
|
|
|
118 |
#define SIGPROTV SIGBUS |
#define SIGPROTV SIGBUS |
119 |
|
|
120 |
/* si_addr not containing the faulting address is a bug in Darwin */ |
/* si_addr not containing the faulting address is a bug in Darwin. |
121 |
/* work around this bug by looking at the dar field of the exception state */ |
Work around this by looking at the dar field of the exception state. */ |
122 |
#define GET_FAULT_ADDR(sig,code,scp,addr) ((char *) (((ucontext_t *) scp)->uc_mcontext->es.dar)) |
#define GET_FAULT_ADDR(sig,code,scp,addr) ((char *) (((ucontext_t *) scp)->uc_mcontext->es.dar)) |
123 |
|
|
124 |
|
|
125 |
/** cache synchronization code */ |
/** Misc stuff */ |
|
|
|
|
/* This is based on powerpc-linux.h. See equivalent code in dyld. */ |
|
126 |
|
|
127 |
#define CLEAR_CACHE_LINE_SIZE 32 |
#define IEEEFLOAT |
128 |
#define CLEAR_CACHE \ |
|
129 |
do {\ |
/* Mac OS X does not have _fileno as in linux.h. Nor does it have _cnt as in bsd.h. |
130 |
void *v=memory->cfd.cfd_start,*ve=v+memory->cfd.cfd_size;\ |
Let's see what we can do with this declaration found in {Net,Free,Open}BSD.h. */ |
131 |
v=(void *)((unsigned long)v & ~(CLEAR_CACHE_LINE_SIZE - 1));\ |
#undef LISTEN_FOR_INPUT |
132 |
for (;v<ve;v+=CLEAR_CACHE_LINE_SIZE)\ |
#define LISTEN_FOR_INPUT(fp) \ |
133 |
asm __volatile__\ |
do {int c=0; \ |
134 |
("dcbst 0,%0\n\tsync\n\ticbi 0,%0\n\tsync\n\tisync": : "r" (v) : "memory");\ |
if ((fp)->_r <=0 && (c=0, ioctl((fp)->_file, FIONREAD, &c), c<=0)) \ |
135 |
|
return(FALSE); \ |
136 |
} while(0) |
} while(0) |
137 |
|
|
138 |
#define SEEK_TO_END_OFILE(fp) seek_to_end_ofile(fp) |
/* We (hopefully) dont need to worry about zeroing fp->_base. */ |
139 |
/* extern int seek_to_end_ofile(FILE *fp); */ |
#define FCLOSE_SETBUF_OK |
|
|
|
|
#undef malloc |
|
|
#define malloc my_malloc |
|
|
|
|
|
#undef free |
|
|
#define free my_free |
|
|
|
|
|
#undef realloc |
|
|
#define realloc my_realloc |
|
|
|
|
|
#undef valloc |
|
|
#define valloc my_valloc |
|
|
|
|
|
#undef calloc |
|
|
#define calloc my_calloc |
|
140 |
|
|
141 |
#define GET_FULL_PATH_SELF(a_) \ |
#define GET_FULL_PATH_SELF(a_) \ |
142 |
do { \ |
do { \ |
143 |
extern int _NSGetExecutablePath (char *, unsigned long *); \ |
extern int _NSGetExecutablePath (char *, unsigned long *); \ |
144 |
unsigned long bufsize = PATH_MAX; \ |
unsigned long bufsize = 1024; \ |
145 |
static char buf [PATH_MAX]; \ |
static char buf [1024]; \ |
146 |
if (_NSGetExecutablePath (buf, &bufsize) != 0) { \ |
static char fub [1024]; \ |
147 |
error ("_NSGetExecutablePath failed"); \ |
if (_NSGetExecutablePath (buf, &bufsize) != 0) { \ |
148 |
} \ |
error ("_NSGetExecutablePath failed"); \ |
149 |
(a_) = buf; \ |
} \ |
150 |
} while (0); |
if (realpath (buf, fub) == 0) { \ |
151 |
|
error ("realpath failed"); \ |
152 |
|
} \ |
153 |
|
(a_) = fub; \ |
154 |
|
} while (0) |