zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: maxfilelocks in ulimit output
@ 2003-02-09  1:06 Clint Adams
  2003-02-09  1:41 ` Clint Adams
  0 siblings, 1 reply; 11+ messages in thread
From: Clint Adams @ 2003-02-09  1:06 UTC (permalink / raw)
  To: zsh-workers

Index: Src/Builtins/rlimits.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Builtins/rlimits.c,v
retrieving revision 1.7
diff -u -r1.7 rlimits.c
--- Src/Builtins/rlimits.c	27 Aug 2002 21:10:34 -0000	1.7
+++ Src/Builtins/rlimits.c	9 Feb 2003 01:05:39 -0000
@@ -257,6 +257,12 @@
 	    printf("threads per process        ");
 	break;
 # endif /* RLIMIT_PTHREAD */
+# ifdef RLIMIT_LOCKS
+    case RLIMIT_LOCKS:
+	if (head)
+	    printf("file locks                 ");
+	break;
+# endif /* RLIMIT_LOCKS */
     }
     /* display the limit */
     if (limit == RLIM_INFINITY)


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

* Re: PATCH: maxfilelocks in ulimit output
  2003-02-09  1:06 PATCH: maxfilelocks in ulimit output Clint Adams
@ 2003-02-09  1:41 ` Clint Adams
  2003-02-09  2:25   ` Bart Schaefer
  0 siblings, 1 reply; 11+ messages in thread
From: Clint Adams @ 2003-02-09  1:41 UTC (permalink / raw)
  To: zsh-workers; +Cc: 180306-forwarded

% ulimit
cpu time (seconds)         unlimited
file size (blocks)         unlimited
data seg size (kbytes)     unlimited
stack size (kbytes)        8192
core file size (blocks)    0
unlimited
processes                  1023
file descriptors           1024
locked-in-memory size (kb) unlimited
memory size (kb)           unlimited
unlimited

This is in glibc 2.3/linux, which

#define RLIMIT_RSS  5               /* max resident set size */
#define RLIMIT_AS   9               /* address space limit */


RLIMIT_VMEM is undefined, so Src/system.h defines it as RLIMIT_AS.

Thus,

# if defined(RLIMIT_RSS) && (!defined(RLIMIT_VMEM) || RLIMIT_VMEM != RLIMIT_RSS)

should be true,

and

#  if defined(RLIMIT_RSS) && RLIMIT_VMEM == RLIMIT_RSS

should be false, thereby printing "resident set size (kbytes) " and
"virtual memory size (kb) " respectively.

Yet the opposite seems to be occurring.  What am I missing?


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

* Re: PATCH: maxfilelocks in ulimit output
  2003-02-09  1:41 ` Clint Adams
@ 2003-02-09  2:25   ` Bart Schaefer
  2003-02-09 17:29     ` Clint Adams
  0 siblings, 1 reply; 11+ messages in thread
From: Bart Schaefer @ 2003-02-09  2:25 UTC (permalink / raw)
  To: Clint Adams, zsh-workers

On Feb 8,  8:41pm, Clint Adams wrote:
} Subject: Re: PATCH: maxfilelocks in ulimit output
}
} # if defined(RLIMIT_RSS) && (!defined(RLIMIT_VMEM) || RLIMIT_VMEM != RLIMIT_RSS)
} 
} should be true,
} 
} and
} 
} #  if defined(RLIMIT_RSS) && RLIMIT_VMEM == RLIMIT_RSS
} 
} should be false, thereby printing "resident set size (kbytes) " and
} "virtual memory size (kb) " respectively.
} 
} Yet the opposite seems to be occurring.  What am I missing?

If you figure it out, I'd love to know.

See zsh-users/5492, zsh-workers/17939,17941,17944,17951,18032 and 18043.


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

* Re: PATCH: maxfilelocks in ulimit output
  2003-02-09  2:25   ` Bart Schaefer
@ 2003-02-09 17:29     ` Clint Adams
  2003-02-09 22:45       ` Clint Adams
  0 siblings, 1 reply; 11+ messages in thread
From: Clint Adams @ 2003-02-09 17:29 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

> If you figure it out, I'd love to know.

GNU cpp 3.2 info says:

   * Identifiers that are not macros, which are all considered to be the
     number zero.  This allows you to write `#if MACRO' instead of
     `#ifdef MACRO', if you know that MACRO, when defined, will
     always have a nonzero value.  Function-like macros used
     without their function call parentheses are also treated as zero.

Seems that it's treating RLIMIT_AS and RLIMIT_RSS as
"identifiers", because they compare equally in the #if.


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

* Re: PATCH: maxfilelocks in ulimit output
  2003-02-09 17:29     ` Clint Adams
