diff options
author | Uros Majstorovic <majstor@majstor.org> | 2017-05-23 14:19:26 +0200 |
---|---|---|
committer | Uros Majstorovic <majstor@majstor.org> | 2017-05-23 14:19:26 +0200 |
commit | 3ef6719f47b734b12c0b11c725b7f12e3fb3c08a (patch) | |
tree | a635ac65bfc72d126d97e48e22c38ac33343b4f4 /code/core/msgq.h | |
parent | 922e8313f2b3f6157a61b3c867fdc3832bb92a68 (diff) |
fs layout updated
Diffstat (limited to 'code/core/msgq.h')
-rw-r--r-- | code/core/msgq.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/code/core/msgq.h b/code/core/msgq.h new file mode 100644 index 0000000..9d16f63 --- /dev/null +++ b/code/core/msgq.h @@ -0,0 +1,32 @@ +#ifdef ECP_WITH_PTHREAD + +#include <pthread.h> +#include <string.h> + +#define ECP_MAX_CONN_MSG 8 +#define ECP_ERR_MAX_CONN_MSG -100 + +struct ECPConnection; + +typedef struct ECPMessage { + unsigned char msg[ECP_MAX_MSG]; + ssize_t size; +} ECPMessage; + +typedef struct ECPConnMsgQ { + unsigned short empty_idx; + unsigned short occupied[ECP_MAX_CONN_MSG]; + unsigned short w_idx[ECP_MAX_MTYPE]; + unsigned short r_idx[ECP_MAX_MTYPE]; + unsigned short msg_idx[ECP_MAX_MTYPE][ECP_MAX_CONN_MSG+1]; + ECPMessage msg[ECP_MAX_CONN_MSG]; + pthread_mutex_t mutex; + pthread_cond_t cond[ECP_MAX_MTYPE]; +} ECPConnMsgQ; + +int ecp_conn_msgq_create(struct ECPConnection *conn); +void ecp_conn_msgq_destroy(struct ECPConnection *conn); +ssize_t ecp_conn_msgq_push(struct ECPConnection *conn, unsigned char *msg, size_t msg_size); +ssize_t ecp_conn_msgq_pop(struct ECPConnection *conn, unsigned char mtype, unsigned char *msg, size_t msg_size, unsigned int timeout); + +#endif /* ECP_WITH_PTHREAD */
\ No newline at end of file |