diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-01-26 09:57:56 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-01-26 09:57:56 -0800 |
| commit | d93cbc059cd1e42773d1aec19f8b49a972f2eac3 (patch) | |
| tree | 71a6c79e8ae5c2ef9ed9beb06088ccd4d832fca9 /src/nng_compat.c | |
| parent | a9e81c87a7b2a203c2bd4f310f936af46ef42fc1 (diff) | |
| download | nng-d93cbc059cd1e42773d1aec19f8b49a972f2eac3.tar.gz nng-d93cbc059cd1e42773d1aec19f8b49a972f2eac3.tar.bz2 nng-d93cbc059cd1e42773d1aec19f8b49a972f2eac3.zip | |
Added more plumbing to facilitate test writing & compatibility.
Also, while here fixed a bug for the PAIR protocol in compat mode.
It should now be possible to import more of the nanomsg tests directly
with little or no modification.
Diffstat (limited to 'src/nng_compat.c')
| -rw-r--r-- | src/nng_compat.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/nng_compat.c b/src/nng_compat.c index 04759e01..3192a5f7 100644 --- a/src/nng_compat.c +++ b/src/nng_compat.c @@ -727,3 +727,41 @@ nn_cmsg_next(struct nn_msghdr *mh, struct nn_cmsghdr *first) } return (first); } + + +// Internal test support routines. + +void +nn_sleep(uint64_t msec) +{ + nng_usleep(msec / 1000); +} + + +uint64_t +nn_clock(void) +{ + return (nng_clock()); +} + + +extern void nni_panic(const char *, ...); + +int +nn_thread_init(struct nn_thread *thr, void (*func)(void *), void *arg) +{ + int rv; + + rv = nng_thread_create(&thr->thr, func, arg); + if (rv != 0) { + nni_panic("Cannot create thread: %s", nng_strerror(rv)); + } + return (rv); +} + + +void +nn_thread_term(struct nn_thread *thr) +{ + nng_thread_destroy(thr->thr); +} |
