Received: by 10.192.165.148 with SMTP id m20csp4294456imm; Mon, 30 Apr 2018 15:46:57 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoY4skwKrLQlxUxpnE1m2bZDseO5CI8oRhghLs9DJscmYXY09GBaKU44Dsz9rZ3ZrUlnOHF X-Received: by 2002:a17:902:1025:: with SMTP id b34-v6mr14073888pla.324.1525128417781; Mon, 30 Apr 2018 15:46:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525128417; cv=none; d=google.com; s=arc-20160816; b=PG5xawYwP7dl1XYGdSg4nPNyO1L0t9XxbryxQWcKJkTkjpWNWc65sDewx3YG2Ip3x+ KVOzAXnaxNwj8YreaNOlynmDMEceBx8ulkgwcI1PrN4sGtQ2vI678fDTghCWxCtQsLJk Ka34aHlNDZWUlkW5kCxJiSy7j1HSu+Im06VSf+EZwYcuc7obexE4XHHLckFI0aJdlhFV mQNtR/4ygVRkqVgZZD23e0ostcH/fYztMPgYJwMIU98fL2F0TMD28v5Uux5iZHkkLzqW 9PWXe6Ska82Kqwv+w5WGu2+ruh6wA/jUkiK5kRccNnVKic2m1PGWLIBSZC5dZ1l4iX4r RtsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=22Sx/mBikw2E4CryyxIfd34R97Rq4cF3iMN2wX9OL+A=; b=sO4C3XppDvZkHY6LaeqlHrPILatx1LyQpM/b1sZ33G5haH7trasUrWv6FBx8olp2MK 23nrwmAs/eY9GsST21yVMBJf5sebHq2Aww6+ipbFBa1LDdnSsDeH3gI5Xd8+CxMDwf9A q5knka0WJUIf4kfi2WNPD/oCLV2RrqK3XTFsL+VSjiKaNX+g4C61OEhlLAL53kBjh63b eO6/CS7sxQtmqtsdHVyAkpKUQQw6cVr2suaZrYy62epJRL1H6fWg59jy6pXdTETfHDmk F07jT0X8rn1awPfMh/7Z0ucHEwUN1foSRhYk503C3eC7tkPhRKhhInsvFmrwMlrkDPXo MMHQ== 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 s88si8224842pfa.339.2018.04.30.15.46.43; Mon, 30 Apr 2018 15:46:57 -0700 (PDT) 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 S1755475AbeD3Wot (ORCPT + 99 others); Mon, 30 Apr 2018 18:44:49 -0400 Received: from mail.efficios.com ([167.114.142.138]:52856 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755285AbeD3Woo (ORCPT ); Mon, 30 Apr 2018 18:44:44 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id AB5A41A627C; Mon, 30 Apr 2018 18:44:43 -0400 (EDT) Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail02.efficios.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id CrmXkQSSK9-N; Mon, 30 Apr 2018 18:44:42 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id A7A2C1A625C; Mon, 30 Apr 2018 18:44:42 -0400 (EDT) X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail02.efficios.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 24Qpd0OzffTe; Mon, 30 Apr 2018 18:44:42 -0400 (EDT) Received: from thinkos.internal.efficios.com (192-222-157-41.qc.cable.ebox.net [192.222.157.41]) by mail.efficios.com (Postfix) with ESMTPSA id 460481A6244; Mon, 30 Apr 2018 18:44:42 -0400 (EDT) From: Mathieu Desnoyers To: Peter Zijlstra , "Paul E . McKenney" , Boqun Feng , Andy Lutomirski , Dave Watson Cc: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Paul Turner , Andrew Morton , Russell King , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Andrew Hunter , Andi Kleen , Chris Lameter , Ben Maurer , Steven Rostedt , Josh Triplett , Linus Torvalds , Catalin Marinas , Will Deacon , Michael Kerrisk , Joel Fernandes , Mathieu Desnoyers Subject: [PATCH 01/14] uapi headers: Provide types_32_64.h (v2) Date: Mon, 30 Apr 2018 18:44:20 -0400 Message-Id: <20180430224433.17407-2-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180430224433.17407-1-mathieu.desnoyers@efficios.com> References: <20180430224433.17407-1-mathieu.desnoyers@efficios.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Provide helper macros for fields which represent pointers in kernel-userspace ABI. This facilitates handling of 32-bit user-space by 64-bit kernels by defining those fields as 32-bit 0-padding and 32-bit integer on 32-bit architectures, which allows the kernel to treat those as 64-bit integers. The order of padding and 32-bit integer depends on the endianness. Signed-off-by: Mathieu Desnoyers CC: "Paul E. McKenney" CC: Peter Zijlstra CC: Paul Turner CC: Thomas Gleixner CC: Andrew Hunter CC: Andy Lutomirski CC: Andi Kleen CC: Dave Watson CC: Chris Lameter CC: Ingo Molnar CC: "H. Peter Anvin" CC: Ben Maurer CC: Steven Rostedt CC: Josh Triplett CC: Linus Torvalds CC: Andrew Morton CC: Russell King CC: Catalin Marinas CC: Will Deacon CC: Michael Kerrisk CC: Boqun Feng CC: linux-api@vger.kernel.org --- Changes since v1: - Public uapi headers use __u32 and __u64 rather than uint32_t and uint64_t. --- include/uapi/linux/types_32_64.h | 50 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 include/uapi/linux/types_32_64.h diff --git a/include/uapi/linux/types_32_64.h b/include/uapi/linux/types_32_64.h new file mode 100644 index 000000000000..0a87ace34a57 --- /dev/null +++ b/include/uapi/linux/types_32_64.h @@ -0,0 +1,50 @@ +/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ +#ifndef _UAPI_LINUX_TYPES_32_64_H +#define _UAPI_LINUX_TYPES_32_64_H + +/* + * linux/types_32_64.h + * + * Integer type declaration for pointers across 32-bit and 64-bit systems. + * + * Copyright (c) 2015-2018 Mathieu Desnoyers + */ + +#ifdef __KERNEL__ +# include +#else +# include +#endif + +#include + +#ifdef __BYTE_ORDER +# if (__BYTE_ORDER == __BIG_ENDIAN) +# define LINUX_BYTE_ORDER_BIG_ENDIAN +# else +# define LINUX_BYTE_ORDER_LITTLE_ENDIAN +# endif +#else +# ifdef __BIG_ENDIAN +# define LINUX_BYTE_ORDER_BIG_ENDIAN +# else +# define LINUX_BYTE_ORDER_LITTLE_ENDIAN +# endif +#endif + +#ifdef __LP64__ +# define LINUX_FIELD_u32_u64(field) __u64 field +# define LINUX_FIELD_u32_u64_INIT_ONSTACK(field, v) field = (intptr_t)v +#else +# ifdef LINUX_BYTE_ORDER_BIG_ENDIAN +# define LINUX_FIELD_u32_u64(field) __u32 field ## _padding, field +# define LINUX_FIELD_u32_u64_INIT_ONSTACK(field, v) \ + field ## _padding = 0, field = (intptr_t)v +# else +# define LINUX_FIELD_u32_u64(field) __u32 field, field ## _padding +# define LINUX_FIELD_u32_u64_INIT_ONSTACK(field, v) \ + field = (intptr_t)v, field ## _padding = 0 +# endif +#endif + +#endif /* _UAPI_LINUX_TYPES_32_64_H */ -- 2.11.0