roken: ROKEN_xxx_ATTRIBUTE macros
Add ROKEN_xxx_ATTRIBUTE macros, derived from krb5-types.h, to aid compiling with compilers that don't have __attribute__ defined.
This commit is contained in:

committed by
Jeffrey Altman

parent
914976aca6
commit
04b3c124ca
@@ -509,7 +509,7 @@ free_environment(char **);
|
||||
#define warnerr rk_warnerr
|
||||
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
|
||||
rk_warnerr(int doerrno, const char *fmt, va_list ap)
|
||||
__attribute__ ((__format__ (__printf__, 2, 0)));
|
||||
ROKEN_PRINTF_ATTRIBUTE((__printf__, 2, 0));
|
||||
|
||||
ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL
|
||||
rk_realloc(void *, size_t);
|
||||
@@ -521,7 +521,7 @@ rk_strpoolcollect(struct rk_strpool *);
|
||||
|
||||
ROKEN_LIB_FUNCTION struct rk_strpool * ROKEN_LIB_CALL
|
||||
rk_strpoolprintf(struct rk_strpool *, const char *, ...)
|
||||
__attribute__ ((__format__ (__printf__, 2, 3)));
|
||||
ROKEN_PRINTF_ATTRIBUTE((__printf__, 2, 3));
|
||||
|
||||
ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
|
||||
rk_strpoolfree(struct rk_strpool *);
|
||||
|
@@ -12,6 +12,14 @@ BEGIN {
|
||||
print "#ifdef HAVE_ERRNO_H"
|
||||
print "#include <errno.h>"
|
||||
print "#endif"
|
||||
print "#if !defined(__has_extension)"
|
||||
print "#define __has_extension(x) 0"
|
||||
print "#endif"
|
||||
print "#ifndef ROKEN_REQUIRE_GNUC"
|
||||
print "#define ROKEN_REQUIRE_GNUC(m,n,p) \\"
|
||||
print " (((__GNUC__ * 10000) + (__GNUC_MINOR__ * 100) + __GNUC_PATCHLEVEL__) >= \\"
|
||||
print " (((m) * 10000) + ((n) * 100) + (p)))"
|
||||
print "#endif"
|
||||
print ""
|
||||
print "int main(int argc, char **argv)"
|
||||
print "{"
|
||||
|
@@ -96,6 +96,58 @@
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#if !defined(__has_extension)
|
||||
#define __has_extension(x) 0
|
||||
#endif
|
||||
|
||||
#ifndef ROKEN_REQUIRE_GNUC
|
||||
#define ROKEN_REQUIRE_GNUC(m,n,p) \
|
||||
(((__GNUC__ * 10000) + (__GNUC_MINOR__ * 100) + __GNUC_PATCHLEVEL__) >= \
|
||||
(((m) * 10000) + ((n) * 100) + (p)))
|
||||
#endif
|
||||
|
||||
#ifndef ROKEN_DEPRECATED
|
||||
#if __has_extension(deprecated) || ROKEN_REQUIRE_GNUC(3,1,0)
|
||||
#define ROKEN_DEPRECATED __attribute__ ((__deprecated__))
|
||||
#elif defined(_MSC_VER) && (_MSC_VER>1200)
|
||||
#define ROKEN_DEPRECATED __declspec(deprecated)
|
||||
#else
|
||||
#define ROKEN_DEPRECATED
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef ROKEN_PRINTF_ATTRIBUTE
|
||||
#if __has_extension(format) || ROKEN_REQUIRE_GNUC(3,1,0)
|
||||
#define ROKEN_PRINTF_ATTRIBUTE(x) __attribute__ ((__format__ x))
|
||||
#else
|
||||
#define ROKEN_PRINTF_ATTRIBUTE(x)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef ROKEN_NORETURN_ATTRIBUTE
|
||||
#if __has_extension(noreturn) || ROKEN_REQUIRE_GNUC(3,1,0)
|
||||
#define ROKEN_NORETURN_ATTRIBUTE __attribute__ ((__noreturn__))
|
||||
#else
|
||||
#define ROKEN_NORETURN_ATTRIBUTE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef ROKEN_UNUSED_ATTRIBUTE
|
||||
#if __has_extension(unused) || ROKEN_REQUIRE_GNUC(3,1,0)
|
||||
#define ROKEN_UNUSED_ATTRIBUTE __attribute__ ((__unused__))
|
||||
#else
|
||||
#define ROKEN_UNUSED_ATTRIBUTE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef ROKEN_WARN_UNUSED_RESULT_ATTRIBUTE
|
||||
#if __has_extension(warn_unused_result) || ROKEN_REQUIRE_GNUC(3,3,0)
|
||||
#define ROKEN_WARN_UNUSED_RESULT_ATTRIBUTE __attribute__ ((__warn_unused_result__))
|
||||
#else
|
||||
#define ROKEN_WARN_UNUSED_RESULT_ATTRIBUTE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WINSOCK
|
||||
/* Declarations for Microsoft Windows */
|
||||
|
||||
@@ -515,7 +567,7 @@ ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL endusershell(void);
|
||||
#endif
|
||||
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
|
||||
rk_snprintf (char *, size_t, const char *, ...)
|
||||
__attribute__ ((__format__ (__printf__, 3, 4)));
|
||||
ROKEN_PRINTF_ATTRIBUTE((__printf__, 3, 4));
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_VSNPRINTF) || defined(NEED_VSNPRINTF_PROTO)
|
||||
@@ -524,7 +576,7 @@ ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
|
||||
#endif
|
||||
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
|
||||
rk_vsnprintf (char *, size_t, const char *, va_list)
|
||||
__attribute__ ((__format__ (__printf__, 3, 0)));
|
||||
ROKEN_PRINTF_ATTRIBUTE((__printf__, 3, 0));
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_ASPRINTF) || defined(NEED_ASPRINTF_PROTO)
|
||||
@@ -533,7 +585,7 @@ ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
|
||||
#endif
|
||||
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
|
||||
rk_asprintf (char **, const char *, ...)
|
||||
__attribute__ ((__format__ (__printf__, 2, 3)));
|
||||
ROKEN_PRINTF_ATTRIBUTE((__printf__, 2, 3));
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_VASPRINTF) || defined(NEED_VASPRINTF_PROTO)
|
||||
@@ -542,7 +594,7 @@ ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
|
||||
#endif
|
||||
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
|
||||
rk_vasprintf (char **, const char *, va_list)
|
||||
__attribute__ ((__format__ (__printf__, 2, 0)));
|
||||
ROKEN_PRINTF_ATTRIBUTE((__printf__, 2, 0));
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_ASNPRINTF) || defined(NEED_ASNPRINTF_PROTO)
|
||||
@@ -551,7 +603,7 @@ ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
|
||||
#endif
|
||||
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
|
||||
rk_asnprintf (char **, size_t, const char *, ...)
|
||||
__attribute__ ((__format__ (__printf__, 3, 4)));
|
||||
ROKEN_PRINTF_ATTRIBUTE((__printf__, 3, 4));
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_VASNPRINTF) || defined(NEED_VASNPRINTF_PROTO)
|
||||
@@ -560,7 +612,7 @@ ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
|
||||
#endif
|
||||
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
|
||||
vasnprintf (char **, size_t, const char *, va_list)
|
||||
__attribute__ ((__format__ (__printf__, 3, 0)));
|
||||
ROKEN_PRINTF_ATTRIBUTE((__printf__, 3, 0));
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_EVASPRINTF) || defined(NEED_EVASPRINTF_PROTO)
|
||||
|
Reference in New Issue
Block a user