about summary refs log tree commit diff
path: root/Src/Builtins/rlimits.awk
diff options
context:
space:
mode:
Diffstat (limited to 'Src/Builtins/rlimits.awk')
-rw-r--r--Src/Builtins/rlimits.awk61
1 files changed, 39 insertions, 22 deletions
diff --git a/Src/Builtins/rlimits.awk b/Src/Builtins/rlimits.awk
index e2500582a..f90fc3d7b 100644
--- a/Src/Builtins/rlimits.awk
+++ b/Src/Builtins/rlimits.awk
@@ -6,7 +6,7 @@
 #
 BEGIN {limidx = 0}
 
-/^[\t ]*(#[\t ]*define[\t _]*RLIMIT_[A-Z]*[\t ]*[0-9][0-9]*|RLIMIT_[A-Z]*,[\t ]*)/ {
+/^[\t ]*(#[\t ]*define[\t _]*RLIMIT_[A-Z_]*[\t ]*[0-9][0-9]*|RLIMIT_[A-Z_]*,[\t ]*)/ {
     limindex = index($0, "RLIMIT_")
     limtail = substr($0, limindex, 80)
     split(limtail, tmp)
@@ -22,19 +22,24 @@ BEGIN {limidx = 0}
     if (lim[limnum] == "") {
 	lim[limnum] = limnam
 	if (limnum ~ /^[0-9]*$/) {
-	    if (limnam == "MEMLOCK") { msg[limnum] = "memorylocked" }
-	    if (limnam == "RSS")     { msg[limnum] = "resident" }
-	    if (limnam == "VMEM")    { msg[limnum] = "vmemorysize" }
-	    if (limnam == "NOFILE")  { msg[limnum] = "descriptors" }
-	    if (limnam == "OFILE")   { msg[limnum] = "descriptors" }
-	    if (limnam == "CORE")    { msg[limnum] = "coredumpsize" }
-	    if (limnam == "STACK")   { msg[limnum] = "stacksize" }
-	    if (limnam == "DATA")    { msg[limnum] = "datasize" }
-	    if (limnam == "FSIZE")   { msg[limnum] = "filesize" }
-	    if (limnam == "CPU")     { msg[limnum] = "cputime" }
-	    if (limnam == "NPROC")   { msg[limnum] = "maxproc" }
-	    if (limnam == "AS")      { msg[limnum] = "addressspace" }
-	    if (limnam == "TCACHE")  { msg[limnum] = "cachedthreads" }
+	    if (limnam == "AIO_MEM") { msg[limnum] = "Maiomemorylocked" }
+	    if (limnam == "AIO_OPS") { msg[limnum] = "Naiooperations" }
+	    if (limnam == "AS")      { msg[limnum] = "Maddressspace" }
+	    if (limnam == "CORE")    { msg[limnum] = "Mcoredumpsize" }
+	    if (limnam == "CPU")     { msg[limnum] = "Tcputime" }
+	    if (limnam == "DATA")    { msg[limnum] = "Mdatasize" }
+	    if (limnam == "FSIZE")   { msg[limnum] = "Mfilesize" }
+	    if (limnam == "LOCKS")   { msg[limnum] = "Nmaxfilelocks" }
+	    if (limnam == "MEMLOCK") { msg[limnum] = "Mmemorylocked" }
+	    if (limnam == "NOFILE")  { msg[limnum] = "Ndescriptors" }
+	    if (limnam == "NPROC")   { msg[limnum] = "Nmaxproc" }
+	    if (limnam == "OFILE")   { msg[limnum] = "Ndescriptors" }
+	    if (limnam == "PTHREAD") { msg[limnum] = "Nmaxpthreads" }
+	    if (limnam == "RSS")     { msg[limnum] = "Mresident" }
+	    if (limnam == "SBSIZE")  { msg[limnum] = "Msockbufsize" }
+	    if (limnam == "STACK")   { msg[limnum] = "Mstacksize" }
+	    if (limnam == "TCACHE")  { msg[limnum] = "Ncachedthreads" }
+	    if (limnam == "VMEM")    { msg[limnum] = "Mvmemorysize" }
         }
     }
 }
@@ -52,21 +57,33 @@ BEGIN {limidx = 0}
 END {
     if (limrev["MEMLOCK"] != "") {
         irss = limrev["RSS"]
-        msg[irss] = "memoryuse"
+        msg[irss] = "Mmemoryuse"
     }
     ps = "%s"
 
     printf("%s\n%s\n\n", "/** rlimits.h                              **/", "/** architecture-customized limits for zsh **/")
-    printf("#define ZSH_NLIMITS %d\n\nstatic char *recs[ZSH_NLIMITS+1] = {\n", 0 + nlimits)
+    printf("#define ZSH_NLIMITS %d\n\nstatic char const *recs[ZSH_NLIMITS] = {\n", 0 + nlimits)
 
     for (i = 0; i < 0 + nlimits; i++)
-	if (msg[i] == "") {
-            badlimit++
+	if (msg[i] == "")
             printf("\t%c%s%c,\n", 34, lim[i], 34)
-	} else
-	    printf("\t%c%s%c,\n", 34, msg[i], 34)
-    print "\tNULL"
+	else
+	    printf("\t%c%s%c,\n", 34, substr(msg[i], 2, 30), 34)
     print "};"
     print ""
-    exit(badlimit)
+    print "static int limtype[ZSH_NLIMITS] = {"
+    for (i = 0; i < 0 + nlimits; i++) {
+	if (msg[i] == "")
+	    limtype = "UNKNOWN"
+	else {
+	    limtype = substr(msg[i], 1, 1)
+	    if(limtype == "M") { limtype = "MEMORY" }
+	    if(limtype == "N") { limtype = "NUMBER" }
+	    if(limtype == "T") { limtype = "TIME" }
+	}
+	printf("\tZLIMTYPE_%s,\n", limtype)
+    }
+    print "};"
+
+    exit(0)
 }