malloc: Remove memusage.h
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Thu, 16 Dec 2021 18:26:36 +0000 (15:26 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 28 Dec 2021 17:57:57 +0000 (14:57 -0300)
And use machine-sp.h instead.  The Linux implementation is based on
already provided CURRENT_STACK_FRAME (used on nptl code) and
STACK_GROWS_UPWARD is replaced with _STACK_GROWS_UP.

24 files changed:
malloc/memusage.c
sysdeps/aarch64/memusage.h [deleted file]
sysdeps/alpha/memusage.h [deleted file]
sysdeps/arc/memusage.h [deleted file]
sysdeps/arm/memusage.h [deleted file]
sysdeps/csky/memusage.h [deleted file]
sysdeps/hppa/memusage.h [deleted file]
sysdeps/i386/htl/machine-sp.h
sysdeps/i386/i586/memusage.h [deleted file]
sysdeps/i386/i686/memusage.h [deleted file]
sysdeps/i386/memusage.h [deleted file]
sysdeps/ia64/memusage.h [deleted file]
sysdeps/m68k/memusage.h [deleted file]
sysdeps/mach/i386/machine-sp.h
sysdeps/microblaze/memusage.h [deleted file]
sysdeps/mips/memusage.h [deleted file]
sysdeps/nios2/memusage.h [deleted file]
sysdeps/powerpc/memusage.h [deleted file]
sysdeps/riscv/memusage.h [deleted file]
sysdeps/s390/memusage.h [deleted file]
sysdeps/sh/memusage.h [deleted file]
sysdeps/sparc/memusage.h [deleted file]
sysdeps/unix/sysv/linux/machine-sp.h [moved from sysdeps/generic/memusage.h with 68% similarity]
sysdeps/x86_64/memusage.h [deleted file]

index eaf4965..6391d88 100644 (file)
@@ -33,8 +33,9 @@
 #include <sys/mman.h>
 #include <sys/time.h>
 
-#include <memusage.h>
 #include <hp-timing.h>
+#include <machine-sp.h>
+#include <stackinfo.h>  /* For _STACK_GROWS_UP  */
 
 /* Pointer to the real functions.  These are determined used `dlsym'
    when really needed.  */
@@ -155,10 +156,10 @@ update_data (struct header *result, size_t len, size_t old_len)
      the main thread and it is the first call to any of these
      functions.  */
   if (__glibc_unlikely (!start_sp))
-    start_sp = GETSP ();
+    start_sp = __thread_stack_pointer ();
 
-  uintptr_t sp = GETSP ();
-#ifdef STACK_GROWS_UPWARD
+  uintptr_t sp = __thread_stack_pointer ();
+#ifdef _STACK_GROWS_UP
   /* This can happen in threads where we didn't catch the thread's
      stack early enough.  */
   if (__glibc_unlikely (sp < start_sp))
@@ -268,7 +269,7 @@ me (void)
       const char *outname;
 
       if (!start_sp)
-        start_sp = GETSP ();
+        start_sp = __thread_stack_pointer ();
 
       outname = getenv ("MEMUSAGE_OUTPUT");
       if (outname != NULL && outname[0] != '\0'
@@ -334,7 +335,7 @@ static void
 __attribute__ ((constructor))
 init (void)
 {
-  start_sp = GETSP ();
+  start_sp = __thread_stack_pointer ();
   if (!initialized)
     me ();
 }
diff --git a/sysdeps/aarch64/memusage.h b/sysdeps/aarch64/memusage.h
deleted file mode 100644 (file)
index d29f7c7..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/* Copyright (C) 2000-2021 Free Software Foundation, Inc.
-
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public License as
-   published by the Free Software Foundation; either version 2.1 of the
-   License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#define GETSP() ({ register uintptr_t stack_ptr asm ("sp"); stack_ptr; })
-
-#include <sysdeps/generic/memusage.h>
diff --git a/sysdeps/alpha/memusage.h b/sysdeps/alpha/memusage.h
deleted file mode 100644 (file)
index bbd2830..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright (C) 2000-2021 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#define GETSP() ({ register uintptr_t stack_ptr asm ("$30"); stack_ptr; })
-
-#include <sysdeps/generic/memusage.h>
diff --git a/sysdeps/arc/memusage.h b/sysdeps/arc/memusage.h
deleted file mode 100644 (file)
index e8a508a..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/* Machine-specific definitions for memory usage profiling, ARC version.
-   Copyright (C) 2020-2021 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#define GETSP() ({ register uintptr_t stack_ptr asm ("sp"); stack_ptr; })
-
-#include <sysdeps/generic/memusage.h>
diff --git a/sysdeps/arm/memusage.h b/sysdeps/arm/memusage.h
deleted file mode 100644 (file)
index 2ec8de2..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright (C) 2000-2021 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#define GETSP() ({ register uintptr_t stack_ptr asm ("sp"); stack_ptr; })
-
-#include <sysdeps/generic/memusage.h>
diff --git a/sysdeps/csky/memusage.h b/sysdeps/csky/memusage.h
deleted file mode 100644 (file)
index 392682e..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/* Machine-specific definitions for memory usage profiling, C-SKY version.
-   Copyright (C) 2018-2021 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#define GETSP() ({ register uintptr_t stack_ptr asm ("sp"); stack_ptr; })
-
-#include <sysdeps/generic/memusage.h>
diff --git a/sysdeps/hppa/memusage.h b/sysdeps/hppa/memusage.h
deleted file mode 100644 (file)
index 25e8b94..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/* Copyright (C) 2000-2021 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#define GETSP() ({ register uintptr_t stack_ptr asm ("%r30"); stack_ptr; })
-#define STACK_GROWS_UPWARD 1
-
-#include <sysdeps/generic/memusage.h>
index 6b64dea..812223d 100644 (file)
@@ -22,7 +22,7 @@
 /* Return the current stack pointer.  */
 
 #define __thread_stack_pointer() ({                                          \
-  register void *__sp__ asm("esp");                                          \
+  register uintptr_t __sp__ asm("esp");                                              \
   __sp__;                                                                    \
 })
 
