zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: RLIMITS macros
@ 2003-03-31 10:16 Peter Stephenson
  2003-03-31 18:54 ` Bart Schaefer
  0 siblings, 1 reply; 12+ messages in thread
From: Peter Stephenson @ 2003-03-31 10:16 UTC (permalink / raw)
  To: Zsh hackers list

Attempt to fix the clashing limits problem.

Could someone affected please try it?

Index: zshconfig.ac
===================================================================
RCS file: /cvsroot/zsh/zsh/zshconfig.ac,v
retrieving revision 1.35
diff -u -r1.35 zshconfig.ac
--- zshconfig.ac	24 Mar 2003 12:56:59 -0000	1.35
+++ zshconfig.ac	31 Mar 2003 10:13:56 -0000
@@ -1221,6 +1221,65 @@
   AC_DEFINE_UNQUOTED(rlim_t, $DEFAULT_RLIM_T)
 fi
 
+
+dnl On some systems the RLIMIT_* are macros which don't evaluate
+dnl to integers at compile time.  In this case we are not able to
+dnl do preprocessor comparisions and need our tests to determine
+dnl if there are clashing definitions.
+AC_CACHE_CHECK(if RLIMIT_VMEM and RLIMIT_RSS are the same,
+zsh_cv_rlimit_vmem_is_rss,
+[AC_TRY_RUN([
+#include <sys/types.h>
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#include <sys/resource.h>
+int main()
+{
+int ret = 1;
+#ifdef RLIMIT_VMEM
+#ifdef RLIMIT_RSS
+if (RLIMIT_RSS == RLIMIT_VMEM) ret = 0;
+#endif
+#endif
+return ret;
+}],
+  zsh_cv_rlimit_vmem_is_rss=yes,
+  zsh_cv_rlimit_vmem_is_rss=no,
+  zsh_cv_rlimit_vmem_is_rss=no)])
+
+if test $zsh_cv_rlimit_vmem_is_rss = yes; then
+  AC_DEFINE(RLIMIT_VMEM_IS_RSS)
+fi
+
+
+AC_CACHE_CHECK(if RLIMIT_VMEM and RLIMIT_AS are the same,
+zsh_cv_rlimit_vmem_is_as,
+[AC_TRY_RUN([
+#include <sys/types.h>
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#include <sys/resource.h>
+int main()
+{
+int ret = 1;
+#ifdef RLIMIT_VMEM
+#ifdef RLIMIT_AS
+if (RLIMIT_AS == RLIMIT_VMEM) ret = 0;
+#endif
+#endif
+return ret;
+}],
+  zsh_cv_rlimit_vmem_is_as=yes,
+  zsh_cv_rlimit_vmem_is_as=no,
+  zsh_cv_rlimit_vmem_is_as=no)])
+
+if test $zsh_cv_rlimit_vmem_is_as = yes; then
+  AC_DEFINE(RLIMIT_VMEM_IS_AS)
+fi
+
+
 dnl ----------------------------
 dnl CHECK FOR /dev/fd FILESYSTEM
 dnl ----------------------------
Index: acconfig.h
===================================================================
RCS file: /cvsroot/zsh/zsh/acconfig.h,v
retrieving revision 1.14
diff -u -r1.14 acconfig.h
--- acconfig.h	6 May 2002 14:50:10 -0000	1.14
+++ acconfig.h	31 Mar 2003 10:13:56 -0000
@@ -238,6 +238,12 @@
 /* Define to the type used in struct rlimit */
 #undef rlim_t
 
+/* Define to 1 if RLIMIT_VMEM and RLIMIT_RSS both exist and are equal */
+#undef RLIMIT_VMEM_IS_RSS
+
+/* Define to 1 if RLIMIT_VMEM and RLIMIT_AS both exist and are equal */
+#undef RLIMIT_VMEM_IS_AS
+
 /* Define to 1 if /bin/sh does not interpret \ escape sequences */
 #undef SH_USE_BSD_ECHO
 
Index: Src/Builtins/rlimits.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Builtins/rlimits.c,v
retrieving revision 1.8
diff -u -r1.8 rlimits.c
--- Src/Builtins/rlimits.c	9 Feb 2003 01:12:38 -0000	1.8
+++ Src/Builtins/rlimits.c	31 Mar 2003 10:13:56 -0000
@@ -175,7 +175,7 @@
 	break;
 /* If RLIMIT_VMEM and RLIMIT_RSS are defined and equal, avoid *
  * duplicate case statement.  Observed on QNX Neutrino 6.1.0. */
-# if defined(RLIMIT_RSS) && (!defined(RLIMIT_VMEM) || RLIMIT_VMEM != RLIMIT_RSS)
+# if defined(RLIMIT_RSS) && !defined(RLIMIT_VMEM_IS_RSS)
     case RLIMIT_RSS:
 	if (head)
 	    printf("resident set size (kbytes) ");
@@ -206,7 +206,7 @@
 # ifdef RLIMIT_VMEM
     case RLIMIT_VMEM:
 	if (head)
-#  if defined(RLIMIT_RSS) && RLIMIT_VMEM == RLIMIT_RSS
+#  if defined(RLIMIT_RSS) && defined(RLIMIT_VMEM_IS_RSS)
 	    printf("memory size (kb)           ");
 #  else
 	    printf("virtual memory size (kb)   ");
@@ -215,7 +215,7 @@
 	    limit /= 1024;
 	break;
 # endif /* RLIMIT_VMEM */
-# if defined RLIMIT_AS && RLIMIT_AS != RLIMIT_VMEM
+# if defined RLIMIT_AS && !defined(RLIMIT_VMEM_IS_AS)
     case RLIMIT_AS:
 	if (head)
 	    printf("address space (kb)         ");
@@ -579,7 +579,7 @@
 # endif /* RLIMIT_MEMLOCK */
 /* If RLIMIT_VMEM and RLIMIT_RSS are defined and equal, avoid *
  * duplicate case statement.  Observed on QNX Neutrino 6.1.0. */
-# if defined(RLIMIT_VMEM) && (!defined(RLIMIT_RSS) || RLIMIT_RSS != RLIMIT_VMEM)
+# if defined(RLIMIT_VMEM) && !defined(RLIMIT_VMEM_IS_RSS)
 	    case RLIMIT_VMEM:
 # endif /* RLIMIT_VMEM */
 # ifdef RLIMIT_AIO_MEM

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: PATCH: RLIMITS macros
  2003-03-31 10:16 PATCH: RLIMITS macros Peter Stephenson
@ 2003-03-31 18:54 ` Bart Schaefer
  2003-04-01  9:40   ` Peter Stephenson
  0 siblings, 1 reply; 12+ messages in thread
From: Bart Schaefer @ 2003-03-31 18:54 UTC (permalink / raw)
  To: Zsh hackers list

On Mar 31, 11:16am, Peter Stephenson wrote:
}
} Could someone affected please try it?

Applied patch, "make clean", remove config.cache, rerun configure, make:

checking if RLIMIT_VMEM and RLIMIT_RSS are the same... no
checking if RLIMIT_VMEM and RLIMIT_AS are the same... no

gcc -c -I. -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHAVE_CONFIG_H -Wall -Wmissing-prototypes -ggdb  -o rlimits.o
../../../zsh-4.0/Src/Builtins/rlimits.c
../../../zsh-4.0/Src/Builtins/rlimits.c: In function `printulimit':
../../../zsh-4.0/Src/Builtins/rlimits.c:219: duplicate case value
../../../zsh-4.0/Src/Builtins/rlimits.c:207: this is the first entry for that value
make[3]: *** [rlimits.o] Error 1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: PATCH: RLIMITS macros
  2003-03-31 18:54 ` Bart Schaefer
@ 2003-04-01  9:40   ` Peter Stephenson
  2003-04-01 10:20     ` Peter Stephenson
  2003-04-01 15:47     ` Bart Schaefer
  0 siblings, 2 replies; 12+ messages in thread
