git-svn sucks. Kill r2609

svn path=/trunk/; revision=2611
This commit is contained in:
Benoît Dejean
2007-06-25 17:30:40 +00:00
parent 1e0ba1d7aa
commit ef34cfb38a
15 changed files with 10 additions and 210 deletions

View File

@@ -8,7 +8,7 @@ DEFS = @DEFS@
noinst_PROGRAMS = first second pprint procargs df netlist \
mountlist procmap netload sysdeps timings \
openfiles smp proclist mem wd affinity
openfiles smp proclist mem wd
first_SOURCES = first.c
first_LDADD = $(top_builddir)/lib/libgtop-2.0.la
@@ -58,5 +58,3 @@ wd_LDADD = $(top_builddir)/lib/libgtop-2.0.la
mem_SOURCE = mem.c
mem_LDADD = $(top_builddir)/lib/libgtop-2.0.la
affinity_SOURCES = affinity.c
affinity_LDADD = $(top_builddir)/lib/libgtop-2.0.la

View File

@@ -1,34 +0,0 @@
#include <glibtop.h>
#include <glibtop/procaffinity.h>
#include <glib.h>
#include <unistd.h>
int main(int argc, char **argv)
{
pid_t pid;
glibtop_proc_affinity buf;
guint16 *cpus;
size_t i;
if (argc < 2 || !(pid = strtoul(argv[1], NULL, 0)))
pid = getpid();
glibtop_init();
cpus = glibtop_get_proc_affinity(&buf, pid);
g_print("Process %u:\n"
" - all: %d\n",
(unsigned)pid, buf.all);
for (i = 0; i != buf.number; ++i)
g_print(" - CPU#%u is set\n", cpus[i]);
g_free(cpus);
glibtop_close();
return 0;
}

View File

@@ -23,5 +23,4 @@ void|netload|ulong(if_flags,mtu,subnet,address,packets_in,packets_out,packets_to
void|ppp|ulong(state,bytes_in,bytes_out)|ushort(device)
char **|netlist|unsigned(number)
char **|proc_wd|ulong(number),str(root),str(exe)|pid_t(pid)
guint16*|proc_affinity|ulong(number),int(all)|pid_t(pid)

View File

@@ -8,7 +8,7 @@ glibtop_HEADERS = close.h loadavg.h prockernel.h procstate.h \
procsignal.h union.h gnuserv.h \
parameter.h mountlist.h fsusage.h procmap.h signal.h \
sysinfo.h ppp.h procargs.h netload.h \
procwd.h procaffinity.h \
procwd.h \
netlist.h procopenfiles.h open.h
noinst_HEADERS = error.h write.h read_data.h read.h init_hooks.h

View File

@@ -58,9 +58,8 @@ G_BEGIN_DECLS
#define GLIBTOP_CMND_NETLIST 24
#define GLIBTOP_CMND_PROC_OPEN_FILES 25
#define GLIBTOP_CMND_PROC_WD 26
#define GLIBTOP_CMND_PROC_AFFINITY 27
#define GLIBTOP_MAX_CMND 28
#define GLIBTOP_MAX_CMND 27
#define _GLIBTOP_PARAM_SIZE 16

View File

@@ -1,61 +0,0 @@
/* Copyright (C) 2007 Benoît Dejean
This file is part of LibGTop 2.
LibGTop is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
LibGTop is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with LibGTop; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef __GLIBTOP_PROCAFFINITY_H__
#define __GLIBTOP_PROCAFFINITY_H__
#include <glibtop.h>
#include <glibtop/global.h>
G_BEGIN_DECLS
typedef struct _glibtop_proc_affinity glibtop_proc_affinity;
#define GLIBTOP_PROC_AFFINITY_NUMBER 0
#define GLIBTOP_PROC_AFFINITY_ALL 1
struct _glibtop_proc_affinity
{
guint64 flags;
guint32 number;
gboolean all;
};
guint16 * glibtop_get_proc_affinity(glibtop_proc_affinity *buf, pid_t pid);
guint16 * glibtop_get_proc_affinity_l(glibtop *server, glibtop_proc_affinity *buf, pid_t pid);
#if GLIBTOP_SUID_PROC_AFFINITY
#define glibtop_get_proc_affinity_r glibtop_get_proc_affinity_p
void _glibtop_init_proc_affinity_p(glibtop *server);
guint16 * glibtop_get_proc_affinity_p(glibtop *server, glibtop_proc_affinity *buf, pid_t pid);
#else
#define glibtop_get_proc_affinity_r glibtop_get_proc_affinity_s
void _glibtop_init_proc_affinity_s(glibtop *server);
guint16 * glibtop_get_proc_affinity_s(glibtop *server, glibtop_proc_affinity *buf, pid_t pid);
#endif
G_END_DECLS
#endif

View File

@@ -52,9 +52,8 @@ G_BEGIN_DECLS
#define GLIBTOP_SYSDEPS_NETLIST 23
#define GLIBTOP_SYSDEPS_PROC_OPEN_FILES 24
#define GLIBTOP_SYSDEPS_PROC_WD 25
#define GLIBTOP_SYSDEPS_PROC_AFFINITY 26
#define GLIBTOP_MAX_SYSDEPS 27
#define GLIBTOP_MAX_SYSDEPS 26
#define GLIBTOP_SYSDEPS_ALL ((1 << GLIBTOP_MAX_SYSDEPS) - 1)
@@ -89,7 +88,6 @@ struct _glibtop_sysdeps
guint64 netload; /* glibtop_netload */
guint64 ppp; /* glibtop_ppp */
guint64 proc_wd; /* glibtop_proc_wd */
guint64 proc_affinity; /* glibtop_proc_affinity */
};
void glibtop_get_sysdeps (glibtop_sysdeps *buf);

