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.

84 lines
2.9KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_cxx_restrict_this.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_CXX_RESTRICT_THIS
  8. #
  9. # DESCRIPTION
  10. #
  11. # Determine whether the C++ compiler supports qualifying a member function
  12. # with a restricted "this" pointer. Define "restrict_this" to the correct
  13. # spelling; use like this:
  14. #
  15. # T::fn() restrict_this { /* code */ }
  16. #
  17. # Otherwise, define "restrict_this" to be empty.
  18. #
  19. # Note: the syntax above is a GCC extension. If your C++ compiler has a
  20. # different way of applying the 'restricted' qualifier to the "this"
  21. # pointer, please consider reporting it.
  22. #
  23. # LICENSE
  24. #
  25. # Copyright (c) 2010 Riccardo Murri <riccardo.murri@gmail.com>
  26. #
  27. # This program is free software; you can redistribute it and/or modify it
  28. # under the terms of the GNU General Public License as published by the
  29. # Free Software Foundation, either version 3 of the License, or (at your
  30. # option) any later version.
  31. #
  32. # This program is distributed in the hope that it will be useful, but
  33. # WITHOUT ANY WARRANTY; without even the implied warranty of
  34. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  35. # Public License for more details.
  36. #
  37. # Under Section 7 of GPL version 3, you are granted additional permissions
  38. # described in the Autoconf Configure Script Exception, version 3.0, as
  39. # published by the Free Software Foundation.
  40. #
  41. # You should have received a copy of the GNU General Public License and a
  42. # copy of the Autoconf Configure Script Exception along with this program;
  43. # see the files COPYINGv3 and COPYING.EXCEPTION respectively. If not, see
  44. # <https://www.gnu.org/licenses/>.
  45. #serial 2
  46. AC_DEFUN([AX_CXX_RESTRICT_THIS],
  47. [AC_CACHE_CHECK([whether C++ supports GCC's restrict "this" syntax], ax_cv_cxx_restrict_this,
  48. [ax_cv_cxx_restrict_this=no
  49. AC_LANG_PUSH([C++])
  50. # The order here caters to the fact that C++ does not require restrict.
  51. for ac_kw in __restrict __restrict__ _Restrict restrict; do
  52. AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
  53. [[#define restrict_this $ac_kw
  54. class Foo {
  55. private:
  56. int x_;
  57. public:
  58. Foo(int x) : x_(x) { };
  59. int bar(Foo* other);
  60. };
  61. int Foo::bar(Foo* other) restrict_this { return this->x_ + other->x_; }
  62. ]],
  63. [[
  64. Foo a(3), b(5);
  65. return (8 == a.bar(&b));
  66. ]])],
  67. [ax_cv_cxx_restrict_this=$ac_kw])
  68. test "$ax_cv_cxx_restrict_this" != no && break
  69. done
  70. AC_LANG_POP([C++])
  71. ])
  72. AH_VERBATIM([restrict_this],
  73. [/* Define to the keyword(s) used to specify that a member function's
  74. "this" pointer is unaliased. Define to nothing if this is not
  75. supported. */
  76. #undef restrict_this])
  77. case $ax_cv_cxx_restrict_this in
  78. no) AC_DEFINE([restrict_this], []) ;;
  79. *) AC_DEFINE_UNQUOTED([restrict_this], [$ax_cv_cxx_restrict_this]) ;;
  80. esac
  81. ])# AC_C_RESTRICT