From cd9122e5846af77ac34fe8ad5ff4bbc1178f505a Mon Sep 17 00:00:00 2001 From: Lucio Andrés Illanes Albornoz Date: Jan 17 2019 23:49:51 +0000 Subject: patches/musl/: removes obsolete patches (via Redfoxmoon.) --- diff --git a/patches/musl/musl-0001-fopencookie.patch b/patches/musl/musl-0001-fopencookie.patch deleted file mode 100644 index 6c9f32c..0000000 --- a/patches/musl/musl-0001-fopencookie.patch +++ /dev/null @@ -1,204 +0,0 @@ -From 061843340fbf2493bb615e20e66f60c5d1ef0455 Mon Sep 17 00:00:00 2001 -From: William Pitcock -Date: Tue, 5 Dec 2017 16:04:43 -0500 -Subject: implement the fopencookie extension to stdio - -notes added by maintainer: - -this function is a GNU extension. it was chosen over the similar BSD -function funopen because the latter depends on fpos_t being an -arithmetic type as part of its public API, conflicting with our -definition of fpos_t and with the intent that it be an opaque type. it -was accepted for inclusion because, despite not being widely used, it -is usually very difficult to extricate software using it from the -dependency on it. - -calling pattern for the read and write callbacks is not likely to -match glibc or other implementations, but should work with any -reasonable callbacks. in particular the read function is never called -without at least one byte being needed to satisfy its caller, so that -spurious blocking is not introduced. - -contracts for what callbacks called from inside libc/stdio can do are -always complicated, and at some point still need to be specified -explicitly. at the very least, the callbacks must return or block -indefinitely (they cannot perform nonlocal exits) and they should not -make calls to stdio using their own FILE as an argument. ---- - include/stdio.h | 14 +++++ - src/stdio/fopencookie.c | 138 ++++++++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 152 insertions(+) - create mode 100644 src/stdio/fopencookie.c - -diff --git a/include/stdio.h b/include/stdio.h -index 884d2e6..2932c76 100644 ---- a/include/stdio.h -+++ b/include/stdio.h -@@ -182,6 +182,20 @@ int vasprintf(char **, const char *, __isoc_va_list); - #ifdef _GNU_SOURCE - char *fgets_unlocked(char *, int, FILE *); - int fputs_unlocked(const char *, FILE *); -+ -+typedef ssize_t (cookie_read_function_t)(void *, char *, size_t); -+typedef ssize_t (cookie_write_function_t)(void *, const char *, size_t); -+typedef int (cookie_seek_function_t)(void *, off_t *, int); -+typedef int (cookie_close_function_t)(void *); -+ -+typedef struct { -+ cookie_read_function_t *read; -+ cookie_write_function_t *write; -+ cookie_seek_function_t *seek; -+ cookie_close_function_t *close; -+} cookie_io_functions_t; -+ -+FILE *fopencookie(void *, const char *, cookie_io_functions_t); - #endif - - #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) -diff --git a/src/stdio/fopencookie.c b/src/stdio/fopencookie.c -new file mode 100644 -index 0000000..2f46dd5 ---- /dev/null -+++ b/src/stdio/fopencookie.c -@@ -0,0 +1,138 @@ -+#define _GNU_SOURCE -+#include "stdio_impl.h" -+#include -+#include -+#include -+#include -+#include -+ -+struct fcookie { -+ void *cookie; -+ cookie_io_functions_t iofuncs; -+}; -+ -+struct cookie_FILE { -+ FILE f; -+ struct fcookie fc; -+ unsigned char buf[UNGET+BUFSIZ]; -+}; -+ -+static size_t cookieread(FILE *f, unsigned char *buf, size_t len) -+{ -+ struct fcookie *fc = f->cookie; -+ ssize_t ret = -1; -+ size_t remain = len, readlen = 0; -+ size_t len2 = len - !!f->buf_size; -+ -+ if (!fc->iofuncs.read) goto bail; -+ -+ if (len2) { -+ ret = fc->iofuncs.read(fc->cookie, (char *) buf, len2); -+ if (ret <= 0) goto bail; -+ -+ readlen += ret; -+ remain -= ret; -+ } -+ -+ if (!f->buf_size || remain > !!f->buf_size) return readlen; -+ -+ f->rpos = f->buf; -+ ret = fc->iofuncs.read(fc->cookie, (char *) f->rpos, f->buf_size); -+ if (ret <= 0) goto bail; -+ f->rend = f->rpos + ret; -+ -+ buf[readlen++] = *f->rpos++; -+ -+ return readlen; -+ -+bail: -+ f->flags |= ret == 0 ? F_EOF : F_ERR; -+ f->rpos = f->rend = f->buf; -+ return readlen; -+} -+ -+static size_t cookiewrite(FILE *f, const unsigned char *buf, size_t len) -+{ -+ struct fcookie *fc = f->cookie; -+ ssize_t ret; -+ size_t len2 = f->wpos - f->wbase; -+ if (!fc->iofuncs.write) return len; -+ if (len2) { -+ f->wpos = f->wbase; -+ if (cookiewrite(f, f->wpos, len2) < len2) return 0; -+ } -+ ret = fc->iofuncs.write(fc->cookie, (const char *) buf, len); -+ if (ret < 0) { -+ f->wpos = f->wbase = f->wend = 0; -+ f->flags |= F_ERR; -+ return 0; -+ } -+ return ret; -+} -+ -+static off_t cookieseek(FILE *f, off_t off, int whence) -+{ -+ struct fcookie *fc = f->cookie; -+ int res; -+ if (whence > 2U) { -+ errno = EINVAL; -+ return -1; -+ } -+ if (!fc->iofuncs.seek) { -+ errno = ENOTSUP; -+ return -1; -+ } -+ res = fc->iofuncs.seek(fc->cookie, &off, whence); -+ if (res < 0) -+ return res; -+ return off; -+} -+ -+static int cookieclose(FILE *f) -+{ -+ struct fcookie *fc = f->cookie; -+ if (fc->iofuncs.close) return fc->iofuncs.close(fc->cookie); -+ return 0; -+} -+ -+FILE *fopencookie(void *cookie, const char *mode, cookie_io_functions_t iofuncs) -+{ -+ struct cookie_FILE *f; -+ -+ /* Check for valid initial mode character */ -+ if (!strchr("rwa", *mode)) { -+ errno = EINVAL; -+ return 0; -+ } -+ -+ /* Allocate FILE+fcookie+buffer or fail */ -+ if (!(f=malloc(sizeof *f))) return 0; -+ -+ /* Zero-fill only the struct, not the buffer */ -+ memset(&f->f, 0, sizeof f->f); -+ -+ /* Impose mode restrictions */ -+ if (!strchr(mode, '+')) f->f.flags = (*mode == 'r') ? F_NOWR : F_NORD; -+ -+ /* Set up our fcookie */ -+ f->fc.cookie = cookie; -+ f->fc.iofuncs.read = iofuncs.read; -+ f->fc.iofuncs.write = iofuncs.write; -+ f->fc.iofuncs.seek = iofuncs.seek; -+ f->fc.iofuncs.close = iofuncs.close; -+ -+ f->f.fd = -1; -+ f->f.cookie = &f->fc; -+ f->f.buf = f->buf + UNGET; -+ f->f.buf_size = BUFSIZ; -+ f->f.lbf = EOF; -+ -+ /* Initialize op ptrs. No problem if some are unneeded. */ -+ f->f.read = cookieread; -+ f->f.write = cookiewrite; -+ f->f.seek = cookieseek; -+ f->f.close = cookieclose; -+ -+ /* Add new FILE to open file list */ -+ return __ofl_add(&f->f); -+} --- -cgit v0.11.2 - diff --git a/patches/musl/musl-0002-fopencookie+abi-compat.patch b/patches/musl/musl-0002-fopencookie+abi-compat.patch deleted file mode 100644 index 772994d..0000000 --- a/patches/musl/musl-0002-fopencookie+abi-compat.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 2488d31f5a946e63e40058baf29fd2991343ea6f Mon Sep 17 00:00:00 2001 -From: Rich Felker -Date: Wed, 6 Dec 2017 13:14:22 -0500 -Subject: adjust fopencookie structure tag for ABI-compat - -stdio types use the struct tag names from glibc libio to match C++ -ABI. ---- - include/stdio.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/include/stdio.h b/include/stdio.h -index 2932c76..7c4f9ee 100644 ---- a/include/stdio.h -+++ b/include/stdio.h -@@ -188,7 +188,7 @@ typedef ssize_t (cookie_write_function_t)(void *, const char *, size_t); - typedef int (cookie_seek_function_t)(void *, off_t *, int); - typedef int (cookie_close_function_t)(void *); - --typedef struct { -+typedef struct _IO_cookie_io_functions_t { - cookie_read_function_t *read; - cookie_write_function_t *write; - cookie_seek_function_t *seek; --- -cgit v0.11.2 - diff --git a/patches/musl/musl-0003-remove-inclusion-guard-hacks-for-sys-kd.h.patch b/patches/musl/musl-0003-remove-inclusion-guard-hacks-for-sys-kd.h.patch deleted file mode 100644 index c869b3b..0000000 --- a/patches/musl/musl-0003-remove-inclusion-guard-hacks-for-sys-kd.h.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 2fab90a71acd3698954c08b9062db67188443dd7 Mon Sep 17 00:00:00 2001 -From: midipix -Date: Sat, 14 Jul 2018 22:49:06 -0400 -Subject: [PATCH 1/2] remove inclusion guard hacks for sys/kd.h -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -maintainer's note: at some point, probably long before linux separated -the uapi headers, it was the case, or at least I believed it was the -case, that linux/types.h was unsafe to include from userspace. thus, -the inclusion guard macro _LINUX_TYPES_H was defined in sys/kd.h to -prevent linux/kd.h from including linux/types.h (which it spuriously -includes but does not use). as far as I can tell, whatever problem -this was meant to solve does not seem to have been present for a long -time, and the hack was not done correctly anyway, so removing it is -the right thing to do. - -Signed-off-by: Lucio Andrés Illanes Albornoz ---- - include/sys/kd.h | 7 ------- - 1 file changed, 7 deletions(-) - -diff --git a/include/sys/kd.h b/include/sys/kd.h -index 793fd59f..33b873f4 100644 ---- a/include/sys/kd.h -+++ b/include/sys/kd.h -@@ -1,8 +1 @@ --#ifndef _SYS_KD_H --#define _SYS_KD_H -- --#define _LINUX_TYPES_H - #include --#undef _LINUX_TYPES_H -- --#endif --- -2.17.0 - diff --git a/patches/musl/musl-0004-move-inclusion-of-linux-headers-for-kd.h-soundcard.h.patch b/patches/musl/musl-0004-move-inclusion-of-linux-headers-for-kd.h-soundcard.h.patch deleted file mode 100644 index 4a0c2a0..0000000 --- a/patches/musl/musl-0004-move-inclusion-of-linux-headers-for-kd.h-soundcard.h.patch +++ /dev/null @@ -1,77 +0,0 @@ -From f2c6dbe2442027ed8fe0fa869918e41f495534d8 Mon Sep 17 00:00:00 2001 -From: midipix -Date: Sat, 14 Jul 2018 22:51:22 -0400 -Subject: [PATCH 2/2] move inclusion of linux headers for kd.h, soundcard.h, - vt.h to bits -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -maintainer's note: while musl does not use the linux kernel headers, -it does provide these three sys/* headers which do nothing but include -the corresponding linux/* headers, since the sys/* versions are the -ones documented for application use (and they arguably provide -interfaces that are not linux-specific but common to other unices). -these headers should probably not be provided by libc (rather by a -separate package), but as long as they are, use the bits header -framework as an aid to out-of-tree ports of musl for non-linux systems -that want to implement them in some other way. - -Signed-off-by: Lucio Andrés Illanes Albornoz ---- - arch/generic/bits/kd.h | 1 + - arch/generic/bits/soundcard.h | 1 + - arch/generic/bits/vt.h | 1 + - include/sys/kd.h | 2 +- - include/sys/soundcard.h | 2 +- - include/sys/vt.h | 2 +- - 6 files changed, 6 insertions(+), 3 deletions(-) - create mode 100644 arch/generic/bits/kd.h - create mode 100644 arch/generic/bits/soundcard.h - create mode 100644 arch/generic/bits/vt.h - -diff --git a/arch/generic/bits/kd.h b/arch/generic/bits/kd.h -new file mode 100644 -index 00000000..33b873f4 ---- /dev/null -+++ b/arch/generic/bits/kd.h -@@ -0,0 +1 @@ -+#include -diff --git a/arch/generic/bits/soundcard.h b/arch/generic/bits/soundcard.h -new file mode 100644 -index 00000000..fade986f ---- /dev/null -+++ b/arch/generic/bits/soundcard.h -@@ -0,0 +1 @@ -+#include -diff --git a/arch/generic/bits/vt.h b/arch/generic/bits/vt.h -new file mode 100644 -index 00000000..834abfbc ---- /dev/null -+++ b/arch/generic/bits/vt.h -@@ -0,0 +1 @@ -+#include -diff --git a/include/sys/kd.h b/include/sys/kd.h -index 33b873f4..42122b9c 100644 ---- a/include/sys/kd.h -+++ b/include/sys/kd.h -@@ -1 +1 @@ --#include -+#include -diff --git a/include/sys/soundcard.h b/include/sys/soundcard.h -index fade986f..5ca77646 100644 ---- a/include/sys/soundcard.h -+++ b/include/sys/soundcard.h -@@ -1 +1 @@ --#include -+#include -diff --git a/include/sys/vt.h b/include/sys/vt.h -index 834abfbc..5000de49 100644 ---- a/include/sys/vt.h -+++ b/include/sys/vt.h -@@ -1 +1 @@ --#include -+#include --- -2.17.0 -