tkernel_2/lib/libsys/src/bitsclr.c | bare source | permlink (0.02 seconds) |
1: /* 2: *---------------------------------------------------------------------- 3: * T-Kernel 2.0 Software Package 4: * 5: * Copyright 2011 by Ken Sakamura. 6: * This software is distributed under the latest version of T-License 2.x. 7: *---------------------------------------------------------------------- 8: * 9: * Released by T-Engine Forum(http://www.t-engine.org/) at 2011/05/17. 10: * Modified by T-Engine Forum at 2014/09/10. 11: * Modified by TRON Forum(http://www.tron.org/) at 2015/06/01. 12: * 13: *---------------------------------------------------------------------- 14: */ 15: 16: /* 17: * bitsclr.c (libsys) 18: */ 19: 20: #include <sys/bitop.h> 21: #include <libstr.h> 22: 23: /* 24: * Clear the bit string. 25: * Clear the width bits from the position of specified bit. 26: */ 27: EXPORT void BitsClr( void *base, W offset, W width ) 28: { 29: UB *bp; 30: INT n; 31: 32: n = offset / 8; 33: bp = (UB*)base + n; 34: 35: n = (W)((UW)offset & 7U); 36: if ( n > 0 ) { 37: for ( ; n < 8; ++n ) { 38: if ( --width < 0 ) { 39: return; 40: } 41: BitClr(bp, (UW)n); 42: } 43: bp++; 44: } 45: 46: n = width / 8; 47: if ( n > 0 ) { 48: MEMSET(bp, 0U, (size_t)n); 49: } 50: bp += n; 51: width -= n * 8; 52: 53: for ( n = 0; n < width; ++n ) { 54: BitClr(bp, (UW)n); 55: } 56: }