From: Peter Stephenson @ 2003-04-01  9:40 UTC (permalink / raw)
  To: Zsh hackers list

"Bart Schaefer" wrote:
> checking if RLIMIT_VMEM and RLIMIT_RSS are the same... no
> checking if RLIMIT_VMEM and RLIMIT_AS are the same... no
> 
> gcc -c -I. -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHAVE_CONFIG_H -Wall -
> Wmissing-prototypes -ggdb  -o rlimits.o
> ../../../zsh-4.0/Src/Builtins/rlimits.c
> ../../../zsh-4.0/Src/Builtins/rlimits.c: In function `printulimit':
> ../../../zsh-4.0/Src/Builtins/rlimits.c:219: duplicate case value
> ../../../zsh-4.0/Src/Builtins/rlimits.c:207: this is the first entry for that
>  value
> make[3]: *** [rlimits.o] Error 1

Does that mean RLIMIT_AS and RLIMIT_VMEM aren't actually definitions at
all?  That's the only conclusion I can see.  Presumably it's necessary
to test compilation with RLIMIT_VMEM, RLIMIT_RSS, RLIMIT_AS, use
these to define HAVE_RLIMIT_VMEM, HAVE_RLIMIT_RSS, HAVE_RLIMIT_AS, and
replace the #ifdef's in the configure tests with those.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: PATCH: RLIMITS macros
  2003-04-01  9:40   ` Peter Stephenson
@ 2003-04-01 10:20     ` Peter Stephenson
  2003-04-01 15:47     ` Bart Schaefer
  1 sibling, 0 replies; 12+ messages in thread
From: Peter Stephenson @ 2003-04-01 10:20 UTC (permalink / raw)
  To: Zsh hackers list

Peter Stephenson wrote:
> Does that mean RLIMIT_AS and RLIMIT_VMEM aren't actually definitions at
> all?  That's the only conclusion I can see.  Presumably it's necessary
> to test compilation with RLIMIT_VMEM, RLIMIT_RSS, RLIMIT_AS, use
> these to define HAVE_RLIMIT_VMEM, HAVE_RLIMIT_RSS, HAVE_RLIMIT_AS, and
> replace the #ifdef's in the configure tests with those.

[OK, now running in gung-ho mode and not waiting for responses.]

This is about the best I can come up with.  If this doesn't work, I'm
stuck.  This is a cumulative patch of the old bit and the new bit since
I haven't committed anything yet.

Index: acconfig.h
===================================================================
RCS file: /cvsroot/zsh/zsh/acconfig.h,v
retrieving revision 1.14
diff -u -r1.14 acconfig.h
--- acconfig.h	6 May 2002 14:50:10 -0000	1.14
+++ acconfig.h	1 Apr 2003 10:16:24 -0000
@@ -238,6 +238,21 @@
 /* Define to the type used in struct rlimit */
 #undef rlim_t
 
+/* Define to 1 if RLIMIT_VMEM is present (whether or not as a macro) */
+#undef HAVE_RLIMIT_VMEM
+
+/* Define to 1 if RLIMIT_RSS is present (whether or not as a macro) */
+#undef HAVE_RLIMIT_RSS
+
+/* Define to 1 if RLIMIT_AS is present (whether or not as a macro) */
+#undef HAVE_RLIMIT_AS
+
+/* Define to 1 if RLIMIT_VMEM and RLIMIT_RSS both exist and are equal */
+#undef RLIMIT_VMEM_IS_RSS
+
+/* Define to 1 if RLIMIT_VMEM and RLIMIT_AS both exist and are equal */
+#undef RLIMIT_VMEM_IS_AS
+
 /* Define to 1 if /bin/sh does not interpret \ escape sequences */
 #undef SH_USE_BSD_ECHO
 
Index: zshconfig.ac
===================================================================
RCS file: /cvsroot/zsh/zsh/zshconfig.ac,v
retrieving revision 1.35
diff -u -r1.35 zshconfig.ac
--- zshconfig.ac	24 Mar 2003 12:56:59 -0000	1.35
+++ zshconfig.ac	1 Apr 2003 10:16:24 -0000
@@ -1221,6 +1221,109 @@
   AC_DEFINE_UNQUOTED(rlim_t, $DEFAULT_RLIM_T)
 fi
 
+
+dnl On some systems the RLIMIT_* are macros which don't evaluate
+dnl to integers at compile time.  In this case we are not able to
+dnl do preprocessor comparisions and need our tests to determine
+dnl if there are clashing definitions.
+AC_CACHE_CHECK(if RLIMIT_VMEM exists,
+zsh_cv_rlimit_vmem,
+[AC_TRY_COMPILE([
+#include <sys/types.h>
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#include <sys/resource.h>],
+[RLIMIT_VMEM],
+  zsh_cv_rlimit_vmem=yes,
+  zsh_cv_rlimit_vmem=no)])
+
+if test $zsh_cv_rlimit_vmem = yes; then
+  AC_DEFINE(HAVE_RLIMIT_VMEM)
+fi
+
+AC_CACHE_CHECK(if RLIMIT_RSS exists,
+zsh_cv_rlimit_rss,
+[AC_TRY_COMPILE([
+#include <sys/types.h>
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#include <sys/resource.h>],
+[RLIMIT_RSS],
+  zsh_cv_rlimit_rss=yes,
+  zsh_cv_rlimit_rss=no)])
+
+if test $zsh_cv_rlimit_rss = yes; then
+  AC_DEFINE(HAVE_RLIMIT_RSS)
+fi
+
+AC_CACHE_CHECK(if RLIMIT_AS exists,
+zsh_cv_rlimit_as,
+[AC_TRY_COMPILE([
+#include <sys/types.h>
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#include <sys/resource.h>],
+[RLIMIT_AS],
+  zsh_cv_rlimit_as=yes,
+  zsh_cv_rlimit_as=no)])
+
+if test $zsh_cv_rlimit_as = yes; then
+  AC_DEFINE(HAVE_RLIMIT_AS)
+fi
+
+AC_CACHE_CHECK(if RLIMIT_VMEM and RLIMIT_RSS are the same,
+zsh_cv_rlimit_vmem_is_rss,
+[AC_TRY_RUN([
+#include <sys/types.h>
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#include <sys/resource.h>
+int main()
+{
+int ret = 1;
+#if defined(HAVE_RLIMIT_VMEM) && defined(HAVE_RLIMIT_RSS)
+if (RLIMIT_RSS == RLIMIT_VMEM) ret = 0;
+#endif
+return ret;
+}],
+  zsh_cv_rlimit_vmem_is_rss=yes,
+  zsh_cv_rlimit_vmem_is_rss=no,
+  zsh_cv_rlimit_vmem_is_rss=no)])
+
+if test $zsh_cv_rlimit_vmem_is_rss = yes; then
+  AC_DEFINE(RLIMIT_VMEM_IS_RSS)
+fi
+
+
+AC_CACHE_CHECK(if RLIMIT_VMEM and RLIMIT_AS are the same,
+zsh_cv_rlimit_vmem_is_as,
+[AC_TRY_RUN([
+#include <sys/types.h>
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#include <sys/resource.h>
+int main()
+{
+int ret = 1;
+#if defined(HAVE_RLIMIT_VMEM) && defined(HAVE_RLIMIT_AS)
+if (RLIMIT_AS == RLIMIT_VMEM) ret = 0;
+#endif
+return ret;
+}],
+  zsh_cv_rlimit_vmem_is_as=yes,
+  zsh_cv_rlimit_vmem_is_as=no,
+  zsh_cv_rlimit_vmem_is_as=no)])
+
+if test $zsh_cv_rlimit_vmem_is_as = yes; then
+  AC_DEFINE(RLIMIT_VMEM_IS_AS)
+fi
+
+
 dnl ----------------------------
 dnl CHECK FOR /dev/fd FILESYSTEM
 dnl ----------------------------

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: PATCH: RLIMITS macros
  2003-04-01  9:40   ` Peter Stephenson
  2003-04-01 10:20     ` Peter Stephenson
@ 2003-04-01 15:47     ` Bart Schaefer
  2003-04-01 16:08       ` Bart Schaefer
  1 sibling, 1 reply; 12+ messages in thread
From: Bart Schaefer @ 2003-04-01 15:47 UTC (permalink / raw)
  To: Zsh hackers list

On Apr 1, 10:40am, Peter Stephenson wrote:
} Subject: Re: PATCH: RLIMITS macros
}
} "Bart Schaefer" wrote:
} > checking if RLIMIT_VMEM and RLIMIT_RSS are the same... no
} > checking if RLIMIT_VMEM and RLIMIT_AS are the same... no
} 
} Does that mean RLIMIT_AS and RLIMIT_VMEM aren't actually definitions at
} all?

