From 168d9538f16869d4cdcbcc01a5ddce0af4a8b918 Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Sat, 22 Oct 2022 15:31:21 +0200 Subject: fix and install ts --- src/liboutils/outils.h | 32 ++++++++++++++++++++++++++++---- src/usr.bin/ts/ts.c | 4 +++- 2 files changed, 31 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/liboutils/outils.h b/src/liboutils/outils.h index 1e628ed..7e9a7ec 100644 --- a/src/liboutils/outils.h +++ b/src/liboutils/outils.h @@ -1,9 +1,9 @@ #define DEF_WEAK(x) #define __weak_alias(new, old) \ - extern __typeof(old) new __attribute__((weak, alias(#old))) + extern __typeof(old) new __attribute__((weak, alias(#old))) #define MAKE_CLONE(new, old) \ - extern __typeof(old) new __attribute__((weak, alias(#old))) + extern __typeof(old) new __attribute__((weak, alias(#old))) #define __dead __attribute__((__noreturn__)) #define __BEGIN_DECLS #define __END_DECLS @@ -17,10 +17,34 @@ #ifndef SA_LEN #define SA_LEN(X) \ - (((struct sockaddr*)(X))->sa_family == AF_INET ? sizeof(struct sockaddr_in) : \ - ((struct sockaddr*)(X))->sa_family == AF_INET6 ? sizeof(struct sockaddr_in6) : sizeof(struct sockaddr)) + (((struct sockaddr*)(X))->sa_family == AF_INET ? sizeof(struct sockaddr_in) : \ + ((struct sockaddr*)(X))->sa_family == AF_INET6 ? sizeof(struct sockaddr_in6) : sizeof(struct sockaddr)) #endif +#ifndef timespecadd +#define timespecadd(tsp, usp, vsp) \ + do { \ + (vsp)->tv_sec = (tsp)->tv_sec + (usp)->tv_sec; \ + (vsp)->tv_nsec = (tsp)->tv_nsec + (usp)->tv_nsec; \ + if ((vsp)->tv_nsec >= 1000000000L) { \ + (vsp)->tv_sec++; \ + (vsp)->tv_nsec -= 1000000000L; \ + } \ + } while (0) +#endif +#ifndef timespecsub +#define timespecsub(tsp, usp, vsp) \ + do { \ + (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \ + (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \ + if ((vsp)->tv_nsec < 0) { \ + (vsp)->tv_sec--; \ + (vsp)->tv_nsec += 1000000000L; \ + } \ + } while (0) +#endif + + #include #include #include diff --git a/src/usr.bin/ts/ts.c b/src/usr.bin/ts/ts.c index f8e3cb0..2d82b82 100644 --- a/src/usr.bin/ts/ts.c +++ b/src/usr.bin/ts/ts.c @@ -131,10 +131,12 @@ main(int argc, char *argv[]) return 0; } +extern char *__progname; + static void __dead usage(void) { - fprintf(stderr, "usage: %s [-i | -s] [-m] [format]\n", getprogname()); + fprintf(stderr, "usage: %s [-i | -s] [-m] [format]\n", __progname); exit(1); } -- cgit 1.4.1