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

C++ INT_TO_PTR函数代码示例

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

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



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


示例16: link_new

int link_new(Manager *m, Link **ret, int ifindex) {
        _cleanup_(link_freep) Link *l = NULL;
        int r;

        assert(m);
        assert(ifindex > 0);

        r = hashmap_ensure_allocated(&m->links, NULL);
        if (r < 0)
                return r;

        l = new0(Link, 1);
        if (!l)
                return -ENOMEM;

        l->ifindex = ifindex;
        l->llmnr_support = RESOLVE_SUPPORT_YES;
        l->mdns_support = RESOLVE_SUPPORT_NO;
        l->dnssec_mode = _DNSSEC_MODE_INVALID;

        r = hashmap_put(m->links, INT_TO_PTR(ifindex), l);
        if (r < 0)
                return r;

        l->manager = m;

        if (ret)
                *ret = l;
        l = NULL;

        return 0;
}
开发者ID:nmartensen,项目名称:systemd,代码行数:32,代码来源:resolved-link.c


示例17: turbulence_loop_close

/** 
 * @brief Finishes the provided \ref TurbulenceLoop, releasing
 * resources and stopping its resources.
 *
 * @param loop The loop to finish.
 *
 * @param notify In the case the internal thread started by the loop
 * should be notified to be stopped.
 */
void             turbulence_loop_close (TurbulenceLoop * loop, axl_bool notify)
{
	if (loop == NULL)
		return;

	/* now finish log manager */
	if (notify && loop->queue != NULL) {
		vortex_async_queue_push (loop->queue, INT_TO_PTR (-4));
		vortex_thread_destroy (&loop->thread, axl_false);
	} /* end if */	
	
	axl_list_free (loop->list);
	loop->list = NULL;

	axl_list_cursor_free (loop->cursor);
	loop->cursor = NULL;

	vortex_async_queue_unref (loop->queue);
	loop->queue = NULL;

	__vortex_io_waiting_default_destroy (loop->fileset);
	loop->fileset = NULL;

	axl_free (loop);

	return;
}
开发者ID:ASPLes,项目名称:turbulence,代码行数:36,代码来源:turbulence-loop.c


示例18: is_clean_exit

bool is_clean_exit(int code, int status, ExitClean clean, ExitStatusSet *success_status) {

        if (code == CLD_EXITED)
                return status == 0 ||
                       (success_status &&
                        set_contains(success_status->status, INT_TO_PTR(status)));

        /* If a daemon does not implement handlers for some of the signals that's not considered an unclean shutdown */
        if (code == CLD_KILLED)
                return
                        (clean == EXIT_CLEAN_DAEMON && IN_SET(status, SIGHUP, SIGINT, SIGTERM, SIGPIPE)) ||
                        (success_status &&
                         set_contains(success_status->signal, INT_TO_PTR(status)));

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


示例19: soc_i2c_max664x_monitor

/*
 * Function: soc_i2c_max664x_monitor
 *
 * Purpose:
 *     Monitor configuration: start or stop a temperature probe
 *     task to monitor temperatures every nsecs.
 * Parameters:
 *    unit - StrataSwitch device number or I2C bus number
 *    enable - start or stop a temperature probe task
 *    nsecs - number of seconds delay, between succesive queries.
 *  Returns:
 *    None
 *  Notes:
 *    None
 */
void
soc_i2c_max664x_monitor(int unit, int enable, int nsecs)
{
    if (!soc_i2c_is_attached(unit)) {
        soc_i2c_attach(unit, 0, 0);
    }
    if (max664x_info[unit] == NULL) {
        return;
    }
    if (!enable) {
        max664x_info[unit]->sleep = 0;
        return;
    }
    if (max664x_info[unit]->sleep) {
        return;
    }
    max664x_info[unit]->sleep = nsecs;
    
    sal_thread_create("bcmTEMP",
                      SAL_THREAD_STKSZ,
                      50,
                      (void (*)(void*))max664x_thread,
                      INT_TO_PTR(unit));
    LOG_CLI((BSL_META_U(unit,
                        "unit %d: thermal monitoring enabled\n"), unit));
}
开发者ID:ariavie,项目名称:bcm,代码行数:41,代码来源:max664x.c


示例20: list_bus_names

static int list_bus_names(sd_bus *bus, char **argv) {
        _cleanup_strv_free_ char **acquired = NULL, **activatable = NULL;
        _cleanup_free_ char **merged = NULL;
        _cleanup_hashmap_free_ Hashmap *names = NULL;
        char **i;
        int r;
        size_t max_i = 0;
        unsigned n = 0;
        void *v;
        char *k;
        Iterator iterator;

        assert(bus);

        r = sd_bus_list_names(bus, (arg_acquired || arg_unique) ? &acquired : NULL, arg_activatable ? &activatable : NULL);
        if (r < 0) {
                log_error("Failed to list names: %s", strerror(-r));
                return r;
        }

        pager_open_if_enabled();

        names = hashmap_new(&string_hash_ops);
        if (!names)
                return log_oom();

        STRV_FOREACH(i, acquired) {
                max_i = MAX(max_i, strlen(*i));

                r = hashmap_put(names, *i, INT_TO_PTR(1));
                if (r < 0) {
                        log_error("Failed to add to hashmap: %s", strerror(-r));
                        return r;
                }
        }
开发者ID:klausi,项目名称:systemd,代码行数:35,代码来源:busctl.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ INVALIDATE函数代码示例发布时间:2022-05-30
下一篇:
C++ INT_FATAL函数代码示例发布时间: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