Subversion Repositories HelenOS-historic

Rev

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

Rev 1262 Rev 1549
Line 64... Line 64...
64
 * @param start Starting bit.
64
 * @param start Starting bit.
65
 * @param bits Number of bits to set.
65
 * @param bits Number of bits to set.
66
 */
66
 */
67
void bitmap_set_range(bitmap_t *bitmap, index_t start, count_t bits)
67
void bitmap_set_range(bitmap_t *bitmap, index_t start, count_t bits)
68
{
68
{
69
    index_t i;
69
    index_t i=0;
70
    index_t aligned_start;
70
    index_t aligned_start;
71
    count_t lub;        /* leading unaligned bits */
71
    count_t lub;        /* leading unaligned bits */
72
    count_t amb;        /* aligned middle bits */
72
    count_t amb;        /* aligned middle bits */
73
    count_t tab;        /* trailing aligned bits */
73
    count_t tab;        /* trailing aligned bits */
74
   
74
   
Line 77... Line 77...
77
    aligned_start = ALIGN_UP(start, 8);
77
    aligned_start = ALIGN_UP(start, 8);
78
    lub = min(aligned_start - start, bits);
78
    lub = min(aligned_start - start, bits);
79
    amb = bits > lub ? bits - lub : 0;
79
    amb = bits > lub ? bits - lub : 0;
80
    tab = amb % 8;
80
    tab = amb % 8;
81
   
81
   
-
 
82
    if ( start + bits < aligned_start ) {
-
 
83
        /*
-
 
84
        * Set bits in the middle of byte
-
 
85
        */
-
 
86
        bitmap->map[start / 8] |= ((1 << lub)-1) << (start&7);
-
 
87
        return;
-
 
88
    }
-
 
89
   
82
    if (lub) {
90
    if (lub) {
83
        /*
91
        /*
84
         * Make sure to set any leading unaligned bits.
92
         * Make sure to set any leading unaligned bits.
85
         */
93
         */
86
        bitmap->map[start / 8] |= ~((1 << (8 - lub)) - 1);
94
        bitmap->map[start / 8] |= ~((1 << (8 - lub)) - 1);
Line 106... Line 114...
106
 * @param start Starting bit.
114
 * @param start Starting bit.
107
 * @param bits Number of bits to clear.
115
 * @param bits Number of bits to clear.
108
 */
116
 */
109
void bitmap_clear_range(bitmap_t *bitmap, index_t start, count_t bits)
117
void bitmap_clear_range(bitmap_t *bitmap, index_t start, count_t bits)
110
{
118
{
111
    index_t i;
119
    index_t i=0;
112
    index_t aligned_start;
120
    index_t aligned_start;
113
    count_t lub;        /* leading unaligned bits */
121
    count_t lub;        /* leading unaligned bits */
114
    count_t amb;        /* aligned middle bits */
122
    count_t amb;        /* aligned middle bits */
115
    count_t tab;        /* trailing aligned bits */
123
    count_t tab;        /* trailing aligned bits */
116
   
124
   
Line 119... Line 127...
119
    aligned_start = ALIGN_UP(start, 8);
127
    aligned_start = ALIGN_UP(start, 8);
120
    lub = min(aligned_start - start, bits);
128
    lub = min(aligned_start - start, bits);
121
    amb = bits > lub ? bits - lub : 0;
129
    amb = bits > lub ? bits - lub : 0;
122
    tab = amb % 8;
130
    tab = amb % 8;
123
 
131
 
-
 
132
    if ( start + bits < aligned_start )
-
 
133
    {
-
 
134
        /*
-
 
135
        * Set bits in the middle of byte
-
 
136
        */
-
 
137
        bitmap->map[start / 8] &= ~(((1 << lub)-1) << (start&7));
-
 
138
        return;
-
 
139
    }
-
 
140
 
-
 
141
 
124
    if (lub) {
142
    if (lub) {
125
        /*
143
        /*
126
         * Make sure to clear any leading unaligned bits.
144
         * Make sure to clear any leading unaligned bits.
127
         */
145
         */
128
        bitmap->map[start / 8] &= (1 << (8 - lub)) - 1;
146
        bitmap->map[start / 8] &= (1 << (8 - lub)) - 1;