. use library function to parse memory string
[minix3.git] / kernel / const.h
blobb8cd35263199d2f0d00b4142495117a40402b551
1 /* General macros and constants used by the kernel. */
2 #ifndef CONST_H
3 #define CONST_H
5 #include <minix/config.h>
6 #include <minix/bitmap.h>
8 #include "config.h"
10 /* Map a process number to a privilege structure id. */
11 #define s_nr_to_id(n) (NR_TASKS + (n) + 1)
13 /* Translate a pointer to a field in a structure to a pointer to the structure
14 * itself. So it translates '&struct_ptr->field' back to 'struct_ptr'.
16 #define structof(type, field, ptr) \
17 ((type *) (((char *) (ptr)) - offsetof(type, field)))
19 /* Translate an endpoint number to a process number, return success. */
20 #define isokendpt(e,p) isokendpt_d((e),(p),0)
21 #define okendpt(e,p) isokendpt_d((e),(p),1)
23 /* Constants used in virtual_copy(). Values must be 0 and 1, respectively. */
24 #define _SRC_ 0
25 #define _DST_ 1
27 /* Number of random sources */
28 #define RANDOM_SOURCES 16
30 #define get_sys_bit(map,bit) \
31 ( MAP_CHUNK(map.chunk,bit) & (1 << CHUNK_OFFSET(bit) )
32 #define get_sys_bits(map,bit) \
33 ( MAP_CHUNK(map.chunk,bit) )
34 #define set_sys_bit(map,bit) \
35 ( MAP_CHUNK(map.chunk,bit) |= (1 << CHUNK_OFFSET(bit) )
36 #define unset_sys_bit(map,bit) \
37 ( MAP_CHUNK(map.chunk,bit) &= ~(1 << CHUNK_OFFSET(bit) )
38 #define NR_SYS_CHUNKS BITMAP_CHUNKS(NR_SYS_PROCS)
40 #if DEBUG_LOCK_CHECK
41 #define reallock(c, v) { if(intr_disabled()) { kinfo.relocking++; } else { intr_disable(); } }
42 #else
43 #define reallock(c, v) intr_disable()
44 #endif
46 #define realunlock(c) intr_enable()
48 #if DEBUG_TIME_LOCKS
49 #define lock(c, v) do { reallock(c, v); locktimestart(c, v); } while(0)
50 #define unlock(c) do { locktimeend(c); realunlock(c); } while(0)
51 #else
52 /* Disable/ enable hardware interrupts. The parameters of lock() and unlock()
53 * are used when debugging is enabled. See debug.h for more information.
55 #define lock(c, v) reallock(c, v)
56 #define unlock(c) realunlock(c)
57 #endif
59 /* args to intr_init() */
60 #define INTS_ORIG 0 /* restore interrupts */
61 #define INTS_MINIX 1 /* initialize interrupts for minix */
63 #endif /* CONST_H */