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