xref: /freebsd/lib/libc/gen/_spinlock_stub.c (revision 8a16b7a18f5d0b031f09832fd7752fba717e2a97)
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 
32ea8d448aSDavid E. O'Brien #include <sys/cdefs.h>
33ea8d448aSDavid E. O'Brien __FBSDID("$FreeBSD$");
34ea8d448aSDavid E. O'Brien 
351b5fef40SJohn Birrell #include <stdio.h>
36f0f62729SJohn Birrell 
371b5fef40SJohn Birrell #include "spinlock.h"
3845468c53SKonstantin Belousov #include "libc_private.h"
391b5fef40SJohn Birrell 
409fd9d097SXin LI long _atomic_lock_stub(volatile long *);
419fd9d097SXin LI void _spinlock_stub(spinlock_t *);
429fd9d097SXin LI void _spinunlock_stub(spinlock_t *);
439fd9d097SXin LI 
4454fd7f68SDaniel Eischen __weak_reference(_atomic_lock_stub, _atomic_lock);
4554fd7f68SDaniel Eischen 
46d201fe46SDaniel Eischen long
479fd9d097SXin LI _atomic_lock_stub(volatile long *lck __unused)
48d201fe46SDaniel Eischen {
49d201fe46SDaniel Eischen 	return (0L);
50d201fe46SDaniel Eischen }
51d201fe46SDaniel Eischen 
5245468c53SKonstantin Belousov #pragma weak _spinlock
531b5fef40SJohn Birrell void
5445468c53SKonstantin Belousov _spinlock(spinlock_t *lck)
5545468c53SKonstantin Belousov {
5645468c53SKonstantin Belousov 
5745468c53SKonstantin Belousov 	((void (*)(spinlock_t *lck))__libc_interposing[INTERPOS_spinlock])
5845468c53SKonstantin Belousov 	    (lck);
5945468c53SKonstantin Belousov 
6045468c53SKonstantin Belousov }
6145468c53SKonstantin Belousov 
62eb75dcc0SKonstantin Belousov #pragma weak _spinunlock
6345468c53SKonstantin Belousov void
6445468c53SKonstantin Belousov _spinunlock(spinlock_t *lck)
6545468c53SKonstantin Belousov {
6645468c53SKonstantin Belousov 
6745468c53SKonstantin Belousov 	((void (*)(spinlock_t *lck))__libc_interposing[INTERPOS_spinunlock])
6845468c53SKonstantin Belousov 	    (lck);
6945468c53SKonstantin Belousov 
7045468c53SKonstantin Belousov }
7145468c53SKonstantin Belousov 
7245468c53SKonstantin Belousov void
7345468c53SKonstantin Belousov __libc_spinlock_stub(spinlock_t *lck __unused)
741b5fef40SJohn Birrell {
751b5fef40SJohn Birrell }
761b5fef40SJohn Birrell 
77cc3521d6SJeff Roberson void
7845468c53SKonstantin Belousov __libc_spinunlock_stub(spinlock_t *lck __unused)
791b5fef40SJohn Birrell {
801b5fef40SJohn Birrell }
81