Print this page
NEX-16819 loader UEFI support
Includes work by Toomas Soome <tsoome@me.com>
Upstream commits:
loader: pxe receive cleanup
9475 libefi: Do not return only if ReceiveFilter
installboot: should support efi system partition
8931 boot1.efi: scan all display modes rather than
loader: spinconsole updates
loader: gfx experiment to try GOP Blt() function.
sha1 build test
loader: add sha1 hash calculation
common/sha1: update for loader build
loader: biosdisk rework
uts: 32-bit kernel FB needs mapping in low memory
uts: add diag-device
uts: boot console mirror with diag-device
uts: enable very early console on ttya
kmdb: add diag-device as input/output device
uts: test VGA memory exclusion from mapping
uts: clear boot mapping and protect boot pages test
uts: add dboot map debug printf
uts: need to release FB pages in release_bootstrap()
uts: add screenmap ioctl
uts: update sys/queue.h
loader: add illumos uts/common to include path
loader: tem/gfx font cleanup
loader: vbe checks
uts: gfx_private set KD_TEXT when KD_RESETTEXT is
uts: gfx 8-bit update
loader: gfx 8-bit fix
loader: always set media size from partition.
uts: MB2 support for 32-bit kernel
loader: x86 should have tem 80x25
uts: x86 should have tem 80x25
uts: font update
loader: font update
uts: tem attributes
loader: tem.c comment added
uts: use font module
loader: add font module
loader: build rules for new font setup
uts: gfx_private update for new font structure
uts: early boot update for new font structure
uts: font update
uts: font build rules update for new fonts
uts: tem update to new font structure
loader: module.c needs to include tem_impl.h
uts: gfx_private 8x16 font rework
uts: make font_lookup public
loader: font rework
uts: font rework
9259 libefi: efi_alloc_and_read should check for PMBR
uts: tem utf-8 support
loader: implement tem utf-8 support
loader: tem should be able to display UTF-8
7784 uts: console input should support utf-8
7796 uts: ldterm default to utf-8
uts: do not reset serial console
uts: set up colors even if tem is not console
uts: add type for early boot properties
uts: gfx_private experiment with drm and vga
uts: gfx_private should use setmode drm callback.
uts: identify FB types and set up gfx_private based
loader: replace gop and vesa with framebuffer
uts: boot needs simple tem to support mdb
uts: boot_keyboard should emit esc sequences for
uts: gfx_private FB showuld be written by line
kmdb: set terminal window size
uts: gfx_private needs to keep track of early boot FB
pnglite: move pnglite to usr/src/common
loader: gfx_fb
ficl-sys: add gfx primitives
loader: add illumos.png logo
ficl: add fb-putimage
loader: add png support
loader: add alpha blending for gfx_fb
loader: use term-drawrect for menu frame
ficl: add simple gfx words
uts: provide fb_info via fbgattr dev_specific array.
uts: gfx_private add alpha blending
uts: update sys/ascii.h
uts: tem OSC support (incomplete)
uts: implement env module support and use data from
uts: tem get colors from early boot data
loader: use crc32 from libstand (libz)
loader: optimize for size
loader: pass tem info to the environment
loader: import tem for loader console
loader: UEFI loader needs to set ISADIR based on
loader: need UEFI32 support
8918 loader.efi: add vesa edid support
uts: tem_safe_pix_clear_prom_output() should only
uts: tem_safe_pix_clear_entire_screen() should use
uts: tem_safe_check_first_time() should query cursor
uts: tem implement cls callback & visual_io v4
uts: gfx_vgatext use block cursor for vgatext
uts: gfx_private implement cls callback & visual_io
uts: gfx_private bitmap framebuffer implementation
uts: early start frame buffer console support
uts: font functions should check the input char
uts: font rendering should support 16/24/32bit depths
uts: use smallest font as fallback default.
uts: update terminal dimensions based on selected
7834 uts: vgatext should use gfx_private
uts: add spacing property to 8859-1.bdf
terminfo: add underline for sun-color
terminfo: sun-color has 16 colors
uts: add font load callback type
loader: do not repeat int13 calls with error 0x20 and
8905 loader: add skein/edonr support
8904 common/crypto: make skein and edonr loader
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Revert "NEX-16819 loader UEFI support"
This reverts commit ec06b9fc617b99234e538bf2e7e4d02a24993e0c.
Reverting due to failures in the zfs-tests and the sharefs-tests
NEX-16819 loader UEFI support
Includes work by Toomas Soome <tsoome@me.com>
Upstream commits:
loader: pxe receive cleanup
9475 libefi: Do not return only if ReceiveFilter
installboot: should support efi system partition
8931 boot1.efi: scan all display modes rather than
loader: spinconsole updates
loader: gfx experiment to try GOP Blt() function.
sha1 build test
loader: add sha1 hash calculation
common/sha1: update for loader build
loader: biosdisk rework
uts: 32-bit kernel FB needs mapping in low memory
uts: add diag-device
uts: boot console mirror with diag-device
uts: enable very early console on ttya
kmdb: add diag-device as input/output device
uts: test VGA memory exclusion from mapping
uts: clear boot mapping and protect boot pages test
uts: add dboot map debug printf
uts: need to release FB pages in release_bootstrap()
uts: add screenmap ioctl
uts: update sys/queue.h
loader: add illumos uts/common to include path
loader: tem/gfx font cleanup
loader: vbe checks
uts: gfx_private set KD_TEXT when KD_RESETTEXT is
uts: gfx 8-bit update
loader: gfx 8-bit fix
loader: always set media size from partition.
uts: MB2 support for 32-bit kernel
loader: x86 should have tem 80x25
uts: x86 should have tem 80x25
uts: font update
loader: font update
uts: tem attributes
loader: tem.c comment added
uts: use font module
loader: add font module
loader: build rules for new font setup
uts: gfx_private update for new font structure
uts: early boot update for new font structure
uts: font update
uts: font build rules update for new fonts
uts: tem update to new font structure
loader: module.c needs to include tem_impl.h
uts: gfx_private 8x16 font rework
uts: make font_lookup public
loader: font rework
uts: font rework
libefi: efi_alloc_and_read should check for PMBR
uts: tem utf-8 support
loader: implement tem utf-8 support
loader: tem should be able to display UTF-8
7784 uts: console input should support utf-8
7796 uts: ldterm default to utf-8
uts: do not reset serial console
uts: set up colors even if tem is not console
uts: add type for early boot properties
uts: gfx_private experiment with drm and vga
uts: gfx_private should use setmode drm callback.
uts: identify FB types and set up gfx_private based
loader: replace gop and vesa with framebuffer
uts: boot needs simple tem to support mdb
uts: boot_keyboard should emit esc sequences for
uts: gfx_private FB showuld be written by line
kmdb: set terminal window size
uts: gfx_private needs to keep track of early boot FB
pnglite: move pnglite to usr/src/common
loader: gfx_fb
ficl-sys: add gfx primitives
loader: add illumos.png logo
ficl: add fb-putimage
loader: add png support
loader: add alpha blending for gfx_fb
loader: use term-drawrect for menu frame
ficl: add simple gfx words
uts: provide fb_info via fbgattr dev_specific array.
uts: gfx_private add alpha blending
uts: update sys/ascii.h
uts: tem OSC support (incomplete)
uts: implement env module support and use data from
uts: tem get colors from early boot data
loader: use crc32 from libstand (libz)
loader: optimize for size
loader: pass tem info to the environment
loader: import tem for loader console
loader: UEFI loader needs to set ISADIR based on
loader: need UEFI32 support
8918 loader.efi: add vesa edid support
uts: tem_safe_pix_clear_prom_output() should only
uts: tem_safe_pix_clear_entire_screen() should use
uts: tem_safe_check_first_time() should query cursor
uts: tem implement cls callback & visual_io v4
uts: gfx_vgatext use block cursor for vgatext
uts: gfx_private implement cls callback & visual_io
uts: gfx_private bitmap framebuffer implementation
uts: early start frame buffer console support
uts: font functions should check the input char
uts: font rendering should support 16/24/32bit depths
uts: use smallest font as fallback default.
uts: update terminal dimensions based on selected
7834 uts: vgatext should use gfx_private
uts: add spacing property to 8859-1.bdf
terminfo: add underline for sun-color
terminfo: sun-color has 16 colors
uts: add font load callback type
loader: do not repeat int13 calls with error 0x20 and
8905 loader: add skein/edonr support
8904 common/crypto: make skein and edonr loader
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/common/ficl/float.c
+++ new/usr/src/common/ficl/float.c
1 1 /*
2 2 * f l o a t . c
3 3 * Forth Inspired Command Language
4 4 * ANS Forth FLOAT word-set written in C
5 5 * Author: Guy Carver & John Sadler (john_sadler@alum.mit.edu)
6 6 * Created: Apr 2001
7 7 * $Id: float.c,v 1.10 2010/09/13 18:43:04 asau Exp $
8 8 */
9 9 /*
10 10 * Copyright (c) 1997-2001 John Sadler (john_sadler@alum.mit.edu)
11 11 * All rights reserved.
12 12 *
13 13 * Get the latest Ficl release at http://ficl.sourceforge.net
14 14 *
15 15 * I am interested in hearing from anyone who uses Ficl. If you have
16 16 * a problem, a success story, a defect, an enhancement request, or
17 17 * if you would like to contribute to the Ficl release, please
18 18 * contact me by email at the address above.
19 19 *
20 20 * L I C E N S E and D I S C L A I M E R
21 21 *
22 22 * Redistribution and use in source and binary forms, with or without
23 23 * modification, are permitted provided that the following conditions
24 24 * are met:
25 25 * 1. Redistributions of source code must retain the above copyright
26 26 * notice, this list of conditions and the following disclaimer.
27 27 * 2. Redistributions in binary form must reproduce the above copyright
28 28 * notice, this list of conditions and the following disclaimer in the
29 29 * documentation and/or other materials provided with the distribution.
30 30 *
31 31 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
32 32 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
33 33 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
34 34 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
35 35 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
39 39 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
40 40 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
41 41 * SUCH DAMAGE.
42 42 */
43 43
44 44 #include "ficl.h"
45 45
46 46 #if FICL_WANT_FLOAT
47 47 #include <math.h>
48 48 #include <values.h>
49 49
50 50
51 51 /*
52 52 * Create a floating point constant.
53 53 * fconstant ( r -"name"- )
54 54 */
55 55 static void
56 56 ficlPrimitiveFConstant(ficlVm *vm)
57 57 {
58 58 ficlDictionary *dictionary = ficlVmGetDictionary(vm);
59 59 ficlString name = ficlVmGetWord(vm);
60 60
61 61 FICL_STACK_CHECK(vm->floatStack, 1, 0);
62 62
63 63 ficlDictionaryAppendWord(dictionary, name,
64 64 (ficlPrimitive)ficlInstructionFConstantParen, FICL_WORD_DEFAULT);
65 65 ficlDictionaryAppendCell(dictionary, ficlStackPop(vm->floatStack));
66 66 }
67 67
68 68
69 69 ficlWord *
70 70 ficlDictionaryAppendFConstant(ficlDictionary *dictionary, char *name,
71 71 ficlFloat value)
72 72 {
73 73 ficlString s;
74 74 FICL_STRING_SET_FROM_CSTRING(s, name);
75 75 return (ficlDictionaryAppendConstantInstruction(dictionary, s,
76 76 ficlInstructionFConstantParen, *(ficlInteger *)(&value)));
77 77 }
78 78
79 79
80 80 ficlWord *
81 81 ficlDictionarySetFConstant(ficlDictionary *dictionary, char *name,
82 82 ficlFloat value)
83 83 {
84 84 ficlString s;
85 85 FICL_STRING_SET_FROM_CSTRING(s, name);
86 86 return (ficlDictionarySetConstantInstruction(dictionary, s,
87 87 ficlInstructionFConstantParen, *(ficlInteger *)(&value)));
88 88 }
89 89
90 90
91 91
92 92
93 93 static void
94 94 ficlPrimitiveF2Constant(ficlVm *vm)
95 95 {
96 96 ficlDictionary *dictionary = ficlVmGetDictionary(vm);
97 97 ficlString name = ficlVmGetWord(vm);
98 98
99 99 FICL_STACK_CHECK(vm->floatStack, 2, 0);
100 100
101 101 ficlDictionaryAppendWord(dictionary, name,
102 102 (ficlPrimitive)ficlInstructionF2ConstantParen, FICL_WORD_DEFAULT);
103 103 ficlDictionaryAppendCell(dictionary, ficlStackPop(vm->floatStack));
104 104 ficlDictionaryAppendCell(dictionary, ficlStackPop(vm->floatStack));
105 105 }
106 106
107 107 ficlWord *
108 108 ficlDictionaryAppendF2Constant(ficlDictionary *dictionary, char *name,
109 109 ficlFloat value)
110 110 {
111 111 ficlString s;
112 112 FICL_STRING_SET_FROM_CSTRING(s, name);
113 113 return (ficlDictionaryAppend2ConstantInstruction(dictionary, s,
114 114 ficlInstructionF2ConstantParen, *(ficl2Integer *)(&value)));
115 115 }
116 116
117 117 ficlWord *
118 118 ficlDictionarySetF2Constant(ficlDictionary *dictionary, char *name,
119 119 ficlFloat value)
120 120 {
121 121 ficlString s;
122 122 FICL_STRING_SET_FROM_CSTRING(s, name);
123 123 return (ficlDictionarySet2ConstantInstruction(dictionary, s,
124 124 ficlInstructionF2ConstantParen, *(ficl2Integer *)(&value)));
125 125 }
126 126
127 127 /*
128 128 * Display a float in decimal format.
129 129 * f. ( r -- )
130 130 */
131 131 static void
132 132 ficlPrimitiveFDot(ficlVm *vm)
133 133 {
134 134 ficlFloat f;
135 135
136 136 FICL_STACK_CHECK(vm->floatStack, 1, 0);
137 137
138 138 f = ficlStackPopFloat(vm->floatStack);
139 139 sprintf(vm->pad, "%#f ", f);
140 140 ficlVmTextOut(vm, vm->pad);
141 141 }
142 142
143 143 /*
144 144 * Display a float in engineering format.
145 145 * fe. ( r -- )
146 146 */
147 147 static void
148 148 ficlPrimitiveEDot(ficlVm *vm)
149 149 {
150 150 ficlFloat f;
151 151
152 152 FICL_STACK_CHECK(vm->floatStack, 1, 0);
153 153
154 154 f = ficlStackPopFloat(vm->floatStack);
155 155 sprintf(vm->pad, "%#e ", f);
156 156 ficlVmTextOut(vm, vm->pad);
157 157 }
158 158
159 159 /*
160 160 * d i s p l a y FS t a c k
161 161 * Display the parameter stack (code for "f.s")
162 162 * f.s ( -- )
163 163 */
164 164 struct stackContext
165 165 {
166 166 ficlVm *vm;
167 167 int count;
168 168 };
169 169
170 170 static ficlInteger
171 171 ficlFloatStackDisplayCallback(void *c, ficlCell *cell)
172 172 {
173 173 struct stackContext *context = (struct stackContext *)c;
174 174 char buffer[80];
175 175 #ifdef _LP64
176 176 snprintf(buffer, sizeof (buffer), "[0x%016lx %3d] %20e (0x%016lx)\n",
177 177 (unsigned long) cell, context->count++, cell->f, cell->u);
178 178 #else
179 179 snprintf(buffer, sizeof (buffer), "[0x%08x %3d] %12e (0x%08x)\n",
180 180 (unsigned)cell, context->count++, cell->f, cell->u);
181 181 #endif
182 182 ficlVmTextOut(context->vm, buffer);
183 183 return (FICL_TRUE);
184 184 }
185 185
186 186 void
187 187 ficlVmDisplayFloatStack(ficlVm *vm)
188 188 {
189 189 struct stackContext context;
190 190 context.vm = vm;
191 191 context.count = 0;
192 192 ficlStackDisplay(vm->floatStack, ficlFloatStackDisplayCallback,
193 193 &context);
194 194 }
195 195
196 196 /*
197 197 * Do float stack depth.
198 198 * fdepth ( -- n )
199 199 */
200 200 static void
201 201 ficlPrimitiveFDepth(ficlVm *vm)
202 202 {
203 203 int i;
204 204
205 205 FICL_STACK_CHECK(vm->dataStack, 0, 1);
206 206
207 207 i = ficlStackDepth(vm->floatStack);
208 208 ficlStackPushInteger(vm->dataStack, i);
209 209 }
210 210
211 211 /*
212 212 * Compile a floating point literal.
213 213 */
214 214 static void
215 215 ficlPrimitiveFLiteralImmediate(ficlVm *vm)
216 216 {
217 217 ficlDictionary *dictionary = ficlVmGetDictionary(vm);
218 218 ficlCell cell;
219 219
220 220 FICL_STACK_CHECK(vm->floatStack, 1, 0);
221 221
222 222 cell = ficlStackPop(vm->floatStack);
223 223 if (cell.f == 1.0f) {
224 224 ficlDictionaryAppendUnsigned(dictionary, ficlInstructionF1);
225 225 } else if (cell.f == 0.0f) {
226 226 ficlDictionaryAppendUnsigned(dictionary, ficlInstructionF0);
227 227 } else if (cell.f == -1.0f) {
228 228 ficlDictionaryAppendUnsigned(dictionary, ficlInstructionFNeg1);
229 229 } else {
230 230 ficlDictionaryAppendUnsigned(dictionary,
231 231 ficlInstructionFLiteralParen);
232 232 ficlDictionaryAppendCell(dictionary, cell);
233 233 }
234 234 }
235 235
236 236 /*
237 237 * F l o a t P a r s e S t a t e
238 238 * Enum to determine the current segement of a floating point number
239 239 * being parsed.
240 240 */
241 241 #define NUMISNEG 1
242 242 #define EXPISNEG 2
243 243
244 244 typedef enum _floatParseState
245 245 {
246 246 FPS_START,
247 247 FPS_ININT,
248 248 FPS_INMANT,
249 249 FPS_STARTEXP,
250 250 FPS_INEXP
251 251 } FloatParseState;
252 252
253 253 /*
254 254 * f i c l P a r s e F l o a t N u m b e r
255 255 * vm -- Virtual Machine pointer.
256 256 * s -- String to parse.
257 257 * Returns 1 if successful, 0 if not.
258 258 */
259 259 int
260 260 ficlVmParseFloatNumber(ficlVm *vm, ficlString s)
261 261 {
262 262 unsigned char c;
263 263 unsigned char digit;
264 264 char *trace;
265 265 ficlUnsigned length;
266 266 ficlFloat power;
267 267 ficlFloat accum = 0.0f;
268 268 ficlFloat mant = 0.1f;
269 269 ficlInteger exponent = 0;
270 270 char flag = 0;
271 271 FloatParseState estate = FPS_START;
272 272
273 273 FICL_STACK_CHECK(vm->floatStack, 0, 1);
274 274
275 275 /*
276 276 * floating point numbers only allowed in base 10
277 277 */
278 278 if (vm->base != 10)
279 279 return (0);
280 280
281 281 trace = FICL_STRING_GET_POINTER(s);
282 282 length = FICL_STRING_GET_LENGTH(s);
283 283
284 284 /* Loop through the string's characters. */
285 285 while ((length--) && ((c = *trace++) != 0)) {
286 286 switch (estate) {
287 287 /* At start of the number so look for a sign. */
288 288 case FPS_START:
289 289 estate = FPS_ININT;
290 290 if (c == '-') {
291 291 flag |= NUMISNEG;
292 292 break;
293 293 }
294 294 if (c == '+') {
295 295 break;
296 296 }
297 297 /* FALLTHROUGH */
298 298 /*
299 299 * Converting integer part of number.
300 300 * Only allow digits, decimal and 'E'.
301 301 */
302 302 case FPS_ININT:
303 303 if (c == '.') {
304 304 estate = FPS_INMANT;
305 305 } else if ((c == 'e') || (c == 'E')) {
306 306 estate = FPS_STARTEXP;
307 307 } else {
308 308 digit = (unsigned char)(c - '0');
309 309 if (digit > 9)
310 310 return (0);
311 311
312 312 accum = accum * 10 + digit;
313 313 }
314 314 break;
315 315 /*
316 316 * Processing the fraction part of number.
317 317 * Only allow digits and 'E'
318 318 */
319 319 case FPS_INMANT:
320 320 if ((c == 'e') || (c == 'E')) {
321 321 estate = FPS_STARTEXP;
322 322 } else {
323 323 digit = (unsigned char)(c - '0');
324 324 if (digit > 9)
325 325 return (0);
326 326
327 327 accum += digit * mant;
328 328 mant *= 0.1f;
329 329 }
330 330 break;
331 331 /* Start processing the exponent part of number. */
332 332 /* Look for sign. */
333 333 case FPS_STARTEXP:
334 334 estate = FPS_INEXP;
335 335
336 336 if (c == '-') {
337 337 flag |= EXPISNEG;
338 338 break;
339 339 } else if (c == '+') {
340 340 break;
341 341 }
342 342 /* FALLTHROUGH */
343 343 /*
344 344 * Processing the exponent part of number.
345 345 * Only allow digits.
346 346 */
347 347 case FPS_INEXP:
348 348 digit = (unsigned char)(c - '0');
349 349 if (digit > 9)
350 350 return (0);
351 351
352 352 exponent = exponent * 10 + digit;
353 353
354 354 break;
355 355 }
356 356 }
357 357
358 358 /* If parser never made it to the exponent this is not a float. */
359 359 if (estate < FPS_STARTEXP)
360 360 return (0);
361 361
362 362 /* Set the sign of the number. */
363 363 if (flag & NUMISNEG)
364 364 accum = -accum;
365 365
366 366 /* If exponent is not 0 then adjust number by it. */
367 367 if (exponent != 0) {
368 368 /* Determine if exponent is negative. */
369 369 if (flag & EXPISNEG) {
370 370 exponent = -exponent;
371 371 }
372 372 /* power = 10^x */
373 373 #if defined(_LP64)
374 374 power = (ficlFloat)pow(10.0, exponent);
375 375 #else
376 376 power = (ficlFloat)powf(10.0, exponent);
377 377 #endif
378 378 accum *= power;
379 379 }
380 380
381 381 ficlStackPushFloat(vm->floatStack, accum);
382 382 if (vm->state == FICL_VM_STATE_COMPILE)
383 383 ficlPrimitiveFLiteralImmediate(vm);
384 384
385 385 return (1);
386 386 }
387 387 #endif /* FICL_WANT_FLOAT */
388 388
389 389 #if FICL_WANT_LOCALS
390 390 static void
391 391 ficlPrimitiveFLocalParen(ficlVm *vm)
392 392 {
393 393 ficlLocalParen(vm, 0, 1);
394 394 }
|
↓ open down ↓ |
394 lines elided |
↑ open up ↑ |
395 395
396 396 static void
397 397 ficlPrimitiveF2LocalParen(ficlVm *vm)
398 398 {
399 399 ficlLocalParen(vm, 1, 1);
400 400 }
401 401 #endif /* FICL_WANT_LOCALS */
402 402
403 403 /*
404 404 * Add float words to a system's dictionary.
405 - * system -- Pointer to the Ficl sytem to add float words to.
405 + * system -- Pointer to the Ficl system to add float words to.
406 406 */
407 407 void
408 408 ficlSystemCompileFloat(ficlSystem *system)
409 409 {
410 410 ficlDictionary *dictionary = ficlSystemGetDictionary(system);
411 411 ficlDictionary *environment = ficlSystemGetEnvironment(system);
412 412 #if FICL_WANT_FLOAT
413 413 ficlCell data;
414 414 #endif
415 415
416 416 FICL_SYSTEM_ASSERT(system, dictionary);
417 417 FICL_SYSTEM_ASSERT(system, environment);
418 418
419 419 #if FICL_WANT_LOCALS
420 420 ficlDictionarySetPrimitive(dictionary, "(flocal)",
421 421 ficlPrimitiveFLocalParen, FICL_WORD_COMPILE_ONLY);
422 422 ficlDictionarySetPrimitive(dictionary, "(f2local)",
423 423 ficlPrimitiveF2LocalParen, FICL_WORD_COMPILE_ONLY);
424 424 #endif /* FICL_WANT_LOCALS */
425 425
426 426 #if FICL_WANT_FLOAT
427 427 ficlDictionarySetPrimitive(dictionary, "fconstant",
428 428 ficlPrimitiveFConstant, FICL_WORD_DEFAULT);
429 429 ficlDictionarySetPrimitive(dictionary, "fvalue",
430 430 ficlPrimitiveFConstant, FICL_WORD_DEFAULT);
431 431 ficlDictionarySetPrimitive(dictionary, "f2constant",
432 432 ficlPrimitiveF2Constant, FICL_WORD_DEFAULT);
433 433 ficlDictionarySetPrimitive(dictionary, "f2value",
434 434 ficlPrimitiveF2Constant, FICL_WORD_DEFAULT);
435 435 ficlDictionarySetPrimitive(dictionary, "fdepth", ficlPrimitiveFDepth,
436 436 FICL_WORD_DEFAULT);
437 437 ficlDictionarySetPrimitive(dictionary, "fliteral",
438 438 ficlPrimitiveFLiteralImmediate, FICL_WORD_IMMEDIATE);
439 439 ficlDictionarySetPrimitive(dictionary, "f.", ficlPrimitiveFDot,
440 440 FICL_WORD_DEFAULT);
441 441 ficlDictionarySetPrimitive(dictionary, "f.s", ficlVmDisplayFloatStack,
442 442 FICL_WORD_DEFAULT);
443 443 ficlDictionarySetPrimitive(dictionary, "fe.", ficlPrimitiveEDot,
444 444 FICL_WORD_DEFAULT);
445 445
446 446 /*
447 447 * Missing words:
448 448 *
449 449 * d>f
450 450 * f>d
451 451 * falign
452 452 * faligned
453 453 * float+
454 454 * floats
455 455 * floor
456 456 * fmax
457 457 * fmin
458 458 */
459 459
460 460 #if defined(_LP64)
461 461 data.f = MAXDOUBLE;
462 462 #else
463 463 data.f = MAXFLOAT;
464 464 #endif
465 465 ficlDictionarySetConstant(environment, "max-float", data.i);
466 466 /* not all required words are present */
467 467 ficlDictionarySetConstant(environment, "floating", FICL_FALSE);
468 468 ficlDictionarySetConstant(environment, "floating-ext", FICL_FALSE);
469 469 ficlDictionarySetConstant(environment, "floating-stack",
470 470 system->stackSize);
471 471 #else
472 472 ficlDictionarySetConstant(environment, "floating", FICL_FALSE);
473 473 #endif
474 474 }
|
↓ open down ↓ |
59 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX