1 /* Copyright (C) 1998 Joshua Sled
2    This file is part of LibGTop 1.0.
3 
4    Contributed by Joshua Sled <jsled@xcf.berkeley.edu>, July 1998.
5 
6    LibGTop is free software; you can redistribute it and/or modify it
7    under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License,
9    or (at your option) any later version.
10 
11    LibGTop is distributed in the hope that it will be useful, but WITHOUT
12    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14    for more details.
15 
16    You should have received a copy of the GNU General Public License
17    along with LibGTop; see the file COPYING. If not, write to the
18    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19    Boston, MA 02110-1301, USA.
20 */
21 
22 #include <config.h>
23 #include <sys/types.h>
24 #include <sys/sysctl.h>
25 #include <glibtop.h>
26 #include <glibtop/open.h>
27 #include <glibtop/cpu.h>
28 #include <glibtop/error.h>
29 
30 #include <glibtop_private.h>
31 
32 
33 void
glibtop_open_s(glibtop * server,const char * program_name,const unsigned long features,const unsigned flags)34 glibtop_open_s (glibtop *server, const char *program_name,
35 		const unsigned long features,
36 		const unsigned flags)
37 {
38 	int ncpus;
39 	size_t len;
40 
41 	len = sizeof (ncpus);
42 	sysctlbyname ("hw.ncpu", &ncpus, &len, NULL, 0);
43 	server->real_ncpu = ncpus - 1;
44 	server->ncpu = MIN(GLIBTOP_NCPU - 1, server->real_ncpu);
45 
46 #ifdef __DragonFly__
47 	server->os_version_code = __DragonFly_version;
48 #else
49 	server->os_version_code = __FreeBSD_version;
50 #endif
51 
52 }
53