ax_func_memmove.m4 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_func_memmove.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_FUNC_MEMMOVE
  8. #
  9. # DESCRIPTION
  10. #
  11. # Checks for a memmove that can handle overlaps correctly. If no working
  12. # memmove is found, request a replacement and warn the user about it.
  13. #
  14. # LICENSE
  15. #
  16. # Copyright (c) 2008 Ruediger Kuhlmann <info@ruediger-kuhlmann.de>
  17. #
  18. # Copying and distribution of this file, with or without modification, are
  19. # permitted in any medium without royalty provided the copyright notice
  20. # and this notice are preserved. This file is offered as-is, without any
  21. # warranty.
  22. #serial 8
  23. AU_ALIAS([AC_FUNC_MEMMOVE], [AX_FUNC_MEMMOVE])
  24. AC_DEFUN([AX_FUNC_MEMMOVE],
  25. [AC_CHECK_FUNCS(memmove)
  26. AC_MSG_CHECKING(for working memmove)
  27. AC_CACHE_VAL(ac_cv_have_working_memmove,
  28. [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
  29. #include <stdlib.h>
  30. #include <string.h>
  31. int main(void)
  32. {
  33. char buf[10];
  34. strcpy (buf, "01234567");
  35. memmove (buf, buf + 2, 3);
  36. if (strcmp (buf, "23434567"))
  37. exit (1);
  38. strcpy (buf, "01234567");
  39. memmove (buf + 2, buf, 3);
  40. if (strcmp (buf, "01012567"))
  41. exit (1);
  42. exit (0);
  43. }]])],[ac_cv_have_working_memmove=yes],[ac_cv_have_working_memmove=no],[ac_cv_have_working_memmove=cross])])
  44. AC_MSG_RESULT([$ac_cv_have_working_memmove])
  45. if test x$ac_cv_have_working_memmove != "xyes"; then
  46. AC_LIBOBJ(memmove)
  47. AC_MSG_WARN([Replacing missing/broken memmove.])
  48. AC_DEFINE(PREFER_PORTABLE_MEMMOVE, 1, "enable replacement memmove if system memmove is broken or missing")
  49. fi])