xref: /f-stack/tools/compat/include/sys/_mutex.h (revision 2317ada5)
11eaf0ac3Slogwang /*
21eaf0ac3Slogwang  * Copyright (c) 2010 Kip Macy All rights reserved.
31eaf0ac3Slogwang  * Copyright (c) 2013 Patrick Kelsey. All rights reserved.
4*2317ada5Sfengbojiang  * Copyright (C) 2017-2021 THL A29 Limited, a Tencent company.
51eaf0ac3Slogwang  * All rights reserved.
61eaf0ac3Slogwang  *
71eaf0ac3Slogwang  * Redistribution and use in source and binary forms, with or without
81eaf0ac3Slogwang  * modification, are permitted provided that the following conditions are met:
91eaf0ac3Slogwang  *
101eaf0ac3Slogwang  * 1. Redistributions of source code must retain the above copyright notice, this
111eaf0ac3Slogwang  *   list of conditions and the following disclaimer.
121eaf0ac3Slogwang  * 2. Redistributions in binary form must reproduce the above copyright notice,
131eaf0ac3Slogwang  *   this list of conditions and the following disclaimer in the documentation
141eaf0ac3Slogwang  *   and/or other materials provided with the distribution.
151eaf0ac3Slogwang  *
161eaf0ac3Slogwang  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
171eaf0ac3Slogwang  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
181eaf0ac3Slogwang  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
191eaf0ac3Slogwang  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
201eaf0ac3Slogwang  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
211eaf0ac3Slogwang  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
221eaf0ac3Slogwang  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
231eaf0ac3Slogwang  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
241eaf0ac3Slogwang  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
251eaf0ac3Slogwang  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
261eaf0ac3Slogwang  *
271eaf0ac3Slogwang  */
281eaf0ac3Slogwang 
291eaf0ac3Slogwang #ifndef _SYS__MUTEX_H_
301eaf0ac3Slogwang #define _SYS__MUTEX_H_
311eaf0ac3Slogwang 
321eaf0ac3Slogwang /*
331eaf0ac3Slogwang  * Sleep/spin mutex
341eaf0ac3Slogwang  */
351eaf0ac3Slogwang struct mtx {
361eaf0ac3Slogwang     struct lock_object lock_object;
371eaf0ac3Slogwang     void* mtx_lock;
381eaf0ac3Slogwang };
391eaf0ac3Slogwang 
401eaf0ac3Slogwang /*
411eaf0ac3Slogwang  * Members of struct mtx_padalign must mirror members of struct mtx.
421eaf0ac3Slogwang  * mtx_padalign mutexes can use the mtx(9) API transparently without
431eaf0ac3Slogwang  * modification.
441eaf0ac3Slogwang  */
451eaf0ac3Slogwang struct mtx_padalign {
461eaf0ac3Slogwang     struct lock_object    lock_object;
471eaf0ac3Slogwang     void*    mtx_lock;
481eaf0ac3Slogwang } __attribute__((__aligned__(64)));
491eaf0ac3Slogwang 
501eaf0ac3Slogwang #endif
51