Skip to content

Commit

Permalink
replace zp_ prefix with z_
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisBiryukov91 committed Feb 28, 2024
1 parent b1a5f86 commit e7cbf51
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 86 deletions.
24 changes: 12 additions & 12 deletions examples/z_ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
#define handle_error_en(en, msg) \
do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0)

zp_condvar_t cond;
zp_mutex_t mutex;
z_condvar_t cond;
z_mutex_t mutex;

void callback(const z_sample_t* sample, void* context) { zp_condvar_signal(&cond); }
void drop(void* context) { zp_condvar_free(&cond); }
void callback(const z_sample_t* sample, void* context) { z_condvar_signal(&cond); }
void drop(void* context) { z_condvar_free(&cond); }

struct args_t {
unsigned int size; // -s
Expand All @@ -42,8 +42,8 @@ int main(int argc, char** argv) {
DEFAULT_PKT_SIZE, DEFAULT_PING_NB, DEFAULT_WARMUP_MS);
return 1;
}
zp_mutex_init(&mutex);
zp_condvar_init(&cond);
z_mutex_init(&mutex);
z_condvar_init(&cond);
z_owned_config_t config = args.config_path ? zc_config_from_file(args.config_path) : z_config_default();
z_owned_session_t session = z_open(z_move(config));
z_keyexpr_t ping = z_keyexpr_unchecked("test/ping");
Expand All @@ -55,7 +55,7 @@ int main(int argc, char** argv) {
for (int i = 0; i < args.size; i++) {
data[i] = i % 10;
}
zp_mutex_lock(&mutex);
z_mutex_lock(&mutex);
if (args.warmup_ms) {
printf("Warming up for %dms...\n", args.warmup_ms);
struct timespec wmup_start, wmup_stop, wmup_timeout;
Expand All @@ -65,9 +65,9 @@ int main(int argc, char** argv) {
clock_gettime(CLOCK_REALTIME, &wmup_timeout);
wmup_timeout.tv_sec += PING_TIMEOUT_SEC;
z_publisher_put(z_loan(pub), data, args.size, NULL);
int s = zp_condvar_wait(&cond, &mutex);
int s = z_condvar_wait(&cond, &mutex);
if (s != 0) {
handle_error_en(s, "zp_condvar_wait");
handle_error_en(s, "z_condvar_wait");
}
clock_gettime(CLOCK_MONOTONIC, &wmup_stop);
elapsed_us =
Expand All @@ -81,17 +81,17 @@ int main(int argc, char** argv) {
t_timeout.tv_sec += PING_TIMEOUT_SEC;
clock_gettime(CLOCK_MONOTONIC, &t_start);
z_publisher_put(z_loan(pub), data, args.size, NULL);
int s = zp_condvar_wait(&cond, &mutex);
int s = z_condvar_wait(&cond, &mutex);
if (s != 0) {
handle_error_en(s, "zp_condvar_wait");
handle_error_en(s, "z_condvar_wait");
}
clock_gettime(CLOCK_MONOTONIC, &t_stop);
results[i] = (1000000 * (t_stop.tv_sec - t_start.tv_sec) + (t_stop.tv_nsec - t_start.tv_nsec) / 1000);
}
for (int i = 0; i < args.number_of_pings; i++) {
printf("%d bytes: seq=%d rtt=%luµs, lat=%luµs\n", args.size, i, results[i], results[i] / 2);
}
zp_mutex_unlock(&mutex);
z_mutex_unlock(&mutex);
free(results);
free(data);
z_drop(z_move(sub));
Expand Down
78 changes: 39 additions & 39 deletions include/zenoh_commons.h
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,20 @@ typedef struct z_owned_closure_zid_t {
void (*call)(const struct z_id_t*, void*);
void (*drop)(void*);
} z_owned_closure_zid_t;
/**
* Condvar
*
*/
typedef struct z_condvar_t {
size_t _0;
} z_condvar_t;
/**
* Mutex
*
*/
typedef struct z_mutex_t {
size_t _0;
} z_mutex_t;
/**
* An owned zenoh configuration.
*
Expand Down Expand Up @@ -788,6 +802,16 @@ typedef struct z_owned_scouting_config_t {
typedef struct z_subscriber_t {
const struct z_owned_subscriber_t *_0;
} z_subscriber_t;
/**
* Task
*
*/
typedef struct z_task_t {
size_t _0;
} z_task_t;
typedef struct z_task_attr_t {
size_t _0;
} z_task_attr_t;
/**
* The options for `zc_liveliness_declare_token`
*/
Expand Down Expand Up @@ -957,30 +981,6 @@ typedef struct ze_querying_subscriber_options_t {
typedef struct ze_querying_subscriber_t {
const struct ze_owned_querying_subscriber_t *_0;
} ze_querying_subscriber_t;
/**
* Condvar
*
*/
typedef struct zp_condvar_t {
size_t _0;
} zp_condvar_t;
/**
* Mutex
*
*/
typedef struct zp_mutex_t {
size_t _0;
} zp_mutex_t;
/**
* Task
*
*/
typedef struct zp_task_t {
size_t _0;
} zp_task_t;
typedef struct zp_task_attr_t {
size_t _0;
} zp_task_attr_t;
ZENOHC_API extern const unsigned int Z_ROUTER;
ZENOHC_API extern const unsigned int Z_PEER;
ZENOHC_API extern const unsigned int Z_CLIENT;
Expand Down Expand Up @@ -1214,6 +1214,10 @@ ZENOHC_API void z_closure_zid_drop(struct z_owned_closure_zid_t *closure);
* Constructs a null safe-to-drop value of 'z_owned_closure_zid_t' type
*/
ZENOHC_API struct z_owned_closure_zid_t z_closure_zid_null(void);
ZENOHC_API int8_t z_condvar_free(struct z_condvar_t *cv);
ZENOHC_API int8_t z_condvar_init(struct z_condvar_t *cv);
ZENOHC_API int8_t z_condvar_signal(struct z_condvar_t *cv);
ZENOHC_API int8_t z_condvar_wait(struct z_condvar_t *cv, struct z_mutex_t *m);
/**
* Returns ``true`` if `config` is valid.
*/
Expand Down Expand Up @@ -1631,6 +1635,11 @@ ZENOHC_API struct z_owned_str_t z_keyexpr_to_string(struct z_keyexpr_t keyexpr);
*/
ZENOHC_API
struct z_keyexpr_t z_keyexpr_unchecked(const char *name);
ZENOHC_API int8_t z_mutex_free(struct z_mutex_t *m);
ZENOHC_API int8_t z_mutex_init(struct z_mutex_t *m);
ZENOHC_API int8_t z_mutex_lock(struct z_mutex_t *m);
ZENOHC_API int8_t z_mutex_try_lock(struct z_mutex_t *m);
ZENOHC_API int8_t z_mutex_unlock(struct z_mutex_t *m);
/**
* Opens a zenoh session. Should the session opening fail, `z_check` ing the returned value will return `false`.
*/
Expand Down Expand Up @@ -2028,6 +2037,12 @@ ZENOHC_API struct z_subscriber_options_t z_subscriber_options_default(void);
* sub: The :c:type:`z_owned_pull_subscriber_t` to pull from.
*/
ZENOHC_API int8_t z_subscriber_pull(struct z_pull_subscriber_t sub);
ZENOHC_API
int8_t z_task_init(struct z_task_t *task,
const struct z_task_attr_t *_attr,
void (*fun)(void *arg),
void *arg);
ZENOHC_API int8_t z_task_join(struct z_task_t *task);
/**
* Returns ``true`` if `ts` is a valid timestamp
*/
Expand Down Expand Up @@ -2550,18 +2565,3 @@ int8_t ze_undeclare_publication_cache(struct ze_owned_publication_cache_t *pub_c
*/
ZENOHC_API
int8_t ze_undeclare_querying_subscriber(struct ze_owned_querying_subscriber_t *sub);
ZENOHC_API int8_t zp_condvar_free(struct zp_condvar_t *cv);
ZENOHC_API int8_t zp_condvar_init(struct zp_condvar_t *cv);
ZENOHC_API int8_t zp_condvar_signal(struct zp_condvar_t *cv);
ZENOHC_API int8_t zp_condvar_wait(struct zp_condvar_t *cv, struct zp_mutex_t *m);
ZENOHC_API int8_t zp_mutex_free(struct zp_mutex_t *m);
ZENOHC_API int8_t zp_mutex_init(struct zp_mutex_t *m);
ZENOHC_API int8_t zp_mutex_lock(struct zp_mutex_t *m);
ZENOHC_API int8_t zp_mutex_try_lock(struct zp_mutex_t *m);
ZENOHC_API int8_t zp_mutex_unlock(struct zp_mutex_t *m);
ZENOHC_API
int8_t zp_task_init(struct zp_task_t *task,
const struct zp_task_attr_t *_attr,
void (*fun)(void *arg),
void *arg);
ZENOHC_API int8_t zp_task_join(struct zp_task_t *task);
Loading

0 comments on commit e7cbf51

Please sign in to comment.