From patchwork Tue Sep 30 18:40:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Serebryany X-Patchwork-Id: 395067 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 6E28F1400A3 for ; Wed, 1 Oct 2014 04:41:18 +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=sJCWxn/GBCSQlEmryOzpp78ZuXkZm +OiYX8bSHpKtjIacnR1okL9V6x+t09J5m64kIH6gtDoUu1GIWYiLffKN6ADDwh36 FHt2UMWapTTwfwVLvZc7r4SfYDNlY1dmrg3IieGQDp8f+Up3ZUjdGoW6yLKjPO9a CESl6I5ybJMjr4= 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=3IfTdYbSWvCs0FNubSHP7SLpMwI=; b=qqO LnGgWtrdeoQexHbRJwh+0xD6BUKNU7Kzmn1gCGaly6gAgp13zNh9xpdsNqLX0buy 1hyRmtnLKqLO+39JZ2TOq3zfAVR1ynCjdUoeqfk4dxg1jN8/SQooirwnLsBQcVK0 4EF0+Ro9PO3jXRcWlHlorSjIqi3zN5H+0zA1zFto= Received: (qmail 28414 invoked by alias); 30 Sep 2014 18:41:08 -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 28354 invoked by uid 89); 30 Sep 2014 18:41:07 -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-f169.google.com X-Received: by 10.220.142.196 with SMTP id r4mr2781584vcu.63.1412102464550; Tue, 30 Sep 2014 11:41:04 -0700 (PDT) MIME-Version: 1.0 From: Konstantin Serebryany Date: Tue, 30 Sep 2014 11:40:43 -0700 Message-ID: Subject: [PATCH] remove nested functions from elf/dl-deps.c To: Roland McGrath , GNU C Library Hi, Please review the patch that removes nested functions from elf/dl-deps.c The patch does not noticeably affect the generated code (the new code is 2 instructions shorter, a few differences in used registers, offsets, etc). The function is inlined in both cases. No regressions in 'make check' on x86_64-linux-gnu (Ubuntu 14.04) 2014-09-30 Kostya Serebryany * elf/dl-deps.c (preload): New functions broken out of _dl_map_object_deps. (_dl_map_object_deps): Remove a nested function. Update call sites. --kcc diff --git a/elf/dl-deps.c b/elf/dl-deps.c index c3b0cfc..c4824d1 100644 --- a/elf/dl-deps.c +++ b/elf/dl-deps.c @@ -138,6 +138,19 @@ cannot load auxiliary `%s' because of empty dynamic string token " \ \ __result; }) +static inline +void preload (struct link_map *map, struct list *known, unsigned int *nlist) +{ + known[*nlist].done = 0; + known[*nlist].map = map; + known[*nlist].next = &known[*nlist + 1]; + + ++(*nlist); + /* We use `l_reserved' as a mark bit to detect objects we have + already put in the search list and avoid adding duplicate + elements later in the list. */ + map->l_reserved = 1; +} void internal_function @@ -155,28 +168,15 @@ _dl_map_object_deps (struct link_map *map, const char *errstring; const char *objname; - void preload (struct link_map *map) - { - known[nlist].done = 0; - known[nlist].map = map; - known[nlist].next = &known[nlist + 1]; - - ++nlist; - /* We use `l_reserved' as a mark bit to detect objects we have - already put in the search list and avoid adding duplicate - elements later in the list. */ - map->l_reserved = 1; - } - /* No loaded object so far. */ nlist = 0; /* First load MAP itself. */ - preload (map); + preload (map, known, &nlist); /* Add the preloaded items after MAP but before any of its dependencies. */ for (i = 0; i < npreloads; ++i) - preload (preloads[i]); + preload (preloads[i], known, &nlist); /* Terminate the lists. */ known[nlist - 1].next = NULL;