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


C++ ASSERTN函数代码示例

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


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

示例1: bus_write

int bus_write(struct bus_t *self_p,
              int id,
              const void *buf_p,
              size_t size)
{
    ASSERTN(self_p != NULL, EINVAL);
    ASSERTN(buf_p != NULL, EINVAL);
    ASSERTN(size > 0, EINVAL);

    int number_of_receivers;
    struct bus_listener_t *curr_p;

    rwlock_reader_take(&self_p->rwlock);

    curr_p = (struct bus_listener_t *)binary_tree_search(
        &self_p->listeners, id);
    number_of_receivers = 0;

    while (curr_p != NULL) {
        ((struct chan_t *)curr_p->chan_p)->write(curr_p->chan_p,
                                                 buf_p,
                                                 size);
        number_of_receivers++;
        curr_p = curr_p->next_p;
    }

    rwlock_reader_give(&self_p->rwlock);

    return (number_of_receivers);
}
开发者ID:eerimoq,项目名称:simba,代码行数:30,代码来源:bus.c

示例2: settings_write_by_name

ssize_t settings_write_by_name(const char *name_p,
                               const void *src_p,
                               size_t size)
{
    ASSERTN(name_p != NULL, EINVAL);
    ASSERTN(src_p != NULL, EINVAL);
    ASSERTN(size > 0, EINVAL);

    const FAR struct setting_t *setting_p;

    /* Find the setting in the settings array. */
    setting_p = &settings[0];

    while (setting_p->name_p != NULL) {
        if (std_strcmp(name_p, setting_p->name_p) == 0) {
            if (size > setting_p->size) {
                return (-1);
            }

            return (settings_write(setting_p->address, src_p, size));
        }

        setting_p++;
    }

    return (-1);
}
开发者ID:eerimoq,项目名称:simba,代码行数:27,代码来源:settings.c

示例3: spi_init

int spi_init(struct spi_driver_t *self_p,
             struct spi_device_t *dev_p,
             struct pin_device_t *ss_pin_p,
             int mode,
             int speed,
             int polarity,
             int phase)
{
    ASSERTN(self_p != NULL, EINVAL);
    ASSERTN(dev_p != NULL, EINVAL);
    ASSERTN(ss_pin_p != NULL, EINVAL);

    self_p->dev_p = dev_p;
    self_p->mode = mode;
    self_p->speed = speed;
    self_p->polarity = polarity;
    self_p->phase = phase;

    return (spi_port_init(self_p,
                          dev_p,
                          ss_pin_p,
                          mode,
                          speed,
                          polarity,
                          phase));
}
开发者ID:eerimoq,项目名称:simba,代码行数:26,代码来源:spi.c

示例4: queue_init

int queue_init(struct queue_t *self_p,
               void *buf_p,
               size_t size)
{
    ASSERTN(self_p != NULL, EINVAL);
    ASSERTN((buf_p == NULL)
            || ((buf_p != NULL) && (size > 0)), EINVAL);

    chan_init(&self_p->base,
              (chan_read_fn_t)queue_read,
              (chan_write_fn_t)queue_write,
              (chan_size_fn_t)queue_size);
    chan_set_write_isr_cb(&self_p->base, (chan_write_fn_t)queue_write_isr);

    self_p->buffer.begin_p = buf_p;
    self_p->buffer.read_p = buf_p;
    self_p->buffer.write_p = buf_p;
    self_p->buffer.end_p = &((char*)buf_p)[size];
    self_p->buffer.size = size;

    self_p->state = QUEUE_STATE_INITIALIZED;

    self_p->buf_p = NULL;
    self_p->size = 0;
    self_p->left = 0;

    return (0);
}
开发者ID:eerimoq,项目名称:simba,代码行数:28,代码来源:queue.c

示例5: heap_free

int heap_free(struct heap_t *self_p,
              void *buf_p)
{
    ASSERTN(self_p != NULL, EINVAL);
    ASSERTN(buf_p != NULL, EINVAL);

    int count;
    struct heap_buffer_header_t *header_p;

    header_p = &((struct heap_buffer_header_t *)buf_p)[-1];

    sys_lock();

    if (header_p->count > 0) {
        header_p->count--;
        count = header_p->count;
        
        /* Free when count is zero. */
        if (count == 0) {
            if (header_p->u.fixed_p != NULL) {
                count = free_fixed_size(self_p, header_p);
            } else {
                count = free_dynamic_buffer(self_p, header_p);
            }
        }
    } else {
        count = -1;
    }

    sys_unlock();

    return (count);
}
开发者ID:eerimoq,项目名称:simba,代码行数:33,代码来源:heap.c

示例6: http_server_init

int http_server_init(struct http_server_t *self_p,
                     struct http_server_listener_t *listener_p,
                     struct http_server_connection_t *connections_p,
                     const char *root_path_p,
                     const struct http_server_route_t *routes_p,
                     http_server_route_callback_t on_no_route)
{
    ASSERTN(self_p != NULL, EINVAL);
    ASSERTN(listener_p != NULL, EINVAL)
    ASSERTN(connections_p != NULL, EINVAL);
    ASSERTN(routes_p != NULL, EINVAL);
    ASSERTN(on_no_route != NULL, EINVAL);

    struct http_server_connection_t *connection_p;

    self_p->listener_p = listener_p;
    self_p->connections_p = connections_p;
    self_p->root_path_p = root_path_p;
    self_p->routes_p = routes_p;
    self_p->on_no_route = on_no_route;

    connection_p = self_p->connections_p;

    while (connection_p->thrd.name_p != NULL) {
        connection_p->state = http_server_connection_state_free_t;
        connection_p->self_p = self_p;
        event_init(&connection_p->events);

        connection_p++;
    }

    event_init(&self_p->events);

    return (0);
}
开发者ID:eerimoq,项目名称:simba,代码行数:35,代码来源:http_server.c

