import less(1)
[unleashed/tickless.git] / usr / src / lib / libc / port / sys / lwp_rwlock.c
blob009d88b3f3b05e85d0db7fcb911e79ad430714ce
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include "lint.h"
30 #include <synch.h>
31 #include <time.h>
32 #include <errno.h>
33 #include <sys/syscall.h>
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
41 int
42 __lwp_rwlock_rdlock(rwlock_t *rwl, timespec_t *tsp)
44 sysret_t rval;
45 int error;
47 error = __systemcall(&rval, SYS_lwp_rwlock_sys,
48 SUBSYS_lwp_rwlock_rdlock, rwl, tsp);
49 if (error == ERESTART)
50 error = EINTR;
52 return (error);
55 int
56 __lwp_rwlock_wrlock(rwlock_t *rwl, timespec_t *tsp)
58 sysret_t rval;
59 int error;
61 error = __systemcall(&rval, SYS_lwp_rwlock_sys,
62 SUBSYS_lwp_rwlock_wrlock, rwl, tsp);
63 if (error == ERESTART)
64 error = EINTR;
66 return (error);
69 int
70 __lwp_rwlock_tryrdlock(rwlock_t *rwl)
72 sysret_t rval;
73 int error;
75 error = __systemcall(&rval, SYS_lwp_rwlock_sys,
76 SUBSYS_lwp_rwlock_tryrdlock, rwl);
77 if (error == ERESTART)
78 error = EINTR;
80 return (error);
83 int
84 __lwp_rwlock_trywrlock(rwlock_t *rwl)
86 sysret_t rval;
87 int error;
89 error = __systemcall(&rval, SYS_lwp_rwlock_sys,
90 SUBSYS_lwp_rwlock_trywrlock, rwl);
91 if (error == ERESTART)
92 error = EINTR;
94 return (error);
97 int
98 __lwp_rwlock_unlock(rwlock_t *rwl)
100 sysret_t rval;
101 int error;
103 error = __systemcall(&rval, SYS_lwp_rwlock_sys,
104 SUBSYS_lwp_rwlock_unlock, rwl);
105 if (error == ERESTART)
106 error = EINTR;
108 return (error);