It means that both RLIMIT_AS and RLIMIT_RSS are defined, are different
from one another, and that RLIMIT_VMEM is not defined at all.

(I see that you've followed up and I'll try that patch but I thought the
above might be useful anyway.)


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: PATCH: RLIMITS macros
  2003-04-01 15:47     ` Bart Schaefer
@ 2003-04-01 16:08       ` Bart Schaefer
  2003-04-01 17:04         ` Peter Stephenson
  0 siblings, 1 reply; 12+ messages in thread
From: Bart Schaefer @ 2003-04-01 16:08 UTC (permalink / raw)
  To: Zsh hackers list

On Apr 1,  3:47pm, Bart Schaefer wrote:
}
} It means that both RLIMIT_AS and RLIMIT_RSS are defined, are different
} from one another, and that RLIMIT_VMEM is not defined at all.

Oh, but the important bit is that they're defined as members of an enum,
not as integer digits, so they can't be compared for equality using the
preprocessor.

With the 18419 patch, zsh compiles but still mishandles "ulimit -v":

schaefer[571] Src/zsh -f
zagzig% limit         
cputime         unlimited
filesize        unlimited
datasize        unlimited
stacksize       8MB
coredumpsize    unlimited
memoryuse       unlimited
maxproc         2040
descriptors     1024
memorylocked    unlimited
addressspace    unlimited
zagzig% ulimit -v 1024
zagzig% zsh: segmentation fault (core dumped)  Src/zsh -f


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: PATCH: RLIMITS macros
  2003-04-01 16:08       ` Bart Schaefer
@ 2003-04-01 17:04         ` Peter Stephenson
  2003-04-01 17:52           ` Bart Schaefer
  0 siblings, 1 reply; 12+ messages in thread
From: Peter Stephenson @ 2003-04-01 17:04 UTC (permalink / raw)
  To: Zsh hackers list

"Bart Schaefer" wrote:
> With the 18419 patch, zsh compiles but still mishandles "ulimit -v":
> zagzig% ulimit -v 1024
> zagzig% zsh: segmentation fault (core dumped)  Src/zsh -f

Isn't that giving you 1MB, which may not be enough?  Can you verify it's
still not multiplying by 1024?

Anyway, the following uses HAVE macros for all limits we need to test.
The M4 macro would be shorter as a loop, but that's somewhere beyond my
limit in configure tests.

Index: acconfig.h
===================================================================
RCS file: /cvsroot/zsh/zsh/acconfig.h,v
retrieving revision 1.14
diff -u -r1.14 acconfig.h
--- acconfig.h	6 May 2002 14:50:10 -0000	1.14
+++ acconfig.h	1 Apr 2003 16:59:17 -0000
@@ -238,6 +238,48 @@
 /* Define to the type used in struct rlimit */
 #undef rlim_t
 
+/* Define to 1 if RLIMIT_AIO_MEM is present (whether or not as a macro) */
+#undef HAVE_RLIMIT_AIO_MEM
+
+/* Define to 1 if RLIMIT_AIO_OPS is present (whether or not as a macro) */
+#undef HAVE_RLIMIT_AIO_OPS
+
+/* Define to 1 if RLIMIT_AS is present (whether or not as a macro) */
+#undef HAVE_RLIMIT_AS
+
+/* Define to 1 if RLIMIT_LOCKS is present (whether or not as a macro) */
+#undef HAVE_RLIMIT_LOCKS
+
+/* Define to 1 if RLIMIT_MEMLOCK is present (whether or not as a macro) */
+#undef HAVE_RLIMIT_MEMLOCK
+
+/* Define to 1 if RLIMIT_NPROC is present (whether or not as a macro) */
+#undef HAVE_RLIMIT_NPROC
+
+/* Define to 1 if RLIMIT_NOFILE is present (whether or not as a macro) */
+#undef HAVE_RLIMIT_NOFILE
+
+/* Define to 1 if RLIMIT_PTHREAD is present (whether or not as a macro) */
+#undef HAVE_RLIMIT_PTHREAD
+
+/* Define to 1 if RLIMIT_RSS is present (whether or not as a macro) */
+#undef HAVE_RLIMIT_RSS
+
+/* Define to 1 if RLIMIT_SBSIZE is present (whether or not as a macro) */
+#undef HAVE_RLIMIT_SBSIZE
+
+/* Define to 1 if RLIMIT_TCACHE is present (whether or not as a macro) */
+#undef HAVE_RLIMIT_TCACHE
+
+/* Define to 1 if RLIMIT_VMEM is present (whether or not as a macro) */
+#undef HAVE_RLIMIT_VMEM
+
+/* Define to 1 if RLIMIT_VMEM and RLIMIT_RSS both exist and are equal */
+#undef RLIMIT_VMEM_IS_RSS
+
+/* Define to 1 if RLIMIT_VMEM and RLIMIT_AS both exist and are equal */
+#undef RLIMIT_VMEM_IS_AS
+
 /* Define to 1 if /bin/sh does not interpret \ escape sequences */
 #undef SH_USE_BSD_ECHO
 
Index: aczsh.m4
===================================================================
RCS file: /cvsroot/zsh/zsh/aczsh.m4,v
retrieving revision 1.14
diff -u -r1.14 aczsh.m4
--- aczsh.m4	22 Oct 2001 17:18:29 -0000	1.14
+++ aczsh.m4	1 Apr 2003 16:59:17 -0000
@@ -710,3 +710,21 @@
   AC_DEFINE_UNQUOTED([SOCKLEN_T], [$zsh_cv_type_socklen_t])]
 )
 
