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

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).