Skip to content

Commit

Permalink
Disabling raw names in libdillimpl.h
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Sustrik <[email protected]>
  • Loading branch information
sustrik committed Apr 14, 2018
1 parent c9f4840 commit ef5bb6e
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 29 deletions.
10 changes: 5 additions & 5 deletions bsock.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,25 @@
#include "libdillimpl.h"
#include "utils.h"

dill_unique_id(bsock_type);
dill_unique_id(dill_bsock_type);

int dill_bsend(int s, const void *buf, size_t len, int64_t deadline) {
struct bsock_vfs *b = hquery(s, bsock_type);
struct bsock_vfs *b = hquery(s, dill_bsock_type);
if(dill_slow(!b)) return -1;
struct iolist iol = {(void*)buf, len, NULL, 0};
return b->bsendl(b, &iol, &iol, deadline);
}

int dill_brecv(int s, void *buf, size_t len, int64_t deadline) {
struct bsock_vfs *b = hquery(s, bsock_type);
struct bsock_vfs *b = hquery(s, dill_bsock_type);
if(dill_slow(!b)) return -1;
struct iolist iol = {buf, len, NULL, 0};
return b->brecvl(b, &iol, &iol, deadline);
}

int dill_bsendl(int s, struct iolist *first, struct iolist *last,
int64_t deadline) {
struct bsock_vfs *b = hquery(s, bsock_type);
struct bsock_vfs *b = hquery(s, dill_bsock_type);
if(dill_slow(!b)) return -1;
if(dill_slow(!first || !last || last->iol_next)) {
errno = EINVAL; return -1;}
Expand All @@ -55,7 +55,7 @@ int dill_bsendl(int s, struct iolist *first, struct iolist *last,

int dill_brecvl(int s, struct iolist *first, struct iolist *last,
int64_t deadline) {
struct bsock_vfs *b = hquery(s, bsock_type);
struct bsock_vfs *b = hquery(s, dill_bsock_type);
if(dill_slow(!b)) return -1;
if(dill_slow((first && !last) || (!first && last) || last->iol_next)) {
errno = EINVAL; return -1;}
Expand Down
4 changes: 2 additions & 2 deletions handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void dill_ctx_handle_term(struct dill_ctx_handle *ctx) {
free(ctx->handles);
}

int hmake(struct hvfs *vfs) {
int dill_hmake(struct hvfs *vfs) {
struct dill_ctx_handle *ctx = &dill_getctx->handle;
if(dill_slow(!vfs || !vfs->query || !vfs->close)) {
errno = EINVAL; return -1;}
Expand Down Expand Up @@ -120,7 +120,7 @@ int dill_hown(int h) {
return res;
}

void *hquery(int h, const void *type) {
void *dill_hquery(int h, const void *type) {
struct dill_ctx_handle *ctx = &dill_getctx->handle;
CHECKHANDLE(h, NULL);
/* Try and use the cached pointer first; otherwise do the expensive virtual
Expand Down
50 changes: 33 additions & 17 deletions libdillimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,42 +31,58 @@
/* Handles */
/******************************************************************************/

struct hvfs {
void *(*query)(struct hvfs *vfs, const void *type);
void (*close)(struct hvfs *vfs);
struct dill_hvfs {
void *(*query)(struct dill_hvfs *vfs, const void *type);
void (*close)(struct dill_hvfs *vfs);
};

DILL_EXPORT int hmake(struct hvfs *vfs);
DILL_EXPORT void *hquery(int h, const void *type);
DILL_EXPORT int dill_hmake(struct dill_hvfs *vfs);
DILL_EXPORT void *dill_hquery(int h, const void *type);

#if !defined DILL_DISABLE_RAW_NAMES
#define hvfs dill_hvfs
#define hmake dill_hmake
#define hquery dill_hquery
#endif

#if !defined DILL_DISABLE_SOCKETS

/******************************************************************************/
/* Bytestream sockets. */
/******************************************************************************/

DILL_EXPORT extern const void *bsock_type;
DILL_EXPORT extern const void *dill_bsock_type;

struct bsock_vfs {
int (*bsendl)(struct bsock_vfs *vfs,
struct iolist *first, struct iolist *last, int64_t deadline);
int (*brecvl)(struct bsock_vfs *vfs,
struct iolist *first, struct iolist *last, int64_t deadline);
struct dill_bsock_vfs {
int (*bsendl)(struct dill_bsock_vfs *vfs,
struct dill_iolist *first, struct dill_iolist *last, int64_t deadline);
int (*brecvl)(struct dill_bsock_vfs *vfs,
struct dill_iolist *first, struct dill_iolist *last, int64_t deadline);
};

#if !defined DILL_DISABLE_RAW_NAMES
#define bsock_vfs dill_bsock_vfs
#define bsock_type dill_bsock_type
#endif

/******************************************************************************/
/* Message sockets. */
/******************************************************************************/

DILL_EXPORT extern const void *msock_type;
DILL_EXPORT extern const void *dill_msock_type;

struct msock_vfs {
int (*msendl)(struct msock_vfs *vfs,
struct iolist *first, struct iolist *last, int64_t deadline);
ssize_t (*mrecvl)(struct msock_vfs *vfs,
struct iolist *first, struct iolist *last, int64_t deadline);
struct dill_msock_vfs {
int (*msendl)(struct dill_msock_vfs *vfs,
struct dill_iolist *first, struct dill_iolist *last, int64_t deadline);
ssize_t (*mrecvl)(struct dill_msock_vfs *vfs,
struct dill_iolist *first, struct dill_iolist *last, int64_t deadline);
};

#if !defined DILL_DISABLE_RAW_NAMES
#define msock_vfs dill_msock_vfs
#define msock_type dill_msock_type
#endif

#endif

#endif
Expand Down
10 changes: 5 additions & 5 deletions msock.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,25 @@
#include "libdillimpl.h"
#include "utils.h"

dill_unique_id(msock_type);
dill_unique_id(dill_msock_type);

int dill_msend(int s, const void *buf, size_t len, int64_t deadline) {
struct msock_vfs *m = hquery(s, msock_type);
struct msock_vfs *m = hquery(s, dill_msock_type);
if(dill_slow(!m)) return -1;
struct iolist iol = {(void*)buf, len, NULL, 0};
return m->msendl(m, &iol, &iol, deadline);
}

ssize_t dill_mrecv(int s, void *buf, size_t len, int64_t deadline) {
struct msock_vfs *m = hquery(s, msock_type);
struct msock_vfs *m = hquery(s, dill_msock_type);
if(dill_slow(!m)) return -1;
struct iolist iol = {buf, len, NULL, 0};
return m->mrecvl(m, &iol, &iol, deadline);
}

int dill_msendl(int s, struct iolist *first, struct iolist *last,
int64_t deadline) {
struct msock_vfs *m = hquery(s, msock_type);
struct msock_vfs *m = hquery(s, dill_msock_type);
if(dill_slow(!m)) return -1;
if(dill_slow(!first || !last || last->iol_next)) {
errno = EINVAL; return -1;}
Expand All @@ -55,7 +55,7 @@ int dill_msendl(int s, struct iolist *first, struct iolist *last,

ssize_t dill_mrecvl(int s, struct iolist *first, struct iolist *last,
int64_t deadline) {
struct msock_vfs *m = hquery(s, msock_type);
struct msock_vfs *m = hquery(s, dill_msock_type);
if(dill_slow(!m)) return -1;
if(dill_slow((last && last->iol_next) ||
(!first && last) ||
Expand Down

0 comments on commit ef5bb6e

Please sign in to comment.