diff --git a/sysdeps/i386/i586/memusage.h b/sysdeps/i386/i586/memusage.h
deleted file mode 100644 (file)
index c817087..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../i686/memusage.h"
diff --git a/sysdeps/i386/i686/memusage.h b/sysdeps/i386/i686/memusage.h
deleted file mode 100644 (file)
index 07b2412..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright (C) 2000-2021 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#define GETSP() ({ register uintptr_t stack_ptr asm ("esp"); stack_ptr; })
-
-#include <sysdeps/generic/memusage.h>
diff --git a/sysdeps/i386/memusage.h b/sysdeps/i386/memusage.h
deleted file mode 100644 (file)
index 07b2412..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright (C) 2000-2021 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#define GETSP() ({ register uintptr_t stack_ptr asm ("esp"); stack_ptr; })
-
-#include <sysdeps/generic/memusage.h>
diff --git a/sysdeps/ia64/memusage.h b/sysdeps/ia64/memusage.h
deleted file mode 100644 (file)
index 33fd6ec..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Copyright (C) 2000-2021 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <hp-timing.h>
-
-#define GETSP() ({ register uintptr_t stack_ptr asm ("%r12"); stack_ptr; })
-
-#include <sysdeps/generic/memusage.h>
diff --git a/sysdeps/m68k/memusage.h b/sysdeps/m68k/memusage.h
deleted file mode 100644 (file)
index c22d312..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/* Copyright (C) 2000-2021 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <https://www.gnu.org/licenses/>.  */
-
-
-#define GETSP() ({ register uintptr_t stack_ptr asm ("%sp"); stack_ptr; })
-
-#include <sysdeps/generic/memusage.h>
index 280f3b7..54b2a16 100644 (file)
@@ -22,7 +22,7 @@
 /* Return the current stack pointer.  */
 
 #define __thread_stack_pointer() ({                                          \
-  void *__sp__;                                                                      \
+  uintptr_t __sp__;                                                          \
   __asm__ ("movl %%esp, %0" : "=r" (__sp__));                                \
   __sp__;                                                                    \
 })
