Deleted Added
full compact
mutex.h (225736) mutex.h (230799)
1/*-
2 * Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.

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

21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
28 * from BSDI $Id: mutex.h,v 2.7.2.35 2000/04/27 03:10:26 cp Exp $
1/*-
2 * Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.

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

21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
28 * from BSDI $Id: mutex.h,v 2.7.2.35 2000/04/27 03:10:26 cp Exp $
29 * $FreeBSD: stable/9/sys/sys/mutex.h 218673 2011-02-14 02:37:27Z alc $
29 * $FreeBSD: stable/9/sys/sys/mutex.h 230799 2012-01-31 01:45:20Z attilio $
30 */
31
32#ifndef _SYS_MUTEX_H_
33#define _SYS_MUTEX_H_
34
35#include <sys/queue.h>
36#include <sys/_lock.h>
37#include <sys/_mutex.h>

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

76
77/*
78 * Prototypes
79 *
80 * NOTE: Functions prepended with `_' (underscore) are exported to other parts
81 * of the kernel via macros, thus allowing us to use the cpp LOCK_FILE
82 * and LOCK_LINE. These functions should not be called directly by any
83 * code using the API. Their macros cover their functionality.
30 */
31
32#ifndef _SYS_MUTEX_H_
33#define _SYS_MUTEX_H_
34
35#include <sys/queue.h>
36#include <sys/_lock.h>
37#include <sys/_mutex.h>

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

76
77/*
78 * Prototypes
79 *
80 * NOTE: Functions prepended with `_' (underscore) are exported to other parts
81 * of the kernel via macros, thus allowing us to use the cpp LOCK_FILE
82 * and LOCK_LINE. These functions should not be called directly by any
83 * code using the API. Their macros cover their functionality.
84 * Functions with a `_' suffix are the entrypoint for the common
85 * KPI covering both compat shims and fast path case. These can be
86 * used by consumers willing to pass options, file and line
87 * informations, in an option-independent way.
84 *
85 * [See below for descriptions]
86 *
87 */
88void mtx_init(struct mtx *m, const char *name, const char *type, int opts);
89void mtx_destroy(struct mtx *m);
90void mtx_sysinit(void *arg);
91void mutex_init(void);

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

104 int line);
105void _mtx_unlock_spin_flags(struct mtx *m, int opts, const char *file,
106 int line);
107#if defined(INVARIANTS) || defined(INVARIANT_SUPPORT)
108void _mtx_assert(struct mtx *m, int what, const char *file, int line);
109#endif
110void _thread_lock_flags(struct thread *, int, const char *, int);
111
88 *
89 * [See below for descriptions]
90 *
91 */
92void mtx_init(struct mtx *m, const char *name, const char *type, int opts);
93void mtx_destroy(struct mtx *m);
94void mtx_sysinit(void *arg);
95void mutex_init(void);

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

108 int line);
109void _mtx_unlock_spin_flags(struct mtx *m, int opts, const char *file,
110 int line);
111#if defined(INVARIANTS) || defined(INVARIANT_SUPPORT)
112void _mtx_assert(struct mtx *m, int what, const char *file, int line);
113#endif
114void _thread_lock_flags(struct thread *, int, const char *, int);
115
116#define mtx_trylock_flags_(m, opts, file, line) \
117 _mtx_trylock((m), (opts), (file), (line))
118
119#define thread_lock_flags_(tdp, opts, file, line) \
120 _thread_lock_flags((tdp), (opts), (file), (line))
112#define thread_lock(tdp) \
113 _thread_lock_flags((tdp), 0, __FILE__, __LINE__)
114#define thread_lock_flags(tdp, opt) \
115 _thread_lock_flags((tdp), (opt), __FILE__, __LINE__)
116#define thread_unlock(tdp) \
117 mtx_unlock_spin((tdp)->td_lock)
118
119#define mtx_recurse lock_object.lo_data

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

285 */
286extern struct mtx_pool *mtxpool_lockbuilder;
287extern struct mtx_pool *mtxpool_sleep;
288
289#ifndef LOCK_DEBUG
290#error LOCK_DEBUG not defined, include <sys/lock.h> before <sys/mutex.h>
291#endif
292#if LOCK_DEBUG > 0 || defined(MUTEX_NOINLINE)
121#define thread_lock(tdp) \
122 _thread_lock_flags((tdp), 0, __FILE__, __LINE__)
123#define thread_lock_flags(tdp, opt) \
124 _thread_lock_flags((tdp), (opt), __FILE__, __LINE__)
125#define thread_unlock(tdp) \
126 mtx_unlock_spin((tdp)->td_lock)
127
128#define mtx_recurse lock_object.lo_data

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

