1 /*
2  * $Id: openwince.h,v 1.1 2005/09/29 08:31:18 telka Exp $
3  *
4  * Common header file
5  * Copyright (C) 2002 ETC s.r.o.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 3. Neither the name of the ETC s.r.o. nor the names of its contributors
17  *    may be used to endorse or promote products derived from this software
18  *    without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  *
31  * Written by Marcel Telka <marcel@telka.sk>, 2002.
32  *
33  */
34 
35 #ifndef	COMMON_H
36 #define	COMMON_H
37 
38 #ifndef LANGUAGE
39 #	ifdef __ASSEMBLY__
40 #		define LANGUAGE ASM
41 #	else
42 #		define LANGUAGE C
43 #	endif
44 #endif
45 
46 #ifndef ASM
47 #define	ASM	0
48 #endif
49 
50 #ifndef C
51 #define	C	1
52 #endif
53 
54 #define	MAX_BITS_ABS_VAL	1024
55 #define	BITS_ABS(a)		(((((a) + MAX_BITS_ABS_VAL) / MAX_BITS_ABS_VAL) * 2 - 1) * (a))
56 #define	BITS_MIN(a,b)		(((a) + (b) - BITS_ABS((a) - (b))) / 2)
57 
58 #define	bit(b)			(1 << (b))
59 #define	bits(b1,b2)		(((2 << BITS_ABS((b1) - (b2))) - 1) << BITS_MIN(b1,b2))
60 #define	bits_val(b1,b2,v)	(((v) << BITS_MIN(b1,b2)) & bits(b1,b2))
61 #define	bits_get(b1,b2,v)	(((v) & bits(b1,b2)) >> BITS_MIN(b1,b2))
62 
63 #endif /* COMMON_H */
64