+dnl Check for limit $1 e.g. RLIMIT_RSS.
+AC_DEFUN(zsh_LIMIT_PRESENT,
+[AC_CACHE_CHECK([for limit $1],
+zsh_cv_have_$1,
+[AC_TRY_COMPILE([
+#include <sys/types.h>
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#include <sys/resource.h>],
+[$1],
+  zsh_cv_have_$1=yes,
+  zsh_cv_have_$1=no)])
+
+if test $zsh_cv_have_$1 = yes; then
+  AC_DEFINE(HAVE_$1)
+fi])
+
Index: zshconfig.ac
===================================================================
RCS file: /cvsroot/zsh/zsh/zshconfig.ac,v
retrieving revision 1.35
diff -u -r1.35 zshconfig.ac
--- zshconfig.ac	24 Mar 2003 12:56:59 -0000	1.35
+++ zshconfig.ac	1 Apr 2003 16:59:17 -0000
@@ -1221,6 +1221,75 @@
   AC_DEFINE_UNQUOTED(rlim_t, $DEFAULT_RLIM_T)
 fi
 
+
+dnl On some systems the RLIMIT_* don't evaluate to integers at compile time
+dnl (they may be enums).  In this case we are not able to do preprocessor
+dnl comparisions and need our tests to determine what values exist and
+dnl if there are clashing definitions.
+
+zsh_LIMIT_PRESENT(RLIMIT_AIO_MEM)
+zsh_LIMIT_PRESENT(RLIMIT_AIO_OPS)
+zsh_LIMIT_PRESENT(RLIMIT_AS)
+zsh_LIMIT_PRESENT(RLIMIT_LOCKS)
+zsh_LIMIT_PRESENT(RLIMIT_MEMLOCK)
+zsh_LIMIT_PRESENT(RLIMIT_NPROC)
+zsh_LIMIT_PRESENT(RLIMIT_NOFILE)
+zsh_LIMIT_PRESENT(RLIMIT_PTHREAD)
+zsh_LIMIT_PRESENT(RLIMIT_RSS)
+zsh_LIMIT_PRESENT(RLIMIT_SBSIZE)
+zsh_LIMIT_PRESENT(RLIMIT_TCACHE)
+zsh_LIMIT_PRESENT(RLIMIT_VMEM)
+
+AC_CACHE_CHECK(if RLIMIT_VMEM and RLIMIT_RSS are the same,
+zsh_cv_rlimit_vmem_is_rss,
+[AC_TRY_RUN([
+#include <sys/types.h>
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#include <sys/resource.h>
+int main()
+{
+int ret = 1;
+#if defined(HAVE_RLIMIT_VMEM) && defined(HAVE_RLIMIT_RSS)
+if (RLIMIT_RSS == RLIMIT_VMEM) ret = 0;
+#endif
+return ret;
+}],
+  zsh_cv_rlimit_vmem_is_rss=yes,
+  zsh_cv_rlimit_vmem_is_rss=no,
+  zsh_cv_rlimit_vmem_is_rss=no)])
+
+if test $zsh_cv_rlimit_vmem_is_rss = yes; then
+  AC_DEFINE(RLIMIT_VMEM_IS_RSS)
+fi
+
+
+AC_CACHE_CHECK(if RLIMIT_VMEM and RLIMIT_AS are the same,
+zsh_cv_rlimit_vmem_is_as,
+[AC_TRY_RUN([
+#include <sys/types.h>
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#include <sys/resource.h>
+int main()
+{
+int ret = 1;
+#if defined(HAVE_RLIMIT_VMEM) && defined(HAVE_RLIMIT_AS)
+if (RLIMIT_AS == RLIMIT_VMEM) ret = 0;
+#endif
+return ret;
+}],
+  zsh_cv_rlimit_vmem_is_as=yes,
+  zsh_cv_rlimit_vmem_is_as=no,
+  zsh_cv_rlimit_vmem_is_as=no)])
+
+if test $zsh_cv_rlimit_vmem_is_as = yes; then
+  AC_DEFINE(RLIMIT_VMEM_IS_AS)
+fi
+
+
 dnl ----------------------------
 dnl CHECK FOR /dev/fd FILESYSTEM
 dnl ----------------------------
Index: Src/Builtins/rlimits.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Builtins/rlimits.c,v
retrieving revision 1.8
diff -u -r1.8 rlimits.c
--- Src/Builtins/rlimits.c	9 Feb 2003 01:12:38 -0000	1.8
+++ Src/Builtins/rlimits.c	1 Apr 2003 16:59:17 -0000
@@ -175,38 +175,38 @@
 	break;
 /* If RLIMIT_VMEM and RLIMIT_RSS are defined and equal, avoid *
  * duplicate case statement.  Observed on QNX Neutrino 6.1.0. */
-# if defined(RLIMIT_RSS) && (!defined(RLIMIT_VMEM) || RLIMIT_VMEM != RLIMIT_RSS)
+# if defined(HAVE_RLIMIT_RSS) && !defined(RLIMIT_VMEM_IS_RSS)
     case RLIMIT_RSS:
 	if (head)
 	    printf("resident set size (kbytes) ");
 	if (limit != RLIM_INFINITY)
 	    limit /= 1024;
 	break;
-# endif /* RLIMIT_RSS */
-# ifdef RLIMIT_MEMLOCK
+# endif /* HAVE_RLIMIT_RSS */
+# ifdef HAVE_RLIMIT_MEMLOCK
     case RLIMIT_MEMLOCK:
 	if (head)
 	    printf("locked-in-memory size (kb) ");
 	if (limit != RLIM_INFINITY)
 	    limit /= 1024;
 	break;
-# endif /* RLIMIT_MEMLOCK */
-# ifdef RLIMIT_NPROC
+# endif /* HAVE_RLIMIT_MEMLOCK */
+# ifdef HAVE_RLIMIT_NPROC
     case RLIMIT_NPROC:
 	if (head)
 	    printf("processes                  ");
 	break;
-# endif /* RLIMIT_NPROC */
-# ifdef RLIMIT_NOFILE
+# endif /* HAVE_RLIMIT_NPROC */
+# ifdef HAVE_RLIMIT_NOFILE
     case RLIMIT_NOFILE:
 	if (head)
 	    printf("file descriptors           ");
 	break;
-# endif /* RLIMIT_NOFILE */
-# ifdef RLIMIT_VMEM
+# endif /* HAVE_RLIMIT_NOFILE */
+# ifdef HAVE_RLIMIT_VMEM
     case RLIMIT_VMEM:
 	if (head)
-#  if defined(RLIMIT_RSS) && RLIMIT_VMEM == RLIMIT_RSS
+#  if defined(HAVE_RLIMIT_RSS) && defined(RLIMIT_VMEM_IS_RSS)
 	    printf("memory size (kb)           ");
 #  else
 	    printf("virtual memory size (kb)   ");
@@ -214,55 +214,55 @@
 	if (limit != RLIM_INFINITY)
 	    limit /= 1024;
 	break;
-# endif /* RLIMIT_VMEM */
-# if defined RLIMIT_AS && RLIMIT_AS != RLIMIT_VMEM
+# endif /* HAVE_RLIMIT_VMEM */
+# if defined HAVE_RLIMIT_AS && !defined(RLIMIT_VMEM_IS_AS)
     case RLIMIT_AS:
 	if (head)
 	    printf("address space (kb)         ");
 	if (limit != RLIM_INFINITY)
 	    limit /= 1024;
 	break;
-# endif /* RLIMIT_AS */
-# ifdef RLIMIT_TCACHE
+# endif /* HAVE_RLIMIT_AS */
+# ifdef HAVE_RLIMIT_TCACHE
     case RLIMIT_TCACHE:
 	if (head)
 	    printf("cached threads             ");
 	break;
-# endif /* RLIMIT_TCACHE */
-# ifdef RLIMIT_AIO_OPS
+# endif /* HAVE_RLIMIT_TCACHE */
+# ifdef HAVE_RLIMIT_AIO_OPS
     case RLIMIT_AIO_OPS:
 	if (head)
 	    printf("AIO operations             ");
 	break;
-# endif /* RLIMIT_AIO_OPS */
-# ifdef RLIMIT_AIO_MEM
+# endif /* HAVE_RLIMIT_AIO_OPS */
+# ifdef HAVE_RLIMIT_AIO_MEM
     case RLIMIT_AIO_MEM:
 	if (head)
 	    printf("AIO locked-in-memory (kb)  ");
 	if (limit != RLIM_INFINITY)
 	    limit /= 1024;
 	break;
-# endif /* RLIMIT_AIO_MEM */
-# ifdef RLIMIT_SBSIZE
+# endif /* HAVE_RLIMIT_AIO_MEM */
+# ifdef HAVE_RLIMIT_SBSIZE
     case RLIMIT_SBSIZE:
 	if (head)
 	    printf("socket buffer size (kb)    ");
 	if (limit != RLIM_INFINITY)
 	    limit /= 1024;
 	break;
-# endif /* RLIMIT_SBSIZE */
-# ifdef RLIMIT_PTHREAD
+# endif /* HAVE_RLIMIT_SBSIZE */
+# ifdef HAVE_RLIMIT_PTHREAD
     case RLIMIT_PTHREAD:
 	if (head)
 	    printf("threads per process        ");
 	break;
-# endif /* RLIMIT_PTHREAD */
-# ifdef RLIMIT_LOCKS
+# endif /* HAVE_RLIMIT_PTHREAD */
+# ifdef HAVE_RLIMIT_LOCKS
     case RLIMIT_LOCKS:
 	if (head)
 	    printf("file locks                 ");
 	break;
-# endif /* RLIMIT_LOCKS */
+# endif /* HAVE_RLIMIT_LOCKS */
     }
     /* display the limit */
     if (limit == RLIM_INFINITY)
