1 | /* |
---|
2 | * Copyright (c) 1992-1998 Michael A. Cooper. |
---|
3 | * This software may be freely used and distributed provided it is not |
---|
4 | * sold for profit or used in part or in whole for commercial gain |
---|
5 | * without prior written agreement, and the author is credited |
---|
6 | * appropriately. |
---|
7 | */ |
---|
8 | |
---|
9 | #ifndef lint |
---|
10 | static char *RCSid = "$Revision: 1.1.1.3 $"; |
---|
11 | #endif |
---|
12 | |
---|
13 | /* |
---|
14 | * Get cpu type information |
---|
15 | */ |
---|
16 | |
---|
17 | #include "defs.h" |
---|
18 | |
---|
19 | /* |
---|
20 | * Get cpu type using sysinfo(SI_ISALIST) system call. |
---|
21 | */ |
---|
22 | extern char *GetCpuTypeIsalist() |
---|
23 | { |
---|
24 | static char Buff[128]; |
---|
25 | register char *cp; |
---|
26 | |
---|
27 | #if defined(SI_ISALIST) |
---|
28 | if (Buff[0]) |
---|
29 | return(Buff); |
---|
30 | |
---|
31 | if (sysinfo(SI_ISALIST, Buff, sizeof(Buff)) < 0) |
---|
32 | return((char *) NULL); |
---|
33 | |
---|
34 | /* We want only the first argument */ |
---|
35 | if (cp = strchr(Buff, ' ')) |
---|
36 | *cp = CNULL; |
---|
37 | #endif /* SI_ISALIST */ |
---|
38 | |
---|
39 | return( (Buff[0]) ? Buff : (char *) NULL ); |
---|
40 | } |
---|
41 | |
---|
42 | /* |
---|
43 | * Get cpu type using sysinfo() system call. |
---|
44 | */ |
---|
45 | extern char *GetCpuTypeSysinfo() |
---|
46 | { |
---|
47 | static char buff[128]; |
---|
48 | |
---|
49 | #if defined(HAVE_SYSINFO) |
---|
50 | if (buff[0]) |
---|
51 | return(buff); |
---|
52 | |
---|
53 | if (sysinfo(SI_ARCHITECTURE, buff, sizeof(buff)) < 0) |
---|
54 | return((char *) NULL); |
---|
55 | #endif /* HAVE_SYSINFO */ |
---|
56 | |
---|
57 | return( (buff[0]) ? buff : (char *) NULL ); |
---|
58 | } |
---|
59 | |
---|
60 | /* |
---|
61 | * Use predefined CPU_NAME. |
---|
62 | */ |
---|
63 | extern char *GetCpuTypeDef() |
---|
64 | { |
---|
65 | #if defined(CPU_NAME) |
---|
66 | return(CPU_NAME); |
---|
67 | #else /* !CPU_NAME */ |
---|
68 | return((char *)NULL); |
---|
69 | #endif /* CPU_NAME */ |
---|
70 | } |
---|
71 | |
---|
72 | /* |
---|
73 | * Run Test Files |
---|
74 | */ |
---|
75 | extern char *GetCpuTypeTest() |
---|
76 | { |
---|
77 | extern char *CPUFiles[]; |
---|
78 | |
---|
79 | return(RunTestFiles(CPUFiles)); |
---|
80 | } |
---|
81 | |
---|
82 | /* |
---|
83 | * Run Test Commands |
---|
84 | */ |
---|
85 | extern char *GetCpuTypeCmds() |
---|
86 | { |
---|
87 | extern char *AppArchCmds[]; |
---|
88 | |
---|
89 | return(RunCmds(AppArchCmds, FALSE)); |
---|
90 | } |
---|
91 | |
---|
92 | /* |
---|
93 | * Get CPU type |
---|
94 | */ |
---|
95 | extern char *GetCpuType() |
---|
96 | { |
---|
97 | extern PSI_t GetCpuTypePSI[]; |
---|
98 | static char *Str = NULL; |
---|
99 | |
---|
100 | if (Str) |
---|
101 | return(Str); |
---|
102 | |
---|
103 | return(Str = PSIquery(GetCpuTypePSI)); |
---|
104 | } |
---|
105 | |
---|
106 | /* |
---|
107 | * Use sysconf() to find number of CPU's. |
---|
108 | */ |
---|
109 | extern char *GetNumCpuSysconf() |
---|
110 | { |
---|
111 | int Num = -1; |
---|
112 | static char *NumStr = NULL; |
---|
113 | |
---|
114 | if (NumStr) |
---|
115 | return(NumStr); |
---|
116 | |
---|
117 | #if defined(_SC_NPROCESSORS_CONF) |
---|
118 | Num = (int) sysconf(_SC_NPROCESSORS_CONF); |
---|
119 | if (Num >= 0) { |
---|
120 | NumStr = itoa(Num); |
---|
121 | if (NumStr) |
---|
122 | NumStr = strdup(NumStr); |
---|
123 | } |
---|
124 | #endif /* _SC_NPROCESSORS_CONF */ |
---|
125 | |
---|
126 | return(NumStr); |
---|
127 | } |
---|
128 | |
---|
129 | /* |
---|
130 | * Get number of CPU's |
---|
131 | */ |
---|
132 | extern char *GetNumCpu() |
---|
133 | { |
---|
134 | extern PSI_t GetNumCpuPSI[]; |
---|
135 | static char *Str = NULL; |
---|
136 | |
---|
137 | if (Str) |
---|
138 | return(Str); |
---|
139 | |
---|
140 | return(Str = PSIquery(GetNumCpuPSI)); |
---|
141 | } |
---|