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 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 #include "hplib_sync.h"
51 /*--------------------------*/
52 /*----------spinLock--------*/
53 /*--------------------------*/
55 #define NETAPI_spinLock_T hplib_spinLock_T
57 #define NETAPI_spinLock_LOCKVAL hplib_spinLock_LOCKVAL
58 #define NETAPI_spinLock_UNLOCKVAL hplib_spinLock_UNLOCKVAL
59 #define NETAPI_spinLock_UNLOCKED_INITIALIZER (NETAPI_spinLock_UNLOCKVAL)
61 /* init a lock */
62 #define netapi_spinLock_init hplib_mSpinLockInit
64 /* lock a spinLock */
65 #define netapi_spinLock_lock hplib_mSpinLockLock
68 /* try to get lock 1 time. Return 1 if ok, 0 if un-successful */
69 #define netapi_spinLock_try_lock hplib_mSpinLockTryLock
71 /* unlock a spinLock. */
72 #define netapi_spinLock_unlock hplib_mSpinLockUnlock
74 /* poll a lock, return 0 if unlocked, NETAPI_spinLock_LOCKVAL if locked */
75 #define netapi_spinLock_is_locked hplib_mSpinLockIsLocked
78 /*--------------------------*/
79 /*----------rwLock--------*/
80 /*--------------------------*/
82 /* a rw lock strucuture */
83 #define NETAPI_rwLock_T hplib_rwLock_T
85 //initialize a rw lock
86 #define netapi_rwLock_init hplib_mRWLockInit
88 // lock a write lock.
89 #define netapi_rwLock_write_lock hplib_mRWLockWriteLock
92 //unlock a writer part of rwLock */
93 #define netapi_rwLock_write_unlock hplib_mRWLockWriteUnlock
95 //grab a read lock
96 //=> can be other readers, but no writer
97 #define netapi_rwLock_read_lock hplib_mRWLockReadLock
99 //rw_lock reader unlock
100 #define netapi_rwLock_read_unlock hplib_mRWLockReadUnlock
103 /*--------------------------*/
104 /*----------atomic32--------*/
105 /*--------------------------*/
106 #define NETAPI_ATOMIC32_T hplib_atomic32_T
110 #define NETAPI_ATOMIC_INIT32 hplib_mAtomic32Init
112 #define netapi_atomic_read32 hplib_mAtomic32Read
114 #define netapi_atomic_set32 hplib_mAtomic32Set
116 #define netapi_atomic_add32 hplib_mAtomic32Add
118 #define netapi_atomic_sub32 hplib_mAtomic32Sub
120 #define NETAPI_atomic_inc32 hplib_mAtomic32Inc
122 #define NETAPI_atomic_dec32(p) hplib_mAtomic32Dec
124 #define netapi_atomic_add_return32 hplib_mAtomic32AddReturn
126 #define netapi_atomic_sub_return32 hplib_mAtomic32SubReturn
129 #define netapi_atomic_inc_and_test32 hplib_mAtomic32IncAndTest
131 #define netapi_atomic_dec_and_test32 hplib_mAtomic32DecAndTest
133 #define netapi_atomic_test_and_set32 hplib_mAtomic32TestSetReturn
135 #define netapi_atomic_clear32(p) hplib_mAtomic32Clear
137 /*--------------------------*/
138 /*----------atomic64--------*/
139 /*--------------------------*/
140 #define NETAPI_ATOMIC64_T hplib_atomic64_T
143 #define NETAPI_ATOMIC_INIT64(x) hplib_mAtomic64Init
145 #define netapi_atomic_read64 hplib_mAtomic64Read
147 #define netapi_atomic_set64 hplib_mAtomic64Set
149 #define netapi_atomic_add64 hplib_mAtomic64Add
151 /*******************************************************
152 ****************memory barrier************************
153 ******************************************************/
154 #define netapi_mb hplib_mMemBarrier
155 #define netapi_rmb hplib_mReadMemBarrier
156 #define netapi_wmb hplib_mWriteMemBarrier
159 #ifdef __cplusplus
160 }
161 #endif
162 #endif