294 */
295extern struct mtx_pool *mtxpool_lockbuilder;
296extern struct mtx_pool *mtxpool_sleep;
297
298#ifndef LOCK_DEBUG
299#error LOCK_DEBUG not defined, include <sys/lock.h> before <sys/mutex.h>
300#endif
301#if LOCK_DEBUG > 0 || defined(MUTEX_NOINLINE)
293#define mtx_lock_flags(m, opts) \
294 _mtx_lock_flags((m), (opts), LOCK_FILE, LOCK_LINE)
295#define mtx_unlock_flags(m, opts) \
296 _mtx_unlock_flags((m), (opts), LOCK_FILE, LOCK_LINE)
297#define mtx_lock_spin_flags(m, opts) \
298 _mtx_lock_spin_flags((m), (opts), LOCK_FILE, LOCK_LINE)
299#define mtx_unlock_spin_flags(m, opts) \
300 _mtx_unlock_spin_flags((m), (opts), LOCK_FILE, LOCK_LINE)
302#define mtx_lock_flags_(m, opts, file, line) \
303 _mtx_lock_flags((m), (opts), (file), (line))
304#define mtx_unlock_flags_(m, opts, file, line) \
305 _mtx_unlock_flags((m), (opts), (file), (line))
306#define mtx_lock_spin_flags_(m, opts, file, line) \
307 _mtx_lock_spin_flags((m), (opts), (file), (line))
308#define mtx_unlock_spin_flags_(m, opts, file, line) \
309 _mtx_unlock_spin_flags((m), (opts), (file), (line))
301#else /* LOCK_DEBUG == 0 && !MUTEX_NOINLINE */
310#else /* LOCK_DEBUG == 0 && !MUTEX_NOINLINE */
311#define mtx_lock_flags_(m, opts, file, line) \
312 __mtx_lock((m), curthread, (opts), (file), (line))
313#define mtx_unlock_flags_(m, opts, file, line) \
314 __mtx_unlock((m), curthread, (opts), (file), (line))
315#define mtx_lock_spin_flags_(m, opts, file, line) \
316 __mtx_lock_spin((m), curthread, (opts), (file), (line))
317#define mtx_unlock_spin_flags_(m, opts, file, line) \
318 __mtx_unlock_spin((m))
319#endif /* LOCK_DEBUG > 0 || MUTEX_NOINLINE */
320
321#ifdef INVARIANTS
322#define mtx_assert_(m, what, file, line) \
323 _mtx_assert((m), (what), (file), (line))
324
325#define GIANT_REQUIRED mtx_assert_(&Giant, MA_OWNED, __FILE__, __LINE__)
326
327#else /* INVARIANTS */
328#define mtx_assert_(m, what, file, line) (void)0
329#define GIANT_REQUIRED
330#endif /* INVARIANTS */
331
302#define mtx_lock_flags(m, opts) \
332#define mtx_lock_flags(m, opts) \
303 __mtx_lock((m), curthread, (opts), LOCK_FILE, LOCK_LINE)
333 mtx_lock_flags_((m), (opts), LOCK_FILE, LOCK_LINE)
304#define mtx_unlock_flags(m, opts) \
334#define mtx_unlock_flags(m, opts) \
305 __mtx_unlock((m), curthread, (opts), LOCK_FILE, LOCK_LINE)
335 mtx_unlock_flags_((m), (opts), LOCK_FILE, LOCK_LINE)
306#define mtx_lock_spin_flags(m, opts) \
336#define mtx_lock_spin_flags(m, opts) \
307 __mtx_lock_spin((m), curthread, (opts), LOCK_FILE, LOCK_LINE)
337 mtx_lock_spin_flags_((m), (opts), LOCK_FILE, LOCK_LINE)
308#define mtx_unlock_spin_flags(m, opts) \
338#define mtx_unlock_spin_flags(m, opts) \
309 __mtx_unlock_spin((m))
310#endif /* LOCK_DEBUG > 0 || MUTEX_NOINLINE */
311
339 mtx_unlock_spin_flags_((m), (opts), LOCK_FILE, LOCK_LINE)
312#define mtx_trylock_flags(m, opts) \
340#define mtx_trylock_flags(m, opts) \
313 _mtx_trylock((m), (opts), LOCK_FILE, LOCK_LINE)
341 mtx_trylock_flags_((m), (opts), LOCK_FILE, LOCK_LINE)
342#define mtx_assert(m, what) \
343 mtx_assert_((m), (what), __FILE__, __LINE__)
314
315#define mtx_sleep(chan, mtx, pri, wmesg, timo) \
316 _sleep((chan), &(mtx)->lock_object, (pri), (wmesg), (timo))
317
318#define mtx_initialized(m) lock_initalized(&(m)->lock_object)
319
320#define mtx_owned(m) (((m)->mtx_lock & ~MTX_FLAGMASK) == (uintptr_t)curthread)
321

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

393 */
394#if defined(INVARIANTS) || defined(INVARIANT_SUPPORT)
395#define MA_OWNED LA_XLOCKED
396#define MA_NOTOWNED LA_UNLOCKED
397#define MA_RECURSED LA_RECURSED
398#define MA_NOTRECURSED LA_NOTRECURSED
399#endif
400
344
345#define mtx_sleep(chan, mtx, pri, wmesg, timo) \
346 _sleep((chan), &(mtx)->lock_object, (pri), (wmesg), (timo))
347
348#define mtx_initialized(m) lock_initalized(&(m)->lock_object)
349
350#define mtx_owned(m) (((m)->mtx_lock & ~MTX_FLAGMASK) == (uintptr_t)curthread)
351

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

423 */
424#if defined(INVARIANTS) || defined(INVARIANT_SUPPORT)
425#define MA_OWNED LA_XLOCKED
426#define MA_NOTOWNED LA_UNLOCKED
427#define MA_RECURSED LA_RECURSED
428#define MA_NOTRECURSED LA_NOTRECURSED
429#endif
430
401#ifdef INVARIANTS
402#define mtx_assert(m, what) \
403 _mtx_assert((m), (what), __FILE__, __LINE__)
404
405#define GIANT_REQUIRED mtx_assert(&Giant, MA_OWNED)
406
407#else /* INVARIANTS */
408#define mtx_assert(m, what) (void)0
409#define GIANT_REQUIRED
410#endif /* INVARIANTS */
411
412/*
413 * Common lock type names.
414 */
415#define MTX_NETWORK_LOCK "network driver"
416
417#endif /* _KERNEL */
418#endif /* _SYS_MUTEX_H_ */
431/*
432 * Common lock type names.
433 */
434#define MTX_NETWORK_LOCK "network driver"
435
436#endif /* _KERNEL */
437#endif /* _SYS_MUTEX_H_ */