| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: __longjmp14.c,v 1.5 2008/04/28 20:22:55 martin Exp $ */ | | 1 | /* $NetBSD: __longjmp14.c,v 1.6 2013/03/12 19:38:20 martin Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2003 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2003 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Christian Limpach and Matt Thomas. | | 8 | * by Christian Limpach and Matt Thomas. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -46,44 +46,47 @@ void | | | @@ -46,44 +46,47 @@ void |
46 | __longjmp14(jmp_buf env, int val) | | 46 | __longjmp14(jmp_buf env, int val) |
47 | { | | 47 | { |
48 | struct sigcontext *sc = (void *)env; | | 48 | struct sigcontext *sc = (void *)env; |
49 | ucontext_t uc; | | 49 | ucontext_t uc; |
50 | | | 50 | |
51 | /* Ensure non-zero SP */ | | 51 | /* Ensure non-zero SP */ |
52 | if (sc->sc_sp == 0 || sc->sc_regs[R_ZERO] != 0xacedbade) | | 52 | if (sc->sc_sp == 0 || sc->sc_regs[R_ZERO] != 0xacedbade) |
53 | goto err; | | 53 | goto err; |
54 | | | 54 | |
55 | /* Ensure non-zero return value */ | | 55 | /* Ensure non-zero return value */ |
56 | if (val == 0) | | 56 | if (val == 0) |
57 | val = -1; | | 57 | val = -1; |
58 | | | 58 | |
| | | 59 | memset(&uc, 0, sizeof uc); |
| | | 60 | |
59 | /* Set _UC_SIGMASK and _UC_CPU */ | | 61 | /* Set _UC_SIGMASK and _UC_CPU */ |
60 | uc.uc_flags = _UC_SIGMASK | _UC_CPU; | | 62 | uc.uc_flags = _UC_SIGMASK | _UC_CPU; |
61 | | | 63 | |
62 | /* Clear uc_link */ | | 64 | /* Clear uc_link */ |
63 | uc.uc_link = 0; | | 65 | uc.uc_link = 0; |
64 | | | 66 | |
65 | /* Save return value in context */ | | 67 | /* Save return value in context */ |
66 | uc.uc_mcontext.__gregs[_REG_V0] = val; | | 68 | uc.uc_mcontext.__gregs[_REG_V0] = val; |
67 | | | 69 | |
68 | /* Copy saved registers */ | | 70 | /* Copy saved registers */ |
69 | uc.uc_mcontext.__gregs[_REG_S0] = sc->sc_regs[R_S0]; | | 71 | uc.uc_mcontext.__gregs[_REG_S0] = sc->sc_regs[R_S0]; |
70 | uc.uc_mcontext.__gregs[_REG_S1] = sc->sc_regs[R_S1]; | | 72 | uc.uc_mcontext.__gregs[_REG_S1] = sc->sc_regs[R_S1]; |
71 | uc.uc_mcontext.__gregs[_REG_S2] = sc->sc_regs[R_S2]; | | 73 | uc.uc_mcontext.__gregs[_REG_S2] = sc->sc_regs[R_S2]; |
72 | uc.uc_mcontext.__gregs[_REG_S3] = sc->sc_regs[R_S3]; | | 74 | uc.uc_mcontext.__gregs[_REG_S3] = sc->sc_regs[R_S3]; |
73 | uc.uc_mcontext.__gregs[_REG_S4] = sc->sc_regs[R_S4]; | | 75 | uc.uc_mcontext.__gregs[_REG_S4] = sc->sc_regs[R_S4]; |
74 | uc.uc_mcontext.__gregs[_REG_S5] = sc->sc_regs[R_S5]; | | 76 | uc.uc_mcontext.__gregs[_REG_S5] = sc->sc_regs[R_S5]; |
75 | uc.uc_mcontext.__gregs[_REG_S6] = sc->sc_regs[R_S6]; | | 77 | uc.uc_mcontext.__gregs[_REG_S6] = sc->sc_regs[R_S6]; |
76 | uc.uc_mcontext.__gregs[_REG_RA] = sc->sc_regs[R_RA]; | | 78 | uc.uc_mcontext.__gregs[_REG_RA] = sc->sc_regs[R_RA]; |
| | | 79 | uc.uc_mcontext.__gregs[_REG_GP] = sc->sc_regs[R_GP]; |
77 | uc.uc_mcontext.__gregs[_REG_SP] = sc->sc_sp; | | 80 | uc.uc_mcontext.__gregs[_REG_SP] = sc->sc_sp; |
78 | uc.uc_mcontext.__gregs[_REG_PC] = sc->sc_pc; | | 81 | uc.uc_mcontext.__gregs[_REG_PC] = sc->sc_pc; |
79 | uc.uc_mcontext.__gregs[_REG_PS] = | | 82 | uc.uc_mcontext.__gregs[_REG_PS] = |
80 | (sc->sc_ps | ALPHA_PSL_USERSET) & ~ALPHA_PSL_USERCLR; | | 83 | (sc->sc_ps | ALPHA_PSL_USERSET) & ~ALPHA_PSL_USERCLR; |
81 | | | 84 | |
82 | /* Copy FP state */ | | 85 | /* Copy FP state */ |
83 | if (sc->sc_ownedfp) { | | 86 | if (sc->sc_ownedfp) { |
84 | memcpy(&uc.uc_mcontext.__fpregs.__fp_fr, | | 87 | memcpy(&uc.uc_mcontext.__fpregs.__fp_fr, |
85 | &sc->sc_fpregs, 31 * sizeof(unsigned long)); | | 88 | &sc->sc_fpregs, 31 * sizeof(unsigned long)); |
86 | uc.uc_mcontext.__fpregs.__fp_fpcr = sc->sc_fpcr; | | 89 | uc.uc_mcontext.__fpregs.__fp_fpcr = sc->sc_fpcr; |
87 | /* XXX sc_fp_control */ | | 90 | /* XXX sc_fp_control */ |
88 | uc.uc_flags |= _UC_FPU; | | 91 | uc.uc_flags |= _UC_FPU; |
89 | } | | 92 | } |