summaryrefslogtreecommitdiffstats
path: root/src/include/sys/msg.h
blob: eec71ea4e8151d9d26d7ce83eab92f951745ebbf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef __SYS_MSG_H
#define __SYS_MSG_H

#include <stdint.h>
#include <stdlib.h>
#include <builtins.h>

#ifdef __cplusplus
extern "C"
{
#endif

typedef void* msg_q_t;

struct msg_t
{
    uint32_t type;
    uint32_t __reserved__async;
    uint64_t data[2];
    void* extra_data;
};

// Message queue interfaces.
msg_q_t msg_q_create();
int msg_q_destroy();
int msg_q_register(msg_q_t q, const char* name);
msg_q_t msg_q_resolve(const char* name);

// Message interfaces.
ALWAYS_INLINE 
    inline msg_t* msg_allocate() { return (msg_t*)malloc(sizeof(msg_t)); }
ALWAYS_INLINE
    inline void msg_free(msg_t* m) { free(m); }

int msg_send(msg_q_t q, msg_t* msg);
int msg_sendrecv(msg_q_t q, msg_t* msg);
int msg_respond(msg_q_t q, msg_t* msg);
msg_t* msg_wait(msg_q_t q);

ALWAYS_INLINE
    inline uint32_t msg_is_async(msg_t* msg) 
	{ return 0 == msg->__reserved__async; }

#ifdef __cplusplus
}
#endif

#endif
OpenPOWER on IntegriCloud