/* Copyright 2005 Chris Thomasson */ #if ! defined(SPINLOCK_IA32_H_INCLUDED) #define SPINLOCK_IA32_H_INCLUDED #if defined(__cplusplus) extern "C" { #endif #include "helper.h" #define IA32_L2CACHELINESZ 128 #define IA32_BOOL_TRUE ((signed int)1) #define IA32_BOOL_FALSE ((signed int)0) #define SPINLOCK_IA32_PADSZ IA32_L2CACHELINESZ #define SPINLOCK_IA32_TABLE_DEPTH 0x100 #define SPINLOCK_IA32_TABLE_ALIGNSZ IA32_L2CACHELINESZ #define SPINLOCK_IA32_TABLE_MEMALIGNSZ(mp_tabletype) \ (sizeof(mp_tabletype) + MEMALIGNSZ(SPINLOCK_IA32_TABLE_ALIGNSZ)) #define SPINLOCK_IA32_TABLE_MEMALIGNPTR(mp_tablemem) \ ((spinlock_ia32_table_t*)MEMALIGNPTR((mp_tablemem).base, SPINLOCK_IA32_TABLE_ALIGNSZ)) typedef struct spinlock_ia32_s spinlock_ia32_t; typedef struct spinlock_ia32_padded_s spinlock_ia32_padded_t; typedef struct spinlock_ia32_table_s spinlock_ia32_table_t; typedef struct spinlock_ia32_table_mem_s spinlock_ia32_table_mem_t; struct spinlock_ia32_s { void *state; }; struct spinlock_ia32_padded_s { spinlock_ia32_t _this; char pad1[TYPEPADSZ(spinlock_ia32_t, SPINLOCK_IA32_PADSZ)]; }; struct spinlock_ia32_table_s { spinlock_ia32_padded_t locks[SPINLOCK_IA32_TABLE_DEPTH]; }; struct spinlock_ia32_table_mem_s { char base[SPINLOCK_IA32_TABLE_MEMALIGNSZ(spinlock_ia32_table_t)]; }; extern void spinlock_ia32_libinit(void); extern spinlock_ia32_table_mem_t g_spinlock_ia32_table_mem; extern spinlock_ia32_table_t* g_spinlock_ia32_table; #if defined(__cplusplus) } #endif #endif