/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ /* * See COPYRIGHT in top-level directory. */ #ifndef _ZM_LOCK_H #define _ZM_LOCK_H #define ZM_TICKET_IF 1 #define ZM_MCS_IF 2 #define ZM_MMCS_IF 3 #define ZM_HMCS_IF 4 #define ZM_MCSP_IF 5 #define ZM_TLP_IF 6 /* default lock interface */ #define ZM_LOCK_IF @ZM_LOCK_IF@ #if ZM_LOCK_IF == ZM_TICKET_IF #include /* types */ #define zm_lock_t zm_ticket_t #define zm_lock_ctxt_t int /*dummy*/ #define zm_lock_init(L) zm_ticket_init(L) #define zm_lock_destroy(L) zm_ticket_destroy(L) /* Context-less routines */ #define zm_lock_acquire(L) zm_ticket_acquire(L) #define zm_lock_acquire_l(L) zm_ticket_acquire(L) #define zm_lock_release(L) zm_ticket_release(L) /* Context-full routines */ #define zm_lock_acquire_c(L, ctxt) zm_ticket_acquire(L) #define zm_lock_acquire_lc(L, ctxt) zm_ticket_acquire(L) #define zm_lock_release_c(L, ctxt) zm_ticket_release(L) #elif ZM_LOCK_IF == ZM_MCS_IF #include /* types */ #define zm_lock_t zm_mcs_t #define zm_lock_ctxt_t zm_mcs_qnode_t #define zm_lock_init zm_mcs_init #define zm_lock_destroy(L) zm_mcs_destroy(L) /* Context-less routines */ #define zm_lock_acquire(L) zm_mcs_acquire(*(L)) #define zm_lock_tryacq(L, acq) zm_mcs_tryacq(*(L), acq) #define zm_lock_acquire_l(L) zm_mcs_acquire(*(L)) #define zm_lock_release(L) zm_mcs_release(*(L)) /* Context-full routines */ #define zm_lock_acquire_c(L, ctxt) zm_mcs_acquire_c(*(L), ctxt) #define zm_lock_acquire_lc(L, ctxt) zm_mcs_acquire_c(*(L), ctxt) #define zm_lock_release_c(L, ctxt) zm_mcs_release_c(*(L), ctxt) #elif ZM_LOCK_IF == ZM_HMCS_IF #include /* types */ #define zm_lock_t zm_hmcs_t #define zm_lock_ctxt_t int /*dummy*/ #define zm_lock_init zm_hmcs_init #define zm_lock_destroy zm_hmcs_destroy /* Context-less routines */ #define zm_lock_acquire(L) zm_hmcs_acquire(*(L)) #define zm_lock_tryacq(L, acq) zm_hmcs_tryacq(*(L), acq) #define zm_lock_acquire_l(L) zm_hmcs_acquire(*(L)) #define zm_lock_release(L) zm_hmcs_release(*(L)) /* Context-full routines */ #define zm_lock_acquire_c(L, ctxt) zm_hmcs_acquire(*(L)) #define zm_lock_acquire_lc(L, ctxt) zm_hmcs_acquire(*(L)) #define zm_lock_release_c(L, ctxt) zm_hmcs_release(*(L)) #elif ZM_LOCK_IF == ZM_MMCS_IF #include /* types */ #define zm_lock_t zm_mmcs_t #define zm_lock_ctxt_t zm_mcs_qnode_t #define zm_lock_init zm_mmcs_init #define zm_lock_destroy(L) zm_mmcs_destroy(L) /* Context-full routines */ #define zm_lock_acquire_c(L, ctxt) zm_mmcs_acquire_c(L, ctxt) #define zm_lock_acquire_lc(L, ctxt) zm_mmcs_acquire_c(L, ctxt) #define zm_lock_release_c(L, ctxt) zm_mmcs_release_c(L, ctxt) #elif ZM_LOCK_IF == ZM_TLP_IF #include /* types */ #define zm_lock_t zm_tlp_t #define zm_lock_ctxt_t zm_mcs_qnode_t #define zm_lock_init zm_tlp_init #define zm_lock_destroy(L) zm_tlp_destroy(L) /* Context-less routines */ #define zm_lock_acquire(L) zm_tlp_acquire(L) #define zm_lock_acquire_l(L) zm_tlp_acquire_low(L) #define zm_lock_release(L) zm_tlp_release(L) /* Context-full routines */ #define zm_lock_acquire_c(L, ctxt) zm_tlp_acquire_c(L, ctxt) #define zm_lock_acquire_lc(L, ctxt) zm_tlp_acquire_low_c(L, ctxt) #define zm_lock_release_c(L, ctxt) zm_tlp_release_c(L, ctxt) #elif ZM_LOCK_IF == ZM_MCSP_IF #include /* types */ #define zm_lock_t zm_mcsp_t #define zm_lock_ctxt_t zm_mcs_qnode_t #define zm_lock_init zm_mcsp_init #define zm_lock_destroy(L) zm_mcsp_destroy(L) /* Context-full routines */ #define zm_lock_acquire(L) zm_mcsp_acquire(L) #define zm_lock_acquire_l(L) zm_mcsp_acquire_low(L) #define zm_lock_release(L) zm_mcsp_release(L) /* Context-full routines */ #define zm_lock_acquire_c(L, ctxt) zm_mcsp_acquire_c(L, ctxt) #define zm_lock_acquire_lc(L, ctxt) zm_mcsp_acquire_low_c(L, ctxt) #define zm_lock_release_c(L, ctxt) zm_mcsp_release_c(L, ctxt) #else #error "Wrong lock implementation" #endif /* ZM_LOCK_IF */ #endif /* _IZEM_LOCK_H */