aboutsummaryrefslogtreecommitdiff
path: root/src/shared/helpers.h
diff options
context:
space:
mode:
authorSam James <sam@gentoo.org>2023-04-19 04:29:10 +0100
committerMike Frysinger <vapier@gmail.com>2023-04-19 16:44:51 -0400
commiteb8831a1416ab2ee8123b3add78421c2aa316b39 (patch)
tree3d5759e4a48db6a806174a8c8f1f0af24be11dba /src/shared/helpers.h
parent0b5cb3abcb500d38f7302addb4182b07c1dc2ad7 (diff)
Rename attribute macros to namespaced RC_*
This conflicts with linux-headers which uses __unused for some padding members on ppc64le at least. Closes: https://github.com/OpenRC/openrc/issues/622
Diffstat (limited to 'src/shared/helpers.h')
-rw-r--r--src/shared/helpers.h31
1 files changed, 10 insertions, 21 deletions
diff --git a/src/shared/helpers.h b/src/shared/helpers.h
index 0e9115e4..0303937b 100644
--- a/src/shared/helpers.h
+++ b/src/shared/helpers.h
@@ -30,20 +30,9 @@
#define UNCONST(a) ((void *)(unsigned long)(const void *)(a))
-#ifdef lint
-# define _unused
-#endif
-#if __GNUC__ > 2 || defined(__INTEL_COMPILER)
-# define _dead __attribute__((__noreturn__))
-# define _noreturn __attribute__ ((__noreturn__))
-# define _unused __attribute__((__unused__))
-# define _xasprintf(a, b) __attribute__((__format__(__printf__, a, b)))
-#else
-# define _dead
-# define _noreturn
-# define _unused
-# define _xasprintf(a, b)
-#endif
+#define RC_UNUSED __attribute__((__unused__))
+#define RC_NORETURN __attribute__((__noreturn__))
+#define RC_PRINTF(a, b) __attribute__((__format__(__printf__, a, b)))
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
@@ -65,7 +54,7 @@
} while (/* CONSTCOND */ 0)
#endif
-_unused static void *xmalloc (size_t size)
+RC_UNUSED static void *xmalloc (size_t size)
{
void *value = malloc(size);
@@ -76,7 +65,7 @@ _unused static void *xmalloc (size_t size)
/* NOTREACHED */
}
-_unused static void *xrealloc(void *ptr, size_t size)
+RC_UNUSED static void *xrealloc(void *ptr, size_t size)
{
void *value = realloc(ptr, size);
@@ -87,7 +76,7 @@ _unused static void *xrealloc(void *ptr, size_t size)
/* NOTREACHED */
}
-_unused static char *xstrdup(const char *str)
+RC_UNUSED static char *xstrdup(const char *str)
{
char *value;
@@ -109,7 +98,7 @@ _unused static char *xstrdup(const char *str)
* basename_c never modifies the argument. As such, if there is a trailing
* slash then an empty string is returned.
*/
-_unused static const char *basename_c(const char *path)
+RC_UNUSED static const char *basename_c(const char *path)
{
const char *slash = strrchr(path, '/');
@@ -118,14 +107,14 @@ _unused static const char *basename_c(const char *path)
return (path);
}
-_unused static bool exists(const char *pathname)
+RC_UNUSED static bool exists(const char *pathname)
{
struct stat buf;
return (stat(pathname, &buf) == 0);
}
-_unused static bool existss(const char *pathname)
+RC_UNUSED static bool existss(const char *pathname)
{
struct stat buf;
@@ -140,7 +129,7 @@ _unused static bool existss(const char *pathname)
* functions to handle memory allocation.
* this function was originally written by Mike Frysinger.
*/
-_unused _xasprintf(2,3) static int xasprintf(char **strp, const char *fmt, ...)
+RC_UNUSED RC_PRINTF(2,3) static int xasprintf(char **strp, const char *fmt, ...)
{
va_list ap;
int len;