本文整理汇总了C++中PTR_TO_INT函数的典型用法代码示例。如果您正苦于以下问题:C++ PTR_TO_INT函数的具体用法?C++ PTR_TO_INT怎么用?C++ PTR_TO_INT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PTR_TO_INT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_one
static int test_one(bool client_negotiate_unix_fds, bool server_negotiate_unix_fds,
bool client_anonymous_auth, bool server_anonymous_auth) {
struct context c;
pthread_t s;
void *p;
int r, q;
zero(c);
assert_se(socketpair(AF_UNIX, SOCK_STREAM, 0, c.fds) >= 0);
c.client_negotiate_unix_fds = client_negotiate_unix_fds;
c.server_negotiate_unix_fds = server_negotiate_unix_fds;
c.client_anonymous_auth = client_anonymous_auth;
c.server_anonymous_auth = server_anonymous_auth;
r = pthread_create(&s, NULL, server, &c);
if (r != 0)
return -r;
r = client(&c);
q = pthread_join(s, &p);
if (q != 0)
return -q;
if (r < 0)
return r;
if (PTR_TO_INT(p) < 0)
return PTR_TO_INT(p);
return 0;
}
示例2: main
int main(int argc, char *argv[]) {
struct context c = {};
pthread_t s;
void *p;
int r, q;
zero(c);
c.automatic_integer_property = 4711;
assert_se(c.automatic_string_property = strdup("dudeldu"));
assert_se(socketpair(AF_UNIX, SOCK_STREAM, 0, c.fds) >= 0);
r = pthread_create(&s, NULL, server, &c);
if (r != 0)
return -r;
r = client(&c);
q = pthread_join(s, &p);
if (q != 0)
return -q;
if (r < 0)
return r;
if (PTR_TO_INT(p) < 0)
return PTR_TO_INT(p);
free(c.something);
free(c.automatic_string_property);
return EXIT_SUCCESS;
}
示例3: __turbulence_loop_discard_broken
void __turbulence_loop_discard_broken (TurbulenceCtx * ctx, TurbulenceLoop * loop)
{
int loop_descriptor;
int result = -1;
char bytes[4];
/* reset cursor */
axl_list_cursor_first (loop->cursor);
while (axl_list_cursor_has_item (loop->cursor)) {
/* get loop descriptor */
loop_descriptor = PTR_TO_INT (axl_list_cursor_get (loop->cursor));
/* now add to the waiting socket */
result = recv (loop_descriptor, bytes, 1, MSG_PEEK);
if (result == -1 && errno == EBADF) {
/* failed to add descriptor, close it and remove from wait list */
error ("Discarding descriptor %d because it is broken/invalid (EBADF/%d)", loop_descriptor, errno);
/* remove cursor */
axl_list_cursor_remove (loop->cursor);
continue;
} /* end if */
/* get the next item */
axl_list_cursor_next (loop->cursor);
} /* end if */
return;
}
示例4: TkAlarmRxThread
void
TkAlarmRxThread(void *cookie)
{
int16 MsgLen = 0;
TkMsgBuff *pMsgBuf ;
uint32 pathId = PTR_TO_INT(cookie);
pMsgBuf = (TkMsgBuff *) TkOamMemGet(pathId);
while (1) {
if ((MsgLen =
sal_msg_rcv(gTagLinkCfg[pathId].almMsgQid,
(char *) pMsgBuf,
TK_MAX_RX_TX_DATA_LENGTH, WAIT_FOREVER)) < 0) {
sal_usleep(1);
continue;
} else {
if (TkDbgLevelIsSet(TkDbgMsgEnable | TkDbgAlmEnable)) {
TkDbgPrintf(("\r\nAlmTask received a msg\n"));
TkDbgDataDump((uint8 *) pMsgBuf, MsgLen, 16);
}
if (ieeeAlmProcessFn)
ieeeAlmProcessFn(pathId, pMsgBuf->buff, MsgLen);
}
sal_usleep(1);
}
TkOamMemPut(pathId,(void *) pMsgBuf);
}
示例5: match_app_by_id
static bool match_app_by_id(const void *data, const void *user_data)
{
const struct health_app *app = data;
uint16_t app_id = PTR_TO_INT(user_data);
return app->id == app_id;
}
示例6: _bcm_gport_show_bandwidth
STATIC int
_bcm_gport_show_bandwidth(int unit, bcm_gport_t port, int numq,
uint32 flags, bcm_gport_t sched_gport, void *user_data)
{
bcm_cos_queue_t cosq;
bcm_port_t user_port = PTR_TO_INT(user_data);
bcm_port_t local_port = 0;
uint32 kbits_sec_min, kbits_sec_max, bw_flags;
BCM_IF_ERROR_RETURN(
bcm_port_local_get(unit, port, &local_port));
if (user_port != local_port) {
return BCM_E_NONE;
}
for (cosq = 0; cosq < 16; cosq++) {
if (bcm_cosq_gport_bandwidth_get(unit, sched_gport, cosq,
&kbits_sec_min, &kbits_sec_max, &bw_flags) == 0) {
printk(" U %4s | %d | %8d | %8d | %6d\n",
BCM_PORT_NAME(unit, local_port), cosq, kbits_sec_min,
kbits_sec_max, bw_flags);
}
}
return BCM_E_NONE;
}
示例7: device_monitor_handler
static int device_monitor_handler(sd_device_monitor *monitor, sd_device *device, void *userdata) {
const char *action = NULL, *devpath = NULL, *subsystem = NULL;
MonitorNetlinkGroup group = PTR_TO_INT(userdata);
struct timespec ts;
assert(device);
assert(IN_SET(group, MONITOR_GROUP_UDEV, MONITOR_GROUP_KERNEL));
(void) sd_device_get_property_value(device, "ACTION", &action);
(void) sd_device_get_devpath(device, &devpath);
(void) sd_device_get_subsystem(device, &subsystem);
assert_se(clock_gettime(CLOCK_MONOTONIC, &ts) == 0);
printf("%-6s[%"PRI_TIME".%06"PRI_NSEC"] %-8s %s (%s)\n",
group == MONITOR_GROUP_UDEV ? "UDEV" : "KERNEL",
ts.tv_sec, (nsec_t)ts.tv_nsec/1000,
action, devpath, subsystem);
if (arg_show_property) {
const char *key, *value;
FOREACH_DEVICE_PROPERTY(device, key, value)
printf("%s=%s\n", key, value);
printf("\n");
}
return 0;
}
示例8: exit_handler
static int exit_handler(sd_event_source *s, void *userdata) {
log_info("got quit handler on %c", PTR_TO_INT(userdata));
got_exit = true;
return 3;
}
示例9: signal_handler
static int signal_handler(sd_event_source *s, const struct signalfd_siginfo *si, void *userdata) {
sd_event_source *p = NULL;
sigset_t ss;
pid_t pid;
assert_se(s);
assert_se(si);
log_info("got signal on %c", PTR_TO_INT(userdata));
assert_se(userdata == INT_TO_PTR('e'));
assert_se(sigemptyset(&ss) >= 0);
assert_se(sigaddset(&ss, SIGCHLD) >= 0);
assert_se(sigprocmask(SIG_BLOCK, &ss, NULL) >= 0);
pid = fork();
assert_se(pid >= 0);
if (pid == 0)
_exit(0);
assert_se(sd_event_add_child(sd_event_source_get_event(s), &p, pid, WEXITED, child_handler, INT_TO_PTR('f')) >= 0);
assert_se(sd_event_source_set_enabled(p, SD_EVENT_ONESHOT) >= 0);
sd_event_source_unref(s);
return 1;
}
示例10: soc_ipoll_thread
/*
* Function:
* soc_ipoll_thread
* Description:
* Thread context for interrupt handlers in polled IRQ mode
* Parameters:
* data - poll delay in usecs (passed as pointer)
* Returns:
* Nothing
*/
STATIC void
soc_ipoll_thread(void *data)
{
int dev, spl, udelay;
udelay = PTR_TO_INT(data);
while (_ihandlers) {
spl = sal_splhi();
for (dev = 0; dev < SOC_MAX_NUM_DEVICES; dev++) {
if (_ictrl[dev].handler != NULL && !_ictrl[dev].paused) {
if (soc_feature(dev, soc_feature_cmicm)) {
soc_cmicm_ipoll_handler(dev);
} else {
soc_cmic_ipoll_handler(dev);
}
}
}
sal_spl(spl);
if (udelay) {
sal_usleep(udelay);
} else {
sal_thread_yield();
}
}
sal_thread_exit(0);
}
示例11: match_mdep_by_id
static bool match_mdep_by_id(const void *data, const void *user_data)
{
const struct mdep_cfg *mdep = data;
uint16_t mdep_id = PTR_TO_INT(user_data);
return mdep->id == mdep_id;
}
示例12: cputrans_rx_pkt_free
void
cputrans_rx_pkt_free(bcm_pkt_t *pkt)
{
int idx;
if (pkt == NULL) {
LOG_INFO(BSL_LS_TKS_CTPKT,
(BSL_META("CT free: Packet NULL\n")));
return;
}
if (!_rx_setup_done) {
LOG_INFO(BSL_LS_TKS_CTPKT,
(BSL_META("CT free: Not initialized\n")));
return;
}
idx = PTR_TO_INT(pkt->cookie2);
if (idx >= _rx_lists) {
LOG_INFO(BSL_LS_TKS_CTPKT,
(BSL_META("CT free: bad CT index: %d > %d\n"),
idx, _rx_lists));
return;
}
CPUTRANS_LOCK;
pkt->next = _rx_free_lists[idx];
_rx_free_lists[idx] = pkt;
CPUTRANS_UNLOCK;
}
示例13: sal_dma_alloc
void *
sal_dma_alloc(size_t sz, char *s)
{
uint32 *p;
/*
* Round up size to accommodate corruption detection sentinels.
* Place sentinels at the beginning and end of the data area to
* detect memory corruption. These are verified on free.
*/
sz = (sz + 3) & ~3;
if ((p = malloc(sz + 12)) == 0) {
return p;
}
assert(INT_TO_PTR(PTR_TO_INT(p)) == p);
p[0] = sz / 4;
p[1] = 0xaaaaaaaa;
p[2 + sz / 4] = 0xbbbbbbbb;
#ifdef BROADCOM_DEBUG
#ifdef INCLUDE_BCM_SAL_PROFILE
SAL_DMA_ALLOC_RESOURCE_USAGE_INCR(
_sal_dma_alloc_curr,
_sal_dma_alloc_max,
(sz),
ilock);
#endif
#endif /* BROADCOM_DEBUG */
MEMLOG_ALLOC("sal_dma_alloc", &p[0], orig_sz, s);
return (void *) &p[2];
}
示例14: match_mdep_by_role
static bool match_mdep_by_role(const void *data, const void *user_data)
{
const struct mdep_cfg *mdep = data;
uint16_t role = PTR_TO_INT(user_data);
return mdep->role == role;
}
示例15: match_channel_by_mdep_id
static bool match_channel_by_mdep_id(const void *data, const void *user_data)
{
const struct health_channel *channel = data;
uint16_t mdep_id = PTR_TO_INT(user_data);
return channel->mdep_id == mdep_id;
}