Skip to content

Commit 5265111

Browse files
committed
options/posix: fix sys/resource.h pollution
1 parent 9993994 commit 5265111

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

abis/linux/resource.h

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,46 @@
55
extern "C" {
66
#endif
77

8+
#include <mlibc-config.h>
89
#include <bits/posix/timeval.h>
910

11+
#if defined(_GNU_SOURCE)
12+
#define PRIO_MIN (-20)
13+
#define PRIO_MAX 20
14+
#endif /* defined(_GNU_SOURCE) */
15+
16+
#if defined(_DEFAULT_SOURCE) || __MLIBC_XOPEN
1017
#define PRIO_PROCESS 0
1118
#define PRIO_PGRP 1
1219
#define PRIO_USER 2
1320

14-
#define PRIO_MIN (-20)
15-
#define PRIO_MAX 20
16-
1721
#define RUSAGE_SELF 0
1822
#define RUSAGE_CHILDREN -1
1923

2024
#define RLIMIT_CPU 0
25+
#endif /* defined(_DEFAULT_SOURCE) || __MLIBC_XOPEN */
26+
2127
#define RLIMIT_FSIZE 1
2228
#define RLIMIT_DATA 2
2329
#define RLIMIT_STACK 3
2430
#define RLIMIT_CORE 4
31+
#define RLIMIT_NOFILE 7
32+
#define RLIMIT_AS 9
33+
34+
#if defined(_DEFAULT_SOURCE)
2535
#define RLIMIT_RSS 5
2636
#define RLIMIT_NPROC 6
27-
#define RLIMIT_NOFILE 7
2837
#define RLIMIT_MEMLOCK 8
29-
#define RLIMIT_AS 9
3038
#define RLIMIT_LOCKS 10
3139
#define RLIMIT_SIGPENDING 11
3240
#define RLIMIT_MSGQUEUE 12
3341
#define RLIMIT_NICE 13
3442
#define RLIMIT_RTPRIO 14
3543
#define RLIMIT_RTTIME 15
3644
#define RLIMIT_NLIMITS 16
45+
#endif
3746

47+
#if defined(_DEFAULT_SOURCE) || __MLIBC_XOPEN
3848
struct rusage {
3949
struct timeval ru_utime;
4050
struct timeval ru_stime;
@@ -53,6 +63,7 @@ struct rusage {
5363
long ru_nvcsw;
5464
long ru_nivcsw;
5565
};
66+
#endif /* defined(_DEFAULT_SOURCE) || __MLIBC_XOPEN */
5667

5768
#ifdef __cplusplus
5869
}

options/posix/include/sys/resource.h

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
#define RLIM_SAVED_MAX ((rlim_t)-1)
1616
#define RLIM_SAVED_CUR ((rlim_t)-1)
1717

18+
#if defined(_GNU_SOURCE)
1819
#define RLIM_NLIMITS RLIMIT_NLIMITS
20+
#endif /* defined(_GNU_SOURCE) */
1921

2022
#ifdef __cplusplus
2123
extern "C" {
@@ -28,20 +30,24 @@ struct rlimit {
2830

2931
#ifndef __MLIBC_ABI_ONLY
3032

33+
#if defined(_DEFAULT_SOURCE) || __MLIBC_XOPEN
3134
int getpriority(int __which, id_t __who);
3235
int setpriority(int __which, id_t __who, int __prio);
3336

3437
int getrusage(int __who, struct rusage *__usage);
38+
#endif /* defined(_DEFAULT_SOURCE) || __MLIBC_XOPEN */
39+
3540
int getrlimit(int __resource, struct rlimit *__rlim);
36-
#if __MLIBC_LINUX_OPTION
37-
int getrlimit64(int __resource, struct rlimit *__rlim);
38-
#endif /* !__MLIBC_LINUX_OPTION */
3941
int setrlimit(int __resource, const struct rlimit *__rlim);
40-
#if __MLIBC_LINUX_OPTION
42+
43+
#if __MLIBC_LINUX_OPTION && defined(_LARGEFILE64_SOURCE)
44+
int getrlimit64(int __resource, struct rlimit *__rlim);
4145
int setrlimit64(int __resource, const struct rlimit *__rlim);
42-
#endif /* !__MLIBC_LINUX_OPTION */
46+
#endif /* __MLIBC_LINUX_OPTION && defined(_LARGEFILE64_SOURCE) */
4347

48+
#if defined(_GNU_SOURCE)
4449
int prlimit(pid_t __pid, int __resource, const struct rlimit *__new_limits, struct rlimit *__old_limits);
50+
#endif /* defined(_GNU_SOURCE) */
4551

4652
#endif /* !__MLIBC_ABI_ONLY */
4753

0 commit comments

Comments
 (0)