2 * Copyright (c) 2000 Daniel Capo Sobral
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * Additional FICL words designed for FreeBSD's loader
35 #include <sys/types.h>
47 #include <machine/cpufunc.h>
49 #include "bootstrap.h"
54 #include <uuid/uuid.h>
60 * FreeBSD's loader interaction words and extras
62 * setenv ( value n name n' -- )
63 * setenv? ( value n name n' flag -- )
64 * getenv ( addr n -- addr' n' | -1 )
65 * unsetenv ( addr n -- )
66 * copyin ( addr addr' len -- )
67 * copyout ( addr addr' len -- )
68 * findfile ( name len type len' -- addr )
69 * ccall ( [[...[p10] p9] ... p1] n addr -- result )
70 * uuid-from-string ( addr n -- addr' )
71 * uuid-to-string ( addr' -- addr n | -1 )
76 ficlSetenv(ficlVm
*pVM
)
82 FICL_STACK_CHECK(ficlVmGetDataStack(pVM
), 4, 0);
84 names
= ficlStackPopInteger(ficlVmGetDataStack(pVM
));
85 namep
= (char *)ficlStackPopPointer(ficlVmGetDataStack(pVM
));
86 values
= ficlStackPopInteger(ficlVmGetDataStack(pVM
));
87 valuep
= (char *)ficlStackPopPointer(ficlVmGetDataStack(pVM
));
89 name
= (char *)ficlMalloc(names
+1);
91 ficlVmThrowError(pVM
, "Error: out of memory");
92 strncpy(name
, namep
, names
);
94 value
= (char *)ficlMalloc(values
+1);
96 ficlVmThrowError(pVM
, "Error: out of memory");
97 strncpy(value
, valuep
, values
);
100 setenv(name
, value
, 1);
106 ficlSetenvq(ficlVm
*pVM
)
109 char *namep
, *valuep
;
110 int names
, values
, overwrite
;
112 FICL_STACK_CHECK(ficlVmGetDataStack(pVM
), 5, 0);
114 overwrite
= ficlStackPopInteger(ficlVmGetDataStack(pVM
));
115 names
= ficlStackPopInteger(ficlVmGetDataStack(pVM
));
116 namep
= (char *)ficlStackPopPointer(ficlVmGetDataStack(pVM
));
117 values
= ficlStackPopInteger(ficlVmGetDataStack(pVM
));
118 valuep
= (char *)ficlStackPopPointer(ficlVmGetDataStack(pVM
));
120 name
= (char *)ficlMalloc(names
+1);
122 ficlVmThrowError(pVM
, "Error: out of memory");
123 strncpy(name
, namep
, names
);
125 value
= (char *)ficlMalloc(values
+1);
127 ficlVmThrowError(pVM
, "Error: out of memory");
128 strncpy(value
, valuep
, values
);
129 value
[values
] = '\0';
131 setenv(name
, value
, overwrite
);
137 ficlGetenv(ficlVm
*pVM
)
143 FICL_STACK_CHECK(ficlVmGetDataStack(pVM
), 2, 2);
145 names
= ficlStackPopInteger(ficlVmGetDataStack(pVM
));
146 namep
= (char *)ficlStackPopPointer(ficlVmGetDataStack(pVM
));
148 name
= (char *)ficlMalloc(names
+1);
150 ficlVmThrowError(pVM
, "Error: out of memory");
151 strncpy(name
, namep
, names
);
154 value
= getenv(name
);
158 ficlStackPushPointer(ficlVmGetDataStack(pVM
), value
);
159 ficlStackPushInteger(ficlVmGetDataStack(pVM
), strlen(value
));
161 ficlStackPushInteger(ficlVmGetDataStack(pVM
), -1);
165 ficlUnsetenv(ficlVm
*pVM
)
171 FICL_STACK_CHECK(ficlVmGetDataStack(pVM
), 2, 0);
173 names
= ficlStackPopInteger(ficlVmGetDataStack(pVM
));
174 namep
= (char *)ficlStackPopPointer(ficlVmGetDataStack(pVM
));
176 name
= (char *)ficlMalloc(names
+1);
178 ficlVmThrowError(pVM
, "Error: out of memory");
179 strncpy(name
, namep
, names
);
187 ficlCopyin(ficlVm
*pVM
)
195 FICL_STACK_CHECK(ficlVmGetDataStack(pVM
), 3, 0);
198 len
= ficlStackPopInteger(ficlVmGetDataStack(pVM
));
199 dest
= ficlStackPopInteger(ficlVmGetDataStack(pVM
));
200 src
= ficlStackPopPointer(ficlVmGetDataStack(pVM
));
201 archsw
.arch_copyin(src
, dest
, len
);
203 (void) ficlStackPopInteger(ficlVmGetDataStack(pVM
));
204 (void) ficlStackPopInteger(ficlVmGetDataStack(pVM
));
205 (void) ficlStackPopPointer(ficlVmGetDataStack(pVM
));
210 ficlCopyout(ficlVm
*pVM
)
218 FICL_STACK_CHECK(ficlVmGetDataStack(pVM
), 3, 0);
221 len
= ficlStackPopInteger(ficlVmGetDataStack(pVM
));
222 dest
= ficlStackPopPointer(ficlVmGetDataStack(pVM
));
223 src
= ficlStackPopInteger(ficlVmGetDataStack(pVM
));
224 archsw
.arch_copyout(src
, dest
, len
);
226 (void) ficlStackPopInteger(ficlVmGetDataStack(pVM
));
227 (void) ficlStackPopPointer(ficlVmGetDataStack(pVM
));
228 (void) ficlStackPopInteger(ficlVmGetDataStack(pVM
));
233 ficlFindfile(ficlVm
*pVM
)
240 struct preloaded_file
*fp
;
242 FICL_STACK_CHECK(ficlVmGetDataStack(pVM
), 4, 1);
245 types
= ficlStackPopInteger(ficlVmGetDataStack(pVM
));
246 typep
= (char *)ficlStackPopPointer(ficlVmGetDataStack(pVM
));
247 names
= ficlStackPopInteger(ficlVmGetDataStack(pVM
));
248 namep
= (char *)ficlStackPopPointer(ficlVmGetDataStack(pVM
));
250 name
= (char *)ficlMalloc(names
+1);
252 ficlVmThrowError(pVM
, "Error: out of memory");
253 strncpy(name
, namep
, names
);
255 type
= (char *)ficlMalloc(types
+1);
257 ficlVmThrowError(pVM
, "Error: out of memory");
258 strncpy(type
, typep
, types
);
261 fp
= file_findfile(name
, type
);
263 (void) ficlStackPopInteger(ficlVmGetDataStack(pVM
));
264 (void) ficlStackPopPointer(ficlVmGetDataStack(pVM
));
265 (void) ficlStackPopInteger(ficlVmGetDataStack(pVM
));
266 (void) ficlStackPopPointer(ficlVmGetDataStack(pVM
));
270 ficlStackPushPointer(ficlVmGetDataStack(pVM
), fp
);
274 ficlCcall(ficlVm
*pVM
)
276 int (*func
)(int, ...);
280 FICL_STACK_CHECK(ficlVmGetDataStack(pVM
), 2, 0);
282 func
= (int (*)(int, ...))ficlStackPopPointer(ficlVmGetDataStack(pVM
));
283 nparam
= ficlStackPopInteger(ficlVmGetDataStack(pVM
));
285 FICL_STACK_CHECK(ficlVmGetDataStack(pVM
), nparam
, 1);
287 for (i
= 0; i
< nparam
; i
++)
288 p
[i
] = ficlStackPopInteger(ficlVmGetDataStack(pVM
));
290 result
= func(p
[0], p
[1], p
[2], p
[3], p
[4], p
[5], p
[6], p
[7], p
[8],
293 ficlStackPushInteger(ficlVmGetDataStack(pVM
), result
);
297 ficlUuidFromString(ficlVm
*pVM
)
309 FICL_STACK_CHECK(ficlVmGetDataStack(pVM
), 2, 0);
311 uuid_size
= ficlStackPopInteger(ficlVmGetDataStack(pVM
));
312 uuid_ptr
= ficlStackPopPointer(ficlVmGetDataStack(pVM
));
314 uuid
= ficlMalloc(uuid_size
+ 1);
316 ficlVmThrowError(pVM
, "Error: out of memory");
317 (void) memcpy(uuid
, uuid_ptr
, uuid_size
);
318 uuid
[uuid_size
] = '\0';
320 u
= ficlMalloc(sizeof (*u
));
322 uuid_from_string(uuid
, u
, &status
);
324 if (status
!= uuid_s_ok
) {
329 status
= uuid_parse(uuid
, *u
);
336 ficlStackPushPointer(ficlVmGetDataStack(pVM
), u
);
340 ficlUuidToString(ficlVm
*pVM
)
348 FICL_STACK_CHECK(ficlVmGetDataStack(pVM
), 1, 0);
350 u
= ficlStackPopPointer(ficlVmGetDataStack(pVM
));
352 uuid_to_string(u
, &uuid
, &status
);
353 if (status
== uuid_s_ok
) {
354 ficlStackPushPointer(ficlVmGetDataStack(pVM
), uuid
);
355 ficlStackPushInteger(ficlVmGetDataStack(pVM
), strlen(uuid
));
358 uuid
= ficlMalloc(UUID_PRINTABLE_STRING_LENGTH
);
360 uuid_unparse(*u
, uuid
);
361 ficlStackPushPointer(ficlVmGetDataStack(pVM
), uuid
);
362 ficlStackPushInteger(ficlVmGetDataStack(pVM
), strlen(uuid
));
365 ficlStackPushInteger(ficlVmGetDataStack(pVM
), -1);
369 * f i c l E x e c F D
370 * reads in text from file fd and passes it to ficlExec()
371 * returns FICL_VM_STATUS_OUT_OF_TEXT on success or the ficlExec() error
376 ficlExecFD(ficlVm
*pVM
, int fd
)
379 int nLine
= 0, rval
= FICL_VM_STATUS_OUT_OF_TEXT
;
385 pVM
->sourceId
.i
= fd
+1; /* in loader we can get 0, there is no stdin */
387 /* feed each line to ficlExec */
392 while ((status
= read(fd
, &ch
, 1)) > 0 && ch
!= '\n')
403 FICL_STRING_SET_POINTER(s
, cp
);
404 FICL_STRING_SET_LENGTH(s
, i
);
406 rval
= ficlVmExecuteString(pVM
, s
);
407 if (rval
!= FICL_VM_STATUS_QUIT
&&
408 rval
!= FICL_VM_STATUS_USER_EXIT
&&
409 rval
!= FICL_VM_STATUS_OUT_OF_TEXT
) {
411 (void) ficlVmEvaluate(pVM
, "");
418 * Pass an empty line with SOURCE-ID == -1 to flush
419 * any pending REFILLs (as required by FILE wordset)
421 (void) ficlVmEvaluate(pVM
, "");
423 if (rval
== FICL_VM_STATUS_USER_EXIT
)
424 ficlVmThrow(pVM
, FICL_VM_STATUS_USER_EXIT
);
429 static void displayCellNoPad(ficlVm
*pVM
)
432 FICL_STACK_CHECK(ficlVmGetDataStack(pVM
), 1, 0);
434 c
= ficlStackPop(ficlVmGetDataStack(pVM
));
435 ficlLtoa((c
).i
, pVM
->pad
, pVM
->base
);
436 ficlVmTextOut(pVM
, pVM
->pad
);
440 * isdir? - Return whether an fd corresponds to a directory.
442 * isdir? ( fd -- bool )
445 isdirQuestion(ficlVm
*pVM
)
451 FICL_STACK_CHECK(ficlVmGetDataStack(pVM
), 1, 1);
453 fd
= ficlStackPopInteger(ficlVmGetDataStack(pVM
));
458 if (fstat(fd
, &sb
) < 0)
460 if (!S_ISDIR(sb
.st_mode
))
464 ficlStackPushInteger(ficlVmGetDataStack(pVM
), flag
);
468 * fopen - open a file and return new fd on stack.
470 * fopen ( ptr count mode -- fd )
472 extern char *get_dev(const char *);
483 FICL_STACK_CHECK(ficlVmGetDataStack(pVM
), 3, 1);
485 mode
= ficlStackPopInteger(ficlVmGetDataStack(pVM
)); /* get mode */
486 count
= ficlStackPopInteger(ficlVmGetDataStack(pVM
)); /* get count */
487 ptr
= ficlStackPopPointer(ficlVmGetDataStack(pVM
)); /* get ptr */
489 if ((count
< 0) || (ptr
== NULL
)) {
490 ficlStackPushInteger(ficlVmGetDataStack(pVM
), -1);
494 /* ensure that the string is null terminated */
495 name
= (char *)malloc(count
+1);
496 bcopy(ptr
, name
, count
);
505 fd
= open(name
, mode
);
507 ficlStackPushInteger(ficlVmGetDataStack(pVM
), fd
);
511 * fclose - close a file who's fd is on stack.
519 FICL_STACK_CHECK(ficlVmGetDataStack(pVM
), 1, 0);
521 fd
= ficlStackPopInteger(ficlVmGetDataStack(pVM
)); /* get fd */
527 * fread - read file contents
528 * fread ( fd buf nbytes -- nread )
536 FICL_STACK_CHECK(ficlVmGetDataStack(pVM
), 3, 1);
538 len
= ficlStackPopInteger(ficlVmGetDataStack(pVM
));
539 buf
= ficlStackPopPointer(ficlVmGetDataStack(pVM
)); /* get buffer */
540 fd
= ficlStackPopInteger(ficlVmGetDataStack(pVM
)); /* get fd */
541 if (len
> 0 && buf
&& fd
!= -1)
542 ficlStackPushInteger(ficlVmGetDataStack(pVM
),
545 ficlStackPushInteger(ficlVmGetDataStack(pVM
), -1);
549 * fopendir - open directory
551 * fopendir ( addr len -- ptr TRUE | FALSE )
553 static void pfopendir(ficlVm
*pVM
)
564 ficlInteger flag
= FICL_FALSE
;
566 FICL_STACK_CHECK(ficlVmGetDataStack(pVM
), 2, 1);
568 count
= ficlStackPopInteger(ficlVmGetDataStack(pVM
));
569 ptr
= ficlStackPopPointer(ficlVmGetDataStack(pVM
)); /* get ptr */
571 if ((count
< 0) || (ptr
== NULL
)) {
572 ficlStackPushInteger(ficlVmGetDataStack(pVM
), -1);
575 /* ensure that the string is null terminated */
576 name
= (char *)malloc(count
+1);
577 bcopy(ptr
, name
, count
);
584 fd
= open(name
, O_RDONLY
);
589 if (fstat(fd
, &sb
) < 0)
591 if (!S_ISDIR(sb
.st_mode
))
594 ficlStackPushInteger(ficlVmGetDataStack(pVM
), fd
);
595 ficlStackPushInteger(ficlVmGetDataStack(pVM
), flag
);
602 ficlStackPushInteger(ficlVmGetDataStack(pVM
), flag
);
608 ficlStackPushInteger(ficlVmGetDataStack(pVM
), flag
);
613 ficlStackPushPointer(ficlVmGetDataStack(pVM
), dir
);
614 ficlStackPushInteger(ficlVmGetDataStack(pVM
), flag
);
619 * freaddir - read directory contents
620 * freaddir ( fd -- ptr len TRUE | FALSE )
623 pfreaddir(ficlVm
*pVM
)
626 static DIR *dir
= NULL
;
630 struct dirent
*d
= NULL
;
632 FICL_STACK_CHECK(ficlVmGetDataStack(pVM
), 1, 3);
634 * libstand readdir does not always return . nor .. so filter
635 * them out to have consistent behaviour.
638 dir
= ficlStackPopPointer(ficlVmGetDataStack(pVM
));
642 if (d
!= NULL
&& strcmp(d
->d_name
, ".") == 0)
644 if (d
!= NULL
&& strcmp(d
->d_name
, "..") == 0)
649 fd
= ficlStackPopInteger(ficlVmGetDataStack(pVM
));
653 if (d
!= NULL
&& strcmp(d
->d_name
, ".") == 0)
655 if (d
!= NULL
&& strcmp(d
->d_name
, "..") == 0)
661 ficlStackPushPointer(ficlVmGetDataStack(pVM
), d
->d_name
);
662 ficlStackPushInteger(ficlVmGetDataStack(pVM
),
664 ficlStackPushInteger(ficlVmGetDataStack(pVM
), FICL_TRUE
);
666 ficlStackPushInteger(ficlVmGetDataStack(pVM
), FICL_FALSE
);
671 * fclosedir - close a dir on stack.
673 * fclosedir ( fd -- )
676 pfclosedir(ficlVm
*pVM
)
684 FICL_STACK_CHECK(ficlVmGetDataStack(pVM
), 1, 0);
687 dir
= ficlStackPopPointer(ficlVmGetDataStack(pVM
)); /* get dir */
691 fd
= ficlStackPopInteger(ficlVmGetDataStack(pVM
)); /* get fd */
698 * fload - interpret file contents
702 static void pfload(ficlVm
*pVM
)
706 FICL_STACK_CHECK(ficlVmGetDataStack(pVM
), 1, 0);
708 fd
= ficlStackPopInteger(ficlVmGetDataStack(pVM
)); /* get fd */
714 * fwrite - write file contents
716 * fwrite ( fd buf nbytes -- nwritten )
724 FICL_STACK_CHECK(ficlVmGetDataStack(pVM
), 3, 1);
726 len
= ficlStackPopInteger(ficlVmGetDataStack(pVM
)); /* bytes to read */
727 buf
= ficlStackPopPointer(ficlVmGetDataStack(pVM
)); /* get buffer */
728 fd
= ficlStackPopInteger(ficlVmGetDataStack(pVM
)); /* get fd */
729 if (len
> 0 && buf
&& fd
!= -1)
730 ficlStackPushInteger(ficlVmGetDataStack(pVM
),
731 write(fd
, buf
, len
));
733 ficlStackPushInteger(ficlVmGetDataStack(pVM
), -1);
737 * fseek - seek to a new position in a file
739 * fseek ( fd ofs whence -- pos )
746 FICL_STACK_CHECK(ficlVmGetDataStack(pVM
), 3, 1);
748 whence
= ficlStackPopInteger(ficlVmGetDataStack(pVM
));
749 pos
= ficlStackPopInteger(ficlVmGetDataStack(pVM
));
750 fd
= ficlStackPopInteger(ficlVmGetDataStack(pVM
));
751 ficlStackPushInteger(ficlVmGetDataStack(pVM
), lseek(fd
, pos
, whence
));
755 * key - get a character from stdin
762 FICL_STACK_CHECK(ficlVmGetDataStack(pVM
), 0, 1);
764 ficlStackPushInteger(ficlVmGetDataStack(pVM
), getchar());
768 * key? - check for a character from stdin (FACILITY)
772 keyQuestion(ficlVm
*pVM
)
780 FICL_STACK_CHECK(ficlVmGetDataStack(pVM
), 0, 1);
783 tcgetattr(STDIN_FILENO
, &oldt
);
785 newt
.c_lflag
&= ~(ICANON
| ECHO
);
787 newt
.c_cc
[VTIME
] = 0;
788 tcsetattr(STDIN_FILENO
, TCSANOW
, &newt
);
790 tcsetattr(STDIN_FILENO
, TCSANOW
, &oldt
);
793 (void) ungetc(ch
, stdin
);
795 ficlStackPushInteger(ficlVmGetDataStack(pVM
),
796 ch
!= -1? FICL_TRUE
: FICL_FALSE
);
798 ficlStackPushInteger(ficlVmGetDataStack(pVM
),
799 ischar()? FICL_TRUE
: FICL_FALSE
);
804 * seconds - gives number of seconds since beginning of time
806 * beginning of time is defined as:
808 * BTX - number of seconds since midnight
809 * FreeBSD - number of seconds since Jan 1 1970
814 pseconds(ficlVm
*pVM
)
816 FICL_STACK_CHECK(ficlVmGetDataStack(pVM
), 0, 1);
818 ficlStackPushUnsigned(ficlVmGetDataStack(pVM
),
819 (ficlUnsigned
) time(NULL
));
823 * ms - wait at least that many milliseconds (FACILITY)
829 FICL_STACK_CHECK(ficlVmGetDataStack(pVM
), 1, 0);
832 usleep(ficlStackPopUnsigned(ficlVmGetDataStack(pVM
)) * 1000);
834 delay(ficlStackPopUnsigned(ficlVmGetDataStack(pVM
)) * 1000);
839 * fkey - get a character from a file
840 * fkey ( file -- char )
848 FICL_STACK_CHECK(ficlVmGetDataStack(pVM
), 1, 1);
850 fd
= ficlStackPopInteger(ficlVmGetDataStack(pVM
));
851 i
= read(fd
, &ch
, 1);
852 ficlStackPushInteger(ficlVmGetDataStack(pVM
), i
> 0 ? ch
: -1);
860 * outb ( port# c -- )
861 * Store a byte to I/O port number port#
864 ficlOutb(ficlVm
*pVM
)
869 port
= ficlStackPopUnsigned(ficlVmGetDataStack(pVM
));
870 c
= ficlStackPopInteger(ficlVmGetDataStack(pVM
));
876 * Fetch a byte from I/O port number port#
884 port
= ficlStackPopUnsigned(ficlVmGetDataStack(pVM
));
886 ficlStackPushInteger(ficlVmGetDataStack(pVM
), c
);
892 * Retrieves free space remaining on the dictionary
895 freeHeap(ficlVm
*pVM
)
897 ficlStackPushInteger(ficlVmGetDataStack(pVM
),
898 ficlDictionaryCellsAvailable(ficlVmGetDictionary(pVM
)));
902 * f i c l C o m p i l e P l a t f o r m
903 * Build FreeBSD platform extensions into the system dictionary
906 ficlSystemCompilePlatform(ficlSystem
*pSys
)
908 ficlDictionary
*dp
= ficlSystemGetDictionary(pSys
);
909 ficlDictionary
*env
= ficlSystemGetEnvironment(pSys
);
911 ficlCompileFcn
**fnpp
;
914 FICL_SYSTEM_ASSERT(pSys
, dp
);
915 FICL_SYSTEM_ASSERT(pSys
, env
);
917 ficlDictionarySetPrimitive(dp
, ".#", displayCellNoPad
,
919 ficlDictionarySetPrimitive(dp
, "isdir?", isdirQuestion
,
921 ficlDictionarySetPrimitive(dp
, "fopen", pfopen
, FICL_WORD_DEFAULT
);
922 ficlDictionarySetPrimitive(dp
, "fclose", pfclose
, FICL_WORD_DEFAULT
);
923 ficlDictionarySetPrimitive(dp
, "fread", pfread
, FICL_WORD_DEFAULT
);
924 ficlDictionarySetPrimitive(dp
, "fopendir", pfopendir
,
926 ficlDictionarySetPrimitive(dp
, "freaddir", pfreaddir
,
928 ficlDictionarySetPrimitive(dp
, "fclosedir", pfclosedir
,
930 ficlDictionarySetPrimitive(dp
, "fload", pfload
, FICL_WORD_DEFAULT
);
931 ficlDictionarySetPrimitive(dp
, "fkey", fkey
, FICL_WORD_DEFAULT
);
932 ficlDictionarySetPrimitive(dp
, "fseek", pfseek
, FICL_WORD_DEFAULT
);
933 ficlDictionarySetPrimitive(dp
, "fwrite", pfwrite
, FICL_WORD_DEFAULT
);
934 ficlDictionarySetPrimitive(dp
, "key", key
, FICL_WORD_DEFAULT
);
935 ficlDictionarySetPrimitive(dp
, "key?", keyQuestion
, FICL_WORD_DEFAULT
);
936 ficlDictionarySetPrimitive(dp
, "ms", ms
, FICL_WORD_DEFAULT
);
937 ficlDictionarySetPrimitive(dp
, "seconds", pseconds
, FICL_WORD_DEFAULT
);
938 ficlDictionarySetPrimitive(dp
, "heap?", freeHeap
, FICL_WORD_DEFAULT
);
940 ficlDictionarySetPrimitive(dp
, "setenv", ficlSetenv
, FICL_WORD_DEFAULT
);
941 ficlDictionarySetPrimitive(dp
, "setenv?", ficlSetenvq
,
943 ficlDictionarySetPrimitive(dp
, "getenv", ficlGetenv
, FICL_WORD_DEFAULT
);
944 ficlDictionarySetPrimitive(dp
, "unsetenv", ficlUnsetenv
,
946 ficlDictionarySetPrimitive(dp
, "copyin", ficlCopyin
, FICL_WORD_DEFAULT
);
947 ficlDictionarySetPrimitive(dp
, "copyout", ficlCopyout
,
949 ficlDictionarySetPrimitive(dp
, "findfile", ficlFindfile
,
951 ficlDictionarySetPrimitive(dp
, "ccall", ficlCcall
, FICL_WORD_DEFAULT
);
952 ficlDictionarySetPrimitive(dp
, "uuid-from-string", ficlUuidFromString
,
954 ficlDictionarySetPrimitive(dp
, "uuid-to-string", ficlUuidToString
,
958 ficlDictionarySetPrimitive(dp
, "outb", ficlOutb
, FICL_WORD_DEFAULT
);
959 ficlDictionarySetPrimitive(dp
, "inb", ficlInb
, FICL_WORD_DEFAULT
);
961 /* Register words from linker set. */
962 SET_FOREACH(fnpp
, Xficl_compile_set
)
966 #if defined(__i386__) || defined(__amd64__)
967 ficlDictionarySetConstant(env
, "arch-i386", FICL_TRUE
);
968 ficlDictionarySetConstant(env
, "arch-sparc", FICL_FALSE
);
971 ficlDictionarySetConstant(env
, "arch-i386", FICL_FALSE
);
972 ficlDictionarySetConstant(env
, "arch-sparc", FICL_TRUE
);