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.

52 lines
1.6KB

  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 6
  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_TRY_RUN(
  29. [#include <stdio.h>
  30. int main(void)
  31. {
  32. char buf[10];
  33. strcpy (buf, "01234567");
  34. memmove (buf, buf + 2, 3);
  35. if (strcmp (buf, "23434567"))
  36. exit (1);
  37. strcpy (buf, "01234567");
  38. memmove (buf + 2, buf, 3);
  39. if (strcmp (buf, "01012567"))
  40. exit (1);
  41. exit (0);
  42. }], ac_cv_have_working_memmove=yes, ac_cv_have_working_memmove=no, ac_cv_have_working_memmove=cross)])
  43. AC_MSG_RESULT([$ac_cv_have_working_memmove])
  44. if test x$ac_cv_have_working_memmove != "xyes"; then
  45. AC_LIBOBJ(memmove)
  46. AC_MSG_WARN([Replacing missing/broken memmove.])
  47. AC_DEFINE(PREFER_PORTABLE_MEMMOVE, 1, "enable replacement memmove if system memmove is broken or missing")
  48. fi])