本文整理汇总了C++中TEST_BIT函数的典型用法代码示例。如果您正苦于以下问题:C++ TEST_BIT函数的具体用法?C++ TEST_BIT怎么用?C++ TEST_BIT使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TEST_BIT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CSP_CCM_get_sys_clk_status
s32 CSP_CCM_get_sys_clk_status(CSP_CCM_sysClkNo_t sysClkNo)
{
switch (sysClkNo)
{
case CSP_CCM_SYS_CLK_HOSC:
return HOSC_IS_ABLE;
case CSP_CCM_SYS_CLK_VE_PLL:
return VE_PLL_IS_ABLE;
case CSP_CCM_SYS_CLK_AUDIO_PLL:
case CSP_CCM_SYS_CLK_AUDIO_PLL_4X://///
case CSP_CCM_SYS_CLK_AUDIO_PLL_8X://///
return AUDIO_PLL_IS_ABLE;
case CSP_CCM_SYS_CLK_SDRAM_PLL:
return TEST_BIT(CCM_SDRAM_PLL_R, 11);
case CSP_CCM_SYS_CLK_VIDEO_PLL0:
case CSP_CCM_SYS_CLK_VIDEO_PLL0_2X:
return TEST_BIT(CCM_VIDEO_PLL_R, 7);
case CSP_CCM_SYS_CLK_VIDEO_PLL1:
case CSP_CCM_SYS_CLK_VIDEO_PLL1_2X:
return TEST_BIT(CCM_VIDEO_PLL_R, 23);
case CSP_CCM_SYS_CLK_TVENC_0:
case CSP_CCM_SYS_CLK_TVENC_1:
return 1;//clock is on
default:
CCM_msg("Exception: get status of clock[%d] failed.\n", sysClkNo);
return 0;
}
}
示例2: QFile
void MImHwKeyboardTrackerPrivate::tryEvdevDevice(const char *device)
{
QFile *qfile = new QFile(this);
unsigned char evbits[BITS2BYTES(EV_MAX)];
int fd;
qfile->setFileName(device);
if (!qfile->open(QIODevice::ReadOnly | QIODevice::Unbuffered)) {
delete qfile;
return;
}
fd = qfile->handle();
if (fd == -1) {
delete qfile;
return;
}
if (ioctl(fd, EVIOCGBIT(0, EV_MAX), evbits) < 0) {
delete qfile;
return;
}
// Check that this input device has switches
if (!TEST_BIT(EV_SW, evbits)) {
delete qfile;
return;
}
unsigned char swbit[BITS2BYTES(EV_MAX)];
if (ioctl(fd, EVIOCGBIT(EV_SW, SW_CNT), swbit) < 0) {
delete qfile;
return;
}
// Check that there is a tablet mode switch here
if (!TEST_BIT(SW_TABLET_MODE, swbit)) {
delete qfile;
return;
}
// Found an appropriate device - start monitoring it
QSocketNotifier *sn = new QSocketNotifier(fd, QSocketNotifier::Read, qfile);
sn->setEnabled(true);
QObject::connect(sn, SIGNAL(activated(int)), this, SLOT(evdevEvent()));
evdevFile = qfile;
present = true;
// Initialise initial tablet mode state
unsigned long state[BITS2BYTES(SW_MAX)];
if (ioctl(fd, EVIOCGSW(SW_MAX), state) < 0)
return;
evdevTabletMode = TEST_BIT(SW_TABLET_MODE, state);
}
示例3: ebc_anal_jmp
static void ebc_anal_jmp(RAnalOp *op, ut64 addr, const ut8 *buf) {
op->fail = addr + 6;
op->jump = (ut64)*(int32_t*)(buf + 2);
if (TEST_BIT(buf[1], 4))
op->jump += addr + 6;
if (buf[1] & 0x7) {
op->type = R_ANAL_OP_TYPE_UJMP;
} else {
if (TEST_BIT(buf[1], 7)) {
op->type = R_ANAL_OP_TYPE_CJMP;
} else {
op->type = R_ANAL_OP_TYPE_JMP;
}
}
}
示例4: _get_apb_device_clk_gating
static s32
_get_apb_device_clk_gating( CSP_CCM_modClkNo_t clkNo )
{
u32 pos = (u32)(clkNo - CSP_CCM_MOD_CLK_APB_KEY_PAD);
return TEST_BIT(CCM_APB_GATE_R, pos);
}
示例5: cfg_blocks_add
static void
cfg_blocks_add (basic_block bb)
{
gcc_assert (bb != ENTRY_BLOCK_PTR && bb != EXIT_BLOCK_PTR);
gcc_assert (!TEST_BIT (bb_in_list, bb->index));
if (cfg_blocks_empty_p ())
{
cfg_blocks_tail = cfg_blocks_head = 0;
cfg_blocks_num = 1;
}
else
{
cfg_blocks_num++;
if (cfg_blocks_num > VARRAY_SIZE (cfg_blocks))
{
/* We have to grow the array now. Adjust to queue to occupy the
full space of the original array. */
cfg_blocks_tail = VARRAY_SIZE (cfg_blocks);
cfg_blocks_head = 0;
VARRAY_GROW (cfg_blocks, 2 * VARRAY_SIZE (cfg_blocks));
}
else
cfg_blocks_tail = (cfg_blocks_tail + 1) % VARRAY_SIZE (cfg_blocks);
}
VARRAY_BB (cfg_blocks, cfg_blocks_tail) = bb;
SET_BIT (bb_in_list, bb->index);
}
示例6: cached_make_edge
edge
cached_make_edge (sbitmap edge_cache, basic_block src, basic_block dst, int flags)
{
if (edge_cache == NULL
|| src == ENTRY_BLOCK_PTR
|| dst == EXIT_BLOCK_PTR)
return make_edge (src, dst, flags);
/* Does the requested edge already exist? */
if (! TEST_BIT (edge_cache, dst->index))
{
/* The edge does not exist. Create one and update the
cache. */
SET_BIT (edge_cache, dst->index);
return unchecked_make_edge (src, dst, flags);
}
/* At this point, we know that the requested edge exists. Adjust
flags if necessary. */
if (flags)
{
edge e = find_edge (src, dst);
e->flags |= flags;
}
return NULL;
}
示例7: do_tagging
void chunkArchive::do_tagging(enum atoms TAG)
{
if (!TEST_BIT(status_bits, bTAG))
return;
CLEAR_BIT(status_bits, bTAG);
writeBlock((const char *) &TAG, 1);
}
示例8: iio_device_get_sample_size_mask
ssize_t iio_device_get_sample_size_mask(const struct iio_device *dev,
const uint32_t *mask, size_t words)
{
ssize_t size = 0;
unsigned int i;
if (words != (dev->nb_channels + 31) / 32)
return -EINVAL;
for (i = 0; i < dev->nb_channels; i++) {
const struct iio_channel *chn = dev->channels[i];
unsigned int length = chn->format.length / 8;
if (chn->index < 0)
break;
if (!TEST_BIT(mask, chn->index))
continue;
if (size % length)
size += 2 * length - (size % length);
else
size += length;
}
return size;
}
示例9: assert
char *mem_pool::mem_pool_impl::alloc_page(int &index)
{
assert(inited == 1);
if(free_pages == 0) {
return 0; /* there are no pages to allocate */
}
/*
* find a free page index from bitmap
*/
int page_index;
for(;; ++current_page) {
if(current_page == total_pages) {
current_page = 0;
}
if(TEST_BIT(page_bitmap, current_page) == 0) { /* found */
page_index = current_page++;
break;
}
}
index = page_index;
--free_pages;
SET_BIT(page_bitmap, index);
return index_to_page(index);
}
示例10: open_dev
int open_dev(const char *path)
{
if((dev_fd = open(path, O_RDWR)) == -1) {
if((dev_fd = open(path, O_RDONLY)) == -1) {
perror("failed to open device");
return -1;
}
fprintf(stderr, "opened device read-only, LEDs won't work\n");
}
if(ioctl(dev_fd, EVIOCGNAME(sizeof(dev_name)), dev_name) == -1) {
perror("EVIOCGNAME ioctl failed\n");
strcpy(dev_name, "unknown");
}
if(ioctl(dev_fd, EVIOCGBIT(0, sizeof(evtype_mask)), evtype_mask) == -1) {
perror("EVIOCGBIT ioctl failed\n");
close(dev_fd);
dev_fd = -1;
return -1;
}
if(!TEST_BIT(EV_REL, evtype_mask)) {
fprintf(stderr, "Wrong device, no relative events reported!\n");
close(dev_fd);
dev_fd = -1;
return -1;
}
if(cfg.led) {
set_led(1);
}
return 0;
}
示例11: iio_buffer_first
void * iio_buffer_first(const struct iio_buffer *buffer,
const struct iio_channel *chn)
{
size_t len;
unsigned int i;
uintptr_t ptr = (uintptr_t) buffer->buffer;
if (!iio_channel_is_enabled(chn))
return iio_buffer_end(buffer);
for (i = 0; i < buffer->dev->nb_channels; i++) {
struct iio_channel *cur = buffer->dev->channels[i];
len = cur->format.length / 8;
/* NOTE: dev->channels are ordered by index */
if (cur->index < 0 || cur->index == chn->index)
break;
/* Test if the buffer has samples for this channel */
if (!TEST_BIT(buffer->mask, cur->index))
continue;
if (ptr % len)
ptr += len - (ptr % len);
ptr += len;
}
len = chn->format.length / 8;
if (ptr % len)
ptr += len - (ptr % len);
return (void *) ptr;
}
示例12: fill_joystick_buttons
static bool fill_joystick_buttons(ALLEGRO_JOYSTICK_LINUX *joy, int fd)
{
unsigned long key_bits[NLONGS(KEY_CNT)] = {0};
int b;
int i;
if (ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(key_bits)), key_bits) < 0)
return false;
b = 0;
for (i = LJOY_BTN_RANGE_START; i < LJOY_BTN_RANGE_END; i++) {
if (TEST_BIT(i, key_bits) && is_joystick_button(i)) {
joy->button_mapping[b].ev_code = i;
ALLEGRO_DEBUG("Input event code %d maps to button %d\n", i, b);
joy->parent.info.button[b].name = al_malloc(32);
snprintf((char *)joy->parent.info.button[b].name, 32, "B%d", b+1);
b++;
if (b == _AL_MAX_JOYSTICK_BUTTONS)
break;
}
}
joy->parent.info.num_buttons = b;
/* Clear the rest. */
for (; b < _AL_MAX_JOYSTICK_BUTTONS; b++) {
joy->button_mapping[b].ev_code = -1;
}
return true;
}
示例13: DM8168VIDEOM3_halResetCtrl
/*!
* @brief Function to control reset operations
*
* @param halObj Pointer to the HAL object
* @param cmd Reset control command
* @param arg Arguments specific to the reset control command
*
* @sa
*/
Int
DM8168VIDEOM3_halResetCtrl(Ptr halObj, Processor_ResetCtrlCmd cmd, Ptr args)
{
Int status = PROCESSOR_SUCCESS;
DM8168VIDEOM3_HalObject * halObject = NULL;
GT_3trace(curTrace, GT_ENTER, "DM8168VIDEOM3_halResetCtrl", halObj, cmd, args);
GT_assert(curTrace, (halObj != NULL));
GT_assert(curTrace, (cmd < Processor_ResetCtrlCmd_EndValue));
halObject = (DM8168VIDEOM3_HalObject *) halObj ;
switch (cmd) {
case Processor_ResetCtrlCmd_Reset:
{
/*Put ONLY Ducati M3_0 to Reset*/
SET_BIT (REG((halObject->prcmBase) + RM_DEFAULT_RSTCTRL), 0x2);
/* clear the status bit only if it is set*/
if(TEST_BIT(REG((halObject->prcmBase) + RM_DEFAULT_RSTST) , 0x2)) {
REG((halObject->prcmBase) + RM_DEFAULT_RSTST) = 0x4;
}
}
break;
case Processor_ResetCtrlCmd_Release:
{
/*Bring ONLY Ducati M3_0 out of Reset*/
CLEAR_BIT (REG((halObject->prcmBase) + RM_DEFAULT_RSTCTRL), 0x2);
/*Check for Ducati M3_0 out of Reset*/
while((((REG(halObject->prcmBase + RM_DEFAULT_RSTST)&0x04))!=0x04) &&
(((REG(halObject->prcmBase + RM_DEFAULT_RSTST)&0x14))!=0x14) &&
(((REG(halObject->prcmBase + RM_DEFAULT_RSTST)&0x1C))!=0x1C)) ;
/*Check Module is in Functional Mode */
while(((REG(halObject->prcmBase + CM_DEFAULT_DUCATI_CLKCTRL)&0x30000)>>16)!=0) ;
}
break;
case Processor_ResetCtrlCmd_PeripheralUp:
{
/* Nothing to be done to bringup the peripherals for this device. */
}
break;
default:
{
/*! @retval PROCESSOR_E_INVALIDARG Invalid argument */
status = PROCESSOR_E_INVALIDARG;
GT_setFailureReason (curTrace, GT_4CLASS,
"DM8168VIDEOM3_halResetCtrl", status,
"Unsupported reset ctrl cmd specified");
}
break;
}
GT_1trace(curTrace, GT_LEAVE, "DM8168VIDEOM3_halResetCtrl",status);
/*! @retval PROCESSOR_SUCCESS Operation successful */
return status;
}
示例14: expandList1_
int
expandList1_ (char ***tolist, int num, int *bitmMaps, char **keys)
{
int ii, jj, isSet;
char **temp;
if (num <= 0)
return 0;
if ((temp = (char **) calloc (num, sizeof (char *))) == NULL)
{
lserrno = LSE_MALLOC;
return (-1);
}
for (ii = 0, jj = 0; ii < num; ii++)
{
TEST_BIT (ii, bitmMaps, isSet);
if (isSet == 1)
{
temp[jj++] = keys[ii];
}
}
if (jj > 0)
{
*tolist = temp;
}
else
{
FREEUP (temp);
*tolist = NULL;
}
return (jj);
}
示例15: SDL_LockSurface
void Vga::draw() {
if(SDL_MUSTLOCK(screen)) {
SDL_LockSurface(screen);
}
for(int y = 0; y < VGA_HEIGHT; ++y) {
for(int x = 0; x < VGA_WIDTH; x += (sizeof(ensitlm::data_t) * CHAR_BIT)) {
ensitlm::data_t d;
initiator.read(address + ((x + (y * VGA_LINE)) / CHAR_BIT), d);
for(unsigned int bit = 0; bit < (sizeof(ensitlm::data_t) * CHAR_BIT); ++bit) {
Uint16 *bufp = (Uint16 *) screen->pixels +
x + (y * screen->pitch / 2) +
((sizeof(ensitlm::data_t) * CHAR_BIT) - 1 - bit);
if(TEST_BIT(d, bit)) {
*bufp = white;
}
else {
*bufp = black;
}
}
}
}
if(SDL_MUSTLOCK(screen)) {
SDL_UnlockSurface(screen);
}
SDL_Flip(screen);
}