Received: by 10.192.165.156 with SMTP id m28csp2353382imm; Thu, 12 Apr 2018 12:52:34 -0700 (PDT) X-Google-Smtp-Source: AIpwx48HtRNtuJuOVTtGQlTma+WaSz4MBqtHorTdvakO49UQE1WIvE7vChoqrUremUi8ol/NLCYV X-Received: by 10.101.101.15 with SMTP id x15mr1738870pgv.322.1523562754315; Thu, 12 Apr 2018 12:52:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523562754; cv=none; d=google.com; s=arc-20160816; b=eEALJ9rfPerZVypnatij0+7jh/p36qk4AS/aBvasFw5MbwW720reqjJHfLGUQekQLY mquEiDsuQibbGbTXyNdxTFAq3QOZXPqQkVHkZrrcZ6NuH2CHnO3KYZom97LX7V9f8oP0 +dfdGCmGtlRoxhTm0Ot1qrWBV4iCL47O07OEyG7MSVU8H1cUxpXC8G9/MX/kdwWV9/Di UypQhRQOYU7y7vGDihbOCi2yv7IYTpXm94NnCXN1SXmsA0rGTmicSfAebt4szYeiAvkY y5SDxC0ttzW0/fxzK3gUOaftK02faOT/pUEVHktb4RKM13ZjdG/9uNgTohTZoYSuPbG/ eyjQ== 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=mNVWw9mPwQe+TcDjm32wCUvmmBh/3b4nEA+UZ93jgBs=; b=sP9DvEHnwsUx4y12jNCo/L+JH/ciGQJR2og7ybsvv6WDjt7umHuhDVwF+IDgIIbSdS aqp9TTWJYfV80X79iOegMXLMe/7UeqINF4w9QgwV9I8tbvWMhlXHuuYGaLwcOucUq5pr n5wDDGQOOv8jGyPBImU9dEKoXts3ZoJgVQ3Oxr65s8KlUSOuID+MlRbtftYavEv7mnEg LRPbu7W/Vh0MIbLnv16g1kQ7IUrgRouqYm5F3gqb/U9e07UsPxbk0Qm94A3/JsOTVfcW 8qKOSjBxeatnBWvM1ZraT/vmEz2B/M0DATAsgc2CMBrIQsjbi/xqC8rFhiUK1c8HVYfa KoSQ== 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 t3si2634974pgc.87.2018.04.12.12.52.20; Thu, 12 Apr 2018 12:52:34 -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 S1753398AbeDLT2Z (ORCPT + 99 others); Thu, 12 Apr 2018 15:28:25 -0400 Received: from mail.efficios.com ([167.114.142.138]:45450 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752900AbeDLT2V (ORCPT ); Thu, 12 Apr 2018 15:28:21 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id B34D31B0690; Thu, 12 Apr 2018 15:28:20 -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 uwUTWtmULtNJ; Thu, 12 Apr 2018 15:28:19 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id E11F51B067A; Thu, 12 Apr 2018 15:28:19 -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 8bR974-Suefc; Thu, 12 Apr 2018 15:28:19 -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 8A4201B066D; Thu, 12 Apr 2018 15:28:19 -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 , Mathieu Desnoyers Subject: [RFC PATCH for 4.18 01/23] uapi headers: Provide types_32_64.h (v2) Date: Thu, 12 Apr 2018 15:27:38 -0400 Message-Id: <20180412192800.15708-2-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180412192800.15708-1-mathieu.desnoyers@efficios.com> References: <20180412192800.15708-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 | 67 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 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..fc9602c318cd --- /dev/null +++ b/include/uapi/linux/types_32_64.h @@ -0,0 +1,67 @@ +#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-2017 Mathieu Desnoyers + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#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