X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flib%2Fkernel%2Fbitmap.c;h=d14a98cf343e935a390d9fd5702980ea50640dc6;hb=4d8d667bed137a2d791e9cb7befc3cbfb3a31c09;hp=df23cc34c1b8c9dddf86d8cc3796904838e36dac;hpb=615bf3b3d2a8573ed6fb9ddc0055745e163ac999;p=pintos-anon diff --git a/src/lib/kernel/bitmap.c b/src/lib/kernel/bitmap.c index df23cc3..d14a98c 100644 --- a/src/lib/kernel/bitmap.c +++ b/src/lib/kernel/bitmap.c @@ -71,10 +71,10 @@ last_mask (const struct bitmap *b) /* Creation and destruction. */ -/* Initializes B to be a bitmap of BIT_CNT bits - and sets all of its bits to false. - Returns true if success, false if memory allocation - failed. */ +/* Creates and returns a pointer to a newly allocated bitmap with room for + BIT_CNT (or more) bits. Returns a null pointer if memory allocation fails. + The caller is responsible for freeing the bitmap, with bitmap_destroy(), + when it is no longer needed. */ struct bitmap * bitmap_create (size_t bit_cnt) { @@ -118,8 +118,7 @@ bitmap_buf_size (size_t bit_cnt) } /* Destroys bitmap B, freeing its storage. - Not for use on bitmaps created by - bitmap_create_preallocated(). */ + Not for use on bitmaps created by bitmap_create_in_buf(). */ void bitmap_destroy (struct bitmap *b) { @@ -163,7 +162,7 @@ bitmap_mark (struct bitmap *b, size_t bit_idx) /* This is equivalent to `b->bits[idx] |= mask' except that it is guaranteed to be atomic on a uniprocessor machine. See the description of the OR instruction in [IA32-v2b]. */ - asm ("or %0, %1" : "=m" (b->bits[idx]) : "r" (mask) : "cc"); + asm ("orl %1, %0" : "=m" (b->bits[idx]) : "r" (mask) : "cc"); } /* Atomically sets the bit numbered BIT_IDX in B to false. */ @@ -176,7 +175,7 @@ bitmap_reset (struct bitmap *b, size_t bit_idx) /* This is equivalent to `b->bits[idx] &= ~mask' except that it is guaranteed to be atomic on a uniprocessor machine. See the description of the AND instruction in [IA32-v2a]. */ - asm ("and %0, %1" : "=m" (b->bits[idx]) : "r" (~mask) : "cc"); + asm ("andl %1, %0" : "=m" (b->bits[idx]) : "r" (~mask) : "cc"); } /* Atomically toggles the bit numbered IDX in B; @@ -191,7 +190,7 @@ bitmap_flip (struct bitmap *b, size_t bit_idx) /* This is equivalent to `b->bits[idx] ^= mask' except that it is guaranteed to be atomic on a uniprocessor machine. See the description of the XOR instruction in [IA32-v2b]. */ - asm ("xor %0, %1" : "=m" (b->bits[idx]) : "r" (mask) : "cc"); + asm ("xorl %1, %0" : "=m" (b->bits[idx]) : "r" (mask) : "cc"); } /* Returns the value of the bit numbered IDX in B. */