From patchwork Thu Dec 23 17:37:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 49216 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 A4990385800A for ; Thu, 23 Dec 2021 17:38:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A4990385800A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1640281093; bh=17oGZNy7WFTY/K2u15G8sDw2US9/kL/g8/fv5Ee4gGY=; 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=GieAMeWVre1JEGmmFXZcdH1E36znbZMWGEkrKRzQc5lelhwTyaFoEcu1rXH/DP7cY hcenQ6SnWmI/uh2XedNW3lvw6fjDl2WvvzVEpYwup2OQhqVmH4DgbFkiDBDSiOx9l4 n5jA36iuFUT2cvbYH0zCZjrmkEMnhNRdNnS3NfnQ= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x735.google.com (mail-qk1-x735.google.com [IPv6:2607:f8b0:4864:20::735]) by sourceware.org (Postfix) with ESMTPS id 1913A385841C for ; Thu, 23 Dec 2021 17:37:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1913A385841C Received: by mail-qk1-x735.google.com with SMTP id m186so6146039qkb.4 for ; Thu, 23 Dec 2021 09:37:11 -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=17oGZNy7WFTY/K2u15G8sDw2US9/kL/g8/fv5Ee4gGY=; b=vA+0EElUi5q09ALo/gsAQgYyz/RJkQW5RiNmnuzHMG7Io2Gb2O6/WDuthy2aT38Nmu iL/Tk3xFG5foyiMTB9q9FYksCbAYcDx+Q2dljcKFkIoY857w06Gx4d/SMNacUsUCAWum aQeM3xkSipn/0YTpuJLqg3mXRIQYGobuMgBVxDjynNd8mpUXgjGy0QYIbSy8jZ/6ojZD Jbk3q9LrHz/LqnJdUVTTUMIU2yY5sY3bPIyoymhzCp8GRkYAymeXbf/3XuDqEPbnKdHt a7M2AXc8ACA/Fkcm96nRxP48Iq6nrnqhqnBa61bvhvUwS/lgvWbwvr2hUzO8RRaisHNu wpzw== X-Gm-Message-State: AOAM533W+bxtdmo4ICcSMuYaExxoDg+9gaPOGyZvpsH4QTh7Asxd0QIz 1jG0mdMmGRuWfDsGbrXwVn5bn2lu00ssQg== X-Google-Smtp-Source: ABdhPJx2ofFlHxm33Wjr+FguCe65sfNvdDgHJ7WiJzRfhlC/pjAiimmANgo2n52rk3KvVusIMrbHmw== X-Received: by 2002:a05:620a:4624:: with SMTP id br36mr2035549qkb.531.1640281030460; Thu, 23 Dec 2021 09:37:10 -0800 (PST) Received: from birita.. ([2804:431:c7cb:3b1e:1fd1:c581:58d8:4df2]) by smtp.gmail.com with ESMTPSA id w13sm4956531qko.20.2021.12.23.09.37.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 09:37:10 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH v2 1/4] malloc: Remove atomic_* usage Date: Thu, 23 Dec 2021 14:37:03 -0300 Message-Id: <20211223173706.1179720-2-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211223173706.1179720-1-adhemerval.zanella@linaro.org> References: <20211223173706.1179720-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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" These typedef are used solely on memusage and can be replaced with generic types. --- malloc/memusage.c | 36 ++++++++++++++++++------------------ sysdeps/arc/memusage.h | 2 -- sysdeps/generic/memusage.h | 14 -------------- sysdeps/nios2/memusage.h | 2 -- 4 files changed, 18 insertions(+), 36 deletions(-) diff --git a/malloc/memusage.c b/malloc/memusage.c index e99f0c1c14..de39ad1c1a 100644 --- a/malloc/memusage.c +++ b/malloc/memusage.c @@ -71,20 +71,20 @@ struct header #define MAGIC 0xfeedbeaf -static memusage_cntr_t calls[idx_last]; -static memusage_cntr_t failed[idx_last]; -static memusage_size_t total[idx_last]; -static memusage_size_t grand_total; -static memusage_cntr_t histogram[65536 / 16]; -static memusage_cntr_t large; -static memusage_cntr_t calls_total; -static memusage_cntr_t inplace; -static memusage_cntr_t decreasing; -static memusage_cntr_t realloc_free; -static memusage_cntr_t inplace_mremap; -static memusage_cntr_t decreasing_mremap; -static memusage_size_t current_heap; -static memusage_size_t peak_use[3]; +static unsigned long int calls[idx_last]; +static unsigned long int failed[idx_last]; +static size_t total[idx_last]; +static size_t grand_total; +static unsigned long int histogram[65536 / 16]; +static unsigned long int large; +static unsigned long int calls_total; +static unsigned long int inplace; +static unsigned long int decreasing; +static unsigned long int realloc_free; +static unsigned long int inplace_mremap; +static unsigned long int decreasing_mremap; +static size_t current_heap; +static size_t peak_use[3]; static __thread uintptr_t start_sp; /* A few macros to make the source more readable. */ @@ -111,7 +111,7 @@ struct entry }; static struct entry buffer[2 * DEFAULT_BUFFER_SIZE]; -static uatomic32_t buffer_cnt; +static uint32_t buffer_cnt; static struct entry first; @@ -128,7 +128,7 @@ update_data (struct header *result, size_t len, size_t old_len) } /* Compute current heap usage and compare it with the maximum value. */ - memusage_size_t heap + size_t heap = catomic_exchange_and_add (¤t_heap, len - old_len) + len - old_len; catomic_max (&peak_heap, heap); @@ -161,14 +161,14 @@ update_data (struct header *result, size_t len, size_t old_len) /* Store the value only if we are writing to a file. */ if (fd != -1) { - uatomic32_t idx = catomic_exchange_and_add (&buffer_cnt, 1); + uint32_t idx = catomic_exchange_and_add (&buffer_cnt, 1); if (idx + 1 >= 2 * buffer_size) { /* We try to reset the counter to the correct range. If this fails because of another thread increasing the counter it does not matter since that thread will take care of the correction. */ - uatomic32_t reset = (idx + 1) % (2 * buffer_size); + uint32_t reset = (idx + 1) % (2 * buffer_size); catomic_compare_and_exchange_val_acq (&buffer_cnt, reset, idx + 1); if (idx >= 2 * buffer_size) idx = reset - 1; diff --git a/sysdeps/arc/memusage.h b/sysdeps/arc/memusage.h index 290252a92f..e8a508a8ff 100644 --- a/sysdeps/arc/memusage.h +++ b/sysdeps/arc/memusage.h @@ -18,6 +18,4 @@ #define GETSP() ({ register uintptr_t stack_ptr asm ("sp"); stack_ptr; }) -#define uatomic32_t unsigned int - #include diff --git a/sysdeps/generic/memusage.h b/sysdeps/generic/memusage.h index 408e0b891b..c9bde5cd11 100644 --- a/sysdeps/generic/memusage.h +++ b/sysdeps/generic/memusage.h @@ -17,7 +17,6 @@ #include -#include #include #ifndef GETSP @@ -36,16 +35,3 @@ high = usecs >> 32; \ } #endif - -#if LONG_BIT == 32 -# define memusage_cntr_t uatomic32_t -#else -# define memusage_cntr_t uatomic64_t -#endif -#ifndef memusage_size_t -# if LONG_BIT == 32 -# define memusage_size_t uatomic32_t -# else -# define memusage_size_t uatomic64_t -# endif -#endif diff --git a/sysdeps/nios2/memusage.h b/sysdeps/nios2/memusage.h index 01618e44a8..6f1c78812d 100644 --- a/sysdeps/nios2/memusage.h +++ b/sysdeps/nios2/memusage.h @@ -18,6 +18,4 @@ #define GETSP() ({ register uintptr_t stack_ptr asm ("%sp"); stack_ptr; }) -#define uatomic32_t unsigned int - #include From patchwork Thu Dec 23 17:37:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 49218 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 EEB133858421 for ; Thu, 23 Dec 2021 17:39:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EEB133858421 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1640281178; bh=9BhJ3NXrbhuG+jHVhIXNn/NIpw3awE1mfRGDwRR7Lzs=; 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=Bs8rjD2VKV0CLqPY3gt134Vn04KgDnl4Darwg61TdTZMP0UZexrw0U/EN/QGpP0Y6 VIkEMEXLhMjPnnhUjQLUXIfuw1SOS8tYyDpQtmUS3k7Jv5M1bvJqPHmP64aLZulHbu y3KMkJ+iy++4e6LPlMNW2WAAnN1AntDXnLQwc4ro= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) by sourceware.org (Postfix) with ESMTPS id 8CC7A3858418 for ; Thu, 23 Dec 2021 17:37:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8CC7A3858418 Received: by mail-qk1-x72c.google.com with SMTP id l11so6100465qke.11 for ; Thu, 23 Dec 2021 09:37:12 -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=9BhJ3NXrbhuG+jHVhIXNn/NIpw3awE1mfRGDwRR7Lzs=; b=Uti7fYiaBaDaO7RVnRgPZTq7CyliddGsDxUxwrR+Mty7oSUW5zqkH+Zur4qT8JGT5M PRRc3v1TwWtR3IIBnGmp8SyhzAz1VgIhx4+YqTZFHN2S80vDvbL4KDIsBG+RCAbTQH4k szf29rJdRX3l6ndvLKK1j+CxDXx+RoyaNOvkJ50cppF59U/u02MJYf+LMqXoEO8soJ+w qynKKTM0ifVQrDz436o5esjR8ylDXkiaedu/Oo4CJsDpSe1B0xzYXmgPPrbIZra0nAnV LjzijKtwWiFfVr5hL6nSeYLBcR3LDAhUWcTtDPYIEH98ZFPgrJzFROmL6992NfOCslzd b1dA== X-Gm-Message-State: AOAM531vshjvH2JJMHgB3U57vzeeFQ2Ffn1g7X6h5Xs3PsAAZiXuHQ24 ZoygkbRkmMZej4O5jybZ1m2TLEPYLOhSaw== X-Google-Smtp-Source: ABdhPJw9gbZ7BTRcdsmbp0mcd9CnXkHxlEiXCqsM1mjzV+JnUf3/ZytTvUSVhLNyQDZUgvRFQ8Vqeg== X-Received: by 2002:a05:620a:4003:: with SMTP id h3mr2053793qko.225.1640281031667; Thu, 23 Dec 2021 09:37:11 -0800 (PST) Received: from birita.. ([2804:431:c7cb:3b1e:1fd1:c581:58d8:4df2]) by smtp.gmail.com with ESMTPSA id w13sm4956531qko.20.2021.12.23.09.37.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 09:37:11 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH v2 2/4] Remove atomic-machine.h atomic typedefs Date: Thu, 23 Dec 2021 14:37:04 -0300 Message-Id: <20211223173706.1179720-3-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211223173706.1179720-1-adhemerval.zanella@linaro.org> References: <20211223173706.1179720-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.8 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" Now that memusage.c uses generic types we can remove them. --- sysdeps/aarch64/atomic-machine.h | 17 -------- sysdeps/alpha/atomic-machine.h | 27 +------------ sysdeps/arc/atomic-machine.h | 12 ------ sysdeps/arm/atomic-machine.h | 17 -------- sysdeps/csky/atomic-machine.h | 10 ----- sysdeps/ia64/atomic-machine.h | 26 ------------ sysdeps/m68k/coldfire/atomic-machine.h | 31 -------------- sysdeps/m68k/m680x0/m68020/atomic-machine.h | 28 ------------- sysdeps/microblaze/atomic-machine.h | 17 -------- sysdeps/mips/atomic-machine.h | 17 -------- sysdeps/powerpc/atomic-machine.h | 17 -------- sysdeps/s390/atomic-machine.h | 27 ------------- sysdeps/sparc/atomic-machine.h | 27 ------------- sysdeps/unix/sysv/linux/hppa/atomic-machine.h | 17 -------- .../sysv/linux/m68k/coldfire/atomic-machine.h | 11 ----- .../unix/sysv/linux/nios2/atomic-machine.h | 12 ------ .../unix/sysv/linux/riscv/atomic-machine.h | 13 ------ sysdeps/unix/sysv/linux/sh/atomic-machine.h | 28 ------------- sysdeps/x86/atomic-machine.h | 40 ++++--------------- 19 files changed, 8 insertions(+), 386 deletions(-) diff --git a/sysdeps/aarch64/atomic-machine.h b/sysdeps/aarch64/atomic-machine.h index 44f55d424d..6056737e0d 100644 --- a/sysdeps/aarch64/atomic-machine.h +++ b/sysdeps/aarch64/atomic-machine.h @@ -19,23 +19,6 @@ #ifndef _AARCH64_ATOMIC_MACHINE_H #define _AARCH64_ATOMIC_MACHINE_H 1 -#include - -typedef int8_t atomic8_t; -typedef int16_t atomic16_t; -typedef int32_t atomic32_t; -typedef int64_t atomic64_t; - -typedef uint8_t uatomic8_t; -typedef uint16_t uatomic16_t; -typedef uint32_t uatomic32_t; -typedef uint64_t uatomic64_t; - -typedef intptr_t atomicptr_t; -typedef uintptr_t uatomicptr_t; -typedef intmax_t atomic_max_t; -typedef uintmax_t uatomic_max_t; - #define __HAVE_64B_ATOMICS 1 #define USE_ATOMIC_COMPILER_BUILTINS 1 #define ATOMIC_EXCHANGE_USES_CAS 0 diff --git a/sysdeps/alpha/atomic-machine.h b/sysdeps/alpha/atomic-machine.h index 201b8cf836..2c93e14653 100644 --- a/sysdeps/alpha/atomic-machine.h +++ b/sysdeps/alpha/atomic-machine.h @@ -17,31 +17,6 @@ #include -typedef int8_t atomic8_t; -typedef uint8_t uatomic8_t; -typedef int_fast8_t atomic_fast8_t; -typedef uint_fast8_t uatomic_fast8_t; - -typedef int16_t atomic16_t; -typedef uint16_t uatomic16_t; -typedef int_fast16_t atomic_fast16_t; -typedef uint_fast16_t uatomic_fast16_t; - -typedef int32_t atomic32_t; -typedef uint32_t uatomic32_t; -typedef int_fast32_t atomic_fast32_t; -typedef uint_fast32_t uatomic_fast32_t; - -typedef int64_t atomic64_t; -typedef uint64_t uatomic64_t; -typedef int_fast64_t atomic_fast64_t; -typedef uint_fast64_t uatomic_fast64_t; - -typedef intptr_t atomicptr_t; -typedef uintptr_t uatomicptr_t; -typedef intmax_t atomic_max_t; -typedef uintmax_t uatomic_max_t; - #define __HAVE_64B_ATOMICS 1 #define USE_ATOMIC_COMPILER_BUILTINS 0 @@ -127,7 +102,7 @@ typedef uintmax_t uatomic_max_t; : [__prev] "=&r" (__prev), \ [__cmp] "=&r" (__cmp) \ : [__mem] "m" (*(mem)), \ - [__old] "Ir" ((uint64_t)(atomic32_t)(uint64_t)(old)), \ + [__old] "Ir" ((uint64_t)(int32_t)(uint64_t)(old)), \ [__new] "Ir" (new) \ : "memory"); \ }) diff --git a/sysdeps/arc/atomic-machine.h b/sysdeps/arc/atomic-machine.h index 4cffc97f20..2080aaabfc 100644 --- a/sysdeps/arc/atomic-machine.h +++ b/sysdeps/arc/atomic-machine.h @@ -19,18 +19,6 @@ #ifndef _ARC_BITS_ATOMIC_H #define _ARC_BITS_ATOMIC_H 1 -#include - -typedef int32_t atomic32_t; -typedef uint32_t uatomic32_t; -typedef int_fast32_t atomic_fast32_t; -typedef uint_fast32_t uatomic_fast32_t; - -typedef intptr_t atomicptr_t; -typedef uintptr_t uatomicptr_t; -typedef intmax_t atomic_max_t; -typedef uintmax_t uatomic_max_t; - #define __HAVE_64B_ATOMICS 0 #define USE_ATOMIC_COMPILER_BUILTINS 1 diff --git a/sysdeps/arm/atomic-machine.h b/sysdeps/arm/atomic-machine.h index 7928ff29d8..b439be9bfc 100644 --- a/sysdeps/arm/atomic-machine.h +++ b/sysdeps/arm/atomic-machine.h @@ -16,23 +16,6 @@ License along with the GNU C Library. If not, see . */ -#include - -typedef int8_t atomic8_t; -typedef uint8_t uatomic8_t; -typedef int_fast8_t atomic_fast8_t; -typedef uint_fast8_t uatomic_fast8_t; - -typedef int32_t atomic32_t; -typedef uint32_t uatomic32_t; -typedef int_fast32_t atomic_fast32_t; -typedef uint_fast32_t uatomic_fast32_t; - -typedef intptr_t atomicptr_t; -typedef uintptr_t uatomicptr_t; -typedef intmax_t atomic_max_t; -typedef uintmax_t uatomic_max_t; - #define __HAVE_64B_ATOMICS 0 #define USE_ATOMIC_COMPILER_BUILTINS 0 #define ATOMIC_EXCHANGE_USES_CAS 1 diff --git a/sysdeps/csky/atomic-machine.h b/sysdeps/csky/atomic-machine.h index 7544c50413..4cd9f87aad 100644 --- a/sysdeps/csky/atomic-machine.h +++ b/sysdeps/csky/atomic-machine.h @@ -19,16 +19,6 @@ #ifndef __CSKY_ATOMIC_H_ #define __CSKY_ATOMIC_H_ -#include - -typedef int32_t atomic32_t; -typedef uint32_t uatomic32_t; - -typedef intptr_t atomicptr_t; -typedef uintptr_t uatomicptr_t; -typedef intmax_t atomic_max_t; -typedef uintmax_t uatomic_max_t; - #define __HAVE_64B_ATOMICS 0 #define USE_ATOMIC_COMPILER_BUILTINS 1 #define ATOMIC_EXCHANGE_USES_CAS 1 diff --git a/sysdeps/ia64/atomic-machine.h b/sysdeps/ia64/atomic-machine.h index 8b7cefbd99..6f0b44ef03 100644 --- a/sysdeps/ia64/atomic-machine.h +++ b/sysdeps/ia64/atomic-machine.h @@ -15,34 +15,8 @@ License along with the GNU C Library; if not, see . */ -#include #include -typedef int8_t atomic8_t; -typedef uint8_t uatomic8_t; -typedef int_fast8_t atomic_fast8_t; -typedef uint_fast8_t uatomic_fast8_t; - -typedef int16_t atomic16_t; -typedef uint16_t uatomic16_t; -typedef int_fast16_t atomic_fast16_t; -typedef uint_fast16_t uatomic_fast16_t; - -typedef int32_t atomic32_t; -typedef uint32_t uatomic32_t; -typedef int_fast32_t atomic_fast32_t; -typedef uint_fast32_t uatomic_fast32_t; - -typedef int64_t atomic64_t; -typedef uint64_t uatomic64_t; -typedef int_fast64_t atomic_fast64_t; -typedef uint_fast64_t uatomic_fast64_t; - -typedef intptr_t atomicptr_t; -typedef uintptr_t uatomicptr_t; -typedef intmax_t atomic_max_t; -typedef uintmax_t uatomic_max_t; - #define __HAVE_64B_ATOMICS 1 #define USE_ATOMIC_COMPILER_BUILTINS 0 diff --git a/sysdeps/m68k/coldfire/atomic-machine.h b/sysdeps/m68k/coldfire/atomic-machine.h index eae9240a35..23dae68439 100644 --- a/sysdeps/m68k/coldfire/atomic-machine.h +++ b/sysdeps/m68k/coldfire/atomic-machine.h @@ -18,37 +18,6 @@ #ifndef _ATOMIC_MACHINE_H #define _ATOMIC_MACHINE_H 1 -#include - -/* Coldfire has no atomic compare-and-exchange operation, and the - kernel provides no userspace atomicity operations. Here we just - use generic non-atomic implementations instead. */ - -typedef int8_t atomic8_t; -typedef uint8_t uatomic8_t; -typedef int_fast8_t atomic_fast8_t; -typedef uint_fast8_t uatomic_fast8_t; - -typedef int16_t atomic16_t; -typedef uint16_t uatomic16_t; -typedef int_fast16_t atomic_fast16_t; -typedef uint_fast16_t uatomic_fast16_t; - -typedef int32_t atomic32_t; -typedef uint32_t uatomic32_t; -typedef int_fast32_t atomic_fast32_t; -typedef uint_fast32_t uatomic_fast32_t; - -typedef int64_t atomic64_t; -typedef uint64_t uatomic64_t; -typedef int_fast64_t atomic_fast64_t; -typedef uint_fast64_t uatomic_fast64_t; - -typedef intptr_t atomicptr_t; -typedef uintptr_t uatomicptr_t; -typedef intmax_t atomic_max_t; -typedef uintmax_t uatomic_max_t; - /* If we have just non-atomic operations, we can as well make them wide. */ #define __HAVE_64B_ATOMICS 1 #define USE_ATOMIC_COMPILER_BUILTINS 0 diff --git a/sysdeps/m68k/m680x0/m68020/atomic-machine.h b/sysdeps/m68k/m680x0/m68020/atomic-machine.h index 7c8c8e75c9..bbf4f1b07d 100644 --- a/sysdeps/m68k/m680x0/m68020/atomic-machine.h +++ b/sysdeps/m68k/m680x0/m68020/atomic-machine.h @@ -15,34 +15,6 @@ License along with the GNU C Library. If not, see . */ -#include - - -typedef int8_t atomic8_t; -typedef uint8_t uatomic8_t; -typedef int_fast8_t atomic_fast8_t; -typedef uint_fast8_t uatomic_fast8_t; - -typedef int16_t atomic16_t; -typedef uint16_t uatomic16_t; -typedef int_fast16_t atomic_fast16_t; -typedef uint_fast16_t uatomic_fast16_t; - -typedef int32_t atomic32_t; -typedef uint32_t uatomic32_t; -typedef int_fast32_t atomic_fast32_t; -typedef uint_fast32_t uatomic_fast32_t; - -typedef int64_t atomic64_t; -typedef uint64_t uatomic64_t; -typedef int_fast64_t atomic_fast64_t; -typedef uint_fast64_t uatomic_fast64_t; - -typedef intptr_t atomicptr_t; -typedef uintptr_t uatomicptr_t; -typedef intmax_t atomic_max_t; -typedef uintmax_t uatomic_max_t; - #define __HAVE_64B_ATOMICS 1 #define USE_ATOMIC_COMPILER_BUILTINS 0 diff --git a/sysdeps/microblaze/atomic-machine.h b/sysdeps/microblaze/atomic-machine.h index 365402eeb0..d9cfa7f9c4 100644 --- a/sysdeps/microblaze/atomic-machine.h +++ b/sysdeps/microblaze/atomic-machine.h @@ -16,25 +16,8 @@ License along with the GNU C Library. If not, see . */ -#include #include - -typedef int8_t atomic8_t; -typedef uint8_t uatomic8_t; -typedef int_fast8_t atomic_fast8_t; -typedef uint_fast8_t uatomic_fast8_t; - -typedef int32_t atomic32_t; -typedef uint32_t uatomic32_t; -typedef int_fast32_t atomic_fast32_t; -typedef uint_fast32_t uatomic_fast32_t; - -typedef intptr_t atomicptr_t; -typedef uintptr_t uatomicptr_t; -typedef intmax_t atomic_max_t; -typedef uintmax_t uatomic_max_t; - #define __HAVE_64B_ATOMICS 0 #define USE_ATOMIC_COMPILER_BUILTINS 0 diff --git a/sysdeps/mips/atomic-machine.h b/sysdeps/mips/atomic-machine.h index e946b9d395..47752ee53e 100644 --- a/sysdeps/mips/atomic-machine.h +++ b/sysdeps/mips/atomic-machine.h @@ -19,25 +19,8 @@ #ifndef _MIPS_ATOMIC_MACHINE_H #define _MIPS_ATOMIC_MACHINE_H 1 -#include -#include #include -typedef int32_t atomic32_t; -typedef uint32_t uatomic32_t; -typedef int_fast32_t atomic_fast32_t; -typedef uint_fast32_t uatomic_fast32_t; - -typedef int64_t atomic64_t; -typedef uint64_t uatomic64_t; -typedef int_fast64_t atomic_fast64_t; -typedef uint_fast64_t uatomic_fast64_t; - -typedef intptr_t atomicptr_t; -typedef uintptr_t uatomicptr_t; -typedef intmax_t atomic_max_t; -typedef uintmax_t uatomic_max_t; - #if _MIPS_SIM == _ABIO32 && __mips < 2 #define MIPS_PUSH_MIPS2 ".set mips2\n\t" #else diff --git a/sysdeps/powerpc/atomic-machine.h b/sysdeps/powerpc/atomic-machine.h index 7535ba5d19..c0e7f6503f 100644 --- a/sysdeps/powerpc/atomic-machine.h +++ b/sysdeps/powerpc/atomic-machine.h @@ -25,23 +25,6 @@ * as appropriate and which in turn include this file. */ -#include - -typedef int32_t atomic32_t; -typedef uint32_t uatomic32_t; -typedef int_fast32_t atomic_fast32_t; -typedef uint_fast32_t uatomic_fast32_t; - -typedef int64_t atomic64_t; -typedef uint64_t uatomic64_t; -typedef int_fast64_t atomic_fast64_t; -typedef uint_fast64_t uatomic_fast64_t; - -typedef intptr_t atomicptr_t; -typedef uintptr_t uatomicptr_t; -typedef intmax_t atomic_max_t; -typedef uintmax_t uatomic_max_t; - /* * Powerpc does not have byte and halfword forms of load and reserve and * store conditional. So for powerpc we stub out the 8- and 16-bit forms. diff --git a/sysdeps/s390/atomic-machine.h b/sysdeps/s390/atomic-machine.h index 34409ca3c6..880e0e3c86 100644 --- a/sysdeps/s390/atomic-machine.h +++ b/sysdeps/s390/atomic-machine.h @@ -15,33 +15,6 @@ License along with the GNU C Library; if not, see . */ -#include - -typedef int8_t atomic8_t; -typedef uint8_t uatomic8_t; -typedef int_fast8_t atomic_fast8_t; -typedef uint_fast8_t uatomic_fast8_t; - -typedef int16_t atomic16_t; -typedef uint16_t uatomic16_t; -typedef int_fast16_t atomic_fast16_t; -typedef uint_fast16_t uatomic_fast16_t; - -typedef int32_t atomic32_t; -typedef uint32_t uatomic32_t; -typedef int_fast32_t atomic_fast32_t; -typedef uint_fast32_t uatomic_fast32_t; - -typedef int64_t atomic64_t; -typedef uint64_t uatomic64_t; -typedef int_fast64_t atomic_fast64_t; -typedef uint_fast64_t uatomic_fast64_t; - -typedef intptr_t atomicptr_t; -typedef uintptr_t uatomicptr_t; -typedef intmax_t atomic_max_t; -typedef uintmax_t uatomic_max_t; - /* Activate all C11 atomic builtins. Note: diff --git a/sysdeps/sparc/atomic-machine.h b/sysdeps/sparc/atomic-machine.h index 062600218c..b92d2820a0 100644 --- a/sysdeps/sparc/atomic-machine.h +++ b/sysdeps/sparc/atomic-machine.h @@ -19,33 +19,6 @@ #ifndef _ATOMIC_MACHINE_H #define _ATOMIC_MACHINE_H 1 -#include - -typedef int8_t atomic8_t; -typedef uint8_t uatomic8_t; -typedef int_fast8_t atomic_fast8_t; -typedef uint_fast8_t uatomic_fast8_t; - -typedef int16_t atomic16_t; -typedef uint16_t uatomic16_t; -typedef int_fast16_t atomic_fast16_t; -typedef uint_fast16_t uatomic_fast16_t; - -typedef int32_t atomic32_t; -typedef uint32_t uatomic32_t; -typedef int_fast32_t atomic_fast32_t; -typedef uint_fast32_t uatomic_fast32_t; - -typedef int64_t atomic64_t; -typedef uint64_t uatomic64_t; -typedef int_fast64_t atomic_fast64_t; -typedef uint_fast64_t uatomic_fast64_t; - -typedef intptr_t atomicptr_t; -typedef uintptr_t uatomicptr_t; -typedef intmax_t atomic_max_t; -typedef uintmax_t uatomic_max_t; - #ifdef __arch64__ # define __HAVE_64B_ATOMICS 1 #else diff --git a/sysdeps/unix/sysv/linux/hppa/atomic-machine.h b/sysdeps/unix/sysv/linux/hppa/atomic-machine.h index e9edc0e7bc..640f6756f8 100644 --- a/sysdeps/unix/sysv/linux/hppa/atomic-machine.h +++ b/sysdeps/unix/sysv/linux/hppa/atomic-machine.h @@ -15,26 +15,9 @@ License along with the GNU C Library. If not, see . */ -#include /* Required for type definitions e.g. uint8_t. */ - #ifndef _ATOMIC_MACHINE_H #define _ATOMIC_MACHINE_H 1 -typedef int8_t atomic8_t; -typedef uint8_t uatomic8_t; -typedef int_fast8_t atomic_fast8_t; -typedef uint_fast8_t uatomic_fast8_t; - -typedef int32_t atomic32_t; -typedef uint32_t uatomic32_t; -typedef int_fast32_t atomic_fast32_t; -typedef uint_fast32_t uatomic_fast32_t; - -typedef intptr_t atomicptr_t; -typedef uintptr_t uatomicptr_t; -typedef intmax_t atomic_max_t; -typedef uintmax_t uatomic_max_t; - #define atomic_full_barrier() __sync_synchronize () #define __HAVE_64B_ATOMICS 0 diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/atomic-machine.h b/sysdeps/unix/sysv/linux/m68k/coldfire/atomic-machine.h index 1228660058..929bdf8edd 100644 --- a/sysdeps/unix/sysv/linux/m68k/coldfire/atomic-machine.h +++ b/sysdeps/unix/sysv/linux/m68k/coldfire/atomic-machine.h @@ -18,22 +18,11 @@ #ifndef _ATOMIC_MACHINE_H #define _ATOMIC_MACHINE_H 1 -#include #include /* Coldfire has no atomic compare-and-exchange operation, but the kernel provides userspace atomicity operations. Use them. */ -typedef int32_t atomic32_t; -typedef uint32_t uatomic32_t; -typedef int_fast32_t atomic_fast32_t; -typedef uint_fast32_t uatomic_fast32_t; - -typedef intptr_t atomicptr_t; -typedef uintptr_t uatomicptr_t; -typedef intmax_t atomic_max_t; -typedef uintmax_t uatomic_max_t; - #define __HAVE_64B_ATOMICS 0 #define USE_ATOMIC_COMPILER_BUILTINS 0 diff --git a/sysdeps/unix/sysv/linux/nios2/atomic-machine.h b/sysdeps/unix/sysv/linux/nios2/atomic-machine.h index 9bba636c68..8ea7cdbc9b 100644 --- a/sysdeps/unix/sysv/linux/nios2/atomic-machine.h +++ b/sysdeps/unix/sysv/linux/nios2/atomic-machine.h @@ -19,18 +19,6 @@ #ifndef _NIOS2_ATOMIC_MACHINE_H #define _NIOS2_ATOMIC_MACHINE_H 1 -#include - -typedef int32_t atomic32_t; -typedef uint32_t uatomic32_t; -typedef int_fast32_t atomic_fast32_t; -typedef uint_fast32_t uatomic_fast32_t; - -typedef intptr_t atomicptr_t; -typedef uintptr_t uatomicptr_t; -typedef intmax_t atomic_max_t; -typedef uintmax_t uatomic_max_t; - #define __HAVE_64B_ATOMICS 0 #define USE_ATOMIC_COMPILER_BUILTINS 0 diff --git a/sysdeps/unix/sysv/linux/riscv/atomic-machine.h b/sysdeps/unix/sysv/linux/riscv/atomic-machine.h index f4006baac2..8848804f49 100644 --- a/sysdeps/unix/sysv/linux/riscv/atomic-machine.h +++ b/sysdeps/unix/sysv/linux/riscv/atomic-machine.h @@ -19,19 +19,6 @@ #ifndef _LINUX_RISCV_BITS_ATOMIC_H #define _LINUX_RISCV_BITS_ATOMIC_H 1 -#include - -typedef int32_t atomic32_t; -typedef uint32_t uatomic32_t; - -typedef int64_t atomic64_t; -typedef uint64_t uatomic64_t; - -typedef intptr_t atomicptr_t; -typedef uintptr_t uatomicptr_t; -typedef intmax_t atomic_max_t; -typedef uintmax_t uatomic_max_t; - #define atomic_full_barrier() __sync_synchronize () #ifdef __riscv_atomic diff --git a/sysdeps/unix/sysv/linux/sh/atomic-machine.h b/sysdeps/unix/sysv/linux/sh/atomic-machine.h index ec82e82c80..28d69907e9 100644 --- a/sysdeps/unix/sysv/linux/sh/atomic-machine.h +++ b/sysdeps/unix/sysv/linux/sh/atomic-machine.h @@ -16,34 +16,6 @@ License along with the GNU C Library; if not, see . */ -#include - - -typedef int8_t atomic8_t; -typedef uint8_t uatomic8_t; -typedef int_fast8_t atomic_fast8_t; -typedef uint_fast8_t uatomic_fast8_t; - -typedef int16_t atomic16_t; -typedef uint16_t uatomic16_t; -typedef int_fast16_t atomic_fast16_t; -typedef uint_fast16_t uatomic_fast16_t; - -typedef int32_t atomic32_t; -typedef uint32_t uatomic32_t; -typedef int_fast32_t atomic_fast32_t; -typedef uint_fast32_t uatomic_fast32_t; - -typedef int64_t atomic64_t; -typedef uint64_t uatomic64_t; -typedef int_fast64_t atomic_fast64_t; -typedef uint_fast64_t uatomic_fast64_t; - -typedef intptr_t atomicptr_t; -typedef uintptr_t uatomicptr_t; -typedef intmax_t atomic_max_t; -typedef uintmax_t uatomic_max_t; - #define __HAVE_64B_ATOMICS 0 #define USE_ATOMIC_COMPILER_BUILTINS 0 diff --git a/sysdeps/x86/atomic-machine.h b/sysdeps/x86/atomic-machine.h index 2692d94a92..af6e1d1c4f 100644 --- a/sysdeps/x86/atomic-machine.h +++ b/sysdeps/x86/atomic-machine.h @@ -23,32 +23,6 @@ #include /* For tcbhead_t. */ #include /* For cast_to_integer. */ -typedef int8_t atomic8_t; -typedef uint8_t uatomic8_t; -typedef int_fast8_t atomic_fast8_t; -typedef uint_fast8_t uatomic_fast8_t; - -typedef int16_t atomic16_t; -typedef uint16_t uatomic16_t; -typedef int_fast16_t atomic_fast16_t; -typedef uint_fast16_t uatomic_fast16_t; - -typedef int32_t atomic32_t; -typedef uint32_t uatomic32_t; -typedef int_fast32_t atomic_fast32_t; -typedef uint_fast32_t uatomic_fast32_t; - -typedef int64_t atomic64_t; -typedef uint64_t uatomic64_t; -typedef int_fast64_t atomic_fast64_t; -typedef uint_fast64_t uatomic_fast64_t; - -typedef intptr_t atomicptr_t; -typedef uintptr_t uatomicptr_t; -typedef intmax_t atomic_max_t; -typedef uintmax_t uatomic_max_t; - - #define LOCK_PREFIX "lock;" #define USE_ATOMIC_COMPILER_BUILTINS 1 @@ -119,9 +93,9 @@ typedef uintmax_t uatomic_max_t; "lock\n" \ "0:\tcmpxchgq %q2, %1" \ : "=a" (ret), "=m" (*mem) \ - : "q" ((atomic64_t) cast_to_integer (newval)), \ + : "q" ((int64_t) cast_to_integer (newval)), \ "m" (*mem), \ - "0" ((atomic64_t) cast_to_integer (oldval)), \ + "0" ((int64_t) cast_to_integer (oldval)), \ "i" (offsetof (tcbhead_t, multiple_threads))); \ ret; }) # define do_exchange_and_add_val_64_acq(pfx, mem, value) 0 @@ -191,7 +165,7 @@ typedef uintmax_t uatomic_max_t; else if (__HAVE_64B_ATOMICS) \ __asm __volatile ("xchgq %q0, %1" \ : "=r" (result), "=m" (*mem) \ - : "0" ((atomic64_t) cast_to_integer (newvalue)), \ + : "0" ((int64_t) cast_to_integer (newvalue)), \ "m" (*mem)); \ else \ { \ @@ -222,7 +196,7 @@ typedef uintmax_t uatomic_max_t; else if (__HAVE_64B_ATOMICS) \ __asm __volatile (lock "xaddq %q0, %1" \ : "=r" (__result), "=m" (*mem) \ - : "0" ((atomic64_t) cast_to_integer (__addval)), \ + : "0" ((int64_t) cast_to_integer (__addval)), \ "m" (*mem), \ "i" (offsetof (tcbhead_t, multiple_threads))); \ else \ @@ -264,7 +238,7 @@ typedef uintmax_t uatomic_max_t; else if (__HAVE_64B_ATOMICS) \ __asm __volatile (lock "addq %q1, %0" \ : "=m" (*mem) \ - : "ir" ((atomic64_t) cast_to_integer (value)), \ + : "ir" ((int64_t) cast_to_integer (value)), \ "m" (*mem), \ "i" (offsetof (tcbhead_t, multiple_threads))); \ else \ @@ -298,7 +272,7 @@ typedef uintmax_t uatomic_max_t; else if (__HAVE_64B_ATOMICS) \ __asm __volatile (LOCK_PREFIX "addq %q2, %0; sets %1" \ : "=m" (*mem), "=qm" (__result) \ - : "ir" ((atomic64_t) cast_to_integer (value)), \ + : "ir" ((int64_t) cast_to_integer (value)), \ "m" (*mem)); \ else \ __atomic_link_error (); \ @@ -322,7 +296,7 @@ typedef uintmax_t uatomic_max_t; else if (__HAVE_64B_ATOMICS) \ __asm __volatile (LOCK_PREFIX "addq %q2, %0; setz %1" \ : "=m" (*mem), "=qm" (__result) \ - : "ir" ((atomic64_t) cast_to_integer (value)), \ + : "ir" ((int64_t) cast_to_integer (value)), \ "m" (*mem)); \ else \ __atomic_link_error (); \ From patchwork Thu Dec 23 17:37:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 49217 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 9B1603858012 for ; Thu, 23 Dec 2021 17:38:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9B1603858012 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1640281135; bh=/i00R2+wpGimzRTJVnX9Vps3ncpYmt6si96oLt1JrP8=; 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=lBKp02veSWMT3VRRx1entCpGYw4gmMj4N73kQUyaBGwL4E5qFjq2VphL7ad1CdDyy 7+2I30V/WouUW0KBFWWyOY9WjJIKslZoMbkEv/ydB/FqmYtUh1dGoLqv87+AIpisWc fCEldC9O7x9C0gMecydCsJ+QXSLV3mVpevNu8YP8= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x733.google.com (mail-qk1-x733.google.com [IPv6:2607:f8b0:4864:20::733]) by sourceware.org (Postfix) with ESMTPS id 4909D3858436 for ; Thu, 23 Dec 2021 17:37:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4909D3858436 Received: by mail-qk1-x733.google.com with SMTP id w27so28432qkj.7 for ; Thu, 23 Dec 2021 09:37:13 -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=/i00R2+wpGimzRTJVnX9Vps3ncpYmt6si96oLt1JrP8=; b=d4m0ABpuW4oKvc1Jl3oL8EVWnjRGEoYboTJNTjyAUUYZLdyzaxte/r05d3wqEq7Yo7 L3zmUmNFj78DYFlEz+KR2n+2RKrKMyVgNMTO5DEaQfYnAVK+MnT+7ojQ+Z+qxxdBuSts +yhk68MuMtqq1aVE6lg4OSqQPKwVM1IV1w14vSPegDm+Bx3E9gJwOVYSLe5WSSnxiiX2 35QRXhAsLogxjwESEBjnN3oIqRkn2P6Su/vBrb2BQCsfH6S3R25PTVW5XdTF4Jkgm1+n g1dgzG+Q2Ys+iQM86PDtWFOQrTRbHuu5NU8Q9QeDi4P2HSrt70c8fr/1Cy9KFJ1C71w2 CoNQ== X-Gm-Message-State: AOAM530eAL9o4c5ukiVWFm//yBJMurpbY55201d/epXbTN/RsCFxs3c5 elCTlw8IsYpB+N79jNW5Nvcakj3/NEHoow== X-Google-Smtp-Source: ABdhPJzinNuvDv88ENx8/UboQJ7ZPKvIZzTbqgFCbrX9zVdloYJbNtE+vzrVRE5CnAA6Dv+ndSI01g== X-Received: by 2002:a05:620a:2891:: with SMTP id j17mr2135389qkp.386.1640281032675; Thu, 23 Dec 2021 09:37:12 -0800 (PST) Received: from birita.. ([2804:431:c7cb:3b1e:1fd1:c581:58d8:4df2]) by smtp.gmail.com with ESMTPSA id w13sm4956531qko.20.2021.12.23.09.37.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 09:37:12 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH v2 3/4] malloc: Use hp-timing on libmemusage Date: Thu, 23 Dec 2021 14:37:05 -0300 Message-Id: <20211223173706.1179720-4-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211223173706.1179720-1-adhemerval.zanella@linaro.org> References: <20211223173706.1179720-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.8 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" Instead of reimplemeting on GETTIME macro. --- malloc/memusage.c | 15 ++++++++++++--- sysdeps/generic/memusage.h | 12 ------------ sysdeps/i386/i686/memusage.h | 1 - sysdeps/ia64/memusage.h | 7 ------- sysdeps/x86_64/memusage.h | 1 - 5 files changed, 12 insertions(+), 24 deletions(-) diff --git a/malloc/memusage.c b/malloc/memusage.c index de39ad1c1a..179dd1c683 100644 --- a/malloc/memusage.c +++ b/malloc/memusage.c @@ -34,6 +34,7 @@ #include #include +#include /* Pointer to the real functions. These are determined used `dlsym' when really needed. */ @@ -114,6 +115,14 @@ static struct entry buffer[2 * DEFAULT_BUFFER_SIZE]; static uint32_t buffer_cnt; static struct entry first; +static void +gettime (struct entry *e) +{ + hp_timing_t now; + HP_TIMING_NOW (now); + e->time_low = now & 0xffffffff; + e->time_high = now >> 32; +} /* Update the global data after a successful function call. */ static void @@ -177,7 +186,7 @@ update_data (struct header *result, size_t len, size_t old_len) buffer[idx].heap = current_heap; buffer[idx].stack = current_stack; - GETTIME (buffer[idx].time_low, buffer[idx].time_high); + gettime (&buffer[idx]); /* Write out buffer if it is full. */ if (idx + 1 == buffer_size) @@ -267,7 +276,7 @@ me (void) /* Write the first entry. */ first.heap = 0; first.stack = 0; - GETTIME (first.time_low, first.time_high); + gettime (&first); /* Write it two times since we need the starting and end time. */ write (fd, &first, sizeof (first)); write (fd, &first, sizeof (first)); @@ -818,7 +827,7 @@ dest (void) stack. */ first.heap = peak_heap; first.stack = peak_stack; - GETTIME (first.time_low, first.time_high); + gettime (&first); write (fd, &first, sizeof (struct entry)); /* Close the file. */ diff --git a/sysdeps/generic/memusage.h b/sysdeps/generic/memusage.h index c9bde5cd11..514bd058d2 100644 --- a/sysdeps/generic/memusage.h +++ b/sysdeps/generic/memusage.h @@ -23,15 +23,3 @@ # warning "GETSP is not defined for this architecture." # define GETSP 0 #endif - -#ifndef GETTIME -# define GETTIME(low,high) \ - { \ - struct __timespec64 now; \ - uint64_t usecs; \ - __clock_gettime64 (CLOCK_REALTIME, &now); \ - usecs = (uint64_t)now.tv_nsec / 1000 + (uint64_t)now.tv_sec * 1000000; \ - low = usecs & 0xffffffff; \ - high = usecs >> 32; \ - } -#endif diff --git a/sysdeps/i386/i686/memusage.h b/sysdeps/i386/i686/memusage.h index 08b7831e12..07b241263c 100644 --- a/sysdeps/i386/i686/memusage.h +++ b/sysdeps/i386/i686/memusage.h @@ -16,6 +16,5 @@ . */ #define GETSP() ({ register uintptr_t stack_ptr asm ("esp"); stack_ptr; }) -#define GETTIME(low,high) asm ("rdtsc" : "=a" (low), "=d" (high)) #include diff --git a/sysdeps/ia64/memusage.h b/sysdeps/ia64/memusage.h index 3c3a526007..33fd6ec899 100644 --- a/sysdeps/ia64/memusage.h +++ b/sysdeps/ia64/memusage.h @@ -18,12 +18,5 @@ #include #define GETSP() ({ register uintptr_t stack_ptr asm ("%r12"); stack_ptr; }) -#define GETTIME(low, high) \ - { \ - hp_timing_t __now; \ - HP_TIMING_NOW (__now); \ - low = __now & 0xffffffff; \ - high = __now >> 32; \ - } #include diff --git a/sysdeps/x86_64/memusage.h b/sysdeps/x86_64/memusage.h index 568dd5512d..6652fc5da1 100644 --- a/sysdeps/x86_64/memusage.h +++ b/sysdeps/x86_64/memusage.h @@ -16,6 +16,5 @@ . */ #define GETSP() ({ register uintptr_t stack_ptr asm ("rsp"); stack_ptr; }) -#define GETTIME(low,high) asm ("rdtsc" : "=a" (low), "=d" (high)) #include From patchwork Thu Dec 23 17:37:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 49219 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 68956385843D for ; Thu, 23 Dec 2021 17:40:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 68956385843D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1640281225; bh=9MlpTjhSlMsZpwWodt8I43p/TmH2jmoWOrjxtY6cHsA=; 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=jNycF9fY2BD+olbSwO8NxwARIZnhC1ox7wFeK+cUBYRNZLLPs2Nx8Ysf6baeXxiue 6yggn+7ixk5nD8Skf63IMtNhArS02LcYaGgT3qrLu1WkKy7ps/47c0Jjj587TPI3ma 0NTZzcq9ERE0JhuHhi9j38n81VX9DDFbWOkHtMPk= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by sourceware.org (Postfix) with ESMTPS id 11E27385800D for ; Thu, 23 Dec 2021 17:37:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 11E27385800D Received: by mail-qk1-x729.google.com with SMTP id w27so28536qkj.7 for ; Thu, 23 Dec 2021 09:37:15 -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=9MlpTjhSlMsZpwWodt8I43p/TmH2jmoWOrjxtY6cHsA=; b=mFl8I56//iMZJwRRI+l5ArlrzdXYwmBB9iJbTFt2/o23G6F6opKNhyQLd6hM1m82OH qQUBGwZCHTp2uu8YIO0sARhcWRejkFrznM/rM16D59MFV0vHeV2gZq2vFYHK66qEcuZN E0tKG9JWzqhjZ8aJ7JOtc6EAT7twqsTD0Uq5DbBapsTKdKb4P52tqby0DUgPjOWzRkjf 35UqqRR6kdOnfqOWVkIAJJfHb39Pi7kzeva+5as7RfD1qhtKaoaDKn8eSOaob3bvahln FMFk8cCBwBb9kA+B7w21cIzykY64SQFQJD3PJiGonIv/tKskdnL7fe7/ymgW7yeCoIFe AWbA== X-Gm-Message-State: AOAM531ssFsE1I2dWJe0UQtmy82xvkYdNUUMd3xfJ5+93zCNrYgTDFfX eAwZaEvNB3jAZvmBKHjg5RVRne4vMQIJXg== X-Google-Smtp-Source: ABdhPJzOgd5meayAuw91gjbxeTLKiY7JKhTE8yvRZ3RN1Tc3KJks+aqr3eK/cjBXDjfnMowAesGg0w== X-Received: by 2002:a05:620a:14bb:: with SMTP id x27mr2167797qkj.382.1640281033867; Thu, 23 Dec 2021 09:37:13 -0800 (PST) Received: from birita.. ([2804:431:c7cb:3b1e:1fd1:c581:58d8:4df2]) by smtp.gmail.com with ESMTPSA id w13sm4956531qko.20.2021.12.23.09.37.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 09:37:13 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH v2 4/4] malloc: Remove memusage.h Date: Thu, 23 Dec 2021 14:37:06 -0300 Message-Id: <20211223173706.1179720-5-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211223173706.1179720-1-adhemerval.zanella@linaro.org> References: <20211223173706.1179720-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.8 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 179dd1c683..a1c5475fdb 100644 --- a/malloc/memusage.c +++ b/malloc/memusage.c @@ -33,8 +33,9 @@ #include #include -#include #include +#include +#include /* For _STACK_GROWS_UP */ /* Pointer to the real functions. These are determined used `dlsym' when really needed. */ @@ -146,10 +147,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)) @@ -259,7 +260,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' @@ -325,7 +326,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