1.0.19.33: Improved interrupt handling on darwin/x86[-64]
[sbcl/eslaughter.git] / src / runtime / search.c
blob4bf6b503fa72f95db2e93fff9bdb6e6b8ea593f9
1 /*
2 * This software is part of the SBCL system. See the README file for
3 * more information.
5 * This software is derived from the CMU CL system, which was
6 * written at Carnegie Mellon University and released into the
7 * public domain. The software is in the public domain and is
8 * provided with absolutely no warranty. See the COPYING and CREDITS
9 * files for more information.
12 #include <string.h>
14 #include "sbcl.h"
15 #include "runtime.h"
16 #include "os.h"
17 #include "search.h"
18 #include "thread.h"
19 #include "genesis/primitive-objects.h"
21 boolean search_for_type(int type, lispobj **start, int *count)
23 lispobj obj, *addr;
25 while ((*count == -1 || (*count > 0)) &&
26 is_valid_lisp_addr((os_vm_address_t)*start)) {
27 obj = **start;
28 addr = *start;
29 if (*count != -1)
30 *count -= 2;
32 if (widetag_of(obj) == type)
33 return 1;
35 (*start) += 2;
37 return 0;
40 boolean search_for_symbol(char *name, lispobj **start, int *count)
42 struct symbol *symbol;
43 struct vector *symbol_name;
45 while (search_for_type(SYMBOL_HEADER_WIDETAG, start, count)) {
46 symbol = (struct symbol *)native_pointer((lispobj)*start);
47 if (lowtag_of(symbol->name) == OTHER_POINTER_LOWTAG) {
48 symbol_name = (struct vector *)native_pointer(symbol->name);
49 if (is_valid_lisp_addr((os_vm_address_t)symbol_name) &&
50 /* FIXME: Broken with more than one type of string
51 (i.e. even broken given (VECTOR NIL) */
52 widetag_of(symbol_name->header) == SIMPLE_BASE_STRING_WIDETAG &&
53 strcmp((char *)symbol_name->data, name) == 0)
54 return 1;
56 (*start) += 2;
58 return 0;