@ 2003-02-09 22:45       ` Clint Adams
  2003-02-10  9:08         ` Borzenkov Andrey
  0 siblings, 1 reply; 11+ messages in thread
From: Clint Adams @ 2003-02-09 22:45 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

> Seems that it's treating RLIMIT_AS and RLIMIT_RSS as
> "identifiers", because they compare equally in the #if.

I'm told that it's impossible to do a preprocessor compare because of
the enum.  So to get this to work we'd need to remove something to
configure or elsewhere.


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

* RE: PATCH: maxfilelocks in ulimit output
  2003-02-09 22:45       ` Clint Adams
@ 2003-02-10  9:08         ` Borzenkov Andrey
  2003-02-10  9:31           ` Zefram
  0 siblings, 1 reply; 11+ messages in thread
From: Borzenkov Andrey @ 2003-02-10  9:08 UTC (permalink / raw)
  To: 'Clint Adams', 'Bart Schaefer'; +Cc: zsh-workers


> 
> > Seems that it's treating RLIMIT_AS and RLIMIT_RSS as
> > "identifiers", because they compare equally in the #if.
> 
> I'm told that it's impossible to do a preprocessor compare because of
> the enum.  So to get this to work we'd need to remove something to
> configure or elsewhere.

Untested idea (not having the relevant system and time :(

AC_DEFUN(zsh_TEST_LIMIT_VALUE,[
echo > get-limit-value.c << EOF

main()
{
#ifdef $1
printf("%d", $1);
#else
printf("%d", -1);
#endif
return 0;
}
EOF

cc -o get-limit-value get-limit-value.c

val=`get-limit-value`
if test "$val" -ge 0; then
AC_DEFINE(ZSH_$1, $val)
fi
]

later on

zsh_TEST_LIMIT_VALUE(RLIMIT_AS)
zsh_TEST_LIMIT_VALUE(RLIMIT_RSS)
...

and in code use ZSH_... instead of original values.

Ugly as sin but it will work.

-andrey


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

* Re: PATCH: maxfilelocks in ulimit output
  2003-02-10  9:08         ` Borzenkov Andrey
@ 2003-02-10  9:31           ` Zefram
  2003-02-10 10:47             ` Peter Stephenson
  2003-02-12  4:03             ` Clint Adams
  0 siblings, 2 replies; 11+ messages in thread
From: Zefram @ 2003-02-10  9:31 UTC (permalink / raw)
  To: zsh-workers

Borzenkov Andrey wrote:
>Untested idea (not having the relevant system and time :(

It's better not to rely on being able to run programs at configure time,
to allow for cross compilation.  It may be better in this case to turn
the troublesome preprocessor conditionals into C conditionals -- gcc,
at least, will optimise them away.

-zefram


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

* Re: PATCH: maxfilelocks in ulimit output
  2003-02-10  9:31           ` Zefram
@ 2003-02-10 10:47             ` Peter Stephenson
  2003-02-12  4:03             ` Clint Adams
  1 sibling, 0 replies; 11+ messages in thread
From: Peter Stephenson @ 2003-02-10 10:47 UTC (permalink / raw)
  To: zsh-workers

Zefram wrote:
> Borzenkov Andrey wrote:
> >Untested idea (not having the relevant system and time :(
> 
> It's better not to rely on being able to run programs at configure time,
> to allow for cross compilation.

Yes, except we already screwed that up long ago; the configure file is
full of tests of that kind and adding one more isn't going to make a
difference.  (I'm doubtful whether it could be got to work without a
whole pile of extra run-time tests, and extremely doubtful that it's
worth the effort trying.)  Andrej's solution will be good enough when it
works.

-- 
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] 11+ messages in thread

* Re: PATCH: maxfilelocks in ulimit output
  2003-02-10  9:31           ` Zefram
  2003-02-10 10:47             ` Peter Stephenson
@ 2003-02-12  4:03             ` Clint Adams
  2003-02-12 11:09               ` Peter Stephenson
  1 sibling, 1 reply; 11+ messages in thread
From: Clint Adams @ 2003-02-12  4:03 UTC (permalink / raw)
  To: Zefram; +Cc: zsh-workers

> It's better not to rely on being able to run programs at configure time,
> to allow for cross compilation.  It may be better in this case to turn
> the troublesome preprocessor conditionals into C conditionals -- gcc,
> at least, will optimise them away.

This works for me; untested on any other platform.

cpu time (seconds)         unlimited
file size (blocks)         unlimited
data seg size (kbytes)     unlimited
stack size (kbytes)        8192
core file size (blocks)    0
resident set size (kbytes) unlimited
processes                  366
file descriptors           1024
locked-in-memory size (kb) unlimited
address space (kb)         unlimited
file locks                 unlimited


Index: Src/system.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/system.h,v
retrieving revision 1.15
diff -u -r1.15 system.h
--- Src/system.h	28 Apr 2001 17:38:01 -0000	1.15
+++ Src/system.h	11 Feb 2003 17:38:58 -0000
@@ -395,9 +395,6 @@
 #if !defined(RLIMIT_NOFILE) && defined(RLIMIT_OFILE)
 # define RLIMIT_NOFILE RLIMIT_OFILE
 #endif
-#if !defined(RLIMIT_VMEM) && defined(RLIMIT_AS)
-# define RLIMIT_VMEM RLIMIT_AS
-#endif
 
 #ifdef HAVE_SYS_CAPABILITY_H
 # include <sys/capability.h>
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	11 Feb 2003 17:38:58 -0000
@@ -175,10 +175,16 @@
 	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)
