From patchwork Tue Dec 29 19:34:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 41586 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 174BB388A838; Tue, 29 Dec 2020 19:35:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 174BB388A838 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1609270511; bh=xE3V2L7OAErV6E4tfNKE9TTze5DOJ7rgCTaFC8cxOWY=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=gH7Cl9zw8T7an8yiFT/6KWJ/QODFtiFKjpY4DkQs3uewYaSbs5hDBK/TVqPVvTuui eDo3kmFSdkspy7n3s5cYXhFdSEPOA0z7Lscbw4QMbzIUo5cuhBfB7LOFmzBOoEtbId v+IxfkBYCEFUOOvXWMRIsDweeMhuNYTeksww44+k= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) by sourceware.org (Postfix) with ESMTPS id 14555388A437 for ; Tue, 29 Dec 2020 19:35:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 14555388A437 Received: by mail-qk1-x72f.google.com with SMTP id 143so12211774qke.10 for ; Tue, 29 Dec 2020 11:35:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xE3V2L7OAErV6E4tfNKE9TTze5DOJ7rgCTaFC8cxOWY=; b=K2WTBGTXKfwLsxE+RHMRsuZhCJ3PuaRtPFrl5PoE9lZiCPTTVNAKGIAXgc1RHH3M9/ liwuhwE0vySJCnAtVUDwNvBYUyPm87MyEGAUrtepnAUh/7ybW7EL8vNq6N+3sVai+9o7 XvFvvAGwHBTbIlcG1bDlFjxB6X6Ae8jsJa/ZY4SWL69yHqotL4h7EiSl+wmhXIC5aHI5 uB8k+vQpwfwH9A1F3G7/g70x+4eu6pf8huk+qhZn2LS5DkcIP3TlwVNXMP5urYatWcQO TPeUrNvpvQ5WeuhMnLES05KaVXwCfA/IYtBiuDZtU9bksgA37qcxe/nZhlDVL1AAMM+/ yheQ== X-Gm-Message-State: AOAM532PIuGWvEM/Ug6MnkeBljB+Tlud0l3T6AaCTbiI0Td41hiQRruh /QovTZfq4MgY9Nh1yqBZ2j2ZEUfsFlEYEw== X-Google-Smtp-Source: ABdhPJwt8pyb/NgnG5RL1tGfNfNpb7cBxHZHZcIZhAfZoOTyec3FhqkaDIQK2Yn/knW3bv+pVKFhcA== X-Received: by 2002:a37:6541:: with SMTP id z62mr49845495qkb.270.1609270508512; Tue, 29 Dec 2020 11:35:08 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id b14sm25383428qtx.36.2020.12.29.11.35.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Dec 2020 11:35:08 -0800 (PST) To: libc-alpha@sourceware.org, Paul Eggert Subject: [PATCH v3 5/6] support: Add support_small_thread_stack_size Date: Tue, 29 Dec 2020 16:34:53 -0300 Message-Id: <20201229193454.34558-6-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201229193454.34558-1-adhemerval.zanella@linaro.org> References: <20201229193454.34558-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.7 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.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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 Netto Reply-To: Adhemerval Zanella Cc: bug-gnulib@gnu.org Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" It returns the minimum stack size large enough to cover most internal glibc stack usage. --- support/support_set_small_thread_stack_size.c | 12 +++++++++--- support/xthread.h | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/support/support_set_small_thread_stack_size.c b/support/support_set_small_thread_stack_size.c index 69d66e97db..74a0e38a72 100644 --- a/support/support_set_small_thread_stack_size.c +++ b/support/support_set_small_thread_stack_size.c @@ -20,8 +20,8 @@ #include #include -void -support_set_small_thread_stack_size (pthread_attr_t *attr) +size_t +support_small_thread_stack_size (void) { /* Some architectures have too small values for PTHREAD_STACK_MIN which cannot be used for creating threads. Ensure that the stack @@ -31,5 +31,11 @@ support_set_small_thread_stack_size (pthread_attr_t *attr) if (stack_size < PTHREAD_STACK_MIN) stack_size = PTHREAD_STACK_MIN; #endif - xpthread_attr_setstacksize (attr, stack_size); + return stack_size; +} + +void +support_set_small_thread_stack_size (pthread_attr_t *attr) +{ + xpthread_attr_setstacksize (attr, support_small_thread_stack_size ()); } diff --git a/support/xthread.h b/support/xthread.h index 05f8d4a7d9..9aeee80032 100644 --- a/support/xthread.h +++ b/support/xthread.h @@ -75,6 +75,8 @@ void xpthread_attr_setstacksize (pthread_attr_t *attr, void xpthread_attr_setguardsize (pthread_attr_t *attr, size_t guardsize); +/* Return the stack size used on support_set_small_thread_stack_size. */ +size_t support_small_thread_stack_size (void); /* Set the stack size in ATTR to a small value, but still large enough to cover most internal glibc stack usage. */ void support_set_small_thread_stack_size (pthread_attr_t *attr);