Commit | Line | Data |
---|---|---|
59f0d218 | 1 | diff -u -r /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/include/stdio.h ./usr/include/stdio.h |
a4b03642 FF |
2 | --- /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/include/stdio.h 2016-03-03 16:54:24.000000000 -0500 |
3 | +++ ./usr/include/stdio.h 2016-04-11 06:54:22.893930847 -0400 | |
4 | @@ -52,6 +52,10 @@ | |
9867ff1a FF |
5 | #include <stdarg.h> |
6 | #include <stddef.h> | |
7 | ||
8 | +#include <string.h> /* For strcpy(3) used by ctermid() */ | |
0475ed56 | 9 | +#include <asm/fcntl.h> /* For O_RDWR and other O_* constants */ |
2c4c89b3 | 10 | +#include <stdlib.h> /* For arc4random() */ |
9867ff1a FF |
11 | + |
12 | #define __need_NULL | |
13 | #include <stddef.h> | |
14 | ||
a4b03642 | 15 | @@ -193,7 +196,7 @@ |
9867ff1a | 16 | |
59f0d218 FF |
17 | /* System V/ANSI C; this is the wrong way to do this, do *not* use these. */ |
18 | #if __BSD_VISIBLE || __XPG_VISIBLE | |
19 | -#define P_tmpdir "/tmp/" | |
c501b827 | 20 | +#define P_tmpdir "@TERMUX_PREFIX@/tmp/" |
59f0d218 FF |
21 | #endif |
22 | #define L_tmpnam 1024 /* XXX must be == PATH_MAX */ | |
23 | #define TMP_MAX 308915776 | |
a4b03642 FF |
24 | @@ -257,7 +260,6 @@ |
25 | int setvbuf(FILE * __restrict, char * __restrict, int, size_t); | |
26 | int sscanf(const char * __restrict, const char * __restrict, ...) | |
27 | __scanflike(2, 3); | |
28 | -FILE *tmpfile(void); | |
29 | int ungetc(int, FILE *); | |
30 | int vfprintf(FILE * __restrict, const char * __restrict, __va_list) | |
31 | __printflike(2, 0); | |
9867ff1a | 32 | @@ -371,6 +373,16 @@ |
59f0d218 FF |
33 | #define fwopen(cookie, fn) funopen(cookie, 0, fn, 0, 0) |
34 | #endif /* __BSD_VISIBLE */ | |
9867ff1a | 35 | |
59f0d218 FF |
36 | +/* Needed by gnulibs freading() */ |
37 | +#define __sferror(p) (((p)->_flags & __SERR) != 0) | |
38 | + | |
93b884f1 | 39 | +/* Used by perl, fish, and others */ |
f153ee93 | 40 | +static char* ctermid(char* s) { |
7f447235 | 41 | + if (s == 0) return (char*) "/dev/tty"; |
93b884f1 FD |
42 | + strcpy(s, "/dev/tty"); |
43 | + return s; | |
44 | +} | |
45 | + | |
59f0d218 | 46 | #if defined(__BIONIC_FORTIFY) |
9867ff1a | 47 | |
59f0d218 | 48 | __BEGIN_DECLS |
b29ec8d9 | 49 | @@ -462,4 +474,29 @@ |
a4b03642 FF |
50 | |
51 | #endif /* defined(__BIONIC_FORTIFY) */ | |
52 | ||
53 | +__BEGIN_DECLS | |
54 | + | |
b29ec8d9 FF |
55 | +extern int open(const char*, int, ...); |
56 | +extern pid_t getpid(); | |
57 | +extern int unlink(const char*); | |
f153ee93 | 58 | +static FILE* tmpfile() { |
a4b03642 FF |
59 | + int p = getpid(); |
60 | + char* path; | |
61 | + int i; | |
62 | + for (i = 0; i < 100; i++) { | |
2c4c89b3 FF |
63 | + unsigned int r = arc4random(); |
64 | + if (asprintf(&path, "@TERMUX_PREFIX@/tmp/tmpfile.%d-%u", p, r) == -1) return NULL; | |
30cd6464 | 65 | + int fd = open(path, O_RDWR | O_CREAT | O_EXCL | O_LARGEFILE, 0600); |
a4b03642 FF |
66 | + free(path); |
67 | + if (fd >= 0) { | |
68 | + FILE* result = fdopen(fd, "w+"); | |
69 | + unlink(path); | |
70 | + return result; | |
71 | + } | |
72 | + } | |
73 | + return NULL; | |
74 | +} | |
75 | + | |
76 | +__END_DECLS | |
77 | + | |
78 | #endif /* _STDIO_H_ */ |