![]() |
|
|||
File indexing completed on 2025-05-11 08:24:21
0001 /*- 0002 * Copyright (c) 2011 Ed Schouten <ed@FreeBSD.org> 0003 * Copyright (c) 2015 embedded brains GmbH & Co. KG 0004 * All rights reserved. 0005 * 0006 * Redistribution and use in source and binary forms, with or without 0007 * modification, are permitted provided that the following conditions 0008 * are met: 0009 * 1. Redistributions of source code must retain the above copyright 0010 * notice, this list of conditions and the following disclaimer. 0011 * 2. Redistributions in binary form must reproduce the above copyright 0012 * notice, this list of conditions and the following disclaimer in the 0013 * documentation and/or other materials provided with the distribution. 0014 * 0015 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 0016 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0017 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 0018 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 0019 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 0020 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 0021 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 0022 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 0023 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 0024 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 0025 * SUCH DAMAGE. 0026 * 0027 * $FreeBSD r279326 2015-02-26T16:39:57Z$ 0028 */ 0029 0030 #include <threads.h> 0031 #include <sys/lock.h> 0032 #include <errno.h> 0033 0034 void 0035 mtx_destroy(mtx_t *mtx) 0036 { 0037 0038 _Mutex_recursive_Destroy(mtx); 0039 } 0040 0041 int 0042 mtx_init(mtx_t *mtx, int type) 0043 { 0044 0045 (void)type; 0046 _Mutex_recursive_Initialize(mtx); 0047 return (thrd_success); 0048 } 0049 0050 int 0051 mtx_lock(mtx_t *mtx) 0052 { 0053 0054 _Mutex_recursive_Acquire(mtx); 0055 return (thrd_success); 0056 } 0057 0058 int 0059 mtx_timedlock(mtx_t *__restrict mtx, const struct timespec *__restrict ts) 0060 { 0061 0062 switch (_Mutex_recursive_Acquire_timed(mtx, ts)) { 0063 case 0: 0064 return (thrd_success); 0065 case ETIMEDOUT: 0066 return (thrd_timedout); 0067 default: 0068 return (thrd_error); 0069 } 0070 } 0071 0072 int 0073 mtx_trylock(mtx_t *mtx) 0074 { 0075 0076 switch (_Mutex_recursive_Try_acquire(mtx)) { 0077 case 0: 0078 return (thrd_success); 0079 default: 0080 return (thrd_busy); 0081 } 0082 } 0083 0084 int 0085 mtx_unlock(mtx_t *mtx) 0086 { 0087 0088 _Mutex_recursive_Release(mtx); 0089 return (thrd_success); 0090 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |