From patchwork Mon Jul 11 22:06:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 13740 Received: (qmail 102071 invoked by alias); 11 Jul 2016 22:06:56 -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 102061 invoked by uid 89); 11 Jul 2016 22:06:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2542, cmetcalf@mellanox.com, cmetcalfmellanoxcom X-HELO: mail-qk0-f196.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Zqvkpfn8+wNc0S/YgZIaG9WjNO37dj4ipvNG73JUjqg=; b=m7uNLkfbGr38ROgR0jPa484ajMVw5XW/2+fN+mAhTuKd4xqgA8XPUdiuI+M3m5LrsZ bvlIqd2Tl3btBkEXDHVGv8kYE6KwTvU9NDxOVVRj8KIeIeQVhgMhu6KZwfyDkfC9VZAi R6ErSJul3kSa2vAtHOg+g7NMKWTeqFNWO7VsoJCFBFMwAQfgK14nJt74M+9W0rr4KHuz toD9xGtz3ekZqUQpaA9YtzlXY4mnPfqMWLSRhVrRC0M3KjCP9gNQrqNbIaCtglH05LeK Rwr5XpnpMqDs0A0m95evw4rznKXqSPmGyaSXyF/w9BewzGdAlVARzaOM9kYfbduP3HFp jR0g== X-Gm-Message-State: ALyK8tKftdepxpJQATw3T7IPZWVroxyCh2VuEWlbhqKfurZ+8EgjfK3xHJv2QnnQ7fWb0VSN4wiFdBopv3us+w== X-Received: by 10.55.105.5 with SMTP id e5mr28746195qkc.192.1468274803268; Mon, 11 Jul 2016 15:06:43 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <20160711192653.GA4457@intel.com> <4067a9a1-f91a-3820-5878-b906a3f0f76d@mellanox.com> From: "H.J. Lu" Date: Mon, 11 Jul 2016 15:06:42 -0700 Message-ID: Subject: Re: [PATCH] Use SYSCALL_LL[64] to pass 64-bit value [BZ #20349] To: Chris Metcalf Cc: GNU C Library On Mon, Jul 11, 2016 at 2:04 PM, H.J. Lu wrote: > On Mon, Jul 11, 2016 at 1:36 PM, Chris Metcalf wrote: >> On 7/11/2016 3:26 PM, H.J. Lu wrote: >>> >>> SYSCALL_LL/SYSCALL_LL64 should be used to pass 64-bit value to system >>> calls. >> >> >> What problem are you trying to solve? >> >> SYSCALL_LL and LO_HI_LONG are different on big-endian systems. In this >> case, LO_HI_LONG is correct, since the kernel API is "unsigned long pos_l, >> unsigned long pos_h". SYSCALL_LL won't do the right thing. >> >> __ALIGNMENT_ARG introduces an extra dummy arguments to be inserted before >> a 64-bit value split into two 32-bit registers, if required by the platform. >> Since preadv/pwritev explicitly use split arguments to construct a 64-bit >> loff_t, __ALIGNMENT_ARG will just add a random inappropriate dummy arg >> to an API that doesn't need one. >> >> I reviewed the casting for LO_HI_LONG and it looks OK; I initially was >> wondering whether losing the "val >> 31, val" semantics from SYSCALL_LL() >> might have been problematic, but it seems like LO_HI_LONG should generate >> the same results. >> > > /* Provide a macro to pass the off{64}_t argument on p{readv,writev}{64}. */ > #define LO_HI_LONG(val) \ > (long) (val), \ > (long) (((uint64_t) (val)) >> 32) > > is wrong for __ASSUME_WORDSIZE64_ILP32 platform. > I am testing this. From 4124e3305bdf0060d3766486673ad0dd29a3a727 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Mon, 11 Jul 2016 14:56:33 -0700 Subject: [PATCH] X86-64: Define LO_HI_LONG to skip pos_h [BZ #20349] Define LO_HI_LONG to skip pos_h since it is ignored by kernel: static inline loff_t pos_from_hilo(unsigned long high, unsigned long low) { #define HALF_LONG_BITS (BITS_PER_LONG / 2) return (((loff_t)high << HALF_LONG_BITS) << HALF_LONG_BITS) | low; } where size of loff_t == size of long. [BZ #20349] * sysdeps/unix/sysv/linux/x86_64/sysdep.h (LO_HI_LONG): New. --- sysdeps/unix/sysv/linux/x86_64/sysdep.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h index d023d68..1a671e1 100644 --- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h +++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h @@ -385,4 +385,8 @@ # endif #endif +/* How to pass the off{64}_t argument on p{readv,writev}{64}. */ +#undef LO_HI_LONG +#define LO_HI_LONG(val) (val) + #endif /* linux/x86_64/sysdep.h */ -- 2.7.4