rename config -> options

This commit is contained in:
luwenpeng
2024-03-08 14:51:21 +08:00
parent d0914483bb
commit 734f6a5135
32 changed files with 336 additions and 336 deletions

View File

@@ -5,7 +5,7 @@
#include "packet_io_marsio.h"
#include "packet_io_dumpfile.h"
typedef void *new_cb(void *config);
typedef void *new_cb(void *options);
typedef void free_cb(void *handle);
typedef void *stat_cb(void *handle);
typedef int init_cb(void *handle, uint16_t thread_id);
@@ -23,7 +23,7 @@ struct packet_io
send_cb *on_send;
};
struct packet_io *packet_io_new(struct packet_io_config *config)
struct packet_io *packet_io_new(struct packet_io_options *opts)
{
struct packet_io *handle = (struct packet_io *)calloc(1, sizeof(struct packet_io));
if (handle == NULL)
@@ -32,21 +32,21 @@ struct packet_io *packet_io_new(struct packet_io_config *config)
return NULL;
}
struct packet_io_marsio_confg marsio_config;
strncpy(marsio_config.app_symbol, config->app_symbol, sizeof(marsio_config.app_symbol));
strncpy(marsio_config.dev_symbol, config->dev_symbol, sizeof(marsio_config.dev_symbol));
memcpy(marsio_config.cpu_mask, config->cpu_mask, sizeof(marsio_config.cpu_mask));
marsio_config.nr_threads = config->nr_threads;
struct packet_io_marsio_opts marsio_opts;
strncpy(marsio_opts.app_symbol, opts->app_symbol, sizeof(marsio_opts.app_symbol));
strncpy(marsio_opts.dev_symbol, opts->dev_symbol, sizeof(marsio_opts.dev_symbol));
memcpy(marsio_opts.cpu_mask, opts->cpu_mask, sizeof(marsio_opts.cpu_mask));
marsio_opts.nr_threads = opts->nr_threads;
struct packet_io_dumpfile_confg dumpfile_config;
strncpy(dumpfile_config.dumpfile_dir, config->dumpfile_dir, sizeof(dumpfile_config.dumpfile_dir));
dumpfile_config.nr_threads = config->nr_threads;
struct packet_io_dumpfile_opts dumpfile_opts;
strncpy(dumpfile_opts.dumpfile_dir, opts->dumpfile_dir, sizeof(dumpfile_opts.dumpfile_dir));
dumpfile_opts.nr_threads = opts->nr_threads;
void *_config = NULL;
void *_opts = NULL;
if (config->mode == PACKET_IO_MARSIO)
if (opts->mode == PACKET_IO_MARSIO)
{
_config = &marsio_config;
_opts = &marsio_opts;
handle->on_new = (new_cb *)packet_io_marsio_new;
handle->on_free = (free_cb *)packet_io_marsio_free;
handle->on_stat = (stat_cb *)packet_io_marsio_stat;
@@ -56,7 +56,7 @@ struct packet_io *packet_io_new(struct packet_io_config *config)
}
else
{
_config = &dumpfile_config;
_opts = &dumpfile_opts;
handle->on_new = (new_cb *)packet_io_dumpfile_new;
handle->on_free = (free_cb *)packet_io_dumpfile_free;
handle->on_stat = (stat_cb *)packet_io_dumpfile_stat;
@@ -65,7 +65,7 @@ struct packet_io *packet_io_new(struct packet_io_config *config)
handle->on_send = (send_cb *)packet_io_dumpfile_send;
}
handle->handle = handle->on_new(_config);
handle->handle = handle->on_new(_opts);
if (handle->handle == NULL)
{
goto error_out;

View File

@@ -37,7 +37,7 @@ enum packet_io_mode
PACKET_IO_MARSIO = 1,
};
struct packet_io_config
struct packet_io_options
{
enum packet_io_mode mode;
@@ -53,7 +53,7 @@ struct packet_io_config
};
struct packet_io;
struct packet_io *packet_io_new(struct packet_io_config *config);
struct packet_io *packet_io_new(struct packet_io_options *opts);
void packet_io_free(struct packet_io *handle);
void packet_io_print_stat(struct packet_io *handle);
struct packet_io_stat *packet_io_get_stat(struct packet_io *handle);

View File

