Imported Upstream version 4.6.0
[debian/atlc] / tests / try_irix.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 #include "config.h"
27
28 #ifdef HAVE_UNISTD_H 
29 #ifdef HAVE_STDIO_H
30 #ifdef HAVE_STDLIB_H
31 #ifdef HAVE_SYS_VID_H
32 #ifdef HAVE_INVENT_H 
33
34 #include <unistd.h>
35 #include <stdio.h>
36 #include <stdlib.h>
37 #include <invent.h>
38 #include <sys/types.h>
39
40 #endif
41 #endif
42 #endif
43 #endif
44 #endif
45
46 #include "defs.h"
47
48 int try_irix(struct computer_data *data)
49
50 {
51 #ifdef HAVE_UNISTD_H 
52 #ifdef HAVE_STDIO_H
53 #ifdef HAVE_STDLIB_H
54 #ifdef HAVE_SYS_VID_H
55 #ifdef HAVE_INVENT_H
56
57   long CPUs_online;
58   inventory_t *invp;
59
60   /* Obtain the maximum number of CPUs supported on the IRIX system */
61
62   /* Obtain the number of CPUs online on the IRIX system */
63 #ifdef _SC_NPROC_ONLN
64   CPUs_online=0;
65   CPUs_online=(long) sysconf(_SC_NPROC_ONLN);
66   if( CPUs_online >= 1 )
67     sprintf(data->cpus,"%ld ",CPUs_online);
68 #endif
69
70
71
72   /* Obtain the of CPU and FPU on the IRIX box */
73   setinvent(); /* Always call before starting to call getinvt() */
74
75   while ( (invp = getinvent()) ) {
76     if ( (invp->inv_class == INV_PROCESSOR) && (invp->inv_type == INV_CPUBOARD))  
77       sprintf(data->mhz,"%d",(int) invp->inv_controller);
78     if ( (invp->inv_class == INV_PROCESSOR) && (invp->inv_type == INV_CPUCHIP))
79       sprintf(data->cpu_type,"%d",invp->inv_state);
80     if ( (invp->inv_class == INV_PROCESSOR) && (invp->inv_type == INV_FPUCHIP) && invp->inv_state)
81       sprintf(data->fpu_type,"%d",invp->inv_state);
82   }
83   /* Obtain the RAM, cache etc on the IRIX system. */
84
85   setinvent(); /* Always call before starting to call getinvt() */
86   while ((invp = getinvent()))
87   {
88     if (invp->inv_class == INV_MEMORY && (invp->inv_type == INV_MAIN_MB))
89       sprintf(data->memory,"%d", invp->inv_state);
90     if (invp->inv_class == INV_MEMORY && (invp->inv_type == INV_DCACHE))
91       sprintf(data->L1data,"%d", invp->inv_state/1024);
92     if (invp->inv_class == INV_MEMORY && (invp->inv_type == INV_ICACHE))
93       sprintf(data->L1instruction,"%d", invp->inv_state/1024);
94     if (invp->inv_class == INV_MEMORY && (invp->inv_type == INV_SIDCACHE))
95       sprintf(data->L2,"%d", invp->inv_state/1024);
96     if (invp->inv_class == INV_MEMORY && (invp->inv_type == INV_SIDCACHE))
97       sprintf(data->L2,"%d", invp->inv_state/1024);
98   }
99
100
101   /* Obtain the manufacturer */
102   sprintf(data->hw_provider,"SGI");
103
104   return(PROBABLY_IRIX);
105 #endif
106 #endif
107 #endif
108 #endif
109 #endif
110   return(-1);
111 }