⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bitsset.c

📁 T-kernel 的extension源代码
💻 C
字号:
/* *---------------------------------------------------------------------- *    T-Kernel / Standard Extension * *    Copyright (C) 2006 by Ken Sakamura. All rights reserved. *    T-Kernel / Standard Extension is distributed  *      under the T-License for T-Kernel / Standard Extension. *---------------------------------------------------------------------- * *    Version:   1.00.00 *    Released by T-Engine Forum(http://www.t-engine.org) at 2006/8/11. * *---------------------------------------------------------------------- *//* *	bitsset.c (common) */#include <bitop.h>#include <libstr.h>#define TSD_BST_N_8		8#define TSD_BST_MSK_7		7U#define TSD_BST_VAL_0XFF	0xffU/* * Set the bit string. *	Set the width bits from the position of specified bit. */EXPORT void BitsSet( VP base, W offset, W width ){	UB	*bp;	INT	n;	n = offset / TSD_BST_N_8;	bp = (UB*)base + n;	n = (W)((UW)offset & TSD_BST_MSK_7);	if ( n > 0 ) {		for ( ; n < TSD_BST_N_8; ++n ) {			if ( --width < 0 ) {				return;			}			BitSet(bp, (UW)n);		}		bp++;	}	n = width / TSD_BST_N_8;	if ( n > 0 ) {		memset(bp, TSD_BST_VAL_0XFF, (size_t)n);	}	bp += n;	width -= n * TSD_BST_N_8;	for ( n = 0; n < width; ++n ) {		BitSet(bp, (UW)n);	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -