source: branches/working-0711/ccl/lisp-kernel/m4macros.m4 @ 7828

Last change on this file since 7828 was 7828, checked in by gb, 13 years ago

A little bit of Windows conditionalization.

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