Releasing debian version 3:6.03+dfsg-10.
[syslinux-debian.git] / com32 / include / sys / cpu.h
blob76c45da030ccc4b758ee833d10b666663818580c
1 #ifndef _CPU_H
2 #define _CPU_H
4 #include <stdbool.h>
5 #include <stdint.h>
6 #include <klibc/compiler.h>
8 #if __SIZEOF_POINTER__ == 4
9 #include <i386/cpu.h>
10 #elif __SIZEOF_POINTER__ == 8
11 #include <x86_64/cpu.h>
12 #else
13 #error "unsupported architecture"
14 #endif
16 typedef unsigned long irq_state_t;
18 static inline irq_state_t irq_state(void)
20 irq_state_t __st;
22 asm volatile("pushf ; pop %0" : "=rm" (__st) : : "memory");
23 return __st;
26 static inline irq_state_t irq_save(void)
28 irq_state_t __st = irq_state();
29 cli();
30 return __st;
33 static inline void irq_restore(irq_state_t __st)
35 asm volatile("push %0 ; popf" : : "rm" (__st) : "memory");
38 /* Standard macro to see if a specific flag is changeable */
39 static inline __constfunc bool cpu_has_eflag(unsigned long flag)
41 unsigned long f0, f1;
42 asm("pushf ; "
43 "pushf ; "
44 "pop %0 ; "
45 "mov %0,%1 ; "
46 "xor %2,%1 ; "
47 "push %1 ; "
48 "popf ; "
49 "pushf ; "
50 "pop %1 ; "
51 "popf"
52 : "=&r" (f0), "=&r" (f1)
53 : "ri" (flag));
54 return !!((f0^f1) & flag);
57 #endif