libbsd: Branch 'master' - 7 commits
Guillem Jover
guillem at kemper.freedesktop.org
Mon Jun 5 03:59:35 UTC 2017
configure.ac | 11 +++++++----
include/bsd/nlist.h | 5 +++++
include/bsd/stdio.h | 10 +++++++---
include/bsd/sys/cdefs.h | 33 +++++++++++++++++++++++++++++++++
src/funopen.c | 10 ++++++++--
src/libbsd.map | 3 +++
src/local-elf.h | 18 ++++++++++++++++++
7 files changed, 81 insertions(+), 9 deletions(-)
New commits:
commit e4475738fefe3b0c7388b293e8b0828560c6b830
Author: Guillem Jover <guillem at hadrons.org>
Date: Fri Jan 20 02:20:12 2017 +0100
Try <linux/a.out.h> if <a.out.h> is not present
At least musl ships the former but not the latter.
diff --git a/include/bsd/nlist.h b/include/bsd/nlist.h
index 2730237..8531f7a 100644
--- a/include/bsd/nlist.h
+++ b/include/bsd/nlist.h
@@ -28,7 +28,12 @@
#define LIBBSD_NLIST_H
#include <sys/cdefs.h>
+
+#if __has_include(<a.out.h>)
#include <a.out.h>
+#elif __has_include(<linux/a.out.h>)
+#include <linux/a.out.h>
+#endif
__BEGIN_DECLS
extern int nlist(const char *filename, struct nlist *list);
commit d6c35f618c4f3ca20a43a5a28e08cde3540e6b7c
Author: Guillem Jover <guillem at hadrons.org>
Date: Tue Jan 10 04:33:15 2017 +0100
Do not provide funopen() on musl
Fixes: https://bugs.debian.org/818246
diff --git a/configure.ac b/configure.ac
index 5cbc2fa..e4d190d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -51,7 +51,11 @@ AS_CASE([$host_os],
AC_SEARCH_LIBS([clock_gettime], [rt], [CLOCK_GETTIME_LIBS="-lrt"])
AC_SUBST([CLOCK_GETTIME_LIBS])
LIBS="$saved_LIBS"
- ]
+ ],
+ [*-musl], [
+ # Upstream refuses to define this, we will do it ourselves then.
+ AC_DEFINE([__MUSL__], [1], [Define to 1 if we are building for musl])
+ ],
)
# Checks for header files.
diff --git a/src/funopen.c b/src/funopen.c
index 7d6ae31..1e05c7e 100644
--- a/src/funopen.c
+++ b/src/funopen.c
@@ -1,5 +1,5 @@
/*
- * Copyright © 2011, 2013 Guillem Jover
+ * Copyright © 2011, 2013, 2017 Guillem Jover
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -137,6 +137,12 @@ funopen(const void *cookie,
return fopencookie(cookiewrap, mode, funcswrap);
}
+#elif defined(__MUSL__)
+/*
+ * This is unimplementable on musl based systems, and upstream has stated
+ * they will not add the needed support to implement it. Just ignore this
+ * interface there, as it has never been provided anyway.
+ */
#else
-#error "Function funopen() needs to be ported."
+#error "Function funopen() needs to be ported or disabled."
#endif
diff --git a/src/libbsd.map b/src/libbsd.map
index 2b9a3db..304c593 100644
--- a/src/libbsd.map
+++ b/src/libbsd.map
@@ -114,6 +114,9 @@ LIBBSD_0.6 {
LIBBSD_0.7 {
getbsize;
+ /* This symbol might not be present on some specific systems, such
+ * as musl based ones. It might need to be removed on SOVERSION bump,
+ * as it cannot be portabily implemented everywhere. */
funopen;
reallocarray;
commit db7470b048a14bdc69a34fbd192ec626e1786411
Author: Guillem Jover <guillem at hadrons.org>
Date: Tue Jan 10 04:27:25 2017 +0100
Gracefully handle lack of system <sys/cdefs.h>
This is the case on musl.
Fixes: https://bugs.debian.org/810589
diff --git a/include/bsd/sys/cdefs.h b/include/bsd/sys/cdefs.h
index 75d3955..044f221 100644
--- a/include/bsd/sys/cdefs.h
+++ b/include/bsd/sys/cdefs.h
@@ -24,15 +24,40 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifndef __has_include
+#define __has_include 1
+#endif
+#ifndef __has_include_next
+#define __has_include_next 1
+#endif
+
#ifdef LIBBSD_OVERLAY
+/*
+ * Some libc implementations do not have a <sys/cdefs.h>, in particular
+ * musl, try to handle this gracefully.
+ */
+#if __has_include_next(<sys/cdefs.h>)
#include_next <sys/cdefs.h>
+#endif
#else
+#if __has_include(<sys/cdefs.h>)
#include <sys/cdefs.h>
#endif
+#endif
#ifndef LIBBSD_SYS_CDEFS_H
#define LIBBSD_SYS_CDEFS_H
+#ifndef __BEGIN_DECLS
+#ifdef __cplusplus
+#define __BEGIN_DECLS extern "C" {
+#define __END_DECLS }
+#else
+#define __BEGIN_DECLS
+#define __END_DECLS
+#endif
+#endif
+
/*
* Some kFreeBSD headers expect those macros to be set for sanity checks.
*/
commit 368af99f554ca1c7211faf9eedfffcf45e5e76bb
Author: Guillem Jover <guillem at hadrons.org>
Date: Sun Aug 28 17:13:20 2016 +0200
Fix the __progname check to avoid the optimizer discarding the symbol
Because we were assigning to another unused variable, when building the
check with optimizations enabled, which is the default when using gcc
as the compiler, the variable was being discarded. Instead pass it to
printf() so that it cannot do so.
diff --git a/configure.ac b/configure.ac
index 5a432d4..5cbc2fa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -131,9 +131,8 @@ AC_LINK_IFELSE(
AC_MSG_CHECKING([for __progname])
AC_LINK_IFELSE(
- [AC_LANG_PROGRAM([[]],
- [[extern char *__progname;
- const char *p = __progname;]])],
+ [AC_LANG_PROGRAM([[extern char *__progname;]],
+ [[printf("%s", __progname);]])],
[AC_DEFINE([HAVE___PROGNAME], [1], [Define to 1 if you have __progname])
AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])])
commit 337e62027503aa6e09ca7adbe94cd7077f3241c3
Author: Guillem Jover <guillem at hadrons.org>
Date: Tue Jan 10 04:24:35 2017 +0100
Support GCC deprecated attribute for GCC older than 4.5
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=99190
Based-on-patch-by: Eric Smith <brouhaha at fedoraproject.org>
diff --git a/include/bsd/stdio.h b/include/bsd/stdio.h
index 7697425..4b69983 100644
--- a/include/bsd/stdio.h
+++ b/include/bsd/stdio.h
@@ -38,7 +38,11 @@
#ifndef LIBBSD_STDIO_H
#define LIBBSD_STDIO_H
+#ifdef LIBBSD_OVERLAY
#include <sys/cdefs.h>
+#else
+#include <bsd/sys/cdefs.h>
+#endif
#include <sys/types.h>
__BEGIN_DECLS
@@ -47,9 +51,9 @@ const char *fmtcheck(const char *, const char *);
/* XXX: The function requires cooperation from the system libc to store the
* line buffer in the FILE struct itself. */
char *fgetln(FILE *fp, size_t *lenp)
- __attribute__((deprecated("This functions cannot be safely ported, "
- "use getline(3) instead, as it is supported "
- "by GNU and POSIX.1-2008.")));
+ LIBBSD_DEPRECATED("This functions cannot be safely ported, "
+ "use getline(3) instead, as it is supported "
+ "by GNU and POSIX.1-2008.");
/*
* Note: We diverge from the FreeBSD, OpenBSD and DragonFlyBSD declarations,
diff --git a/include/bsd/sys/cdefs.h b/include/bsd/sys/cdefs.h
index 4b1063a..75d3955 100644
--- a/include/bsd/sys/cdefs.h
+++ b/include/bsd/sys/cdefs.h
@@ -49,6 +49,14 @@
#define LIBBSD_GCC_VERSION 0
#endif
+#if LIBBSD_GCC_VERSION >= 0x0405
+#define LIBBSD_DEPRECATED(x) __attribute__((deprecated(x)))
+#elif LIBBSD_GCC_VERSION >= 0x0301
+#define LIBBSD_DEPRECATED(x) __attribute__((deprecated))
+#else
+#define LIBBSD_DEPRECATED(x)
+#endif
+
#ifndef __dead2
# if LIBBSD_GCC_VERSION >= 0x0207
# define __dead2 __attribute__((__noreturn__))
commit 088f147ec8e55b760cf631a09d5defb332e7e9c7
Author: Guillem Jover <guillem at hadrons.org>
Date: Wed Feb 8 01:49:48 2017 +0100
Add support for RISC-V
diff --git a/src/local-elf.h b/src/local-elf.h
index 03ebf62..84a6540 100644
--- a/src/local-elf.h
+++ b/src/local-elf.h
@@ -152,6 +152,18 @@
#define ELF_TARG_CLASS ELFCLASS64
#define ELF_TARG_DATA ELFDATA2MSB
+#elif defined(__riscv)
+
+#define ELF_TARG_MACH EM_RISCV
+#if __riscv_xlen == 32
+#define ELF_TARG_CLASS ELFCLASS32
+#elif __riscv_xlen == 64
+#define ELF_TARG_CLASS ELFCLASS64
+#else
+#error Unsupported ELF class
+#endif
+#define ELF_TARG_DATA ELFDATA2LSB
+
#elif defined(__sparc__)
#if defined(__arch64__)
commit b2b1020d8e164d2770bf1307edca85f2d2420deb
Author: Helmut Grohne <helmut at subdivi.de>
Date: Tue Jan 10 03:47:52 2017 +0100
Add support for TileGX
Fixes: https://bugs.debian.org/847560
Signed-off-by: Guillem Jover <guillem at hadrons.org>
diff --git a/src/local-elf.h b/src/local-elf.h
index 28d4007..03ebf62 100644
--- a/src/local-elf.h
+++ b/src/local-elf.h
@@ -185,6 +185,12 @@
#endif
#define ELF_TARG_DATA ELFDATA2MSB
+#elif defined(__tilegx__)
+
+#define ELF_TARG_MACH EM_TILEGX
+#define ELF_TARG_CLASS ELFCLASS64
+#define ELF_TARG_DATA ELFDATA2LSB
+
#elif defined(__or1k__)
#define ELF_TARG_MACH EM_OPENRISC
More information about the libbsd
mailing list