void-packages/srcpkgs/nocache/patches/musl.patch

142 lines
4.5 KiB
Diff

diff --git nocache.c nocache.c
index 6f8c60d..fa4abff 100644
--- a/nocache.c
+++ b/nocache.c
@@ -25,31 +25,47 @@ static void store_pageinfo(int fd);
static void free_unclaimed_pages(int fd);
int open(const char *pathname, int flags, mode_t mode);
+#if defined(__GLIBC__)
int open64(const char *pathname, int flags, mode_t mode);
+#endif
int creat(const char *pathname, int flags, mode_t mode);
+#if defined(__GLIBC__)
int creat64(const char *pathname, int flags, mode_t mode);
+#endif
int openat(int dirfd, const char *pathname, int flags, mode_t mode);
+#if defined(__GLIBC__)
int openat64(int dirfd, const char *pathname, int flags, mode_t mode);
+#endif
int __openat_2(int dirfd, const char *pathname, int flags, mode_t mode)
__attribute__ ((alias ("openat")));
int dup(int oldfd);
int dup2(int oldfd, int newfd);
int close(int fd);
FILE *fopen(const char *path, const char *mode);
+#if defined(__GLIBC__)
FILE *fopen64(const char *path, const char *mode);
+#endif
int fclose(FILE *fp);
int (*_original_open)(const char *pathname, int flags, mode_t mode);
+#if defined(__GLIBC__)
int (*_original_open64)(const char *pathname, int flags, mode_t mode);
+#endif
int (*_original_creat)(const char *pathname, int flags, mode_t mode);
+#if defined(__GLIBC__)
int (*_original_creat64)(const char *pathname, int flags, mode_t mode);
+#endif
int (*_original_openat)(int dirfd, const char *pathname, int flags, mode_t mode);
+#if defined(__GLIBC__)
int (*_original_openat64)(int dirfd, const char *pathname, int flags, mode_t mode);
+#endif
int (*_original_dup)(int fd);
int (*_original_dup2)(int newfd, int oldfd);
int (*_original_close)(int fd);
FILE *(*_original_fopen)(const char *path, const char *mode);
+#if defined(__GLIBC__)
FILE *(*_original_fopen64)(const char *path, const char *mode);
+#endif
int (*_original_fclose)(FILE *fp);
@@ -82,16 +98,24 @@ static void init(void)
assert(fds != NULL);
_original_open = (int (*)(const char *, int, mode_t)) dlsym(RTLD_NEXT, "open");
+#if defined(__GLIBC__)
_original_open64 = (int (*)(const char *, int, mode_t)) dlsym(RTLD_NEXT, "open64");
+#endif
_original_creat = (int (*)(const char *, int, mode_t)) dlsym(RTLD_NEXT, "creat");
+#if defined(__GLIBC__)
_original_creat64 = (int (*)(const char *, int, mode_t)) dlsym(RTLD_NEXT, "creat64");
+#endif
_original_openat = (int (*)(int, const char *, int, mode_t)) dlsym(RTLD_NEXT, "openat");
+#if defined(__GLIBC__)
_original_openat64 = (int (*)(int, const char *, int, mode_t)) dlsym(RTLD_NEXT, "openat64");
+#endif
_original_dup = (int (*)(int)) dlsym(RTLD_NEXT, "dup");
_original_dup2 = (int (*)(int, int)) dlsym(RTLD_NEXT, "dup2");
_original_close = (int (*)(int)) dlsym(RTLD_NEXT, "close");
_original_fopen = (FILE *(*)(const char *, const char *)) dlsym(RTLD_NEXT, "fopen");
+#if defined(__GLIBC__)
_original_fopen64 = (FILE *(*)(const char *, const char *)) dlsym(RTLD_NEXT, "fopen64");
+#endif
_original_fclose = (int (*)(FILE *)) dlsym(RTLD_NEXT, "fclose");
if ((error = dlerror()) != NULL) {
@@ -165,6 +189,7 @@ int open(const char *pathname, int flags, mode_t mode)
return fd;
}
+#if defined(__GLIBC__)
int open64(const char *pathname, int flags, mode_t mode)
{
int fd;
@@ -177,6 +202,7 @@ int open64(const char *pathname, int flags, mode_t mode)
store_pageinfo(fd);
return fd;
}
+#endif
int creat(const char *pathname, int flags, mode_t mode)
{
@@ -191,6 +217,7 @@ int creat(const char *pathname, int flags, mode_t mode)
return fd;
}
+#if defined(__GLIBC__)
int creat64(const char *pathname, int flags, mode_t mode)
{
int fd;
@@ -203,6 +230,7 @@ int creat64(const char *pathname, int flags, mode_t mode)
store_pageinfo(fd);
return fd;
}
+#endif
int openat(int dirfd, const char *pathname, int flags, mode_t mode)
{
@@ -217,6 +245,7 @@ int openat(int dirfd, const char *pathname, int flags, mode_t mode)
return fd;
}
+#if defined(__GLIBC__)
int openat64(int dirfd, const char *pathname, int flags, mode_t mode)
{
int fd;
@@ -229,6 +258,7 @@ int openat64(int dirfd, const char *pathname, int flags, mode_t mode)
store_pageinfo(fd);
return fd;
}
+#endif
int dup(int oldfd)
{
@@ -288,6 +318,7 @@ FILE *fopen(const char *path, const char *mode)
return fp;
}
+#if defined(__GLIBC__)
FILE *fopen64(const char *path, const char *mode)
{
int fd;
@@ -304,6 +335,7 @@ FILE *fopen64(const char *path, const char *mode)
return fp;
}
+#endif
int fclose(FILE *fp)
{