@@ -509,31 +509,31 @@
 		case 'c':
 		    res = RLIMIT_CORE;
 		    break;
-# ifdef RLIMIT_RSS
+# ifdef HAVE_RLIMIT_RSS
 		case 'm':
 		    res = RLIMIT_RSS;
 		    break;
-# endif /* RLIMIT_RSS */
-# ifdef RLIMIT_MEMLOCK
+# endif /* HAVE_RLIMIT_RSS */
+# ifdef HAVE_RLIMIT_MEMLOCK
 		case 'l':
 		    res = RLIMIT_MEMLOCK;
 		    break;
-# endif /* RLIMIT_MEMLOCK */
-# ifdef RLIMIT_NOFILE
+# endif /* HAVE_RLIMIT_MEMLOCK */
+# ifdef HAVE_RLIMIT_NOFILE
 		case 'n':
 		    res = RLIMIT_NOFILE;
 		    break;
-# endif /* RLIMIT_NOFILE */
-# ifdef RLIMIT_NPROC
+# endif /* HAVE_RLIMIT_NOFILE */
+# ifdef HAVE_RLIMIT_NPROC
 		case 'u':
 		    res = RLIMIT_NPROC;
 		    break;
-# endif /* RLIMIT_NPROC */
-# ifdef RLIMIT_VMEM
+# endif /* HAVE_RLIMIT_NPROC */
+# ifdef HAVE_RLIMIT_VMEM
 		case 'v':
 		    res = RLIMIT_VMEM;
 		    break;
-# endif /* RLIMIT_VMEM */
+# endif /* HAVE_RLIMIT_VMEM */
 		default:
 		    /* unrecognised limit */
 		    zwarnnam(name, "bad option: -%c", NULL, *options);
@@ -571,20 +571,20 @@
 		break;
 	    case RLIMIT_DATA:
 	    case RLIMIT_STACK:
-# ifdef RLIMIT_RSS
+# ifdef HAVE_RLIMIT_RSS
 	    case RLIMIT_RSS:
-# endif /* RLIMIT_RSS */
-# ifdef RLIMIT_MEMLOCK
+# endif /* HAVE_RLIMIT_RSS */
+# ifdef HAVE_RLIMIT_MEMLOCK
 	    case RLIMIT_MEMLOCK:
-# endif /* RLIMIT_MEMLOCK */
+# endif /* HAVE_RLIMIT_MEMLOCK */
 /* If RLIMIT_VMEM and RLIMIT_RSS are defined and equal, avoid *
  * duplicate case statement.  Observed on QNX Neutrino 6.1.0. */
-# if defined(RLIMIT_VMEM) && (!defined(RLIMIT_RSS) || RLIMIT_RSS != RLIMIT_VMEM)
+# if defined(HAVE_RLIMIT_VMEM) && !defined(RLIMIT_VMEM_IS_RSS)
 	    case RLIMIT_VMEM:
-# endif /* RLIMIT_VMEM */
-# ifdef RLIMIT_AIO_MEM
+# endif /* HAVE_RLIMIT_VMEM */
+# ifdef HAVE_RLIMIT_AIO_MEM
 	    case RLIMIT_AIO_MEM:
-# endif /* RLIMIT_AIO_MEM */
+# endif /* HAVE_RLIMIT_AIO_MEM */
 		limit *= 1024;
 		break;
 	    }

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: PATCH: RLIMITS macros
  2003-04-01 17:04         ` Peter Stephenson
@ 2003-04-01 17:52           ` Bart Schaefer
  2003-04-01 18:29             ` Peter Stephenson
  0 siblings, 1 reply; 12+ messages in thread
From: Bart Schaefer @ 2003-04-01 17:52 UTC (permalink / raw)
  To: Peter Stephenson, Zsh hackers list

On Apr 1,  6:04pm, Peter Stephenson wrote:
}
} > zagzig% ulimit -v 1024
} > zagzig% zsh: segmentation fault (core dumped)  Src/zsh -f
} 
} Isn't that giving you 1MB, which may not be enough?  Can you verify it's
} still not multiplying by 1024?

schaefer[574] Src/zsh -f
zagzig% ulimit -v 10240
zagzig% zsh: segmentation fault (core dumped)  Src/zsh -f
schaefer[575] Src/zsh -f
zagzig% ulimit -v 102400
zagzig% zsh: segmentation fault (core dumped)  Src/zsh -f
schaefer[575] Src/zsh -f
zagzig% ulimit -v 102400000 
zagzig% limit
cputime         unlimited
filesize        unlimited
datasize        unlimited
stacksize       8MB
coredumpsize    unlimited
memoryuse       unlimited
maxproc         2040
descriptors     1024
memorylocked    unlimited
addressspace    97MB
zagzig% 


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: PATCH: RLIMITS macros
  2003-04-01 17:52           ` Bart Schaefer
