1/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ 2/* 3 * See COPYRIGHT in top-level directory. 4 */ 5 6#ifndef _ZM_LOCK_H 7#define _ZM_LOCK_H 8 9#define ZM_TICKET_IF 1 10#define ZM_MCS_IF 2 11#define ZM_MMCS_IF 3 12#define ZM_HMCS_IF 4 13#define ZM_MCSP_IF 5 14#define ZM_TLP_IF 6 15 16/* default lock interface */ 17#define ZM_LOCK_IF @ZM_LOCK_IF@ 18 19#if ZM_LOCK_IF == ZM_TICKET_IF 20 21#include <lock/zm_ticket.h> 22/* types */ 23#define zm_lock_t zm_ticket_t 24#define zm_lock_ctxt_t int /*dummy*/ 25#define zm_lock_init(L) zm_ticket_init(L) 26#define zm_lock_destroy(L) zm_ticket_destroy(L) 27/* Context-less routines */ 28#define zm_lock_acquire(L) zm_ticket_acquire(L) 29#define zm_lock_acquire_l(L) zm_ticket_acquire(L) 30#define zm_lock_release(L) zm_ticket_release(L) 31/* Context-full routines */ 32#define zm_lock_acquire_c(L, ctxt) zm_ticket_acquire(L) 33#define zm_lock_acquire_lc(L, ctxt) zm_ticket_acquire(L) 34#define zm_lock_release_c(L, ctxt) zm_ticket_release(L) 35 36#elif ZM_LOCK_IF == ZM_MCS_IF 37#include <lock/zm_mcs.h> 38/* types */ 39#define zm_lock_t zm_mcs_t 40#define zm_lock_ctxt_t zm_mcs_qnode_t 41#define zm_lock_init zm_mcs_init 42#define zm_lock_destroy(L) zm_mcs_destroy(L) 43/* Context-less routines */ 44#define zm_lock_acquire(L) zm_mcs_acquire(*(L)) 45#define zm_lock_tryacq(L, acq) zm_mcs_tryacq(*(L), acq) 46#define zm_lock_acquire_l(L) zm_mcs_acquire(*(L)) 47#define zm_lock_release(L) zm_mcs_release(*(L)) 48/* Context-full routines */ 49#define zm_lock_acquire_c(L, ctxt) zm_mcs_acquire_c(*(L), ctxt) 50#define zm_lock_acquire_lc(L, ctxt) zm_mcs_acquire_c(*(L), ctxt) 51#define zm_lock_release_c(L, ctxt) zm_mcs_release_c(*(L), ctxt) 52 53#elif ZM_LOCK_IF == ZM_HMCS_IF 54 55#include <lock/zm_hmcs.h> 56/* types */ 57#define zm_lock_t zm_hmcs_t 58#define zm_lock_ctxt_t int /*dummy*/ 59#define zm_lock_init zm_hmcs_init 60#define zm_lock_destroy zm_hmcs_destroy 61/* Context-less routines */ 62#define zm_lock_acquire(L) zm_hmcs_acquire(*(L)) 63#define zm_lock_tryacq(L, acq) zm_hmcs_tryacq(*(L), acq) 64#define zm_lock_acquire_l(L) zm_hmcs_acquire(*(L)) 65#define zm_lock_release(L) zm_hmcs_release(*(L)) 66/* Context-full routines */ 67#define zm_lock_acquire_c(L, ctxt) zm_hmcs_acquire(*(L)) 68#define zm_lock_acquire_lc(L, ctxt) zm_hmcs_acquire(*(L)) 69#define zm_lock_release_c(L, ctxt) zm_hmcs_release(*(L)) 70 71#elif ZM_LOCK_IF == ZM_MMCS_IF 72 73#include <lock/zm_mmcs.h> 74/* types */ 75#define zm_lock_t zm_mmcs_t 76#define zm_lock_ctxt_t zm_mcs_qnode_t 77#define zm_lock_init zm_mmcs_init 78#define zm_lock_destroy(L) zm_mmcs_destroy(L) 79/* Context-full routines */ 80#define zm_lock_acquire_c(L, ctxt) zm_mmcs_acquire_c(L, ctxt) 81#define zm_lock_acquire_lc(L, ctxt) zm_mmcs_acquire_c(L, ctxt) 82#define zm_lock_release_c(L, ctxt) zm_mmcs_release_c(L, ctxt) 83 84#elif ZM_LOCK_IF == ZM_TLP_IF 85 86#include <lock/zm_tlp.h> 87/* types */ 88#define zm_lock_t zm_tlp_t 89#define zm_lock_ctxt_t zm_mcs_qnode_t 90#define zm_lock_init zm_tlp_init 91#define zm_lock_destroy(L) zm_tlp_destroy(L) 92/* Context-less routines */ 93#define zm_lock_acquire(L) zm_tlp_acquire(L) 94#define zm_lock_acquire_l(L) zm_tlp_acquire_low(L) 95#define zm_lock_release(L) zm_tlp_release(L) 96/* Context-full routines */ 97#define zm_lock_acquire_c(L, ctxt) zm_tlp_acquire_c(L, ctxt) 98#define zm_lock_acquire_lc(L, ctxt) zm_tlp_acquire_low_c(L, ctxt) 99#define zm_lock_release_c(L, ctxt) zm_tlp_release_c(L, ctxt) 100 101#elif ZM_LOCK_IF == ZM_MCSP_IF 102 103#include <lock/zm_mcsp.h> 104/* types */ 105#define zm_lock_t zm_mcsp_t 106#define zm_lock_ctxt_t zm_mcs_qnode_t 107#define zm_lock_init zm_mcsp_init 108#define zm_lock_destroy(L) zm_mcsp_destroy(L) 109/* Context-full routines */ 110#define zm_lock_acquire(L) zm_mcsp_acquire(L) 111#define zm_lock_acquire_l(L) zm_mcsp_acquire_low(L) 112#define zm_lock_release(L) zm_mcsp_release(L) 113/* Context-full routines */ 114#define zm_lock_acquire_c(L, ctxt) zm_mcsp_acquire_c(L, ctxt) 115#define zm_lock_acquire_lc(L, ctxt) zm_mcsp_acquire_low_c(L, ctxt) 116#define zm_lock_release_c(L, ctxt) zm_mcsp_release_c(L, ctxt) 117 118#else 119 120#error "Wrong lock implementation" 121 122#endif /* ZM_LOCK_IF */ 123 124 125#endif /* _IZEM_LOCK_H */ 126