[musl] Remove sys/resource.h and ulimit.h These are legacy POSIX resource measurement and scheduler control interfaces and don't map well to our plans for Fuchsia. Change-Id: I7341465d240906a7dafa3effd47740348459ef04
diff --git a/third_party/ulib/musl/exported.map b/third_party/ulib/musl/exported.map index 24cb152..d713137 100644 --- a/third_party/ulib/musl/exported.map +++ b/third_party/ulib/musl/exported.map
@@ -317,7 +317,6 @@ getpwuid_r; getresgid; getresuid; - getrusage; getservbyname; getservbyport; getsid; @@ -671,7 +670,6 @@ setresgid; setresuid; setreuid; - setrlimit; setsid; setsockopt; setuid;
diff --git a/third_party/ulib/musl/include/module.modulemap b/third_party/ulib/musl/include/module.modulemap index b5d3541..178847a 100644 --- a/third_party/ulib/musl/include/module.modulemap +++ b/third_party/ulib/musl/include/module.modulemap
@@ -263,10 +263,6 @@ header "tar.h" export * } - module ulimit { // POSIX - header "ulimit.h" - export * - } module unistd { // POSIX header "unistd.h" export * @@ -410,10 +406,6 @@ header "sys/msg.h" export * } - module resource { - header "sys/resource.h" - export * - } module select { header "sys/select.h" export *
diff --git a/third_party/ulib/musl/include/sys/param.h b/third_party/ulib/musl/include/sys/param.h index 4515d25..64989a4 100644 --- a/third_party/ulib/musl/include/sys/param.h +++ b/third_party/ulib/musl/include/sys/param.h
@@ -29,4 +29,3 @@ #include <endian.h> #include <limits.h> -#include <sys/resource.h>
diff --git a/third_party/ulib/musl/include/sys/resource.h b/third_party/ulib/musl/include/sys/resource.h deleted file mode 100644 index 9af6bc6..0000000 --- a/third_party/ulib/musl/include/sys/resource.h +++ /dev/null
@@ -1,107 +0,0 @@ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -#include <features.h> -#include <sys/time.h> - -#define __NEED_id_t - -#ifdef _GNU_SOURCE -#define __NEED_pid_t -#endif - -#include <bits/alltypes.h> -#include <bits/resource.h> - -typedef unsigned long long rlim_t; - -struct rlimit { - rlim_t rlim_cur; - rlim_t rlim_max; -}; - -struct rusage { - struct timeval ru_utime; - struct timeval ru_stime; - /* linux extentions, but useful */ - long ru_maxrss; - long ru_ixrss; - long ru_idrss; - long ru_isrss; - long ru_minflt; - long ru_majflt; - long ru_nswap; - long ru_inblock; - long ru_oublock; - long ru_msgsnd; - long ru_msgrcv; - long ru_nsignals; - long ru_nvcsw; - long ru_nivcsw; - /* room for more... */ - long __reserved[16]; -}; - -int getrlimit(int, struct rlimit*); -int setrlimit(int, const struct rlimit*); -int getrusage(int, struct rusage*); - -int getpriority(int, id_t); -int setpriority(int, id_t, int); - -#ifdef _GNU_SOURCE -int prlimit(pid_t, int, const struct rlimit*, struct rlimit*); -#define prlimit64 prlimit -#endif - -#define PRIO_MIN (-20) -#define PRIO_MAX 20 - -#define PRIO_PROCESS 0 -#define PRIO_PGRP 1 -#define PRIO_USER 2 - -#define RUSAGE_SELF 0 -#define RUSAGE_CHILDREN 1 - -#define RLIM_INFINITY (~0ULL) -#define RLIM_SAVED_CUR RLIM_INFINITY -#define RLIM_SAVED_MAX RLIM_INFINITY - -#define RLIMIT_CPU 0 -#define RLIMIT_FSIZE 1 -#define RLIMIT_DATA 2 -#define RLIMIT_STACK 3 -#define RLIMIT_CORE 4 -#ifndef RLIMIT_RSS -#define RLIMIT_RSS 5 -#define RLIMIT_NPROC 6 -#define RLIMIT_NOFILE 7 -#define RLIMIT_MEMLOCK 8 -#define RLIMIT_AS 9 -#endif -#define RLIMIT_LOCKS 10 -#define RLIMIT_SIGPENDING 11 -#define RLIMIT_MSGQUEUE 12 -#define RLIMIT_NICE 13 -#define RLIMIT_RTPRIO 14 -#define RLIMIT_NLIMITS 15 - -#define RLIM_NLIMITS RLIMIT_NLIMITS - -#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) -#define RLIM64_INFINITY RLIM_INFINITY -#define RLIM64_SAVED_CUR RLIM_SAVED_CUR -#define RLIM64_SAVED_MAX RLIM_SAVED_MAX -#define getrlimit64 getrlimit -#define setrlimit64 setrlimit -#define rlimit64 rlimit -#define rlim64_t rlim_t -#endif - -#ifdef __cplusplus -} -#endif
diff --git a/third_party/ulib/musl/include/ulimit.h b/third_party/ulib/musl/include/ulimit.h deleted file mode 100644 index 6e0c814..0000000 --- a/third_party/ulib/musl/include/ulimit.h +++ /dev/null
@@ -1,14 +0,0 @@ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -#define UL_GETFSIZE 1 -#define UL_SETFSIZE 2 - -long ulimit(int, ...); - -#ifdef __cplusplus -} -#endif
diff --git a/third_party/ulib/musl/include/unistd.h b/third_party/ulib/musl/include/unistd.h index 6f9094a0..99a1b8e 100644 --- a/third_party/ulib/musl/include/unistd.h +++ b/third_party/ulib/musl/include/unistd.h
@@ -132,7 +132,6 @@ #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) int lockf(int, int, off_t); long gethostid(void); -int nice(int); void sync(void); int syncfs(int); pid_t setpgrp(void);
diff --git a/third_party/ulib/musl/musl-rules.mk b/third_party/ulib/musl/musl-rules.mk index 8ef9920..ab94a94 100644 --- a/third_party/ulib/musl/musl-rules.mk +++ b/third_party/ulib/musl/musl-rules.mk
@@ -279,7 +279,6 @@ $(LOCAL_DIR)/src/legacy/getpass.c \ $(LOCAL_DIR)/src/legacy/isastream.c \ $(LOCAL_DIR)/src/legacy/lutimes.c \ - $(LOCAL_DIR)/src/legacy/ulimit.c \ $(LOCAL_DIR)/src/linux/adjtime.c \ $(LOCAL_DIR)/src/linux/flock.c \ $(LOCAL_DIR)/src/linux/sethostname.c \ @@ -437,9 +436,6 @@ $(LOCAL_DIR)/src/misc/gethostid.c \ $(LOCAL_DIR)/src/misc/getopt.c \ $(LOCAL_DIR)/src/misc/getopt_long.c \ - $(LOCAL_DIR)/src/misc/getpriority.c \ - $(LOCAL_DIR)/src/misc/getrlimit.c \ - $(LOCAL_DIR)/src/misc/getrusage.c \ $(LOCAL_DIR)/src/misc/getsubopt.c \ $(LOCAL_DIR)/src/misc/initgroups.c \ $(LOCAL_DIR)/src/misc/issetugid.c \ @@ -449,8 +445,6 @@ $(LOCAL_DIR)/src/misc/ptsname.c \ $(LOCAL_DIR)/src/misc/pty.c \ $(LOCAL_DIR)/src/misc/setdomainname.c \ - $(LOCAL_DIR)/src/misc/setpriority.c \ - $(LOCAL_DIR)/src/misc/setrlimit.c \ $(LOCAL_DIR)/src/misc/syslog.c \ $(LOCAL_DIR)/src/misc/wordexp.c \ $(LOCAL_DIR)/src/mman/madvise.c \ @@ -876,7 +870,6 @@ $(LOCAL_DIR)/src/unistd/gethostname.c \ $(LOCAL_DIR)/src/unistd/getlogin.c \ $(LOCAL_DIR)/src/unistd/getlogin_r.c \ - $(LOCAL_DIR)/src/unistd/nice.c \ $(LOCAL_DIR)/src/unistd/pause.c \ $(LOCAL_DIR)/src/unistd/posix_close.c \ $(LOCAL_DIR)/src/unistd/setpgrp.c \
diff --git a/third_party/ulib/musl/src/conf/sysconf.c b/third_party/ulib/musl/src/conf/sysconf.c index 4662cde..5db672d 100644 --- a/third_party/ulib/musl/src/conf/sysconf.c +++ b/third_party/ulib/musl/src/conf/sysconf.c
@@ -2,7 +2,7 @@ #include <errno.h> #include <limits.h> #include <signal.h> -#include <sys/resource.h> +#include <stdint.h> #include <unistd.h> #include <zircon/syscalls.h> @@ -18,16 +18,15 @@ #define JT_PHYS_PAGES JT(8) #define JT_AVPHYS_PAGES JT(9) #define JT_ZERO JT(10) - -#define RLIM(x) (-32768 | (RLIMIT_##x)) +#define JT_CHILD_MAX JT(11) long sysconf(int name) { static const short values[] = { [_SC_ARG_MAX] = JT_ARG_MAX, - [_SC_CHILD_MAX] = RLIM(NPROC), + [_SC_CHILD_MAX] = JT_CHILD_MAX, [_SC_CLK_TCK] = 100, [_SC_NGROUPS_MAX] = 32, - [_SC_OPEN_MAX] = RLIM(NOFILE), + [_SC_OPEN_MAX] = 256, [_SC_STREAM_MAX] = -1, [_SC_TZNAME_MAX] = TZNAME_MAX, [_SC_JOB_CONTROL] = 1, @@ -170,10 +169,6 @@ return -1; } else if (values[name] >= -1) { return values[name]; - } else if (values[name] < -256) { - struct rlimit lim; - getrlimit(values[name] & 16383, &lim); - return lim.rlim_cur > LONG_MAX ? LONG_MAX : lim.rlim_cur; } switch ((unsigned char)values[name]) { @@ -208,6 +203,8 @@ return -1; case JT_ZERO & 255: return 0; + case JT_CHILD_MAX & 255: + return UINT32_MAX; } return values[name]; }
diff --git a/third_party/ulib/musl/src/legacy/getdtablesize.c b/third_party/ulib/musl/src/legacy/getdtablesize.c index cbeb57e..55c8197 100644 --- a/third_party/ulib/musl/src/legacy/getdtablesize.c +++ b/third_party/ulib/musl/src/legacy/getdtablesize.c
@@ -1,10 +1,8 @@ #define _GNU_SOURCE #include <limits.h> -#include <sys/resource.h> #include <unistd.h> int getdtablesize(void) { - struct rlimit rl; - getrlimit(RLIMIT_NOFILE, &rl); - return rl.rlim_max < INT_MAX ? rl.rlim_max : INT_MAX; + int max = sysconf(_SC_OPEN_MAX); + return max < INT_MAX ? max : INT_MAX; }
diff --git a/third_party/ulib/musl/src/legacy/ulimit.c b/third_party/ulib/musl/src/legacy/ulimit.c deleted file mode 100644 index 4a0fbaeb..0000000 --- a/third_party/ulib/musl/src/legacy/ulimit.c +++ /dev/null
@@ -1,19 +0,0 @@ -#include <stdarg.h> -#include <sys/resource.h> -#include <ulimit.h> - -long ulimit(int cmd, ...) { - struct rlimit rl; - getrlimit(RLIMIT_FSIZE, &rl); - if (cmd == UL_SETFSIZE) { - long val; - va_list ap; - va_start(ap, cmd); - val = va_arg(ap, long); - va_end(ap); - rl.rlim_cur = 512ULL * val; - if (setrlimit(RLIMIT_FSIZE, &rl)) - return -1; - } - return rl.rlim_cur / 512; -}
diff --git a/third_party/ulib/musl/src/misc/getpriority.c b/third_party/ulib/musl/src/misc/getpriority.c deleted file mode 100644 index a379eeb..0000000 --- a/third_party/ulib/musl/src/misc/getpriority.c +++ /dev/null
@@ -1,7 +0,0 @@ -#include <errno.h> -#include <sys/resource.h> - -int getpriority(int which, id_t who) { - errno = ENOSYS; - return -1; -}
diff --git a/third_party/ulib/musl/src/misc/getrlimit.c b/third_party/ulib/musl/src/misc/getrlimit.c deleted file mode 100644 index 76f47dd..0000000 --- a/third_party/ulib/musl/src/misc/getrlimit.c +++ /dev/null
@@ -1,8 +0,0 @@ -#include <errno.h> -#include <sys/resource.h> - -int getrlimit(int resource, struct rlimit* rlim) { - // TODO(kulakowski) implement getrlimit - errno = ENOSYS; - return -1; -}
diff --git a/third_party/ulib/musl/src/misc/getrusage.c b/third_party/ulib/musl/src/misc/getrusage.c deleted file mode 100644 index ca4abe3..0000000 --- a/third_party/ulib/musl/src/misc/getrusage.c +++ /dev/null
@@ -1,7 +0,0 @@ -#include <errno.h> -#include <sys/resource.h> - -int getrusage(int who, struct rusage* ru) { - errno = ENOSYS; - return -1; -}
diff --git a/third_party/ulib/musl/src/misc/setpriority.c b/third_party/ulib/musl/src/misc/setpriority.c deleted file mode 100644 index 1bf604e..0000000 --- a/third_party/ulib/musl/src/misc/setpriority.c +++ /dev/null
@@ -1,7 +0,0 @@ -#include <errno.h> -#include <sys/resource.h> - -int setpriority(int which, id_t who, int prio) { - errno = ENOSYS; - return -1; -}
diff --git a/third_party/ulib/musl/src/misc/setrlimit.c b/third_party/ulib/musl/src/misc/setrlimit.c deleted file mode 100644 index 032da14..0000000 --- a/third_party/ulib/musl/src/misc/setrlimit.c +++ /dev/null
@@ -1,6 +0,0 @@ -#include <sys/resource.h> - -int setrlimit(int resource, const struct rlimit* rlim) { - // TODO(kulakowski) Implement fake rlimit. - return -1; -}
diff --git a/third_party/ulib/musl/src/unistd/nice.c b/third_party/ulib/musl/src/unistd/nice.c deleted file mode 100644 index d4c8176..0000000 --- a/third_party/ulib/musl/src/unistd/nice.c +++ /dev/null
@@ -1,10 +0,0 @@ -#include <sys/resource.h> -#include <unistd.h> - -int nice(int inc) { -#ifdef SYS_nice - return syscall(SYS_nice, inc); -#else - return setpriority(PRIO_PROCESS, 0, getpriority(PRIO_PROCESS, 0) + inc); -#endif -}