mirror of
https://github.com/termux/termux-packages.git
synced 2024-11-23 14:56:16 +00:00
e7f4ad8b6d
And keep ndk-patches in 23c/ subdirectory. Run termux_step_setup_toolchain_23c only if TERMUX_NDK_VERSION equals 23c. This is a step towards having the possibility to use different NDK versions. Using a different NDK version than the one termux officially supports should *really* not be done except for testing/debug/development reasons, or if it is strictly necessary to be able to compile a program (for example for packages that need a fortran compiler, which at the moment is only supported with old gcc-using NDKs).
81 lines
2.3 KiB
Diff
81 lines
2.3 KiB
Diff
--- ./usr/include/stdio.h.orig 2021-08-16 11:48:44.308954400 +0200
|
|
+++ ./usr/include/stdio.h 2021-08-16 11:50:00.438924014 +0200
|
|
@@ -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__ < 24
|
|
@@ -165,7 +166,7 @@
|
|
__printflike(2, 0) __warnattr_strict("vsprintf is often misused; please use vsnprintf");
|
|
char* tmpnam(char* __s)
|
|
__warnattr("tmpnam 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");
|
|
|
|
@@ -289,8 +290,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 */
|
|
@@ -304,10 +303,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);
|
|
@@ -376,6 +380,30 @@
|
|
#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);
|
|
+ if (fd >= 0) {
|
|
+ FILE* result = fdopen(fd, "w+");
|
|
+ unlink(path);
|
|
+ free(path);
|
|
+ return result;
|
|
+ }
|
|
+ free(path);
|
|
+ }
|
|
+ return NULL;
|
|
+}
|
|
+
|
|
__END_DECLS
|
|
|
|
#endif
|