From patchwork Tue Jun 11 23:29:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: DJ Delorie X-Patchwork-Id: 1946591 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=dcHUtEKh; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VzPzd5WLBz20Pb for ; Wed, 12 Jun 2024 09:30:21 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ED1473858410 for ; Tue, 11 Jun 2024 23:30:18 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 03B083858D39 for ; Tue, 11 Jun 2024 23:30:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 03B083858D39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 03B083858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718148604; cv=none; b=Bgno5GzYQUnugHs+++0xoXc4AAwMOepN+/YhYs7W9ulV/MvwHc7Ee3EwsdSqu0CUOl/Awa6tonQ4znNQOP64mAXo1xNNh+0QFm9JjxIUDR1XsOVj96VJ2ki91MS6HVyl0tTbp7iKvCAjawhbXOxpzxtNGKeEtJufBvTDHkQpPfk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718148604; c=relaxed/simple; bh=JtNABk1B38ZIWSSLAUHNN/MHGeDsg41zcwWeHAAzf6U=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=A9qR+NLBxDs6akMu/bNa2w8KP6TvYEfrqqZSZH0qLjQaJ77VqDDbt1ea9IOb7M5UF+D9dP8foMqEQTGK1spLJ/kSQmdENVxG2Gn/c6k8PCa/vNAwnr2ZnxGJ66z+tsL20xABE71CBr2MwZPWB9xEvmhVivuVFh0rvhfbOTzQ3AA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718148602; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=KhwWsWwnGVQc5NHngBUKftchc7YbBRjYJbrzv1Dpjcs=; b=dcHUtEKhsNrDwKX0mUqQgwVNYUmvqJk3lTQhnvZX/AxNi9dKOgTAFiqnKTjbpFOR4jT2zT 0EdxmnG2ECsjqQ8ICe+rfM0JKohXADjW2q7pCgkZoV6V35nfv1LTzDS0Gj/yVCEwDXs5W3 6gyta7XAa5Z1tjbAcFvfyZRZtXAgoIs= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-480-SJm39DBsNkuSmxhNPJjKCA-1; Tue, 11 Jun 2024 19:30:01 -0400 X-MC-Unique: SJm39DBsNkuSmxhNPJjKCA-1 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 32BA9195608D for ; Tue, 11 Jun 2024 23:30:00 +0000 (UTC) Received: from greed.delorie.com (unknown [10.22.8.94]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BC71B19560AA; Tue, 11 Jun 2024 23:29:59 +0000 (UTC) Received: from greed.delorie.com.redhat.com (localhost [127.0.0.1]) by greed.delorie.com (8.16.1/8.16.1) with ESMTP id 45BNTsbc1409496; Tue, 11 Jun 2024 19:29:54 -0400 From: DJ Delorie To: Florian Weimer Cc: libc-alpha@sourceware.org Subject: tunables: sort tunables list Date: Tue, 11 Jun 2024 19:29:54 -0400 Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-9.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, RCVD_IN_SBL_CSS, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Florian Weimer writes: > Can we sort during generation of dl-tunable_list.h? > It would fix bug 30027, too. How about this? diff --git a/scripts/gen-tunables.awk b/scripts/gen-tunables.awk index fc3b41376f..548f597fed 100644 --- a/scripts/gen-tunables.awk +++ b/scripts/gen-tunables.awk @@ -131,6 +131,25 @@ END { exit 1 } + # TYPES is an associative array where the index is the data + # TYPESA is an indexed array where the value is the data + # We sort TYPESA + typecount = 0 + for (tnm in types) { + typesa[typecount] = tnm; + typecount ++ + } + # bubble sort is good enough, and more portable than GAWK's sorti() + for (i = 0; i < typecount - 1; i ++) { + for (j = i + 1; j < typecount; j ++) { + if (typesa[i] > typesa[j]) { + temp = typesa[i]; + typesa[i] = typesa[j]; + typesa[j] = temp; + } + } + } + print "/* AUTOGENERATED by gen-tunables.awk. */" print "#ifndef _TUNABLES_H_" print "# error \"Do not include this file directly.\"" @@ -141,7 +160,8 @@ END { # Now, the enum names print "\ntypedef enum" print "{" - for (tnm in types) { + for (i = 0; i < typecount; i++) { + tnm = typesa[i]; split (tnm, indices, SUBSEP); t = indices[1]; n = indices[2]; @@ -157,7 +177,8 @@ END { print "# include \"dl-tunable-types.h\"" # Finally, the tunable list. print "static tunable_t tunable_list[] attribute_relro __attribute_used__ = {" - for (tnm in types) { + for (i = 0; i < typecount; i++) { + tnm = typesa[i]; split (tnm, indices, SUBSEP); t = indices[1]; n = indices[2]; @@ -172,7 +193,8 @@ END { # Map of tunable with environment variables aliases used during parsing. */ print "\nstatic const tunable_id_t tunable_env_alias_list[] =" printf "{\n" - for (tnm in types) { + for (i = 0; i < typecount; i++) { + tnm = typesa[i]; split (tnm, indices, SUBSEP); t = indices[1]; n = indices[2];