Imported Upstream version 4.6.0
[debian/atlc] / tests / try_solaris.c
1 /*
2 atlc - arbitrary transmission line calculator, for the analysis of
3 transmission lines are directional couplers. 
4
5 Copyright (C) 2002. Dr. David Kirkby, PhD (G8WRB).
6
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either package_version 2
10 of the License, or (at your option) any later package_version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
20 USA.
21
22 Dr. David Kirkby, e-mail drkirkby@ntlworld.com 
23
24 */
25 /* Try to get data. This will work only on a Solaris machine. */
26
27 #include "config.h"
28
29 #ifdef HAVE_SYS_PARAM_H     /* This looks for header files that should be     */
30 #ifdef HAVE_SYS_PROCESSOR_H /* present on Solaris. If they are all present    */
31 #ifdef HAVE_STDIO_H         /* it does ***not** necessarily mean it's Solaris */
32 #ifdef HAVE_STDLIB_H        /* but it will define some variables that we      */
33 #ifdef HAVE_SYS_TYPES_H     /* later check for, to confirm it's Solaris       */
34 #ifdef HAVE_STRING_H
35 #ifdef HAVE_SYS_UNISTD_H
36 #ifdef HAVE_UNISTD_H 
37 #ifdef HAVE_SYS_UTSNAME_H
38 #ifdef HAVE_SYS_SYSTEMINFO_H
39
40 #include <sys/param.h>    /* Include the header files */
41 #include <sys/processor.h>    /* Include the header files */
42 #include <stdio.h>
43 #include <stdlib.h>
44 #include <sys/types.h>
45 #include <string.h>
46 #include <unistd.h>
47 #include <sys/unistd.h>
48 #include <sys/utsname.h>
49 #include <sys/systeminfo.h>
50
51 #endif
52 #endif
53 #endif
54 #endif
55 #endif
56 #endif
57 #endif
58 #endif  
59 #endif
60 #endif  /* End of including header files likely to be on Solaris system */
61
62 #include "defs.h"
63
64 int try_solaris(struct computer_data *data)
65
66 {
67 #ifdef HAVE_SYS_SYSTEMINFO_H
68 #ifdef HAVE_SYS_PARAM_H     
69 #ifdef HAVE_SYS_PROCESSOR_H 
70 #ifdef HAVE_STDIO_H         
71 #ifdef HAVE_STDLIB_H       
72 #ifdef HAVE_SYS_TYPES_H   
73 #ifdef HAVE_STRING_H
74 #ifdef HAVE_SYS_UNISTD_H
75 #ifdef HAVE_UNISTD_H 
76 #ifdef HAVE_SYS_UTSNAME_H
77 #ifdef HAVE_SYSCONF
78
79 #ifdef _SC_AVPHYS_PAGES   
80
81   int clock_speed_in_MHz;
82 #ifdef HAVE_PROCESSOR_INFO
83   processor_info_t infop;
84 #endif
85
86 #ifdef _SC_NPROCESSORS_MAX
87   long max_CPUs=0;
88
89   /* Obtain the maximum number of CPUs supported on the Solaris system */
90   max_CPUs=0;
91   max_CPUs=(long) sysconf(_SC_NPROCESSORS_MAX);
92   if(max_CPUs >=1 )
93     sprintf(data->max_cpus,"%ld",max_CPUs);
94 #endif
95
96 #ifdef HAVE_PROCESSOR_INFO
97   /* Obtain the of CPU and FPU on the Solaris box */
98   if( processor_info((processorid_t) 0, &infop) == 0)
99   {
100     strcpy(data->cpu_type,infop.pi_processor_type);
101     strcpy(data->fpu_type,infop.pi_fputypes);
102     clock_speed_in_MHz=(int) infop.pi_clock;
103     if(clock_speed_in_MHz > 1)
104       sprintf(data->mhz,"%d",clock_speed_in_MHz);
105   }
106 #endif
107
108   /* Obtain the Platform */
109 #ifdef SI_PLATFORM
110   sysinfo(SI_PLATFORM,data->hw_platform,MAX_SIZE);
111 #endif
112
113   /* Obtain the manufacturer */
114 #ifdef SI_HW_PROVIDER
115   sysinfo(SI_HW_PROVIDER,data->hw_provider,MAX_SIZE);
116 #endif
117
118   return(PROBABLY_SOLARIS);
119
120 #endif
121 #endif
122 #endif
123 #endif
124 #endif
125 #endif
126 #endif
127 #endif
128 #endif
129 #endif
130 #endif
131 #else  
132   return(-1);
133 #endif
134 }