9804 hal-set-property should support --direct option
[unleashed.git] / usr / src / cmd / sgs / libconv / common / arch.c
blob61838245752e555129e6f9631558ceedd71f7673
1 /*
2 * CDDL HEADER START
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]
19 * CDDL HEADER END
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
26 #pragma ident "%Z%%M% %I% %E% SMI"
28 #include <stdio.h>
29 #include <unistd.h>
30 #include <string.h>
31 #include <sys/systeminfo.h>
32 #include "_conv.h"
33 #include "arch_msg.h"
36 * Determine if the 32-bit or 64-bit kernel is running.
37 * Return the corresponding EI_CLASS constant.
39 int
40 conv_sys_eclass(void)
42 char buf[BUFSIZ];
45 * SI_ISALIST will return -1 on pre-2.6 machines,
46 * which is fine - it can't be a 64-bit kernel.
48 if (sysinfo(SI_ISALIST, buf, BUFSIZ) == -1)
49 return (ELFCLASS32);
51 if ((strstr(buf, MSG_ORIG(MSG_ARCH_SPARCV9)) != NULL) ||
52 (strstr(buf, MSG_ORIG(MSG_ARCH_AMD64)) != NULL))
53 return (ELFCLASS64);
55 return (ELFCLASS32);
58 #if defined(_LP64)
59 /* ARGSUSED */
60 uchar_t
61 conv_check_native(char **argv, char **envp)
63 /* 64-bit version does nothing */
64 return (ELFCLASS64);
67 #else
70 * Wrapper for isaexec(3c) that allows disabling 64-bit counterpart execution
71 * via setting LD_NOEXEC64=yes.
73 * The only callers are 32-bit sgs applications. These applications determine
74 * whether a 64-bit counterpart is available via this routine, and if not,
75 * control is passed back to the caller, who will then complete execution.
76 * Note, isaexec() will eventually fall through to looking for a 32-bit
77 * counterpart (ie. sparcv7, or sparc), but as none of the callers provide these
78 * counterparts, we simply return to the caller.
80 uchar_t
81 conv_check_native(char **argv, char **envp)
83 const char *str;
86 * LD_NOEXEC_64 defined in the environment prevents the isaexec() call.
87 * This is used by the test suite to test 32-bit support libraries.
89 if (((str = getenv(MSG_ORIG(MSG_LD_NOEXEC64))) != NULL) && *str)
90 return (ELFCLASS32);
92 if ((str = getexecname()) != NULL)
93 (void) isaexec(str, argv, envp);
94 return (ELFCLASS32);
96 #endif