/[gcl]/gcl/h/m68k-linux.h
ViewVC logotype

Diff of /gcl/h/m68k-linux.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by camm, Tue Jan 8 19:26:58 2002 UTC revision 1.2 by camm, Sun Feb 3 18:44:07 2002 UTC
# Line 0  Line 1 
1    /* #define GMP */
2    #define BSD386
3    #include "bsd.h"
4    
5    
6    #ifdef __ELF__
7    /* #if ! defined(IN_UNIXFASL) */
8    #undef HAVE_AOUT
9    #define HAVE_AOUT <elf.h>
10    #define HAVE_ELF
11    
12    /* Seeking to the end of ELF data is a little messy... */
13    #define SEEK_TO_END_OFILE(fp)\
14      do { \
15            long offset = 0, endofelf; int j; \
16            Elf32_Ehdr eheader; Elf32_Shdr shdr; \
17            fseek(fp, 0, SEEK_SET); \
18            fread(&eheader, sizeof(eheader), 1, fp); \
19      /* in case the headers themselves come AFTER the actual sections */ \
20            endofelf=offset = eheader.e_shoff+ eheader.e_shentsize *eheader.e_shnum;\
21            fseek(fp, eheader.e_shoff, SEEK_SET); \
22            if ( eheader.e_shentsize != sizeof(Elf32_Shdr) ) \
23              { FEerror("Bad ELF section header size",0); } \
24            for ( j = 0; j < eheader.e_shnum; j++ ) \
25              { fread(&shdr,eheader.e_shentsize,1,fp); \
26                if ( (shdr.sh_offset > offset) && (shdr.sh_type != SHT_NOBITS) ) \
27                  { offset = shdr.sh_offset; endofelf = offset+shdr.sh_size; } \
28              } \
29            if ( fseek(fp, endofelf, SEEK_SET) ) \
30                FEerror("Bad ELF file",0); \
31          } while(0)
32    
33    
34    #ifdef IN_GBC
35    /* Based upon sun4.h */
36    #define INSTALL_MPROTECT_HANDLER \
37    do {static struct sigaction action; \
38          action.sa_handler = memprotect_handler; \
39          action.sa_flags = SA_RESTART; \
40          action.sa_restorer = 0; \
41          sigemptyset(&action.sa_mask); \
42          sigaddset(&action.sa_mask,SIGINT); \
43          sigaddset(&action.sa_mask,SIGALRM); \
44          sigaction(SIGSEGV,&action,0); \
45          sigaction(SIGBUS,&action,0);} while (0)
46    
47    /* the following two files have changed back
48       and forth in recent versions of linux...
49       Include both if they both exist, otherwise
50       include whatever one exists...
51       basically one wants the
52       struct sigcontext_struct { ... } ;
53       so as to get the fault address.
54       */
55    
56    #ifdef   SIGNAL_H_HAS_SIGCONTEXT
57    #include <signal.h>
58    #else    
59    #ifdef HAVE_ASM_SIGCONTEXT_H    
60    #include <asm/sigcontext.h>
61    #endif
62    #ifdef HAVE_ASM_SIGNAL_H          
63    #include <asm/signal.h>
64    #endif
65    #ifdef HAVE_SIGCONTEXT
66    #define sigcontext_struct sigcontext
67    #endif
68    #endif    
69    
70    
71    /* GET_FAULT_ADDR is a bit complicated to implement on m68k, because the fault
72       address can't be found directly in the sigcontext. One has to look at the
73       CPU frame, and that one is different for each CPU.
74       */
75    #define GET_FAULT_ADDR(sig,code,sv,a) \
76        ({  \
77            struct sigcontext *scp = (struct sigcontext *)(sv); \
78            int format = (scp->sc_formatvec >> 12) & 0xf; \
79            unsigned long *framedata = (unsigned long *)(scp + 1); \
80            unsigned long ea; \
81            if (format == 0xa || format == 0xb) \
82                            /* 68020/030 */ \
83              ea = framedata[2]; \
84            else if (format == 7) \
85                            /* 68040 */ \
86              ea = framedata[3]; \
87            else if (format == 4) { \
88                            /* 68060 */ \
89              ea = framedata[0]; \
90              if (framedata[1] & 0x08000000) \
91                            /* correct addr on misaligned access */ \
92                ea = (ea+4095)&(~4095); \
93            } \
94            ea; })
95    #endif
96    
97    
98    /* is #define ELF_TEXT_BASE 0x8000000   on current linux */
99    #define ELF_TEXT_BASE  DBEGIN
100    
101    /* on some linux x86 machines the C stack starts in positive number
102       range, however since we might compile on one and run on another
103       we will have to do this:
104    */  
105    #define NULL_OR_ON_C_STACK(x) ( x == 0 || (((unsigned int) x) >= 0xe0000000 ))
106    
107    #undef SET_REAL_MAXPAGE
108    #define SET_REAL_MAXPAGE do { struct rlimit data_rlimit; \
109                                   extern char etext; \
110                                   real_maxpage = MAXPAGE ;\
111            getrlimit(RLIMIT_DATA, &data_rlimit); \
112                            real_maxpage = ((unsigned int)&etext/PAGESIZE \
113                            + data_rlimit.rlim_cur/PAGESIZE - ELF_TEXT_BASE/PAGESIZE); \
114            if (real_maxpage > MAXPAGE) \
115                    real_maxpage = MAXPAGE ; } while(0)
116    
117    #define SPECIAL_RSYM "rsym_elf.c"
118    #define SEPARATE_SFASL_FILE "sfaslelf.c"
119    
120    #define UNEXEC_USE_MAP_PRIVATE
121    #define UNIXSAVE "unexelf.c"
122    /* end ELF */
123    #else
124    #define RELOC_FILE "rel_sun3.c"
125    #define UNIXSAVE "unexec.c"
126    
127    #define start_of_data() &etext
128    #define start_of_text() ( (char *) 0 )
129    #define A_TEXT_OFFSET(hdr) (N_MAGIC(hdr) == QMAGIC ? sizeof (struct exec) : 0)
130    #define A_TEXT_SEEK(hdr) (N_TXTOFF(hdr) + A_TEXT_OFFSET(hdr))
131    #define ADJUST_EXEC_HEADER \
132      unexec_text_start = N_TXTADDR(ohdr) + A_TEXT_OFFSET(ohdr)
133    
134    #endif
135    
136    
137    /* #include "386.h" */
138    #undef HAVE_SIGVEC
139    /* #define NEED_TO_REINSTALL_SIGNALS */
140    #define HAVE_SIGACTION
141    /* make this a noop */
142    #define SETUP_SIG_STACK
143    #ifndef HAVE_SV_ONSTACK
144    #define SV_ONSTACK 0
145    #endif
146    
147    /* unblock signals m and n, and set val to signal_mask(m) | signal_mask(n)
148       if they were set */
149    #define SIG_UNBLOCK_SIGNALS(val,m,n) \
150        current_mask = sigblock(0);  \
151        sigsetmask(~(sigmask(m)) & ~(sigmask(n)) & current_mask); \
152        result = (current_mask & sigmask(m) ? signal_mask(m) : 0) \
153          | (current_mask & sigmask(n) ? signal_mask(n) : 0);
154    
155    #undef RUN_PROCESS
156    
157    #define ADDITIONAL_FEATURES \
158                         ADD_FEATURE("BSD386"); \
159                 ADD_FEATURE("MC68020")
160    
161    
162    #define M68K
163    #define IEEEFLOAT
164          
165    
166    /* Pages on Linux are 4096 bytes. */
167    #ifdef PAGEWIDTH
168    #error PAGEWIDTH definition conflict
169    #endif
170    #define PAGEWIDTH       12      /*  page width  */
171    
172    
173    #undef HAVE_XDR
174    
175    #ifdef IN_UNIXSAVE
176    #include <linux/user.h>
177    #endif
178    
179    #define USE_ULONG_
180    
181    /*   How to check for input */
182    #undef LISTEN_FOR_INPUT
183    
184    #define LISTEN_FOR_INPUT(fp) \
185    do { int c = 0; \
186      if(((fp)->_IO_read_ptr >= (fp)->_IO_read_end) \
187         && (ioctl((fp)->_fileno, FIONREAD, &c),c<=0)) \
188         return 0;} while (0)
189    
190    /* we dont need to worry about zeroing fp->_base , to prevent  */
191    #define FCLOSE_SETBUF_OK
192    
193    /* #define DATA_BEGIN((TXTRELOC+header.a_text+(SEGSIZ-1)) & ~(SEGSIZ-1)); */
194    #define DATA_BEGIN (char *)(char *)N_DATADDR(header);
195    
196    /*
197    #undef   FILECPY_HEADER
198    #define FILECPY_HEADER \
199            if (header.a_magic == ZMAGIC) \
200                    filecpy(save, original, PAGSIZ - sizeof(header)); \
201            filecpy(save, original, header.a_text);
202    */
203    
204    
205    #define LITTLE_END
206    
207    #define PAGSIZ          (NBPG)
208    #define SEGSIZ          (NBPG * CLSIZE)
209    #define TXTRELOC        0
210    
211    #define USE_DIRENT
212    #define GETPATHNAME
213    #define PATHNAME_CACHE  10
214    
215    
216    /* try out the gnu malloc */
217    /* #define GNU_MALLOC */
218    
219    #define INSTALL_SEGMENTATION_CATCHER \
220             (void) signal(SIGSEGV,segmentation_catcher)
221    /* if you are in an early version of linux without SIGBUS, uncomment
222       the next line */
223    /* #define SIGBUS SIGSEGV */
224    #ifndef HAVE_SIGSYS
225    #define SIGSYS SIGSEGV
226    #endif
227    
228    #ifndef HAVE_SIGEMT
229    #define SIGEMT SIGSEGV
230    #endif
231    
232    
233    /* get the fileno of a FILE* */
234    #define FILENO(x) fileno(x)
235    
236    #define ULONG_DEFINED
237    /* #define NO_PROFILE */
238    
239    
240    
241    #undef LD_COMMAND
242    #define LD_COMMAND(command,main,start,input,ldarg,output) \
243      sprintf(command, "ld -d -S -N -x -A %s -T %x %s %s -o %s", \
244                main,start,input,ldarg,output)
245    
246    #define SET_SESSION_ID() (setpgrp() ? -1 : 0)
247    
248    
249    
250    
251    /* NOTE: The following text will be automatically included in a
252       constructed file cmpinclude.h */
253    /* Begin for cmpinclude */
254    
255    
256    /* NOTE: If you don't have the system call mprotect DON'T
257       define this.
258       All Linux ELF systems should have mprotect. */
259    #ifdef __ELF__
260    #define SGC
261    #endif
262    
263    /* _setjmp and _longjmp exist on bsd and are more efficient
264       and handle the C stack which is all we need. [I think!]
265     */
266    
267    /* End for cmpinclude */
268    /* define if there is no _cleanup,   do here what needs
269       to be done before calling unexec
270       */  
271    #define CLEANUP_CODE \
272      setbuf(stdin,0); \
273       setbuf(stdout,0);
274    
275    /* the following will try to make sure that the stdin and stdout are
276    set correctly on startup after a save */
277    
278    
279    #define INIT_CORE_END terminal_io->sm.sm_object0->sm.sm_fp = stdin;terminal_io->sm.sm_object1->sm.sm_fp = stdout;
280    
281    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26