diff --git a/bin/xbps-alternatives/main.c b/bin/xbps-alternatives/main.c index 6bfbae6c..85364013 100644 --- a/bin/xbps-alternatives/main.c +++ b/bin/xbps-alternatives/main.c @@ -35,6 +35,8 @@ #include +#include "macro.h" + static void __attribute__((noreturn)) usage(bool fail) { diff --git a/bin/xbps-checkvers/main.c b/bin/xbps-checkvers/main.c index ab1f56f3..c63c4df0 100644 --- a/bin/xbps-checkvers/main.c +++ b/bin/xbps-checkvers/main.c @@ -26,21 +26,24 @@ * */ +#include + +#include +#include +#include +#include #include +#include #include -#include #include +#include #include #include -#include -#include -#include -#include -#include -#include #include +#include "macro.h" + #define GOT_PKGNAME_VAR 0x1 #define GOT_VERSION_VAR 0x2 #define GOT_REVISION_VAR 0x4 diff --git a/bin/xbps-create/main.c b/bin/xbps-create/main.c index a9a902ba..37e78a3d 100644 --- a/bin/xbps-create/main.c +++ b/bin/xbps-create/main.c @@ -22,27 +22,30 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include #include -#include -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include #include #include #include -#include -#include -#include #include -#include -#include -#include -#include -#include -#include #include + +#include "macro.h" #include "queue.h" #ifdef __clang__ diff --git a/bin/xbps-fbulk/main.c b/bin/xbps-fbulk/main.c index ea298e39..4bd10b05 100644 --- a/bin/xbps-fbulk/main.c +++ b/bin/xbps-fbulk/main.c @@ -49,22 +49,26 @@ */ #define _DEFAULT_SOURCE #define _BSD_SOURCE -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include + #include #include #include + +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include #include + +#include "macro.h" #include "uthash.h" #ifndef __arraycount diff --git a/bin/xbps-install/main.c b/bin/xbps-install/main.c index 639847a6..c7eb5659 100644 --- a/bin/xbps-install/main.c +++ b/bin/xbps-install/main.c @@ -35,7 +35,9 @@ #include #include + #include "defs.h" +#include "macro.h" static void __attribute__((noreturn)) usage(bool fail) diff --git a/bin/xbps-install/state_cb.c b/bin/xbps-install/state_cb.c index a13ebbaf..28e06fbd 100644 --- a/bin/xbps-install/state_cb.c +++ b/bin/xbps-install/state_cb.c @@ -23,13 +23,16 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include +#include #include #include -#include #include -#include + #include + #include "defs.h" +#include "macro.h" int state_cb(const struct xbps_state_cb_data *xscd, void *cbdata UNUSED) diff --git a/bin/xbps-pkgdb/check.c b/bin/xbps-pkgdb/check.c index f5dcf9da..12b6dfac 100644 --- a/bin/xbps-pkgdb/check.c +++ b/bin/xbps-pkgdb/check.c @@ -24,16 +24,19 @@ */ #include -#include + +#include +#include #include +#include #include #include -#include #include -#include #include + #include "defs.h" +#include "macro.h" static int pkgdb_cb(struct xbps_handle *xhp UNUSED, diff --git a/bin/xbps-pkgdb/check_pkg_unneeded.c b/bin/xbps-pkgdb/check_pkg_unneeded.c index 2b137b3f..90702cb7 100644 --- a/bin/xbps-pkgdb/check_pkg_unneeded.c +++ b/bin/xbps-pkgdb/check_pkg_unneeded.c @@ -23,17 +23,12 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -#include #include -#include -#include -#include -#include -#include #include + #include "defs.h" +#include "macro.h" /* * Checks package integrity of an installed package. diff --git a/bin/xbps-pkgdb/main.c b/bin/xbps-pkgdb/main.c index 48751e98..e0b7091c 100644 --- a/bin/xbps-pkgdb/main.c +++ b/bin/xbps-pkgdb/main.c @@ -23,15 +23,16 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include +#include #include +#include #include #include #include -#include -#include #include + #include "defs.h" static void __attribute__((noreturn)) diff --git a/bin/xbps-query/list.c b/bin/xbps-query/list.c index c22ae00d..e3f3bbbb 100644 --- a/bin/xbps-query/list.c +++ b/bin/xbps-query/list.c @@ -24,14 +24,18 @@ */ #include -#include + +#include +#include #include +#include #include -#include #include -#include + +#include #include "defs.h" +#include "macro.h" struct list_pkgver_cb { unsigned int pkgver_len; diff --git a/bin/xbps-query/main.c b/bin/xbps-query/main.c index 44316c1a..73cc8406 100644 --- a/bin/xbps-query/main.c +++ b/bin/xbps-query/main.c @@ -23,13 +23,14 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include +#include #include #include #include -#include -#include #include + #include "defs.h" static void __attribute__((noreturn)) diff --git a/bin/xbps-query/ownedby.c b/bin/xbps-query/ownedby.c index 356224ec..9edc6be4 100644 --- a/bin/xbps-query/ownedby.c +++ b/bin/xbps-query/ownedby.c @@ -23,18 +23,20 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -#include -#include -#include +#include +#include #include #include -#include -#include #include +#include +#include +#include +#include #include + #include "defs.h" +#include "macro.h" struct ffdata { bool rematch; diff --git a/bin/xbps-query/search.c b/bin/xbps-query/search.c index 6724e3ef..bf1bac27 100644 --- a/bin/xbps-query/search.c +++ b/bin/xbps-query/search.c @@ -29,19 +29,21 @@ #include "compat.h" -#include -#include -#include -#include +#include #include -#include -#include #include -#include +#include +#include #include +#include +#include +#include +#include #include + #include "defs.h" +#include "macro.h" struct search_data { bool regex, repo_mode; diff --git a/bin/xbps-reconfigure/main.c b/bin/xbps-reconfigure/main.c index c1f4e2fc..ea0f2afc 100644 --- a/bin/xbps-reconfigure/main.c +++ b/bin/xbps-reconfigure/main.c @@ -23,16 +23,18 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include +#include #include #include -#include -#include #include +#include #include + #include "defs.h" +#include "macro.h" static void __attribute__((noreturn)) usage(bool fail) diff --git a/bin/xbps-remove/clean-cache.c b/bin/xbps-remove/clean-cache.c index ea9caccb..fb993820 100644 --- a/bin/xbps-remove/clean-cache.c +++ b/bin/xbps-remove/clean-cache.c @@ -23,19 +23,21 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include +#include +#include +#include #include +#include #include #include #include -#include -#include #include -#include -#include #include + #include "defs.h" +#include "macro.h" static int binpkg_parse(char *buf, size_t bufsz, const char *path, const char **pkgver, const char **arch) diff --git a/bin/xbps-remove/main.c b/bin/xbps-remove/main.c index 7c24d614..4b2b8d6b 100644 --- a/bin/xbps-remove/main.c +++ b/bin/xbps-remove/main.c @@ -23,21 +23,23 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include +#include +#include +#include #include +#include #include #include #include -#include -#include -#include -#include -#include #include +#include #include + #include "../xbps-install/defs.h" #include "defs.h" +#include "macro.h" static void __attribute__((noreturn)) usage(bool fail) diff --git a/bin/xbps-rindex/index-clean.c b/bin/xbps-rindex/index-clean.c index 9e33e409..ba369357 100644 --- a/bin/xbps-rindex/index-clean.c +++ b/bin/xbps-rindex/index-clean.c @@ -24,19 +24,22 @@ */ #include -#include -#include -#include -#include -#include + +#include #include +#include +#include #include -#include #include -#include +#include +#include +#include +#include #include + #include "defs.h" +#include "macro.h" static xbps_dictionary_t dest; diff --git a/bin/xbps-rindex/remove-obsoletes.c b/bin/xbps-rindex/remove-obsoletes.c index 913c0429..00ad000c 100644 --- a/bin/xbps-rindex/remove-obsoletes.c +++ b/bin/xbps-rindex/remove-obsoletes.c @@ -24,17 +24,20 @@ */ #include -#include + +#include +#include +#include +#include #include +#include #include #include -#include -#include -#include -#include #include + #include "defs.h" +#include "macro.h" static int remove_pkg(const char *repodir, const char *file) diff --git a/configure b/configure index c7d78bf1..ba8c4457 100755 --- a/configure +++ b/configure @@ -200,7 +200,6 @@ echo "CPPFLAGS += -DXBPS_SYSCONF_PATH=\\\"${ETCDIR}\\\"" >>$CONFIG_MK echo "CPPFLAGS += -DXBPS_SYSDEFCONF_PATH=\\\"${SHAREDIR}/xbps.d\\\"" >>$CONFIG_MK echo "CPPFLAGS += -DXBPS_VERSION=\\\"${VERSION}\\\"" >>$CONFIG_MK echo "CPPFLAGS += -DXBPS_META_PATH=\\\"${DBDIR}\\\"" >>$CONFIG_MK -echo "CPPFLAGS += -DUNUSED=\"__attribute__((__unused__))\"" >>$CONFIG_MK if [ -d .git ] && command -v git >/dev/null; then _gitrev=$(git rev-parse --short HEAD) diff --git a/include/compat.h b/include/compat.h index cedd1be2..80528d59 100644 --- a/include/compat.h +++ b/include/compat.h @@ -1,15 +1,12 @@ #ifndef COMPAT_H #define COMPAT_H -#include #include + #include +#include -#if HAVE_VISIBILITY -#define HIDDEN __attribute__ ((visibility("hidden"))) -#else -#define HIDDEN -#endif +#include "macro.h" #ifndef HAVE_STRLCAT size_t HIDDEN strlcat(char *, const char *, size_t); diff --git a/include/macro.h b/include/macro.h new file mode 100644 index 00000000..1316f758 --- /dev/null +++ b/include/macro.h @@ -0,0 +1,40 @@ +/*- + * Copyright (c) 2012-2020 Juan Romero Pardines. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef XBPS_MACRO_H +#define XBPS_MACRO_H + +#define UNUSED __attribute__((__unused__)) + +#ifndef __UNCONST +# define __UNCONST(a) ((void *)(uintptr_t)(const void *)(a)) +#endif + +#if HAVE_VISIBILITY +# define HIDDEN __attribute__ ((visibility("hidden"))) +#else +# define HIDDEN +#endif + +#endif /*!XBPS_MACRO_H*/ diff --git a/include/xbps_api_impl.h b/include/xbps_api_impl.h index f0560138..02ba9bb0 100644 --- a/include/xbps_api_impl.h +++ b/include/xbps_api_impl.h @@ -29,19 +29,8 @@ #include "xbps.h" -/* - * By default all public functions have default visibility, unless - * visibility has been detected by configure and the HIDDEN definition - * is used. - */ -#if HAVE_VISIBILITY -#define HIDDEN __attribute__ ((visibility("hidden"))) -#else -#define HIDDEN -#endif - #include "queue.h" -#include "compat.h" +#include "macro.h" #define EXTRACT_FLAGS ARCHIVE_EXTRACT_SECURE_NODOTDOT | \ ARCHIVE_EXTRACT_SECURE_SYMLINKS | \ @@ -50,10 +39,6 @@ ARCHIVE_EXTRACT_UNLINK #define FEXTRACT_FLAGS ARCHIVE_EXTRACT_OWNER | EXTRACT_FLAGS -#ifndef __UNCONST -#define __UNCONST(a) ((void *)(uintptr_t)(const void *)(a)) -#endif - #ifndef __arraycount #define __arraycount(x) (sizeof(x) / sizeof(*x)) #endif diff --git a/lib/pkgdb.c b/lib/pkgdb.c index 71f35594..8ba7496f 100644 --- a/lib/pkgdb.c +++ b/lib/pkgdb.c @@ -31,6 +31,7 @@ #include #include +#include "macro.h" #include "xbps_api_impl.h" /** diff --git a/lib/plist_fetch.c b/lib/plist_fetch.c index 8034b420..764fa521 100644 --- a/lib/plist_fetch.c +++ b/lib/plist_fetch.c @@ -31,6 +31,7 @@ #include #include +#include "macro.h" #include "xbps_api_impl.h" #include "fetch.h" diff --git a/lib/rpool.c b/lib/rpool.c index cf509945..600c42f0 100644 --- a/lib/rpool.c +++ b/lib/rpool.c @@ -29,6 +29,7 @@ #include #include +#include "macro.h" #include "xbps_api_impl.h" #include "fetch.h" diff --git a/lib/transaction_check_conflicts.c b/lib/transaction_check_conflicts.c index e850be84..d5055104 100644 --- a/lib/transaction_check_conflicts.c +++ b/lib/transaction_check_conflicts.c @@ -29,6 +29,7 @@ #include #include +#include "macro.h" #include "xbps_api_impl.h" static void diff --git a/lib/util_path.c b/lib/util_path.c index e6e8c97b..2f0e0586 100644 --- a/lib/util_path.c +++ b/lib/util_path.c @@ -58,9 +58,12 @@ #include #include +#include +#include #include #include +/* XXX: this shouldn't need xbps_api_impl.h */ #include "xbps_api_impl.h" ssize_t