Add methods for converting between Collections (asBag, asSet, etc)
[panda.git] / src / st-types.h
blob02086c8fbf89ce5a11359b355fd72f5b078b7114
1 /*
2 * st-types.h
4 * Copyright (C) 2008 Vincent Geddes
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
25 #ifndef __ST_TYPES_H__
26 #define __ST_TYPES_H__
28 #include <stdbool.h>
29 #include <stdint.h>
30 #include <config.h>
31 #include <stddef.h>
33 /* Check host data model. We only support LP64 at the moment.
35 #if (SIZEOF_VOID_P == 4 && SIZEOF_INT == 4)
36 # define ST_HOST32 1
37 # define ST_HOST64 0
38 # define ST_BITS_PER_WORD 32
39 # define ST_BITS_PER_INTEGER 32
40 #elif (SIZEOF_VOID_P == 8)
41 # define ST_HOST32 0
42 # define ST_HOST64 1
43 # define ST_BITS_PER_WORD 64
44 # define ST_BITS_PER_INTEGER 32
45 #else
46 # error Sorry, platform not supported. Patches welcome!
47 #endif
49 #define ST_SMALL_INTEGER_MIN (-ST_SMALL_INTEGER_MAX - 1)
50 #define ST_SMALL_INTEGER_MAX 536870911
52 enum {
53 ST_SMI_TAG,
54 ST_POINTER_TAG,
55 ST_CHARACTER_TAG,
56 ST_MARK_TAG,
59 #define ST_TAG_SIZE 2
61 /* basic oop pointer:
62 * integral type wide enough to hold a C pointer.
63 * Can either point to a heap object or contain a smi or Character immediate.
65 typedef uintptr_t st_oop;
67 typedef unsigned char st_uchar;
68 typedef unsigned short st_ushort;
69 typedef unsigned long st_ulong;
70 typedef unsigned int st_uint;
71 typedef void * st_pointer;
72 typedef st_uint st_unichar;
74 static inline st_oop
75 st_tag_pointer (st_pointer p)
77 return ((st_oop) p) + ST_POINTER_TAG;
80 static inline st_oop *
81 st_detag_pointer (st_oop oop)
83 return (st_oop *) (oop - ST_POINTER_TAG);
86 #endif /* __ST_TYPES_H__ */