]>
git.saurik.com Git - apple/libc.git/blob - gen/OSSystemInfo.c
42f1691f6814342099338fe5db0574c966816b22
2 * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
26 #include <sys/types.h>
27 #include <sys/sysctl.h>
30 static int osi_oid
[2] = {-1, 0};
33 OSSystemInfo(int selector
, unsigned long long *resultp
)
39 * Check cached OID, look it up if we haven't already.
41 * NB. Whilst this isn't strictly thread safe, since the
42 * result as written by any thread will be the same
43 * there is no actual risk of corruption.
45 if (osi_oid
[0] == -1) {
47 if (sysctlnametomib("hw.systeminfo", &osi_oid
, &size
) ||
58 size
= sizeof(*resultp
);
59 if (sysctl(oid
, 3, resultp
, &size
, NULL
, 0) ||
60 (size
!= sizeof(*resultp
)))