Imported Upstream version 4.6.0
[debian/atlc] / tests / try_hpux.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 HP-UX machine. */
26
27 #include "config.h"
28
29
30 #ifdef HAVE_SYS_PARAM_H   /* This looks for header files that should be  */
31 #ifdef HAVE_SYS_PSTAT_H   /* present on HP-UX. If they are all present */
32 #ifdef HAVE_STDIO_H       /* it does ***not** necessarily mean it's HP-UX */
33 #ifdef HAVE_STDLIB_H      /* but it will define some variables that we */
34 #ifdef HAVE_SYS_TYPES_H   /* later check for, to confirm it's HP-UX */
35 #ifdef HAVE_STRING_H
36 #ifdef HAVE_UNISTD_H 
37 #ifdef HAVE_SYS_UTSNAME_H
38
39 #include <sys/param.h>    /* Include the header files */
40 #include <sys/pstat.h>
41 #include <stdio.h>
42 #include <stdlib.h>
43 #include <sys/types.h>
44 #include <string.h>
45 #include <unistd.h>
46 #include <sys/unistd.h>
47 #include <sys/utsname.h>
48
49 extern long _CPU_REVISION;
50 extern long _FPU_MODEL;
51
52 #endif
53 #endif
54 #endif
55 #endif
56 #endif  
57 #endif
58 #endif
59 #endif  /* End of including header files likely to be on HP-UX system */
60
61 #define BYTES_PER_MB  1048576
62
63 #include "defs.h"
64 int try_hpux(struct computer_data *data)
65 {
66
67 #ifdef HAVE_SYS_PARAM_H 
68 #ifdef HAVE_SYS_PSTAT_H
69 #ifdef HAVE_STDIO_H
70 #ifdef HAVE_STDLIB_H
71 #ifdef HAVE_SYS_TYPES_H
72 #ifdef HAVE_STRING_H
73 #ifdef HAVE_UNISTD_H 
74 #ifdef HAVE_SYS_UTSNAME_H
75
76
77 #ifdef HAVE_PSTAT_GETDYNAMIC /* Check for some HP-UX specific bits now */
78 #ifdef HAVE_PSTAT_GETPROCESSOR
79 #ifdef HAVE_PSTAT
80
81   long max_CPUs=0, CPUs_online=0;
82   double clock_speed_in_Hz, ram, scclktick;
83
84   struct pst_dynamic dynamic_hpux;
85   struct pst_static  static_hpux;
86   struct pst_processor psp;
87
88   /* Obtain the maximum number of CPUs supported on the HP-UX system */
89
90   pstat_getdynamic(&dynamic_hpux,(size_t) sizeof(dynamic_hpux),1,0);
91   max_CPUs=(long) dynamic_hpux.psd_max_proc_cnt;
92   if(max_CPUs >=1 )
93     sprintf(data->max_cpus,"%ld",max_CPUs);
94
95   /* Obtain the number of CPUs online on the HP-UXs system */
96   CPUs_online=(long) dynamic_hpux.psd_proc_cnt; ;
97   if( CPUs_online >= 1 )
98     sprintf(data->cpus,"%ld",CPUs_online);
99
100   /* Obtain the of CPU and FPU on the HP-UX box */
101   
102   sprintf(data->cpu_type,"%ld",_CPU_REVISION);
103   sprintf(data->fpu_type,"%ld",_FPU_MODEL);
104
105   /* Obtain the RAM on the HP-UX system */
106
107   pstat_getstatic(&static_hpux,(size_t) sizeof(static_hpux),1,0);
108   ram=(double) static_hpux.physical_memory;
109   ram*=(double) static_hpux.page_size;
110   ram=ram/(double) BYTES_PER_MB;
111   sprintf(data->memory,"%ld",(long) (0.5+ram));
112
113
114   /* Obtain the processor speed */
115   pstat_getprocessor(&psp, sizeof(psp), 1, 0);
116   scclktick=(double) sysconf(_SC_CLK_TCK);
117   clock_speed_in_Hz = ((double) psp.psp_iticksperclktick) * scclktick;
118   if(clock_speed_in_Hz > 1)
119     sprintf(data->mhz,"%.1f",clock_speed_in_Hz/1000000);
120   return(0);
121 #endif
122 #endif
123 #endif
124 #endif
125 #endif
126 #endif
127 #endif
128 #endif
129 #endif
130 #endif
131 #endif
132   return(1);
133 }