1 |
|
/* math.h - Public interface to L4 mathematical support functions. |
2 |
|
Copyright (C) 2003 Free Software Foundation, Inc. |
3 |
|
Written by Marcus Brinkmann <marcus@gnu.org>. |
4 |
|
|
5 |
|
This file is part of the GNU L4 library. |
6 |
|
|
7 |
|
The GNU L4 library is free software; you can redistribute it and/or |
8 |
|
modify it under the terms of the GNU Lesser General Public License |
9 |
|
as published by the Free Software Foundation; either version 2.1 of |
10 |
|
the License, or (at your option) any later version. |
11 |
|
|
12 |
|
The GNU L4 library is distributed in the hope that it will be |
13 |
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty |
14 |
|
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
|
GNU Lesser General Public License for more details. |
16 |
|
|
17 |
|
You should have received a copy of the GNU Lesser General Public |
18 |
|
License along with the GNU L4 library; if not, write to the Free |
19 |
|
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
20 |
|
02111-1307, USA. */ |
21 |
|
|
22 |
#ifndef _L4_MATH_H |
#ifndef _L4_MATH_H |
23 |
#define _L4_MATH_H 1 |
#define _L4_MATH_H 1 |
24 |
|
|
25 |
#include <l4/types.h> |
#include <l4/types.h> |
26 |
|
|
27 |
/* <l4/bits/math.h> defines __l4_msb_(). */ |
/* <l4/bits/math.h> defines__l4_msb() and __l4_lsb(). */ |
28 |
#include <l4/bits/math.h> |
#include <l4/bits/math.h> |
29 |
|
|
30 |
|
|
|
#ifndef _L4_EXTERN_INLINE |
|
|
#define _L4_EXTERN_INLINE extern __inline |
|
|
#endif |
|
|
|
|
|
|
|
|
_L4_EXTERN_INLINE l4_word_t |
|
|
__l4_msb (l4_word_t data) __attribute__((__const__)); |
|
|
|
|
31 |
/* Return 0 if DATA is 0, or the bit number of the most significant |
/* Return 0 if DATA is 0, or the bit number of the most significant |
32 |
bit set in DATA. The least significant bit is 1, the most |
bit set in DATA. The least significant bit is 1, the most |
33 |
significant bit 32 resp. 64. */ |
significant bit 32 resp. 64. */ |
34 |
_L4_EXTERN_INLINE l4_word_t |
static inline l4_word_t |
35 |
|
__attribute__((__always_inline__)) |
36 |
l4_msb (l4_word_t data) |
l4_msb (l4_word_t data) |
37 |
{ |
{ |
38 |
if (__builtin_constant_p (data)) |
if (__builtin_constant_p (data)) |
71 |
/* Return 0 if DATA is 0, or the bit number of the least significant |
/* Return 0 if DATA is 0, or the bit number of the least significant |
72 |
bit set in DATA. The least significant bit is 1, the most |
bit set in DATA. The least significant bit is 1, the most |
73 |
significant bit 32 resp. 64. */ |
significant bit 32 resp. 64. */ |
74 |
_L4_EXTERN_INLINE l4_word_t |
static inline l4_word_t |
75 |
|
__attribute__((__always_inline__)) |
76 |
l4_lsb (l4_word_t data) |
l4_lsb (l4_word_t data) |
77 |
{ |
{ |
78 |
if (__builtin_constant_p (data)) |
if (__builtin_constant_p (data)) |
104 |
return data ? __l4_lsb (data) : 0; |
return data ? __l4_lsb (data) : 0; |
105 |
} |
} |
106 |
|
|
|
|
|
107 |
#endif /* l4/math.h */ |
#endif /* l4/math.h */ |