From patchwork Wed Jun 4 08:01:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Serebryany X-Patchwork-Id: 355754 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E33CC14007B for ; Wed, 4 Jun 2014 18:02:00 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:from:date:message-id:subject:to :content-type; q=dns; s=default; b=jE2lR2yQi83XfCap9gmfDz+heBXOE Wt3wpUdEotyBBBOVedqR3MTREEJ07mRhFzOC/WA5silYBXxG2lKBEBGlziUXJeMJ hVRdAGIA/mtn9ZuCXtFboFJ4VR48omovhomkyFdeyhqVO2alFYE1gd4xJsy9m2Ev n4LDdCSrBKjmz8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:from:date:message-id:subject:to :content-type; s=default; bh=caxERXFRqmpuXJNyCKEAof24vJo=; b=QUP SXk68RxDoE5f34RPQTMjs1aaHDWR4B0NIp1Gv/K6BtKjd6DAfjkH0Rz4bAXRDa3D BO+xuFqxiDJuUPFmJzs/HyIrbmT19Ugg5wPgiXXIrc8GZcUktdSbnEeb7mGyicMX JslWWn3ZfYHA20VG5dKpX1N7g4Mws+a63ZEt3+jk= Received: (qmail 4227 invoked by alias); 4 Jun 2014 08:01:54 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 4212 invoked by uid 89); 4 Jun 2014 08:01:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-vc0-f176.google.com X-Received: by 10.58.39.98 with SMTP id o2mr218149vek.75.1401868905309; Wed, 04 Jun 2014 01:01:45 -0700 (PDT) MIME-Version: 1.0 From: Konstantin Serebryany Date: Wed, 4 Jun 2014 12:01:24 +0400 Message-ID: Subject: [PATCH] remove one nested function from nptl/allocatestack.c To: GNU C Library Please review a patch to remove the use of a nested function. No functionality change intended. The removal of nested functions was previously discussed here: https://sourceware.org/ml/libc-alpha/2014-05/msg00400.html 2014-06-04 Kostya Serebryany * nptl/allocatestack.c (check_list): New function. (__reclaim_stacks): Remove the nested check_list function, and use the static check_list instead. diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c index 1e22f7d..7368701 100644 --- a/nptl/allocatestack.c +++ b/nptl/allocatestack.c @@ -809,6 +809,24 @@ __make_stacks_executable (void **stack_endp) return err; } +/* We always add at the beginning of the list. So in this + case we only need to check the beginning of these lists. */ +static int +check_list (list_t *l, list_t *elem) +{ + if (l->next->prev != l) + { + assert (l->next->prev == elem); + + elem->next = l->next; + elem->prev = l; + l->next = elem; + + return 1; + } + + return 0; +} /* In case of a fork() call the memory allocation in the child will be the same but only one thread is running. All stacks except that of @@ -830,26 +848,8 @@ __reclaim_stacks (void) if (add_p) { - /* We always add at the beginning of the list. So in this - case we only need to check the beginning of these lists. */ - int check_list (list_t *l) - { - if (l->next->prev != l) - { - assert (l->next->prev == elem); - - elem->next = l->next; - elem->prev = l; - l->next = elem; - - return 1; - } - - return 0; - } - - if (check_list (&stack_used) == 0) - (void) check_list (&stack_cache); + if (check_list (&stack_used, elem) == 0) + (void) check_list (&stack_cache, elem); } else {