示例7: event_read

ssize_t event_read(struct event_t *self_p,
                   void *buf_p,
                   size_t size)
{
    ASSERTN(self_p != NULL, EINVAL);
    ASSERTN(buf_p != NULL, EINVAL);
    ASSERTN(size == sizeof(uint32_t), EINVAL);

    uint32_t *mask_p, mask;

    mask_p = (uint32_t *)buf_p;

    sys_lock();

    mask = (self_p->mask & *mask_p);

    /* Event already set? Otherwise wait for it. */
    if (mask != 0) {
        *mask_p = mask;
    } else {
        self_p->base.reader_p = thrd_self();
        thrd_suspend_isr(NULL);
        *mask_p = (self_p->mask & *mask_p);
    }

    /* Remove read events from the event channel. */
    self_p->mask &= (~(*mask_p));

    sys_unlock();

    return (size);
}
开发者ID:eerimoq,项目名称:simba,代码行数:32,代码来源:event.c

示例8: pin_write

int pin_write(struct pin_driver_t *self_p, int value)
{
    ASSERTN(self_p != NULL, EINVAL);
    ASSERTN((value == 0) || (value == 1), EINVAL);

    return (pin_port_write(self_p, value));
}
开发者ID:eerimoq,项目名称:simba,代码行数:7,代码来源:pin.c

示例9: network_interface_wifi_init

int network_interface_wifi_init(struct network_interface_wifi_t *self_p,
                                const char *name_p,
                                struct network_interface_wifi_driver_t *driver_p,
                                void *arg_p,
                                const char *ssid_p,
                                const char *password_p)
{
    ASSERTN(self_p != NULL, EINVAL);
    ASSERTN(name_p != NULL, EINVAL);
    ASSERTN(driver_p != NULL, EINVAL);
    ASSERTN(ssid_p != NULL, EINVAL);

    self_p->network_interface.name_p = name_p;
    self_p->network_interface.start =
        (network_interface_start_t)network_interface_wifi_start;
    self_p->network_interface.stop =
        (network_interface_stop_t)network_interface_wifi_stop;
    self_p->network_interface.is_up =
        (network_interface_is_up_t)network_interface_wifi_is_up;
    self_p->network_interface.set_ip_info =
        (network_interface_set_ip_info_t)network_interface_wifi_set_ip_info;
    self_p->network_interface.get_ip_info =
        (network_interface_get_ip_info_t)network_interface_wifi_get_ip_info;

    self_p->driver_p = driver_p;
    self_p->arg_p = arg_p;
    self_p->ssid_p = ssid_p;
    self_p->password_p = password_p;
    self_p->info_p = NULL;

    /* Initialize the driver. */
    driver_p->init(arg_p);
    
    return (0);
}
开发者ID:wuwx,项目名称:simba,代码行数:35,代码来源:wifi.c

示例10: settings_read

ssize_t settings_read(void *dst_p, size_t src, size_t size)
{
    ASSERTN(dst_p != NULL, EINVAL);
    ASSERTN(src >= 0, EINVAL);
    ASSERTN(size > 0, EINVAL);

    return (settings_port_read(dst_p, src, size));
}
开发者ID:eerimoq,项目名称:simba,代码行数:8,代码来源:settings.c

示例11: settings_write

ssize_t settings_write(size_t dst, const void *src_p, size_t size)
{
    ASSERTN(dst >= 0, EINVAL);
    ASSERTN(src_p != NULL, EINVAL);
    ASSERTN(size > 0, EINVAL);

    return (settings_port_write(dst, src_p, size));
}
开发者ID:eerimoq,项目名称:simba,代码行数:8,代码来源:settings.c

示例12: network_interface_wifi_get_ip_info

int network_interface_wifi_get_ip_info(struct network_interface_wifi_t *self_p,
                                       struct inet_if_ip_info_t *info_p)
{
    ASSERTN(self_p != NULL, EINVAL);
    ASSERTN(info_p != NULL, EINVAL);

    return (self_p->driver_p->get_ip_info(self_p->arg_p, info_p));
}
开发者ID:wuwx,项目名称:simba,代码行数:8,代码来源:wifi.c

示例13: spi_get

ssize_t spi_get(struct spi_driver_t *self_p,
                uint8_t *data_p)
{
    ASSERTN(self_p != NULL, EINVAL);
    ASSERTN(data_p != NULL, EINVAL);

    return (spi_read(self_p, data_p, 1));
}
开发者ID:eerimoq,项目名称:simba,代码行数:8,代码来源:spi.c

示例14: spi_read

ssize_t spi_read(struct spi_driver_t *self_p,
                 void *rxbuf_p,
                 size_t size)
{
    ASSERTN(self_p != NULL, EINVAL);
    ASSERTN(rxbuf_p != NULL, EINVAL);
    ASSERTN(size > 0, EINVAL);

    return (spi_transfer(self_p, rxbuf_p, NULL, size));
}
开发者ID:eerimoq,项目名称:simba,代码行数:10,代码来源:spi.c

示例15: can_read

ssize_t can_read(struct can_driver_t *self_p,
                 struct can_frame_t *frame_p,
                 size_t size)
{
    ASSERTN(self_p != NULL, EINVAL);
    ASSERTN(frame_p != NULL, EINVAL);
    ASSERTN(size > 0, EINVAL);

    return (queue_read(&self_p->chin, frame_p, size));
}
开发者ID:wuwx,项目名称:simba,代码行数:10,代码来源:can.c


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