@ 2003-04-01 18:29             ` Peter Stephenson
  2003-04-02  3:25               ` Bart Schaefer
  0 siblings, 1 reply; 12+ messages in thread
From: Peter Stephenson @ 2003-04-01 18:29 UTC (permalink / raw)
  To: Zsh hackers list

"Bart Schaefer" wrote:
> zagzig% ulimit -v 102400000 
> zagzig% limit
> cputime         unlimited
> filesize        unlimited
> datasize        unlimited
> stacksize       8MB
> coredumpsize    unlimited
> memoryuse       unlimited
> maxproc         2040
> descriptors     1024
> memorylocked    unlimited
> addressspace    97MB
> zagzig% 

What are HAVE_RLIMIT_RSS, HAVE_RLIMIT_VMEM, HAVE_RLIMIT_AS,
RLIMIT_VMEM_IS_RSS, RLIMIT_VMEM_IS_AS?

It's possible to skip the multiplication by 1024 if RLIMIT_AS is defined
and is not the same as RLIMIT_RSS, but I didn't think that was the case
here.  Maybe there needs to be a

# if defined(HAVE_RLIMIT_AS) && !defined(RLIMIT_VMEM_IS_AS)
	    case RLIMIT_AS:
# endif /* HAVE_RLIMIT_AS */

in that switch anyway.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: PATCH: RLIMITS macros
  2003-04-01 18:29             ` Peter Stephenson
@ 2003-04-02  3:25               ` Bart Schaefer
  2003-04-02  9:46                 ` Peter Stephenson
  0 siblings, 1 reply; 12+ messages in thread
From: Bart Schaefer @ 2003-04-02  3:25 UTC (permalink / raw)
  To: Peter Stephenson, Zsh hackers list

On Apr 1,  7:29pm, Peter Stephenson wrote:
}
} What are HAVE_RLIMIT_RSS, HAVE_RLIMIT_VMEM, HAVE_RLIMIT_AS,
} RLIMIT_VMEM_IS_RSS, RLIMIT_VMEM_IS_AS?

After applying the patch from 18425 and rerunning configure, I have:

#define HAVE_RLIMIT_AS 1
#define HAVE_RLIMIT_RSS 1
/* #undef HAVE_RLIMIT_VMEM */
/* #undef RLIMIT_VMEM_IS_RSS */
/* #undef RLIMIT_VMEM_IS_AS */

And after compiling, I now get:

zagzig% ulimit -v 10240
ulimit: bad option: -v

} It's possible to skip the multiplication by 1024 if RLIMIT_AS is defined
} and is not the same as RLIMIT_RSS, but I didn't think that was the case
} here.

That's *exactly* the case here.  The following is all inside enum { }:

/usr/include/bits/resource.h:  RLIMIT_RSS = 5,
/usr/include/bits/resource.h:#define	RLIMIT_RSS RLIMIT_RSS
/usr/include/bits/resource.h:  RLIMIT_AS = 9,
/usr/include/bits/resource.h:#define RLIMIT_AS RLIMIT_AS


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: PATCH: RLIMITS macros
  2003-04-02  3:25               ` Bart Schaefer
@ 2003-04-02  9:46                 ` Peter Stephenson
  2003-04-03  9:49                   ` Peter Stephenson
  0 siblings, 1 reply; 12+ messages in thread
From: Peter Stephenson @ 2003-04-02  9:46 UTC (permalink / raw)
  To: Zsh hackers list

"Bart Schaefer" wrote:
> } It's possible to skip the multiplication by 1024 if RLIMIT_AS is defined
> } and is not the same as RLIMIT_RSS, but I didn't think that was the case
> } here.
> 
> That's *exactly* the case here.

Aha.  In that case the following revised version should work.

>  The following is all inside enum { }:
> 
> /usr/include/bits/resource.h:  RLIMIT_RSS = 5,
> /usr/include/bits/resource.h:#define	RLIMIT_RSS RLIMIT_RSS
> /usr/include/bits/resource.h:  RLIMIT_AS = 9,
> /usr/include/bits/resource.h:#define RLIMIT_AS RLIMIT_AS

That makes the HAVE_RLIMIT_RSS stuff redundant, but I'm inclined to
leave it in for future-proofing.

Index: acconfig.h
===================================================================
RCS file: /cvsroot/zsh/zsh/acconfig.h,v
retrieving revision 1.14
diff -u -r1.14 acconfig.h
--- acconfig.h	6 May 2002 14:50:10 -0000	1.14
+++ acconfig.h	2 Apr 2003 09:45:13 -0000
@@ -238,6 +238,48 @@
 /* Define to the type used in struct rlimit */
 #undef rlim_t
 
+/* Define to 1 if RLIMIT_AIO_MEM is present (whether or not as a macro) */
+#undef HAVE_RLIMIT_AIO_MEM
+
+/* Define to 1 if RLIMIT_AIO_OPS is present (whether or not as a macro) */
+#undef HAVE_RLIMIT_AIO_OPS
+
+/* Define to 1 if RLIMIT_AS is present (whether or not as a macro) */
+#undef HAVE_RLIMIT_AS
+
+/* Define to 1 if RLIMIT_LOCKS is present (whether or not as a macro) */
+#undef HAVE_RLIMIT_LOCKS
+
+/* Define to 1 if RLIMIT_MEMLOCK is present (whether or not as a macro) */
+#undef HAVE_RLIMIT_MEMLOCK
+
+/* Define to 1 if RLIMIT_NPROC is present (whether or not as a macro) */
+#undef HAVE_RLIMIT_NPROC
+
+/* Define to 1 if RLIMIT_NOFILE is present (whether or not as a macro) */
+#undef HAVE_RLIMIT_NOFILE
+
+/* Define to 1 if RLIMIT_PTHREAD is present (whether or not as a macro) */
+#undef HAVE_RLIMIT_PTHREAD
+
+/* Define to 1 if RLIMIT_RSS is present (whether or not as a macro) */
+#undef HAVE_RLIMIT_RSS
+
+/* Define to 1 if RLIMIT_SBSIZE is present (whether or not as a macro) */
+#undef HAVE_RLIMIT_SBSIZE
+
+/* Define to 1 if RLIMIT_TCACHE is present (whether or not as a macro) */
+#undef HAVE_RLIMIT_TCACHE
+
+/* Define to 1 if RLIMIT_VMEM is present (whether or not as a macro) */
+#undef HAVE_RLIMIT_VMEM
+
+/* Define to 1 if RLIMIT_VMEM and RLIMIT_RSS both exist and are equal */
+#undef RLIMIT_VMEM_IS_RSS
+
+/* Define to 1 if RLIMIT_VMEM and RLIMIT_AS both exist and are equal */
+#undef RLIMIT_VMEM_IS_AS
+
 /* Define to 1 if /bin/sh does not interpret \ escape sequences */
 #undef SH_USE_BSD_ECHO
 
Index: aczsh.m4
===================================================================
RCS file: /cvsroot/zsh/zsh/aczsh.m4,v
retrieving revision 1.14
diff -u -r1.14 aczsh.m4
--- aczsh.m4	22 Oct 2001 17:18:29 -0000	1.14
+++ aczsh.m4	2 Apr 2003 09:45:13 -0000
@@ -710,3 +710,21 @@
   AC_DEFINE_UNQUOTED([SOCKLEN_T], [$zsh_cv_type_socklen_t])]
 )
 
