Imported Upstream version 4.6.0
[debian/atlc] / tests / try_bsd.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 IRIX machine. */
26
27 #include "config.h"
28
29 #ifdef HAVE_STDIO_H
30 #ifdef HAVE_STDLIB_H
31 #ifdef HAVE_SYS_TYPES_H
32 #ifdef HAVE_SYS_SYSCTL_H
33 #ifdef HAVE_SYSCTL
34
35 #include <stdio.h>
36 #include <stdlib.h>
37
38 /* On BSD 3.2 for SPARC, NGROUPS don't seem to be defined, but
39 it is on other systems. To be safe, the relavant header files
40 will only be included if NGROUPS is not defined */
41
42 #ifndef NGROUPS
43
44 #ifdef HAVE_SYS_PARAM_H
45 #include <sys/param.h>
46 #endif
47
48 #ifdef HAVE_SYS_SYSLIMITS_H
49 #include <sys/syslimits.h>
50 #endif
51
52 #endif /* End of ifndef NGROUPS */
53
54 #include <sys/types.h>
55 #include <sys/sysctl.h>
56
57 #endif
58 #endif
59 #endif
60 #endif
61 #endif
62
63 #include "defs.h"
64
65 int try_bsd(struct computer_data *data)
66 {
67 #ifdef HAVE_STDIO_H
68 #ifdef HAVE_STDLIB_H
69 #ifdef HAVE_SYS_TYPES_H
70 #ifdef HAVE_SYS_SYSCTL_H
71 #ifdef HAVE_SYSCTL
72 #ifdef CTL_HW 
73
74   int cpus, ram, mib[2], ret;
75   size_t len;
76
77   /* Obtain the maximum number of CPUs supported on the BSD system */
78
79   /* Obtain the number of CPUs online on the BSD system */
80
81 #ifdef HW_NCPU
82   mib[0]=CTL_HW;
83   mib[1]=HW_NCPU;
84   len=sizeof(cpus);
85   ret=sysctl(mib, 2, &cpus, &len, NULL, 0);
86   if (cpus>= 1 && ret==0)
87     sprintf(data->cpus,"%d ",  cpus);
88 #endif
89
90   /* Obtain the CPU speed in MHz - as a double */
91
92   /* Obtain the of CPU and FPU on the ???? box */
93
94   /* Obtain the RAM, cache etc on the BSD system. */
95
96 #ifdef HW_PHYSMEM
97   mib[0]=CTL_HW;
98   mib[1]=HW_PHYSMEM;
99   ret=sysctl(mib, 2, &ram , &len, NULL, 0);
100   if( ram > 0 && ret ==0 )
101     sprintf(data->memory,"%d", ram/(1024*1024));
102 #endif
103
104
105   /* Obtain the manufacturer */
106
107   /* sprintf(data->hw_provider,"SGI"); */
108   return(PROBABLY_BSD);
109 #endif
110 #endif
111 #endif
112 #endif
113 #endif
114 #endif
115   return(-1);
116 }