From patchwork Thu Dec 16 19:42:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 49025 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AA7DF3858439 for ; Thu, 16 Dec 2021 19:46:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AA7DF3858439 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1639683991; bh=rQl5Zf10CIgayKywn5wNs+aXwAEYCsdWoLMeMddtKsA=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=rsFf9+/4jiHol4WGoonq/5D8BH4JAKa0FxScLFmhgkO0rFxVkcMuTlP9xL6tYpBrg 5hsglObS9IkoDrjNb6oxY0yJ01cQjeNYreWbwqsOaxyclsfSEfKV5jiHk2EZeRoxmO 6NzedfE3Vfu0ZsuJ6fL4QVgjo/ardno1zNcW5MDo= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qv1-xf33.google.com (mail-qv1-xf33.google.com [IPv6:2607:f8b0:4864:20::f33]) by sourceware.org (Postfix) with ESMTPS id 847A4385843D for ; Thu, 16 Dec 2021 19:42:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 847A4385843D Received: by mail-qv1-xf33.google.com with SMTP id m6so259314qvh.10 for ; Thu, 16 Dec 2021 11:42:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rQl5Zf10CIgayKywn5wNs+aXwAEYCsdWoLMeMddtKsA=; b=wDFEmkR8bT1aQYa8MlFvB/wKFAIdQcfAIz2zr6PyvPaDiOqttwiJboEdHvMdlPvv1W 4S0Gl8jwjesLqdFW1lTKpWBVuRAj0kPPtgoBr+rQRwcZQGf1uf6FGyFd2bThzGifcqbp J8LFAoWjefAIUy/YzEYGiTLicyIOUGqa20mHkw4IpLYGSU3+N+ht05zxQHYPiyEaKEwN gZRaOy3iEfzzSLEAtDcZ7nJ78g/jrSm2D/eyShYyeZ+5zF4W7GXST86vv6OQnAsXlSRS XpwyMBlxznAoy12HQfX404nmgyWwuHPii3cgTEmFKkZSoEqe/mDSXKjzdIrJpYUy0O9b DUNA== X-Gm-Message-State: AOAM532laMhpz/3IqFrjgPDUrZoT7MHvbEwa4rJl4FOhf+C1Y8alD2IZ jcszbFkvL+ICx6uc5d1YmqZfEDp6G7SZRA== X-Google-Smtp-Source: ABdhPJxA0yLNNhED9PLi6UL9PdgoV+pmh0bt6uVfAIkeRj6p5FO6J0+HEJeL7Vnifb+k15eh4ptxLw== X-Received: by 2002:a05:6214:262e:: with SMTP id gv14mr2958312qvb.5.1639683753536; Thu, 16 Dec 2021 11:42:33 -0800 (PST) Received: from birita.. ([2804:431:c7ca:103f:96e9:fe91:2aff:a44d]) by smtp.gmail.com with ESMTPSA id br13sm3503836qkb.10.2021.12.16.11.42.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 11:42:33 -0800 (PST) To: libc-alpha@sourceware.org, Stafford Horne Subject: [PATCH 5/5] malloc: Remove memusage.h Date: Thu, 16 Dec 2021 16:42:22 -0300 Message-Id: <20211216194222.186992-6-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211216194222.186992-1-adhemerval.zanella@linaro.org> References: <20211216194222.186992-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" 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. --- malloc/memusage.c | 13 ++++++----- sysdeps/aarch64/memusage.h | 21 ------------------ sysdeps/alpha/memusage.h | 20 ----------------- sysdeps/arc/memusage.h | 21 ------------------ sysdeps/arm/memusage.h | 20 ----------------- sysdeps/csky/memusage.h | 21 ------------------ sysdeps/hppa/memusage.h | 21 ------------------ sysdeps/i386/htl/machine-sp.h | 2 +- sysdeps/i386/i586/memusage.h | 1 - sysdeps/i386/i686/memusage.h | 20 ----------------- sysdeps/i386/memusage.h | 20 ----------------- sysdeps/ia64/memusage.h | 22 ------------------- sysdeps/m68k/memusage.h | 21 ------------------ sysdeps/mach/hurd/i386/tls.h | 1 - sysdeps/mach/i386/machine-sp.h | 2 +- sysdeps/microblaze/memusage.h | 21 ------------------ sysdeps/mips/memusage.h | 20 ----------------- sysdeps/nios2/memusage.h | 21 ------------------ sysdeps/powerpc/memusage.h | 20 ----------------- sysdeps/riscv/memusage.h | 21 ------------------ sysdeps/s390/memusage.h | 20 ----------------- sysdeps/sh/memusage.h | 20 ----------------- sysdeps/sparc/memusage.h | 20 ----------------- .../sysv/linux/machine-sp.h} | 18 +++++++++------ sysdeps/x86_64/memusage.h | 20 ----------------- 25 files changed, 20 insertions(+), 407 deletions(-) delete mode 100644 sysdeps/aarch64/memusage.h delete mode 100644 sysdeps/alpha/memusage.h delete mode 100644 sysdeps/arc/memusage.h delete mode 100644 sysdeps/arm/memusage.h delete mode 100644 sysdeps/csky/memusage.h delete mode 100644 sysdeps/hppa/memusage.h delete mode 100644 sysdeps/i386/i586/memusage.h delete mode 100644 sysdeps/i386/i686/memusage.h delete mode 100644 sysdeps/i386/memusage.h delete mode 100644 sysdeps/ia64/memusage.h delete mode 100644 sysdeps/m68k/memusage.h delete mode 100644 sysdeps/microblaze/memusage.h delete mode 100644 sysdeps/mips/memusage.h delete mode 100644 sysdeps/nios2/memusage.h delete mode 100644 sysdeps/powerpc/memusage.h delete mode 100644 sysdeps/riscv/memusage.h delete mode 100644 sysdeps/s390/memusage.h delete mode 100644 sysdeps/sh/memusage.h delete mode 100644 sysdeps/sparc/memusage.h rename sysdeps/{generic/memusage.h => unix/sysv/linux/machine-sp.h} (68%) delete mode 100644 sysdeps/x86_64/memusage.h diff --git a/malloc/memusage.c b/malloc/memusage.c index fb4e754e09..383ad51848 100644 --- a/malloc/memusage.c +++ b/malloc/memusage.c @@ -34,8 +34,9 @@ #include #include -#include #include +#include +#include /* For _STACK_GROWS_UP */ /* Pointer to the real functions. These are determined used `dlsym' when really needed. */ @@ -147,10 +148,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)) @@ -260,7 +261,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' @@ -326,7 +327,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 index d29f7c7f89..0000000000 --- a/sysdeps/aarch64/memusage.h +++ /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 - . */ - -#define GETSP() ({ register uintptr_t stack_ptr asm ("sp"); stack_ptr; }) - -#include diff --git a/sysdeps/alpha/memusage.h b/sysdeps/alpha/memusage.h deleted file mode 100644 index bbd28302e4..0000000000 --- a/sysdeps/alpha/memusage.h +++ /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 - . */ - -#define GETSP() ({ register uintptr_t stack_ptr asm ("$30"); stack_ptr; }) - -#include diff --git a/sysdeps/arc/memusage.h b/sysdeps/arc/memusage.h deleted file mode 100644 index e8a508a8ff..0000000000 --- a/sysdeps/arc/memusage.h +++ /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 - . */ - -#define GETSP() ({ register uintptr_t stack_ptr asm ("sp"); stack_ptr; }) - -#include diff --git a/sysdeps/arm/memusage.h b/sysdeps/arm/memusage.h deleted file mode 100644 index 2ec8de22a5..0000000000 --- a/sysdeps/arm/memusage.h +++ /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 - . */ - -#define GETSP() ({ register uintptr_t stack_ptr asm ("sp"); stack_ptr; }) - -#include diff --git a/sysdeps/csky/memusage.h b/sysdeps/csky/memusage.h deleted file mode 100644 index 392682e12b..0000000000 --- a/sysdeps/csky/memusage.h +++ /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 - . */ - -#define GETSP() ({ register uintptr_t stack_ptr asm ("sp"); stack_ptr; }) - -#include diff --git a/sysdeps/hppa/memusage.h b/sysdeps/hppa/memusage.h deleted file mode 100644 index 25e8b94b3f..0000000000 --- a/sysdeps/hppa/memusage.h +++ /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 - . */ - -#define GETSP() ({ register uintptr_t stack_ptr asm ("%r30"); stack_ptr; }) -#define STACK_GROWS_UPWARD 1 - -#include diff --git a/sysdeps/i386/htl/machine-sp.h b/sysdeps/i386/htl/machine-sp.h index 6b64dea385..812223d783 100644 --- a/sysdeps/i386/htl/machine-sp.h +++ b/sysdeps/i386/htl/machine-sp.h @@ -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 index c8170874d0..0000000000 --- a/sysdeps/i386/i586/memusage.h +++ /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 index 07b241263c..0000000000 --- a/sysdeps/i386/i686/memusage.h +++ /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 - . */ - -#define GETSP() ({ register uintptr_t stack_ptr asm ("esp"); stack_ptr; }) - -#include diff --git a/sysdeps/i386/memusage.h b/sysdeps/i386/memusage.h deleted file mode 100644 index 07b241263c..0000000000 --- a/sysdeps/i386/memusage.h +++ /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 - . */ - -#define GETSP() ({ register uintptr_t stack_ptr asm ("esp"); stack_ptr; }) - -#include diff --git a/sysdeps/ia64/memusage.h b/sysdeps/ia64/memusage.h deleted file mode 100644 index 33fd6ec899..0000000000 --- a/sysdeps/ia64/memusage.h +++ /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 - . */ - -#include - -#define GETSP() ({ register uintptr_t stack_ptr asm ("%r12"); stack_ptr; }) - -#include diff --git a/sysdeps/m68k/memusage.h b/sysdeps/m68k/memusage.h deleted file mode 100644 index c22d312aed..0000000000 --- a/sysdeps/m68k/memusage.h +++ /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 - . */ - - -#define GETSP() ({ register uintptr_t stack_ptr asm ("%sp"); stack_ptr; }) - -#include diff --git a/sysdeps/mach/hurd/i386/tls.h b/sysdeps/mach/hurd/i386/tls.h index c70ea73a81..c03d64c4d9 100644 --- a/sysdeps/mach/hurd/i386/tls.h +++ b/sysdeps/mach/hurd/i386/tls.h @@ -295,7 +295,6 @@ out: asm ("movl %%gs:%P1,%0" : "=q" (_dtv) : "i" (offsetof (tcbhead_t, dtv)));\ _dtv; }) - /* Set the stack guard field in TCB head. */ #define THREAD_SET_STACK_GUARD(value) \ THREAD_SETMEM (THREAD_SELF, stack_guard, value) diff --git a/sysdeps/mach/i386/machine-sp.h b/sysdeps/mach/i386/machine-sp.h index 280f3b7a4d..54b2a16c01 100644 --- a/sysdeps/mach/i386/machine-sp.h +++ b/sysdeps/mach/i386/machine-sp.h @@ -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 index 516c0b4609..0000000000 --- a/sysdeps/microblaze/memusage.h +++ /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 - . */ - -#define GETSP() ({ register uintptr_t stack_ptr asm ("r1"); stack_ptr; }) - -#include diff --git a/sysdeps/mips/memusage.h b/sysdeps/mips/memusage.h deleted file mode 100644 index 64c558c81d..0000000000 --- a/sysdeps/mips/memusage.h +++ /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 - . */ - -#define GETSP() ({ register uintptr_t stack_ptr asm ("$29"); stack_ptr; }) - -#include diff --git a/sysdeps/nios2/memusage.h b/sysdeps/nios2/memusage.h deleted file mode 100644 index 6f1c78812d..0000000000 --- a/sysdeps/nios2/memusage.h +++ /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 - . */ - -#define GETSP() ({ register uintptr_t stack_ptr asm ("%sp"); stack_ptr; }) - -#include diff --git a/sysdeps/powerpc/memusage.h b/sysdeps/powerpc/memusage.h deleted file mode 100644 index ab21f46258..0000000000 --- a/sysdeps/powerpc/memusage.h +++ /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 - . */ - -#define GETSP() ({ register uintptr_t stack_ptr asm ("%r1"); stack_ptr; }) - -#include diff --git a/sysdeps/riscv/memusage.h b/sysdeps/riscv/memusage.h deleted file mode 100644 index b7b45791b9..0000000000 --- a/sysdeps/riscv/memusage.h +++ /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 - . */ - -#define GETSP() ({ register uintptr_t stack_ptr asm ("sp"); stack_ptr; }) - -#include diff --git a/sysdeps/s390/memusage.h b/sysdeps/s390/memusage.h deleted file mode 100644 index 6219d79664..0000000000 --- a/sysdeps/s390/memusage.h +++ /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 - . */ - -#define GETSP() ({ register uintptr_t stack_ptr __asm__ ("15"); stack_ptr; }) - -#include diff --git a/sysdeps/sh/memusage.h b/sysdeps/sh/memusage.h deleted file mode 100644 index 87c3d40fdf..0000000000 --- a/sysdeps/sh/memusage.h +++ /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 - . */ - -#define GETSP() ({ register uintptr_t stack_ptr asm ("r15"); stack_ptr; }) - -#include diff --git a/sysdeps/sparc/memusage.h b/sysdeps/sparc/memusage.h deleted file mode 100644 index 13741e2577..0000000000 --- a/sysdeps/sparc/memusage.h +++ /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 - . */ - -#define GETSP() ({ register uintptr_t stack_ptr asm ("%sp"); stack_ptr; }) - -#include diff --git a/sysdeps/generic/memusage.h b/sysdeps/unix/sysv/linux/machine-sp.h similarity index 68% rename from sysdeps/generic/memusage.h rename to sysdeps/unix/sysv/linux/machine-sp.h index 514bd058d2..257d09e60d 100644 --- a/sysdeps/generic/memusage.h +++ b/sysdeps/unix/sysv/linux/machine-sp.h @@ -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 @@ -15,11 +16,14 @@ License along with the GNU C Library; if not, see . */ +#ifndef _MACHINE_SP_H +#define _MACHINE_SP_H -#include -#include +/* 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 index 6652fc5da1..0000000000 --- a/sysdeps/x86_64/memusage.h +++ /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 - . */ - -#define GETSP() ({ register uintptr_t stack_ptr asm ("rsp"); stack_ptr; }) - -#include