• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ PTR_TO_INT函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中PTR_TO_INT函数的典型用法代码示例。如果您正苦于以下问题:C++ PTR_TO_INT函数的具体用法?C++ PTR_TO_INT怎么用?C++ PTR_TO_INT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了PTR_TO_INT函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:MOBO-OSS,项目名称:systemd-relative,代码行数:35,代码来源:test-bus-server.c


示例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;
}
开发者ID:rhvgoyal,项目名称:systemd,代码行数:34,代码来源:test-bus-objects.c


示例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;
}
开发者ID:ASPLes,项目名称:turbulence,代码行数:30,代码来源:turbulence-loop.c


示例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);
}
开发者ID:ariavie,项目名称:bcm,代码行数:28,代码来源:TkMsgProcess.c


示例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;
}
开发者ID:ghent360,项目名称:bluez,代码行数:7,代码来源:health.c


示例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;
}
开发者ID:ariavie,项目名称:bcm,代码行数:26,代码来源:cos.c


示例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;
}
开发者ID:tblume,项目名称:systemd-testsuite-suse,代码行数:30,代码来源:udevadm-monitor.c


示例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;
}
开发者ID:275288698,项目名称:systemd-ubuntu-with-dbus,代码行数:7,代码来源:test-event.c


示例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;
}
开发者ID:275288698,项目名称:systemd-ubuntu-with-dbus,代码行数:29,代码来源:test-event.c


示例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);
}
开发者ID:ariavie,项目名称:bcm,代码行数:41,代码来源:ipoll.c


示例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;
}
开发者ID:ghent360,项目名称:bluez,代码行数:7,代码来源:health.c


示例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;
}
开发者ID:ariavie,项目名称:bcm,代码行数:30,代码来源:cputrans.c


示例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];
}
开发者ID:ariavie,项目名称:bcm,代码行数:35,代码来源:alloc.c


示例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;
}
开发者ID:ghent360,项目名称:bluez,代码行数:7,代码来源:health.c


示例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;
}
开发者ID:ghent360,项目名称:bluez,代码行数:7,代码来源:health.c


示例16: __myqttd_conn_mgr_proxy_on_close

void __myqttd_conn_mgr_proxy_on_close (MyQttConn * conn, axlPointer _loop)
{
	MyQttdLoop  * loop = _loop;
	/* MyQttdCtx   * ctx  = myqttd_loop_ctx (loop); */

	/* get socket associated */
	int               _socket = PTR_TO_INT (myqtt_conn_get_data (conn, "myqttd:proxy:fd"));	

	/* msg ("PROXY: closing connection-id=%d, refs=%d, socket=%d", 
	   myqtt_conn_get_id (conn), myqtt_conn_ref_count (conn), _socket); */

	/* unregister socket from loop watcher */
	/* msg ("PROXY: calling to unwatch descriptor from loop _socket=%d (finished watching=%d)", _socket, myqttd_loop_watching (loop)); */
	myqttd_loop_unwatch_descriptor (loop, _socket, axl_true);
	/* msg ("PROXY: calling to unwatch descriptor from loop _socket=%d (finished watching=%d)", _socket, myqttd_loop_watching (loop)); */

	/* close socket */
	myqtt_close_socket (_socket);
	
	/* release and shutdown */
	conn->preread_handler   = NULL;
	conn->preread_user_data = NULL;

	/* reduce reference counting but do it out side the close handler */
	myqtt_thread_pool_new_task (CONN_CTX (conn), __myqttd_conn_mgr_release_proxy_conn, conn);

	return;
}
开发者ID:ASPLes,项目名称:myqtt,代码行数:28,代码来源:myqttd-conn-mgr.c


示例17: NameNH

INLINE HCHAR *NameNH(memchr_search)(void *data,
				    HCHAR *haystack,
				    ptrdiff_t haystacklen)
{
  return NameNH(MEMCHR)(haystack,
			DO_NOT_WARN((NCHAR)(ptrdiff_t) PTR_TO_INT(data)),
			haystacklen);
}
开发者ID:ajinkya007,项目名称:pike-1,代码行数:8,代码来源:pike_search_engine2.c


示例18: get_irg_graph_nr

long get_irg_graph_nr(const ir_graph *irg)
{
#ifdef DEBUG_libfirm
	return irg->graph_nr;
#else
	return PTR_TO_INT(irg);
#endif
}
开发者ID:MatzeB,项目名称:libfirm,代码行数:8,代码来源:irgraph.c


示例19: add_watch

static dbus_bool_t add_watch(DBusWatch *watch, void *data) {
        EpollData _cleanup_free_ *e = NULL;
        struct epoll_event ev;

        assert(watch);

        e = new0(EpollData, 1);
        if (!e)
                return FALSE;

        e->fd = dbus_watch_get_unix_fd(watch);
        e->object = watch;
        e->is_timeout = false;

        zero(ev);
        ev.events = bus_flags_to_events(watch);
        ev.data.ptr = e;

        if (epoll_ctl(PTR_TO_INT(data), EPOLL_CTL_ADD, e->fd, &ev) < 0) {

                if (errno != EEXIST)
                        return FALSE;

                /* Hmm, bloody D-Bus creates multiple watches on the
                 * same fd. epoll() does not like that. As a dirty
                 * hack we simply dup() the fd and hence get a second
                 * one we can safely add to the epoll(). */

                e->fd = dup(e->fd);
                if (e->fd < 0)
                        return FALSE;

                if (epoll_ctl(PTR_TO_INT(data), EPOLL_CTL_ADD, e->fd, &ev) < 0) {
                        close_nointr_nofail(e->fd);
                        return FALSE;
                }

                e->fd_is_dupped = true;
        }

        dbus_watch_set_data(watch, e, NULL);
        e = NULL; /* prevent freeing */

        return TRUE;
}
开发者ID:olegchir,项目名称:systemd,代码行数:45,代码来源:dbus-loop.c


示例20: get_entity_nr

long get_entity_nr(const ir_entity *ent)
{
	assert(ent->kind == k_entity);
#ifdef DEBUG_libfirm
	return ent->nr;
#else
	return (long)PTR_TO_INT(ent);
#endif
}
开发者ID:qznc,项目名称:libfirm,代码行数:9,代码来源:entity.c



注:本文中的PTR_TO_INT函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ PTX函数代码示例发布时间:2022-05-30
下一篇:
C++ PTR_ERR_OR_ZERO函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap