nixpkgs/pkgs/development/libraries/libbsd/darwin.patch

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

248 lines
6.5 KiB
Diff
Raw Normal View History

2021-11-02 10:44:23 +00:00
diff --git c/configure.ac w/configure.ac
index 09cb310..30c0e2a 100644
--- c/configure.ac
+++ w/configure.ac
@@ -110,7 +110,7 @@ AS_CASE([$host_os],
AM_CONDITIONAL([OS_WINDOWS], [test "x$is_windows" = "xyes"])
# Checks for header files.
2021-11-02 10:44:23 +00:00
-AC_CHECK_HEADERS([sys/ndir.h sys/dir.h ndir.h dirent.h pwd.h grp.h])
+AC_CHECK_HEADERS([sys/ndir.h sys/dir.h ndir.h dirent.h pwd.h grp.h nlist.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
2021-11-02 10:44:23 +00:00
@@ -210,7 +210,8 @@ AC_LINK_IFELSE(
2018-10-13 23:14:56 +00:00
AC_CHECK_FUNCS([clearenv dirfd fopencookie __fpurge \
getauxval getentropy getexecname getline \
- pstat_getproc sysconf])
+ pstat_getproc sysconf \
+ strlcpy strlcat strnstr strmode fpurge])
AM_CONDITIONAL([HAVE_GETENTROPY], [test "x$ac_cv_func_getentropy" = "xtrue"])
2021-11-02 10:44:23 +00:00
AC_SUBST([LIBBSD_LIBS])
diff --git c/include/bsd/string.h w/include/bsd/string.h
2018-10-13 23:14:56 +00:00
index f987fee..a1e17ed 100644
2021-11-02 10:44:23 +00:00
--- c/include/bsd/string.h
+++ w/include/bsd/string.h
2018-10-13 23:14:56 +00:00
@@ -41,10 +41,21 @@
#include <sys/types.h>
__BEGIN_DECLS
2018-10-13 23:14:56 +00:00
+#if !HAVE_STRLCPY
size_t strlcpy(char *dst, const char *src, size_t siz);
2018-10-13 23:14:56 +00:00
+#endif
+
+#if !HAVE_STRLCAT
size_t strlcat(char *dst, const char *src, size_t siz);
2018-10-13 23:14:56 +00:00
+#endif
+
+#if !HAVE_STRNSTR
char *strnstr(const char *str, const char *find, size_t str_len);
+#endif
2018-10-13 23:14:56 +00:00
+
+#if !HAVE_STRMODE
void strmode(mode_t mode, char *str);
+#endif
2018-10-13 23:14:56 +00:00
#if !defined(__GLIBC__) || \
(defined(__GLIBC__) && (!__GLIBC_PREREQ(2, 25) || !defined(_GNU_SOURCE)))
2021-11-02 10:44:23 +00:00
diff --git c/src/fpurge.c w/src/fpurge.c
2018-10-13 23:14:56 +00:00
index 462535a..a8941db 100644
2021-11-02 10:44:23 +00:00
--- c/src/fpurge.c
+++ w/src/fpurge.c
2018-10-13 23:14:56 +00:00
@@ -26,9 +26,10 @@
#include <errno.h>
#include <stdio.h>
2018-10-13 23:14:56 +00:00
-#include <stdio_ext.h>
2018-10-13 23:14:56 +00:00
#ifdef HAVE___FPURGE
+#include <stdio_ext.h>
+
int
fpurge(FILE *fp)
{
2018-10-13 23:14:56 +00:00
@@ -41,6 +42,36 @@ fpurge(FILE *fp)
return 0;
}
2018-10-13 23:14:56 +00:00
+/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin 1.7 */
+#elif HAVE_FPURGE
+int
+fpurge(FILE *fp)
+{
+ if (fp == NULL || fileno(fp) < 0) {
+ errno = EBADF;
+ return EOF;
+ }
+
+ /* Call the system's fpurge function. */
2018-10-13 23:14:56 +00:00
+#undef fpurge
+#if !HAVE_DECL_FPURGE
+ extern int fpurge (FILE *);
2018-10-13 23:14:56 +00:00
+#endif
+ int result = fpurge (fp);
2018-10-13 23:14:56 +00:00
+/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */
+#if defined(__sferror) || defined(__DragonFly__)
+ if (result == 0)
+ /* Correct the invariants that fpurge broke.
+ <stdio.h> on BSD systems says:
+ "The following always hold: if _flags & __SRD, _w is 0."
+ If this invariant is not fulfilled and the stream is read-write but
+ currently reading, subsequent putc or fputc calls will write directly
+ into the buffer, although they shouldn't be allowed to. */
2018-10-13 23:14:56 +00:00
+ if ((fp->_flags & __SRD) != 0)
+ fp->_w = 0;
+#endif
+ return result;
+}
2018-10-13 23:14:56 +00:00
#else
#error "Function fpurge() needs to be ported."
#endif
2021-11-02 10:44:23 +00:00
diff --git c/src/funopen.c w/src/funopen.c
index 1e6f43a..3a3af6a 100644
--- c/src/funopen.c
+++ w/src/funopen.c
@@ -143,6 +143,7 @@ funopen(const void *cookie,
* they will not add the needed support to implement it. Just ignore this
* interface there, as it has never been provided anyway.
*/
2018-10-13 23:14:56 +00:00
+#elif defined(__MACH__)
#else
#error "Function funopen() needs to be ported or disabled."
#endif
2021-11-02 10:44:23 +00:00
diff --git c/src/local-link.h w/src/local-link.h
index 0d4351a..fc520af 100644
2021-11-02 10:44:23 +00:00
--- c/src/local-link.h
+++ w/src/local-link.h
@@ -27,6 +27,11 @@
2018-10-13 23:14:56 +00:00
#ifndef LIBBSD_LOCAL_LINK_H
#define LIBBSD_LOCAL_LINK_H
+#ifdef __MACH__
+#define libbsd_link_warning(symbol, msg)
+#define libbsd_symver_default(alias, symbol, version)
+#define libbsd_symver_variant(alias, symbol, version)
2018-10-13 23:14:56 +00:00
+#else
#define libbsd_link_warning(symbol, msg) \
static const char libbsd_emit_link_warning_##symbol[] \
__attribute__((__used__,__section__(".gnu.warning." #symbol))) = msg;
@@ -45,3 +50,4 @@
#endif
2018-10-13 23:14:56 +00:00
#endif
+#endif
2021-11-02 10:44:23 +00:00
diff --git c/src/nlist.c w/src/nlist.c
index d22fa19..f41333f 100644
--- c/src/nlist.c
+++ w/src/nlist.c
2018-10-13 23:14:56 +00:00
@@ -41,6 +41,7 @@
#include <unistd.h>
#include <nlist.h>
2018-10-13 23:14:56 +00:00
+#if !HAVE_NLIST_H
#include "local-elf.h"
2021-11-02 10:44:23 +00:00
#ifndef SIZE_T_MAX
@@ -282,3 +283,4 @@ nlist(const char *name, struct nlist *list)
(void)close(fd);
return (n);
}
2018-10-13 23:14:56 +00:00
+#endif
2021-11-02 10:44:23 +00:00
diff --git c/src/readpassphrase.c w/src/readpassphrase.c
2018-10-13 23:14:56 +00:00
index f9f6195..2bc5fb4 100644
2021-11-02 10:44:23 +00:00
--- c/src/readpassphrase.c
+++ w/src/readpassphrase.c
2018-10-13 23:14:56 +00:00
@@ -36,6 +36,14 @@
#define TCSASOFT 0
#endif
+#ifndef _SIGMAX
+#define _SIGMAX 64
+#endif
+
+#ifndef _NSIG
+#define _NSIG (_SIGMAX + 1)
+#endif
+
static volatile sig_atomic_t signo[_NSIG];
static void handler(int);
2021-11-02 10:44:23 +00:00
diff --git c/src/setproctitle.c w/src/setproctitle.c
index ff32aa3..51ed833 100644
2021-11-02 10:44:23 +00:00
--- c/src/setproctitle.c
+++ w/src/setproctitle.c
@@ -33,6 +33,10 @@
#include <string.h>
#include "local-link.h"
2018-10-13 23:14:56 +00:00
+#ifdef __MACH__
+extern char **environ;
+#endif
+
static struct {
/* Original value. */
const char *arg0;
@@ -287,7 +291,8 @@ libbsd_symver_default(setproctitle, setproctitle_impl, LIBBSD_0.5);
2018-10-13 23:14:56 +00:00
* in 0.5, make the implementation available in the old version as an alias
* for code linking against that version, and change the default to use the
* new version, so that new code depends on the implemented version. */
2018-10-13 23:14:56 +00:00
-#ifdef HAVE_TYPEOF
+#ifdef __MACH__
+#elif defined(HAVE_TYPEOF)
extern __typeof__(setproctitle_impl)
setproctitle_stub
__attribute__((__alias__("setproctitle_impl")));
2021-11-02 10:44:23 +00:00
diff --git c/src/strlcat.c w/src/strlcat.c
2018-10-13 23:14:56 +00:00
index 14c53a1..5961c17 100644
2021-11-02 10:44:23 +00:00
--- c/src/strlcat.c
+++ w/src/strlcat.c
2018-10-13 23:14:56 +00:00
@@ -26,6 +26,7 @@
* Returns strlen(src) + MIN(dsize, strlen(initial dst)).
* If retval >= dsize, truncation occurred.
*/
2018-10-13 23:14:56 +00:00
+#if !HAVE_STRLCAT
size_t
strlcat(char *dst, const char *src, size_t dsize)
{
2018-10-13 23:14:56 +00:00
@@ -53,3 +54,4 @@ strlcat(char *dst, const char *src, size_t dsize)
return(dlen + (src - osrc)); /* count does not include NUL */
}
+#endif
2021-11-02 10:44:23 +00:00
diff --git c/src/strlcpy.c w/src/strlcpy.c
2018-10-13 23:14:56 +00:00
index e9a7fe4..5137acb 100644
2021-11-02 10:44:23 +00:00
--- c/src/strlcpy.c
+++ w/src/strlcpy.c
2018-10-13 23:14:56 +00:00
@@ -24,6 +24,7 @@
* chars will be copied. Always NUL terminates (unless dsize == 0).
* Returns strlen(src); if retval >= dsize, truncation occurred.
*/
2018-10-13 23:14:56 +00:00
+#if !HAVE_STRLCPY
size_t
strlcpy(char *dst, const char *src, size_t dsize)
{
2018-10-13 23:14:56 +00:00
@@ -48,3 +49,4 @@ strlcpy(char *dst, const char *src, size_t dsize)
return(src - osrc - 1); /* count does not include NUL */
}
+#endif
2021-11-02 10:44:23 +00:00
diff --git c/src/strmode.c w/src/strmode.c
2018-10-13 23:14:56 +00:00
index e6afde5..da680c9 100644
2021-11-02 10:44:23 +00:00
--- c/src/strmode.c
+++ w/src/strmode.c
2018-10-13 23:14:56 +00:00
@@ -32,6 +32,7 @@
#include <sys/stat.h>
#include <string.h>
2018-10-13 23:14:56 +00:00
+#if !HAVE_STRMODE
void
strmode(mode_t mode, char *p)
2018-10-13 23:14:56 +00:00
{
@@ -141,3 +142,4 @@ strmode(mode_t mode, char *p)
*p++ = ' '; /* will be a '+' if ACL's implemented */
*p = '\0';
}
+#endif