+dnl Check for limit $1 e.g. RLIMIT_RSS.
+AC_DEFUN(zsh_LIMIT_PRESENT,
+[AC_CACHE_CHECK([for limit $1],
+zsh_cv_have_$1,
+[AC_TRY_COMPILE([
+#include <sys/types.h>
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#include <sys/resource.h>],
+[$1],
+  zsh_cv_have_$1=yes,
+  zsh_cv_have_$1=no)])
+
+if test $zsh_cv_have_$1 = yes; then
+  AC_DEFINE(HAVE_$1)
+fi])
+
Index: zshconfig.ac
===================================================================
RCS file: /cvsroot/zsh/zsh/zshconfig.ac,v
retrieving revision 1.35
diff -u -r1.35 zshconfig.ac
--- zshconfig.ac	24 Mar 2003 12:56:59 -0000	1.35
+++ zshconfig.ac	2 Apr 2003 09:45:13 -0000
@@ -1221,6 +1221,75 @@
   AC_DEFINE_UNQUOTED(rlim_t, $DEFAULT_RLIM_T)
 fi
 
+
+dnl On some systems the RLIMIT_* don't evaluate to integers at compile time
+dnl (they may be enums).  In this case we are not able to do preprocessor
+dnl comparisions and need our tests to determine what values exist and
+dnl if there are clashing definitions.
+
+zsh_LIMIT_PRESENT(RLIMIT_AIO_MEM)
+zsh_LIMIT_PRESENT(RLIMIT_AIO_OPS)
+zsh_LIMIT_PRESENT(RLIMIT_AS)
+zsh_LIMIT_PRESENT(RLIMIT_LOCKS)
+zsh_LIMIT_PRESENT(RLIMIT_MEMLOCK)
+zsh_LIMIT_PRESENT(RLIMIT_NPROC)
+zsh_LIMIT_PRESENT(RLIMIT_NOFILE)
+zsh_LIMIT_PRESENT(RLIMIT_PTHREAD)
+zsh_LIMIT_PRESENT(RLIMIT_RSS)
+zsh_LIMIT_PRESENT(RLIMIT_SBSIZE)
+zsh_LIMIT_PRESENT(RLIMIT_TCACHE)
+zsh_LIMIT_PRESENT(RLIMIT_VMEM)
+
+AC_CACHE_CHECK(if RLIMIT_VMEM and RLIMIT_RSS are the same,
+zsh_cv_rlimit_vmem_is_rss,
+[AC_TRY_RUN([
+#include <sys/types.h>
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#include <sys/resource.h>
+int main()
+{
+int ret = 1;
+#if defined(HAVE_RLIMIT_VMEM) && defined(HAVE_RLIMIT_RSS)
+if (RLIMIT_RSS == RLIMIT_VMEM) ret = 0;
+#endif
+return ret;
+}],
+  zsh_cv_rlimit_vmem_is_rss=yes,
+  zsh_cv_rlimit_vmem_is_rss=no,
+  zsh_cv_rlimit_vmem_is_rss=no)])
+
+if test $zsh_cv_rlimit_vmem_is_rss = yes; then
+  AC_DEFINE(RLIMIT_VMEM_IS_RSS)
+fi
+
+
+AC_CACHE_CHECK(if RLIMIT_VMEM and RLIMIT_AS are the same,
+zsh_cv_rlimit_vmem_is_as,
+[AC_TRY_RUN([
+#include <sys/types.h>
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#include <sys/resource.h>
+int main()
+{
+int ret = 1;
+#if defined(HAVE_RLIMIT_VMEM) && defined(HAVE_RLIMIT_AS)
+if (RLIMIT_AS == RLIMIT_VMEM) ret = 0;
+#endif
+return ret;
+}],
+  zsh_cv_rlimit_vmem_is_as=yes,
+  zsh_cv_rlimit_vmem_is_as=no,
+  zsh_cv_rlimit_vmem_is_as=no)])
+
+if test $zsh_cv_rlimit_vmem_is_as = yes; then
+  AC_DEFINE(RLIMIT_VMEM_IS_AS)
+fi
+
+
 dnl ----------------------------
 dnl CHECK FOR /dev/fd FILESYSTEM
 dnl ----------------------------
Index: Src/Builtins/rlimits.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Builtins/rlimits.c,v
retrieving revision 1.8
diff -u -r1.8 rlimits.c
--- Src/Builtins/rlimits.c	9 Feb 2003 01:12:38 -0000	1.8
+++ Src/Builtins/rlimits.c	2 Apr 2003 09:45:13 -0000
@@ -175,38 +175,38 @@
 	break;
 /* If RLIMIT_VMEM and RLIMIT_RSS are defined and equal, avoid *
  * duplicate case statement.  Observed on QNX Neutrino 6.1.0. */
-# if defined(RLIMIT_RSS) && (!defined(RLIMIT_VMEM) || RLIMIT_VMEM != RLIMIT_RSS)
+# if defined(HAVE_RLIMIT_RSS) && !defined(RLIMIT_VMEM_IS_RSS)
     case RLIMIT_RSS:
 	if (head)
 	    printf("resident set size (kbytes) ");
 	if (limit != RLIM_INFINITY)
 	    limit /= 1024;
 	break;
-# endif /* RLIMIT_RSS */
-# ifdef RLIMIT_MEMLOCK
+# endif /* HAVE_RLIMIT_RSS */
+# ifdef HAVE_RLIMIT_MEMLOCK
     case RLIMIT_MEMLOCK:
 	if (head)
 	    printf("locked-in-memory size (kb) ");
 	if (limit != RLIM_INFINITY)
 	    limit /= 1024;
 	break;
-# endif /* RLIMIT_MEMLOCK */
-# ifdef RLIMIT_NPROC
+# endif /* HAVE_RLIMIT_MEMLOCK */
+# ifdef HAVE_RLIMIT_NPROC
     case RLIMIT_NPROC:
 	if (head)
 	    printf("processes                  ");
 	break;
-# endif /* RLIMIT_NPROC */
-# ifdef RLIMIT_NOFILE
+# endif /* HAVE_RLIMIT_NPROC */
+# ifdef HAVE_RLIMIT_NOFILE
     case RLIMIT_NOFILE:
 	if (head)
 	    printf("file descriptors           ");
 	break;
-# endif /* RLIMIT_NOFILE */
-# ifdef RLIMIT_VMEM
+# endif /* HAVE_RLIMIT_NOFILE */
+# ifdef HAVE_RLIMIT_VMEM
     case RLIMIT_VMEM:
 	if (head)
-#  if defined(RLIMIT_RSS) && RLIMIT_VMEM == RLIMIT_RSS
+#  if defined(HAVE_RLIMIT_RSS) && defined(RLIMIT_VMEM_IS_RSS)
 	    printf("memory size (kb)           ");
 #  else
 	    printf("virtual memory size (kb)   ");
@@ -214,55 +214,55 @@
 	if (limit != RLIM_INFINITY)
 	    limit /= 1024;
 	break;
-# endif /* RLIMIT_VMEM */
-# if defined RLIMIT_AS && RLIMIT_AS != RLIMIT_VMEM
+# endif /* HAVE_RLIMIT_VMEM */
+# if defined HAVE_RLIMIT_AS && !defined(RLIMIT_VMEM_IS_AS)
     case RLIMIT_AS:
 	if (head)
 	    printf("address space (kb)         ");
 	if (limit != RLIM_INFINITY)
 	    limit /= 1024;
 	break;
-# endif /* RLIMIT_AS */
-# ifdef RLIMIT_TCACHE
+# endif /* HAVE_RLIMIT_AS */
+# ifdef HAVE_RLIMIT_TCACHE
     case RLIMIT_TCACHE:
 	if (head)
 	    printf("cached threads             ");
 	break;
-# endif /* RLIMIT_TCACHE */
-# ifdef RLIMIT_AIO_OPS
+# endif /* HAVE_RLIMIT_TCACHE */
+# ifdef HAVE_RLIMIT_AIO_OPS
     case RLIMIT_AIO_OPS:
 	if (head)
 	    printf("AIO operations             ");
 	break;
-# endif /* RLIMIT_AIO_OPS */
-# ifdef RLIMIT_AIO_MEM
+# endif /* HAVE_RLIMIT_AIO_OPS */
+# ifdef HAVE_RLIMIT_AIO_MEM
     case RLIMIT_AIO_MEM:
 	if (head)
 	    printf("AIO locked-in-memory (kb)  ");
 	if (limit != RLIM_INFINITY)
 	    limit /= 1024;
 	break;
-# endif /* RLIMIT_AIO_MEM */
-# ifdef RLIMIT_SBSIZE
+# endif /* HAVE_RLIMIT_AIO_MEM */
+# ifdef HAVE_RLIMIT_SBSIZE
     case RLIMIT_SBSIZE:
 	if (head)
 	    printf("socket buffer size (kb)    ");
 	if (limit != RLIM_INFINITY)
 	    limit /= 1024;
 	break;
-# endif /* RLIMIT_SBSIZE */
-# ifdef RLIMIT_PTHREAD
+# endif /* HAVE_RLIMIT_SBSIZE */
+# ifdef HAVE_RLIMIT_PTHREAD
     case RLIMIT_PTHREAD:
 	if (head)
 	    printf("threads per process        ");
 	break;
-# endif /* RLIMIT_PTHREAD */
-# ifdef RLIMIT_LOCKS
+# endif /* HAVE_RLIMIT_PTHREAD */
+# ifdef HAVE_RLIMIT_LOCKS
     case RLIMIT_LOCKS:
 	if (head)
 	    printf("file locks                 ");
 	break;
-# endif /* RLIMIT_LOCKS */
+# endif /* HAVE_RLIMIT_LOCKS */
     }
     /* display the limit */
     if (limit == RLIM_INFINITY)
