xref: /netbsd-src/lib/libpthread/arch/sparc/pthread_md.h (revision c5d359be42eb19abf2d53efc7f682499ff4507f6)
1*c5d359beSchristos /*	$NetBSD: pthread_md.h,v 1.8 2011/01/25 19:12:06 christos Exp $	*/
2c62a74e6Sthorpej 
3c62a74e6Sthorpej /*-
4c62a74e6Sthorpej  * Copyright (c) 2002 The NetBSD Foundation, Inc.
5c62a74e6Sthorpej  * All rights reserved.
6c62a74e6Sthorpej  *
7c62a74e6Sthorpej  * Redistribution and use in source and binary forms, with or without
8c62a74e6Sthorpej  * modification, are permitted provided that the following conditions
9c62a74e6Sthorpej  * are met:
10c62a74e6Sthorpej  * 1. Redistributions of source code must retain the above copyright
11c62a74e6Sthorpej  *    notice, this list of conditions and the following disclaimer.
12c62a74e6Sthorpej  * 2. Redistributions in binary form must reproduce the above copyright
13c62a74e6Sthorpej  *    notice, this list of conditions and the following disclaimer in the
14c62a74e6Sthorpej  *    documentation and/or other materials provided with the distribution.
15c62a74e6Sthorpej  *
16c62a74e6Sthorpej  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17c62a74e6Sthorpej  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18c62a74e6Sthorpej  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19c62a74e6Sthorpej  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20c62a74e6Sthorpej  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21c62a74e6Sthorpej  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22c62a74e6Sthorpej  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23c62a74e6Sthorpej  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24c62a74e6Sthorpej  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25c62a74e6Sthorpej  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26c62a74e6Sthorpej  * POSSIBILITY OF SUCH DAMAGE.
27c62a74e6Sthorpej  */
28c62a74e6Sthorpej 
29c62a74e6Sthorpej #ifndef _LIB_PTHREAD_SPARC_MD_H
30c62a74e6Sthorpej #define _LIB_PTHREAD_SPARC_MD_H
31c62a74e6Sthorpej 
32c62a74e6Sthorpej /*
33c62a74e6Sthorpej  * pthread__sp used for identifying thread
34c62a74e6Sthorpej  */
35*c5d359beSchristos static inline unsigned long
pthread__sp(void)36c62a74e6Sthorpej pthread__sp(void)
37c62a74e6Sthorpej {
38*c5d359beSchristos 	unsigned long ret;
39c62a74e6Sthorpej 
40c62a74e6Sthorpej 	__asm("mov %%sp, %0" : "=r" (ret));
41c62a74e6Sthorpej 
42c62a74e6Sthorpej 	return ret;
43c62a74e6Sthorpej }
44c62a74e6Sthorpej 
45c62a74e6Sthorpej #define pthread__uc_sp(ucp) ((ucp)->uc_mcontext.__gregs[_REG_O6])
46c62a74e6Sthorpej 
47a67e1e34Sad /* Don't need additional memory barriers. */
48a67e1e34Sad #define	PTHREAD__ATOMIC_IS_MEMBAR
49a67e1e34Sad 
50c62a74e6Sthorpej #endif /* _LIB_PTHREAD_SPARC_MD_H */
51