refactored some code. compiles now without suppresing any warning with gcc-6.3.0.
[AROS.git] / rom / kernel / spinlock.c
blob0450429f546e339e6eefa98cc8a17dd10c265fe5
1 /*
2 Copyright © 2015-2017, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 */
8 #include <aros/types/spinlock_s.h>
9 #include <aros/kernel.h>
10 #include <aros/libcall.h>
11 #include <utility/hooks.h>
13 #include <kernel_base.h>
15 /*****************************************************************************
17 NAME */
18 #include <proto/kernel.h>
20 AROS_LH3(spinlock_t *, KrnSpinLock,
22 /* SYNOPSIS */
23 AROS_LHA(spinlock_t *, lock, A1),
24 AROS_LHA(struct Hook *, failhook, A0),
25 AROS_LHA(ULONG, mode, D0),
27 /* LOCATION */
28 struct KernelBase *, KernelBase, 52, Kernel)
30 /* FUNCTION
32 INPUTS
33 lock - spinlock to lock
34 failhook - called if the lock is already held
35 mode - type of lock to obtain.
37 RESULT
38 returns a pointer to the spinlock "handle".
40 NOTES
41 The failhook is necessary, because it is not safe
42 for code running in user space to spin on a shared lock.
43 If a lower priority task holds the lock, it will never be released.
44 Because of this, Exec uses a hook that puts the task on
45 a spinning list, to allow other code to run until the lock is
46 released. At this point the "spinning" task will wake and
47 obtain the lock.
49 EXAMPLE
51 BUGS
53 SEE ALSO
55 INTERNALS
57 ******************************************************************************/
59 AROS_LIBFUNC_INIT
61 /* The implementation of this function is architecture-specific */
62 return lock;
64 AROS_LIBFUNC_EXIT