1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #pragma ident "%Z%%M% %I% %E% SMI" 28 29 #include "synonyms.h" 30 #include <synch.h> 31 #include <time.h> 32 #include <errno.h> 33 #include <sys/syscall.h> 34 35 #define SUBSYS_lwp_rwlock_rdlock 0 36 #define SUBSYS_lwp_rwlock_wrlock 1 37 #define SUBSYS_lwp_rwlock_tryrdlock 2 38 #define SUBSYS_lwp_rwlock_trywrlock 3 39 #define SUBSYS_lwp_rwlock_unlock 4 40 41 int 42 __lwp_rwlock_rdlock(rwlock_t *rwl, timespec_t *tsp) 43 { 44 if (syscall(SYS_lwp_rwlock_sys, 45 SUBSYS_lwp_rwlock_rdlock, rwl, tsp) == -1) 46 return (errno); 47 return (0); 48 } 49 50 int 51 __lwp_rwlock_wrlock(rwlock_t *rwl, timespec_t *tsp) 52 { 53 if (syscall(SYS_lwp_rwlock_sys, 54 SUBSYS_lwp_rwlock_wrlock, rwl, tsp) == -1) 55 return (errno); 56 return (0); 57 } 58 59 int 60 __lwp_rwlock_tryrdlock(rwlock_t *rwl) 61 { 62 if (syscall(SYS_lwp_rwlock_sys, 63 SUBSYS_lwp_rwlock_tryrdlock, rwl) == -1) 64 return (errno); 65 return (0); 66 } 67 68 int 69 __lwp_rwlock_trywrlock(rwlock_t *rwl) 70 { 71 if (syscall(SYS_lwp_rwlock_sys, 72 SUBSYS_lwp_rwlock_trywrlock, rwl) == -1) 73 return (errno); 74 return (0); 75 } 76 77 int 78 __lwp_rwlock_unlock(rwlock_t *rwl) 79 { 80 if (syscall(SYS_lwp_rwlock_sys, 81 SUBSYS_lwp_rwlock_unlock, rwl) == -1) 82 return (errno); 83 return (0); 84 } 85