From patchwork Sun Feb 3 01:10:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 157356 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2261421jaa; Sat, 2 Feb 2019 17:11:44 -0800 (PST) X-Google-Smtp-Source: ALg8bN41SVOBMJgJLuuLhnT2Z8RGBHGXJ1RrqAxUvMa4WTJS2kBQBa1mVUPoMHt6VhLESSnYrQJo X-Received: by 2002:a17:902:f81:: with SMTP id 1mr44385881plz.174.1549156304774; Sat, 02 Feb 2019 17:11:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549156304; cv=none; d=google.com; s=arc-20160816; b=YrhMmN+S7r9fMGpCXlbEptOpjvaA0/krGhOyRHSZ5P/vc4dWZMgiRYZ+VnHVgEk9vq lKWCdIX9DGGJFGy3SpvqFDMs6toSbe3yGCvaZ/p+T6B/aFozRdsZibrvWXip6NLQh097 TE44IqRwi+CXnCYWY24qC0/E0gzUkrYGH+sFbk+fEfqu0iRixsFuHjcutvewr780044u 2kdZZ4C+h3yfngHJh/e4dnygI1iYEVWcShi/zZb/G1EespM/KjKxNC9AkVz+ot3yGBCW SvxhziYTvF2IpefiLehl5dKC7SU8+PVDpSWejpuBdBjxRqdn56DAl3hNbsxbMKOS3l6x 6weA== 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:dkim-signature:dkim-filter; bh=ITMGLYM/7IAMDES5rQP8ldF4uEVSueN3HN2Y7ZH55r4=; b=Rv4DawDWloAodA3i2b30aIMArevxByljJs/eYQYeUEp9NX5LdY1Ngb0jb1asD+Lf0n rmOhKmjQidclcdvs+TsX3uFEgv4LFQHCgqxOusJqxTC5VKogRBXhC74LVKbec2veOEQs QvBYNcREppOOouCD9F1CLtV+KcyR9/g+9/QfOqMdGI8plF1Zrog1ltjT4adVoBH/Nl8V 67X5K8Rr+vx33BQ+vZ2AHexU3NLxyY5L6wYsX80Z6IUW/MjcKAkc17A28ycnPKkIMmOe elxR4yewYeNZXNO1RsHWPRwuFHTtUyDZCl5y6e/pcnIHaWYuee1X8XUk21XkpkvYzyfB pyPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=xGlxSkn1; 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 73si13809607pfm.50.2019.02.02.17.11.44; Sat, 02 Feb 2019 17:11:44 -0800 (PST) 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; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=xGlxSkn1; 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 S1727295AbfBCBL2 (ORCPT + 31 others); Sat, 2 Feb 2019 20:11:28 -0500 Received: from conuserg-12.nifty.com ([210.131.2.79]:38028 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726746AbfBCBL1 (ORCPT ); Sat, 2 Feb 2019 20:11:27 -0500 Received: from grover.tkatk1.zaq.ne.jp (zaqdadce369.zaq.ne.jp [218.220.227.105]) (authenticated) by conuserg-12.nifty.com with ESMTP id x131Ahu7007227; Sun, 3 Feb 2019 10:10:44 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com x131Ahu7007227 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1549156245; bh=ITMGLYM/7IAMDES5rQP8ldF4uEVSueN3HN2Y7ZH55r4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xGlxSkn19cJ/w/YKBclz+tF2j8PuJzfw8Vmc45nuJ+ZLL2QUpJgXayDZ4/nlZ0hx1 F4l0sn+6JyrsVtk5UQQzQPHK1jMnRto9zjAEjpZRB/Faq4bIe+kOYifgIDIp/X2ocz n0TDqVZeW04UoZiar+1kI54dImzaUvN0FgTZ9+WN4eJxW+p9V8btdTLbHXoELdCboC e4MZUX//Z77yq76vH3QjFbSeC5AfWcmfl35uX0S9nltb1iodUzx7y9Z+KmgJJk/tDS C+BXThBJ43kvuaq/NqHqqqqgutxB1Lk+kWHDa/xyl9je5wbu14R9CCwizlkgT+uljp WbmEi4OWbMmUA== X-Nifty-SrcIP: [218.220.227.105] From: Masahiro Yamada To: Andrew Morton Cc: Masahiro Yamada , Alex Elder , Alexey Dobriyan , Zhang Yanmin , linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] linux/kernel.h: split *_MAX and *_MIN macros into Date: Sun, 3 Feb 2019 10:10:42 +0900 Message-Id: <1549156242-20806-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1549156242-20806-1-git-send-email-yamada.masahiro@socionext.com> References: <1549156242-20806-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org tends to be cluttered because we often put various sort of unrelated stuff in it. So, we have split out a sensible chunk of code into a separate header from time to time. This commit splits out the *_MAX and *_MIN defines. The standard header contains various MAX, MIN constants including numerial limits. [1] I think it makes sense to move in-kernel MAX, MIN constants into include/linux/limits.h. We already have include/uapi/linux/limits.h to contain some user-space constants. I changed its include guard to _UAPI_LINUX_LIMITS_H. This change has no impact to the user-space because scripts/headers_install.sh rips off the '_UAPI' prefix from the include guards of exported headers. [1] http://pubs.opengroup.org/onlinepubs/009604499/basedefs/limits.h.html Signed-off-by: Masahiro Yamada Cc: Alex Elder Cc: Alexey Dobriyan Cc: Zhang Yanmin --- Changes in v2: None include/linux/kernel.h | 29 +---------------------------- include/linux/limits.h | 36 ++++++++++++++++++++++++++++++++++++ include/uapi/linux/limits.h | 4 ++-- 3 files changed, 39 insertions(+), 30 deletions(-) create mode 100644 include/linux/limits.h -- 2.7.4 diff --git a/include/linux/kernel.h b/include/linux/kernel.h index afc19d9..b80b965 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -4,6 +4,7 @@ #include +#include #include #include #include @@ -16,34 +17,6 @@ #include #include -#define USHRT_MAX ((unsigned short)~0U) -#define SHRT_MAX ((short)(USHRT_MAX>>1)) -#define SHRT_MIN ((short)(-SHRT_MAX - 1)) -#define INT_MAX ((int)(~0U>>1)) -#define INT_MIN (-INT_MAX - 1) -#define UINT_MAX (~0U) -#define LONG_MAX ((long)(~0UL>>1)) -#define LONG_MIN (-LONG_MAX - 1) -#define ULONG_MAX (~0UL) -#define LLONG_MAX ((long long)(~0ULL>>1)) -#define LLONG_MIN (-LLONG_MAX - 1) -#define ULLONG_MAX (~0ULL) -#define SIZE_MAX (~(size_t)0) -#define PHYS_ADDR_MAX (~(phys_addr_t)0) - -#define U8_MAX ((u8)~0U) -#define S8_MAX ((s8)(U8_MAX>>1)) -#define S8_MIN ((s8)(-S8_MAX - 1)) -#define U16_MAX ((u16)~0U) -#define S16_MAX ((s16)(U16_MAX>>1)) -#define S16_MIN ((s16)(-S16_MAX - 1)) -#define U32_MAX ((u32)~0U) -#define S32_MAX ((s32)(U32_MAX>>1)) -#define S32_MIN ((s32)(-S32_MAX - 1)) -#define U64_MAX ((u64)~0ULL) -#define S64_MAX ((s64)(U64_MAX>>1)) -#define S64_MIN ((s64)(-S64_MAX - 1)) - #define STACK_MAGIC 0xdeadbeef /** diff --git a/include/linux/limits.h b/include/linux/limits.h new file mode 100644 index 0000000..76afcd2 --- /dev/null +++ b/include/linux/limits.h @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_LIMITS_H +#define _LINUX_LIMITS_H + +#include +#include + +#define USHRT_MAX ((unsigned short)~0U) +#define SHRT_MAX ((short)(USHRT_MAX >> 1)) +#define SHRT_MIN ((short)(-SHRT_MAX - 1)) +#define INT_MAX ((int)(~0U >> 1)) +#define INT_MIN (-INT_MAX - 1) +#define UINT_MAX (~0U) +#define LONG_MAX ((long)(~0UL >> 1)) +#define LONG_MIN (-LONG_MAX - 1) +#define ULONG_MAX (~0UL) +#define LLONG_MAX ((long long)(~0ULL >> 1)) +#define LLONG_MIN (-LLONG_MAX - 1) +#define ULLONG_MAX (~0ULL) +#define SIZE_MAX (~(size_t)0) +#define PHYS_ADDR_MAX (~(phys_addr_t)0) + +#define U8_MAX ((u8)~0U) +#define S8_MAX ((s8)(U8_MAX >> 1)) +#define S8_MIN ((s8)(-S8_MAX - 1)) +#define U16_MAX ((u16)~0U) +#define S16_MAX ((s16)(U16_MAX >> 1)) +#define S16_MIN ((s16)(-S16_MAX - 1)) +#define U32_MAX ((u32)~0U) +#define S32_MAX ((s32)(U32_MAX >> 1)) +#define S32_MIN ((s32)(-S32_MAX - 1)) +#define U64_MAX ((u64)~0ULL) +#define S64_MAX ((s64)(U64_MAX >> 1)) +#define S64_MIN ((s64)(-S64_MAX - 1)) + +#endif /* _LINUX_LIMITS_H */ diff --git a/include/uapi/linux/limits.h b/include/uapi/linux/limits.h index c3547f0..6bcbe30 100644 --- a/include/uapi/linux/limits.h +++ b/include/uapi/linux/limits.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -#ifndef _LINUX_LIMITS_H -#define _LINUX_LIMITS_H +#ifndef _UAPI_LINUX_LIMITS_H +#define _UAPI_LINUX_LIMITS_H #define NR_OPEN 1024