Imported Upstream version 4.6.0
[debian/atlc] / tests / try_linux.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 Linux machine. */
26
27 #include "config.h"
28
29 #ifdef HAVE_STDIO_H         /* it does ***not** necessarily mean it's Linux */
30 #ifdef HAVE_STDLIB_H        /* but it will define some variables that we      */
31 #ifdef HAVE_SYS_TYPES_H     /* later check for, to confirm it's Linux       */
32 #ifdef HAVE_SYS_UTSNAME_H   /* later check for, to confirm it's Linux       */
33 #ifdef HAVE_UNISTD_H 
34 #ifdef HAVE_STRING_H
35 #ifdef HAVE_SYS_SYSINFO_H
36 #ifdef HAVE_LINUX_IP_H      /* I don't want to include this, but it is proof 
37                                that the system is Linux */
38
39 #include <stdio.h>
40 #include <stdlib.h>
41 #include <sys/types.h>
42 #include <sys/utsname.h>
43 #include <unistd.h>
44 #include <string.h>
45 #include <sys/sysinfo.h>
46
47 #ifdef HAVE_ERRNO_H
48 #include <errno.h>
49 #endif
50
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 Linux system */
60
61 #include "defs.h"
62 #define BYTES_PER_MB  1048576
63
64 int try_linux(struct computer_data *data)
65 {
66 #ifdef HAVE_STDIO_H         /* it does ***not** necessarily mean it's Linux */
67 #ifdef HAVE_STDLIB_H        /* but it will define some variables that we      */
68 #ifdef HAVE_SYS_TYPES_H     /* later check for, to confirm it's Linux       */
69 #ifdef HAVE_SYS_UTSNAME_H   /* later check for, to confirm it's Linux       */
70 #ifdef HAVE_UNISTD_H 
71 #ifdef HAVE_STRING_H
72 #ifdef HAVE_SYS_SYSINFO_H
73 #ifdef HAVE_LINUX_IP_H      /* I don't want to include this, but it is proof 
74                                that the system is Linux */
75
76   /* Obtain the maximum number of CPUs supported on the Linux system */
77
78   /* Obtain the number of CPUs online on the Linux system */
79
80 #ifdef _SC_NPROCESSORS_CONF
81   if( sysconf(_SC_NPROCESSORS_CONF) >= 1)
82     sprintf(data->cpus,"%d", sysconf( _SC_NPROCESSORS_CONF));
83 #endif
84
85   /* Obtain the of CPU and FPU on the Linux box */
86
87   /* Obtain the RAM on the Linux system if possible. Currently this is 
88   done in try_portable.c, but is not 100% accurate on Linux */
89
90   /* Obtain operating system informaton */
91
92   /* Obtain the manufacturer - I don't think this will be too possible,
93    but it might be, but clearly some boxes are going to be generic. */
94
95   /* Obtain the Platform */
96
97   return(PROBABLY_LINUX);
98
99 #endif
100 #endif
101 #endif
102 #endif
103 #endif
104 #endif
105 #endif
106 #endif
107   return(-1);
108 }