pthread_md.h revision 1.4 1 1.4 ad /* $NetBSD: pthread_md.h,v 1.4 2008/02/10 18:50:55 ad Exp $ */
2 1.1 uwe
3 1.1 uwe /*
4 1.1 uwe * Copyright 2003 Wasabi Systems, Inc.
5 1.1 uwe * All rights reserved.
6 1.1 uwe *
7 1.1 uwe * Written by Steve C. Woodford for Wasabi Systems, Inc.
8 1.1 uwe *
9 1.1 uwe * Redistribution and use in source and binary forms, with or without
10 1.1 uwe * modification, are permitted provided that the following conditions
11 1.1 uwe * are met:
12 1.1 uwe * 1. Redistributions of source code must retain the above copyright
13 1.1 uwe * notice, this list of conditions and the following disclaimer.
14 1.1 uwe * 2. Redistributions in binary form must reproduce the above copyright
15 1.1 uwe * notice, this list of conditions and the following disclaimer in the
16 1.1 uwe * documentation and/or other materials provided with the distribution.
17 1.1 uwe * 3. All advertising materials mentioning features or use of this software
18 1.1 uwe * must display the following acknowledgement:
19 1.1 uwe * This product includes software developed for the NetBSD Project by
20 1.1 uwe * Wasabi Systems, Inc.
21 1.1 uwe * 4. The name of Wasabi Systems, Inc. may not be used to endorse
22 1.1 uwe * or promote products derived from this software without specific prior
23 1.1 uwe * written permission.
24 1.1 uwe *
25 1.1 uwe * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26 1.1 uwe * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 1.1 uwe * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 1.1 uwe * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
29 1.1 uwe * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 1.1 uwe * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 1.1 uwe * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 1.1 uwe * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 1.1 uwe * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 1.1 uwe * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 1.1 uwe * POSSIBILITY OF SUCH DAMAGE.
36 1.1 uwe */
37 1.1 uwe
38 1.1 uwe #ifndef _LIB_PTHREAD_SH3_MD_H
39 1.1 uwe #define _LIB_PTHREAD_SH3_MD_H
40 1.1 uwe
41 1.3 perry static inline long
42 1.1 uwe pthread__sp(void)
43 1.1 uwe {
44 1.1 uwe long ret;
45 1.1 uwe __asm("mov r15, %0" : "=r" (ret));
46 1.1 uwe
47 1.1 uwe return ret;
48 1.1 uwe }
49 1.1 uwe
50 1.1 uwe #define pthread__uc_sp(ucp) ((ucp)->uc_mcontext.__gregs[_REG_R15])
51 1.1 uwe #define pthread__uc_pc(ucp) ((ucp)->uc_mcontext.__gregs[_REG_PC])
52 1.1 uwe
53 1.2 uwe /*
54 1.2 uwe * Set initial, sane values for registers whose values aren't just
55 1.2 uwe * "don't care".
56 1.2 uwe */
57 1.2 uwe #define _INITCONTEXT_U_MD(ucp) \
58 1.2 uwe (ucp)->uc_mcontext.__gregs[_REG_SR] = 0;
59 1.1 uwe
60 1.1 uwe /*
61 1.1 uwe * SH3 requires no extra stack space
62 1.1 uwe */
63 1.1 uwe #define STACKSPACE 0
64 1.1 uwe
65 1.1 uwe
66 1.1 uwe /*
67 1.1 uwe * Conversions between struct reg and struct mcontext. Used by
68 1.1 uwe * libpthread_dbg.
69 1.1 uwe */
70 1.1 uwe
71 1.1 uwe #define PTHREAD_UCONTEXT_TO_REG(reg, uc) \
72 1.1 uwe memcpy((reg), &(uc)->uc_mcontext.__gregs[0], sizeof(*(reg)))
73 1.1 uwe
74 1.1 uwe #define PTHREAD_REG_TO_UCONTEXT(uc, reg) do { \
75 1.1 uwe memcpy(&(uc)->uc_mcontext.__gregs[0], (reg), sizeof(*(reg))); \
76 1.1 uwe (uc)->uc_flags = ((uc)->uc_flags | _UC_CPU) & ~_UC_USER; \
77 1.1 uwe } while (/*CONSTCOND*/0)
78 1.1 uwe
79 1.1 uwe #if 0 /* no struct fpreg!!! */
80 1.1 uwe #define PTHREAD_UCONTEXT_TO_FPREG(freg, uc) \
81 1.1 uwe memcpy((freg), &(uc)->uc_mcontext.__fpregs, sizeof(*(freg)));
82 1.1 uwe
83 1.1 uwe #define PTHREAD_FPREG_TO_UCONTEXT(uc, freg) do { \
84 1.1 uwe memcpy(&(uc)->uc_mcontext.__fpregs, (freg), sizeof(*(freg))); \
85 1.1 uwe (uc)->uc_flags = ((uc)->uc_flags | _UC_FPU) & ~_UC_USER; \
86 1.1 uwe } while (/*CONSTCOND*/0)
87 1.1 uwe
88 1.1 uwe #else /* SBUBS */
89 1.1 uwe #define PTHREAD_UCONTEXT_TO_FPREG(freg, uc)
90 1.1 uwe #define PTHREAD_FPREG_TO_UCONTEXT(uc, freg)
91 1.1 uwe #endif
92 1.1 uwe
93 1.4 ad /* sh3 will not go SMP */
94 1.4 ad #define PTHREAD__ATOMIC_IS_MEMBAR
95 1.4 ad
96 1.1 uwe #endif /* _LIB_PTHREAD_SH3_MD_H */
97