From patchwork Mon Jan 27 22:15:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 23762 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f72.google.com (mail-vb0-f72.google.com [209.85.212.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A0FF220300 for ; Mon, 27 Jan 2014 22:15:42 +0000 (UTC) Received: by mail-vb0-f72.google.com with SMTP id w20sf12839221vbb.3 for ; Mon, 27 Jan 2014 14:15:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:message-id:date:from:user-agent :mime-version:to:subject:references:in-reply-to:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe:content-type :content-transfer-encoding; bh=5g20tPua6iIKtZ/z+Ya/d7vFLXkodpfTjjWcVTsKukQ=; b=R9bqc4S4tnA9UtRyca8RiO00WsNorDl+Mi28XsXhJS9pHbxJdZ4voycgSOQQKtgUD2 IEk/CsSn+Q0Pydo09WiDsWenQlfD2RAYXahe8odO6JuNkSDskwOFrRyEN/TQDIuaP8qw iN+L0/PuynUy+a8KJtE15ORwz4ou/jkN1ZsRlTAAcc84DtvBYdmrw83E5xQk9GEzjdGX lZN3vz/hZOoyLaC204n+QQ6tYmGA2b21KJkjwm9PaN8RWVsiQF2ChE9CJFj1vfl8Xdnj GSzBYk5Rvtk3mr0jUZ2Ih7xzUQ9mNrlH5nXB/nUncUpEzIsN7YRgqkkzqUYFDi8ztmPd vjDg== X-Gm-Message-State: ALoCoQn3aXggPl9Ugik2xKYIY8hhWIcuoe3paDeEqOYDF1wawIm9kJlmZhRcMu4ChtcGAHGx/VYc X-Received: by 10.236.133.82 with SMTP id p58mr9587433yhi.37.1390860941838; Mon, 27 Jan 2014 14:15:41 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.26.195 with SMTP id 61ls1720231qgv.19.gmail; Mon, 27 Jan 2014 14:15:41 -0800 (PST) X-Received: by 10.220.97.145 with SMTP id l17mr589541vcn.35.1390860941771; Mon, 27 Jan 2014 14:15:41 -0800 (PST) Received: from mail-vb0-f52.google.com (mail-vb0-f52.google.com [209.85.212.52]) by mx.google.com with ESMTPS id av10si4193443ved.36.2014.01.27.14.15.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 27 Jan 2014 14:15:41 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.52 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.52; Received: by mail-vb0-f52.google.com with SMTP id p14so3717758vbm.25 for ; Mon, 27 Jan 2014 14:15:41 -0800 (PST) X-Received: by 10.221.66.73 with SMTP id xp9mr1885325vcb.27.1390860941698; Mon, 27 Jan 2014 14:15:41 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp162761vcz; Mon, 27 Jan 2014 14:15:41 -0800 (PST) X-Received: by 10.50.29.65 with SMTP id i1mr19880449igh.39.1390860940895; Mon, 27 Jan 2014 14:15:40 -0800 (PST) Received: from mail-ig0-f177.google.com (mail-ig0-f177.google.com [209.85.213.177]) by mx.google.com with ESMTPS id ix6si18095287icb.5.2014.01.27.14.15.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 27 Jan 2014 14:15:40 -0800 (PST) Received-SPF: neutral (google.com: 209.85.213.177 is neither permitted nor denied by best guess record for domain of alex.elder@linaro.org) client-ip=209.85.213.177; Received: by mail-ig0-f177.google.com with SMTP id k19so10301367igc.4 for ; Mon, 27 Jan 2014 14:15:40 -0800 (PST) X-Received: by 10.43.49.195 with SMTP id vb3mr23082892icb.19.1390860940626; Mon, 27 Jan 2014 14:15:40 -0800 (PST) Received: from [172.22.22.4] (c-71-195-31-37.hsd1.mn.comcast.net. [71.195.31.37]) by mx.google.com with ESMTPSA id x13sm22946823igp.2.2014.01.27.14.15.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 27 Jan 2014 14:15:40 -0800 (PST) Message-ID: <52E6DA8C.3090700@linaro.org> Date: Mon, 27 Jan 2014 16:15:40 -0600 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: patches@linaro.org Subject: Fwd: [PATCH v2 2/3] kernel.h: define u8, s8, u32, etc. limits References: <52BC65EA.8030505@linaro.org> In-Reply-To: <52BC65EA.8030505@linaro.org> X-Enigmail-Version: 1.5.2 X-Forwarded-Message-Id: <52BC65EA.8030505@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: alex.elder@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.52 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , -------- Original Message -------- Subject: [PATCH v2 2/3] kernel.h: define u8, s8, u32, etc. limits Date: Thu, 26 Dec 2013 11:22:50 -0600 From: Alex Elder To: Sage Weil , David Miller , kuznet@ms2.inr.ac.ru, jmorris@namei.org, yoshfuji@linux-ipv6.org, kaber@trash.net, Al Viro , jeffm@suse.com, Steven Rostedt , Andrew Morton , mst@redhat.com, Ingo Molnar Create constants that define the maximum and minimum values representable by the kernel types u8, s8, u16, s16, and so on. Signed-off-by: Alex Elder --- v2: - invert the bits *after* the cast - use integer suffixes (e.g. ULL) include/linux/kernel.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/linux/kernel.h b/include/linux/kernel.h index ecb8754..a01fa7a 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -29,6 +29,19 @@ #define ULLONG_MAX (~0ULL) #define SIZE_MAX (~(size_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 #define REPEAT_BYTE(x) ((~0ul / 0xff) * (x))