View File

@@ -43,7 +43,6 @@
#include <glibtop/procmap.h>
#include <glibtop/procopenfiles.h>
#include <glibtop/procwd.h>
#include <glibtop/procaffinity.h>
#include <glibtop/mountlist.h>
#include <glibtop/fsusage.h>
@@ -83,7 +82,6 @@ union _glibtop_union
glibtop_ppp ppp;
glibtop_proc_open_files proc_open_files;
glibtop_proc_wd proc_wd;
glibtop_proc_affinity proc_affinity;
};
G_END_DECLS

View File

@@ -42,10 +42,6 @@ glibtop_get_ppp
glibtop_get_ppp_l
glibtop_get_ppp_p
glibtop_get_ppp_s
glibtop_get_proc_affinity
glibtop_get_proc_affinity_l
glibtop_get_proc_affinity_p
glibtop_get_proc_affinity_s
glibtop_get_proc_args
glibtop_get_proc_args_l
glibtop_get_proc_args_p
@@ -57,6 +53,10 @@ glibtop_get_proc_kernel
glibtop_get_proc_kernel_l
glibtop_get_proc_kernel_p
glibtop_get_proc_kernel_s
glibtop_get_proclist
glibtop_get_proclist_l
glibtop_get_proclist_p
glibtop_get_proclist_s
glibtop_get_proc_map
glibtop_get_proc_map_l
glibtop_get_proc_map_p
@@ -93,10 +93,6 @@ glibtop_get_proc_wd
glibtop_get_proc_wd_l
glibtop_get_proc_wd_p
glibtop_get_proc_wd_s
glibtop_get_proclist
glibtop_get_proclist_l
glibtop_get_proclist_p
glibtop_get_proclist_s
glibtop_get_sem_limits
glibtop_get_sem_limits_l
glibtop_get_sem_limits_p
@@ -131,4 +127,4 @@ glibtop_open_s
glibtop_server_features
glibtop_set_parameter_l
glibtop_set_parameter_p
glibtop_sys_siglist
glibtop_sys_siglist

View File