diff --git a/sysdeps/microblaze/memusage.h b/sysdeps/microblaze/memusage.h
deleted file mode 100644 (file)
index 516c0b4..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/* Copyright (C) 2000-2021 Free Software Foundation, Inc.
-
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public License as
-   published by the Free Software Foundation; either version 2.1 of the
-   License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#define GETSP() ({ register uintptr_t stack_ptr asm ("r1"); stack_ptr; })
-
-#include <sysdeps/generic/memusage.h>
diff --git a/sysdeps/mips/memusage.h b/sysdeps/mips/memusage.h
deleted file mode 100644 (file)
index 64c558c..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright (C) 2000-2021 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#define GETSP() ({ register uintptr_t stack_ptr asm ("$29"); stack_ptr; })
-
-#include <sysdeps/generic/memusage.h>
diff --git a/sysdeps/nios2/memusage.h b/sysdeps/nios2/memusage.h
deleted file mode 100644 (file)
index 6f1c788..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/* Machine-specific definitions for memory usage profiling, Nios II version.
-   Copyright (C) 2000-2021 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#define GETSP() ({ register uintptr_t stack_ptr asm ("%sp"); stack_ptr; })
-
-#include <sysdeps/generic/memusage.h>
diff --git a/sysdeps/powerpc/memusage.h b/sysdeps/powerpc/memusage.h
deleted file mode 100644 (file)
index ab21f46..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright (C) 2000-2021 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#define GETSP() ({ register uintptr_t stack_ptr asm ("%r1"); stack_ptr; })
-
-#include <sysdeps/generic/memusage.h>
diff --git a/sysdeps/riscv/memusage.h b/sysdeps/riscv/memusage.h
deleted file mode 100644 (file)
index b7b4579..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/* Machine-specific definitions for memory usage profiling, RISC-V version.
-   Copyright (C) 2000-2021 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#define GETSP() ({ register uintptr_t stack_ptr asm ("sp"); stack_ptr; })
-
-#include <sysdeps/generic/memusage.h>
diff --git a/sysdeps/s390/memusage.h b/sysdeps/s390/memusage.h
deleted file mode 100644 (file)
index 6219d79..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright (C) 2000-2021 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#define GETSP() ({ register uintptr_t stack_ptr __asm__ ("15"); stack_ptr; })
-
-#include <sysdeps/generic/memusage.h>
diff --git a/sysdeps/sh/memusage.h b/sysdeps/sh/memusage.h
deleted file mode 100644 (file)
index 87c3d40..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright (C) 2000-2021 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#define GETSP() ({ register uintptr_t stack_ptr asm ("r15"); stack_ptr; })
-
-#include <sysdeps/generic/memusage.h>
diff --git a/sysdeps/sparc/memusage.h b/sysdeps/sparc/memusage.h
deleted file mode 100644 (file)
index 13741e2..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright (C) 2000-2021 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#define GETSP() ({ register uintptr_t stack_ptr asm ("%sp"); stack_ptr; })
-
-#include <sysdeps/generic/memusage.h>
similarity index 68%
rename from sysdeps/generic/memusage.h
rename to sysdeps/unix/sysv/linux/machine-sp.h
index 514bd05..257d09e 100644 (file)
@@ -1,4 +1,5 @@
-/* Copyright (C) 2000-2021 Free Software Foundation, Inc.
+/* Machine-specific function to return the stack pointer.  Linux version.
+   Copyright (C) 2021 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#ifndef _MACHINE_SP_H
+#define _MACHINE_SP_H
 
-#include <limits.h>
-#include <stdint.h>
+/* Return the current stack pointer.  */
+static inline uintptr_t
+__thread_stack_pointer (void)
+{
+  return (uintptr_t) CURRENT_STACK_FRAME;
+}
 
-#ifndef GETSP
-# warning "GETSP is not defined for this architecture."
-# define GETSP 0
-#endif
+#endif /* machine-sp.h */
diff --git a/sysdeps/x86_64/memusage.h b/sysdeps/x86_64/memusage.h
deleted file mode 100644 (file)
index 6652fc5..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright (C) 2001-2021 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#define GETSP() ({ register uintptr_t stack_ptr asm ("rsp"); stack_ptr; })
-
-#include <sysdeps/generic/memusage.h>