* ========== Copyright Header Begin ==========================================
* OpenSPARC T2 Processor File: Math.h
* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
* The above named program 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.
* The above named program 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 this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
* ========== Copyright Header End ============================================
* Math.h defines common simple math functions.
static inline bool ispow2 (int64 v
)
return (v
<= 0) ? false : ((v
& (v
-1)) == 0);
static inline int64
log2 (int64 v
)
while (v
> 1) { v
>>= 1; i
++; }
static inline int64
pow2 (int64 v
)
static inline int min (int a
, int b
)
static inline int max (int a
, int b
)
static inline unsigned min (unsigned a
, unsigned b
)
static inline unsigned max (unsigned a
, unsigned b
)
static inline long min (long a
, long b
)
static inline long max (long a
, long b
)
static inline unsigned long min (unsigned long a
, unsigned long b
)
static inline unsigned long max (unsigned long a
, unsigned long b
)
static inline long long min (long long a
, long long b
)
static inline long long max (long long a
, long long b
)
static inline unsigned long long min (unsigned long long a
,
static inline unsigned long long max (unsigned long long a
,
static inline float min (float a
, float b
)
static inline float max (float a
, float b
)
static inline double min (double a
, double b
)
static inline double max (double a
, double b
)