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, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2004 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 int rval; 45 46 do { 47 rval = syscall(SYS_lwp_rwlock_sys, 48 SUBSYS_lwp_rwlock_rdlock, rwl, tsp); 49 } while (rval == -1 && errno == EINTR); 50 51 return (rval == -1 ? errno : 0); 52 } 53 54 int 55 __lwp_rwlock_wrlock(rwlock_t *rwl, timespec_t *tsp) 56 { 57 int rval; 58 59 do { 60 rval = syscall(SYS_lwp_rwlock_sys, 61 SUBSYS_lwp_rwlock_wrlock, rwl, tsp); 62 } while (rval == -1 && errno == EINTR); 63 64 return (rval == -1 ? errno : 0); 65 } 66 67 int 68 __lwp_rwlock_tryrdlock(rwlock_t *rwl) 69 { 70 if (syscall(SYS_lwp_rwlock_sys, 71 SUBSYS_lwp_rwlock_tryrdlock, rwl) == -1) 72 return (errno); 73 return (0); 74 } 75 76 int 77 __lwp_rwlock_trywrlock(rwlock_t *rwl) 78 { 79 if (syscall(SYS_lwp_rwlock_sys, 80 SUBSYS_lwp_rwlock_trywrlock, rwl) == -1) 81 return (errno); 82 return (0); 83 } 84 85 int 86 __lwp_rwlock_unlock(rwlock_t *rwl) 87 { 88 if (syscall(SYS_lwp_rwlock_sys, SUBSYS_lwp_rwlock_unlock, rwl) == -1) 89 return (errno); 90 return (0); 91 } 92