Add configure check for arm64 user_regs_struct.

old glibc defined kernel user_pt_regs, but newer glibc instead
define user_regs_struct. Add a configure test to see what we need.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14176 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/configure.ac b/configure.ac
index c91ea94..238e624 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1461,6 +1461,22 @@
 
 AM_CONDITIONAL(CXX_CAN_INCLUDE_THREAD_HEADER, test x$ac_cxx_can_include_thread_header = xyes)
 
+
+# On aarch64 before glibc 2.20 we would get the kernel user_pt_regs instead
+# of the user_regs_struct from sys/user.h. They are structurally the same
+# but we get either one or the other.
+
+AC_CHECK_TYPE([struct user_regs_struct],
+              [sys_user_has_user_regs=yes], [sys_user_has_user_regs=no],
+              [[#include <sys/ptrace.h>]
+               [#include <sys/time.h>]
+               [#include <sys/user.h>]])
+if test "$sys_user_has_user_regs" = "yes"; then
+  AC_DEFINE(HAVE_SYS_USER_REGS, 1,
+            [Define to 1 if <sys/user.h> defines struct user_regs_struct])
+fi
+
+
 #----------------------------------------------------------------------------
 # Checking for supported compiler flags.
 #----------------------------------------------------------------------------
diff --git a/coregrind/vgdb-invoker-ptrace.c b/coregrind/vgdb-invoker-ptrace.c
index 0ad631a..acb4d0d 100644
--- a/coregrind/vgdb-invoker-ptrace.c
+++ b/coregrind/vgdb-invoker-ptrace.c
@@ -515,7 +515,13 @@
 }
 
 #  if defined(VGA_arm64)
+/* arm64 is extra special, old glibc defined kernel user_pt_regs, but
+   newer glibc instead define user_regs_struct. */
+#    ifdef HAVE_SYS_USER_REGS
+static struct user_regs_struct user_save;
+#    else
 static struct user_pt_regs user_save;
+#    endif
 #  else
 static struct user user_save;
 #  endif
@@ -783,7 +789,13 @@
    long res;
    Bool stopped;
 #  if defined(VGA_arm64)
+/* arm64 is extra special, old glibc defined kernel user_pt_regs, but
+   newer glibc instead define user_regs_struct. */
+#    ifdef HAVE_SYS_USER_REGS
+   struct user_regs_struct user_mod;
+#    else
    struct user_pt_regs user_mod;
+#    endif
 #  else
    struct user user_mod;
 #  endif