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-06-07 01:07:52.000000000 +0200
3 +++ ./usr/include/stdio.h 2017-06-18 01:59:17.835984565 +0200
8 +#include <string.h> /* For strcpy(3) used by ctermid() */
9 +#include <asm/fcntl.h> /* For O_RDWR and other O_* constants */
15 __warnattr_strict("vsprintf is often misused; please use vsnprintf");
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*, const char*)
21 __warnattr("tempnam is unsafe, use mkstemp or tmpfile instead");
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*) __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, const char*);
57 +int open(const char*, int, ...) __overloadable __RENAME_CLANG(open);
58 +extern pid_t getpid();
59 +extern int unlink(const char*);
61 +uint32_t arc4random(void);
62 +static __inline__ FILE* tmpfile() {
66 + for (i = 0; i < 100; i++) {
67 + unsigned int r = arc4random();
68 + if (asprintf(&path, "@TERMUX_PREFIX@/tmp/tmpfile.%d-%u", p, r) == -1) return NULL;
69 + int fd = open(path, O_RDWR | O_CREAT | O_EXCL | O_LARGEFILE, 0600);
72 + FILE* result = fdopen(fd, "w+");
82 #endif /* _STDIO_H_ */