1 /* General macros and constants used by the kernel. */
5 #include <minix/config.h>
6 #include <minix/bitmap.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. */
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)
41 #define reallock(c, v) { if(intr_disabled()) { kinfo.relocking++; } else { intr_disable(); } }
43 #define reallock(c, v) intr_disable()
46 #define realunlock(c) intr_enable()
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)
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)
59 /* args to intr_init() */
60 #define INTS_ORIG 0 /* restore interrupts */
61 #define INTS_MINIX 1 /* initialize interrupts for minix */