Source

LIME / inc / LIME_common.h

Full commit
/****************************************************************
This header file contains common arithmetic definitions used by 
LIME. KISS.

Copyright (C) 2008 NXP Semiconductors B.V.

This file is part of LIME.

LIME is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

LIME is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with LIME.  If not, see <http://www.gnu.org/licenses/>.
****************************************************************/
#ifndef __COMMON__
#define __COMMON__

// Common defines
#define lengthof(type)	(sizeof type/sizeof type[0])

// Associative operations for collectives

#define max(a,b) ( (a) >= (b) ? (a) : (b) )
#define min(a,b) ( (a) <= (b) ? (a) : (b) )
#define equ(a,b) ( (a) == (b) )
#define sum(a,b) ( (a) + (b) )
#define prod(a,b) ( (a) * (b) )

// g is the granule size
#define roundup(s,g)	((s)/(g)+!!((s) % (g)))
#define round_up(t,g)	roundup(sizeof(t),g)

// l is log2 of the granule size
#define loground(s,l)	(1+((((s)-1) & ~((1<<(l))-1))>>(l)))
#define log_round(t,l)	loground(sizeof(t),l)

#endif//__COMMON__