termux-packages/ndk-patches/stdio.h.patch
Vishal Biswas 160d3aeb06 update ndk to 17 and switch some packages to clang build (#2415)
* update ndk to 17

* bump NDK version in setup-android script

* libnl: fix for ndk r17

* libpixman: use clang's __builtin_shufflevector instead of __builtin_shuffle (#1)

Required to make package build with ndk17.

* fix as for arm

* ndk17 still uses ld.bfd on aarch64

* use -fno-integrated-as for clang only

* glib: remove patch unnecessary after ndk17

* torsocks: remove unneeded patch after ndk17

* subversion: fix build as clang++ now errors out for mismatched flags

* libpulseaudio: fix build with ndk17

https://github.com/termux/termux-packages/pull/2415#issuecomment-388296684

* gst-plugins-good: disable video4linux2

ioctl is defined as __overloadable in ndk17 headers which
  conflicts with v4l2object's member ioctl

* libzmq: disable Werror to build with ndk17

* ltrace: hardcode symbol not available in ndk17

* busybox: build with clang for all arches except arm

* dropbear: build with clang instead of gcc

* gnupg: build with clang instead of gcc

* openssl: use clang for all arches except arm

* picolisp: build with clang instead of gcc

* valgrind: use clang on all arches except aarch64

* Revert "gst-plugins-good: disable video4linux2"

This reverts commit 43850b81ccf60033c25cb13dfd326c1b0528773a.
Already applied on base branch.

* libllvm: use default arm triple
2018-05-27 14:55:20 +02:00

81 lines
2.4 KiB
Diff

diff -u -r /home/fornwall/lib/android-ndk/sysroot/usr/include/stdio.h ./usr/include/stdio.h
--- /home/fornwall/lib/android-ndk/sysroot/usr/include/stdio.h 2017-11-09 09:57:12.000000000 +0100
+++ ./usr/include/stdio.h 2017-11-15 11:57:58.567432093 +0100
@@ -44,6 +44,9 @@
#include <stdarg.h>
#include <stddef.h>
+#include <string.h> /* For strcpy(3) used by ctermid() */
+#include <asm/fcntl.h> /* For O_RDWR and other O_* constants */
+
#include <bits/seek_constants.h>
#if __ANDROID_API__ < __ANDROID_API_N__
@@ -167,7 +170,7 @@
__warnattr_strict("vsprintf is often misused; please use vsnprintf");
char* tmpnam(char* __s)
__warnattr("tempnam is unsafe, use mkstemp or tmpfile instead");
-#define P_tmpdir "/tmp/" /* deprecated */
+#define P_tmpdir "@TERMUX_PREFIX@/tmp/" /* deprecated */
char* tempnam(const char* __dir, const char* __prefix)
__warnattr("tempnam is unsafe, use mkstemp or tmpfile instead");
@@ -242,8 +245,6 @@
FILE* freopen64(const char* __path, const char* __mode, FILE* __fp) __INTRODUCED_IN(24);
#endif /* __ANDROID_API__ >= 24 */
-FILE* tmpfile(void);
-
#if __ANDROID_API__ >= 24
FILE* tmpfile64(void) __INTRODUCED_IN(24);
#endif /* __ANDROID_API__ >= 24 */
@@ -259,10 +260,15 @@
#define L_ctermid 1024 /* size for ctermid() */
-#if __ANDROID_API__ >= 26
-char* ctermid(char* __buf) __INTRODUCED_IN(26);
-#endif /* __ANDROID_API__ >= 26 */
+/* Needed by gnulibs freading(). */
+#define __sferror(p) (((p)->_flags & __SERR) != 0)
+/* Used by perl, fish, and others. */
+static __inline__ char* ctermid(char* s) {
+ if (s == 0) return (char*) "/dev/tty";
+ strcpy(s, "/dev/tty");
+ return s;
+}
FILE* fdopen(int __fd, const char* __mode);
int fileno(FILE* __fp);
@@ -310,6 +316,29 @@
#include <bits/fortify/stdio.h>
#endif
+int open(const char*, int, ...);
+extern pid_t getpid();
+extern int unlink(const char*);
+void free(void* p);
+uint32_t arc4random(void);
+static __inline__ FILE* tmpfile() {
+ int p = getpid();
+ char* path;
+ int i;
+ for (i = 0; i < 100; i++) {
+ unsigned int r = arc4random();
+ if (asprintf(&path, "@TERMUX_PREFIX@/tmp/tmpfile.%d-%u", p, r) == -1) return NULL;
+ int fd = open(path, O_RDWR | O_CREAT | O_EXCL | O_LARGEFILE, 0600);
+ free(path);
+ if (fd >= 0) {
+ FILE* result = fdopen(fd, "w+");
+ unlink(path);
+ return result;
+ }
+ }
+ return NULL;
+}
+
__END_DECLS
#endif