@@ -47,7 +47,6 @@ GLIBTOP_SUID_PROC_MAP +
GLIBTOP_SUID_NETLOAD +
GLIBTOP_SUID_NETLIST +
GLIBTOP_SUID_PROC_WD +
GLIBTOP_SUID_PROC_AFFINITY +
GLIBTOP_SUID_PPP;
const _glibtop_init_func_t _glibtop_init_hook_s [] = {
@@ -114,9 +113,6 @@ const _glibtop_init_func_t _glibtop_init_hook_s [] = {
#if !GLIBTOP_SUID_PROC_WD
_glibtop_init_proc_wd_s,
#endif
#if !GLIBTOP_SUID_PROC_AFFINITY
_glibtop_init_proc_affinity_s,
#endif
#if !GLIBTOP_SUID_PPP
_glibtop_init_ppp_s,
#endif
@@ -187,9 +183,6 @@ const _glibtop_init_func_t _glibtop_init_hook_p [] = {
#if GLIBTOP_SUID_PROC_WD
_glibtop_init_proc_wd_p,
#endif
#if GLIBTOP_SUID_PROC_AFFINITY
_glibtop_init_proc_affinity_p,
#endif
#if GLIBTOP_SUID_PPP
_glibtop_init_ppp_p,
#endif

View File

@@ -53,7 +53,6 @@ GLIBTOP_SUID_PROC_MAP +
GLIBTOP_SUID_NETLOAD +
GLIBTOP_SUID_NETLIST +
GLIBTOP_SUID_PROC_WD +
GLIBTOP_SUID_PROC_AFFINITY +
GLIBTOP_SUID_PPP;
#include <fcntl.h>

View File

@@ -368,17 +368,3 @@ glibtop_get_proc_wd(glibtop_proc_wd *buf, pid_t pid)
}
/**
* glibtop_get_proc_affinity:
* @buf:
* @pid: Process id to get the affinity
*
* Get the processor affinity list for a process
*
* Returns: A list of processor ID of 'buf.number' elements.
*/
guint16 *
glibtop_get_proc_affinity(glibtop_proc_affinity *buf, pid_t pid)
{
return glibtop_get_proc_affinity_l(glibtop_global_server, buf, pid);
}

View File

@@ -8,8 +8,7 @@ libgtop_sysdeps_2_0_la_SOURCES = open.c close.c cpu.c mem.c swap.c \
proctime.c procmem.c procsignal.c prockernel.c \
procsegment.c procargs.c procmap.c siglist.c \
sysinfo.c netload.c ppp.c glibtop_private.c \
fsusage.c netlist.c procopenfiles.c procwd.c \
procaffinity.c
fsusage.c netlist.c procopenfiles.c procwd.c
libgtop_sysdeps_2_0_la_LIBADD = @GLIB_LIBS@

View File

@@ -43,7 +43,6 @@
#define GLIBTOP_SUID_NETLOAD 0
#define GLIBTOP_SUID_NETLIST 0
#define GLIBTOP_SUID_PROC_WD 0
#define GLIBTOP_SUID_PROC_AFFINITY 0
#define GLIBTOP_SUID_PPP 0
#define GLIBTOP_SUID_PROC_FILE 0

View File

@@ -1,69 +0,0 @@
/* Copyright (C) 2007 Benoît Dejean
This file is part of LibGTop 2.
LibGTop is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
LibGTop is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with LibGTop; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <config.h>
#include <glibtop/procaffinity.h>
#include <glibtop/error.h>
#include <glibtop_private.h>
#include <sched.h>
void
_glibtop_init_proc_affinity_s(glibtop *server)
{
server->sysdeps.proc_affinity =
(1 << GLIBTOP_PROC_AFFINITY_NUMBER) |
(1 << GLIBTOP_PROC_AFFINITY_ALL);
}
guint16 *
glibtop_get_proc_affinity_s(glibtop *server, glibtop_proc_affinity *buf, pid_t pid)
{
cpu_set_t set;
size_t i;
GArray* cpus;
memset(buf, 0, sizeof *buf);
if (sched_getaffinity(pid, sizeof set, &set) == -1) {
glibtop_error_r(server, "sched_getaffinity failed");
return NULL;
}
cpus = g_array_new(FALSE, FALSE, sizeof(guint16));
for (i = 0; i < MIN(CPU_SETSIZE, (size_t)(server->ncpu + 1)); i++) {
if (CPU_ISSET(i, &set)) {
guint16 n = i;
g_array_append_val(cpus, n);
}
}
buf->number = cpus->len;
buf->all = (cpus->len == (size_t)(server->ncpu + 1));
buf->flags = (1 << GLIBTOP_PROC_AFFINITY_NUMBER)
| (1 << GLIBTOP_PROC_AFFINITY_ALL);
return (guint16*) g_array_free(cpus, FALSE);
}