@@ -509,31 +509,31 @@
 		case 'c':
 		    res = RLIMIT_CORE;
 		    break;
-# ifdef RLIMIT_RSS
+# ifdef HAVE_RLIMIT_RSS
 		case 'm':
 		    res = RLIMIT_RSS;
 		    break;
-# endif /* RLIMIT_RSS */
-# ifdef RLIMIT_MEMLOCK
+# endif /* HAVE_RLIMIT_RSS */
+# ifdef HAVE_RLIMIT_MEMLOCK
 		case 'l':
 		    res = RLIMIT_MEMLOCK;
 		    break;
-# endif /* RLIMIT_MEMLOCK */
-# ifdef RLIMIT_NOFILE
+# endif /* HAVE_RLIMIT_MEMLOCK */
+# ifdef HAVE_RLIMIT_NOFILE
 		case 'n':
 		    res = RLIMIT_NOFILE;
 		    break;
-# endif /* RLIMIT_NOFILE */
-# ifdef RLIMIT_NPROC
+# endif /* HAVE_RLIMIT_NOFILE */
+# ifdef HAVE_RLIMIT_NPROC
 		case 'u':
 		    res = RLIMIT_NPROC;
 		    break;
-# endif /* RLIMIT_NPROC */
-# ifdef RLIMIT_VMEM
+# endif /* HAVE_RLIMIT_NPROC */
+# ifdef HAVE_RLIMIT_VMEM
 		case 'v':
 		    res = RLIMIT_VMEM;
 		    break;
-# endif /* RLIMIT_VMEM */
+# endif /* HAVE_RLIMIT_VMEM */
 		default:
 		    /* unrecognised limit */
 		    zwarnnam(name, "bad option: -%c", NULL, *options);
@@ -571,20 +571,24 @@
 		break;
 	    case RLIMIT_DATA:
 	    case RLIMIT_STACK:
-# ifdef RLIMIT_RSS
+# ifdef HAVE_RLIMIT_RSS
 	    case RLIMIT_RSS:
-# endif /* RLIMIT_RSS */
-# ifdef RLIMIT_MEMLOCK
+# endif /* HAVE_RLIMIT_RSS */
+# ifdef HAVE_RLIMIT_MEMLOCK
 	    case RLIMIT_MEMLOCK:
-# endif /* RLIMIT_MEMLOCK */
+# endif /* HAVE_RLIMIT_MEMLOCK */
 /* If RLIMIT_VMEM and RLIMIT_RSS are defined and equal, avoid *
  * duplicate case statement.  Observed on QNX Neutrino 6.1.0. */
-# if defined(RLIMIT_VMEM) && (!defined(RLIMIT_RSS) || RLIMIT_RSS != RLIMIT_VMEM)
+# if defined(HAVE_RLIMIT_VMEM) && !defined(RLIMIT_VMEM_IS_RSS)
 	    case RLIMIT_VMEM:
-# endif /* RLIMIT_VMEM */
-# ifdef RLIMIT_AIO_MEM
+# endif /* HAVE_RLIMIT_VMEM */
+/* ditto RLIMIT_VMEM and RLIMIT_AS */
+# if defined(HAVE_RLIMIT_AS) && !defined(RLIMIT_VMEM_IS_AS)
+	    case RLIMIT_AS:
+# endif /* HAVE_RLIMIT_AS */
+# ifdef HAVE_RLIMIT_AIO_MEM
 	    case RLIMIT_AIO_MEM:
-# endif /* RLIMIT_AIO_MEM */
+# endif /* HAVE_RLIMIT_AIO_MEM */
 		limit *= 1024;
 		break;
 	    }

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: PATCH: RLIMITS macros
  2003-04-02  9:46                 ` Peter Stephenson
@ 2003-04-03  9:49                   ` Peter Stephenson
  0 siblings, 0 replies; 12+ messages in thread
From: Peter Stephenson @ 2003-04-03  9:49 UTC (permalink / raw)
  To: Zsh hackers list

Peter Stephenson wrote:
> Aha.  In that case the following revised version should work.

I finally realised I could try this at home.

I think the thing to do is make `ulimit -v' refer to RLIMIT_AS when
RLIMIT_VMEM doesn't exist and document this.  Then `ulimit -v' will use
RLIMIT_AS which will correctly multiply by 1024.

I will commit this without posting any more versions.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2003-04-03  9:49 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-31 10:16 PATCH: RLIMITS macros Peter Stephenson
2003-03-31 18:54 ` Bart Schaefer
2003-04-01  9:40   ` Peter Stephenson
2003-04-01 10:20     ` Peter Stephenson
2003-04-01 15:47     ` Bart Schaefer
2003-04-01 16:08       ` Bart Schaefer
2003-04-01 17:04         ` Peter Stephenson
2003-04-01 17:52           ` Bart Schaefer
2003-04-01 18:29             ` Peter Stephenson
2003-04-02  3:25               ` Bart Schaefer
2003-04-02  9:46                 ` Peter Stephenson
2003-04-03  9:49                   ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).