Deleted Added
full compact
lock.h (115080) lock.h (115278)
1/*
2 * Copyright (c) 2001, 2003 Daniel Eischen <deischen@freebsd.org>.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*
2 * Copyright (c) 2001, 2003 Daniel Eischen <deischen@freebsd.org>.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/lib/libkse/sys/lock.h 115080 2003-05-16 19:58:30Z deischen $
26 * $FreeBSD: head/lib/libkse/sys/lock.h 115278 2003-05-24 02:29:25Z deischen $
27 */
28
29#ifndef _LOCK_H_
30#define _LOCK_H_
31
32struct lockreq;
33struct lockuser;
34struct lock;

--- 14 unchanged lines hidden (view full) ---

49 lock_handler_t *l_wakeup; /* only used for adaptive locks */
50};
51
52/* Try to make this >= CACHELINESIZE */
53struct lockreq {
54 volatile long lr_locked; /* lock granted = 0, busy otherwise */
55 struct lockuser *lr_watcher; /* only used for priority locks */
56 struct lockuser *lr_owner; /* only used for priority locks */
27 */
28
29#ifndef _LOCK_H_
30#define _LOCK_H_
31
32struct lockreq;
33struct lockuser;
34struct lock;

--- 14 unchanged lines hidden (view full) ---

49 lock_handler_t *l_wakeup; /* only used for adaptive locks */
50};
51
52/* Try to make this >= CACHELINESIZE */
53struct lockreq {
54 volatile long lr_locked; /* lock granted = 0, busy otherwise */
55 struct lockuser *lr_watcher; /* only used for priority locks */
56 struct lockuser *lr_owner; /* only used for priority locks */
57 long lr_waiting; /* non-zero when wakeup needed */
58 volatile int lr_active; /* non-zero if the lock is last lock for thread */
59};
60
61struct lockuser {
62 struct lockreq *lu_myreq; /* request to give up/trade */
63 struct lockreq *lu_watchreq; /* watch this request */
64 int lu_priority; /* only used for priority locks */
65 void *lu_private1; /* private{1,2} are initialized to */
66 void *lu_private2; /* NULL and can be used by caller */
67#define lu_private lu_private1
68};
69
70#define _LCK_INITIALIZER(lck_req) { &lck_req, NULL, LCK_DEFAULT, \
71 NULL, NULL }
72#define _LCK_REQUEST_INITIALIZER { 0, NULL, NULL, 0 }
73
74#define _LCK_BUSY(lu) ((lu)->lu_watchreq->lr_locked != 0)
75#define _LCK_ACTIVE(lu) ((lu)->lu_watchreq->lr_active != 0)
57 volatile int lr_active; /* non-zero if the lock is last lock for thread */
58};
59
60struct lockuser {
61 struct lockreq *lu_myreq; /* request to give up/trade */
62 struct lockreq *lu_watchreq; /* watch this request */
63 int lu_priority; /* only used for priority locks */
64 void *lu_private1; /* private{1,2} are initialized to */
65 void *lu_private2; /* NULL and can be used by caller */
66#define lu_private lu_private1
67};
68
69#define _LCK_INITIALIZER(lck_req) { &lck_req, NULL, LCK_DEFAULT, \
70 NULL, NULL }
71#define _LCK_REQUEST_INITIALIZER { 0, NULL, NULL, 0 }
72
73#define _LCK_BUSY(lu) ((lu)->lu_watchreq->lr_locked != 0)
74#define _LCK_ACTIVE(lu) ((lu)->lu_watchreq->lr_active != 0)
76#define _LCK_GRANTED(lu) ((lu)->lu_watchreq->lr_locked == 0)
75#define _LCK_GRANTED(lu) ((lu)->lu_watchreq->lr_locked == 3)
77
78#define _LCK_SET_PRIVATE(lu, p) (lu)->lu_private = (void *)(p)
79#define _LCK_GET_PRIVATE(lu) (lu)->lu_private
80#define _LCK_SET_PRIVATE2(lu, p) (lu)->lu_private2 = (void *)(p)
81#define _LCK_GET_PRIVATE2(lu) (lu)->lu_private2
82
83void _lock_destroy(struct lock *);
84int _lock_init(struct lock *, enum lock_type,
85 lock_handler_t *, lock_handler_t *);
86int _lockuser_init(struct lockuser *lu, void *priv);
87void _lockuser_destroy(struct lockuser *lu);
88void _lockuser_setactive(struct lockuser *lu, int active);
89void _lock_acquire(struct lock *, struct lockuser *, int);
90void _lock_release(struct lock *, struct lockuser *);
91void _lock_grant(struct lock *, struct lockuser *);
92
93#endif
76
77#define _LCK_SET_PRIVATE(lu, p) (lu)->lu_private = (void *)(p)
78#define _LCK_GET_PRIVATE(lu) (lu)->lu_private
79#define _LCK_SET_PRIVATE2(lu, p) (lu)->lu_private2 = (void *)(p)
80#define _LCK_GET_PRIVATE2(lu) (lu)->lu_private2
81
82void _lock_destroy(struct lock *);
83int _lock_init(struct lock *, enum lock_type,
84 lock_handler_t *, lock_handler_t *);
85int _lockuser_init(struct lockuser *lu, void *priv);
86void _lockuser_destroy(struct lockuser *lu);
87void _lockuser_setactive(struct lockuser *lu, int active);
88void _lock_acquire(struct lock *, struct lockuser *, int);
89void _lock_release(struct lock *, struct lockuser *);
90void _lock_grant(struct lock *, struct lockuser *);
91
92#endif