mailing list of musl libc
 help / color / mirror / code / Atom feed
665b67de0b9862a8e6ce8353f03f072e24f18ea6 blob 1003 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
 
#include <sys/resource.h>
#include <errno.h>
#include "syscall.h"
#include "libc.h"

#define MIN(a, b) ((a)<(b) ? (a) : (b))

int __setrlimit(int resource, const struct rlimit *rlim)
{
	unsigned long k_rlim[2];
#ifdef __broken_RLIM_INFINITY
	struct rlimit tmp;
	tmp.rlim_cur = MIN(rlim->rlim_cur, -1UL/2);
	tmp.rlim_max = MIN(rlim->rlim_max, -1UL/2);
	rlim = &tmp;
#endif
	int ret = __syscall(SYS_prlimit64, 0, resource, rlim, 0);
	if (ret != -ENOSYS) return ret;
	k_rlim[0] = MIN(rlim->rlim_cur, -1UL);
	k_rlim[1] = MIN(rlim->rlim_max, -1UL);
	return __syscall(SYS_setrlimit, resource, k_rlim);
}

struct ctx {
	const struct rlimit *rlim;
	int res;
	int err;
};

static void do_setrlimit(void *p)
{
	struct ctx *c = p;
	if (c->err) return;
	c->err = -__setrlimit(c->res, c->rlim);
}

int setrlimit(int resource, const struct rlimit *rlim)
{
	struct ctx c = { .res = resource, .rlim = rlim };
	__synccall(do_setrlimit, &c);
	if (c.err) {
		errno = c.err;
		return -1;
	}
	return 0;
}

LFS64(setrlimit);
debug log:

solving 665b67d ...
found 665b67d in https://inbox.vuxu.org/musl/20140524081320.GH12324@port70.net/
found ddc13e9 in https://git.vuxu.org/mirror/musl/
preparing index
index prepared:
100644 ddc13e98bf9e8272c17fe4b074ac0a86cc7cc8d5	src/misc/setrlimit.c

applying [1/1] https://inbox.vuxu.org/musl/20140524081320.GH12324@port70.net/
diff --git a/src/misc/setrlimit.c b/src/misc/setrlimit.c
index ddc13e9..665b67d 100644

Checking patch src/misc/setrlimit.c...
Applied patch src/misc/setrlimit.c cleanly.

index at:
100644 665b67de0b9862a8e6ce8353f03f072e24f18ea6	src/misc/setrlimit.c

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

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

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