From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/10015 Path: news.gmane.org!not-for-mail From: Bobby Bingham Newsgroups: gmane.linux.lib.musl.general Subject: Deduplicating __NR_* and SYS_* syscall defines Date: Mon, 9 May 2016 19:26:37 -0500 Message-ID: <20160510002637.GA21262@dora.lan> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 X-Trace: ger.gmane.org 1462840022 17226 80.91.229.3 (10 May 2016 00:27:02 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 10 May 2016 00:27:02 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-10028-gllmg-musl=m.gmane.org@lists.openwall.com Tue May 10 02:27:01 2016 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1azvVs-0006CV-23 for gllmg-musl@m.gmane.org; Tue, 10 May 2016 02:27:00 +0200 Original-Received: (qmail 7777 invoked by uid 550); 10 May 2016 00:26:56 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 7735 invoked from network); 10 May 2016 00:26:51 -0000 Content-Disposition: inline X-Operating-System: Linux dora 4.3.3 User-Agent: Mutt/1.6.0 (2016-04-01) Xref: news.gmane.org gmane.linux.lib.musl.general:10015 Archived-At: During the powerpc64 review, Rich mentioned wanting to replace the arch/*/bits/syscall.h files with .in files that would be preprocessed with something like: sed -e p -e s/__NR_/SYS_/ < $< > $@ This would eliminate a lot of intra-file duplication here. I took a look, and this won't quite work as-is, because the following lines in the arm version would end up outputting duplicate definitions: #define __ARM_NR_breakpoint 0x0f0001 #define __ARM_NR_cacheflush 0x0f0002 #define __ARM_NR_usr26 0x0f0003 #define __ARM_NR_usr32 0x0f0004 #define __ARM_NR_set_tls 0x0f0005 Same thing for this line in x32: #define __X32_SYSCALL_BIT 0x40000000 I'm thinking something like the following awk script would work: { print } $1 ~ /^#(define|undef)$/ && $2 ~ /^__NR_/ { sub(/__NR_/, "SYS_", $2) print } The handling for #undef is for the x32 file. It looks like only the `#undef __NR_getdents' in that file is actually necessary, and even that could be avoided by just omitting the earlier line: #define __NR_getdents (__X32_SYSCALL_BIT + 78) So maybe we can get rid of the #undefs there, and simplify the awk script accordingly. Thoughts on this approach? If this sounds ok, I'll submit a patch. -- Bobby