@@ -91,7 +91,7 @@ static void *dumpfile_thread_cycle(void *arg)
* Public API
******************************************************************************/
struct packet_io_dumpfile *packet_io_dumpfile_new(struct packet_io_dumpfile_confg *config)
struct packet_io_dumpfile *packet_io_dumpfile_new(struct packet_io_dumpfile_opts *opts)
{
pthread_t tid;
struct packet_io_dumpfile *handle = (struct packet_io_dumpfile *)calloc(1, sizeof(struct packet_io_dumpfile));
@@ -101,8 +101,8 @@ struct packet_io_dumpfile *packet_io_dumpfile_new(struct packet_io_dumpfile_conf
return NULL;
}
handle->nr_threads = config->nr_threads;
strncpy(handle->dumpfile_dir, config->dumpfile_dir, sizeof(handle->dumpfile_dir));
handle->nr_threads = opts->nr_threads;
strncpy(handle->dumpfile_dir, opts->dumpfile_dir, sizeof(handle->dumpfile_dir));
for (uint16_t i = 0; i < handle->nr_threads; i++)
{

View File

@@ -8,7 +8,7 @@ extern "C"
#include "packet.h"
struct packet_io_dumpfile_confg
struct packet_io_dumpfile_opts
{
char dumpfile_dir[256];
uint8_t nr_threads;
@@ -16,7 +16,7 @@ struct packet_io_dumpfile_confg
struct packet_io_dumpfile;
struct packet_io_dumpfile *packet_io_dumpfile_new(struct packet_io_dumpfile_confg *config);
struct packet_io_dumpfile *packet_io_dumpfile_new(struct packet_io_dumpfile_opts *opts);
void packet_io_dumpfile_free(struct packet_io_dumpfile *handle);
struct packet_io_stat *packet_io_dumpfile_stat(struct packet_io_dumpfile *handle);

View File

@@ -65,14 +65,14 @@ static int is_keepalive_packet(const char *data, int len)
* Public API
******************************************************************************/
struct packet_io_marsio *packet_io_marsio_new(struct packet_io_marsio_confg *config)
struct packet_io_marsio *packet_io_marsio_new(struct packet_io_marsio_opts *opts)
{
int opt = 1;
cpu_set_t coremask;
CPU_ZERO(&coremask);
for (uint8_t i = 0; i < config->nr_threads; i++)
for (uint8_t i = 0; i < opts->nr_threads; i++)
{
CPU_SET(config->cpu_mask[i], &coremask);
CPU_SET(opts->cpu_mask[i], &coremask);
}
struct packet_io_marsio *handle = (struct packet_io_marsio *)calloc(1, sizeof(struct packet_io_marsio));
@@ -92,13 +92,13 @@ struct packet_io_marsio *packet_io_marsio_new(struct packet_io_marsio_confg *con
marsio_option_set(handle->mr_ins, MARSIO_OPT_THREAD_MASK_IN_CPUSET, &coremask, sizeof(coremask));
marsio_option_set(handle->mr_ins, MARSIO_OPT_EXIT_WHEN_ERR, &opt, sizeof(opt));
if (marsio_init(handle->mr_ins, config->app_symbol) != 0)
if (marsio_init(handle->mr_ins, opts->app_symbol) != 0)
{
PACKET_IO_LOG_ERROR("unable to init marsio instance");
goto error_out;
}
handle->mr_dev = marsio_open_device(handle->mr_ins, config->dev_symbol, config->nr_threads, config->nr_threads);
handle->mr_dev = marsio_open_device(handle->mr_ins, opts->dev_symbol, opts->nr_threads, opts->nr_threads);
if (handle->mr_dev == NULL)
{
PACKET_IO_LOG_ERROR("unable to open marsio device");

View File

@@ -8,7 +8,7 @@ extern "C"
#include "packet.h"
struct packet_io_marsio_confg
struct packet_io_marsio_opts
{
char app_symbol[64];
char dev_symbol[64];
@@ -18,7 +18,7 @@ struct packet_io_marsio_confg
struct packet_io_marsio;
struct packet_io_marsio *packet_io_marsio_new(struct packet_io_marsio_confg *config);
struct packet_io_marsio *packet_io_marsio_new(struct packet_io_marsio_opts *opts);
void packet_io_marsio_free(struct packet_io_marsio *handle);
struct packet_io_stat *packet_io_marsio_stat(struct packet_io_marsio *handle);