Skip to content

Commit ec4b091

Browse files
committed
simplify the program by using hard-coded maximum
1 parent 09b6081 commit ec4b091

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

pthreads/pthread-rwlock-limit.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
2-
* Find out the lock count limit on your system.
2+
* Find out the lock count limit on your system, assuming it is less than
3+
* ULONG_MAX.
34
*/
45

56
#define _XOPEN_SOURCE 700
@@ -10,19 +11,16 @@
1011
#include <stdio.h>
1112
#include <stdlib.h>
1213
#include <string.h>
14+
#include <limits.h>
1315

1416
pthread_rwlock_t rwlock = PTHREAD_RWLOCK_INITIALIZER;
1517

1618
int
1719
main(int argc, char *argv[])
1820
{
19-
size_t numlocks;
21+
size_t numlocks = ULONG_MAX;
2022
int e;
2123

22-
if (argc != 2)
23-
errx(1, "usage: %s num_locks", argv[0]);
24-
25-
numlocks = strtoll(argv[1], NULL, 10);
2624
printf("will try: %zu\n", numlocks);
2725

2826
for (size_t i = 0; i < numlocks; i++) {

0 commit comments

Comments
 (0)