xref: /freebsd/lib/libc/gen/_spinlock_stub.c (revision 559a218c9b257775fb249b67945fe4a05b7a6b9f)
1*8a16b7a1SPedro F. Giffuni /*-
2*8a16b7a1SPedro F. Giffuni  * SPDX-License-Identifier: BSD-3-Clause
3*8a16b7a1SPedro F. Giffuni  *
41b5fef40SJohn Birrell  * Copyright (c) 1998 John Birrell <jb@cimlogic.com.au>.
51b5fef40SJohn Birrell  * All rights reserved.
61b5fef40SJohn Birrell  *
71b5fef40SJohn Birrell  * Redistribution and use in source and binary forms, with or without
81b5fef40SJohn Birrell  * modification, are permitted provided that the following conditions
91b5fef40SJohn Birrell  * are met:
101b5fef40SJohn Birrell  * 1. Redistributions of source code must retain the above copyright
111b5fef40SJohn Birrell  *    notice, this list of conditions and the following disclaimer.
121b5fef40SJohn Birrell  * 2. Redistributions in binary form must reproduce the above copyright
131b5fef40SJohn Birrell  *    notice, this list of conditions and the following disclaimer in the
141b5fef40SJohn Birrell  *    documentation and/or other materials provided with the distribution.
157dcf45c0SWarner Losh  * 3. Neither the name of the author nor the names of any co-contributors
161b5fef40SJohn Birrell  *    may be used to endorse or promote products derived from this software
171b5fef40SJohn Birrell  *    without specific prior written permission.
181b5fef40SJohn Birrell  *
191b5fef40SJohn Birrell  * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND
201b5fef40SJohn Birrell  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
211b5fef40SJohn Birrell  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
221b5fef40SJohn Birrell  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
231b5fef40SJohn Birrell  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
241b5fef40SJohn Birrell  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
251b5fef40SJohn Birrell  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
261b5fef40SJohn Birrell  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
271b5fef40SJohn Birrell  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
281b5fef40SJohn Birrell  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
291b5fef40SJohn Birrell  * SUCH DAMAGE.
301b5fef40SJohn Birrell  */
311b5fef40SJohn Birrell 
321b5fef40SJohn Birrell #include <stdio.h>
33f0f62729SJohn Birrell 
341b5fef40SJohn Birrell #include "spinlock.h"
3545468c53SKonstantin Belousov #include "libc_private.h"
361b5fef40SJohn Birrell 
379fd9d097SXin LI long _atomic_lock_stub(volatile long *);
389fd9d097SXin LI void _spinlock_stub(spinlock_t *);
399fd9d097SXin LI void _spinunlock_stub(spinlock_t *);
409fd9d097SXin LI 
4154fd7f68SDaniel Eischen __weak_reference(_atomic_lock_stub, _atomic_lock);
4254fd7f68SDaniel Eischen 
43d201fe46SDaniel Eischen long
_atomic_lock_stub(volatile long * lck __unused)449fd9d097SXin LI _atomic_lock_stub(volatile long *lck __unused)
45d201fe46SDaniel Eischen {
46d201fe46SDaniel Eischen 	return (0L);
47d201fe46SDaniel Eischen }
48d201fe46SDaniel Eischen 
4945468c53SKonstantin Belousov #pragma weak _spinlock
501b5fef40SJohn Birrell void
_spinlock(spinlock_t * lck)5145468c53SKonstantin Belousov _spinlock(spinlock_t *lck)
5245468c53SKonstantin Belousov {
5345468c53SKonstantin Belousov 
5445468c53SKonstantin Belousov 	((void (*)(spinlock_t *lck))__libc_interposing[INTERPOS_spinlock])
5545468c53SKonstantin Belousov 	    (lck);
5645468c53SKonstantin Belousov 
5745468c53SKonstantin Belousov }
5845468c53SKonstantin Belousov 
59eb75dcc0SKonstantin Belousov #pragma weak _spinunlock
6045468c53SKonstantin Belousov void
_spinunlock(spinlock_t * lck)6145468c53SKonstantin Belousov _spinunlock(spinlock_t *lck)
6245468c53SKonstantin Belousov {
6345468c53SKonstantin Belousov 
6445468c53SKonstantin Belousov 	((void (*)(spinlock_t *lck))__libc_interposing[INTERPOS_spinunlock])
6545468c53SKonstantin Belousov 	    (lck);
6645468c53SKonstantin Belousov 
6745468c53SKonstantin Belousov }
6845468c53SKonstantin Belousov 
6945468c53SKonstantin Belousov void
__libc_spinlock_stub(spinlock_t * lck __unused)7045468c53SKonstantin Belousov __libc_spinlock_stub(spinlock_t *lck __unused)
711b5fef40SJohn Birrell {
721b5fef40SJohn Birrell }
731b5fef40SJohn Birrell 
74cc3521d6SJeff Roberson void
__libc_spinunlock_stub(spinlock_t * lck __unused)7545468c53SKonstantin Belousov __libc_spinunlock_stub(spinlock_t *lck __unused)
761b5fef40SJohn Birrell {
771b5fef40SJohn Birrell }
78