From patchwork Wed Nov 23 10:35:44 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 1381 Return-Path: Received: from confino.investici.org (investici.nine.ch [217.150.252.179]) by open-mesh.org (Postfix) with ESMTPS id 31A906007A8 for ; Wed, 23 Nov 2011 11:36:00 +0100 (CET) Authentication-Results: open-mesh.org; dkim=pass (1024-bit key) header.i=@autistici.org; dkim-adsp=pass Received: from [217.150.252.179] (confino [217.150.252.179]) (Authenticated sender: ordex@autistici.org) by localhost (Postfix) with ESMTPSA id 5A1CFC865D; Wed, 23 Nov 2011 10:35:59 +0000 (UTC) X-DKIM: Sendmail DKIM Filter v2.8.2 confino.investici.org 5A1CFC865D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1322044559; bh=LW4K0EE34W11KbQaln9FolXQm6ovjAOIwAUSzv5OFus=; h=From:To:Cc:Subject:Date:Message-Id; b=RG+VtrytoydMED5Telit/Inb03h4BtihfDuqPodT0tP+z/AxlO1m1EDLxLmeiaW7Q o9KQwHlMyLCTGnerUQ1iSxDJFicvfgd3DoKUbLRWe4qe5T+GeMXH2/UWhYvkywsezX xLFD5Lt8m/7sdKEqT8DCFjquvXzi5DFEiWN9A+Jo= From: Antonio Quartulli To: b.a.t.m.a.n@lists.open-mesh.org Date: Wed, 23 Nov 2011 11:35:44 +0100 Message-Id: <1322044544-15153-1-git-send-email-ordex@autistici.org> X-Mailer: git-send-email 1.7.3.4 Subject: [B.A.T.M.A.N.] [PATCH] batman-adv: add biggest_unsigned_int(x) macro X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.13 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Nov 2011 10:36:00 -0000 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 --- main.h | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/main.h b/main.h index 464439f..3c58235 100644 --- a/main.h +++ b/main.h @@ -210,6 +210,9 @@ static inline int compare_eth(const void *data1, const void *data2) /* 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