leptonica: Avoid linking against openjpeg
[termux-packages] / ndk_patches / stdio.h.patch
CommitLineData
59f0d218 1diff -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() */
a4b03642 9+#include <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
FD
39+/* Used by perl, fish, and others */
40+static char* ctermid(char* s) {
41+ if (s == 0) return "/dev/tty";
42+ strcpy(s, "/dev/tty");
43+ return s;
44+}
45+
59f0d218 46 #if defined(__BIONIC_FORTIFY)
9867ff1a 47
59f0d218 48 __BEGIN_DECLS
a4b03642
FF
49@@ -462,4 +474,26 @@
50
51 #endif /* defined(__BIONIC_FORTIFY) */
52
53+__BEGIN_DECLS
54+
55+static FILE* tmpfile() {
56+ int p = getpid();
57+ char* path;
58+ int i;
59+ for (i = 0; i < 100; i++) {
2c4c89b3
FF
60+ unsigned int r = arc4random();
61+ if (asprintf(&path, "@TERMUX_PREFIX@/tmp/tmpfile.%d-%u", p, r) == -1) return NULL;
a4b03642
FF
62+ int fd = open(path, O_RDWR | O_CREAT | O_EXCL | O_LARGEFILE);
63+ free(path);
64+ if (fd >= 0) {
65+ FILE* result = fdopen(fd, "w+");
66+ unlink(path);
67+ return result;
68+ }
69+ }
70+ return NULL;
71+}
72+
73+__END_DECLS
74+
75 #endif /* _STDIO_H_ */