From c0f9d4cae4a73150dd274598f467db4038153b23 Mon Sep 17 00:00:00 2001 From: Martin Date: Mon, 13 Oct 2008 18:03:58 +0200 Subject: [PATCH] Compilation fixes --- fwp/lib/core/fwp_endpoint.c | 8 ++-- fwp/lib/core/fwp_endpoint.h | 2 +- fwp/lib/core/fwp_vres.c | 61 +++++++++++++------------- fwp/lib/core/fwp_vres.h | 7 ++- fwp/tests/Makefile.omk | 4 +- fwp/tests/fwp_vrestest/Makefile.omk | 4 +- fwp/tests/fwp_vrestest/fwp_vrestest1.c | 2 +- 7 files changed, 44 insertions(+), 44 deletions(-) diff --git a/fwp/lib/core/fwp_endpoint.c b/fwp/lib/core/fwp_endpoint.c index db91bc3..9393350 100644 --- a/fwp/lib/core/fwp_endpoint.c +++ b/fwp/lib/core/fwp_endpoint.c @@ -291,12 +291,12 @@ err: * * \return On success returns 0. On error, -1 and errno is set appropriately. */ -int fwp_send_endpoint_bind(fwp_endpoint_t *epoint, fwp_vres_d_t vresd) +int fwp_send_endpoint_bind(fwp_vres_d_t vresd, fwp_endpoint_t *epoint) { int rv ; fwp_endpoint_t *fwp_epoint = epoint; - rv = _fwp_vres_bind(vresd, fwp_epoint->sockd); + rv = fwp_vres_bind(vresd, fwp_epoint->sockd); /* if send endpoint is already bound if (epoint->type == FWP_EPOINT_BOUND) { fwp_send_endpoint_unbind(epoint); @@ -318,7 +318,7 @@ int fwp_send_endpoint_unbind(fwp_endpoint_d_t epointd) fwp_endpoint_t *fwp_epoint = epointd; /* unlink epoint-vres mutually */ - if ((rv = _fwp_vres_unbind(fwp_epoint->vresd)) < 0) + if ((rv = fwp_vres_unbind(fwp_epoint->vresd)) < 0) return rv; return 0; @@ -501,6 +501,6 @@ int fwp_send(fwp_endpoint_t *fwp_epoint,const void *msg, const size_t size, int /*}*/ /* TODO: test whether _fwp_vres_send is successful */ - return _fwp_vres_send(fwp_epoint->vresd, msgb); + return fwp_vres_send(fwp_epoint->vresd, msgb); } diff --git a/fwp/lib/core/fwp_endpoint.h b/fwp/lib/core/fwp_endpoint.h index 855fa0e..dbdae60 100644 --- a/fwp/lib/core/fwp_endpoint.h +++ b/fwp/lib/core/fwp_endpoint.h @@ -37,7 +37,7 @@ int fwp_receive_endpoint_create(/*unsigned int node,*/ unsigned int port, fwp_endpoint_t **epoint); int fwp_endpoint_destroy(fwp_endpoint_d_t epointd); -int fwp_send_endpoint_bind(fwp_endpoint_d_t epointd, fwp_vres_d_t vresd); +int fwp_send_endpoint_bind(fwp_vres_d_t vresd, fwp_endpoint_d_t epointd); int fwp_send_endpoint_unbind(fwp_endpoint_d_t epointd); ssize_t fwp_recv(fwp_endpoint_t *endpoint, diff --git a/fwp/lib/core/fwp_vres.c b/fwp/lib/core/fwp_vres.c index e94f146..d4e15d4 100644 --- a/fwp/lib/core/fwp_vres.c +++ b/fwp/lib/core/fwp_vres.c @@ -10,7 +10,7 @@ static void* fwp_vres_tx_thread(void *_vres); typedef enum { FWP_VF_USED = 1 , - FWP_VF_ACTIVE = 2 , + FWP_VF_BOUND = 2 , FWP_VF_RESCHED = 4 , } fwp_vres_flag_t; @@ -75,14 +75,14 @@ static inline int fwp_vres_set_ac(int sockd, fwp_ac_t ac_id) return 0; } -static inline int fwp_vres_set_flag(fwp_vres_t *vres, fwp_vres_flag_t flag) +static inline void fwp_vres_set_flag(fwp_vres_t *vres, fwp_vres_flag_t flag) { - return (vres->flags | (1 << flag)); + vres->flags |= (1 << flag); } -static inline int fwp_vres_clear_flag(fwp_vres_t *vres, fwp_vres_flag_t flag) +static inline void fwp_vres_clear_flag(fwp_vres_t *vres, fwp_vres_flag_t flag) { - return (vres->flags & ~(1 << flag)); + vres->flags &= ~(1 << flag); } static inline int fwp_vres_get_flag(fwp_vres_t *vres, fwp_vres_flag_t flag) @@ -90,6 +90,11 @@ static inline int fwp_vres_get_flag(fwp_vres_t *vres, fwp_vres_flag_t flag) return !!(vres->flags & (1 << flag)); } +static inline void fwp_vres_clearall_flag(fwp_vres_t *vres) +{ + vres->flags = 0; +} + #if 0 /* Deprecated */ static int fwp_vres_ac_open(fwp_ac_t ac_id) @@ -121,7 +126,7 @@ static int fwp_vres_ac_open(fwp_ac_t ac_id) } #endif -static inline int __fwp_vres_send(unsigned int ac_sockd, struct fwp_msgb* msgb) +static inline int _fwp_vres_send(unsigned int ac_sockd, struct fwp_msgb* msgb) { /*_fwp_sendto(ac_sockd, msgb->data, msgb->len, 0, msgb->peer->addr, msgb->peer->addrlen);*/ @@ -130,7 +135,7 @@ static inline int __fwp_vres_send(unsigned int ac_sockd, struct fwp_msgb* msgb) static inline void fwp_vres_free(fwp_vres_t *vres) { - fwp_vres_clear_flag(vres, FWP_VF_USED); + fwp_vres_clearall_flag(vres); } static inline int fwp_vres_is_valid(fwp_vres_t *vres) @@ -205,6 +210,8 @@ fwp_vres_d_t fwp_vres_alloc() inline int _fwp_vres_set_params(fwp_vres_t *vres, fwp_vres_params_t *params) { + int rv; + /* copy vres paramters into vres structure */ rv = fwp_vres_set_ac(vres->ac_sockd, params->ac_id); if (!rv) @@ -228,14 +235,13 @@ inline int _fwp_vres_set_params(fwp_vres_t *vres, fwp_vres_params_t *params) int fwp_vres_set_params(fwp_vres_d_t vresd, fwp_vres_params_t *params) { fwp_vres_t *vres = vresd; - int rv; if (!fwp_vres_is_valid(vres)) { errno = EINVAL; return -1; } - return fwp_vres_set_params(vres, params); + return _fwp_vres_set_params(vres, params); } /** @@ -253,29 +259,25 @@ int fwp_vres_create(fwp_vres_params_t *params, fwp_vres_d_t *vresdp) int rv; fwp_vres_t *vres; - /* Check for validity of the contract */ - vres = fwp_vres_alloc(); if (!vres) { return -1; } - /* copy vres paramters into vres structure */ - memcpy(&vres->params, params, sizeof(struct fwp_vres_params)); /* initialize msg queue */ fwp_msgq_init(&vres->tx_queue); + _fwp_vres_set_params(vres, params); pthread_attr_init(&vres->tx_thread_attr); if ((rv = pthread_create(&vres->tx_thread, &vres->tx_thread_attr, fwp_vres_tx_thread, (void*) vres)) != 0){ goto err; } - _fwp_vres_set_params + *vresdp = vres; return 0; err: fwp_vres_free(vres); - errno = rv; return -1; } @@ -299,7 +301,7 @@ int fwp_vres_destroy(fwp_vres_d_t vresd) } pthread_cancel(vres->tx_thread); - + FWP_DEBUG("Vres vparam_id=%d destroyed.\n", vres->params.id); return 0; } @@ -337,8 +339,8 @@ static void* fwp_vres_tx_thread(void *_vres) struct fwp_msgb *msgb = NULL; unsigned int ac_id = vres->params.ac_id; /*unsigned int ac_sockd = vres->ac_sockd;*/ - int budget = vres->params.budget; - int curr_budget; + fwp_budget_t budget = vres->params.budget; + fwp_budget_t curr_budget; int rc; struct timespec start_period, end_period, period; @@ -372,7 +374,7 @@ static void* fwp_vres_tx_thread(void *_vres) curr_budget = 0; while ((curr_budget < budget)&& (msgb = fwp_msgq_dequeue(msgq))) { - rc = __fwp_vres_send(vres->ac_sockd, msgb); + rc = _fwp_vres_send(vres->ac_sockd, msgb); if (!(rc < 0)) { FWP_DEBUG("Message sent through AC%d\n",ac_id); /* Switch to this in the future @@ -400,7 +402,7 @@ static void* fwp_vres_tx_thread(void *_vres) return NULL; } -int _fwp_vres_send(fwp_vres_d_t vresd, struct fwp_msgb* msgb) +int fwp_vres_send(fwp_vres_d_t vresd, struct fwp_msgb* msgb) { fwp_vres_t *vres = vresd; @@ -412,9 +414,8 @@ int _fwp_vres_send(fwp_vres_d_t vresd, struct fwp_msgb* msgb) } } -#if 0 -/*int _fwp_vres_bind(fwp_vres_d_t vresd, fwp_endpoint_t *epoint)*/ -int _fwp_vres_bind(fwp_vres_d_t vresd, int sockd) +/*int fwp_vres_bind(fwp_vres_d_t vresd, fwp_endpoint_t *epoint)*/ +int fwp_vres_bind(fwp_vres_d_t vresd, int sockd) { fwp_vres_t *vres = vresd; int rv = 0; @@ -426,21 +427,23 @@ int _fwp_vres_bind(fwp_vres_d_t vresd, int sockd) goto err; } - if (vres->status != FWP_VRES_UNBOUND) { /*if already bounded */ + if (fwp_vres_get_flag(vres, FWP_VF_BOUND)) { /*if already bounded */ errno = EPERM; rv = -1; goto err; } vres->ac_sockd = sockd; - fwp_vres_set_ac(vres->ac_sockd,vres->params.ac_id); - vres->status = FWP_VRES_BOUND; + rv = fwp_vres_set_ac(vres->ac_sockd,vres->params.ac_id); + if (rv) + goto err; + fwp_vres_set_flag(vres, FWP_VF_BOUND); err: pthread_mutex_unlock(&fwp_vres_table.lock); return rv; } -int _fwp_vres_unbind(fwp_vres_d_t vresd) +int fwp_vres_unbind(fwp_vres_d_t vresd) { fwp_vres_t *vres = vresd; @@ -448,10 +451,8 @@ int _fwp_vres_unbind(fwp_vres_d_t vresd) errno = EINVAL; return -1; } - vres->status = FWP_VRES_UNBOUND; + fwp_vres_clear_flag(vres, FWP_VF_BOUND); /* TODO: consider what to do with pending messages */ /* fwp_vres_free_msgb(vres->tx_queue); */ - return 0; } -#endif diff --git a/fwp/lib/core/fwp_vres.h b/fwp/lib/core/fwp_vres.h index 183d155..6638c7d 100644 --- a/fwp/lib/core/fwp_vres.h +++ b/fwp/lib/core/fwp_vres.h @@ -46,12 +46,11 @@ fwp_vres_id_t fwp_vres_get_id(fwp_vres_d_t vresd); int fwp_vres_set_params(fwp_vres_d_t vresd, fwp_vres_params_t *params); int fwp_vres_create(fwp_vres_params_t *params, fwp_vres_d_t *vresdp); int fwp_vres_destroy(fwp_vres_d_t vresd); -/* */ -int _fwp_vres_send(fwp_vres_d_t vresd, struct fwp_msgb* msgb); +int fwp_vres_send(fwp_vres_d_t vresd, struct fwp_msgb* msgb); /*int _fwp_vres_bind(fwp_vres_d_t vresd, fwp_endpoint_d_t epointd);*/ -int _fwp_vres_bind(fwp_vres_d_t vresd, int sockd); -int _fwp_vres_unbind(fwp_vres_d_t vresd); +int fwp_vres_bind(fwp_vres_d_t vresd, int sockd); +int fwp_vres_unbind(fwp_vres_d_t vresd); #endif /* _FWP_INTERNALS_ */ #endif /* _FWP_VRES_H */ diff --git a/fwp/tests/Makefile.omk b/fwp/tests/Makefile.omk index 5d10f83..dc39775 100644 --- a/fwp/tests/Makefile.omk +++ b/fwp/tests/Makefile.omk @@ -1,5 +1,5 @@ -SUBDIRS= fwp_msgtest -#fwp_vrestest fwp_prototest fwp_mngrtest +SUBDIRS= fwp_msgtest fwp_vrestest +#fwp_prototest fwp_mngrtest CFLAGS += -Wall -D_REENTRANT -g #SUBDIRS= fwp_msgtest fwp_vrestest fwp_prototest fwp_mngrtest #fwp_mngrtest unixsocktest diff --git a/fwp/tests/fwp_vrestest/Makefile.omk b/fwp/tests/fwp_vrestest/Makefile.omk index 45879d3..8023964 100644 --- a/fwp/tests/fwp_vrestest/Makefile.omk +++ b/fwp/tests/fwp_vrestest/Makefile.omk @@ -1,5 +1,5 @@ -test_PROGRAMS = fwp_vrestest1 fwp_vrestest2 +test_PROGRAMS = fwp_vrestest1 CFLAGS+= -D_FWP_INTERNALS_ fwp_vrestest1_SOURCES+= fwp_vrestest1.c -fwp_vrestest2_SOURCES+= fwp_vrestest2.c +#fwp_vrestest2_SOURCES+= fwp_vrestest2.c lib_LOADLIBES += fwp pthread rt ulut diff --git a/fwp/tests/fwp_vrestest/fwp_vrestest1.c b/fwp/tests/fwp_vrestest/fwp_vrestest1.c index 8882f36..85effe8 100644 --- a/fwp/tests/fwp_vrestest/fwp_vrestest1.c +++ b/fwp/tests/fwp_vrestest/fwp_vrestest1.c @@ -67,7 +67,7 @@ int main() return -1; } printf("Send endpoint 1 created\n"); - fwp_send_endpoint_bind(sepoint_d1, vresd1); + fwp_send_endpoint_bind(vresd1, sepoint_d1); for (count = 0; count < NUM; count++) { sprintf(msg1,"msg%d",count); -- 2.39.2