#ifndef __ASM_SYSTEM_H
#define __ASM_SYSTEM_H
-#include <xen/config.h>
-#include <xen/types.h>
+#include <xen/lib.h>
#include <asm/bitops.h>
#define read_segment_register(name) \
/* used when interrupts are already enabled or to shutdown the processor */
#define halt() asm volatile ( "hlt" : : : "memory" )
+#define local_save_flags(x) \
+({ \
+ BUILD_BUG_ON(sizeof(x) != sizeof(long)); \
+ asm volatile ( "pushf" __OS " ; pop" __OS " %0" : "=g" (x)); \
+})
+#define local_irq_save(x) \
+({ \
+ local_save_flags(x); \
+ local_irq_disable(); \
+})
+#define local_irq_restore(x) \
+({ \
+ BUILD_BUG_ON(sizeof(x) != sizeof(long)); \
+ asm volatile ( "push" __OS " %0 ; popf" __OS \
+ : : "g" (x) : "memory", "cc" ); \
+})
+
static inline int local_irq_is_enabled(void)
{
unsigned long flags;
- __save_flags(flags);
+ local_save_flags(flags);
return !!(flags & (1<<9)); /* EFLAGS_IF */
}
#define mb() \
asm volatile ( "lock; addl $0,0(%%esp)" : : : "memory" )
-#define __save_flags(x) \
- asm volatile ( "pushfl ; popl %0" : "=g" (x) : )
-#define __restore_flags(x) \
- asm volatile ( "pushl %0 ; popfl" : : "g" (x) : "memory", "cc" )
-
-#define local_irq_save(x) \
- asm volatile ( "pushfl ; popl %0 ; cli" : "=g" (x) : : "memory" )
-#define local_irq_restore(x) \
- __restore_flags(x)
-
#endif /* __X86_32_SYSTEM_H__ */
#define mb() \
asm volatile ( "mfence" : : : "memory" )
-#define __save_flags(x) \
- asm volatile ( "pushfq ; popq %q0" : "=g" (x) : :"memory" )
-#define __restore_flags(x) \
- asm volatile ( "pushq %0 ; popfq" : : "g" (x) : "memory", "cc" )
-
-#define local_irq_save(x) \
- asm volatile ( "pushfq ; popq %0 ; cli" : "=g" (x) : : "memory" )
-#define local_irq_restore(x) \
- __restore_flags(x)
-
#endif /* __X86_64_SYSTEM_H__ */