brickOS Kernel Developer
v0.9.0
bitops.h
Go to the documentation of this file.
1
6
/*
7
* The contents of this file are subject to the Mozilla Public License
8
* Version 1.0 (the "License"); you may not use this file except in
9
* compliance with the License. You may obtain a copy of the License
10
* at http://www.mozilla.org/MPL/
11
*
12
* Software distributed under the License is distributed on an "AS IS"
13
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
* the License for the specific language governing rights and
15
* limitations under the License.
16
*
17
* The Original Code is legOS code, released October 17, 1999.
18
*
19
* The Initial Developer of the Original Code is Markus L. Noga.
20
* Portions created by Markus L. Noga are Copyright (C) 1999
21
* Markus L. Noga. All Rights Reserved.
22
*
23
* Contributor(s): Markus L. Noga <markus@noga.de>
24
*/
25
26
#ifndef __sys_bitops_h__
27
#define __sys_bitops_h__
28
29
#ifdef __cplusplus
30
extern
"C"
{
31
#endif
32
34
//
35
// Functions
36
//
38
39
// g++ warns about __asm__ const. we define the problem away.
40
// the CXX symbol is predefined in the Makefile
41
//
42
#if defined(CXX) || __GNUC__ >= 3
43
# define ASMCONST
44
#else
45
# define ASMCONST const
46
#endif
47
48
//
49
// the H8/300 processor offers many useful bit operations.
50
// sometimes, we have to help gcc to realize their full
51
// potential.
52
//
53
// the bit operations don't alter cc except for bld
54
//
55
57
59
#define bit_set(byte,bit) \
60
__asm__ ASMCONST ( "bset %0,@%1\n" : : "i" (bit),"r" (byte))
61
63
65
#define bit_clear(byte,bit) \
66
__asm__ ASMCONST ( "bclr %0,@%1\n" : : "i" (bit),"r" (byte))
67
69
71
#define bit_load(mask,bit) \
72
__asm__ ASMCONST ( "bld %0,%1l\n" : : "i" (bit),"r" (mask):"cc")
73
75
77
#define bit_iload(mask,bit) \
78
__asm__ ASMCONST ( "bild %0,%1l\n" : : "i" (bit),"r" (mask):"cc")
79
81
83
#define bit_store(byte,bit) \
84
__asm__ ASMCONST ( "bst %0,@%1\n" : : "i" (bit),"r" (byte))
85
86
#ifdef __cplusplus
87
}
88
#endif
89
90
#endif
// __sys_bitops_h__
include
sys
bitops.h
Generated by
1.9.8