diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2017-03-08 12:17:31 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2017-03-08 12:17:31 +0000 |
commit | 495d625add9e52b29a98c4fa2627a45d20d44849 (patch) | |
tree | 4927b430b4115c3217965fa08a9aba76fe809422 | |
parent | fa3f206449c7c54afedbc2c7d4107a73e55c204a (diff) | |
download | s6-linux-utils-495d625add9e52b29a98c4fa2627a45d20d44849.tar.xz |
Make it build with skalibs-2.5.0.0
-rw-r--r-- | src/minutils/s6-devd.c | 4 | ||||
-rw-r--r-- | src/minutils/s6-logwatch.c | 10 | ||||
-rw-r--r-- | src/minutils/s6-mount.c | 10 | ||||
-rw-r--r-- | src/minutils/s6-ps.c | 38 | ||||
-rw-r--r-- | src/minutils/s6-ps.h | 22 | ||||
-rw-r--r-- | src/minutils/s6-uevent-listener.c | 16 | ||||
-rw-r--r-- | src/minutils/s6-uevent-spawner.c | 16 | ||||
-rw-r--r-- | src/minutils/s6ps_grcache.c | 5 | ||||
-rw-r--r-- | src/minutils/s6ps_otree.c | 10 | ||||
-rw-r--r-- | src/minutils/s6ps_pfield.c | 29 | ||||
-rw-r--r-- | src/minutils/s6ps_pwcache.c | 10 | ||||
-rw-r--r-- | src/minutils/s6ps_statparse.c | 26 | ||||
-rw-r--r-- | src/minutils/s6ps_ttycache.c | 26 | ||||
-rw-r--r-- | src/minutils/s6ps_wchan.c | 23 |
14 files changed, 116 insertions, 129 deletions
diff --git a/src/minutils/s6-devd.c b/src/minutils/s6-devd.c index 58508a5..f14a8f1 100644 --- a/src/minutils/s6-devd.c +++ b/src/minutils/s6-devd.c @@ -1,7 +1,7 @@ /* ISC license. */ #include <sys/types.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/sgetopt.h> #include <skalibs/strerr2.h> #include <skalibs/djbunix.h> @@ -35,7 +35,7 @@ int main (int argc, char const *const *argv, char const *const *envp) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "qvb:l:t:", &l) ; + int opt = subgetopt_r(argc, argv, "qvb:l:t:", &l) ; if (opt == -1) break ; switch (opt) { diff --git a/src/minutils/s6-logwatch.c b/src/minutils/s6-logwatch.c index 66ff442..d522b5e 100644 --- a/src/minutils/s6-logwatch.c +++ b/src/minutils/s6-logwatch.c @@ -1,6 +1,7 @@ /* ISC license. */ #include <sys/types.h> +#include <sys/uio.h> #include <errno.h> #include <unistd.h> #include <signal.h> @@ -14,10 +15,9 @@ #include <skalibs/buffer.h> #include <skalibs/bufalloc.h> #include <skalibs/sig.h> -#include <skalibs/siovec.h> #include <skalibs/djbunix.h> #include <skalibs/iopause.h> -#include <skalibs/ulong.h> +#include <skalibs/types.h> #define USAGE "s6-logwatch [ -m maxbuffer ] logdir" #define dieusage() strerr_dieusage(100, USAGE) @@ -40,8 +40,8 @@ static void X (void) static size_t nbcat (int fdcurrent) { char buf[N+1] ; - buffer b = BUFFER_INIT(&buffer_read, fdcurrent, buf, N+1) ; - siovec_t v[2] ; + buffer b = BUFFER_INIT(&fd_readv, fdcurrent, buf, N+1) ; + struct iovec v[2] ; size_t bytes = 0 ; for (;;) { @@ -71,7 +71,7 @@ int main (int argc, char const *const *argv) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "m:", &l) ; + int opt = subgetopt_r(argc, argv, "m:", &l) ; if (opt == -1) break ; switch (opt) { diff --git a/src/minutils/s6-mount.c b/src/minutils/s6-mount.c index bb6db81..fe218c2 100644 --- a/src/minutils/s6-mount.c +++ b/src/minutils/s6-mount.c @@ -1,11 +1,12 @@ /* ISC license. */ +#include <string.h> #include <errno.h> #include <sys/mount.h> #include <mntent.h> #include <stdio.h> -#include <skalibs/sgetopt.h> #include <skalibs/bytestr.h> +#include <skalibs/sgetopt.h> #include <skalibs/strerr2.h> #include <skalibs/stralloc.h> #include <skalibs/djbunix.h> @@ -16,14 +17,13 @@ #define SWITCH(opt) do #define HCTIWS(opt) while(0) ; -#define CASE(s) if (n == sizeof(s) - 1 && !str_diffn(opt, (s), n)) +#define CASE(s) if (n == sizeof(s) - 1 && !strncmp(opt, (s), n)) static void scanopt (stralloc *data, unsigned long *flags, char const *opt) { for (;;) { - register unsigned int n = str_chr(opt, ',') ; - + unsigned int n = str_chr(opt, ',') ; SWITCH(opt) { CASE("defaults") { *flags = MS_MGC_VAL ; break ; } @@ -98,7 +98,7 @@ int main (int argc, char const *const *argv) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "nz:arwt:o:", &l) ; + int opt = subgetopt_r(argc, argv, "nz:arwt:o:", &l) ; if (opt == -1) break ; switch (opt) { diff --git a/src/minutils/s6-ps.c b/src/minutils/s6-ps.c index 2b435bc..5b1a568 100644 --- a/src/minutils/s6-ps.c +++ b/src/minutils/s6-ps.c @@ -9,8 +9,8 @@ #include <pwd.h> #include <dirent.h> -#include <skalibs/uint.h> #include <skalibs/uint64.h> +#include <skalibs/types.h> #include <skalibs/fmtscan.h> #include <skalibs/sgetopt.h> #include <skalibs/bytestr.h> @@ -54,8 +54,8 @@ void *left_dtok (unsigned int d, void *x) int uint_cmp (void const *a, void const *b, void *x) { - register unsigned int aa = *(unsigned int *)a ; - register unsigned int bb = *(unsigned int *)b ; + unsigned int aa = *(unsigned int *)a ; + unsigned int bb = *(unsigned int *)b ; (void)x ; return (aa < bb) ? -1 : (aa > bb) ; } @@ -74,22 +74,22 @@ static int fillo_notree (unsigned int i, unsigned int h, void *x) return 1 ; } -static inline unsigned int fieldscan (char const *s, pfield_t *list, uint64 *fbf) +static inline unsigned int fieldscan (char const *s, pfield_t *list, uint64_t *fbf) { - uint64 bits = 0 ; + uint64_t bits = 0 ; unsigned int n = 0 ; int cont = 1 ; for (; cont ; n++) { size_t len = str_chr(s, ',') ; - register pfield_t i = 0 ; + pfield_t i = 0 ; if (!len) strerr_dief3x(100, "invalid", " (empty)", " field for -o option") ; if (!s[len]) cont = 0 ; { char tmp[len+1] ; - byte_copy(tmp, len, s) ; + memcpy(tmp, s, len) ; tmp[len] = 0 ; - for (; i < PFIELD_PHAIL ; i++) if (!str_diff(tmp, s6ps_opttable[i])) break ; + for (; i < PFIELD_PHAIL ; i++) if (!strcmp(tmp, s6ps_opttable[i])) break ; if (i >= PFIELD_PHAIL) strerr_dief4x(100, "invalid", " field for -o option", ": ", tmp) ; if (bits & (1 << i)) @@ -118,7 +118,7 @@ int main (int argc, char const *const *argv) { genalloc pscans = GENALLOC_ZERO ; /* array of pscan_t */ pfield_t fieldlist[PFIELD_PHAIL] = { PFIELD_USER, PFIELD_PID, PFIELD_TTY, PFIELD_STATE, PFIELD_START, PFIELD_ARGS } ; - uint64 fbf = (1 << PFIELD_USER) | (1 << PFIELD_PID) | (1 << PFIELD_TTY) | (1 << PFIELD_STATE) | (1 << PFIELD_START) | (1 << PFIELD_ARGS) ; + uint64_t fbf = (1 << PFIELD_USER) | (1 << PFIELD_PID) | (1 << PFIELD_TTY) | (1 << PFIELD_STATE) | (1 << PFIELD_START) | (1 << PFIELD_ARGS) ; size_t mypos = 0 ; unsigned int nfields = 6 ; pscan_t *p ; @@ -133,7 +133,7 @@ int main (int argc, char const *const *argv) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "Hlw:W:o:", &l) ; + int opt = subgetopt_r(argc, argv, "Hlw:W:o:", &l) ; if (opt == -1) break ; switch (opt) { @@ -220,7 +220,7 @@ int main (int argc, char const *const *argv) for (;;) { pscan_t pscan = PSCAN_ZERO ; - uint64 u ; + uint64_t u ; int dirfd ; errno = 0 ; d = readdir(dir) ; @@ -280,7 +280,7 @@ int main (int argc, char const *const *argv) { unsigned int orderedlist[n+1] ; /* 1st element will be 0, ignored */ - register unsigned int i = 0 ; + unsigned int i = 0 ; /* Order the processes for display */ @@ -326,10 +326,10 @@ int main (int argc, char const *const *argv) size_t fmtlen[n][nfields] ; size_t maxlen[nfields] ; unsigned int maxspaces = 0 ; - for (i = 0 ; i < nfields ; i++) maxlen[i] = str_len(s6ps_fieldheaders[fieldlist[i]]) ; + for (i = 0 ; i < nfields ; i++) maxlen[i] = strlen(s6ps_fieldheaders[fieldlist[i]]) ; for (i = 0 ; i < n ; i++) { - register unsigned int j = 0 ; + unsigned int j = 0 ; for (; j < nfields ; j++) { if (!(*s6ps_pfield_fmt[fieldlist[j]])(p+i, &fmtpos[i][j], &fmtlen[i][j])) @@ -350,8 +350,8 @@ int main (int argc, char const *const *argv) for (i = 0 ; i < maxspaces ; i++) spaces[i] = ' ' ; for (i = 0 ; i < nfields ; i++) { - register unsigned int rightformatted = !!(((uint64)1 << fieldlist[i]) & RIGHTFORMATTED) ; - register size_t len = str_len(s6ps_fieldheaders[fieldlist[i]]) ; + unsigned int rightformatted = !!(((uint64_t)1 << fieldlist[i]) & RIGHTFORMATTED) ; + size_t len = strlen(s6ps_fieldheaders[fieldlist[i]]) ; if (rightformatted && (buffer_put(buffer_1, spaces, maxlen[i] - len) < (int)(maxlen[i] - len))) goto nowrite ; if (buffer_put(buffer_1, s6ps_fieldheaders[fieldlist[i]], len) < (int)len) @@ -362,11 +362,11 @@ int main (int argc, char const *const *argv) if (buffer_put(buffer_1, "\n", 1) < 1) goto nowrite ; for (i = 0 ; i < n ; i++) { - register unsigned int oi = orderedlist[i+1] ; - register unsigned int j = 0 ; + unsigned int oi = orderedlist[i+1] ; + unsigned int j = 0 ; for (; j < nfields ; j++) { - register unsigned int rightformatted = !!(((uint64)1 << fieldlist[j]) & RIGHTFORMATTED) ; + unsigned int rightformatted = !!(((uint64_t)1 << fieldlist[j]) & RIGHTFORMATTED) ; if (rightformatted && (buffer_put(buffer_1, spaces, maxlen[j] - fmtlen[oi][j]) < (int)(maxlen[j] - fmtlen[oi][j]))) goto nowrite ; if (buffer_put(buffer_1, p[oi].data.s + fmtpos[oi][j], fmtlen[oi][j]) < (int)fmtlen[oi][j]) diff --git a/src/minutils/s6-ps.h b/src/minutils/s6-ps.h index 3e5508c..9afd701 100644 --- a/src/minutils/s6-ps.h +++ b/src/minutils/s6-ps.h @@ -84,18 +84,18 @@ struct pscan_s pid_t session ; dev_t ttynr ; pid_t tpgid ; - uint64 utime ; - uint64 stime ; - uint64 cutime ; - uint64 cstime ; + uint64_t utime ; + uint64_t stime ; + uint64_t cutime ; + uint64_t cstime ; int prio ; int nice ; - uint32 threads ; - uint64 start ; - uint64 vsize ; - uint64 rss ; - uint64 rsslim ; - uint64 wchan ; + uint32_t threads ; + uint64_t start ; + uint64_t vsize ; + uint64_t rss ; + uint64_t rsslim ; + uint64_t wchan ; uint32_t cpuno ; uint32_t rtprio ; uint32_t policy ; @@ -158,6 +158,6 @@ extern void s6ps_ttycache_finish (void) ; extern int s6ps_ttycache_lookup (stralloc *, dev_t) ; extern int s6ps_wchan_init (char const *) ; extern void s6ps_wchan_finish (void) ; -extern int s6ps_wchan_lookup (stralloc *, uint64) ; +extern int s6ps_wchan_lookup (stralloc *, uint64_t) ; #endif diff --git a/src/minutils/s6-uevent-listener.c b/src/minutils/s6-uevent-listener.c index d620081..e93cb3a 100644 --- a/src/minutils/s6-uevent-listener.c +++ b/src/minutils/s6-uevent-listener.c @@ -11,7 +11,7 @@ #include <sys/socket.h> #include <sys/wait.h> #include <linux/netlink.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/allreadwrite.h> #include <skalibs/siovec.h> #include <skalibs/buffer.h> @@ -30,7 +30,7 @@ #define BUFSIZE 8191 static char buf1[BUFSIZE + 1] ; -static buffer b1 = BUFFER_INIT(&fd_writesv, 1, buf1, BUFSIZE + 1) ; +static buffer b1 = BUFFER_INIT(&fd_writev, 1, buf1, BUFSIZE + 1) ; static unsigned int cont = 1, verbosity = 1 ; static pid_t pid ; @@ -98,22 +98,20 @@ static inline void handle_stdout (void) static inline void handle_netlink (void) { struct sockaddr_nl nl; - struct iovec iov[2] ; + struct iovec v[2] ; struct msghdr msg = { .msg_name = &nl, .msg_namelen = sizeof(struct sockaddr_nl), - .msg_iov = iov, + .msg_iov = v, .msg_iovlen = 2, .msg_control = 0, .msg_controllen = 0, .msg_flags = 0 } ; - siovec_t v[2] ; - register ssize_t r ; + ssize_t r ; buffer_wpeek(&b1, v) ; siovec_trunc(v, 2, siovec_len(v, 2) - 1) ; - iovec_from_siovec(iov, v, 2) ; r = sanitize_read(fd_recvmsg(0, &msg)) ; if (r < 0) { @@ -153,7 +151,7 @@ int main (int argc, char const *const *argv, char const *const *envp) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "v:b:", &l) ; + int opt = subgetopt_r(argc, argv, "v:b:", &l) ; if (opt == -1) break ; switch (opt) { @@ -190,7 +188,7 @@ int main (int argc, char const *const *argv, char const *const *envp) while (cont || buffer_len(buffer_1)) { - register int r ; + int r ; x[1].events = buffer_len(&b1) ? IOPAUSE_WRITE : 0 ; x[2].events = buffer_available(&b1) >= MAXNLSIZE + 1 ? IOPAUSE_READ : 0 ; r = iopause(x, 2 + cont, 0, 0) ; diff --git a/src/minutils/s6-uevent-spawner.c b/src/minutils/s6-uevent-spawner.c index e6c0927..f220d42 100644 --- a/src/minutils/s6-uevent-spawner.c +++ b/src/minutils/s6-uevent-spawner.c @@ -1,6 +1,6 @@ /* ISC license. */ -#include <sys/types.h> +#include <string.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> @@ -10,9 +10,9 @@ #include <stdlib.h> #include <skalibs/config.h> #include <skalibs/allreadwrite.h> -#include <skalibs/buffer.h> #include <skalibs/bytestr.h> -#include <skalibs/uint.h> +#include <skalibs/buffer.h> +#include <skalibs/types.h> #include <skalibs/sgetopt.h> #include <skalibs/strerr2.h> #include <skalibs/tai.h> @@ -135,7 +135,7 @@ static inline void handle_stdin (stralloc *sa, char const *linevar, char const * while (!pid) { size_t start ; - register ssize_t r ; + ssize_t r ; if (!sa->len && linevar) if (!stralloc_cats(sa, linevar) || !stralloc_catb(sa, "=", 1)) dienomem() ; @@ -149,7 +149,7 @@ static inline void handle_stdin (stralloc *sa, char const *linevar, char const * if (r <= 0) break ; if (sa->len == start + 1) { - start = linevar ? 0 : str_len(sa->s) + 1 ; + start = linevar ? 0 : strlen(sa->s) + 1 ; if (start >= sa->len) { if (verbosity) strerr_warnw1x("read an empty event!") ; @@ -191,7 +191,7 @@ int main (int argc, char const *const *argv, char const *const *envp) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "l:v:t:", &l) ; + int opt = subgetopt_r(argc, argv, "l:v:t:", &l) ; if (opt == -1) break ; switch (opt) { @@ -204,7 +204,7 @@ int main (int argc, char const *const *argv, char const *const *envp) argc -= l.ind ; argv += l.ind ; if (!argc) strerr_dieusage(100, USAGE) ; } - if (linevar && linevar[str_chr(linevar, '=')]) + if (linevar && strchr(linevar, '=')) strerr_dief2x(100, "invalid variable: ", linevar) ; if (ndelay_on(0) < 0) strerr_diefu1sys(111, "set stdin nonblocking") ; @@ -221,7 +221,7 @@ int main (int argc, char const *const *argv, char const *const *envp) while (cont || pid) { - register int r ; + int r ; if (buffer_len(buffer_0)) handle_stdin(&sa, linevar, argv, envp) ; r = iopause_g(x, 1 + (!pid && cont), &deadline) ; diff --git a/src/minutils/s6ps_grcache.c b/src/minutils/s6ps_grcache.c index 9a0d133..f41ccf4 100644 --- a/src/minutils/s6ps_grcache.c +++ b/src/minutils/s6ps_grcache.c @@ -1,9 +1,8 @@ /* ISC license. */ -#include <sys/types.h> #include <grp.h> #include <errno.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/stralloc.h> #include <skalibs/genalloc.h> #include <skalibs/skamisc.h> @@ -56,7 +55,7 @@ int s6ps_grcache_lookup (stralloc *sa, gid_t gid) return stralloc_cats(sa, satmp.s + genalloc_s(dius_t, &grcache_index)[i].right) ; err: { - register int e = errno ; + int e = errno ; if (wasnull) stralloc_free(&satmp) ; else satmp.len = d.right ; errno = e ; diff --git a/src/minutils/s6ps_otree.c b/src/minutils/s6ps_otree.c index 447906e..0f7ccf1 100644 --- a/src/minutils/s6ps_otree.c +++ b/src/minutils/s6ps_otree.c @@ -4,8 +4,6 @@ #include <skalibs/avltreen.h> #include "s6-ps.h" -/* XXX: need to change all the types if the libdatastruct API changes */ - typedef struct ptreeiter_s ptreeiter_t, *ptreeiter_t_ref ; struct ptreeiter_s { @@ -27,8 +25,8 @@ struct pstuff_s static int fillchildlist (unsigned int i, unsigned int h, void *x) { - register ptreeiter_t *pt = x ; - register unsigned int j = pt->ppindex[i] ; + ptreeiter_t *pt = x ; + unsigned int j = pt->ppindex[i] ; pt->childlist[pt->childindex[j] + pt->cpos[j]++] = i ; (void)h ; return 1 ; @@ -37,7 +35,7 @@ static int fillchildlist (unsigned int i, unsigned int h, void *x) static void fillo_tree_rec (pstuff_t *blah, unsigned int root, signed int h) { static unsigned int j = 0 ; - register unsigned int i = !blah->p[root].pid ; + unsigned int i = !blah->p[root].pid ; if (blah->p[root].pid == 1) h = -1 ; blah->p[root].height = (h > 0) ? h : 0 ; blah->orderedlist[j++] = root ; @@ -55,7 +53,7 @@ void s6ps_otree (pscan_t *p, unsigned int n, avltreen *pidtree, unsigned int *or unsigned int childlist[n] ; unsigned int childindex[n] ; unsigned int nchild[n] ; - register unsigned int i = 0 ; + unsigned int i = 0 ; for (; i < n ; i++) nchild[i] = 0 ; /* Compute the ppid tree */ diff --git a/src/minutils/s6ps_pfield.c b/src/minutils/s6ps_pfield.c index ded0b41..3930d32 100644 --- a/src/minutils/s6ps_pfield.c +++ b/src/minutils/s6ps_pfield.c @@ -1,14 +1,13 @@ /* ISC license. */ +#include <stdint.h> #include <unistd.h> #include <time.h> #include <sys/sysinfo.h> -#include <skalibs/uint32.h> #include <skalibs/uint64.h> +#include <skalibs/types.h> #include <skalibs/bytestr.h> #include <skalibs/strerr2.h> -#include <skalibs/ulong.h> -#include <skalibs/fmtscan.h> #include <skalibs/tai.h> #include <skalibs/djbtime.h> #include <skalibs/stralloc.h> @@ -94,7 +93,7 @@ char const *const *s6ps_opttable = opttable ; static tain_t boottime = TAIN_EPOCH ; -static int fmt_32 (pscan_t *p, size_t *pos, size_t *len, uint32 u) +static int fmt_32 (pscan_t *p, size_t *pos, size_t *len, uint32_t u) { if (!stralloc_readyplus(&p->data, UINT32_FMT)) return 0 ; *pos = p->data.len ; @@ -103,7 +102,7 @@ static int fmt_32 (pscan_t *p, size_t *pos, size_t *len, uint32 u) return 1 ; } -static int fmt_64 (pscan_t *p, size_t *pos, size_t *len, uint64 u) +static int fmt_64 (pscan_t *p, size_t *pos, size_t *len, uint64_t u) { if (!stralloc_readyplus(&p->data, UINT64_FMT)) return 0 ; *pos = p->data.len ; @@ -220,10 +219,10 @@ int s6ps_compute_boottime (pscan_t *p, unsigned int mypos) } } -static int fmt_jiffies (pscan_t *p, size_t *pos, size_t *len, uint64 j) +static int fmt_jiffies (pscan_t *p, size_t *pos, size_t *len, uint64_t j) { unsigned int hz = gethz() ; - uint32 hrs, mins, secs, hfrac ; + uint32_t hrs, mins, secs, hfrac ; if (!stralloc_readyplus(&p->data, UINT64_FMT + 13)) return 0 ; hfrac = (j % hz) * 100 / hz ; *pos = p->data.len ; @@ -441,7 +440,7 @@ static int fmt_args (pscan_t *p, size_t *pos, size_t *len) *pos = p->data.len ; if (p->height) { - register unsigned int i = 0 ; + unsigned int i = 0 ; for (; i < 4 * (unsigned int)p->height - 3 ; i++) p->data.s[p->data.len + i] = ' ' ; byte_copy(p->data.s + p->data.len + 4 * p->height - 3, 3, "\\_ ") ; @@ -449,12 +448,12 @@ static int fmt_args (pscan_t *p, size_t *pos, size_t *len) } if (p->cmdlen) { - register char const *r = p->data.s + p->statlen + p->commlen ; - register char *w = p->data.s + p->data.len ; - register size_t i = p->cmdlen ; + char const *r = p->data.s + p->statlen + p->commlen ; + char *w = p->data.s + p->data.len ; + size_t i = p->cmdlen ; while (i--) { - register char c = *r++ ; + char c = *r++ ; *w++ = c ? c : ' ' ; } p->data.len += p->cmdlen ; @@ -472,7 +471,7 @@ static int fmt_args (pscan_t *p, size_t *pos, size_t *len) static int fmt_env (pscan_t *p, size_t *pos, size_t *len) { - register size_t i = 0 ; + size_t i = 0 ; if (!p->envlen) { if (!stralloc_catb(&p->data, "*", 1)) return 0 ; @@ -487,10 +486,10 @@ static int fmt_env (pscan_t *p, size_t *pos, size_t *len) return 1 ; } -static uint64 gettotalj (uint64 j) +static uint64_t gettotalj (uint64_t j) { tain_t totaltime ; - register unsigned int hz = gethz() ; + unsigned int hz = gethz() ; tain_sub(&totaltime, &STAMP, &boottime) ; j = totaltime.sec.x * hz + totaltime.nano / (1000000000 / hz) - j ; if (!j) j = 1 ; diff --git a/src/minutils/s6ps_pwcache.c b/src/minutils/s6ps_pwcache.c index abee250..2f4c329 100644 --- a/src/minutils/s6ps_pwcache.c +++ b/src/minutils/s6ps_pwcache.c @@ -3,7 +3,7 @@ #include <sys/types.h> #include <pwd.h> #include <errno.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/stralloc.h> #include <skalibs/genalloc.h> #include <skalibs/skamisc.h> @@ -33,7 +33,7 @@ int s6ps_pwcache_lookup (stralloc *sa, uid_t uid) if (!avltree_search(&pwcache_tree, &d.left, &i)) { struct passwd *pw ; - size_t n = genalloc_len(dius_t, &pwcache_index) ; + unsigned int n = genalloc_len(dius_t, &pwcache_index) ; errno = 0 ; pw = getpwuid(uid) ; if (!pw) @@ -45,7 +45,7 @@ int s6ps_pwcache_lookup (stralloc *sa, uid_t uid) stralloc_catb(&satmp, ")", 2) ; } else if (!stralloc_cats(&satmp, pw->pw_name) || !stralloc_0(&satmp)) return 0 ; - if (!genalloc_append(diuint, &pwcache_index, &d)) goto err ; + if (!genalloc_append(dius_t, &pwcache_index, &d)) goto err ; if (!avltree_insert(&pwcache_tree, n)) { genalloc_setlen(dius_t, &pwcache_index, n) ; @@ -53,10 +53,10 @@ int s6ps_pwcache_lookup (stralloc *sa, uid_t uid) } i = n ; } - return stralloc_cats(sa, satmp.s + genalloc_s(diuint, &pwcache_index)[i].right) ; + return stralloc_cats(sa, satmp.s + genalloc_s(dius_t, &pwcache_index)[i].right) ; err: { - register int e = errno ; + int e = errno ; if (wasnull) stralloc_free(&satmp) ; else satmp.len = d.right ; errno = e ; diff --git a/src/minutils/s6ps_statparse.c b/src/minutils/s6ps_statparse.c index b49ee28..229ed11 100644 --- a/src/minutils/s6ps_statparse.c +++ b/src/minutils/s6ps_statparse.c @@ -1,10 +1,10 @@ /* ISC license. */ +#include <stdint.h> #include <sys/types.h> #include <errno.h> -#include <skalibs/uint32.h> #include <skalibs/uint64.h> -#include <skalibs/fmtscan.h> +#include <skalibs/types.h> #include <skalibs/stralloc.h> #include <skalibs/tai.h> #include "s6-ps.h" @@ -21,13 +21,13 @@ typedef scanfunc_t *scanfunc_t_ref ; static size_t f32 (char const *s, void *u32) { - uint32 *u = u32 ; + uint32_t *u = u32 ; return uint32_scan(s, u) ; } static size_t f64 (char const *s, void *u64) { - uint64 *u = u64 ; + uint64_t *u = u64 ; return uint64_scan(s, u) ; } @@ -39,18 +39,14 @@ static size_t fint (char const *s, void *i) static size_t fpid (char const *s, void *p) { - uint64 u ; - register size_t l = uint64_scan(s, &u) ; - *(pid_t *)p = u ; - return l ; + pid_t *pid = p ; + return pid_scan(s, pid) ; } static size_t fdev (char const *s, void *p) { - uint64 u ; - register size_t l = uint64_scan(s, &u) ; - *(dev_t *)p = u ; - return l ; + dev_t *d = p ; + return dev_scan(s, d) ; } static scanfunc_t_ref scanfuncs[STATVARS] = @@ -100,8 +96,8 @@ static scanfunc_t_ref scanfuncs[STATVARS] = int s6ps_statparse (pscan_t *p) { - uint64 dummy64 ; - uint32 dummy32 ; + uint64_t dummy64 ; + uint32_t dummy32 ; size_t pos = 0 ; void *scanresults[STATVARS] = { @@ -147,7 +143,7 @@ int s6ps_statparse (pscan_t *p) &dummy32, &dummy32 } ; - register unsigned int i = 0 ; + unsigned int i = 0 ; if (!p->statlen) return 0 ; pos = uint32_scan(p->data.s, &dummy32) ; diff --git a/src/minutils/s6ps_ttycache.c b/src/minutils/s6ps_ttycache.c index dcbbc54..df59334 100644 --- a/src/minutils/s6ps_ttycache.c +++ b/src/minutils/s6ps_ttycache.c @@ -4,11 +4,11 @@ #define _BSD_SOURCE #endif -#include <sys/types.h> +#include <string.h> #include <sys/stat.h> #include <errno.h> -#include <skalibs/bytestr.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> +#include <skalibs/allreadwrite.h> #include <skalibs/buffer.h> #include <skalibs/stralloc.h> #include <skalibs/genalloc.h> @@ -55,8 +55,8 @@ static int ttyguess (stralloc *sa, dev_t ttynr) } else if (maj >= 136 && maj < 144) { + unsigned int n = ((maj - 136) << 20) | min ; char tmp[9 + UINT_FMT] = "/dev/pts/" ; - register unsigned int n = ((maj - 136) << 20) | min ; tmp[9 + uint_fmt(tmp+9, n)] = 0 ; if (check(tmp, ttynr)) return stralloc_cats(sa, tmp+5) && stralloc_0(sa) ; } @@ -64,32 +64,32 @@ static int ttyguess (stralloc *sa, dev_t ttynr) /* Use /sys/dev/char/maj:min if it exists */ { int fd ; + size_t pos = 14 ; char path[23 + 2 * UINT_FMT] = "/sys/dev/char/" ; - register size_t pos = 14 ; pos += uint_fmt(path + pos, maj) ; path[pos++] = ':' ; pos += uint_fmt(path + pos, min) ; - byte_copy(path + pos, 8, "/uevent") ; + memcpy(path + pos, "/uevent", 8) ; fd = open_read(path) ; if (fd >= 0) { char buf[4097] ; - buffer b = BUFFER_INIT(&buffer_read, fd, buf, 4097) ; + buffer b = BUFFER_INIT(&fd_readv, fd, buf, 4097) ; size_t start = satmp.len ; - register int r ; + int r ; for (;;) { satmp.len = start ; r = skagetln(&b, &satmp, '\n') ; if (r <= 0) break ; - if ((satmp.len - start) > 8 && !byte_diff(satmp.s + start, 8, "DEVNAME=")) break ; + if ((satmp.len - start) > 8 && !memcmp(satmp.s + start, "DEVNAME=", 8)) break ; } fd_close(fd) ; if (r > 0) { satmp.s[satmp.len - 1] = 0 ; satmp.len = start ; - byte_copy(satmp.s + start + 3, 5, "/dev/") ; + memcpy(satmp.s + start + 3, "/dev/", 5) ; if (check(satmp.s + start + 3, ttynr)) return stralloc_cats(sa, satmp.s + start + 8) && stralloc_0(sa) ; } @@ -98,8 +98,8 @@ static int ttyguess (stralloc *sa, dev_t ttynr) /* Fallback: print explicit maj:min */ { + size_t pos = 1 ; char tmp[3 + 2 * UINT_FMT] = "(" ; - register size_t pos = 1 ; pos += uint_fmt(tmp + pos, maj) ; tmp[pos++] = ':' ; pos += uint_fmt(tmp + pos, min) ; @@ -116,7 +116,7 @@ int s6ps_ttycache_lookup (stralloc *sa, dev_t ttynr) unsigned int i ; if (!avltree_search(&ttycache_tree, &d.left, &i)) { - size_t n = genalloc_len(dius_t, &ttycache_index) ; + unsigned int n = genalloc_len(dius_t, &ttycache_index) ; if (!ttyguess(&satmp, ttynr)) return 0 ; if (!genalloc_append(dius_t, &ttycache_index, &d)) goto err ; if (!avltree_insert(&ttycache_tree, n)) @@ -129,7 +129,7 @@ int s6ps_ttycache_lookup (stralloc *sa, dev_t ttynr) return stralloc_cats(sa, satmp.s + genalloc_s(dius_t, &ttycache_index)[i].right) ; err: { - register int e = errno ; + int e = errno ; if (wasnull) stralloc_free(&satmp) ; else satmp.len = d.right ; errno = e ; diff --git a/src/minutils/s6ps_wchan.c b/src/minutils/s6ps_wchan.c index 77ac671..209e1ef 100644 --- a/src/minutils/s6ps_wchan.c +++ b/src/minutils/s6ps_wchan.c @@ -1,9 +1,8 @@ /* ISC license. */ -#include <sys/types.h> +#include <string.h> #include <sys/utsname.h> #include <skalibs/uint64.h> -#include <skalibs/bytestr.h> #include <skalibs/stralloc.h> #include <skalibs/genalloc.h> #include <skalibs/djbunix.h> @@ -24,13 +23,13 @@ int s6ps_wchan_init (char const *file) struct utsname uts ; size_t n ; if (uname(&uts) < 0) return 0 ; - n = str_len(uts.release) ; + n = strlen(uts.release) ; { char buf[18 + n] ; - register unsigned int i = 0 ; - byte_copy(buf, 16, "/boot/System.map") ; + unsigned int i = 0 ; + memcpy(buf, "/boot/System.map", 16) ; buf[16] = '-' ; - byte_copy(buf + 17, n + 1, uts.release) ; + memcpy(buf + 17, uts.release, n + 1) ; files[1] = buf ; for (; i < 3 ; i++) if (openslurpclose(&sysmap, files[i])) break ; @@ -58,14 +57,14 @@ void s6ps_wchan_finish (void) stralloc_free(&sysmap) ; } -static inline size_t lookup (uint64 addr, size_t *i) +static inline size_t lookup (uint64_t addr, size_t *i) { size_t low = 0, mid, high = genalloc_len(size_t, &ind), len ; for (;;) { - uint64 cur ; + uint64_t cur ; mid = (low + high) >> 1 ; - len = uint64_xscan(sysmap.s + genalloc_s(unsigned int, &ind)[mid], &cur) ; + len = uint64_xscan(sysmap.s + genalloc_s(size_t, &ind)[mid], &cur) ; if (!len) return 0 ; if (cur == addr) break ; if (mid == low) return 0 ; @@ -75,16 +74,14 @@ static inline size_t lookup (uint64 addr, size_t *i) return len ; } -int s6ps_wchan_lookup (stralloc *sa, uint64 addr) +int s6ps_wchan_lookup (stralloc *sa, uint64_t addr) { if (addr == (sizeof(void *) == 8 ? 0xffffffffffffffffULL : 0xffffffffUL)) return stralloc_catb(sa, "*", 1) ; if (!addr) return stralloc_catb(sa, "-", 1) ; if (sysmap.len) { - size_t i ; - size_t len = lookup(addr, &i) ; - register size_t pos ; + size_t i, pos, len = lookup(addr, &i) ; if (!len) return stralloc_catb(sa, "?", 1) ; pos = genalloc_s(size_t, &ind)[i] + len + 3 ; return stralloc_catb(sa, sysmap.s + pos, genalloc_s(size_t, &ind)[i+1] - 1 - pos) ; |