1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
28*0Sstevel@tonic-gate 
29*0Sstevel@tonic-gate #include <sys/types.h>
30*0Sstevel@tonic-gate #include <sys/mkdev.h>
31*0Sstevel@tonic-gate #include <sys/regset.h>
32*0Sstevel@tonic-gate #include <string.h>
33*0Sstevel@tonic-gate 
34*0Sstevel@tonic-gate #if defined(__amd64)
35*0Sstevel@tonic-gate #include <sys/fp.h>
36*0Sstevel@tonic-gate #include <ieeefp.h>
37*0Sstevel@tonic-gate #endif
38*0Sstevel@tonic-gate 
39*0Sstevel@tonic-gate #include "P32ton.h"
40*0Sstevel@tonic-gate 
41*0Sstevel@tonic-gate dev_t
42*0Sstevel@tonic-gate prexpldev(dev32_t d)
43*0Sstevel@tonic-gate {
44*0Sstevel@tonic-gate 	if (d != (dev32_t)-1L)
45*0Sstevel@tonic-gate 		return (makedev((d >> NBITSMINOR32) & MAXMAJ32, d & MAXMIN32));
46*0Sstevel@tonic-gate 
47*0Sstevel@tonic-gate 	return ((dev_t)PRNODEV);
48*0Sstevel@tonic-gate }
49*0Sstevel@tonic-gate 
50*0Sstevel@tonic-gate 
51*0Sstevel@tonic-gate dev32_t
52*0Sstevel@tonic-gate prcmpldev(dev_t d)
53*0Sstevel@tonic-gate {
54*0Sstevel@tonic-gate #ifdef _LP64
55*0Sstevel@tonic-gate 	if (d == PRNODEV) {
56*0Sstevel@tonic-gate 		return (PRNODEV32);
57*0Sstevel@tonic-gate 	} else {
58*0Sstevel@tonic-gate 		major_t maj = major(d);
59*0Sstevel@tonic-gate 		minor_t min = minor(d);
60*0Sstevel@tonic-gate 
61*0Sstevel@tonic-gate 		if (maj == (major_t)PRNODEV || min == (minor_t)PRNODEV)
62*0Sstevel@tonic-gate 			return (PRNODEV32);
63*0Sstevel@tonic-gate 
64*0Sstevel@tonic-gate 		return ((dev32_t)((maj << NBITSMINOR32) | min));
65*0Sstevel@tonic-gate 	}
66*0Sstevel@tonic-gate #else
67*0Sstevel@tonic-gate 	return ((dev32_t)d);
68*0Sstevel@tonic-gate #endif
69*0Sstevel@tonic-gate }
70*0Sstevel@tonic-gate 
71*0Sstevel@tonic-gate #ifdef _LP64
72*0Sstevel@tonic-gate 
73*0Sstevel@tonic-gate void
74*0Sstevel@tonic-gate timestruc_32_to_n(const timestruc32_t *src, timestruc_t *dst)
75*0Sstevel@tonic-gate {
76*0Sstevel@tonic-gate 	dst->tv_sec = (time_t)(uint32_t)src->tv_sec;
77*0Sstevel@tonic-gate 	dst->tv_nsec = (long)(uint32_t)src->tv_nsec;
78*0Sstevel@tonic-gate }
79*0Sstevel@tonic-gate 
80*0Sstevel@tonic-gate void
81*0Sstevel@tonic-gate stack_32_to_n(const stack32_t *src, stack_t *dst)
82*0Sstevel@tonic-gate {
83*0Sstevel@tonic-gate 	dst->ss_sp = (caddr_t)(uintptr_t)src->ss_sp;
84*0Sstevel@tonic-gate 	dst->ss_size = src->ss_size;
85*0Sstevel@tonic-gate 	dst->ss_flags = src->ss_flags;
86*0Sstevel@tonic-gate }
87*0Sstevel@tonic-gate 
88*0Sstevel@tonic-gate void
89*0Sstevel@tonic-gate sigaction_32_to_n(const struct sigaction32 *src, struct sigaction *dst)
90*0Sstevel@tonic-gate {
91*0Sstevel@tonic-gate 	(void) memset(dst, 0, sizeof (struct sigaction));
92*0Sstevel@tonic-gate 	dst->sa_flags = src->sa_flags;
93*0Sstevel@tonic-gate 	dst->sa_handler = (void (*)())(uintptr_t)src->sa_handler;
94*0Sstevel@tonic-gate 	(void) memcpy(&dst->sa_mask, &src->sa_mask, sizeof (dst->sa_mask));
95*0Sstevel@tonic-gate }
96*0Sstevel@tonic-gate 
97*0Sstevel@tonic-gate void
98*0Sstevel@tonic-gate siginfo_32_to_n(const siginfo32_t *src, siginfo_t *dst)
99*0Sstevel@tonic-gate {
100*0Sstevel@tonic-gate 	(void) memset(dst, 0, sizeof (siginfo_t));
101*0Sstevel@tonic-gate 
102*0Sstevel@tonic-gate 	/*
103*0Sstevel@tonic-gate 	 * The absolute minimum content is si_signo and si_code.
104*0Sstevel@tonic-gate 	 */
105*0Sstevel@tonic-gate 	dst->si_signo = src->si_signo;
106*0Sstevel@tonic-gate 	if ((dst->si_code = src->si_code) == SI_NOINFO)
107*0Sstevel@tonic-gate 		return;
108*0Sstevel@tonic-gate 
109*0Sstevel@tonic-gate 	/*
110*0Sstevel@tonic-gate 	 * A siginfo generated by user level is structured
111*0Sstevel@tonic-gate 	 * differently from one generated by the kernel.
112*0Sstevel@tonic-gate 	 */
113*0Sstevel@tonic-gate 	if (SI_FROMUSER(src)) {
114*0Sstevel@tonic-gate 		dst->si_pid = src->si_pid;
115*0Sstevel@tonic-gate 		dst->si_ctid = src->si_ctid;
116*0Sstevel@tonic-gate 		dst->si_zoneid = src->si_zoneid;
117*0Sstevel@tonic-gate 		dst->si_uid = src->si_uid;
118*0Sstevel@tonic-gate 		if (SI_CANQUEUE(src->si_code)) {
119*0Sstevel@tonic-gate 			dst->si_value.sival_int =
120*0Sstevel@tonic-gate 			    (long)(uint32_t)src->si_value.sival_int;
121*0Sstevel@tonic-gate 		}
122*0Sstevel@tonic-gate 		return;
123*0Sstevel@tonic-gate 	}
124*0Sstevel@tonic-gate 
125*0Sstevel@tonic-gate 	dst->si_errno = src->si_errno;
126*0Sstevel@tonic-gate 
127*0Sstevel@tonic-gate 	switch (src->si_signo) {
128*0Sstevel@tonic-gate 	default:
129*0Sstevel@tonic-gate 		dst->si_pid = src->si_pid;
130*0Sstevel@tonic-gate 		dst->si_ctid = src->si_ctid;
131*0Sstevel@tonic-gate 		dst->si_zoneid = src->si_zoneid;
132*0Sstevel@tonic-gate 		dst->si_uid = src->si_uid;
133*0Sstevel@tonic-gate 		dst->si_value.sival_int =
134*0Sstevel@tonic-gate 		    (long)(uint32_t)src->si_value.sival_int;
135*0Sstevel@tonic-gate 		break;
136*0Sstevel@tonic-gate 	case SIGCLD:
137*0Sstevel@tonic-gate 		dst->si_pid = src->si_pid;
138*0Sstevel@tonic-gate 		dst->si_ctid = src->si_ctid;
139*0Sstevel@tonic-gate 		dst->si_zoneid = src->si_zoneid;
140*0Sstevel@tonic-gate 		dst->si_status = src->si_status;
141*0Sstevel@tonic-gate 		dst->si_stime = src->si_stime;
142*0Sstevel@tonic-gate 		dst->si_utime = src->si_utime;
143*0Sstevel@tonic-gate 		break;
144*0Sstevel@tonic-gate 	case SIGSEGV:
145*0Sstevel@tonic-gate 	case SIGBUS:
146*0Sstevel@tonic-gate 	case SIGILL:
147*0Sstevel@tonic-gate 	case SIGTRAP:
148*0Sstevel@tonic-gate 	case SIGFPE:
149*0Sstevel@tonic-gate 	case SIGEMT:
150*0Sstevel@tonic-gate 		dst->si_addr = (void *)(uintptr_t)src->si_addr;
151*0Sstevel@tonic-gate 		dst->si_trapno = src->si_trapno;
152*0Sstevel@tonic-gate 		dst->si_pc = (void *)(uintptr_t)src->si_pc;
153*0Sstevel@tonic-gate 		break;
154*0Sstevel@tonic-gate 	case SIGPOLL:
155*0Sstevel@tonic-gate 	case SIGXFSZ:
156*0Sstevel@tonic-gate 		dst->si_fd = src->si_fd;
157*0Sstevel@tonic-gate 		dst->si_band = src->si_band;
158*0Sstevel@tonic-gate 		break;
159*0Sstevel@tonic-gate 	case SIGPROF:
160*0Sstevel@tonic-gate 		dst->si_faddr = (void *)(uintptr_t)src->si_faddr;
161*0Sstevel@tonic-gate 		dst->si_tstamp.tv_sec = src->si_tstamp.tv_sec;
162*0Sstevel@tonic-gate 		dst->si_tstamp.tv_nsec = src->si_tstamp.tv_nsec;
163*0Sstevel@tonic-gate 		dst->si_syscall = src->si_syscall;
164*0Sstevel@tonic-gate 		dst->si_nsysarg = src->si_nsysarg;
165*0Sstevel@tonic-gate 		dst->si_fault = src->si_fault;
166*0Sstevel@tonic-gate 		break;
167*0Sstevel@tonic-gate 	}
168*0Sstevel@tonic-gate }
169*0Sstevel@tonic-gate 
170*0Sstevel@tonic-gate void
171*0Sstevel@tonic-gate auxv_32_to_n(const auxv32_t *src, auxv_t *dst)
172*0Sstevel@tonic-gate {
173*0Sstevel@tonic-gate 	/*
174*0Sstevel@tonic-gate 	 * This is a little sketchy: we have three types of values stored
175*0Sstevel@tonic-gate 	 * in an auxv (long, void *, and void (*)()) so the only sign-extension
176*0Sstevel@tonic-gate 	 * issue is with the long.  We could case on all possible AT_* types,
177*0Sstevel@tonic-gate 	 * but this seems silly since currently none of the types which use
178*0Sstevel@tonic-gate 	 * a_un.a_val actually use negative numbers as a value.  For this
179*0Sstevel@tonic-gate 	 * reason, it seems simpler to just do an unsigned expansion for now.
180*0Sstevel@tonic-gate 	 */
181*0Sstevel@tonic-gate 	dst->a_type = src->a_type;
182*0Sstevel@tonic-gate 	dst->a_un.a_ptr = (void *)(uintptr_t)src->a_un.a_ptr;
183*0Sstevel@tonic-gate }
184*0Sstevel@tonic-gate 
185*0Sstevel@tonic-gate #if defined(__sparc)
186*0Sstevel@tonic-gate void
187*0Sstevel@tonic-gate rwindow_32_to_n(const struct rwindow32 *src, struct rwindow *dst)
188*0Sstevel@tonic-gate {
189*0Sstevel@tonic-gate 	int i;
190*0Sstevel@tonic-gate 
191*0Sstevel@tonic-gate 	for (i = 0; i < 8; i++) {
192*0Sstevel@tonic-gate 		dst->rw_local[i] = (uint64_t)(uint32_t)src->rw_local[i];
193*0Sstevel@tonic-gate 		dst->rw_in[i] = (uint64_t)(uint32_t)src->rw_in[i];
194*0Sstevel@tonic-gate 	}
195*0Sstevel@tonic-gate }
196*0Sstevel@tonic-gate 
197*0Sstevel@tonic-gate void
198*0Sstevel@tonic-gate gwindows_32_to_n(const gwindows32_t *src, gwindows_t *dst)
199*0Sstevel@tonic-gate {
200*0Sstevel@tonic-gate 	int i;
201*0Sstevel@tonic-gate 
202*0Sstevel@tonic-gate 	(void) memset(dst, 0, sizeof (gwindows_t));
203*0Sstevel@tonic-gate 	dst->wbcnt = src->wbcnt;
204*0Sstevel@tonic-gate 
205*0Sstevel@tonic-gate 	for (i = 0; i < src->wbcnt; i++) {
206*0Sstevel@tonic-gate 		if (src->spbuf[i] != 0) {
207*0Sstevel@tonic-gate 			rwindow_32_to_n(&src->wbuf[i], &dst->wbuf[i]);
208*0Sstevel@tonic-gate 			dst->spbuf[i] = (greg_t *)src->spbuf[i];
209*0Sstevel@tonic-gate 		}
210*0Sstevel@tonic-gate 	}
211*0Sstevel@tonic-gate }
212*0Sstevel@tonic-gate #endif	/* __sparc */
213*0Sstevel@tonic-gate 
214*0Sstevel@tonic-gate void
215*0Sstevel@tonic-gate prgregset_32_to_n(const prgreg32_t *src, prgreg_t *dst)
216*0Sstevel@tonic-gate {
217*0Sstevel@tonic-gate #ifdef __amd64
218*0Sstevel@tonic-gate 	(void) memset(dst, 0, NPRGREG * sizeof (prgreg_t));
219*0Sstevel@tonic-gate 	dst[REG_GS] = (uint32_t)src[GS];
220*0Sstevel@tonic-gate 	dst[REG_FS] = (uint32_t)src[FS];
221*0Sstevel@tonic-gate 	dst[REG_DS] = (uint32_t)src[DS];
222*0Sstevel@tonic-gate 	dst[REG_ES] = (uint32_t)src[ES];
223*0Sstevel@tonic-gate 	dst[REG_RDI] = (uint32_t)src[EDI];
224*0Sstevel@tonic-gate 	dst[REG_RSI] = (uint32_t)src[ESI];
225*0Sstevel@tonic-gate 	dst[REG_RBP] = (uint32_t)src[EBP];
226*0Sstevel@tonic-gate 	dst[REG_RBX] = (uint32_t)src[EBX];
227*0Sstevel@tonic-gate 	dst[REG_RDX] = (uint32_t)src[EDX];
228*0Sstevel@tonic-gate 	dst[REG_RCX] = (uint32_t)src[ECX];
229*0Sstevel@tonic-gate 	dst[REG_RAX] = (uint32_t)src[EAX];
230*0Sstevel@tonic-gate 	dst[REG_TRAPNO] = (uint32_t)src[TRAPNO];
231*0Sstevel@tonic-gate 	dst[REG_ERR] = (uint32_t)src[ERR];
232*0Sstevel@tonic-gate 	dst[REG_RIP] = (uint32_t)src[EIP];
233*0Sstevel@tonic-gate 	dst[REG_CS] = (uint32_t)src[CS];
234*0Sstevel@tonic-gate 	dst[REG_RFL] = (uint32_t)src[EFL];
235*0Sstevel@tonic-gate 	dst[REG_RSP] = (uint32_t)src[UESP];
236*0Sstevel@tonic-gate 	dst[REG_SS] = (uint32_t)src[SS];
237*0Sstevel@tonic-gate #else
238*0Sstevel@tonic-gate 	int i;
239*0Sstevel@tonic-gate 
240*0Sstevel@tonic-gate 	for (i = 0; i < NPRGREG; i++)
241*0Sstevel@tonic-gate 		dst[i] = (prgreg_t)(uint32_t)src[i];
242*0Sstevel@tonic-gate #endif
243*0Sstevel@tonic-gate }
244*0Sstevel@tonic-gate 
245*0Sstevel@tonic-gate void
246*0Sstevel@tonic-gate prfpregset_32_to_n(const prfpregset32_t *src, prfpregset_t *dst)
247*0Sstevel@tonic-gate {
248*0Sstevel@tonic-gate #if defined(__sparc)
249*0Sstevel@tonic-gate 	int i;
250*0Sstevel@tonic-gate 
251*0Sstevel@tonic-gate 	(void) memset(dst, 0, sizeof (prfpregset_t));
252*0Sstevel@tonic-gate 
253*0Sstevel@tonic-gate 	for (i = 0; i < 32; i++)
254*0Sstevel@tonic-gate 		dst->pr_fr.pr_regs[i] = src->pr_fr.pr_regs[i];
255*0Sstevel@tonic-gate 
256*0Sstevel@tonic-gate 	/*
257*0Sstevel@tonic-gate 	 * We deliberately do not convert pr_qcnt or pr_q because it is a long-
258*0Sstevel@tonic-gate 	 * standing /proc bug that this information is not exported, and another
259*0Sstevel@tonic-gate 	 * bug further caused these values to be returned as uninitialized data
260*0Sstevel@tonic-gate 	 * when the 64-bit kernel exported them for a 32-bit process with en=0.
261*0Sstevel@tonic-gate 	 */
262*0Sstevel@tonic-gate 	dst->pr_filler = src->pr_filler;
263*0Sstevel@tonic-gate 	dst->pr_fsr = src->pr_fsr;
264*0Sstevel@tonic-gate 	dst->pr_q_entrysize = src->pr_q_entrysize;
265*0Sstevel@tonic-gate 	dst->pr_en = src->pr_en;
266*0Sstevel@tonic-gate 
267*0Sstevel@tonic-gate #elif defined(__amd64)
268*0Sstevel@tonic-gate 
269*0Sstevel@tonic-gate 	struct _fpstate32 *src32 = (struct _fpstate32 *)src;
270*0Sstevel@tonic-gate 	struct fpchip_state *dst64 = (struct fpchip_state *)dst;
271*0Sstevel@tonic-gate 	int i;
272*0Sstevel@tonic-gate 
273*0Sstevel@tonic-gate 	(void) memcpy(dst64->st, src32->_st, sizeof (src32->_st));
274*0Sstevel@tonic-gate 	(void) memcpy(dst64->xmm, src32->xmm, sizeof (src32->xmm));
275*0Sstevel@tonic-gate 	(void) memset((caddr_t)dst64->xmm + sizeof (src32->xmm), 0,
276*0Sstevel@tonic-gate 	    sizeof (dst64->xmm) - sizeof (src32->xmm));
277*0Sstevel@tonic-gate 	dst64->cw = (uint16_t)src32->cw;
278*0Sstevel@tonic-gate 	dst64->sw = (uint16_t)src32->sw;
279*0Sstevel@tonic-gate 	dst64->fop = 0;
280*0Sstevel@tonic-gate 	dst64->rip = src32->ipoff;
281*0Sstevel@tonic-gate 	dst64->rdp = src32->dataoff;
282*0Sstevel@tonic-gate 	dst64->mxcsr = src32->mxcsr;
283*0Sstevel@tonic-gate 	dst64->mxcsr_mask = 0;
284*0Sstevel@tonic-gate 	dst64->status = src32->status;
285*0Sstevel@tonic-gate 	dst64->xstatus = src32->xstatus;
286*0Sstevel@tonic-gate 
287*0Sstevel@tonic-gate 	/*
288*0Sstevel@tonic-gate 	 * Converting from the tag field to the compressed fctw is easy.
289*0Sstevel@tonic-gate 	 * If the two tag bits are 3, then the register is empty and we
290*0Sstevel@tonic-gate 	 * clear the bit in fctw. Otherwise we set the bit.
291*0Sstevel@tonic-gate 	 */
292*0Sstevel@tonic-gate 
293*0Sstevel@tonic-gate 	dst64->fctw = 0;
294*0Sstevel@tonic-gate 	for (i = 0; i < 8; i++)
295*0Sstevel@tonic-gate 		if (((src32->tag >> (i * 2)) & 3) != 3)
296*0Sstevel@tonic-gate 			dst64->fctw |= 1 << i;
297*0Sstevel@tonic-gate #else
298*0Sstevel@tonic-gate #error "unrecognized ISA"
299*0Sstevel@tonic-gate #endif
300*0Sstevel@tonic-gate }
301*0Sstevel@tonic-gate 
302*0Sstevel@tonic-gate void
303*0Sstevel@tonic-gate lwpstatus_32_to_n(const lwpstatus32_t *src, lwpstatus_t *dst)
304*0Sstevel@tonic-gate {
305*0Sstevel@tonic-gate 	int i;
306*0Sstevel@tonic-gate 
307*0Sstevel@tonic-gate 	dst->pr_flags = src->pr_flags;
308*0Sstevel@tonic-gate 	dst->pr_lwpid = src->pr_lwpid;
309*0Sstevel@tonic-gate 	dst->pr_why = src->pr_why;
310*0Sstevel@tonic-gate 	dst->pr_what = src->pr_what;
311*0Sstevel@tonic-gate 	dst->pr_cursig = src->pr_cursig;
312*0Sstevel@tonic-gate 
313*0Sstevel@tonic-gate 	siginfo_32_to_n(&src->pr_info, &dst->pr_info);
314*0Sstevel@tonic-gate 
315*0Sstevel@tonic-gate 	dst->pr_lwppend = src->pr_lwppend;
316*0Sstevel@tonic-gate 	dst->pr_lwphold = src->pr_lwphold;
317*0Sstevel@tonic-gate 
318*0Sstevel@tonic-gate 	sigaction_32_to_n(&src->pr_action, &dst->pr_action);
319*0Sstevel@tonic-gate 	stack_32_to_n(&src->pr_altstack, &dst->pr_altstack);
320*0Sstevel@tonic-gate 
321*0Sstevel@tonic-gate 	dst->pr_oldcontext = src->pr_oldcontext;
322*0Sstevel@tonic-gate 	dst->pr_syscall = src->pr_syscall;
323*0Sstevel@tonic-gate 	dst->pr_nsysarg = src->pr_nsysarg;
324*0Sstevel@tonic-gate 	dst->pr_errno = src->pr_errno;
325*0Sstevel@tonic-gate 
326*0Sstevel@tonic-gate 	for (i = 0; i < PRSYSARGS; i++)
327*0Sstevel@tonic-gate 		dst->pr_sysarg[i] = (long)(uint32_t)src->pr_sysarg[i];
328*0Sstevel@tonic-gate 
329*0Sstevel@tonic-gate 	dst->pr_rval1 = (long)(uint32_t)src->pr_rval1;
330*0Sstevel@tonic-gate 	dst->pr_rval2 = (long)(uint32_t)src->pr_rval2;
331*0Sstevel@tonic-gate 
332*0Sstevel@tonic-gate 	(void) memcpy(&dst->pr_clname[0], &src->pr_clname[0], PRCLSZ);
333*0Sstevel@tonic-gate 	timestruc_32_to_n(&src->pr_tstamp, &dst->pr_tstamp);
334*0Sstevel@tonic-gate 
335*0Sstevel@tonic-gate 	dst->pr_ustack = src->pr_ustack;
336*0Sstevel@tonic-gate 	dst->pr_instr = src->pr_instr;
337*0Sstevel@tonic-gate 
338*0Sstevel@tonic-gate 	prgregset_32_to_n(src->pr_reg, dst->pr_reg);
339*0Sstevel@tonic-gate 	prfpregset_32_to_n(&src->pr_fpreg, &dst->pr_fpreg);
340*0Sstevel@tonic-gate }
341*0Sstevel@tonic-gate 
342*0Sstevel@tonic-gate void
343*0Sstevel@tonic-gate pstatus_32_to_n(const pstatus32_t *src, pstatus_t *dst)
344*0Sstevel@tonic-gate {
345*0Sstevel@tonic-gate 	dst->pr_flags = src->pr_flags;
346*0Sstevel@tonic-gate 	dst->pr_nlwp = src->pr_nlwp;
347*0Sstevel@tonic-gate 	dst->pr_nzomb = src->pr_nzomb;
348*0Sstevel@tonic-gate 	dst->pr_pid = src->pr_pid;
349*0Sstevel@tonic-gate 	dst->pr_ppid = src->pr_ppid;
350*0Sstevel@tonic-gate 	dst->pr_pgid = src->pr_pgid;
351*0Sstevel@tonic-gate 	dst->pr_sid = src->pr_sid;
352*0Sstevel@tonic-gate 	dst->pr_taskid = src->pr_taskid;
353*0Sstevel@tonic-gate 	dst->pr_projid = src->pr_projid;
354*0Sstevel@tonic-gate 	dst->pr_zoneid = src->pr_zoneid;
355*0Sstevel@tonic-gate 	dst->pr_aslwpid = src->pr_aslwpid;
356*0Sstevel@tonic-gate 	dst->pr_agentid = src->pr_agentid;
357*0Sstevel@tonic-gate 	dst->pr_sigpend = src->pr_sigpend;
358*0Sstevel@tonic-gate 	dst->pr_brkbase = src->pr_brkbase;
359*0Sstevel@tonic-gate 	dst->pr_brksize = src->pr_brksize;
360*0Sstevel@tonic-gate 	dst->pr_stkbase = src->pr_stkbase;
361*0Sstevel@tonic-gate 	dst->pr_stksize = src->pr_stksize;
362*0Sstevel@tonic-gate 
363*0Sstevel@tonic-gate 	timestruc_32_to_n(&src->pr_utime, &dst->pr_utime);
364*0Sstevel@tonic-gate 	timestruc_32_to_n(&src->pr_stime, &dst->pr_stime);
365*0Sstevel@tonic-gate 	timestruc_32_to_n(&src->pr_cutime, &dst->pr_cutime);
366*0Sstevel@tonic-gate 	timestruc_32_to_n(&src->pr_cstime, &dst->pr_cstime);
367*0Sstevel@tonic-gate 
368*0Sstevel@tonic-gate 	dst->pr_sigtrace = src->pr_sigtrace;
369*0Sstevel@tonic-gate 	dst->pr_flttrace = src->pr_flttrace;
370*0Sstevel@tonic-gate 	dst->pr_sysentry = src->pr_sysentry;
371*0Sstevel@tonic-gate 	dst->pr_sysexit = src->pr_sysexit;
372*0Sstevel@tonic-gate 	dst->pr_dmodel = src->pr_dmodel;
373*0Sstevel@tonic-gate 
374*0Sstevel@tonic-gate 	lwpstatus_32_to_n(&src->pr_lwp, &dst->pr_lwp);
375*0Sstevel@tonic-gate }
376*0Sstevel@tonic-gate 
377*0Sstevel@tonic-gate void
378*0Sstevel@tonic-gate lwpsinfo_32_to_n(const lwpsinfo32_t *src, lwpsinfo_t *dst)
379*0Sstevel@tonic-gate {
380*0Sstevel@tonic-gate 	dst->pr_flag = src->pr_flag;
381*0Sstevel@tonic-gate 	dst->pr_lwpid = src->pr_lwpid;
382*0Sstevel@tonic-gate 	dst->pr_addr = src->pr_addr;
383*0Sstevel@tonic-gate 	dst->pr_wchan = src->pr_wchan;
384*0Sstevel@tonic-gate 	dst->pr_stype = src->pr_stype;
385*0Sstevel@tonic-gate 	dst->pr_state = src->pr_state;
386*0Sstevel@tonic-gate 	dst->pr_sname = src->pr_sname;
387*0Sstevel@tonic-gate 	dst->pr_nice = src->pr_nice;
388*0Sstevel@tonic-gate 	dst->pr_syscall = src->pr_syscall;
389*0Sstevel@tonic-gate 	dst->pr_oldpri = src->pr_oldpri;
390*0Sstevel@tonic-gate 	dst->pr_cpu = src->pr_cpu;
391*0Sstevel@tonic-gate 	dst->pr_pri = src->pr_pri;
392*0Sstevel@tonic-gate 	dst->pr_pctcpu = src->pr_pctcpu;
393*0Sstevel@tonic-gate 
394*0Sstevel@tonic-gate 	timestruc_32_to_n(&src->pr_start, &dst->pr_start);
395*0Sstevel@tonic-gate 	timestruc_32_to_n(&src->pr_time, &dst->pr_time);
396*0Sstevel@tonic-gate 
397*0Sstevel@tonic-gate 	(void) memcpy(&dst->pr_clname[0], &src->pr_clname[0], PRCLSZ);
398*0Sstevel@tonic-gate 	(void) memcpy(&dst->pr_name[0], &src->pr_name[0], PRFNSZ);
399*0Sstevel@tonic-gate 
400*0Sstevel@tonic-gate 	dst->pr_onpro = src->pr_onpro;
401*0Sstevel@tonic-gate 	dst->pr_bindpro = src->pr_bindpro;
402*0Sstevel@tonic-gate 	dst->pr_bindpset = src->pr_bindpset;
403*0Sstevel@tonic-gate }
404*0Sstevel@tonic-gate 
405*0Sstevel@tonic-gate void
406*0Sstevel@tonic-gate psinfo_32_to_n(const psinfo32_t *src, psinfo_t *dst)
407*0Sstevel@tonic-gate {
408*0Sstevel@tonic-gate 	dst->pr_flag = src->pr_flag;
409*0Sstevel@tonic-gate 	dst->pr_nlwp = src->pr_nlwp;
410*0Sstevel@tonic-gate 	dst->pr_nzomb = src->pr_nzomb;
411*0Sstevel@tonic-gate 	dst->pr_pid = src->pr_pid;
412*0Sstevel@tonic-gate 	dst->pr_pgid = src->pr_pgid;
413*0Sstevel@tonic-gate 	dst->pr_sid = src->pr_sid;
414*0Sstevel@tonic-gate 	dst->pr_taskid = src->pr_taskid;
415*0Sstevel@tonic-gate 	dst->pr_projid = src->pr_projid;
416*0Sstevel@tonic-gate 	dst->pr_zoneid = src->pr_zoneid;
417*0Sstevel@tonic-gate 	dst->pr_uid = src->pr_uid;
418*0Sstevel@tonic-gate 	dst->pr_euid = src->pr_euid;
419*0Sstevel@tonic-gate 	dst->pr_gid = src->pr_gid;
420*0Sstevel@tonic-gate 	dst->pr_egid = src->pr_egid;
421*0Sstevel@tonic-gate 	dst->pr_addr = src->pr_addr;
422*0Sstevel@tonic-gate 	dst->pr_size = src->pr_size;
423*0Sstevel@tonic-gate 	dst->pr_rssize = src->pr_rssize;
424*0Sstevel@tonic-gate 
425*0Sstevel@tonic-gate 	dst->pr_ttydev = prexpldev(src->pr_ttydev);
426*0Sstevel@tonic-gate 
427*0Sstevel@tonic-gate 	dst->pr_pctcpu = src->pr_pctcpu;
428*0Sstevel@tonic-gate 	dst->pr_pctmem = src->pr_pctmem;
429*0Sstevel@tonic-gate 
430*0Sstevel@tonic-gate 	timestruc_32_to_n(&src->pr_start, &dst->pr_start);
431*0Sstevel@tonic-gate 	timestruc_32_to_n(&src->pr_time, &dst->pr_time);
432*0Sstevel@tonic-gate 	timestruc_32_to_n(&src->pr_ctime, &dst->pr_ctime);
433*0Sstevel@tonic-gate 
434*0Sstevel@tonic-gate 	(void) memcpy(&dst->pr_fname[0], &src->pr_fname[0], PRFNSZ);
435*0Sstevel@tonic-gate 	(void) memcpy(&dst->pr_psargs[0], &src->pr_psargs[0], PRARGSZ);
436*0Sstevel@tonic-gate 
437*0Sstevel@tonic-gate 	dst->pr_wstat = src->pr_wstat;
438*0Sstevel@tonic-gate 	dst->pr_argc = src->pr_argc;
439*0Sstevel@tonic-gate 	dst->pr_argv = src->pr_argv;
440*0Sstevel@tonic-gate 	dst->pr_envp = src->pr_envp;
441*0Sstevel@tonic-gate 	dst->pr_dmodel = src->pr_dmodel;
442*0Sstevel@tonic-gate 
443*0Sstevel@tonic-gate 	lwpsinfo_32_to_n(&src->pr_lwp, &dst->pr_lwp);
444*0Sstevel@tonic-gate }
445*0Sstevel@tonic-gate 
446*0Sstevel@tonic-gate void
447*0Sstevel@tonic-gate timestruc_n_to_32(const timestruc_t *src, timestruc32_t *dst)
448*0Sstevel@tonic-gate {
449*0Sstevel@tonic-gate 	dst->tv_sec = (time32_t)src->tv_sec;
450*0Sstevel@tonic-gate 	dst->tv_nsec = (int32_t)src->tv_nsec;
451*0Sstevel@tonic-gate }
452*0Sstevel@tonic-gate 
453*0Sstevel@tonic-gate void
454*0Sstevel@tonic-gate stack_n_to_32(const stack_t *src, stack32_t *dst)
455*0Sstevel@tonic-gate {
456*0Sstevel@tonic-gate 	dst->ss_sp = (caddr32_t)(uintptr_t)src->ss_sp;
457*0Sstevel@tonic-gate 	dst->ss_size = src->ss_size;
458*0Sstevel@tonic-gate 	dst->ss_flags = src->ss_flags;
459*0Sstevel@tonic-gate }
460*0Sstevel@tonic-gate 
461*0Sstevel@tonic-gate void
462*0Sstevel@tonic-gate sigaction_n_to_32(const struct sigaction *src, struct sigaction32 *dst)
463*0Sstevel@tonic-gate {
464*0Sstevel@tonic-gate 	(void) memset(dst, 0, sizeof (struct sigaction32));
465*0Sstevel@tonic-gate 	dst->sa_flags = src->sa_flags;
466*0Sstevel@tonic-gate 	dst->sa_handler = (caddr32_t)(uintptr_t)src->sa_handler;
467*0Sstevel@tonic-gate 	(void) memcpy(&dst->sa_mask, &src->sa_mask, sizeof (dst->sa_mask));
468*0Sstevel@tonic-gate }
469*0Sstevel@tonic-gate 
470*0Sstevel@tonic-gate void
471*0Sstevel@tonic-gate siginfo_n_to_32(const siginfo_t *src, siginfo32_t *dst)
472*0Sstevel@tonic-gate {
473*0Sstevel@tonic-gate 	(void) memset(dst, 0, sizeof (siginfo32_t));
474*0Sstevel@tonic-gate 
475*0Sstevel@tonic-gate 	/*
476*0Sstevel@tonic-gate 	 * The absolute minimum content is si_signo and si_code.
477*0Sstevel@tonic-gate 	 */
478*0Sstevel@tonic-gate 	dst->si_signo = src->si_signo;
479*0Sstevel@tonic-gate 	if ((dst->si_code = src->si_code) == SI_NOINFO)
480*0Sstevel@tonic-gate 		return;
481*0Sstevel@tonic-gate 
482*0Sstevel@tonic-gate 	/*
483*0Sstevel@tonic-gate 	 * A siginfo generated by user level is structured
484*0Sstevel@tonic-gate 	 * differently from one generated by the kernel.
485*0Sstevel@tonic-gate 	 */
486*0Sstevel@tonic-gate 	if (SI_FROMUSER(src)) {
487*0Sstevel@tonic-gate 		dst->si_pid = src->si_pid;
488*0Sstevel@tonic-gate 		dst->si_ctid = src->si_ctid;
489*0Sstevel@tonic-gate 		dst->si_zoneid = src->si_zoneid;
490*0Sstevel@tonic-gate 		dst->si_uid = src->si_uid;
491*0Sstevel@tonic-gate 		if (SI_CANQUEUE(src->si_code)) {
492*0Sstevel@tonic-gate 			dst->si_value.sival_int =
493*0Sstevel@tonic-gate 			    (int32_t)src->si_value.sival_int;
494*0Sstevel@tonic-gate 		}
495*0Sstevel@tonic-gate 		return;
496*0Sstevel@tonic-gate 	}
497*0Sstevel@tonic-gate 
498*0Sstevel@tonic-gate 	dst->si_errno = src->si_errno;
499*0Sstevel@tonic-gate 
500*0Sstevel@tonic-gate 	switch (src->si_signo) {
501*0Sstevel@tonic-gate 	default:
502*0Sstevel@tonic-gate 		dst->si_pid = src->si_pid;
503*0Sstevel@tonic-gate 		dst->si_ctid = src->si_ctid;
504*0Sstevel@tonic-gate 		dst->si_zoneid = src->si_zoneid;
505*0Sstevel@tonic-gate 		dst->si_uid = src->si_uid;
506*0Sstevel@tonic-gate 		dst->si_value.sival_int =
507*0Sstevel@tonic-gate 		    (int32_t)src->si_value.sival_int;
508*0Sstevel@tonic-gate 		break;
509*0Sstevel@tonic-gate 	case SIGCLD:
510*0Sstevel@tonic-gate 		dst->si_pid = src->si_pid;
511*0Sstevel@tonic-gate 		dst->si_ctid = src->si_ctid;
512*0Sstevel@tonic-gate 		dst->si_zoneid = src->si_zoneid;
513*0Sstevel@tonic-gate 		dst->si_status = src->si_status;
514*0Sstevel@tonic-gate 		dst->si_stime = src->si_stime;
515*0Sstevel@tonic-gate 		dst->si_utime = src->si_utime;
516*0Sstevel@tonic-gate 		break;
517*0Sstevel@tonic-gate 	case SIGSEGV:
518*0Sstevel@tonic-gate 	case SIGBUS:
519*0Sstevel@tonic-gate 	case SIGILL:
520*0Sstevel@tonic-gate 	case SIGTRAP:
521*0Sstevel@tonic-gate 	case SIGFPE:
522*0Sstevel@tonic-gate 	case SIGEMT:
523*0Sstevel@tonic-gate 		dst->si_addr = (caddr32_t)(uintptr_t)src->si_addr;
524*0Sstevel@tonic-gate 		dst->si_trapno = src->si_trapno;
525*0Sstevel@tonic-gate 		dst->si_pc = (caddr32_t)(uintptr_t)src->si_pc;
526*0Sstevel@tonic-gate 		break;
527*0Sstevel@tonic-gate 	case SIGPOLL:
528*0Sstevel@tonic-gate 	case SIGXFSZ:
529*0Sstevel@tonic-gate 		dst->si_fd = src->si_fd;
530*0Sstevel@tonic-gate 		dst->si_band = src->si_band;
531*0Sstevel@tonic-gate 		break;
532*0Sstevel@tonic-gate 	case SIGPROF:
533*0Sstevel@tonic-gate 		dst->si_faddr = (caddr32_t)(uintptr_t)src->si_faddr;
534*0Sstevel@tonic-gate 		dst->si_tstamp.tv_sec = src->si_tstamp.tv_sec;
535*0Sstevel@tonic-gate 		dst->si_tstamp.tv_nsec = src->si_tstamp.tv_nsec;
536*0Sstevel@tonic-gate 		dst->si_syscall = src->si_syscall;
537*0Sstevel@tonic-gate 		dst->si_nsysarg = src->si_nsysarg;
538*0Sstevel@tonic-gate 		dst->si_fault = src->si_fault;
539*0Sstevel@tonic-gate 		break;
540*0Sstevel@tonic-gate 	}
541*0Sstevel@tonic-gate }
542*0Sstevel@tonic-gate 
543*0Sstevel@tonic-gate void
544*0Sstevel@tonic-gate auxv_n_to_32(const auxv_t *src, auxv32_t *dst)
545*0Sstevel@tonic-gate {
546*0Sstevel@tonic-gate 	dst->a_type = src->a_type;
547*0Sstevel@tonic-gate 	dst->a_un.a_ptr = (caddr32_t)(uintptr_t)src->a_un.a_ptr;
548*0Sstevel@tonic-gate }
549*0Sstevel@tonic-gate 
550*0Sstevel@tonic-gate void
551*0Sstevel@tonic-gate prgregset_n_to_32(const prgreg_t *src, prgreg32_t *dst)
552*0Sstevel@tonic-gate {
553*0Sstevel@tonic-gate #ifdef __amd64
554*0Sstevel@tonic-gate 	(void) memset(dst, 0, NPRGREG32 * sizeof (prgreg32_t));
555*0Sstevel@tonic-gate 	dst[GS] = src[REG_GS];
556*0Sstevel@tonic-gate 	dst[FS] = src[REG_FS];
557*0Sstevel@tonic-gate 	dst[DS] = src[REG_DS];
558*0Sstevel@tonic-gate 	dst[ES] = src[REG_ES];
559*0Sstevel@tonic-gate 	dst[EDI] = src[REG_RDI];
560*0Sstevel@tonic-gate 	dst[ESI] = src[REG_RSI];
561*0Sstevel@tonic-gate 	dst[EBP] = src[REG_RBP];
562*0Sstevel@tonic-gate 	dst[EBX] = src[REG_RBX];
563*0Sstevel@tonic-gate 	dst[EDX] = src[REG_RDX];
564*0Sstevel@tonic-gate 	dst[ECX] = src[REG_RCX];
565*0Sstevel@tonic-gate 	dst[EAX] = src[REG_RAX];
566*0Sstevel@tonic-gate 	dst[TRAPNO] = src[REG_TRAPNO];
567*0Sstevel@tonic-gate 	dst[ERR] = src[REG_ERR];
568*0Sstevel@tonic-gate 	dst[EIP] = src[REG_RIP];
569*0Sstevel@tonic-gate 	dst[CS] = src[REG_CS];
570*0Sstevel@tonic-gate 	dst[EFL] = src[REG_RFL];
571*0Sstevel@tonic-gate 	dst[UESP] = src[REG_RSP];
572*0Sstevel@tonic-gate 	dst[SS] = src[REG_SS];
573*0Sstevel@tonic-gate #else
574*0Sstevel@tonic-gate 	int i;
575*0Sstevel@tonic-gate 
576*0Sstevel@tonic-gate 	for (i = 0; i < NPRGREG; i++)
577*0Sstevel@tonic-gate 		dst[i] = (prgreg32_t)src[i];
578*0Sstevel@tonic-gate #endif
579*0Sstevel@tonic-gate }
580*0Sstevel@tonic-gate 
581*0Sstevel@tonic-gate void
582*0Sstevel@tonic-gate prfpregset_n_to_32(const prfpregset_t *src, prfpregset32_t *dst)
583*0Sstevel@tonic-gate {
584*0Sstevel@tonic-gate #if defined(__sparc)
585*0Sstevel@tonic-gate 	int i;
586*0Sstevel@tonic-gate 
587*0Sstevel@tonic-gate 	(void) memset(dst, 0, sizeof (prfpregset32_t));
588*0Sstevel@tonic-gate 
589*0Sstevel@tonic-gate 	for (i = 0; i < 32; i++)
590*0Sstevel@tonic-gate 		dst->pr_fr.pr_regs[i] = src->pr_fr.pr_regs[i];
591*0Sstevel@tonic-gate 
592*0Sstevel@tonic-gate 	dst->pr_filler = src->pr_filler;
593*0Sstevel@tonic-gate 	dst->pr_fsr = src->pr_fsr;
594*0Sstevel@tonic-gate 	dst->pr_q_entrysize = src->pr_q_entrysize;
595*0Sstevel@tonic-gate 	dst->pr_en = src->pr_en;
596*0Sstevel@tonic-gate 
597*0Sstevel@tonic-gate #elif defined(__amd64)
598*0Sstevel@tonic-gate 
599*0Sstevel@tonic-gate 	struct _fpstate32 *dst32 = (struct _fpstate32 *)dst;
600*0Sstevel@tonic-gate 	struct fpchip_state *src64 = (struct fpchip_state *)src;
601*0Sstevel@tonic-gate 	uint32_t top;
602*0Sstevel@tonic-gate 	int i;
603*0Sstevel@tonic-gate 
604*0Sstevel@tonic-gate 	(void) memcpy(dst32->_st, src64->st, sizeof (dst32->_st));
605*0Sstevel@tonic-gate 	(void) memcpy(dst32->xmm, src64->xmm, sizeof (dst32->xmm));
606*0Sstevel@tonic-gate 	dst32->cw = src64->cw;
607*0Sstevel@tonic-gate 	dst32->sw = src64->sw;
608*0Sstevel@tonic-gate 	dst32->ipoff = (unsigned int)src64->rip;
609*0Sstevel@tonic-gate 	dst32->cssel = 0;
610*0Sstevel@tonic-gate 	dst32->dataoff = (unsigned int)src64->rdp;
611*0Sstevel@tonic-gate 	dst32->datasel = 0;
612*0Sstevel@tonic-gate 	dst32->status = src64->status;
613*0Sstevel@tonic-gate 	dst32->mxcsr = src64->mxcsr;
614*0Sstevel@tonic-gate 	dst32->xstatus = src64->xstatus;
615*0Sstevel@tonic-gate 
616*0Sstevel@tonic-gate 	/*
617*0Sstevel@tonic-gate 	 * AMD64 stores the tag in a compressed form. It is
618*0Sstevel@tonic-gate 	 * necessary to extract the original 2-bit tag value.
619*0Sstevel@tonic-gate 	 * See AMD64 Architecture Programmer's Manual Volume 2:
620*0Sstevel@tonic-gate 	 * System Programming, Chapter 11.
621*0Sstevel@tonic-gate 	 */
622*0Sstevel@tonic-gate 
623*0Sstevel@tonic-gate 	top = (src64->sw & FPS_TOP) >> 11;
624*0Sstevel@tonic-gate 	dst32->tag = 0;
625*0Sstevel@tonic-gate 	for (i = 0; i < 8; i++) {
626*0Sstevel@tonic-gate 		/*
627*0Sstevel@tonic-gate 		 * Recall that we need to use the current TOP-of-stack value to
628*0Sstevel@tonic-gate 		 * associate the _st[] index back to a physical register number,
629*0Sstevel@tonic-gate 		 * since tag word indices are physical register numbers.  Then
630*0Sstevel@tonic-gate 		 * to get the tag value, we shift over two bits for each tag
631*0Sstevel@tonic-gate 		 * index, and then grab the bottom two bits.
632*0Sstevel@tonic-gate 		 */
633*0Sstevel@tonic-gate 		uint_t tag_index = (i + top) & 7;
634*0Sstevel@tonic-gate 		uint_t tag_fctw = (src64->fctw >> tag_index) & 1;
635*0Sstevel@tonic-gate 		uint_t tag_value;
636*0Sstevel@tonic-gate 		uint_t exp;
637*0Sstevel@tonic-gate 
638*0Sstevel@tonic-gate 		/*
639*0Sstevel@tonic-gate 		 * Union for overlaying _fpreg structure on to quad-precision
640*0Sstevel@tonic-gate 		 * floating-point value (long double).
641*0Sstevel@tonic-gate 		 */
642*0Sstevel@tonic-gate 		union {
643*0Sstevel@tonic-gate 			struct _fpreg reg;
644*0Sstevel@tonic-gate 			long double ld;
645*0Sstevel@tonic-gate 		} fpru;
646*0Sstevel@tonic-gate 
647*0Sstevel@tonic-gate 		fpru.ld = src64->st[i].__fpr_pad._q;
648*0Sstevel@tonic-gate 		exp = fpru.reg.exponent & 0x7fff;
649*0Sstevel@tonic-gate 
650*0Sstevel@tonic-gate 		if (tag_fctw == 0) {
651*0Sstevel@tonic-gate 			tag_value = 3; /* empty */
652*0Sstevel@tonic-gate 		} else if (exp == 0) {
653*0Sstevel@tonic-gate 			if (fpru.reg.significand[0] == 0 &&
654*0Sstevel@tonic-gate 			    fpru.reg.significand[1] == 0 &&
655*0Sstevel@tonic-gate 			    fpru.reg.significand[2] == 0 &&
656*0Sstevel@tonic-gate 			    fpru.reg.significand[3] == 0)
657*0Sstevel@tonic-gate 				tag_value = 1; /* zero */
658*0Sstevel@tonic-gate 			else
659*0Sstevel@tonic-gate 				tag_value = 2; /* special: denormal */
660*0Sstevel@tonic-gate 		} else if (exp == 0x7fff) {
661*0Sstevel@tonic-gate 			tag_value = 2; /* special: infinity or NaN */
662*0Sstevel@tonic-gate 		} else if (fpru.reg.significand[3] & 0x8000) {
663*0Sstevel@tonic-gate 			tag_value = 0; /* valid */
664*0Sstevel@tonic-gate 		} else {
665*0Sstevel@tonic-gate 			tag_value = 2; /* special: unnormal */
666*0Sstevel@tonic-gate 		}
667*0Sstevel@tonic-gate 		dst32->tag |= tag_value << (tag_index * 2);
668*0Sstevel@tonic-gate 	}
669*0Sstevel@tonic-gate #else
670*0Sstevel@tonic-gate #error "unrecognized ISA"
671*0Sstevel@tonic-gate #endif
672*0Sstevel@tonic-gate }
673*0Sstevel@tonic-gate 
674*0Sstevel@tonic-gate void
675*0Sstevel@tonic-gate lwpstatus_n_to_32(const lwpstatus_t *src, lwpstatus32_t *dst)
676*0Sstevel@tonic-gate {
677*0Sstevel@tonic-gate 	int i;
678*0Sstevel@tonic-gate 
679*0Sstevel@tonic-gate 	dst->pr_flags = src->pr_flags;
680*0Sstevel@tonic-gate 	dst->pr_lwpid = src->pr_lwpid;
681*0Sstevel@tonic-gate 	dst->pr_why = src->pr_why;
682*0Sstevel@tonic-gate 	dst->pr_what = src->pr_what;
683*0Sstevel@tonic-gate 	dst->pr_cursig = src->pr_cursig;
684*0Sstevel@tonic-gate 
685*0Sstevel@tonic-gate 	siginfo_n_to_32(&src->pr_info, &dst->pr_info);
686*0Sstevel@tonic-gate 
687*0Sstevel@tonic-gate 	dst->pr_lwppend = src->pr_lwppend;
688*0Sstevel@tonic-gate 	dst->pr_lwphold = src->pr_lwphold;
689*0Sstevel@tonic-gate 
690*0Sstevel@tonic-gate 	sigaction_n_to_32(&src->pr_action, &dst->pr_action);
691*0Sstevel@tonic-gate 	stack_n_to_32(&src->pr_altstack, &dst->pr_altstack);
692*0Sstevel@tonic-gate 
693*0Sstevel@tonic-gate 	dst->pr_oldcontext = (caddr32_t)src->pr_oldcontext;
694*0Sstevel@tonic-gate 	dst->pr_syscall = src->pr_syscall;
695*0Sstevel@tonic-gate 	dst->pr_nsysarg = src->pr_nsysarg;
696*0Sstevel@tonic-gate 	dst->pr_errno = src->pr_errno;
697*0Sstevel@tonic-gate 
698*0Sstevel@tonic-gate 	for (i = 0; i < PRSYSARGS; i++)
699*0Sstevel@tonic-gate 		dst->pr_sysarg[i] = (int32_t)src->pr_sysarg[i];
700*0Sstevel@tonic-gate 
701*0Sstevel@tonic-gate 	dst->pr_rval1 = (int32_t)src->pr_rval1;
702*0Sstevel@tonic-gate 	dst->pr_rval2 = (int32_t)src->pr_rval2;
703*0Sstevel@tonic-gate 
704*0Sstevel@tonic-gate 	(void) memcpy(&dst->pr_clname[0], &src->pr_clname[0], PRCLSZ);
705*0Sstevel@tonic-gate 	timestruc_n_to_32(&src->pr_tstamp, &dst->pr_tstamp);
706*0Sstevel@tonic-gate 
707*0Sstevel@tonic-gate 	dst->pr_ustack = (caddr32_t)src->pr_ustack;
708*0Sstevel@tonic-gate 	dst->pr_instr = src->pr_instr;
709*0Sstevel@tonic-gate 
710*0Sstevel@tonic-gate 	prgregset_n_to_32(src->pr_reg, dst->pr_reg);
711*0Sstevel@tonic-gate 	prfpregset_n_to_32(&src->pr_fpreg, &dst->pr_fpreg);
712*0Sstevel@tonic-gate }
713*0Sstevel@tonic-gate 
714*0Sstevel@tonic-gate void
715*0Sstevel@tonic-gate pstatus_n_to_32(const pstatus_t *src, pstatus32_t *dst)
716*0Sstevel@tonic-gate {
717*0Sstevel@tonic-gate 	dst->pr_flags = src->pr_flags;
718*0Sstevel@tonic-gate 	dst->pr_nlwp = src->pr_nlwp;
719*0Sstevel@tonic-gate 	dst->pr_nzomb = src->pr_nzomb;
720*0Sstevel@tonic-gate 	dst->pr_pid = (pid32_t)src->pr_pid;
721*0Sstevel@tonic-gate 	dst->pr_ppid = (pid32_t)src->pr_ppid;
722*0Sstevel@tonic-gate 	dst->pr_pgid = (pid32_t)src->pr_pgid;
723*0Sstevel@tonic-gate 	dst->pr_sid = (pid32_t)src->pr_sid;
724*0Sstevel@tonic-gate 	dst->pr_taskid = (id32_t)src->pr_taskid;
725*0Sstevel@tonic-gate 	dst->pr_projid = (id32_t)src->pr_projid;
726*0Sstevel@tonic-gate 	dst->pr_zoneid = (id32_t)src->pr_zoneid;
727*0Sstevel@tonic-gate 	dst->pr_aslwpid = (id32_t)src->pr_aslwpid;
728*0Sstevel@tonic-gate 	dst->pr_agentid = (id32_t)src->pr_agentid;
729*0Sstevel@tonic-gate 	dst->pr_sigpend = src->pr_sigpend;
730*0Sstevel@tonic-gate 	dst->pr_brkbase = (caddr32_t)src->pr_brkbase;
731*0Sstevel@tonic-gate 	dst->pr_brksize = (size32_t)src->pr_brksize;
732*0Sstevel@tonic-gate 	dst->pr_stkbase = (caddr32_t)src->pr_stkbase;
733*0Sstevel@tonic-gate 	dst->pr_stksize = (size32_t)src->pr_stksize;
734*0Sstevel@tonic-gate 
735*0Sstevel@tonic-gate 	timestruc_n_to_32(&src->pr_utime, &dst->pr_utime);
736*0Sstevel@tonic-gate 	timestruc_n_to_32(&src->pr_stime, &dst->pr_stime);
737*0Sstevel@tonic-gate 	timestruc_n_to_32(&src->pr_cutime, &dst->pr_cutime);
738*0Sstevel@tonic-gate 	timestruc_n_to_32(&src->pr_cstime, &dst->pr_cstime);
739*0Sstevel@tonic-gate 
740*0Sstevel@tonic-gate 	dst->pr_sigtrace = src->pr_sigtrace;
741*0Sstevel@tonic-gate 	dst->pr_flttrace = src->pr_flttrace;
742*0Sstevel@tonic-gate 	dst->pr_sysentry = src->pr_sysentry;
743*0Sstevel@tonic-gate 	dst->pr_sysexit = src->pr_sysexit;
744*0Sstevel@tonic-gate 	dst->pr_dmodel = src->pr_dmodel;
745*0Sstevel@tonic-gate 
746*0Sstevel@tonic-gate 	lwpstatus_n_to_32(&src->pr_lwp, &dst->pr_lwp);
747*0Sstevel@tonic-gate }
748*0Sstevel@tonic-gate 
749*0Sstevel@tonic-gate void
750*0Sstevel@tonic-gate lwpsinfo_n_to_32(const lwpsinfo_t *src, lwpsinfo32_t *dst)
751*0Sstevel@tonic-gate {
752*0Sstevel@tonic-gate 	dst->pr_flag = src->pr_flag;
753*0Sstevel@tonic-gate 	dst->pr_lwpid = (id32_t)src->pr_lwpid;
754*0Sstevel@tonic-gate 	dst->pr_addr = (caddr32_t)src->pr_addr;
755*0Sstevel@tonic-gate 	dst->pr_wchan = (caddr32_t)src->pr_wchan;
756*0Sstevel@tonic-gate 	dst->pr_stype = src->pr_stype;
757*0Sstevel@tonic-gate 	dst->pr_state = src->pr_state;
758*0Sstevel@tonic-gate 	dst->pr_sname = src->pr_sname;
759*0Sstevel@tonic-gate 	dst->pr_nice = src->pr_nice;
760*0Sstevel@tonic-gate 	dst->pr_syscall = src->pr_syscall;
761*0Sstevel@tonic-gate 	dst->pr_oldpri = src->pr_oldpri;
762*0Sstevel@tonic-gate 	dst->pr_cpu = src->pr_cpu;
763*0Sstevel@tonic-gate 	dst->pr_pri = src->pr_pri;
764*0Sstevel@tonic-gate 	dst->pr_pctcpu = src->pr_pctcpu;
765*0Sstevel@tonic-gate 
766*0Sstevel@tonic-gate 	timestruc_n_to_32(&src->pr_start, &dst->pr_start);
767*0Sstevel@tonic-gate 	timestruc_n_to_32(&src->pr_time, &dst->pr_time);
768*0Sstevel@tonic-gate 
769*0Sstevel@tonic-gate 	(void) memcpy(&dst->pr_clname[0], &src->pr_clname[0], PRCLSZ);
770*0Sstevel@tonic-gate 	(void) memcpy(&dst->pr_name[0], &src->pr_name[0], PRFNSZ);
771*0Sstevel@tonic-gate 
772*0Sstevel@tonic-gate 	dst->pr_onpro = src->pr_onpro;
773*0Sstevel@tonic-gate 	dst->pr_bindpro = src->pr_bindpro;
774*0Sstevel@tonic-gate 	dst->pr_bindpset = src->pr_bindpset;
775*0Sstevel@tonic-gate }
776*0Sstevel@tonic-gate 
777*0Sstevel@tonic-gate void
778*0Sstevel@tonic-gate psinfo_n_to_32(const psinfo_t *src, psinfo32_t *dst)
779*0Sstevel@tonic-gate {
780*0Sstevel@tonic-gate 	dst->pr_flag = src->pr_flag;
781*0Sstevel@tonic-gate 	dst->pr_nlwp = src->pr_nlwp;
782*0Sstevel@tonic-gate 	dst->pr_nzomb = src->pr_nzomb;
783*0Sstevel@tonic-gate 	dst->pr_pid = (pid32_t)src->pr_pid;
784*0Sstevel@tonic-gate 	dst->pr_pgid = (pid32_t)src->pr_pgid;
785*0Sstevel@tonic-gate 	dst->pr_sid = (pid32_t)src->pr_sid;
786*0Sstevel@tonic-gate 	dst->pr_taskid = (id32_t)src->pr_taskid;
787*0Sstevel@tonic-gate 	dst->pr_projid = (id32_t)src->pr_projid;
788*0Sstevel@tonic-gate 	dst->pr_zoneid = (id32_t)src->pr_zoneid;
789*0Sstevel@tonic-gate 	dst->pr_uid = (uid32_t)src->pr_uid;
790*0Sstevel@tonic-gate 	dst->pr_euid = (uid32_t)src->pr_euid;
791*0Sstevel@tonic-gate 	dst->pr_gid = (gid32_t)src->pr_gid;
792*0Sstevel@tonic-gate 	dst->pr_egid = (gid32_t)src->pr_egid;
793*0Sstevel@tonic-gate 	dst->pr_addr = (caddr32_t)src->pr_addr;
794*0Sstevel@tonic-gate 	dst->pr_size = (size32_t)src->pr_size;
795*0Sstevel@tonic-gate 	dst->pr_rssize = (size32_t)src->pr_rssize;
796*0Sstevel@tonic-gate 
797*0Sstevel@tonic-gate 	dst->pr_ttydev = prcmpldev(src->pr_ttydev);
798*0Sstevel@tonic-gate 
799*0Sstevel@tonic-gate 	dst->pr_pctcpu = src->pr_pctcpu;
800*0Sstevel@tonic-gate 	dst->pr_pctmem = src->pr_pctmem;
801*0Sstevel@tonic-gate 
802*0Sstevel@tonic-gate 	timestruc_n_to_32(&src->pr_start, &dst->pr_start);
803*0Sstevel@tonic-gate 	timestruc_n_to_32(&src->pr_time, &dst->pr_time);
804*0Sstevel@tonic-gate 	timestruc_n_to_32(&src->pr_ctime, &dst->pr_ctime);
805*0Sstevel@tonic-gate 
806*0Sstevel@tonic-gate 	(void) memcpy(&dst->pr_fname[0], &src->pr_fname[0], PRFNSZ);
807*0Sstevel@tonic-gate 	(void) memcpy(&dst->pr_psargs[0], &src->pr_psargs[0], PRARGSZ);
808*0Sstevel@tonic-gate 
809*0Sstevel@tonic-gate 	dst->pr_wstat = src->pr_wstat;
810*0Sstevel@tonic-gate 	dst->pr_argc = src->pr_argc;
811*0Sstevel@tonic-gate 	dst->pr_argv = (caddr32_t)src->pr_argv;
812*0Sstevel@tonic-gate 	dst->pr_envp = (caddr32_t)src->pr_envp;
813*0Sstevel@tonic-gate 	dst->pr_dmodel = src->pr_dmodel;
814*0Sstevel@tonic-gate 
815*0Sstevel@tonic-gate 	lwpsinfo_n_to_32(&src->pr_lwp, &dst->pr_lwp);
816*0Sstevel@tonic-gate }
817*0Sstevel@tonic-gate 
818*0Sstevel@tonic-gate 
819*0Sstevel@tonic-gate #endif	/* _LP64 */
820