Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp770589imu; Thu, 3 Jan 2019 06:52:54 -0800 (PST) X-Google-Smtp-Source: ALg8bN7s9Bld/gcvmEzjrInP4rIL06WctoTJ/4Em/jkaYd90z4fmiMm8rch+ZOZnefd62N3qeVpu X-Received: by 2002:a63:78cd:: with SMTP id t196mr17359768pgc.62.1546527174339; Thu, 03 Jan 2019 06:52:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546527174; cv=none; d=google.com; s=arc-20160816; b=Fx+cArZim3Pl9RDi/bN7evQR63x+txd6Xmc51sWWvpLpbU7RxYnKF9+E2Thgh5bjbo UZasC31riSdqq/ECt4Zq5jZg+U31sn3gK/6IPSYLT7QJL8tKBZH2gA2F48IvezG/Y/Mr p0NfBxlaT0OeIk+5VvZxtK3RtLlQbLMdkPQTC9bkHIYD/RLExq35yNHq8hDPl2uW7PrD y66dcD7MqMI81LqmjOGptXC46pATOfDARK2lNsPZMmaCN24GQTyp47Fszr74zip1I9EQ i3uYbQ/EgpCsZaIMyLLQ8PtrnmP4uvc49MTWRHy+ixgRBZUVKpjYG7HaXU1wozGZG1dt XV5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=yGEN9n6vpOtSoS5EptpZmrhAbVElhR+k177Mo1KISio=; b=KNLvLsxcAITyphiTDWRQHauJAVXPwoqmQA0AX1DXmwHpune6IFNSGN1WQDBHvX/+Id 4J/yRrOx2puZVe2ZiMzsrNcrwAvZxIkez7zQAeEjOHxEDpGNujwKZUUSPdElTw9mdWZe xF4QbqeQeCESPsEIssMzDoO/1gL2b15aK4Qv9dPxRZnJFiraliy2g1Vr++KFF6GRXh9a 98jifgRZPtS9MT2jhaAGderozgalBB4QlJOtolo5snPyGvszN6ajf8etRh+uPFVIHg0+ xeaJ3EFg6OclCvOx49Jupn4dpytr+8YmHs0fvDbzpqNyJ++IInYzNJ1LYM20gGCufFd5 xVKg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q9si15696165pgh.92.2019.01.03.06.52.39; Thu, 03 Jan 2019 06:52:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731145AbfACLek (ORCPT + 99 others); Thu, 3 Jan 2019 06:34:40 -0500 Received: from mail-vs1-f68.google.com ([209.85.217.68]:46672 "EHLO mail-vs1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726814AbfACLej (ORCPT ); Thu, 3 Jan 2019 06:34:39 -0500 Received: by mail-vs1-f68.google.com with SMTP id n10so20550255vso.13; Thu, 03 Jan 2019 03:34:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=yGEN9n6vpOtSoS5EptpZmrhAbVElhR+k177Mo1KISio=; b=AJEfledgGD5h/197bpUXEA2oW/MqMtrcVpIYnqI6rSgaztz3PdKMAcswKWT51iiOwO tXRcPT5Nt26gR+NMcDRqIdlbhW/CJ47CEAaOMluf2EhM+4T9997O5xZrboVBSnSsAkox cSw5yUm9WY1MPk99LLTsvk9yowTVxnwNGeD2Wg07BMtBnJbyy8Z2oHoSd3gZKiwcuP4J G3XNPGSh2WZvCXBrJ72/NoBwR2zq/asMO4w5tDeNznkM9cmydzpkU/9GQkabLIY9JWWe 5UaeYEQQyB2oVZj6AC0jCwup5A/3kZS/GBH1IAJEu12CFZvXoh29bZIij5+kmIGGZLsk 2SBA== X-Gm-Message-State: AA+aEWarke/IDCtPK0TRsOIswosgSkoCPwAKOVZs8DtGDhyJxS9Pw2V4 21EDCIO5FMYgX1uN6HWEOwtDBwP41UWu3i6MCDSDSrUF X-Received: by 2002:a67:c202:: with SMTP id i2mr17067774vsj.11.1546515277324; Thu, 03 Jan 2019 03:34:37 -0800 (PST) MIME-Version: 1.0 References: <1546439331-18646-1-git-send-email-firoz.khan@linaro.org> In-Reply-To: <1546439331-18646-1-git-send-email-firoz.khan@linaro.org> From: Geert Uytterhoeven Date: Thu, 3 Jan 2019 12:34:25 +0100 Message-ID: Subject: Re: [PATCH] scripts: unify system call table generation scripts To: Firoz Khan Cc: Paul Burton , Greg Kroah-Hartman , Philippe Ombredanne , Thomas Gleixner , Kate Stewart , y2038 Mailman List , Linux Kernel Mailing List , Linux-Arch , Arnd Bergmann , Deepa Dinamani , marcin.juszkiewicz@linaro.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Firoz, Thanks for your patch! On Wed, Jan 2, 2019 at 3:30 PM Firoz Khan wrote: > System call table generation support is provided for > alpha, ia64, m68k, microblaze, mips, parisc, powerpc, > sh, sparc and xtensa architectures. The implementat- > ions are almost similar across all the above archte- > ctures. architectures > > In order to reduce the source code across all the > above architectures, create common ".sh" files and > keep it in the common directory, script/. > > This will be a generic scripts which can use for all be generic scripts which can be used for all of > the above architectures. > > Signed-off-by: Firoz Khan > --- > scripts/syscallhdr.sh | 37 +++++++++++++++++++++++++++++++++++++ > scripts/syscallnr.sh | 32 ++++++++++++++++++++++++++++++++ > scripts/syscalltbl.sh | 37 +++++++++++++++++++++++++++++++++++++ > 3 files changed, 106 insertions(+) > create mode 100644 scripts/syscallhdr.sh > create mode 100644 scripts/syscallnr.sh > create mode 100644 scripts/syscalltbl.sh > > diff --git a/scripts/syscallhdr.sh b/scripts/syscallhdr.sh > new file mode 100644 > index 0000000..d03fe3d > --- /dev/null > +++ b/scripts/syscallhdr.sh > @@ -0,0 +1,37 @@ > +#!/bin/sh > +# SPDX-License-Identifier: GPL-2.0 > + > +in="$1" > +out="$2" > +my_abis=`echo "($3)" | tr ',' '|'` > +prefix="$4" > +offset="$5" > + > +fileguard=_UAPI_ASM_`basename "$out" | sed \ Currently, all but MIPS have the architecture name included in the file guard. Shouldn't that be retained? > + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \ > + -e 's/[^A-Z0-9_]/_/g' -e 's/__/_/g'` > +grep -E "^[0-9A-Fa-fXx]+[[:space:]]+${my_abis}" "$in" | sort -n | ( > + printf "#ifndef %s\n" "${fileguard}" > + printf "#define %s\n" "${fileguard}" > + printf "\n" > + > + nxt=0 > + while read nr abi name entry compat ; do > + if [ -z "$offset" ]; then > + printf "#define __NR_%s%s\t%s\n" \ > + "${prefix}" "${name}" "${nr}" > + else > + printf "#define __NR_%s%s\t(%s + %s)\n" \ > + "${prefix}" "${name}" "${offset}" "${nr}" > + fi > + nxt=$((nr+1)) > + done > + > + printf "\n" > + printf "#ifdef __KERNEL__\n" > + printf "#define __NR_syscalls\t%s\n" "${nxt}" > + printf "#endif\n" > + printf "\n" > + printf "#endif /* %s */" "${fileguard}" > + printf "\n" I think this "\n" should be integrated into the previous printf, as it terminates the previous output line. > +) > "$out" > diff --git a/scripts/syscallnr.sh b/scripts/syscallnr.sh > new file mode 100644 > index 0000000..8cf33fa > --- /dev/null > +++ b/scripts/syscallnr.sh > @@ -0,0 +1,32 @@ > +#!/bin/sh > +# SPDX-License-Identifier: GPL-2.0 > + > +in="$1" > +out="$2" > +my_abis=`echo "($3)" | tr ',' '|'` > +prefix="$4" > +offset="$5" > + > +fileguard=_UAPI_ASM_`basename "$out" | sed \ Don't you want the architecture name in the file guard here, too? > + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \ > + -e 's/[^A-Z0-9_]/_/g' -e 's/__/_/g'` > +grep -E "^[0-9A-Fa-fXx]+[[:space:]]+${my_abis}" "$in" | sort -n | ( > + printf "#ifndef %s\n" "${fileguard}" > + printf "#define %s\n" "${fileguard}" > + printf "\n" > + > + nxt=0 > + while read nr abi name entry compat ; do > + nxt=$((nr+1)) > + done > + > + if [ ! -z "$prefix" ]; then > + printf "#define __NR_%s_Linux_syscalls\t%s\n" "${prefix}" "${nxt}" > + if [ ! -z "$offset" ]; then > + printf "#define __NR_%s_Linux\t%s\n" "${prefix}" "${offset}" > + fi > + fi > + printf "\n" > + printf "#endif /* %s */" "${fileguard}" > + printf "\n" > +) > "$out" > diff --git a/scripts/syscalltbl.sh b/scripts/syscalltbl.sh > new file mode 100644 > index 0000000..f60f762 > --- /dev/null > +++ b/scripts/syscalltbl.sh > @@ -0,0 +1,37 @@ > +#!/bin/sh > +# SPDX-License-Identifier: GPL-2.0 > + > +in="$1" > +out="$2" > +my_abis=`echo "($3)" | tr ',' '|'` > +my_abi="$4" > +offset="$5" > + > +emit() { > + t_nxt="$1" > + t_nr="$2" > + t_entry="$3" > + > + while [ $t_nxt -lt $t_nr ]; do > + printf "__SYSCALL(%s,sys_ni_syscall)\n" "${t_nxt}" Please add a space after the comma. > + t_nxt=$((t_nxt+1)) > + done > + printf "__SYSCALL(%s,%s)\n" "${t_nxt}" "${t_entry}" Idem ditto. > +} > + > +grep -E "^[0-9A-Fa-fXx]+[[:space:]]+${my_abis}" "$in" | sort -n | ( > + nxt=0 > + if [ -z "$offset" ]; then > + offset=0 > + fi > + > + while read nr abi name entry compat ; do > + if [ "$my_abi" = "c32" -o "$my_abi" = "64_o32" ] && > + [ ! -z "$compat" ]; then > + emit $((nxt+offset)) $((nr+offset)) $compat > + else > + emit $((nxt+offset)) $((nr+offset)) $entry > + fi > + nxt=$((nr+1)) > + done > +) > "$out" > -- > 1.9.1 > -- Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds