1 /*********************************************
2 * File: netsync.h
3 * Purpose: NETAPI Synchronization primitives
4 **************************************************************
5 * FILE: netsync.h
6 *
7 * DESCRIPTION: netapi synch utilities header file for user space transport
8 * library
9 *
10 * REVISION HISTORY:
11 *
12 * Copyright (c) Texas Instruments Incorporated 2013
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 *
18 * Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 *
21 * Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the
24 * distribution.
25 *
26 * Neither the name of Texas Instruments Incorporated nor the names of
27 * its contributors may be used to endorse or promote products derived
28 * from this software without specific prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 **********************************************/
43 #ifndef NETAPI_SYNC_H
44 #define NETAPI_SYNCH_H
46 #include "hplib_sync.h"
48 /*--------------------------*/
49 /*----------spinLock--------*/
50 /*--------------------------*/
52 #define NETAPI_spinLock_T hplib_spinLock_T
54 #define NETAPI_spinLock_LOCKVAL hplib_spinLock_LOCKVAL
55 #define NETAPI_spinLock_UNLOCKVAL hplib_spinLock_UNLOCKVAL
56 #define NETAPI_spinLock_UNLOCKED_INITIALIZER (NETAPI_spinLock_UNLOCKVAL)
58 /* init a lock */
59 #define netapi_spinLock_init hplib_mSpinLockInit
61 /* lock a spinLock */
62 #define netapi_spinLock_lock hplib_mSpinLockLock
65 /* try to get lock 1 time. Return 1 if ok, 0 if un-successful */
66 #define netapi_spinLock_try_lock hplib_mSpinLockTryLock
68 /* unlock a spinLock. */
69 #define netapi_spinLock_unlock hplib_mSpinLockUnlock
71 /* poll a lock, return 0 if unlocked, NETAPI_spinLock_LOCKVAL if locked */
72 #define netapi_spinLock_is_locked hplib_mSpinLockIsLocked
75 /*--------------------------*/
76 /*----------rwLock--------*/
77 /*--------------------------*/
79 /* a rw lock strucuture */
80 #define NETAPI_rwLock_T hplib_rwLock_T
82 //initialize a rw lock
83 #define netapi_rwLock_init hplib_mRWLockInit
85 // lock a write lock.
86 #define netapi_rwLock_write_lock hplib_mRWLockWriteLock
89 //unlock a writer part of rwLock */
90 #define netapi_rwLock_write_unlock hplib_mRWLockWriteUnlock
92 //grab a read lock
93 //=> can be other readers, but no writer
94 #define netapi_rwLock_read_lock hplib_mRWLockReadLock
96 //rw_lock reader unlock
97 #define netapi_rwLock_read_unlock hplib_mRWLockReadUnlock
100 /*--------------------------*/
101 /*----------atomic32--------*/
102 /*--------------------------*/
103 #define NETAPI_ATOMIC32_T hplib_atomic32_T
107 #define NETAPI_ATOMIC_INIT32 hplib_mAtomic32Init
109 #define netapi_atomic_read32 hplib_mAtomic32Read
111 #define netapi_atomic_set32 hplib_mAtomic32Set
113 #define netapi_atomic_add32 hplib_mAtomic32Add
115 #define netapi_atomic_sub32 hplib_mAtomic32Sub
117 #define NETAPI_atomic_inc32 hplib_mAtomic32Inc
119 #define NETAPI_atomic_dec32(p) hplib_mAtomic32Dec
121 #define netapi_atomic_add_return32 hplib_mAtomic32AddReturn
123 #define netapi_atomic_sub_return32 hplib_mAtomic32SubReturn
126 #define netapi_atomic_inc_and_test32 hplib_mAtomic32IncAndTest
128 #define netapi_atomic_dec_and_test32 hplib_mAtomic32DecAndTest
130 #define netapi_atomic_test_and_set32 hplib_mAtomic32TestSetReturn
132 #define netapi_atomic_clear32(p) hplib_mAtomic32Clear
134 /*--------------------------*/
135 /*----------atomic64--------*/
136 /*--------------------------*/
137 #define NETAPI_ATOMIC64_T hplib_atomic64_T
140 #define NETAPI_ATOMIC_INIT64(x) hplib_mAtomic64Init
142 #define netapi_atomic_read64 hplib_mAtomic64Read
144 #define netapi_atomic_set64 hplib_mAtomic64Set
146 #define netapi_atomic_add64 hplib_mAtomic64Add
148 /*******************************************************
149 ****************memory barrier************************
150 ******************************************************/
151 #define netapi_mb hplib_mMemBarrier
152 #define netapi_rmb hplib_mReadMemBarrier
153 #define netapi_wmb hplib_mWriteMemBarrier
156 #endif