| @@ -1,36 +1,62 @@ | | | @@ -1,36 +1,62 @@ |
1 | $NetBSD: patch-Src_Builtins_rlimits.c,v 1.4 2014/06/25 08:39:11 wiz Exp $ | | 1 | $NetBSD: patch-Src_Builtins_rlimits.c,v 1.5 2014/06/25 12:19:09 wiz Exp $ |
2 | | | 2 | |
3 | Fix thread limit display in ulimit. | | 3 | Fix thread limit display in ulimit. |
4 | From upstream, Peter Stephenson <p.stephenson@samsung.com>. | | 4 | From upstream, Peter Stephenson <p.stephenson@samsung.com>. |
5 | | | 5 | |
6 | --- Src/Builtins/rlimits.c.orig 2013-11-27 19:00:20.000000000 +0000 | | 6 | --- Src/Builtins/rlimits.c.orig 2013-11-27 19:00:20.000000000 +0000 |
7 | +++ Src/Builtins/rlimits.c | | 7 | +++ Src/Builtins/rlimits.c |
8 | @@ -32,12 +32,14 @@ | | 8 | @@ -32,12 +32,17 @@ |
9 | | | 9 | |
10 | #if defined(HAVE_GETRLIMIT) && defined(RLIM_INFINITY) | | 10 | #if defined(HAVE_GETRLIMIT) && defined(RLIM_INFINITY) |
11 | | | 11 | |
12 | -#ifdef RLIMIT_POSIXLOCKS | | 12 | -#ifdef RLIMIT_POSIXLOCKS |
13 | +#if defined(HAVE_RLIMIT_POSIXLOCKS) && !defined(HAVE_RLIMIT_LOCKS) | | 13 | +#if defined(HAVE_RLIMIT_POSIXLOCKS) && !defined(HAVE_RLIMIT_LOCKS) |
14 | # define RLIMIT_LOCKS RLIMIT_POSIXLOCKS | | 14 | # define RLIMIT_LOCKS RLIMIT_POSIXLOCKS |
15 | +# define HAVE_RLIMIT_LOCKS 1 | | 15 | +# define HAVE_RLIMIT_LOCKS 1 |
16 | #endif | | 16 | #endif |
17 | | | 17 | |
18 | -#ifdef RLIMIT_NTHR | | 18 | -#ifdef RLIMIT_NTHR |
19 | +#if defined(HAVE_RLIMIT_NTHR) && !defined(HAVE_RLIMIT_PTHREAD) | | 19 | +#if defined(HAVE_RLIMIT_NTHR) && !defined(HAVE_RLIMIT_PTHREAD) |
20 | # define RLIMIT_PTHREAD RLIMIT_NTHR | | 20 | # define RLIMIT_PTHREAD RLIMIT_NTHR |
21 | +# define HAVE_RLIMIT_PTHREAD 1 | | 21 | +# define HAVE_RLIMIT_PTHREAD 1 |
| | | 22 | +# define THREAD_FMT "-T: threads " |
| | | 23 | +#else |
| | | 24 | +# define THREAD_FMT "-T: threads per process " |
22 | #endif | | 25 | #endif |
23 | | | 26 | |
24 | enum { | | 27 | enum { |
25 | @@ -876,6 +878,11 @@ bin_ulimit(char *name, char **argv, UNUS | | 28 | @@ -373,7 +378,7 @@ printulimit(char *nam, int lim, int hard |
| | | 29 | # ifdef HAVE_RLIMIT_PTHREAD |
| | | 30 | case RLIMIT_PTHREAD: |
| | | 31 | if (head) |
| | | 32 | - printf("-T: threads per process "); |
| | | 33 | + printf(THREAD_FMT); |
| | | 34 | break; |
| | | 35 | # endif /* HAVE_RLIMIT_PTHREAD */ |
| | | 36 | # ifdef HAVE_RLIMIT_NICE |
| | | 37 | @@ -860,6 +865,13 @@ bin_ulimit(char *name, char **argv, UNUS |
| | | 38 | case 'r': |
| | | 39 | res = RLIMIT_RTPRIO; |
| | | 40 | break; |
| | | 41 | +# else |
| | | 42 | +# ifdef HAVE_RLIMIT_NTHR |
| | | 43 | + /* For compatibility with sh on NetBSD */ |
| | | 44 | + case 'r': |
| | | 45 | + res = RLIMIT_NTHR; |
| | | 46 | + break; |
| | | 47 | +# endif /* HAVE_RLIMIT_NTHR */ |
| | | 48 | # endif |
| | | 49 | # ifdef HAVE_RLIMIT_NPTS |
| | | 50 | case 'p': |
| | | 51 | @@ -876,6 +888,11 @@ bin_ulimit(char *name, char **argv, UNUS |
26 | res = RLIMIT_KQUEUES; | | 52 | res = RLIMIT_KQUEUES; |
27 | break; | | 53 | break; |
28 | # endif | | 54 | # endif |
29 | +# ifdef HAVE_RLIMIT_PTHREAD | | 55 | +# ifdef HAVE_RLIMIT_PTHREAD |
30 | + case 'T': | | 56 | + case 'T': |
31 | + res = RLIMIT_PTHREAD; | | 57 | + res = RLIMIT_PTHREAD; |
32 | + break; | | 58 | + break; |
33 | +# endif | | 59 | +# endif |
34 | default: | | 60 | default: |
35 | /* unrecognised limit */ | | 61 | /* unrecognised limit */ |
36 | zwarnnam(name, "bad option: -%c", *options); | | 62 | zwarnnam(name, "bad option: -%c", *options); |