Indent everything to 4 spaces to make it consistant with the other LibGTop

code.
This commit is contained in:
Martin Baulig
1999-12-25 19:01:13 +00:00
parent dbb5f9b636
commit bbb539ef56
6 changed files with 135 additions and 137 deletions

View File

@@ -40,9 +40,9 @@ static const unsigned long _glibtop_sysdeps_loadavg =
int int
glibtop_init_loadavg_s (glibtop *server) glibtop_init_loadavg_s (glibtop *server)
{ {
server->sysdeps.loadavg = _glibtop_sysdeps_loadavg; server->sysdeps.loadavg = _glibtop_sysdeps_loadavg;
return 0; return 0;
} }
/* Provides load average. */ /* Provides load average. */
@@ -51,41 +51,39 @@ int
glibtop_get_loadavg_s (glibtop *server, glibtop_loadavg *buf) glibtop_get_loadavg_s (glibtop *server, glibtop_loadavg *buf)
{ {
#ifndef HAVE_GETLOADAVG #ifndef HAVE_GETLOADAVG
kstat_ctl_t *kc; kstat_ctl_t *kc;
kstat_t *ksp; kstat_t *ksp;
int i; int i;
static char *avestrings[] = { "avenrun_1min", static char *avestrings[] = { "avenrun_1min",
"avenrun_5min", "avenrun_5min",
"avenrun_15min" }; "avenrun_15min" };
#endif #endif
memset (buf, 0, sizeof (glibtop_loadavg)); memset (buf, 0, sizeof (glibtop_loadavg));
#ifdef HAVE_GETLOADAVG #ifdef HAVE_GETLOADAVG
if (getloadavg (buf->loadavg, 3) < 0) if (getloadavg (buf->loadavg, 3) < 0)
return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL; return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL;
#else #else
if(!(kc = server->_priv->machine.kc)) if(!(kc = server->_priv->machine.kc))
return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL; return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL;
switch(kstat_chain_update(kc)) switch(kstat_chain_update(kc)) {
{ case -1: assert(0); /* Debugging, shouldn't happen */
case -1: assert(0); /* Debugging, shouldn't happen */ case 0: break;
case 0: break; default: glibtop_get_kstats(server);
default: glibtop_get_kstats(server); }
} if(!(ksp = server->_priv->machine.system))
if(!(ksp = server->_priv->machine.system)) return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL;
return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL; if(kstat_read(kc, ksp, NULL) < 0)
if(kstat_read(kc, ksp, NULL) < 0) return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL;
return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL; for(i = 0; i < 3; ++i) { /* Do we have a countof macro? */
for(i = 0; i < 3; ++i) /* Do we have a countof macro? */ kstat_named_t *kn;
{
kstat_named_t *kn;
kn = (kstat_named_t *)kstat_data_lookup(ksp, avestrings[i]); kn = (kstat_named_t *)kstat_data_lookup(ksp, avestrings[i]);
if(kn) if(kn)
buf->loadavg[i] = (double)kn->value.ul / FSCALE; buf->loadavg[i] = (double)kn->value.ul / FSCALE;
} }
#endif #endif
buf->flags = _glibtop_sysdeps_loadavg; buf->flags = _glibtop_sysdeps_loadavg;
return 0; return 0;
} }

View File

@@ -39,14 +39,14 @@ static const unsigned long _glibtop_sysdeps_msg_limits =
int int
glibtop_init_msg_limits_p (glibtop *server) glibtop_init_msg_limits_p (glibtop *server)
{ {
kvm_t *kd = server->_priv->machine.kd; kvm_t *kd = server->_priv->machine.kd;
if(kd && !kvm_nlist(kd, nlst)) if(kd && !kvm_nlist(kd, nlst))
server->sysdeps.msg_limits = _glibtop_sysdeps_msg_limits; server->sysdeps.msg_limits = _glibtop_sysdeps_msg_limits;
else else
server->sysdeps.msg_limits = 0; server->sysdeps.msg_limits = 0;
return 0; return 0;
} }
/* Provides information about sysv ipc limits. */ /* Provides information about sysv ipc limits. */
@@ -54,25 +54,25 @@ glibtop_init_msg_limits_p (glibtop *server)
int int
glibtop_get_msg_limits_p (glibtop *server, glibtop_msg_limits *buf) glibtop_get_msg_limits_p (glibtop *server, glibtop_msg_limits *buf)
{ {
kvm_t *kd = server->_priv->machine.kd; kvm_t *kd = server->_priv->machine.kd;
struct msginfo minfo; struct msginfo minfo;
memset (buf, 0, sizeof (glibtop_msg_limits)); memset (buf, 0, sizeof (glibtop_msg_limits));
if(!(server->sysdeps.msg_limits)) if(!(server->sysdeps.msg_limits))
return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL; return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL;
if(kvm_read(kd, nlst[0].n_value, (void *)&minfo, if(kvm_read(kd, nlst[0].n_value, (void *)&minfo,
sizeof(struct msginfo)) != sizeof(struct msginfo)) sizeof(struct msginfo)) != sizeof(struct msginfo))
return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL; return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL;
buf->msgmap = minfo.msgmap; buf->msgmap = minfo.msgmap;
buf->msgmax = minfo.msgmax; buf->msgmax = minfo.msgmax;
buf->msgmnb = minfo.msgmnb; buf->msgmnb = minfo.msgmnb;
buf->msgmni = minfo.msgmni; buf->msgmni = minfo.msgmni;
buf->msgssz = minfo.msgssz; buf->msgssz = minfo.msgssz;
buf->msgtql = minfo.msgtql; buf->msgtql = minfo.msgtql;
buf->msgpool = minfo.msgmni * minfo.msgmnb >> 10; buf->msgpool = minfo.msgmni * minfo.msgmnb >> 10;
buf->flags = _glibtop_sysdeps_msg_limits; buf->flags = _glibtop_sysdeps_msg_limits;
return 0; return 0;
} }

