summaryrefslogtreecommitdiffstats
path: root/libc
diff options
context:
space:
mode:
authorWolfgang Wiedmeyer <wolfgit@wiedmeyer.de>2016-03-18 12:07:00 +0100
committerWolfgang Wiedmeyer <wolfgit@wiedmeyer.de>2016-03-18 12:07:00 +0100
commit385816ce486622d72a8e56443b53ff8404d4ae3b (patch)
treeeda6b439a633bda0fed55b9753ca9b035dc7c04d /libc
parentd103a5984a13da8a540dd760e8682b6ac257e263 (diff)
parentf6164e6c266759ab0cd9e7e491326d3c0974dfbd (diff)
downloadbionic-385816ce486622d72a8e56443b53ff8404d4ae3b.zip
bionic-385816ce486622d72a8e56443b53ff8404d4ae3b.tar.gz
bionic-385816ce486622d72a8e56443b53ff8404d4ae3b.tar.bz2
Merge branch 'cm-13.0' of https://github.com/CyanogenMod/android_bionic into replicant-6.0replicant-6.0-alpha-0005replicant-6.0-alpha-0004
Diffstat (limited to 'libc')
-rw-r--r--libc/bionic/legacy_32_bit_support.cpp19
-rw-r--r--libc/dns/net/getaddrinfo.c8
-rw-r--r--libc/include/libgen.h17
-rw-r--r--libc/include/string.h4
-rw-r--r--libc/include/sys/resource.h3
5 files changed, 36 insertions, 15 deletions
diff --git a/libc/bionic/legacy_32_bit_support.cpp b/libc/bionic/legacy_32_bit_support.cpp
index a107664..1336b43 100644
--- a/libc/bionic/legacy_32_bit_support.cpp
+++ b/libc/bionic/legacy_32_bit_support.cpp
@@ -91,3 +91,22 @@ int getrlimit64(int resource, rlimit64* limits64) {
int setrlimit64(int resource, const rlimit64* limits64) {
return prlimit64(0, resource, limits64, NULL);
}
+
+// There is no prlimit system call, so we need to use prlimit64.
+int prlimit(pid_t pid, int resource, const rlimit* n32, rlimit* o32) {
+ rlimit64 n64;
+ if (n32 != nullptr) {
+ n64.rlim_cur = (n32->rlim_cur == RLIM_INFINITY) ? RLIM64_INFINITY : n32->rlim_cur;
+ n64.rlim_max = (n32->rlim_max == RLIM_INFINITY) ? RLIM64_INFINITY : n32->rlim_max;
+ }
+
+ rlimit64 o64;
+ int result = prlimit64(pid, resource,
+ (n32 != nullptr) ? &n64 : nullptr,
+ (o32 != nullptr) ? &o64 : nullptr);
+ if (result != -1 && o32 != nullptr) {
+ o32->rlim_cur = (o64.rlim_cur == RLIM64_INFINITY) ? RLIM_INFINITY : o64.rlim_cur;
+ o32->rlim_max = (o64.rlim_max == RLIM64_INFINITY) ? RLIM_INFINITY : o64.rlim_max;
+ }
+ return result;
+}
diff --git a/libc/dns/net/getaddrinfo.c b/libc/dns/net/getaddrinfo.c
index 829b679..cc8b8b4 100644
--- a/libc/dns/net/getaddrinfo.c
+++ b/libc/dns/net/getaddrinfo.c
@@ -1791,10 +1791,14 @@ _find_src_addr(const struct sockaddr *addr, struct sockaddr *src_addr, unsigned
return -1;
}
}
- if (mark != MARK_UNSET && setsockopt(sock, SOL_SOCKET, SO_MARK, &mark, sizeof(mark)) < 0)
+ if (mark != MARK_UNSET && setsockopt(sock, SOL_SOCKET, SO_MARK, &mark, sizeof(mark)) < 0) {
+ close(sock);
return 0;
- if (uid > 0 && uid != NET_CONTEXT_INVALID_UID && fchown(sock, uid, (gid_t)-1) < 0)
+ }
+ if (uid > 0 && uid != NET_CONTEXT_INVALID_UID && fchown(sock, uid, (gid_t)-1) < 0) {
+ close(sock);
return 0;
+ }
do {
ret = __connect(sock, addr, len);
} while (ret == -1 && errno == EINTR);
diff --git a/libc/include/libgen.h b/libc/include/libgen.h
index e89328e..4d22d15 100644
--- a/libc/include/libgen.h
+++ b/libc/include/libgen.h
@@ -32,18 +32,19 @@
#include <sys/cdefs.h>
#include <sys/types.h>
+
__BEGIN_DECLS
-#if !defined(__bionic_using_gnu_basename)
/*
- * <string.h> gets you the GNU basename.
- * <libgen.h> the POSIX one.
- * Note that our "POSIX" one has the wrong argument cv-qualifiers, but doesn't
- * modify its input and uses thread-local storage for the result if necessary.
+ * Including <string.h> will get you the GNU basename, unless <libgen.h> is
+ * included, either before or after including <string.h>.
+ *
+ * Note that this has the wrong argument cv-qualifiers, but doesn't modify its
+ * input and uses thread-local storage for the result if necessary.
*/
-extern char* basename(const char*);
-#define __bionic_using_posix_basename
-#endif
+extern char* __posix_basename(const char*) __RENAME(basename);
+
+#define basename __posix_basename
/* This has the wrong argument cv-qualifiers, but doesn't modify its input and uses thread-local storage for the result if necessary. */
extern char* dirname(const char*);
diff --git a/libc/include/string.h b/libc/include/string.h
index d32c164..8ceccd5 100644
--- a/libc/include/string.h
+++ b/libc/include/string.h
@@ -107,18 +107,18 @@ extern size_t strxfrm(char* __restrict, const char* __restrict, size_t);
extern int strcoll_l(const char *, const char *, locale_t) __purefunc;
extern size_t strxfrm_l(char* __restrict, const char* __restrict, size_t, locale_t);
-#if defined(__USE_GNU) && !defined(__bionic_using_posix_basename)
+#if defined(__USE_GNU) && !defined(basename)
/*
* glibc has a basename in <string.h> that's different to the POSIX one in <libgen.h>.
* It doesn't modify its argument, and in C++ it's const-correct.
*/
+
#if defined(__cplusplus)
extern "C++" char* basename(char*) __RENAME(__gnu_basename) __nonnull((1));
extern "C++" const char* basename(const char*) __RENAME(__gnu_basename) __nonnull((1));
#else
extern char* basename(const char*) __RENAME(__gnu_basename) __nonnull((1));
#endif
-#define __bionic_using_gnu_basename
#endif
extern void* __memchr_chk(const void*, int, size_t, size_t);
diff --git a/libc/include/sys/resource.h b/libc/include/sys/resource.h
index 3f8dd45..8209dfb 100644
--- a/libc/include/sys/resource.h
+++ b/libc/include/sys/resource.h
@@ -53,10 +53,7 @@ extern int setpriority(int, int, int);
extern int getrusage(int, struct rusage*);
-#if __LP64__
-/* Implementing prlimit for 32-bit isn't worth the effort. */
extern int prlimit(pid_t, int, const struct rlimit*, struct rlimit*);
-#endif
extern int prlimit64(pid_t, int, const struct rlimit64*, struct rlimit64*);
__END_DECLS