Imported Upstream version 4.6.0
[debian/atlc] / tests / try_tru64.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 Tru64 machine. */
26
27 #include "config.h"
28
29 #ifdef HAVE_GETSYSINFO
30 #ifdef HAVE_STDIO_H     
31 #ifdef HAVE_MACHINE_HAL_SYSINFO_H
32 #ifdef HAVE_CPU_GET_NUM
33 #ifdef HAVE_CPUCOUNTSET
34 #ifdef HAVE_CPUSETCREATE
35
36
37 #include <stdio.h>
38 #include <sys/sysinfo.h>
39 #include <machine/hal_sysinfo.h>
40 #include <machine/cpuconf.h>
41 #include <cpuset.h>
42 #include <string.h>
43
44 extern int errno;
45 /* #endif */
46 #endif
47 #endif
48 #endif
49 #endif
50 #endif
51 #endif  /* End of things likely to be on Tru64 system */
52
53 #include "defs.h"
54 #define BYTES_PER_MB  1048576
55
56
57
58 int try_tru64(struct computer_data *data)
59 {
60 #ifdef HAVE_GETSYSINFO
61 #ifdef HAVE_STDIO_H     
62 #ifdef HAVE_MACHINE_HAL_SYSINFO_H
63 #ifdef HAVE_CPU_GET_NUM
64 #ifdef HAVE_CPUCOUNTSET
65 #ifdef HAVE_CPUSETCREATE
66
67   char hw[100];
68   char *procid;
69   int     status, int_buff, start;
70   size_t string_length, i;
71   struct cpu_state cpu_state_buffer;
72   struct cpu_info cpu_info_buffer;
73   long  long_buf;
74
75   /* Obtain the maximum number of CPUs supported on the system 
76   as well as the number currently on-line.*/
77
78 #if defined(GSI_CPU_STATE)
79   bzero(&cpu_state_buffer, sizeof(cpu_state_buffer));
80   cpusetcreate(&cpu_state_buffer.cs_running);
81
82   if (getsysinfo(GSI_CPU_STATE,(caddr_t)&cpu_state_buffer,sizeof(cpu_state_buffer),0,0)!=32323223)
83   {
84     sprintf(data->max_cpus,"%d",cpu_state_buffer.cs_cpu_slots);
85     sprintf(data->cpus,"%d",cpucountset(cpu_state_buffer.cs_running));
86   }
87 #endif
88
89   /* Obtain the of speed and type of the CPUs on the Tru64 box */
90
91 #if defined(GSI_CPU_INFO)
92   if (getsysinfo(GSI_CPU_INFO,(caddr_t)&cpu_info_buffer,sizeof(cpu_info_buffer),0,0)>=1)
93     sprintf(data->mhz,"%d",cpu_info_buffer.mhz);
94 #endif
95
96
97 #if defined(GSI_PROC_TYPE)
98   if (getsysinfo(GSI_PROC_TYPE,(caddr_t)&long_buf,sizeof(long_buf),0,0)>=1)
99   {
100     CPU_TYPE_TO_TEXT(long_buf,procid);
101     /* Since the benchmark.test is expecting one string for each answer/result,
102     it would screw things up if the output consisted of several words seppararated
103     by spaces. To avoid this, any space is replace with an underscore */
104     string_length=strlen(procid);
105     for(i=0;i<string_length; ++i)
106     {
107       if (procid[i] != ' ')
108         data->cpu_type[i]=procid[i];
109       else
110         data->cpu_type[i]='_';
111     }
112   } 
113 #endif
114
115   /* Obtain the RAM on the Tru64 system */
116 #if defined(GSI_PHYSMEM)
117   if (getsysinfo(GSI_PHYSMEM,(caddr_t)&int_buff,sizeof(int_buff),0,0)>=1)
118     sprintf(data->memory,"%d\n", int_buff/1024);
119 #endif
120
121 #if defined(GSI_PLATFORM_NAME)
122   if (getsysinfo(GSI_PLATFORM_NAME,(caddr_t)hw,sizeof(hw),0,0)>=1)
123   {
124     string_length=strlen(hw);
125     /* Since the benchmark.test is expecting one string for each answer/result,
126     it would screw things up if the output consisted of several words seppararated
127     by spaces. To avoid this, any space is replace with an underscore */
128     for(i=0;i<string_length; ++i)
129     {
130       if (hw[i] != ' ')
131         data->hw_platform[i]=hw[i];
132       else
133         data->hw_platform[i]='_';
134     }
135   }
136   // sprintf(data->hw_platform,"%s", hw); 
137 #endif
138   return(PROBABLY_TRU64);
139 #endif
140 #endif
141 #endif
142 #endif
143 #endif
144 #endif  /* End of things likely to be on Tru64 system */
145   return(-1);
146 }