Collection of DPF-based plugins for packaging
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.5KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_define_integer_bits.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_DEFINE_INTEGER_BITS (TYPE [, CANDIDATE-TYPE]...)
  8. #
  9. # DESCRIPTION
  10. #
  11. # Given a TYPE of the form "int##_t" or "uint##_t", see if the datatype
  12. # TYPE is predefined. If not, then define TYPE -- both with AC_DEFINE and
  13. # as a shell variable -- to the first datatype of exactly ## bits in a
  14. # list of CANDIDATE-TYPEs. If none of the CANDIDATE-TYPEs contains exactly
  15. # ## bits, then set the TYPE shell variable to "no".
  16. #
  17. # For example, the following ensures that uint64_t is defined as a 64-bit
  18. # datatype:
  19. #
  20. # AX_DEFINE_INTEGER_BITS(uint64_t, unsigned long long, unsigned __int64, long)
  21. # if test "$uint64_t" = no; then
  22. # AC_MSG_ERROR([unable to continue without a 64-bit datatype])
  23. # fi
  24. #
  25. # You should then put the following in your C code to ensure that all
  26. # datatypes defined by AX_DEFINE_INTEGER_BITS are visible to your program:
  27. #
  28. # #include "config.h"
  29. #
  30. # #if HAVE_INTTYPES_H
  31. # # include <inttypes.h>
  32. # #else
  33. # # if HAVE_STDINT_H
  34. # # include <stdint.h>
  35. # # endif
  36. # #endif
  37. #
  38. # LICENSE
  39. #
  40. # Copyright (c) 2008 Scott Pakin <pakin@uiuc.edu>
  41. #
  42. # Copying and distribution of this file, with or without modification, are
  43. # permitted in any medium without royalty provided the copyright notice
  44. # and this notice are preserved. This file is offered as-is, without any
  45. # warranty.
  46. #serial 7
  47. AU_ALIAS([AC_DEFINE_INTEGER_BITS], [AX_DEFINE_INTEGER_BITS])
  48. AC_DEFUN([AX_DEFINE_INTEGER_BITS],
  49. [m4_define([ac_datatype_bits], [m4_translit($1, [a-zA-Z_])])
  50. m4_define([ac_datatype_bytes], [m4_eval(ac_datatype_bits/8)])
  51. AC_CHECK_TYPE($1, ,
  52. [
  53. AC_MSG_NOTICE([trying to find a suitable ]ac_datatype_bytes[-byte replacement for $1])
  54. $1=no
  55. find_$1 ()
  56. {
  57. _AX_DEFINE_INTEGER_BITS_HELPER($@)
  58. :
  59. }
  60. find_$1
  61. AC_DEFINE_UNQUOTED($1, $$1,
  62. [If not already defined, then define as a datatype of *exactly* ]ac_datatype_bits[ bits.])
  63. ])
  64. ])
  65. dnl Iterate over arguments $2..$N, trying to find a good match for $1.
  66. m4_define([_AX_DEFINE_INTEGER_BITS_HELPER],
  67. [ifelse($2, , ,
  68. [m4_define([ac_datatype_bits], [m4_translit($1, [a-zA-Z_])])
  69. m4_define([ac_datatype_bytes], [m4_eval(ac_datatype_bits/8)])
  70. AC_CHECK_SIZEOF($2)
  71. if test "$AS_TR_SH(ac_cv_sizeof_$2)" -eq ac_datatype_bytes; then
  72. $1="$2"
  73. return
  74. fi
  75. _AX_DEFINE_INTEGER_BITS_HELPER($1, m4_shift(m4_shift($@)))
  76. ])
  77. ])