|
Packit Service |
407539 |
/*
|
|
Packit Service |
407539 |
This file is part of LibGTop 2.0.
|
|
Packit Service |
407539 |
|
|
Packit Service |
407539 |
LibGTop is free software; you can redistribute it and/or modify it
|
|
Packit Service |
407539 |
under the terms of the GNU General Public License as published by
|
|
Packit Service |
407539 |
the Free Software Foundation; either version 2 of the License,
|
|
Packit Service |
407539 |
or (at your option) any later version.
|
|
Packit Service |
407539 |
|
|
Packit Service |
407539 |
LibGTop is distributed in the hope that it will be useful, but WITHOUT
|
|
Packit Service |
407539 |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
Packit Service |
407539 |
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
Packit Service |
407539 |
for more details.
|
|
Packit Service |
407539 |
|
|
Packit Service |
407539 |
You should have received a copy of the GNU General Public License
|
|
Packit Service |
407539 |
along with LibGTop; see the file COPYING. If not, write to the
|
|
Packit Service |
407539 |
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
Packit Service |
407539 |
Boston, MA 02110-1301, USA.
|
|
Packit Service |
407539 |
*/
|
|
Packit Service |
407539 |
|
|
Packit Service |
407539 |
#include <config.h>
|
|
Packit Service |
407539 |
#include <unistd.h>
|
|
Packit Service |
407539 |
|
|
Packit Service |
407539 |
#include <glibtop.h>
|
|
Packit Service |
407539 |
#include <glibtop/cpu.h>
|
|
Packit Service |
407539 |
#include <glibtop/open.h>
|
|
Packit Service |
407539 |
|
|
Packit Service |
407539 |
#include <mach/mach_host.h>
|
|
Packit Service |
407539 |
#include <mach/mach_init.h>
|
|
Packit Service |
407539 |
#include <mach/mach_interface.h>
|
|
Packit Service |
407539 |
|
|
Packit Service |
407539 |
#include <glibtop/error.h>
|
|
Packit Service |
407539 |
|
|
Packit Service |
407539 |
void
|
|
Packit Service |
407539 |
glibtop_open_s (glibtop *server, const char *program_name,
|
|
Packit Service |
407539 |
const unsigned long features, const unsigned flags)
|
|
Packit Service |
407539 |
{
|
|
Packit Service |
407539 |
processor_cpu_load_info_data_t *pinfo;
|
|
Packit Service |
407539 |
mach_msg_type_number_t info_count;
|
|
Packit Service |
407539 |
natural_t processor_count;
|
|
Packit Service |
407539 |
|
|
Packit Service |
407539 |
if (host_processor_info (mach_host_self (),
|
|
Packit Service |
407539 |
PROCESSOR_CPU_LOAD_INFO,
|
|
Packit Service |
407539 |
&processor_count,
|
|
Packit Service |
407539 |
(processor_info_array_t*)&pinfo,
|
|
Packit Service |
407539 |
&info_count)) {
|
|
Packit Service |
407539 |
glibtop_error_io_r (server, "host_processor_info");
|
|
Packit Service |
407539 |
}
|
|
Packit Service |
407539 |
server->ncpu = (processor_count <= GLIBTOP_NCPU) ?
|
|
Packit Service |
407539 |
processor_count : GLIBTOP_NCPU;
|
|
Packit Service |
407539 |
vm_deallocate (mach_task_self (), (vm_address_t) pinfo, info_count);
|
|
Packit Service |
407539 |
}
|
|
Packit Service |
407539 |
|
|
Packit Service |
407539 |
void
|
|
Packit Service |
407539 |
glibtop_close_s (glibtop *server)
|
|
Packit Service |
407539 |
{ }
|