* zic.c (ZIC_MIN, ZIC_MAX, readlink, symlink): Now ordinary symbols instead of macros, as C macros are too powerful and not needed here. (link): Remove this macro; no longer needed. (linkat): Use HAVE_LINK directly. This should be a bit faster on systems that have symlinks but not hard links, since it avoids an unnecessary readlink call. --- zic.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/zic.c b/zic.c index e18506d..c549c85 100644 --- a/zic.c +++ b/zic.c @@ -23,8 +23,9 @@ #include <stdio.h> typedef int_fast64_t zic_t; -#define ZIC_MIN INT_FAST64_MIN -#define ZIC_MAX INT_FAST64_MAX +static zic_t const + ZIC_MIN = INT_FAST64_MIN, + ZIC_MAX = INT_FAST64_MAX; #define SCNdZIC SCNdFAST64 #ifndef ZIC_MAX_ABBR_LEN_WO_WARN @@ -137,17 +138,29 @@ extern char * optarg; extern int optind; #endif -#if ! HAVE_LINK -# define link(target, linkname) (errno = ENOTSUP, -1) -#endif #if ! HAVE_SYMLINK -# define readlink(file, buf, size) (errno = ENOTSUP, -1) -# define symlink(target, linkname) (errno = ENOTSUP, -1) +static ssize_t +readlink(char const *restrict file, char *restrict buf, size_t size) +{ + errno = ENOTSUP; + return -1; +} +static int +symlink(char const *target, char const *linkname) +{ + errno = ENOTSUP; + return -1; +} # define S_ISLNK(m) 0 #endif #ifndef AT_SYMLINK_FOLLOW -# define linkat(targetdir, target, linknamedir, linkname, flag) \ - (itssymlink(target) ? (errno = ENOTSUP, -1) : link(target, linkname)) +# if HAVE_LINK +# define linkat(targetdir, target, linknamedir, linkname, flag) \ + (itssymlink(target) ? (errno = ENOTSUP, -1) : link(target, linkname)) +# else +# define linkat(targetdir, target, linknamedir, linkname, flag) \ + (errno = ENOTSUP, -1) +# endif #endif static void addtt(zic_t starttime, int type); -- 2.37.3