View File

@@ -31,56 +31,56 @@
int int
s_open(const char *file, int mode) s_open(const char *file, int mode)
{ {
int fd; int fd;
do { do {
fd = open(file, mode); fd = open(file, mode);
} while(fd < 0 && errno == EINTR); } while(fd < 0 && errno == EINTR);
return fd; return fd;
} }
int int
s_stat(const char *path, struct stat *buf) s_stat(const char *path, struct stat *buf)
{ {
int status; int status;
do { do {
status = stat(path, buf); status = stat(path, buf);
} while(status < 0 && errno == EINTR); } while(status < 0 && errno == EINTR);
return status; return status;
} }
int int
s_close(int fd) s_close(int fd)
{ {
int status; int status;
do { do {
status = close(fd); status = close(fd);
} while(status < 0 && errno == EINTR); } while(status < 0 && errno == EINTR);
return status; return status;
} }
ssize_t ssize_t
s_pread(int fd, void *buf, size_t nbytes, off_t offset) s_pread(int fd, void *buf, size_t nbytes, off_t offset)
{ {
ssize_t len; ssize_t len;
/* Now, why doesn't the pread(2) man page say anything about pread() /* Now, why doesn't the pread(2) man page say anything about pread()
return values? Can it read less bytes than requested? */ return values? Can it read less bytes than requested? */
do { do {
len = pread(fd, buf, nbytes, offset); len = pread(fd, buf, nbytes, offset);
} while(len < 0 && errno == EINTR); } while(len < 0 && errno == EINTR);
return len; return len;
} }
int s_closedir(DIR *dirp) int s_closedir(DIR *dirp)
{ {
int status; int status;
do { do {
status = closedir(dirp); status = closedir(dirp);
} while(status < 0 && errno == EINTR); } while(status < 0 && errno == EINTR);
return status; return status;
} }

View File

@@ -40,14 +40,14 @@ static const unsigned long _glibtop_sysdeps_sem_limits =
int int
glibtop_init_sem_limits_p (glibtop *server) glibtop_init_sem_limits_p (glibtop *server)
{ {
kvm_t *kd = server->_priv->machine.kd; kvm_t *kd = server->_priv->machine.kd;
if(kd && !kvm_nlist(kd, nlst)) if(kd && !kvm_nlist(kd, nlst))
server->sysdeps.sem_limits = _glibtop_sysdeps_sem_limits; server->sysdeps.sem_limits = _glibtop_sysdeps_sem_limits;
else else
server->sysdeps.sem_limits = 0; server->sysdeps.sem_limits = 0;
return 0; return 0;
} }
/* Provides information about sysv sem limits. */ /* Provides information about sysv sem limits. */
@@ -55,27 +55,27 @@ glibtop_init_sem_limits_p (glibtop *server)
int int
glibtop_get_sem_limits_p (glibtop *server, glibtop_sem_limits *buf) glibtop_get_sem_limits_p (glibtop *server, glibtop_sem_limits *buf)
{ {
kvm_t *kd = server->_priv->machine.kd; kvm_t *kd = server->_priv->machine.kd;
struct seminfo sinfo; struct seminfo sinfo;
memset (buf, 0, sizeof (glibtop_sem_limits)); memset (buf, 0, sizeof (glibtop_sem_limits));
if(!(server->sysdeps.sem_limits)) if(!(server->sysdeps.sem_limits))
return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL; return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL;
if(kvm_read(kd, nlst[0].n_value, (void *)&sinfo, if(kvm_read(kd, nlst[0].n_value, (void *)&sinfo,
sizeof(struct seminfo)) != sizeof(struct seminfo)) sizeof(struct seminfo)) != sizeof(struct seminfo))
return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL; return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL;
buf->semmap = sinfo.semmap; buf->semmap = sinfo.semmap;
buf->semmni = sinfo.semmni; buf->semmni = sinfo.semmni;
buf->semmns = sinfo.semmns; buf->semmns = sinfo.semmns;
buf->semmnu = sinfo.semmnu; buf->semmnu = sinfo.semmnu;
buf->semmsl = sinfo.semmsl; buf->semmsl = sinfo.semmsl;
buf->semopm = sinfo.semopm; buf->semopm = sinfo.semopm;
buf->semume = sinfo.semume; buf->semume = sinfo.semume;
buf->semusz = sinfo.semusz; buf->semusz = sinfo.semusz;
buf->semvmx = sinfo.semvmx; buf->semvmx = sinfo.semvmx;
buf->semaem = sinfo.semaem; buf->semaem = sinfo.semaem;
buf->flags = _glibtop_sysdeps_sem_limits; buf->flags = _glibtop_sysdeps_sem_limits;
return 0; return 0;
} }

