check_stdcall_func.m4 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # AC_LANG_STDCALL_FUNC_LINK_TRY(FUNCTION, SIGNATURE)
  2. # -------------------------------
  3. # Produce a source which links correctly iff the FUNCTION exists.
  4. AC_DEFUN([AC_LANG_STDCALL_FUNC_LINK_TRY],
  5. [_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
  6. # AC_CHECK_STDCALL_FUNC(FUNCTION, SIGNATURE, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
  7. # -----------------------------------------------------------------
  8. AC_DEFUN([AC_CHECK_STDCALL_FUNC],
  9. [AS_VAR_PUSHDEF([ac_var], [ac_cv_func_$1])dnl
  10. AC_CACHE_CHECK([for $1], ac_var,
  11. [AC_LINK_IFELSE([AC_LANG_STDCALL_FUNC_LINK_TRY([$1],[$2])],
  12. [AS_VAR_SET(ac_var, yes)],
  13. [AS_VAR_SET(ac_var, no)])])
  14. AS_IF([test AS_VAR_GET(ac_var) = yes], [$3], [$4])dnl
  15. AS_VAR_POPDEF([ac_var])dnl
  16. ])# AC_CHECK_FUNC
  17. # AC_LANG_STDCALL_FUNC_LINK_TRY(C)(FUNCTION, SIGNATURE)
  18. # ----------------------------------
  19. # Don't include <ctype.h> because on OSF/1 3.0 it includes
  20. # <sys/types.h> which includes <sys/select.h> which contains a
  21. # prototype for select. Similarly for bzero.
  22. m4_define([AC_LANG_STDCALL_FUNC_LINK_TRY(C)],
  23. [AC_LANG_PROGRAM(
  24. [/* System header to define __stub macros and hopefully few prototypes,
  25. which can conflict with char __stdcall $1 ( $2 ) below. */
  26. #include <assert.h>
  27. /* Override any gcc2 internal prototype to avoid an error. */
  28. #ifdef __cplusplus
  29. extern "C"
  30. #endif
  31. /* We use char because int might match the return type of a gcc2
  32. builtin and then its argument prototype would still apply. */
  33. char __stdcall $1 ( $2 );
  34. char (*f) ( $2 );
  35. ],
  36. [/* The GNU C library defines this for functions which it implements
  37. to always fail with ENOSYS. Some functions are actually named
  38. something starting with __ and the normal name is an alias. */
  39. #if defined (__stub_$1) || defined (__stub___$1)
  40. choke me
  41. #else
  42. f = $1;
  43. #endif
  44. ])])
  45. # AC_LANG_STDCALL_FUNC_LINK_TRY(C++)(FUNCTION)
  46. # ------------------------------------
  47. m4_copy([AC_LANG_STDCALL_FUNC_LINK_TRY(C)], [AC_LANG_STDCALL_FUNC_LINK_TRY(C++)])