4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
28 * This preload library must be applied to forth after libthread is
29 * folded into libc because forth/tokenize.exe is not ABI compliant; it
30 * uses all of the %g registers, including %g7, for its internal purposes.
31 * This preload library interposes on all of the external calls made
32 * from forth/tokenize.exe and, assuming that forth is single-threaded,
33 * sets %g7 properly for use inside libc and restores it to forth's
34 * use on return from the interposed-upon function.
113 typedef long (*realfunc_t
)(long, long, long, long, long, long);
126 { "cfgetospeed", 0 },
130 { "exit_handler", 0 },
194 #define RTLD_NEXT (void *)-1
195 extern void *dlsym(void *handle
, const char *name
);
197 static long global_g7
= -1;
206 callfunc(struct intpose
*ip
,
207 long a0
, long a1
, long a2
, long a3
, long a4
, long a5
)
219 if ((realfunc
= ip
->realfunc
) == 0)
220 ip
->realfunc
= realfunc
=
221 (realfunc_t
)dlsym(RTLD_NEXT
, ip
->fname
);
222 rv
= realfunc(a0
, a1
, a2
, a3
, a4
, a5
);
228 #define ipose(func) \
230 func(long a0, long a1, long a2, long a3, long a4, long a5) \
232 return (callfunc(&intpose[ix_##func], a0, a1, a2, a3, a4, a5)); \