From c31caeb0869803e226cf5ad6669635c2ebafd429 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Sun, 19 Jun 2011 00:10:34 +0000 Subject: 29490: add RLIMIT_RTTIME --- Src/Builtins/rlimits.c | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'Src/Builtins/rlimits.c') diff --git a/Src/Builtins/rlimits.c b/Src/Builtins/rlimits.c index ffcb92052..73bbe10f1 100644 --- a/Src/Builtins/rlimits.c +++ b/Src/Builtins/rlimits.c @@ -36,6 +36,7 @@ enum { ZLIMTYPE_MEMORY, ZLIMTYPE_NUMBER, ZLIMTYPE_TIME, + ZLIMTYPE_MICROSECONDS, ZLIMTYPE_UNKNOWN }; @@ -113,10 +114,37 @@ showlimitvalue(int lim, rlim_t val) seconds. */ printf("%d:%02d:%02d\n", (int)(val / 3600), (int)(val / 60) % 60, (int)(val % 60)); + } else if (limtype[lim] == ZLIMTYPE_MICROSECONDS) { + /* microseconds */ +# ifdef RLIM_T_IS_QUAD_T + printf("%qdus\n", val); +# else +# ifdef RLIM_T_IS_LONG_LONG + printf("%lldus\n", val); +# else +# ifdef RLIM_T_IS_UNSIGNED + printf("%luus\n", val); +# else + printf("%ldus\n", val); +# endif /* RLIM_T_IS_UNSIGNED */ +# endif /* RLIM_T_IS_LONG_LONG */ +# endif /* RLIM_T_IS_QUAD_T */ } else if (limtype[lim] == ZLIMTYPE_NUMBER || limtype[lim] == ZLIMTYPE_UNKNOWN) { /* pure numeric resource */ - printf("%d\n", (int)val); +# ifdef RLIM_T_IS_QUAD_T + printf("%qd\n", val); +# else +# ifdef RLIM_T_IS_LONG_LONG + printf("%lld\n", val); +# else +# ifdef RLIM_T_IS_UNSIGNED + printf("%lu\n", val); +# else + printf("%ld\n", val); +# endif /* RLIM_T_IS_UNSIGNED */ +# endif /* RLIM_T_IS_LONG_LONG */ +# endif /* RLIM_T_IS_QUAD_T */ } else if (val >= 1024L * 1024L) /* memory resource -- display with `K' or `M' modifier */ # ifdef RLIM_T_IS_QUAD_T @@ -125,7 +153,7 @@ showlimitvalue(int lim, rlim_t val) printf("%qdkB\n", val / 1024L); # else # ifdef RLIM_T_IS_LONG_LONG - printf("%lldMB\n", val / (1024L * 1024L)); + printf("%lldMB\n", val / (1024L * 1024L)); else printf("%lldkB\n", val / 1024L); # else @@ -539,7 +567,9 @@ bin_limit(char *nam, char **argv, Options ops, UNUSED(int func)) return 1; } } - } else if (limtype[lim] == ZLIMTYPE_NUMBER || limtype[lim] == ZLIMTYPE_UNKNOWN) { + } else if (limtype[lim] == ZLIMTYPE_NUMBER || + limtype[lim] == ZLIMTYPE_UNKNOWN || + limtype[lim] == ZLIMTYPE_MICROSECONDS) { /* pure numeric resource -- only a straight decimal number is permitted. */ char *t = s; -- cgit v1.2.3 From fdb00982f5405a869392e0dfea6a76e044af212a Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Mon, 31 Oct 2011 09:48:58 +0000 Subject: Jun T: 29883: cast resource types to types they should be anyway --- ChangeLog | 8 +++++++- Src/Builtins/rlimits.c | 24 ++++++++++++------------ Src/Modules/zftp.c | 2 +- 3 files changed, 20 insertions(+), 14 deletions(-) (limited to 'Src/Builtins/rlimits.c') diff --git a/ChangeLog b/ChangeLog index 61d4e4643..84e92c328 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-10-31 Peter Stephenson + + * Jun T: 29883: Src/Builtins/rlimits.c, Src/Modules/zftp.c: cast + to type in printf to work around cases where types aren't + properly distinguished. + 2011-10-30 Peter Stephenson * users/16547: Completion/Unix/Command/_perforce: quote @@ -15527,5 +15533,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5490 $ +* $Revision: 1.5491 $ ***************************************************** diff --git a/Src/Builtins/rlimits.c b/Src/Builtins/rlimits.c index 73bbe10f1..670516169 100644 --- a/Src/Builtins/rlimits.c +++ b/Src/Builtins/rlimits.c @@ -102,9 +102,9 @@ showlimitvalue(int lim, rlim_t val) printf("%lld\n", val); # else # ifdef RLIM_T_IS_UNSIGNED - printf("%lu\n", val); + printf("%lu\n", (unsigned long)val); # else - printf("%ld\n", val); + printf("%ld\n", (long)val); # endif /* RLIM_T_IS_UNSIGNED */ # endif /* RLIM_T_IS_LONG_LONG */ # endif /* RLIM_T_IS_QUAD_T */ @@ -123,9 +123,9 @@ showlimitvalue(int lim, rlim_t val) printf("%lldus\n", val); # else # ifdef RLIM_T_IS_UNSIGNED - printf("%luus\n", val); + printf("%luus\n", (unsigned long)val); # else - printf("%ldus\n", val); + printf("%ldus\n", (long)val); # endif /* RLIM_T_IS_UNSIGNED */ # endif /* RLIM_T_IS_LONG_LONG */ # endif /* RLIM_T_IS_QUAD_T */ @@ -139,9 +139,9 @@ showlimitvalue(int lim, rlim_t val) printf("%lld\n", val); # else # ifdef RLIM_T_IS_UNSIGNED - printf("%lu\n", val); + printf("%lu\n", (unsigned long)val); # else - printf("%ld\n", val); + printf("%ld\n", (long)val); # endif /* RLIM_T_IS_UNSIGNED */ # endif /* RLIM_T_IS_LONG_LONG */ # endif /* RLIM_T_IS_QUAD_T */ @@ -158,13 +158,13 @@ showlimitvalue(int lim, rlim_t val) printf("%lldkB\n", val / 1024L); # else # ifdef RLIM_T_IS_UNSIGNED - printf("%luMB\n", val / (1024L * 1024L)); + printf("%luMB\n", (unsigned long)(val / (1024L * 1024L))); else - printf("%lukB\n", val / 1024L); + printf("%lukB\n", (unsigned long)(val / 1024L)); # else - printf("%ldMB\n", val / (1024L * 1024L)); + printf("%ldMB\n", (long)val / (1024L * 1024L)); else - printf("%ldkB\n", val / 1024L); + printf("%ldkB\n", (long)val / 1024L); # endif /* RLIM_T_IS_UNSIGNED */ # endif /* RLIM_T_IS_LONG_LONG */ # endif /* RLIM_T_IS_QUAD_T */ @@ -398,9 +398,9 @@ printulimit(char *nam, int lim, int hard, int head) printf("%lld\n", limit); # else # ifdef RLIM_T_IS_UNSIGNED - printf("%lu\n", limit); + printf("%lu\n", (unsigned long)limit); # else - printf("%ld\n", limit); + printf("%ld\n", (long)limit); # endif /* RLIM_T_IS_UNSIGNED */ # endif /* RLIM_T_IS_LONG_LONG */ # endif /* RLIM_T_IS_QUAD_T */ diff --git a/Src/Modules/zftp.c b/Src/Modules/zftp.c index 8d688abd4..d16e2f618 100644 --- a/Src/Modules/zftp.c +++ b/Src/Modules/zftp.c @@ -2520,7 +2520,7 @@ zftp_local(UNUSED(char *name), char **args, int flags) printf("%s %s\n", output64(sz), mt); #else DPUTS(sizeof(sz) > 4, "Shell compiled with wrong off_t size"); - printf("%ld %s\n", sz, mt); + printf("%ld %s\n", (long)sz, mt); #endif zsfree(mt); if (dofd) -- cgit v1.2.3