View File

@@ -37,14 +37,14 @@ static const unsigned long _glibtop_sysdeps_shm_limits =
int int
glibtop_init_shm_limits_p (glibtop *server) glibtop_init_shm_limits_p (glibtop *server)
{ {
kvm_t *kd = server->_priv->machine.kd; kvm_t *kd = server->_priv->machine.kd;
if(kd && !kvm_nlist(kd, nlst)) if(kd && !kvm_nlist(kd, nlst))
server->sysdeps.shm_limits = _glibtop_sysdeps_shm_limits; server->sysdeps.shm_limits = _glibtop_sysdeps_shm_limits;
else else
server->sysdeps.shm_limits = 0; server->sysdeps.shm_limits = 0;
return 0; return 0;
} }
/* Provides information about sysv ipc limits. */ /* Provides information about sysv ipc limits. */
@@ -52,21 +52,21 @@ glibtop_init_shm_limits_p (glibtop *server)
int int
glibtop_get_shm_limits_p (glibtop *server, glibtop_shm_limits *buf) glibtop_get_shm_limits_p (glibtop *server, glibtop_shm_limits *buf)
{ {
kvm_t *kd = server->_priv->machine.kd; kvm_t *kd = server->_priv->machine.kd;
struct shminfo sinfo; struct shminfo sinfo;
memset (buf, 0, sizeof (glibtop_shm_limits)); memset (buf, 0, sizeof (glibtop_shm_limits));
if(!(server->sysdeps.shm_limits)) if(!(server->sysdeps.shm_limits))
return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL; return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL;
if(kvm_read(kd, nlst[0].n_value, (void *)&sinfo, if(kvm_read(kd, nlst[0].n_value, (void *)&sinfo,
sizeof(struct shminfo)) != sizeof(struct shminfo)) sizeof(struct shminfo)) != sizeof(struct shminfo))
return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL; return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL;
buf->shmmax = sinfo.shmmax; buf->shmmax = sinfo.shmmax;
buf->shmmin = sinfo.shmmin; buf->shmmin = sinfo.shmmin;
buf->shmmni = sinfo.shmmni; buf->shmmni = sinfo.shmmni;
buf->shmseg = sinfo.shmseg; buf->shmseg = sinfo.shmseg;
buf->flags = _glibtop_sysdeps_shm_limits; buf->flags = _glibtop_sysdeps_shm_limits;
return 0; return 0;
} }

View File

@@ -34,9 +34,9 @@ static const unsigned long _glibtop_sysdeps_uptime =
int int
glibtop_init_uptime_s (glibtop *server) glibtop_init_uptime_s (glibtop *server)
{ {
server->sysdeps.uptime = _glibtop_sysdeps_uptime; server->sysdeps.uptime = _glibtop_sysdeps_uptime;
return 0; return 0;
} }
/* Provides uptime and idle time. */ /* Provides uptime and idle time. */
@@ -44,14 +44,14 @@ glibtop_init_uptime_s (glibtop *server)
int int
glibtop_get_uptime_s (glibtop *server, glibtop_uptime *buf) glibtop_get_uptime_s (glibtop *server, glibtop_uptime *buf)
{ {
memset (buf, 0, sizeof (glibtop_uptime)); memset (buf, 0, sizeof (glibtop_uptime));
if(!(server->_priv->machine.boot)) if(!(server->_priv->machine.boot))
return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL; return -GLIBTOP_ERROR_INCOMPATIBLE_KERNEL;
buf->boot_time = server->_priv->machine.boot; buf->boot_time = server->_priv->machine.boot;
buf->uptime = time(NULL) - server->_priv->machine.boot; buf->uptime = time(NULL) - server->_priv->machine.boot;
buf->flags = _glibtop_sysdeps_uptime; buf->flags = _glibtop_sysdeps_uptime;
return 0; return 0;
} }