Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: RLIMIT_RTTIME



We don't handle this limit, new in recent Linux kernels.  It's in
microseconds, so I've added a type to distinguish from pure numbers.

For some reason we couldn't be bothered to output the full range of pure
numeric resources but cast them to integers.  Probably just laziness.
I've fixed it.

gcc 4.6.0 is producing a range of "value set but not used" warnings that
will want looking at.

Index: Src/Builtins/rlimits.awk
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Builtins/rlimits.awk,v
retrieving revision 1.8
diff -p -u -r1.8 rlimits.awk
--- Src/Builtins/rlimits.awk	17 Mar 2006 23:35:04 -0000	1.8
+++ Src/Builtins/rlimits.awk	18 Jun 2011 23:52:38 -0000
@@ -53,6 +53,7 @@ BEGIN {limidx = 0}
 	    if (limnam == "MSGQUEUE") { msg[limnum] = "Nmsgqueue" }
 	    if (limnam == "NICE") { msg[limnum] = "Nnice" }
 	    if (limnam == "RTPRIO") { msg[limnum] = "Nrt_priority" }
+	    if (limnam == "RTTIME") { msg[limnum] = "Urt_time" }
         }
     }
 }
@@ -99,6 +100,7 @@ END {
 	    if(limtype == "M") { limtype = "MEMORY" }
 	    if(limtype == "N") { limtype = "NUMBER" }
 	    if(limtype == "T") { limtype = "TIME" }
+	    if(limtype == "U") { limtype = "MICROSECONDS" }
 	}
 	printf("\tZLIMTYPE_%s,\n", limtype)
     }
Index: Src/Builtins/rlimits.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Builtins/rlimits.c,v
retrieving revision 1.23
diff -p -u -r1.23 rlimits.c
--- Src/Builtins/rlimits.c	13 May 2011 18:12:06 -0000	1.23
+++ Src/Builtins/rlimits.c	18 Jun 2011 23:52:38 -0000
@@ -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, Option
 		    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;
Index: Src/Builtins/rlimits.mdd
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Builtins/rlimits.mdd,v
retrieving revision 1.5
diff -p -u -r1.5 rlimits.mdd
--- Src/Builtins/rlimits.mdd	3 Feb 2010 18:37:07 -0000	1.5
+++ Src/Builtins/rlimits.mdd	18 Jun 2011 23:52:38 -0000
@@ -14,7 +14,7 @@ rlimits.o rlimits..o: rlimits.h
 rlimits.h: rlimits.awk @RLIMITS_INC_H@
 	$(AWK) -f $(sdir)/rlimits.awk @RLIMITS_INC_H@ /dev/null > rlimits.h
 	@if grep ZLIMTYPE_UNKNOWN rlimits.h >/dev/null; then \
-	    echo >&2 WARNING: unknown limits: mail rlimits.h to developers; \
+	    echo >&2 WARNING: unknown limits: mail Src/Builtins/rlimits.h to developers; \
 	else :; fi
 
 clean-here: clean.rlimits

-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/



Messages sorted by: Reverse Date, Date, Thread, Author