+# ifdef RLIMIT_RSS
     case RLIMIT_RSS:
-	if (head)
-	    printf("resident set size (kbytes) ");
+	if (head) {
+#  ifdef RLIMIT_VMEM
+	    if (RLIMIT_VMEM == RLIMIT_RSS)
+	        printf("memory size (kb)           ");
+	    else
+#  endif
+	        printf("resident set size (kbytes) ");
+	}
 	if (limit != RLIM_INFINITY)
 	    limit /= 1024;
 	break;
@@ -206,16 +212,12 @@
 # ifdef RLIMIT_VMEM
     case RLIMIT_VMEM:
 	if (head)
-#  if defined(RLIMIT_RSS) && RLIMIT_VMEM == RLIMIT_RSS
-	    printf("memory size (kb)           ");
-#  else
 	    printf("virtual memory size (kb)   ");
-#  endif
 	if (limit != RLIM_INFINITY)
 	    limit /= 1024;
 	break;
 # endif /* RLIMIT_VMEM */
-# if defined RLIMIT_AS && RLIMIT_AS != RLIMIT_VMEM
+# ifdef RLIMIT_AS
     case RLIMIT_AS:
 	if (head)
 	    printf("address space (kb)         ");


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

* Re: PATCH: maxfilelocks in ulimit output
  2003-02-12  4:03             ` Clint Adams
@ 2003-02-12 11:09               ` Peter Stephenson
  2003-02-16  4:52                 ` Clint Adams
  0 siblings, 1 reply; 11+ messages in thread
From: Peter Stephenson @ 2003-02-12 11:09 UTC (permalink / raw)
  To: zsh-workers

Clint Adams wrote:
> This works for me; untested on any other platform.

> -# if defined(RLIMIT_RSS) && (!defined(RLIMIT_VMEM) || RLIMIT_VMEM != RLIMIT_
> RSS)
> +# ifdef RLIMIT_RSS

(Note there's another similar case statement further down in another
function.  I know because I missed it on a previous attempt.)

Doesn't this run the risk of duplicate case labels?  This is the problem
that caused this fuss in the first place.  We can't rely on the compiler
being able to handle them gracefully (I don't know what the C standard
says, but the statement seems to hold in any case).

-- 
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] 11+ messages in thread

* Re: PATCH: maxfilelocks in ulimit output
  2003-02-12 11:09               ` Peter Stephenson
@ 2003-02-16  4:52                 ` Clint Adams
  0 siblings, 0 replies; 11+ messages in thread
From: Clint Adams @ 2003-02-16  4:52 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-workers

> Doesn't this run the risk of duplicate case labels?  This is the problem

Yes; we need the configure test.


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

end of thread, other threads:[~2003-02-16  4:52 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-09  1:06 PATCH: maxfilelocks in ulimit output Clint Adams
2003-02-09  1:41 ` Clint Adams
2003-02-09  2:25   ` Bart Schaefer
2003-02-09 17:29     ` Clint Adams
2003-02-09 22:45       ` Clint Adams
2003-02-10  9:08         ` Borzenkov Andrey
2003-02-10  9:31           ` Zefram
2003-02-10 10:47             ` Peter Stephenson
2003-02-12  4:03             ` Clint Adams
2003-02-12 11:09               ` Peter Stephenson
2003-02-16  4:52                 ` Clint Adams

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