AX_CREATE_ATTRIBUTE_H([OUTPUTHEADER],[PREFIX])
,
Guido U. Draheim <guidod@gmx.de>
all rights reserved. no copying allowed. still experimental.
guidod's Uncategorized (released)
The current version does just emit the GCC __attribute__
defines of the same name. However many modern compilers
allow for similar definitions.
AC_DEFUN([AX_CREATE_ATTRIBUTE_H],[
AS_VAR_PUSHDEF([OUT],[ax_create_attribute_h])dnl
AS_VAR_PUSHDEF([PRE],[ax_create_attribute_h_prefix])dnl
AS_VAR_PUSHDEF([DEF],[ax_create_attribute_h_define])dnl
OUT="m4_ifval([$1],[$1],[attribute.h])"
PRE="m4_ifval([$2],[$2],[IS])"
DEF=`echo $OUT | $as_tr_cpp`
AC_CONFIG_COMMANDS($OUT,[
AS_VAR_PUSHDEF([OUT],[ax_create_attribute_h])dnl
AS_VAR_PUSHDEF([PRE],[ax_create_attribute_h_prefix])dnl
AS_VAR_PUSHDEF([DEF],[ax_create_attribute_h_define])dnl
AC_MSG_NOTICE([creating: $OUT: $PRE attribute defines])
{ cat <<!
#ifndef ___INCLUDED
#define ___INCLUDED
#ifdef __GNUC__
#define _IS_ATLEAST_GCC(__M,__N) \\
(__GNUC__+0 > __M || (__GNUC__+0 >= __M && __GNUC_MINOR__+0 >= __N))
#else
#define _IS_ATLEAST_GCC(__M,__N) 0
#endif
/** ATLEAST_GCC(2,2) means we do not know the first version it came about */
#if _IS_ATLEAST_GCC(3,2)
#define _IS_DEPRACATED __attribute__((__deprecated__))
#define _IS_DEPRECATED __attribute__((__deprecated__))
#elif _MSC_VER+0 >= 1310
#define _IS_DEPRACATED __declspec(deprecated)
#define _IS_DEPRECATED __declspec(deprecated)
#else
#define _IS_DEPRACATED
#define _IS_DEPRECATED
#endif
#if _IS_ATLEAST_GCC(2,5)
#define _IS_NORETURN __attribute__((__noreturn__))
#elif _MSC_VER+0 >= 1310
#define _IS_NORETURN __declspec(noreturn)
#else
#define _IS_NORETURN
#endif
#if _IS_ATLEAST_GCC(2,2)
#define _IS_NOINLINE __attribute__((__noinline__))
#elif _MSC_VER+0 >= 1310
#define _IS_NOINLINE __declspec(noinline)
#else
#define _IS_NOINLINE
#endif
#if _IS_ATLEAST_GCC(2,96)
#define _IS_PURE __attribute__((__pure__))
#else
#define _IS_PURE
#endif
#if _IS_ATLEAST_GCC(2,5)
#define _IS_CONST __attribute__((__const__))
#else
#define _IS_CONST
#endif
#if _IS_ATLEAST_GCC(3,2)
#define _IS_NOTHROW __attribute__((__nothrow__))
#elif _MSC_VER+0 >= 1200
#define _IS_NOTHROW __declspec(nothrow)
#else
#define _IS_NOTHROW
#endif
#if _IS_ATLEAST_GCC(2,2)
#define _IS_PRINTF __attribute__((format (__printf__,1,2)))
#define _IS_FPRINTF __attribute__((format (__printf__,2,3)))
#define _IS_SPRINTF __attribute__((format (__printf__,2,3)))
#define _IS_SNPRINTF __attribute__((format (__printf__,3,4)))
#else
#define _IS_PRINTF
#define _IS_FPRINTF
#define _IS_SPRINTF
#define _IS_SNPRINTF
#endif
#if _IS_ATLEAST_GCC(2,2)
#define _IS_NO_INSTRUMENT_FUNCTION __attribute__((__no_instrument_function__))
#else
#define _IS_NO_INSTRUMENT_FUNCTION
#endif
#if _IS_ATLEAST_GCC(2,2)
#define _IS_UNUSED __attribute__((__unused__))
#else
#define _IS_UNUSED
#endif
#if _IS_ATLEAST_GCC(2,2)
#define _IS_USED __attribute__((__used__))
#else
#define _IS_USED
#endif
#if _IS_ATLEAST_GCC(3,4)
#define _IS_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
#else
#define _IS_WARN_UNUSED_RESULT
#endif
#if _IS_ATLEAST_GCC(2,96)
#define _IS_MALLOC __attribute__((__malloc__))
#define _IS_RESTRICT __attribute__((__malloc__))
#elif _MSC_VER+0 >= 1400
#define _IS_MALLOC __declspec(restrict)
#define _IS_RESTRICT __declspec(restrict)
#else
#define _IS_MALLOC
#define _IS_RESTRICT
#endif
#if _IS_ATLEAST_GCC(2,2)
#define _IS_SIGNAL __attribute__((__signal__))
#else
#define _IS_SIGNAL
#endif
#if _IS_ATLEAST_GCC(2,2)
#define _IS_WEAK __attribute__((__weak__))
#else
#define _IS_WEAK
#endif
#if _IS_ATLEAST_GCC(2,2)
#define _IS_DLLEXPORT __attribute__((__dllexport__))
#elif _MSC_VER+0 >= 1100
#define _IS_DLLEXPORT __declspec(dllexport)
#else
#define _IS_DLLEXPORT
#endif
#if _IS_ATLEAST_GCC(2,2)
#define _IS_DLLIMPORT __attribute__((__dllimport__))
#elif _MSC_VER+0 >= 1100
#define _IS_DLLIMPORT __declspec(dllimport)
#else
#define _IS_DLLIMPORT
#endif
#if _IS_ATLEAST_GCC(4,1)
#define _IS_EXTERNAL __attribute__((__externally_visible__))
#else
#define _IS_EXTERNAL
#endif
#if _IS_ATLEAST_GCC(4,1)
#define _IS_EXTERNAL_LOCAL __attribute__((__protected__))
#else
#define _IS_EXTERNAL
#endif
#if _IS_ATLEAST_GCC(4,1)
#define _IS_INTERNAL __attribute__((__hidden__))
#else
#define _IS_INTERNAL
#endif
#if _IS_ATLEAST_GCC(4,1)
#define _IS_INTERNAL_LOCAL __attribute__((__internal__))
#else
#define _IS_INTERNAL_LOCAL
#endif
#if _IS_ATLEAST_GCC(2,50)
#define _IS_STDCALL __attribute__((__stdcall__))
#elif _MSC_VER+0 >= 800
#define _IS_STDCALL __stdcall
#endif
#if _IS_ATLEAST_GCC(2,50)
#define _IS_CDECL __attribute__((__cdecl__))
#elif _MSC_VER+0 >= 800
#define _IS_CDECL __cdecl
#endif
#if _IS_ATLEAST_GCC(2,50)
#define _IS_FASTCALL __attribute__((__fastcall__))
#elif _MSC_VER+0 >= 1100
#define _IS_FASTCALL __fastcall
#endif
#if _IS_ATLEAST_GCC(3,2)
#define _IS_THISCALL __attribute__((__thiscall__))
#elif _MSC_VER+0 >= 1300
#define _IS_THISCALL __thiscall
#endif
#ifdef __IS_FASTCALL
#define __IS_LOCAL_FASTCALL __IS_FASTCALL
#else
#define __IS_LOCAL_FASTCALL
#endif
#ifdef __IS_THISCALL
#define __IS_LOCAL_THISCALL __IS_THISCALL
#else
#define __IS_LOCAL_THISCALL
#endif
#endif
!
} | sed -e "s|_IS|$PRE|g" -e "s|_INCLUDED|$DEF|" > "$OUT.tmp"
if cmp -s "$OUT.tmp" "$OUT" 2>/dev/null; then
rm -f "$OUT.tmp"
AC_MSG_NOTICE([unchanged $OUT])
else
rm -f "$OUT"
mv "$OUT.tmp" "$OUT"
fi
AS_VAR_POPDEF([OUT])dnl
AS_VAR_POPDEF([PRE])dnl
AS_VAR_POPDEF([DEF])dnl
],
OUT="$OUT"
PRE="$PRE"
DEF="$DEF"
)
AS_VAR_POPDEF([OUT])dnl
AS_VAR_POPDEF([PRE])dnl
AS_VAR_POPDEF([DEF])dnl
])