From patchwork Sat Feb 2 16:06:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 157348 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1854476jaa; Sat, 2 Feb 2019 08:07:10 -0800 (PST) X-Google-Smtp-Source: ALg8bN4H/+RCpG+dRy6ZcBPw9kLyPS6HTxLtjudk/xG21E1Q1ptAUfrQzttLO1WyHTDPeA5JJzX0 X-Received: by 2002:a62:2082:: with SMTP id m2mr43102415pfj.163.1549123630227; Sat, 02 Feb 2019 08:07:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549123630; cv=none; d=google.com; s=arc-20160816; b=eCyJ2kweA6ifYuy9H0bwJTeaP6afo3DLtcXNgZsrM3uRYoCoAoHHp5CZvSNnPxQ5UO jC243YMYeLdjbIMdRb6ZsRROv3e1gbSNZ/oq+WIABayxOmofGHM3I52mXQlh5YBQMz8n 7TaprX+SnfH39NOR8hHzlUhRmgiBbsm8mr+mhkbx+v5SUAXtA5eMT4Jzyvyh06L8AS7h RXZ+ob80yPO6RNVDvsHKBN5DKmrEL+PPFv/nkM+3auhmcu0NwxBl0c+8jAA9dHpzJpyM pO71Y9V+I1T3qdBuIMaM/GbGorDqWFScePdcrgVOyefqyD7I5OzweSfFNCLgyVDvb1TH sJ7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=JwopK9+7lX0V7SLAw43HF2FU5AbmP5n4htsIsh/Ga6s=; b=Fm8t8K8EU1JSQIKzE7eOn95XveC1ytM084EcR0s9I/0sf8+TW18a/94UB5BYYAM+ZE mLZUIW1hgDuUop6wIP/rvzE5zUPMVz9dHMvkpKG+P3ZXRUQSYw3kp8sFTrLeVARzazuF yN23/HfO72qgmBaRnRDC1Tzj7b8Y9tEs0Hxcfp3/4qq8JYFTzdVz9yLrLwuj+hf6siP8 eaxS6gVaKzeRBv9KYBoMK9+Ay16A1vUPGg/JdFcNWYrzD3vw9ClJ266/eH4XxUqGDaor 6Oj6mlfSCnuHcSWMojee1aC1GuLK3PobPYeOZ8Eu+tY/OXba1Otn6jw9VnyxnjEdlcLh fktQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b="lGKcH/eL"; 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 d16si10644714pfn.169.2019.02.02.08.07.09; Sat, 02 Feb 2019 08:07:10 -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="lGKcH/eL"; 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 S1728203AbfBBQHI (ORCPT + 31 others); Sat, 2 Feb 2019 11:07:08 -0500 Received: from conuserg-12.nifty.com ([210.131.2.79]:20935 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727843AbfBBQHH (ORCPT ); Sat, 2 Feb 2019 11:07:07 -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 x12G6SvN022387; Sun, 3 Feb 2019 01:06:29 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com x12G6SvN022387 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1549123589; bh=JwopK9+7lX0V7SLAw43HF2FU5AbmP5n4htsIsh/Ga6s=; h=From:To:Cc:Subject:Date:From; b=lGKcH/eLdz2aFQfKfB0EGHjSN+x0exJEefHg9Gtewshe/jWDIP81Lknur8S9jawkT PSk1yUWaau4zOXwFEGFFq6PdkmntAafmhE1hk9jBJboDJnchvDSbdznnSrEo/2bMVP XVSF7SWCMS/xPq+XS8C5YjNQVJJCZEMPg30SrzCU+O+gKuObgrcr65tohlkFzIJ0bQ Pu4RW1+8TAXILYrR08EJLFpBySNEXqZ9hrcIkhBCnNMeyVYvsRZfhuAvLa6Kea6l99 qB6i/2clzyJitQexHn2KnWSolMP9SdNGNYjcnEkFTdIudbmbUfcrE4/g3kOrrnrUP8 oGBS0gc34Nchw== X-Nifty-SrcIP: [218.220.227.105] From: Masahiro Yamada To: Andrew Morton Cc: Masahiro Yamada , Alexey Dobriyan , Zhang Yanmin , linux-kernel@vger.kernel.org Subject: [PATCH 1/2] linux/kernel.h: use 'short' to define USHRT_MAX, SHRT_MAX, SHRT_MIN Date: Sun, 3 Feb 2019 01:06:24 +0900 Message-Id: <1549123585-13800-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The log of commit 44f564a4bf6a ("ipc: add definitions of USHORT_MAX and others") did not explain why it used (s16) and (u16) instead of (short) and (unsigned short). Let's use (short) and (unsigned short), which is more sensible, and more consistent with the other MAX/MIN defines. As you see in include/uapi/asm-generic/int-ll64.h, s16/u16 are typedef'ed as signed/unsigned short. So, this commit does not have a functional change. Signed-off-by: Masahiro Yamada Cc: Alexey Dobriyan Cc: Zhang Yanmin --- include/linux/kernel.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 8f0e68e..110bac1 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -16,9 +16,9 @@ #include #include -#define USHRT_MAX ((u16)(~0U)) -#define SHRT_MAX ((s16)(USHRT_MAX>>1)) -#define SHRT_MIN ((s16)(-SHRT_MAX - 1)) +#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) From patchwork Sat Feb 2 16:06:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 157349 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1854711jaa; Sat, 2 Feb 2019 08:07:21 -0800 (PST) X-Google-Smtp-Source: AHgI3IbAR60G8BlS/m8+owEVcDNGoQhyDg1smE79Wcx9m5ZTcwr+DUeDlCAGmG03KQvnI5puNqPm X-Received: by 2002:a17:902:778b:: with SMTP id o11mr2091611pll.90.1549123641106; Sat, 02 Feb 2019 08:07:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549123641; cv=none; d=google.com; s=arc-20160816; b=1IUutAo8U7EbIBceGP/Q5rEWTnDsr9Ptk2PTyTRStro/jMcaRU8I/zJd2TOnCfbJ91 YDSTGlmW1i02WCWZX7cMrveZc8U8Sxrl3KgzjX1585QJNEcQzPalJmsVGmNhQq+YxRv/ hPD/xBI3PcNtOzvj9X84TlhiAtZ7So7Dx76iiFVFwxLglhAK9mRW2vS0BFcjsZlaMMkH bGLXMmkD7pFx2sFw2ADB/p0XAD9ReSTw0wmJNm6TOOh0NJdlXuUb32AWzF5STxw7Gqor 9y+Y8IUlhpIPO3wAAVYhCMjC0aZx2Q5aAEXp37QI6gAI3dBAGuBhhbzFmA9uM9lXDfsD VjfQ== 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=kYnafPl0RddfLsUZ65qo2ZmuBPvqJnmVRX8/uu8wmrc=; b=UyMCeCKRGikKPgG749EGLpZEo8MCXpgN0/QvPpnige4AjKe08zJ4l/dLze9RMElhiz yTBS7IkyWsfbhFpW+hWLMpQbE0Yacklqp7n3LS3hRiMFij7Ec4DOoSFQZdX/5Zr2dvPM w1H+j81CmH7FT7P3yYYMrRUBAbSl+sO7yOkoXl7np2d6MMk30iRu4IHEKcC30xoUxqlb vKsIQM73wPT6SX8DQSmLh4DVYpD4jFt0VqoxIHT2yhxiMCACcDBiva3Bax0GcdRsUjw+ nauWXMCZhTkdbXUgJHVpu0iPQEmJYK5xo6dZx9qFxiIOVapuxx0IsJhOZ+kk6DPc53s+ 1O8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=SVdwtRih; 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 d16si10644714pfn.169.2019.02.02.08.07.20; Sat, 02 Feb 2019 08:07:21 -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=SVdwtRih; 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 S1728289AbfBBQHT (ORCPT + 31 others); Sat, 2 Feb 2019 11:07:19 -0500 Received: from conuserg-12.nifty.com ([210.131.2.79]:21080 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728159AbfBBQHQ (ORCPT ); Sat, 2 Feb 2019 11:07:16 -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 x12G6SvO022387; Sun, 3 Feb 2019 01:06:29 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com x12G6SvO022387 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1549123590; bh=kYnafPl0RddfLsUZ65qo2ZmuBPvqJnmVRX8/uu8wmrc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SVdwtRihI1bXSD4HB5uT7OOLoRIoebYIIhRRW26ed+/3CpgxcsggY1zsg7Ad1jetr IBKk29bAb7HIas9zFX+jZHYEIGBnfCQZ+LQ5xURxKSgeNyBoq7cTeDaT4YBlsbQmFR wRQvDHI7yOKnWkYvqt06i7Fakipr8pH6RPGQgpolLRvYHGBGP5zmJr7DcIFgwj5/9R r7EHb3uhQsFpo5OL1HfwXcWU3vjGUGnb1Dc3he4VaQ4r/kawVL8vUaN2ZjDioP6fHO X8XlsL7YewYv61fZuyPohHEVrT1dvH0d1zeIi3BACuGZlHkXS5x2OrmUc1mKeC5LYM 0UT5J00buzdAg== 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 2/2] linux/kernel.h: split *_MAX and *_MIN macros into Date: Sun, 3 Feb 2019 01:06:25 +0900 Message-Id: <1549123585-13800-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1549123585-13800-1-git-send-email-yamada.masahiro@socionext.com> References: <1549123585-13800-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] So, 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 --- 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 110bac1..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..01aeb53 --- /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