本文整理汇总了C++中OFFSETOF函数的典型用法代码示例。如果您正苦于以下问题:C++ OFFSETOF函数的具体用法?C++ OFFSETOF怎么用?C++ OFFSETOF使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OFFSETOF函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wl_p2p_scan
int wl_p2p_scan(void *wl, uint16 sync_id, int isActive,
int numProbes, int activeDwellTime, int passiveDwellTime,
int num_channels, uint16 *channels)
{
wl_p2p_scan_t *params = NULL;
int params_size = 0;
int malloc_size = 0;
int nssid = 0;
int err = 0;
wl_escan_params_t *eparams;
malloc_size = sizeof(wl_p2p_scan_t);
malloc_size += OFFSETOF(wl_escan_params_t, params) +
WL_SCAN_PARAMS_FIXED_SIZE + WL_NUMCHANNELS * sizeof(uint16);
malloc_size += WL_SCAN_PARAMS_SSID_MAX * sizeof(wlc_ssid_t);
params = (wl_p2p_scan_t *)malloc(malloc_size);
if (params == NULL) {
fprintf(stderr, "Error allocating %d bytes for scan params\n", malloc_size);
return -1;
}
memset(params, 0, malloc_size);
eparams = (wl_escan_params_t *)(params+1);
params->type = 'E';
eparams->version = htod32(ESCAN_REQ_VERSION);
eparams->action = htod16(WL_SCAN_ACTION_START);
eparams->sync_id = sync_id;
memcpy(&eparams->params.bssid, ðer_bcast, ETHER_ADDR_LEN);
eparams->params.bss_type = DOT11_BSSTYPE_ANY;
eparams->params.scan_type = isActive ? 0 : WL_SCANFLAGS_PASSIVE;
eparams->params.nprobes = htod32(numProbes);
eparams->params.active_time = htod32(activeDwellTime);
eparams->params.passive_time = htod32(passiveDwellTime);
eparams->params.home_time = htod32(-1);
eparams->params.channel_num = 0;
memcpy(eparams->params.channel_list, channels, num_channels * sizeof(uint16));
eparams->params.channel_num = htod32((nssid << WL_SCAN_PARAMS_NSSID_SHIFT) |
(num_channels & WL_SCAN_PARAMS_COUNT_MASK));
params_size = sizeof(wl_p2p_scan_t) + sizeof(wl_escan_params_t) + WL_SCAN_PARAMS_FIXED_SIZE+
(num_channels * sizeof(uint16)) + (nssid * sizeof(wlc_ssid_t));
err = wlu_iovar_setbuf(wl, "p2p_scan", params, params_size, buf, WLC_IOCTL_MAXLEN);
free(params);
return err;
}
示例2: pcie_clkreq_upd
/* centralized clkreq control policy */
static void
pcie_clkreq_upd(pcicore_info_t *pi, uint state)
{
si_t *sih = pi->sih;
ASSERT(PCIE(sih));
if (!PCIE_GEN1(sih))
return;
switch (state) {
case SI_DOATTACH:
if (PCIEGEN1_ASPM(sih))
pcie_clkreq((void *)pi, 1, 0);
break;
case SI_PCIDOWN:
if (sih->buscorerev == 6) { /* turn on serdes PLL down */
si_corereg(sih, SI_CC_IDX, OFFSETOF(chipcregs_t, chipcontrol_addr),
~0, 0);
si_corereg(sih, SI_CC_IDX, OFFSETOF(chipcregs_t, chipcontrol_data),
~0x40, 0);
} else if (pi->pcie_pr42767) {
pcie_clkreq((void *)pi, 1, 1);
}
break;
case SI_PCIUP:
if (sih->buscorerev == 6) { /* turn off serdes PLL down */
si_corereg(sih, SI_CC_IDX, OFFSETOF(chipcregs_t, chipcontrol_addr),
~0, 0);
si_corereg(sih, SI_CC_IDX, OFFSETOF(chipcregs_t, chipcontrol_data),
~0x40, 0x40);
} else if (PCIEGEN1_ASPM(sih)) { /* disable clkreq */
pcie_clkreq((void *)pi, 1, 0);
}
break;
default:
ASSERT(0);
break;
}
}
示例3: si_gpiotimerval
/* mask&set gpio timer val */
uint32
si_gpiotimerval(si_t *sih, uint32 mask, uint32 gpiotimerval)
{
si_info_t *sii;
sii = SI_INFO(sih);
if (sih->ccrev < 16)
return -1;
return (si_corereg(sih, SI_CC_IDX,
OFFSETOF(chipcregs_t, gpiotimerval), mask, gpiotimerval));
}
示例4: buf_walk_init
static int
buf_walk_init(mdb_walk_state_t *wsp)
{
fmd_buf_hash_t bh;
if (mdb_vread(&bh, sizeof (bh), wsp->walk_addr) != sizeof (bh)) {
mdb_warn("failed to read fmd_buf_hash_t at %p", wsp->walk_addr);
return (WALK_ERR);
}
return (hash_walk_init(wsp, (uintptr_t)bh.bh_hash, bh.bh_hashlen,
"fmd_buf", sizeof (fmd_buf_t), OFFSETOF(fmd_buf_t, buf_next)));
}
示例5: init_pike_searching
void init_pike_searching(void)
{
start_new_program();
pike_search_struct_offset=ADD_STORAGE(struct pike_mem_searcher);
MAP_VARIABLE("__s", tStr, 0,
pike_search_struct_offset + OFFSETOF(pike_mem_searcher,s),
PIKE_T_STRING);
pike_search_program=end_program();
add_program_constant("Search",pike_search_program,ID_STATIC);
memsearch_cache=allocate_mapping(10);
memsearch_cache->data->flags |= MAPPING_FLAG_WEAK;
}
示例6: si_gpio_int_enable
uint32
si_gpio_int_enable(si_t *sih, bool enable)
{
si_info_t *sii;
uint offs;
sii = SI_INFO(sih);
if (sih->ccrev < 11)
return -1;
offs = OFFSETOF(chipcregs_t, intmask);
return (si_corereg(sih, SI_CC_IDX, offs, CI_GPIO, (enable ? CI_GPIO : 0)));
}
示例7: DOSVM_HardwareInterruptRM
/**********************************************************************
* DOSVM_HardwareInterruptRM
*
* Emulate call to interrupt handler in real mode.
*
* Either calls directly builtin handler or pushes interrupt frame to
* stack and changes instruction pointer to interrupt handler.
*/
void DOSVM_HardwareInterruptRM( CONTEXT86 *context, BYTE intnum )
{
FARPROC16 handler = DOSVM_GetRMHandler( intnum );
/* check if the call goes to an unhooked interrupt */
if (SELECTOROF(handler) == 0xf000)
{
/* if so, call it directly */
TRACE( "builtin interrupt %02x has been invoked "
"(through vector %02x)\n",
OFFSETOF(handler)/DOSVM_STUB_RM, intnum );
DOSVM_CallBuiltinHandler( context, OFFSETOF(handler)/DOSVM_STUB_RM );
}
else
{
/* the interrupt is hooked, simulate interrupt in DOS space */
WORD flag = LOWORD( context->EFlags );
TRACE( "invoking hooked interrupt %02x at %04x:%04x\n",
intnum, SELECTOROF(handler), OFFSETOF(handler) );
/* Copy virtual interrupt flag to pushed interrupt flag. */
if (context->EFlags & VIF_MASK)
flag |= IF_MASK;
else
flag &= ~IF_MASK;
PUSH_WORD16( context, flag );
PUSH_WORD16( context, context->SegCs );
PUSH_WORD16( context, LOWORD( context->Eip ));
context->SegCs = SELECTOROF( handler );
context->Eip = OFFSETOF( handler );
/* Clear virtual interrupt flag and trap flag. */
context->EFlags &= ~(VIF_MASK | TF_MASK);
}
}
示例8: SwitchStackTo16
/***********************************************************************
* SwitchStackTo (KERNEL.108)
*/
void WINAPI SwitchStackTo16( WORD seg, WORD ptr, WORD top )
{
STACK16FRAME *oldFrame, *newFrame;
INSTANCEDATA *pData;
UINT16 copySize;
if (!(pData = GlobalLock16( seg ))) return;
TRACE("old=%04x:%04x new=%04x:%04x\n",
SELECTOROF( NtCurrentTeb()->WOW32Reserved ),
OFFSETOF( NtCurrentTeb()->WOW32Reserved ), seg, ptr );
/* Save the old stack */
oldFrame = CURRENT_STACK16;
/* pop frame + args and push bp */
pData->old_ss_sp = (SEGPTR)NtCurrentTeb()->WOW32Reserved + sizeof(STACK16FRAME)
+ 2 * sizeof(WORD);
*(WORD *)MapSL(pData->old_ss_sp) = oldFrame->bp;
pData->stacktop = top;
pData->stackmin = ptr;
pData->stackbottom = ptr;
/* Switch to the new stack */
/* Note: we need to take the 3 arguments into account; otherwise,
* the stack will underflow upon return from this function.
*/
copySize = oldFrame->bp - OFFSETOF(pData->old_ss_sp);
copySize += 3 * sizeof(WORD) + sizeof(STACK16FRAME);
NtCurrentTeb()->WOW32Reserved = (void *)MAKESEGPTR( seg, ptr - copySize );
newFrame = CURRENT_STACK16;
/* Copy the stack frame and the local variables to the new stack */
memmove( newFrame, oldFrame, copySize );
newFrame->bp = ptr;
*(WORD *)MapSL( MAKESEGPTR( seg, ptr ) ) = 0; /* clear previous bp */
}
示例9: serd_walk_init
static int
serd_walk_init(mdb_walk_state_t *wsp)
{
fmd_serd_hash_t sh;
if (mdb_vread(&sh, sizeof (sh), wsp->walk_addr) != sizeof (sh)) {
mdb_warn("failed to read fmd_serd_hash at %p", wsp->walk_addr);
return (WALK_ERR);
}
return (hash_walk_init(wsp, (uintptr_t)sh.sh_hash, sh.sh_hashlen,
"fmd_serd_eng", sizeof (fmd_serd_eng_t),
OFFSETOF(fmd_serd_eng_t, sg_next)));
}
示例10: glGenVertexArrays
void sb7fbxmodel::sub_mesh_set_up(sub_mesh& sm)
{
glGenVertexArrays(1, &sm.vao);
glBindVertexArray(sm.vao);
glGenBuffers(1, &sm.vbo);
glBindBuffer(GL_ARRAY_BUFFER, sm.vao);
glBufferData(GL_ARRAY_BUFFER, sizeof(vetex_attr) * sm.count, sm.va, GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(vetex_attr), NULL);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(vetex_attr), (void*)OFFSETOF(vetex_attr, normal));
glEnableVertexAttribArray(0);
//glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 5 * sizeof(GL_FLOAT), (GLvoid*)(3 * sizeof(GL_FLOAT)));
//glEnableVertexAttribArray(1);
glBindVertexArray(0);
}
示例11: SwitchStackBack16
/***********************************************************************
* SwitchStackBack (KERNEL.109)
*/
void WINAPI SwitchStackBack16( CONTEXT *context )
{
STACK16FRAME *oldFrame, *newFrame;
INSTANCEDATA *pData;
if (!(pData = GlobalLock16(SELECTOROF(NtCurrentTeb()->WOW32Reserved))))
return;
if (!pData->old_ss_sp)
{
WARN("No previous SwitchStackTo\n" );
return;
}
TRACE("restoring stack %04x:%04x\n",
SELECTOROF(pData->old_ss_sp), OFFSETOF(pData->old_ss_sp) );
oldFrame = CURRENT_STACK16;
/* Pop bp from the previous stack */
context->Ebp = (context->Ebp & ~0xffff) | *(WORD *)MapSL(pData->old_ss_sp);
pData->old_ss_sp += sizeof(WORD);
/* Switch back to the old stack */
NtCurrentTeb()->WOW32Reserved = (void *)(pData->old_ss_sp - sizeof(STACK16FRAME));
context->SegSs = SELECTOROF(pData->old_ss_sp);
context->Esp = OFFSETOF(pData->old_ss_sp) - sizeof(DWORD); /*ret addr*/
pData->old_ss_sp = 0;
/* Build a stack frame for the return */
newFrame = CURRENT_STACK16;
newFrame->frame32 = oldFrame->frame32;
newFrame->module_cs = oldFrame->module_cs;
newFrame->callfrom_ip = oldFrame->callfrom_ip;
newFrame->entry_ip = oldFrame->entry_ip;
}
示例12: DOSDEV_FindCharDevice
DWORD DOSDEV_FindCharDevice(char*name)
{
SEGPTR cur_ptr = MAKESEGPTR(HIWORD(DOS_LOLSeg), FIELD_OFFSET(DOS_LISTOFLISTS,NUL_dev));
DOS_DEVICE_HEADER *cur = PTR_REAL_TO_LIN(SELECTOROF(cur_ptr),OFFSETOF(cur_ptr));
char dname[8];
int cnt;
/* get first 8 characters */
/* if less than 8 characters, pad with spaces */
for (cnt=0; name[cnt] && cnt<8; cnt++)
dname[cnt]=name[cnt];
while(cnt<8) dname[cnt++] = ' ';
/* search for char devices with the right name */
while (cur &&
((!(cur->attr & ATTR_CHAR)) ||
memcmp(cur->name,dname,8))) {
cur_ptr = cur->next_dev;
if (cur_ptr == NONEXT) cur=NULL;
else cur = PTR_REAL_TO_LIN(SELECTOROF(cur_ptr),OFFSETOF(cur_ptr));
}
return cur_ptr;
}
示例13: xpc_walk_init
static int
xpc_walk_init(mdb_walk_state_t *wsp)
{
fmd_xprt_class_hash_t xch;
if (mdb_vread(&xch, sizeof (xch), wsp->walk_addr) != sizeof (xch)) {
mdb_warn("failed to read fmd_xprt_class_hash at %p",
wsp->walk_addr);
return (WALK_ERR);
}
return (hash_walk_init(wsp, (uintptr_t)xch.xch_hash, xch.xch_hashlen,
"fmd_xprt_class", sizeof (fmd_xprt_class_t),
OFFSETOF(fmd_xprt_class_t, xc_next)));
}
示例14: sparc_update_pc
/* Update Pike_fp->pc */
void sparc_update_pc(void)
{
LOAD_PIKE_FP();
#ifdef PIKE_BYTECODE_SPARC64
/* The ASR registers are implementation specific in Sparc V7 and V8. */
/* rd %pc, %o7 */
SPARC_RD(SPARC_REG_O7, SPARC_RD_REG_PC);
#else /* !0 */
/* call .+8 */
SPARC_CALL(8);
/* The new %o7 is available in the delay slot. */
#endif /* 0 */
/* stw %o7, [ %pike_fp + pc ] */
PIKE_STPTR(SPARC_REG_O7, SPARC_REG_PIKE_FP, OFFSETOF(pike_frame, pc), 1);
}
示例15: pcie_war_noplldown
/* Needs to happen when coming out of 'standby'/'hibernate' */
static void
pcie_war_noplldown(pcicore_info_t *pi)
{
sbpcieregs_t *pcieregs = pi->regs.pcieregs;
uint16 *reg16;
ASSERT(pi->sih->buscorerev == 7);
/* turn off serdes PLL down */
si_corereg(pi->sih, SI_CC_IDX, OFFSETOF(chipcregs_t, chipcontrol),
CHIPCTRL_4321_PLL_DOWN, CHIPCTRL_4321_PLL_DOWN);
/* clear srom shadow backdoor */
reg16 = &pcieregs->sprom[SRSH_BD_OFFSET];
W_REG(pi->osh, reg16, 0);
}