source: trunk/ccl/lisp-kernel/m4macros.m4 @ 5003

Last change on this file since 5003 was 5003, checked in by gb, 14 years ago

Define SYSCALL_SETS_CARRY_ON_ERROR for FreeBSDX664, DarwinX8664.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.9 KB
Line 
1changequote([,])
2changecom([/* ],[*/])
3
4
5
6/*   Copyright (C) 1994-2001 Digitool, Inc  */
7/*   This file is part of OpenMCL.    */
8
9/*   OpenMCL is licensed under the terms of the Lisp Lesser GNU Public  */
10/*   License , known as the LLGPL and distributed with OpenMCL as the  */
11/*   file "LICENSE".  The LLGPL consists of a preamble and the LGPL,  */
12/*   which is distributed with OpenMCL as the file "LGPL".  Where these  */
13/*   conflict, the preamble takes precedence.    */
14
15/*   OpenMCL is referenced in the preamble as the "LIBRARY."  */
16
17/*   The LLGPL is also available online at  */
18/*   http://opensource.franz.com/preamble.html  */
19
20
21
22/*  BSD debugging information (line numbers, etc) is a little different  */
23/*  from ELF/SVr4 debugging information.  There are probably lots more  */
24/*  differences, but this helps us to distinguish between what LinuxPPC  */
25/*  (ELF/SVr4) wants and what Darwin(BSD) wants.  */
26
27
28define([BSDstabs],[1])
29define([ELFstabs],[2])
30undefine([EABI])
31undefine([POWEROPENABI])
32undefine([rTOC])
33
34ifdef([DARWIN],[define([SYSstabs],[BSDstabs])
35                define([DarwinAssembler],[])
36                define([CNamesNeedUnderscores],[])
37                define([LocalLabelPrefix],[L])
38                define([StartTextLabel],[Ltext0])
39                define([EndTextLabel],[Letext])
40                ifdef([PPC],[
41                define([POWEROPENABI],[])])
42                ifdef([X86],[
43                define([SYSCALL_SETS_CARRY_ON_ERROR],[])])
44])
45
46ifdef([LINUX],[define([SYSstabs],[ELFstabs])
47               define([HaveWeakSymbols],[])
48               define([LocalLabelPrefix],[.L])
49               define([StartTextLabel],[.Ltext0])
50               define([EndTextLabel],[.Letext])
51               ifdef([PPC64],[
52               define([POWEROPENABI],[])
53               define([rTOC],[r2])], [
54               define([EABI],[])])])
55
56ifdef([FREEBSD],[define([SYSstabs],[ELFstabs])
57               define([HaveWeakSymbols],[])
58               define([LocalLabelPrefix],[.L])
59               define([StartTextLabel],[.Ltext0])
60               define([EndTextLabel],[.Letext])]
61                ifdef([X86],[
62                define([SYSCALL_SETS_CARRY_ON_ERROR],[])])
63)
64
65ifdef([SOLARIS],[define([SYSstabs],[ELFstabs])
66               define([HaveWeakSymbols],[])
67               define([LocalLabelPrefix],[.L])
68               define([StartTextLabel],[.Ltext0])
69               define([EndTextLabel],[.Letext])])
70
71
72/*  Names exported to (or imported from) C may need leading underscores.  */
73/*  Still.  After all these years.  Why ?  */
74
75define([C],[ifdef([CNamesNeedUnderscores],[[_]$1],[$1])])
76
77define([_linecounter_],0)
78
79define([_emit_BSD_source_line_stab],[
80        .stabd 68,0,$1
81])
82
83
84/*  We don't really do "weak importing" of symbols from a separate  */
85/*  subprims library anymore; if we ever do and the OS supports it,  */
86/*  here's how to say that we want it ...  */
87
88define([WEAK],[ifdef([HaveWeakSymbols],[
89        .weak $1
90],[
91        .globl $1
92])])
93
94define([_emit_ELF_source_line_stab],[
95  define([_linecounter_],incr(_linecounter_))
96        .stabn 68,0,$1,[.LM]_linecounter_[-]__func_name
97[.LM]_linecounter_:
98])
99
100
101
102define([emit_source_line_stab],[
103        ifelse(eval(SYSstabs),eval(BSDstabs),
104        [_emit_BSD_source_line_stab($1)],
105        [_emit_ELF_source_line_stab($1)])])
106
107
108
109/*  Assemble a reference to the high half of a 32-bit constant,  */
110/*  possibly adjusted for sign-extension of thw low half.  */
111
112
113define([HA],[ifdef([DARWIN],[ha16($1)],[$1@ha])])
114
115 
116/*  Likewise for the low half, and for the high half without  */
117/*  concern for sign-extension of the low half.  */
118
119define([LO],[ifdef([DARWIN],[lo16($1)],[$1@l])])
120define([HI],[ifdef([DARWIN],[hi16($1)],[$1@hi])])
121
122/*  Note that m4 macros that could be expanded in the .text segment  */
123/*  need to advertise the current line number after they have finished  */
124/*  expanding.  That shouldn't be too onerous, if only because there  */
125/*  should not be too many of them.  */
126
127
128define([N_FUN],36)
129define([N_SO],100)
130
131/*    I wish that there was a less-dumb way of doing this.  */
132
133define([pwd0],esyscmd([/bin/pwd]))
134define([__pwd__],substr(pwd0,0,decr(len(pwd0)))[/])
135
136/*   _beginfile() -- gets line/file in synch, generates N_SO for file,  */
137/*   starts .text section  */
138
139
140define([_beginfile],[
141        .stabs "__pwd__",N_SO,0,0,StartTextLabel()
142        .stabs "__file__",N_SO,0,0,StartTextLabel()
143ifdef([PPC64],[
144ifdef([DARWIN],[
145        .machine ppc64
146])])
147        .text
148StartTextLabel():
149# __line__ "__file__"
150])
151
152define([_endfile],[
153        .stabs "",N_SO,0,0,EndTextLabel()
154EndTextLabel():
155# __line__
156])
157
158define([_startfn],[define([__func_name],$1)
159# __line__
160        ifelse(eval(SYSstabs),eval(ELFstabs),[
161        .type $1,@function
162])
163$1:
164        .stabd 68,0,__line__
165        .stabs "$1:F1",36,0,__line__,$1
166        .set func_start,$1
167])
168
169
170
171define([_exportfn],[
172        .globl $1
173        _startfn($1)
174ifdef([PPC64],[
175ifdef([LINUX],[
176        .global [.]$1
177[.]$1:
178])])
179# __line__
180])
181
182define([_endfn],[
183LocalLabelPrefix[]__func_name[999]:
184        .stabs "",36,0,0,LocalLabelPrefix[]__func_name[999]-__func_name
185        .line __line__
186        ifelse(eval(SYSstabs),eval(ELFstabs),[
187        .size __func_name,LocalLabelPrefix[]__func_name[999]-__func_name
188])
189        undefine([__func_name])
190])
191
192
193/* _struct(name,start_offset)  */
194/*   This just generates a bunch of assembler equates; m4  */
195/*   doesn't remember much of it ..  */
196
197define([_struct], [define([__struct_name],$1)
198 define([_struct_org_name], _$1_org)
199 define([_struct_base_name], _$1_base)
200        .set _struct_org_name,$2
201        .set _struct_base_name,_struct_org_name
202 ifelse($3,[],[
203  undefine([_struct_fixed_size_name])
204  ],[
205  define([_struct_fixed_size_name], _$1_fixed_size)
206        .set _struct_fixed_size_name,$3
207  ])
208])
209
210define([_struct_pad],[
211        .set _struct_org_name,_struct_org_name + $1
212])
213 
214define([_struct_label],[
215        .set __struct_name[.]$1, _struct_org_name
216])
217
218/*  _field(name,size)   */
219define([_field],[_struct_label($1) _struct_pad($2)])
220
221define([_halfword], [_field($1, 2)])
222define([_word], [_field($1, 4)])
223define([_dword],[_field($1, 8)])
224define([_node], [_field($1, node_size)])
225
226define([_ends],[ifdef([_struct_fixed_size_name],[
227        .set  __struct_name[.size],_struct_fixed_size_name
228        ],[
229        .set  __struct_name[.size], _struct_org_name-_struct_base_name
230        ])
231])
232
233
234/*   Lisp fixed-size objects always have a 1-word header  */
235/*   and are always accessed from a "fulltag_misc"-tagged pointer.  */
236/*   We also want to define STRUCT_NAME.element_count for each  */
237/*   such object.  */
238
239
240define([_structf],[
241        _struct($1,ifelse($2,[],-misc_bias,$2))
242        _node(header)
243])
244
245define([_endstructf],[
246        .set __struct_name.[element_count],((_struct_org_name-node_size)-_struct_base_name)/node_size
247        _ends
248])
249
250
251define([__],[emit_source_line_stab(__line__)
252# __line__
253        $@
254        ])
255
256define([__local_label_counter__],0)
257define([__macro_label_counter__],0)
258
259define([new_local_labels],
260  [define([__local_label_counter__],incr(__local_label_counter__))])
261
262define([new_macro_labels],
263  [define([__macro_label_counter__],incr(__macro_label_counter__))])
264
265define([_local_label],[LocalLabelPrefix()[]$1])
266
267define([local_label],[_local_label($1[]__local_label_counter__)])
268
269define([macro_label],[_local_label($1[]__macro_label_counter__)])
270
271
272/* The Darwin assembler doesn't seem to support .ifdef/.ifndef, but  */
273/* does understand .if.    */
274/* Note that using M4's own ifdef is certainly possible, but it's  */
275/* hard to generate source line information when doing so.  */
276
277 
278define([__ifdef],[ifdef([$1],[.if 1],[.if 0])])
279define([__ifndef],[ifdef([$1],[.if 0],[.if 1])])
280define([__else],[.else])
281define([__endif],[.endif])
282define([__if],[.if $1])
283
284define([equate_if_defined],[ifdef($1,[
285[$1] = 1
286],[
287[$1] = 0
288])])
289
290equate_if_defined([DARWIN])
291equate_if_defined([LINUX])
292equate_if_defined([FREEBSD])
293equate_if_defined([SOLARIS])
294equate_if_defined([PPC64])
295equate_if_defined([X8664])
296
297equate_if_defined([HAVE_TLS])
298/* DARWIN_GS_HACK is hopefully short-lived */
299equate_if_defined([DARWIN_GS_HACK])
300
301equate_if_defined([SYSCALL_SETS_CARRY_ON_ERROR])
302
303
304
305/* We use (more-or-less) a PowerOpen C frame, except on LinuxPPC32  */
306
307define([USE_POWEROPEN_C_FRAME],[])
308undefine([USE_EABI_C_FRAME])
309
310ifdef([LINUX],[
311ifdef([PPC64],[],[
312define([USE_EABI_C_FRAME],[])
313undefine([USE_POWEROPEN_C_FRAME])
314])])
315
316
317
318
Note: See TracBrowser for help on using the repository browser.