当前位置: 首页>>代码示例>>C++>>正文


C++ INT_TO_PTR函数代码示例

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


在下文中一共展示了INT_TO_PTR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: cmd_xmem

cmd_result_t
cmd_xmem(int unit, args_t *a)
{
    char          *token;
    unsigned int   addr, data;

    if ((token = ARG_GET(a)) == NULL) {
        return CMD_USAGE;
    }

    if (sal_strcasecmp(token, "r") == 0) {
        if ((token = ARG_GET(a)) == NULL) {
            return CMD_USAGE;
        }
        addr = parse_integer(token);
        cli_out("0x%x: %08x\n", addr, *((unsigned int *)(INT_TO_PTR(addr))));
    } else if (sal_strcasecmp(token, "w") == 0) {
        if ((token = ARG_GET(a)) == NULL) {
            return CMD_USAGE;
        }
        addr = parse_integer(token);
        if ((token = ARG_GET(a)) == NULL) {
            return CMD_USAGE;
        }
        data = parse_integer(token);
        *((unsigned int *)(INT_TO_PTR(addr))) = data;
    } else {
        cli_out(cmd_xmem_usage);
        return CMD_FAIL;
    }
    return CMD_OK;
}
开发者ID:ariavie,项目名称:bcm,代码行数:32,代码来源:xmem.c

示例2: mod_sasl_mysql_format_handler

/** 
 * @internal Main entry point to resolve requests to mysql database
 * according to the operation requested.
 */
axlPointer mod_sasl_mysql_format_handler (TurbulenceCtx    * ctx,
					  VortexConnection * conn,
					  SaslAuthBackend  * sasl_backend,
					  axlNode          * auth_db_node_conf,
					  ModSaslOpType      op_type,
					  const char       * auth_id,
					  const char       * authorization_id,
					  const char       * formated_password,
					  const char       * password,
					  const char       * serverName,
					  const char       * sasl_method,
					  axlError        ** err,
					  VortexMutex      * mutex)
{
	switch (op_type) {
	case MOD_SASL_OP_TYPE_AUTH:
		/* request to auth user */
		return INT_TO_PTR (mod_sasl_mysql_do_auth (ctx, conn, auth_db_node_conf, 
							   auth_id, authorization_id, formated_password, password, serverName, sasl_method, err));
	case MOD_SASL_OP_TYPE_LOAD_AUTH_DB:
		/* request to load database (check we can connect with current settings) */
		return INT_TO_PTR (mod_sasl_mysql_load_auth_db (ctx, sasl_backend, auth_db_node_conf, err));
	}
	return NULL;
}
开发者ID:ASPLes,项目名称:turbulence,代码行数:29,代码来源:mod_sasl_mysql.c

示例3: main

