From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/10028 Path: news.gmane.org!not-for-mail From: Bobby Bingham Newsgroups: gmane.linux.lib.musl.general Subject: Re: Deduplicating __NR_* and SYS_* syscall defines Date: Wed, 11 May 2016 22:56:57 -0500 Message-ID: <20160512035657.GB23989@dora.lan> References: <20160510002637.GA21262@dora.lan> <20160511215311.GI21636@brightrain.aerifal.cx> <20160512002230.GA23989@dora.lan> <20160512005712.GK21636@brightrain.aerifal.cx> 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 1463025435 24366 80.91.229.3 (12 May 2016 03:57:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 12 May 2016 03:57:15 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-10041-gllmg-musl=m.gmane.org@lists.openwall.com Thu May 12 05:57:15 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 1b0hkQ-0003uf-If for gllmg-musl@m.gmane.org; Thu, 12 May 2016 05:57:14 +0200 Original-Received: (qmail 14332 invoked by uid 550); 12 May 2016 03:57:11 -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 14314 invoked from network); 12 May 2016 03:57:11 -0000 Content-Disposition: inline In-Reply-To: <20160512005712.GK21636@brightrain.aerifal.cx> 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:10028 Archived-At: On Wed, May 11, 2016 at 08:57:12PM -0400, Rich Felker wrote: > The p command just prints the pattern space. The trick is that we > print it an extra time before the s command, but only if the line > matches something the s command is going to change. > > > Any objection to using Alexander's approach to avoid interleaving the > > __NR_* and SYS_* lines? > > I'm indifferent to the interleaving, but if we take that approach, we > should make sure that the rules are written such that interrupting the > make process between the commands doesn't leave a partial file that > subsequent runs of make think is complete. It might be ok as-is if > make automatically deletes the target on error producing it; otherwise > we might need a temp file that's moved into place at the end. I always > forge how this aspect of make works... Make does what you want by default. https://www.gnu.org/software/make/manual/html_node/Interrupts.html > > > > > Same thing for this line in x32: > > > > > > > > #define __X32_SYSCALL_BIT 0x40000000 > > > > > > In general we've tried to eliminate this sort of macro and direct-code > > > the values. I would be in favor of doing the same for x32 I think. But > > > with my fixed sed command (above) I think that change is unnecssary > > > and orthogonal to the deduplication. > > > > I'll submit a separate patch to clean this up. > > Any thoughts on how it should be done? If it were a clean decimal > constant like on mips I'd just write each as a single integer literal > (e.g. 6001, etc.) but since the syscall numbers are normally thought > of as decimal whereas the x32 offset is hex/bit value, it seems + or | > is still needed. I agree. I was planning to use +. > > > > > 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) > > > > > > I don't see why any #undef is needed here; this looks like leftover > > > cruft that was not properly cleaned up. All the logic for replacing > > > syscall numbers belongs in src/internal/syscall.h or > > > arch/$ARCH/syscall_arch.h, I think. > > > > Ok. > > Can you verify that removing these #undef-and-redefine lines from the > bits header doesn't change the result (i.e. it's redundant with other > files) for building libc? I just verified, the generated code for libc is the same either way. > > > > > 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. > > > > > > I'd rather use sed than awk if possible since it's more universally > > > available and understood. > > > > I must be the exception then :) > > :-) > > Rich