Subversion Repositories HelenOS

Rev

Rev 1787 | Rev 1855 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1787 Rev 1812
Line 24... Line 24...
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
27
 */
28
 
28
 
29
 /** @addtogroup generic   
29
/** @addtogroup generic
30
 * @{
30
 * @{
31
 */
31
 */
32
/** @file
32
/** @file
33
 */
33
 */
34
 
34
 
35
#ifndef __MACROS_H__
35
#ifndef __MACROS_H__
36
#define __MACROS_H__
36
#define __MACROS_H__
37
 
37
 
-
 
38
#include <arch/types.h>
-
 
39
#include <typedefs.h>
-
 
40
 
38
#define is_digit(d) (((d) >= '0') && ((d)<='9'))
41
#define is_digit(d)     (((d) >= '0') && ((d) <= '9'))
39
#define is_lower(c) (((c) >= 'a') && ((c) <= 'z'))
42
#define is_lower(c)     (((c) >= 'a') && ((c) <= 'z'))
40
#define is_upper(c) (((c) >= 'A') && ((c) <= 'Z'))
43
#define is_upper(c)     (((c) >= 'A') && ((c) <= 'Z'))
41
#define is_alpha(c) (is_lower(c) || is_upper(c))
44
#define is_alpha(c)     (is_lower(c) || is_upper(c))
42
#define is_alphanum(c)  (is_alpha(c) || is_digit(c))
45
#define is_alphanum(c)  (is_alpha(c) || is_digit(c))
43
#define is_white(c) (((c) == ' ') || ((c) == '\t') || ((c) == '\n') || ((c) == '\r'))
46
#define is_white(c)     (((c) == ' ') || ((c) == '\t') || ((c) == '\n') || ((c) == '\r'))
44
 
47
 
45
#define min(a,b)    ((a)<(b)?(a):(b))
48
#define min(a,b)    ((a) < (b) ? (a) : (b))
46
#define max(a,b)    ((a)>(b)?(a):(b))
49
#define max(a,b)    ((a) > (b) ? (a) : (b))
47
 
50
 
48
/** Return true if the interlvals overlap. */
51
/** Return true if the interlvals overlap. */
49
static inline int overlaps(uintptr_t s1, size_t sz1, uintptr_t s2, size_t sz2)
52
static inline int overlaps(uintptr_t s1, size_t sz1, uintptr_t s2, size_t sz2)
50
{
53
{
51
    uintptr_t e1 = s1+sz1;
54
    uintptr_t e1 = s1 + sz1;
52
    uintptr_t e2 = s2+sz2;
55
    uintptr_t e2 = s2 + sz2;
53
 
56
 
54
    return s1 < e2 && s2 < e1;
57
    return (s1 < e2) && (s2 < e1);
55
}
58
}
56
/* Compute overlapping of physical addresses */
59
/* Compute overlapping of physical addresses */
57
#define PA_overlaps(x,szx,y,szy)  overlaps(KA2PA(x),szx,KA2PA(y), szy)
60
#define PA_overlaps(x, szx, y, szy) overlaps(KA2PA(x), szx, KA2PA(y), szy)
-
 
61
 
-
 
62
#define STRING(arg) STRING_ARG(arg)
-
 
63
#define STRING_ARG(arg) #arg
58
 
64
 
59
#endif
65
#endif
60
 
66
 
61
 /** @}
67
/** @}
62
 */
68
 */
63
 
-