[openssl-dev] MacOS defaults?
Jeffrey Walton
noloader at gmail.com
Mon Mar 7 21:48:23 UTC 2016
On Mon, Mar 7, 2016 at 3:57 PM, Jeffrey Walton <noloader at gmail.com> wrote:
> On Sun, Mar 6, 2016 at 6:05 PM, Andy Polyakov <appro at openssl.org> wrote:
>>>> Hmm. So why do I see this on my macbook?
>>>>
>>>> $ arch
>>>> i386
>>>
>>> Try "uname -m"
>>
>> This is not reliable. Because it must have changed recently, it used to
>> be i386 even on 64-bit systems. sysctl -n hw.optional.x86_64 is the way
>> to go, it's right there in ./config...
>
> ...
> However, there are two interesting ones on the PowerMac:
>
> $ sysctl -A 2>/dev/null | grep hw | egrep 'machine|64'
> hw.machine = Power Macintosh
> hw.physmem = 2147483648
> hw.l2settings = 2147483648
> hw.optional.64bitops: 1
> hw.cpu64bit_capable: 1
It looks like Apple is using either hw.optional.64bitops or
hw.optional.x86_64
(http://opensource.apple.com/source/xnu/xnu-1504.7.4/tools/tests/xnu_quick_test/misc.c?txt):
/*
* Gets the bit'ed-ness of the current host. Returns either 32 or 64.
* This get the hardware capability, but does not tell us whether this
* binary is executing in 64 bit or 32 bit mode. Check sizeof long
* or pointer to determine that.
*/
int get_bits()
{
int my_err, buf;
size_t len = 0;
int rval = 32;
/*
* On 32-bit systems the sysctls 64bitops and x86_64 don't
* even exists, so if we don't find them then we assume
* a 32-bit system.
*/
/* Check for PPC 64 */
if ((my_err = sysctlbyname("hw.optional.64bitops", NULL, &len, NULL,
0))) goto x86_64check; /* Request size */
if (len > sizeof(buf)) goto x86_64check;
if ((my_err = sysctlbyname("hw.optional.64bitops", &buf, &len, NULL,
0))) goto x86_64check; /* Copy value out from kernel */
if (buf == 1) rval = 64;
goto finished;
x86_64check:
/* Check for x86_64 */
if ((my_err = sysctlbyname("hw.optional.x86_64", NULL, &len, NULL,
0))) goto finished; /* Request size */
if (len > sizeof(buf)) goto finished;
if ((my_err = sysctlbyname("hw.optional.x86_64", &buf, &len, NULL,
0))) goto finished; /* Copy value out from kernel */
if (buf == 1) rval = 64;
finished:
return rval;
}
More information about the openssl-dev
mailing list