ax_check_sign.m4 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_check_sign.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_CHECK_SIGN (TYPE, [ACTION-IF-SIGNED], [ACTION-IF-UNSIGNED], [INCLUDES])
  8. #
  9. # DESCRIPTION
  10. #
  11. # Checks whether TYPE is signed or not. If no INCLUDES are specified, the
  12. # default includes are used. If ACTION-IF-SIGNED is given, it is
  13. # additional shell code to execute when the type is signed. If
  14. # ACTION-IF-UNSIGNED is given, it is executed when the type is unsigned.
  15. #
  16. # This macro assumes that the type exists. Therefore the existence of the
  17. # type should be checked before calling this macro. For example:
  18. #
  19. # AC_CHECK_HEADERS([wchar.h])
  20. # AC_CHECK_TYPE([wchar_t],,[ AC_MSG_ERROR([Type wchar_t not found.]) ])
  21. # AX_CHECK_SIGN([wchar_t],
  22. # [ AC_DEFINE(WCHAR_T_SIGNED, 1, [Define if wchar_t is signed]) ],
  23. # [ AC_DEFINE(WCHAR_T_UNSIGNED, 1, [Define if wchar_t is unsigned]) ], [
  24. # #ifdef HAVE_WCHAR_H
  25. # #include <wchar.h>
  26. # #endif
  27. # ])
  28. #
  29. # LICENSE
  30. #
  31. # Copyright (c) 2008 Ville Laurikari <vl@iki.fi>
  32. #
  33. # Copying and distribution of this file, with or without modification, are
  34. # permitted in any medium without royalty provided the copyright notice
  35. # and this notice are preserved. This file is offered as-is, without any
  36. # warranty.
  37. #serial 6
  38. AU_ALIAS([VL_CHECK_SIGN], [AX_CHECK_SIGN])
  39. AC_DEFUN([AX_CHECK_SIGN], [
  40. typename=`echo $1 | sed "s/@<:@^a-zA-Z0-9_@:>@/_/g"`
  41. AC_CACHE_CHECK([whether $1 is signed], ax_cv_decl_${typename}_signed, [
  42. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[$4]],
  43. [[ int foo @<:@ 1 - 2 * !((($1) -1) < 0) @:>@ ]])],
  44. [ eval "ax_cv_decl_${typename}_signed=\"yes\"" ],
  45. [ eval "ax_cv_decl_${typename}_signed=\"no\"" ])])
  46. symbolname=`echo $1 | sed "s/@<:@^a-zA-Z0-9_@:>@/_/g" | tr "a-z" "A-Z"`
  47. if eval "test \"\${ax_cv_decl_${typename}_signed}\" = \"yes\""; then
  48. $2
  49. elif eval "test \"\${ax_cv_decl_${typename}_signed}\" = \"no\""; then
  50. $3
  51. fi
  52. ])dnl