/* Copyright 2005 Chris Thomasson */ #if ! defined(REFCOUNT_IA32_H_INCLUDED) #define REFCOUNT_IA32_H_INCLUDED #if defined(__cplusplus) extern "C" { #endif #include "spinlock-ia32.h" typedef struct refcount_ia32_s refcount_ia32_t; typedef struct refcount_ia32_userstate_s refcount_ia32_userstate_t; typedef void (*refcount_ia32_fpdtor_t) (void*); struct refcount_ia32_userstate_s { refcount_ia32_fpdtor_t fpdtor; void *state; }; struct refcount_ia32_s { int refs; refcount_ia32_userstate_t ustate; }; static void refcount_ia32_libinit(void); extern int refcount_ia32_init( refcount_ia32_t*, int, refcount_ia32_fpdtor_t, void* ); extern void* refcount_ia32_state_load_depends( refcount_ia32_t volatile* ); extern refcount_ia32_t* refcount_ia32_add_load_strong( refcount_ia32_t* volatile*, int, spinlock_ia32_table_t const*, size_t ); extern int refcount_ia32_sub_strong( refcount_ia32_t volatile*, int, spinlock_ia32_table_t const*, size_t ); extern refcount_ia32_t* refcount_ia32_add_swap_weak( refcount_ia32_t* volatile*, refcount_ia32_t*, int ); extern void refcount_ia32_add_weak( refcount_ia32_t volatile*, int ); void refcount_ia32_libinit(void) { spinlock_ia32_libinit(); } #define REFCOUNT_BOOL_TRUE IA32_BOOL_TRUE #define REFCOUNT_BOOL_FALSE IA32_BOOL_FALSE typedef refcount_ia32_t refcount_t; #define refcount_libinit refcount_ia32_libinit #define refcount_init refcount_ia32_init #define refcount_state_load_depends refcount_ia32_state_load_depends #define refcount_add_swap_weak refcount_ia32_add_swap_weak #define refcount_add_weak refcount_ia32_add_weak #define refcount_add_load_strong(mp_pthis, mp_count) \ refcount_ia32_add_load_strong( \ (mp_pthis), \ (mp_count), \ g_spinlock_ia32_table, \ sizeof(spinlock_ia32_padded_t) \ ) #define refcount_sub_strong(mp_this, mp_count) \ refcount_ia32_sub_strong( \ (mp_this), \ (mp_count), \ g_spinlock_ia32_table, \ sizeof(spinlock_ia32_padded_t) \ ) #if defined(__cplusplus) } #endif #endif