From patchwork Sun Apr 29 08:57:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 155720 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3B40AB6EE7 for ; Sun, 29 Apr 2012 18:58:09 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753896Ab2D2I52 (ORCPT ); Sun, 29 Apr 2012 04:57:28 -0400 Received: from investici.nine.ch ([217.150.252.179]:57860 "EHLO confino.investici.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753071Ab2D2I4s (ORCPT ); Sun, 29 Apr 2012 04:56:48 -0400 Received: from [217.150.252.179] (confino [217.150.252.179]) (Authenticated sender: ordex@autistici.org) by localhost (Postfix) with ESMTPSA id EFBA6C86B3; Sun, 29 Apr 2012 08:56:46 +0000 (UTC) X-DKIM: Sendmail DKIM Filter v2.8.2 confino.investici.org EFBA6C86B3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1335689807; bh=SoZqLFIZUKWqZi6QGgQd/ZCd4GxGBHoJq4CXwT3RUkY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=IfnTEPm3aBI6k459G9dnC/QwYc9DGtK5pBvcKYN1ElnJXPvkPP5eK1YOAbsxb9WVP nP6TDu1W4c+f+QiJRe540jysNRSinn2AKujGFj/5sOG8UHUjc+Hw1FXB7YljrSgUqh EntLbHqYpBjmV889266yXwDk53O1hjzzQMoJ2wA0= From: Antonio Quartulli To: davem@davemloft.net Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org, Antonio Quartulli Subject: [PATCH 03/15] batman-adv: add biggest_unsigned_int(x) macro Date: Sun, 29 Apr 2012 10:57:35 +0200 Message-Id: <1335689867-8017-4-git-send-email-ordex@autistici.org> X-Mailer: git-send-email 1.7.9.4 In-Reply-To: <1335689867-8017-1-git-send-email-ordex@autistici.org> References: <1335689867-8017-1-git-send-email-ordex@autistici.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org in case of dynamic type variable, it could be needed to compute at compile time its maximal value. This macro helps in doing that for unsigned integer types Signed-off-by: Antonio Quartulli --- net/batman-adv/main.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index a2b18d0..d9ef4ca 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h @@ -221,6 +221,9 @@ static inline bool has_timed_out(unsigned long timestamp, unsigned int timeout) /* Returns the smallest signed integer in two's complement with the sizeof x */ #define smallest_signed_int(x) (1u << (7u + 8u * (sizeof(x) - 1u))) +/* Returns the biggest unsigned integer with the sizeof x */ +#define biggest_unsigned_int(x) (~(x)0) + /* Checks if a sequence number x is a predecessor/successor of y. * they handle overflows/underflows and can correctly check for a * predecessor/successor unless the variable sequence number has grown by