From patchwork Mon Mar 2 08:01:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 444952 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 62F8D1400B6 for ; Mon, 2 Mar 2015 19:03:19 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=sourceware.org header.i=@sourceware.org header.b=Np3/ejsG; dkim-adsp=none (unprotected policy); dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:date:subject:to:message-id; q=dns; s= default; b=Frf8KXPxh1pY0mjugFAEyKFPyW+yTunVTYjz8jkigAOHUnS8GntS6 8eTTTNnEVjU5C3zbtZ9sF8gwqGmgz4T++m+YC2gVbq0iKHvlIGZ5tJ3tRpNxds5Y GfhuupRUYx7dTkvdLNku1oexqz1pwzm0i9vYx5+rX+8MCYSYwrtvwA= 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:from:date:subject:to:message-id; s=default; bh=UP9MaFQkVoxOAWuPjyCK1YS/LUA=; b=Np3/ejsG6i106Gb+kSo7fSP0kFir /iHGp8+7GiaOrHhbqKKdnlFE3GlYB70PqK8lXo8KBtD8zhuXfJkR9AlMuv8qQrT6 WuA36WnKOsfhr7pe0wmLuwgvIsBnL9Lln7epklw6O4uyuLiw0IU2NLDXDE9pBXao U1YSPWs/NUTmKzg= Received: (qmail 38604 invoked by alias); 2 Mar 2015 08:03:12 -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 38592 invoked by uid 89); 2 Mar 2015 08:03:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.0 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com From: Florian Weimer Date: Mon, 2 Mar 2015 09:01:37 +0100 Subject: [PATCH] Add new script add-abilist.py To: libc-alpha@sourceware.org Message-Id: <20150302080300.B464D4242A0BE@oldenburg.str.redhat.com> This script adds new entries to the abilist files, in the right place according to the sorting produced by scripts/abilist.awk. --- scripts/add-abilist.py | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 scripts/add-abilist.py diff --git a/scripts/add-abilist.py b/scripts/add-abilist.py new file mode 100644 index 0000000..3d6b6b8 --- /dev/null +++ b/scripts/add-abilist.py @@ -0,0 +1,93 @@ +#!/usr/bin/python +# Copyright (C) 2015 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see . + +# usage: +# +# python scripts/add-abilist.py GLIBC_X.Y function1 function2 \ +# -- $(find sysdeps/unix -name libc.abilist) +# +# By default, function symbols are added. You can also add arguments +# of the form "variable 0x4" to add symbols for variables. (Note that +# the size may be architecture-specific.) + +import sys + +def parse_arguments(argv): + if len(argv) < 5 or "--" not in argv[3:]: + sys.stderr.write( + "usage: {} VERSION SYMBOL... -- FILES...\n".format(argv[0])) + sys.exit(1) + version = argv[1] + for dashdash in range(2, len(argv)): + if argv[dashdash] == "--": + break + symbols = argv[2:dashdash] + files = argv[dashdash + 1:] + return version, symbols, files +version, symbols, files = parse_arguments(sys.argv) + +def read_file(path): + result = {} + with file(path) as f: + version = None + for line in f: + if line[0] == ' ': + line = line.strip() + assert version is not None + try: + result[version].add(line) + except KeyError: + result[version] = set((line,)) + else: + version = line.strip() + return result + +def write_file(path, versions): + with file(path, "w") as f: + for (version, symbols) in sorted(versions.items()): + f.write("{}\n".format(version)) + for symbol in sorted(symbols): + f.write(" {}\n".format(symbol)) + +def patch_file(path, version, symbols): + file_versions = read_file(path) + changed = [] + try: + version_symbols = file_versions[version] + except KeyError: + version_symbols = set((version + " A",)) + changed.append(version) + file_versions[version] = version_symbols + for symbol in symbols: + if symbol not in version_symbols: + changed.append(symbol) + if " " not in symbols: + symbol += " F" # Mark as function by default + version_symbols.add(symbol) + write_file(path, file_versions) + return tuple(changed) + +previous = () +for path in sorted(files): + if path[:2] == "./": + path = path[2:] + changed = patch_file(path, version, symbols) + if changed == previous: + changed = "Likewise." + else: + previous = changed + changed = "Add {}.".format(", ".join(changed)) + sys.stdout.write("\t* {}: {}\n".format(path, changed))