1 /* 2 * Copyright (C) 2017 THL A29 Limited, a Tencent company. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright notice, this 9 * list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright notice, 11 * this list of conditions and the following disclaimer in the documentation 12 * and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 18 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * 25 */ 26 27 #ifndef _FSTACK_SYS_MUTEX_H_ 28 #define _FSTACK_SYS_MUTEX_H_ 29 #include_next <sys/mutex.h> 30 31 #undef __mtx_lock 32 #undef __mtx_unlock 33 #undef __mtx_lock_spin 34 #undef __mtx_unlock_spin 35 36 #undef _mtx_lock_flags 37 #undef _mtx_unlock_flags 38 #undef _mtx_lock_spin_flags 39 #undef _mtx_unlock_spin_flags 40 41 #undef thread_lock_flags_ 42 #undef thread_lock 43 #undef thread_lock_flags 44 #undef thread_unlock 45 46 #undef mtx_trylock_flags_ 47 #undef _mtx_trylock_spin_flags 48 #undef __mtx_trylock_spin 49 50 #undef mtx_init 51 #undef mtx_destroy 52 #undef mtx_owned 53 54 #define DO_NOTHING do {} while(0) 55 56 #define __mtx_lock(mp, tid, opts, file, line) DO_NOTHING 57 #define __mtx_unlock(mp, tid, opts, file, line) DO_NOTHING 58 #define __mtx_lock_spin(mp, tid, opts, file, line) DO_NOTHING 59 #define __mtx_unlock_spin(mp) DO_NOTHING 60 61 #define _mtx_lock_flags(m, opts, file, line) DO_NOTHING 62 #define _mtx_unlock_flags(m, opts, file, line) DO_NOTHING 63 #define _mtx_lock_spin_flags(m, opts, file, line) DO_NOTHING 64 #define _mtx_unlock_spin_flags(m, opts, file, line) DO_NOTHING 65 66 #define thread_lock_flags_(tdp, opts, file, line) DO_NOTHING 67 #define thread_lock(tdp) DO_NOTHING 68 #define thread_lock_flags(tdp, opt) DO_NOTHING 69 #define thread_unlock(tdp) DO_NOTHING 70 71 #define mtx_trylock_flags_(m, o, f, l) 1 72 #define _mtx_trylock_spin_flags(m, o, f, l) 1 73 #define __mtx_trylock_spin(m, t, o, f, l) 1 74 75 void ff_mtx_init(struct lock_object *lo, const char *name, const char *type, int opts); 76 77 #define mtx_init(m, n, t, o) \ 78 ff_mtx_init(&(m)->lock_object, n, t, o) 79 80 #define mtx_destroy(m) DO_NOTHING 81 82 #define mtx_owned(m) (1) 83 84 #endif /* _FSTACK_SYS_MUTEX_H_ */ 85