int main(int argc, char *argv[]) {
        struct bus_match_node root;
        _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
        enum bus_match_node_type i;

        zero(root);
        root.type = BUS_MATCH_ROOT;

        assert_se(bus_match_add(&root, "arg2='wal\\'do',sender='foo',type='signal',interface='bar',", filter, INT_TO_PTR(1), NULL) >= 0);
        assert_se(bus_match_add(&root, "arg2='wal\\'do2',sender='foo',type='signal',interface='bar',", filter, INT_TO_PTR(2), NULL) >= 0);
        assert_se(bus_match_add(&root, "arg3='test',sender='foo',type='signal',interface='bar',", filter, INT_TO_PTR(3), NULL) >= 0);
        assert_se(bus_match_add(&root, "arg3='test',sender='foo',type='method_call',interface='bar',", filter, INT_TO_PTR(4), NULL) >= 0);
        assert_se(bus_match_add(&root, "", filter, INT_TO_PTR(5), NULL) >= 0);
        assert_se(bus_match_add(&root, "interface='quux'", filter, INT_TO_PTR(6), NULL) >= 0);
        assert_se(bus_match_add(&root, "interface='bar'", filter, INT_TO_PTR(7), NULL) >= 0);
        assert_se(bus_match_add(&root, "member='waldo',path='/foo/bar'", filter, INT_TO_PTR(8), NULL) >= 0);
        assert_se(bus_match_add(&root, "path='/foo/bar'", filter, INT_TO_PTR(9), NULL) >= 0);
        assert_se(bus_match_add(&root, "path_namespace='/foo'", filter, INT_TO_PTR(10), NULL) >= 0);
        assert_se(bus_match_add(&root, "path_namespace='/foo/quux'", filter, INT_TO_PTR(11), NULL) >= 0);
        assert_se(bus_match_add(&root, "arg1='two'", filter, INT_TO_PTR(12), NULL) >= 0);
        assert_se(bus_match_add(&root, "member='waldo',arg2path='/prefix/'", filter, INT_TO_PTR(13), NULL) >= 0);
        assert_se(bus_match_add(&root, "member='waldo',path='/foo/bar',arg3namespace='prefix'", filter, INT_TO_PTR(14), NULL) >= 0);

        bus_match_dump(&root, 0);

        assert_se(sd_bus_message_new_signal(NULL, "/foo/bar", "bar", "waldo", &m) >= 0);
        assert_se(sd_bus_message_append(m, "ssss", "one", "two", "/prefix/three", "prefix.four") >= 0);
        assert_se(bus_message_seal(m, 1) >= 0);

        zero(mask);
        assert_se(bus_match_run(NULL, &root, 0, m) == 0);
        assert_se(mask_contains((unsigned[]) { 9, 8, 7, 5, 10, 12, 13, 14 }, 8));
开发者ID:kwirk,项目名称:systemd,代码行数:32,代码来源:test-bus-match.c

示例4: exit_status_set_test

bool exit_status_set_test(ExitStatusSet *x, int code, int status) {

        if (exit_status_set_is_empty(x))
                return false;

        if (code == CLD_EXITED && set_contains(x->status, INT_TO_PTR(status)))
                return true;

        if (IN_SET(code, CLD_KILLED, CLD_DUMPED) && set_contains(x->signal, INT_TO_PTR(status)))
                return true;

        return false;
}
开发者ID:davide125,项目名称:systemd,代码行数:13,代码来源:exit-status.c

示例5: cmd_stk_port_set

cmd_result_t
cmd_stk_port_set(int unit, args_t *args)
{
    parse_table_t	pt;
    int rv;
    int stk_unit = unit;
    int stk_port = -1; /* This is intentionally a port */
    int capable = 0,
        enable = 1,
        inactive = 0,
        simplex = 0,
        internal = 0,
        duplex = 0;
    uint32 flags = 0;

    parse_table_init(unit, &pt);
    parse_table_add(&pt, "Unit", PQ_DFL|PQ_INT,
		    INT_TO_PTR(unit), &stk_unit, 0);
    parse_table_add(&pt, "Port", PQ_DFL|PQ_PORT, 0, &stk_port, 0);
    parse_table_add(&pt, "Capable", PQ_DFL|PQ_BOOL, 0, &capable, 0);
    parse_table_add(&pt, "Enable", PQ_DFL|PQ_BOOL, INT_TO_PTR(1), &enable, 0);
    parse_table_add(&pt, "Inactive", PQ_DFL|PQ_BOOL, 0, &inactive, 0);
    parse_table_add(&pt, "Simplex", PQ_DFL|PQ_BOOL, 0, &simplex, 0);
    parse_table_add(&pt, "Duplex", PQ_DFL|PQ_BOOL, 0, &duplex, 0);
    parse_table_add(&pt, "Internal", PQ_DFL|PQ_BOOL, 0, &internal, 0);
    if (parse_arg_eq(args, &pt) < 0) {
        parse_arg_eq_done(&pt);
        return CMD_USAGE;
    }
    parse_arg_eq_done(&pt);
    if (stk_port < 0) {
        printk("ERROR: Must specify port number > 0\n");
        return CMD_USAGE;
    }

    flags |= capable ?   BCM_STK_CAPABLE   : 0;
    flags |= enable ?    BCM_STK_ENABLE    : 0;
    flags |= inactive ?  BCM_STK_INACTIVE  : 0;
    flags |= simplex ?   BCM_STK_SIMPLEX   : 0;
    flags |= duplex ?    BCM_STK_DUPLEX    : 0;
    flags |= internal ?  BCM_STK_INTERNAL  : 0;

    rv = bcm_stk_port_set(stk_unit, stk_port, flags);
    if (rv < 0) {
        printk("ERROR: stk_port_set unit %d port %d flags 0x%x: %s\n",
               stk_unit, stk_port, flags, bcm_errmsg(rv));
        return CMD_FAIL;
    }

    return CMD_OK;
}
开发者ID:ariavie,项目名称:bcm,代码行数:51,代码来源:stk.c

示例6: test_mnt_id

static void test_mnt_id(void) {
        _cleanup_fclose_ FILE *f = NULL;
        Hashmap *h;
        Iterator i;
        char *p;
        void *k;
        int r;

        log_info("/* %s */", __func__);

        assert_se(f = fopen("/proc/self/mountinfo", "re"));
        assert_se(h = hashmap_new(&trivial_hash_ops));

        for (;;) {
                _cleanup_free_ char *line = NULL, *path = NULL;
                int mnt_id;

                r = read_line(f, LONG_LINE_MAX, &line);
                if (r == 0)
                        break;
                assert_se(r > 0);

                assert_se(sscanf(line, "%i %*s %*s %*s %ms", &mnt_id, &path) == 2);

                log_debug("mountinfo: %s → %i", path, mnt_id);

                assert_se(hashmap_put(h, INT_TO_PTR(mnt_id), path) >= 0);
                path = NULL;
        }

        HASHMAP_FOREACH_KEY(p, k, h, i) {
                int mnt_id = PTR_TO_INT(k), mnt_id2;

                r = path_get_mnt_id(p, &mnt_id2);
                if (r < 0) {
                        log_debug_errno(r, "Failed to get the mnt id of %s: %m\n", p);
                        continue;
                }

                log_debug("mnt ids of %s are %i, %i\n", p, mnt_id, mnt_id2);

                if (mnt_id == mnt_id2)
                        continue;

                /* The ids don't match? If so, then there are two mounts on the same path, let's check if
                 * that's really the case */
                char *t = hashmap_get(h, INT_TO_PTR(mnt_id2));
                log_debug("the other path for mnt id %i is %s\n", mnt_id2, t);
                assert_se(path_equal(p, t));
        }
开发者ID:Keruspe,项目名称:systemd,代码行数:50,代码来源:test-mountpoint-util.c

示例7: DBG

static struct health_channel *create_channel(struct health_app *app,
						uint8_t mdep_index,
						struct health_device *dev)
{
	struct mdep_cfg *mdep;
	struct health_channel *channel;
	static unsigned int channel_id = 1;

	DBG("mdep %u", mdep_index);

	if (!dev || !app)
		return NULL;

	mdep = queue_find(app->mdeps, match_mdep_by_id, INT_TO_PTR(mdep_index));
	if (!mdep) {
		if (mdep_index == MDEP_ECHO) {
			mdep = new0(struct mdep_cfg, 1);
			if (!mdep)
				return NULL;

			/* Leave other configuration zeroes */
			mdep->id = MDEP_ECHO;

			if (!queue_push_tail(app->mdeps, mdep)) {
				free_mdep_cfg(mdep);
				return NULL;
			}
		} else
			return NULL;
开发者ID:aguedes,项目名称:bluez,代码行数:29,代码来源:health.c

示例8: bcm_regex_report_control

static int
bcm_regex_report_control(int unit, sal_usecs_t interval)
{
    _bcm_ft_report_ctrl_t *rctrl = _bcm_ft_report_ctrl[unit];
    char name[32];

    rctrl = _bcm_ft_report_ctrl[unit];

    sal_snprintf(name, sizeof(name), "bcmFtExportDma.%d", unit);

    rctrl->interval = interval;
    if (interval) {
        if (rctrl->pid == SAL_THREAD_ERROR) {
            rctrl->pid = sal_thread_create(name, SAL_THREAD_STKSZ,
                                                soc_property_get(unit, spn_BCM_FT_REPORT_THREAD_PRI, 50),
                                                _bcm_report_fifo_dma_thread,
                                                INT_TO_PTR(unit));
            if (rctrl->pid == SAL_THREAD_ERROR) {
                LOG_ERROR(BSL_LS_BCM_COMMON,
                          (BSL_META_U(unit,
                                      "%s: Could not start thread\n"),
                                      FUNCTION_NAME()));
                return BCM_E_MEMORY;
            }
        }
    } else {
        /* Wake up thread so it will check the changed interval value */
        sal_sem_give(SOC_CONTROL(unit)->ftreportIntr);
    }

    return BCM_E_NONE;
}
开发者ID:ariavie,项目名称:bcm,代码行数:32,代码来源:re_report.c

示例9: bt_health_unregister_app

static void bt_health_unregister_app(const void *buf, uint16_t len)
{
	const struct hal_cmd_health_unreg_app *cmd = buf;
	struct health_app *app;

	DBG("");

	app = queue_remove_if(apps, match_app_by_id, INT_TO_PTR(cmd->app_id));
	if (!app) {
		ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_HEALTH,
				HAL_OP_HEALTH_UNREG_APP, HAL_STATUS_INVALID);
		return;
	}

	send_app_reg_notify(app, HAL_HEALTH_APP_DEREG_SUCCESS);

	if (record_id > 0) {
		bt_adapter_remove_record(record_id);
		record_id = 0;
	}

	free_health_app(app);
	ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_HEALTH,
				HAL_OP_HEALTH_UNREG_APP, HAL_STATUS_SUCCESS);
}
开发者ID:ghent360,项目名称:bluez,代码行数:25,代码来源:health.c

示例10: DBG

static struct health_channel *search_channel_by_id(uint16_t id)
{
	const struct queue_entry *apps_entry, *devices_entry;
	struct health_app *app;
	struct health_channel *channel;
	struct health_device *dev;

	DBG("");

	apps_entry = queue_get_entries(apps);
	while (apps_entry) {
		app = apps_entry->data;
		devices_entry = queue_get_entries(app->devices);
		while (devices_entry) {
			dev = devices_entry->data;
			channel = queue_find(dev->channels, match_channel_by_id,
								INT_TO_PTR(id));

			if (channel)
				return channel;

			devices_entry = devices_entry->next;
		}

		apps_entry = apps_entry->next;
	}

	return NULL;
}
开发者ID:ghent360,项目名称:bluez,代码行数:29,代码来源:health.c

示例11: myqttd_conn_mgr_on_close

/** 
 * @internal Handler called once the connection is about to be closed.
 * 
 * @param conn The connection to close.
 */
void myqttd_conn_mgr_on_close (MyQttConn * conn, 
				   axlPointer         user_data)
{
	/* get myqttd context */
	MyQttdCtx          * ctx = user_data;

	/* check if we are the last reference */
	if (myqtt_conn_ref_count (conn) == 1)
		return;

	/* do not remove if hash is not defined */
	if (ctx->conn_mgr_hash == NULL)
		return;

	/* new connection created: configure it */
	myqtt_mutex_lock (&ctx->conn_mgr_mutex);

	/* remove from the hash */
	axl_hash_remove (ctx->conn_mgr_hash, INT_TO_PTR (myqtt_conn_get_id (conn)));

	/* unlock */
	myqtt_mutex_unlock (&ctx->conn_mgr_mutex);


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

示例12: disconnect_cb

static bool disconnect_cb(struct io *io, void *user_data)
{
	struct bt_att *att = user_data;
	int err;
	socklen_t len;

	len = sizeof(err);

	if (getsockopt(att->fd, SOL_SOCKET, SO_ERROR, &err, &len) < 0) {
		util_debug(att->debug_callback, att->debug_data,
					"Failed to obtain disconnect error: %s",
					strerror(errno));
		err = 0;
	}

	util_debug(att->debug_callback, att->debug_data,
					"Physical link disconnected: %s",
					strerror(err));

	io_destroy(att->io);
	att->io = NULL;

	bt_att_cancel_all(att);

	bt_att_ref(att);

	queue_foreach(att->disconn_list, disconn_handler, INT_TO_PTR(err));

	bt_att_unregister_all(att);
	bt_att_unref(att);

	return false;
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:33,代码来源:att.c

示例13: soc_ipoll_connect

/*
 * Function:
 *      soc_ipoll_connect
 * Description:
 *      Install interrupt handler in polled IRQ mode
 * Parameters:
 *      dev - device number
 *      handler - interrupt handler
 *      data - interrupt handler data
 * Return Value:
 *      BCM_E_NONE
 *      BCM_E_XXX - an error occurred
 * Notes:
 *      The first handler installed be cause the polling
 *      thread to be created.
 */
int
soc_ipoll_connect(int dev, ipoll_handler_t handler, void *data)
{
    int spl;
    int udelay, prio;
    int start_thread = 0;

    if (dev >= SOC_MAX_NUM_DEVICES) {
        return SOC_E_PARAM;
    }

    spl = sal_splhi();

    if (_ictrl[dev].handler == NULL) {
        if (_ihandlers++ == 0) {
            /* Create thread if first handler */
            start_thread = 1;
        }
    }
    _ictrl[dev].handler = handler;
    _ictrl[dev].data = data;
    _ictrl[dev].paused = 0;

    sal_spl(spl);

    if (start_thread) {
        udelay = soc_property_get(dev, spn_POLLED_IRQ_DELAY, IPOLL_THREAD_DELAY);
        prio = soc_property_get(dev, spn_POLLED_IRQ_PRIORITY, IPOLL_THREAD_PRIO);
        sal_thread_create("bcmPOLL",
                          SAL_THREAD_STKSZ, prio,
                          soc_ipoll_thread, INT_TO_PTR(udelay));
    }

    return SOC_E_NONE;
}
开发者ID:ariavie,项目名称:bcm,代码行数:51,代码来源:ipoll.c

示例14: mod_sasl_mysql_do_query

/** 
 * @internal Function that makes a SQL connection to the configured
 * database and return a MYSQL_RES object that contains the result or
 * axl_true in the case non_query is axl_true.
 *
 * With the result created, the caller must do:
 *
 * \code
 * MYSQL_ROW row;
 *
 * // get a cell data
 * row = mysql_fetch_row (result);
 * row[i] -> each field.
 *
 * // to release 
 * mysql_free_result (result);
 * \endcode
 */
MYSQL_RES * mod_sasl_mysql_do_query (TurbulenceCtx  * ctx, 
				     axlNode        * auth_db_node_conf,
				     const char     * sql_query,
				     axl_bool         non_query,
				     axlError      ** err)
{  
	MYSQL     * conn;

	/* check sql connection */
	if (sql_query == NULL) {
		axl_error_report (err, -1, "Unable to run SQL query, received NULL content, failed to run SQL command");
		return NULL;
	} /* end if */

	/* get connection */
	conn = mod_sasl_mysql_get_connection (ctx, auth_db_node_conf, err);
	if (conn == NULL) {
		axl_error_report (err, -1, "Failed to get connection to MySQL database. Unable to execute query: %s", sql_query);
		return NULL;
	}

	/* now run query */
	if (mysql_query (conn, sql_query)) {
		axl_error_report (err, mysql_errno (conn), "Failed to run SQL query, error was %u: %s\n", mysql_errno (conn), mysql_error (conn));
		return NULL;
	} /* end if */
	
	/* check if this is a non query and return proper status now */
	if (non_query)
		return INT_TO_PTR (axl_true);

	/* return result created */
	return mysql_store_result (conn);
}
开发者ID:ASPLes,项目名称:turbulence,代码行数:52,代码来源:mod_sasl_mysql.c

示例15: myqttd_conn_mgr_find_by_id

/** 
 * @brief Allows to get a reference to the registered connection with
 * the provided id. The function will return a reference to a
 * MyQttConn owned by the myqttd connection
 * manager. 
 *
 * @param ctx The myqttd conext where the connection reference will be looked up.
 * @param conn_id The connection id to lookup.
 *
 * @return A MyQttConn reference or NULL value it if fails.
 */
MyQttConn * myqttd_conn_mgr_find_by_id (MyQttdCtx * ctx,
						   int             conn_id)
{
	MyQttConn       * conn = NULL;
	MyQttdConnMgrState * state;

	v_return_val_if_fail (ctx, NULL);

	/* lock and send */
	myqtt_mutex_lock (&ctx->conn_mgr_mutex);
	
	/* get the connection */
	state = axl_hash_get (ctx->conn_mgr_hash, INT_TO_PTR (conn_id));
	
	/* set conection */
	/* msg ("Connection find_by_id for conn id=%d returned pointer %p (conn: %p)", conn_id, state, state ? state->conn : NULL); */
	if (state)
		conn = state->conn;

	/* unlock */
	myqtt_mutex_unlock (&ctx->conn_mgr_mutex);

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


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