1 diff -u -r /home/fornwall/lib/android-ndk/sysroot/usr/include/stdio.h ./usr/include/stdio.h
2 --- /home/fornwall/lib/android-ndk/sysroot/usr/include/stdio.h 2017-11-09 09:57:12.000000000 +0100
3 +++ ./usr/include/stdio.h 2017-11-15 11:57:58.567432093 +0100
8 +#include <string.h> /* For strcpy(3) used by ctermid() */
9 +#include <asm/fcntl.h> /* For O_RDWR and other O_* constants */
11 #include <bits/seek_constants.h>
13 #if __ANDROID_API__ < __ANDROID_API_N__
15 __warnattr_strict("vsprintf is often misused; please use vsnprintf");
16 char* tmpnam(char* __s)
17 __warnattr("tempnam is unsafe, use mkstemp or tmpfile instead");
18 -#define P_tmpdir "/tmp/" /* deprecated */
19 +#define P_tmpdir "@TERMUX_PREFIX@/tmp/" /* deprecated */
20 char* tempnam(const char* __dir, const char* __prefix)
21 __warnattr("tempnam is unsafe, use mkstemp or tmpfile instead");
24 FILE* freopen64(const char* __path, const char* __mode, FILE* __fp) __INTRODUCED_IN(24);
25 #endif /* __ANDROID_API__ >= 24 */
29 #if __ANDROID_API__ >= 24
30 FILE* tmpfile64(void) __INTRODUCED_IN(24);
31 #endif /* __ANDROID_API__ >= 24 */
34 #define L_ctermid 1024 /* size for ctermid() */
36 -#if __ANDROID_API__ >= 26
37 -char* ctermid(char* __buf) __INTRODUCED_IN(26);
38 -#endif /* __ANDROID_API__ >= 26 */
39 +/* Needed by gnulibs freading(). */
40 +#define __sferror(p) (((p)->_flags & __SERR) != 0)
42 +/* Used by perl, fish, and others. */
43 +static __inline__ char* ctermid(char* s) {
44 + if (s == 0) return (char*) "/dev/tty";
45 + strcpy(s, "/dev/tty");
49 FILE* fdopen(int __fd, const char* __mode);
50 int fileno(FILE* __fp);
52 #include <bits/fortify/stdio.h>
55 +int open(const char*, int, ...) __overloadable __RENAME_CLANG(open);
56 +extern pid_t getpid();
57 +extern int unlink(const char*);
59 +uint32_t arc4random(void);
60 +static __inline__ FILE* tmpfile() {
64 + for (i = 0; i < 100; i++) {
65 + unsigned int r = arc4random();
66 + if (asprintf(&path, "@TERMUX_PREFIX@/tmp/tmpfile.%d-%u", p, r) == -1) return NULL;
67 + int fd = open(path, O_RDWR | O_CREAT | O_EXCL | O_LARGEFILE, 0600);
70 + FILE* result = fdopen(fd, "w+");