ach
Real-Time IPC Library
generic.h File Reference

This file contains declarations needed by both the userspace public interface and the Linux kernel implementation. More...

Go to the source code of this file.

Data Structures

struct  achk_opt
 Struct containing 'cache' of kernel module data to avoid updating when no changes exist. More...
 

Macros

#define ACH_WARN_UNUSED
 Warn if result is unused.
 
#define ACH_STALE_FRAMES   ACH_EAGAIN
 
#define ACH_LOCKED   ACH_EAGAIN
 
#define ACH_STATUS_MASK(r)   (1<<(r))
 Generate a bit mask from an ach status type. More...
 
#define ACH_MASK_STALE_FRAMES   ACH_MASK_EAGAIN
 
#define ACH_MASK_LOCKED   ACH_MASK_EAGAIN
 
#define ACH_CHAN_NAME_MAX   64ul
 maximum size of a channel name
 

Typedefs

typedef enum ach_status ach_status_t
 return status codes for ach functions. More...
 
typedef enum ach_mask ach_mask_t
 Convenience typedef for enum ach_mask.
 
typedef struct achk_opt achk_opt_t
 Struct containing 'cache' of kernel module data to avoid updating when no changes exist. More...
 

Enumerations

enum  ach_status {
  ACH_OK = 0, ACH_OVERFLOW = 1, ACH_INVALID_NAME = 2, ACH_BAD_SHM_FILE = 3,
  ACH_FAILED_SYSCALL = 4, ACH_EAGAIN = 5, ACH_MISSED_FRAME = 6, ACH_TIMEOUT = 7,
  ACH_EEXIST = 8, ACH_ENOENT = 9, ACH_CLOSED = 10, ACH_BUG = 11,
  ACH_EINVAL = 12, ACH_CORRUPT = 13, ACH_BAD_HEADER = 14, ACH_EACCES = 15,
  ACH_CANCELED = 16, ACH_EFAULT = 17, ACH_EINTR = 18, ACH_ENOTSUP = 19
}
 return status codes for ach functions. More...
 
enum  ach_mask {
  ACH_MASK_OK = ACH_STATUS_MASK(ACH_OK), ACH_MASK_OVERFLOW = ACH_STATUS_MASK(ACH_OVERFLOW), ACH_MASK_INVALID_NAME = ACH_STATUS_MASK(ACH_INVALID_NAME), ACH_MASK_BAD_SHM_FILE = ACH_STATUS_MASK(ACH_BAD_SHM_FILE),
  ACH_MASK_FAILED_SYSCALL = ACH_STATUS_MASK(ACH_FAILED_SYSCALL), ACH_MASK_EAGAIN = ACH_STATUS_MASK(ACH_EAGAIN), ACH_MASK_MISSED_FRAME = ACH_STATUS_MASK(ACH_MISSED_FRAME), ACH_MASK_TIMEOUT = ACH_STATUS_MASK(ACH_TIMEOUT),
  ACH_MASK_EEXIST = ACH_STATUS_MASK(ACH_EEXIST), ACH_MASK_ENOENT = ACH_STATUS_MASK(ACH_ENOENT), ACH_MASK_CLOSED = ACH_STATUS_MASK(ACH_CLOSED), ACH_MASK_BUG = ACH_STATUS_MASK(ACH_BUG),
  ACH_MASK_EINVAL = ACH_STATUS_MASK(ACH_EINVAL), ACH_MASK_CORRUPT = ACH_STATUS_MASK(ACH_CORRUPT), ACH_MASK_BAD_HEADER = ACH_STATUS_MASK(ACH_BAD_HEADER), ACH_MASK_EACCES = ACH_STATUS_MASK(ACH_EACCES),
  ACH_MASK_CANCELED = ACH_STATUS_MASK(ACH_CANCELED), ACH_MASK_EFAULT = ACH_STATUS_MASK(ACH_EFAULT), ACH_MASK_EINTR = ACH_STATUS_MASK(ACH_EINTR), ACH_MASK_ENOTSUP = ACH_STATUS_MASK(ACH_ENOTSUP),
  ACH_MASK_LOCKED = ACH_STATUS_MASK(ACH_LOCKED), ACH_MASK_NONE = 0, ACH_MASK_ALL = 0xffffffff
}
 Bit masks that correspond to members of enum ach_status. More...
 
enum  ach_get_opts_t {
  ACH_O_NONBLOCK = 0x00, ACH_O_FIRST = 0x00, ACH_O_ABSTIME = 0x00, ACH_O_WAIT = 0x01,
  ACH_O_LAST = 0x02, ACH_O_COPY = 0x04, ACH_O_RELTIME = 0x08
}
 Option flags for ach_get(). More...
 

Functions

enum ach_status ach_get_fun (void *cx, void **obj_dst, const void *chan_src, size_t frame_size)
 Function type to transfer data out of the channel. More...
 
enum ach_status ach_put_fun (void *cx, void *chan_dst, const void *obj_src)
 Function type to transfer data into the channel. More...
 

Detailed Description

This file contains declarations needed by both the userspace public interface and the Linux kernel implementation.

Author
Neil T. Dantam

Macro Definition Documentation

#define ACH_STATUS_MASK (   r)    (1<<(r))

Generate a bit mask from an ach status type.

See also
enum ach_mask

Typedef Documentation

typedef enum ach_status ach_status_t

return status codes for ach functions.

See also
enum ach_mask
typedef struct achk_opt achk_opt_t

Struct containing 'cache' of kernel module data to avoid updating when no changes exist.

Enumeration Type Documentation

Option flags for ach_get().

Default behavior is to retrieve the oldest unseen frame without waiting.

Enumerator
ACH_O_NONBLOCK 

Do not block for a new messages.

Exclusive with ACH_O_WAIT.

ACH_O_FIRST 

Retrieve the oldest unseen message.

Exclusive with ACH_O_LAST.

ACH_O_ABSTIME 

Timeout is an absolute time.

Timeout must use the clock set during channel creation.

Exclusive with ACH_O_RELTIME.

See also
ach_channel_clock()
ACH_O_WAIT 

Block until an unseen message arrives or timeout.

If the channel already has data that this subscriber has not seen, ach_get() immediately copies the new data. Otherwise, it waits for some other process or thread to put data into the channel.

Exclusive with ACH_O_NONBLOCK.

ACH_O_LAST 

Read the newest message out of the channel.

If the channel contains multiple messages that this subscriber has not seen, ach_get() will return the newest of these messages. The subscriber will skip past all older messages.

Exclusive with ACH_O_FIRST.

ACH_O_COPY 

Copy the message out of the channel, even if already seen.

The return code of ach_get() for successful copy is ACH_OK.

ACH_O_RELTIME 

Timeout is a relative time.

Exclusive with ACH_O_ABSTIME.

enum ach_mask

Bit masks that correspond to members of enum ach_status.

These masks are useful to check whether a status code matches a set of values.

enum ach_status

return status codes for ach functions.

See also
enum ach_mask
Enumerator
ACH_OK 

Call successful.

ACH_OVERFLOW 

destination too small to hold frame

ACH_INVALID_NAME 

invalid channel name

ACH_BAD_SHM_FILE 

channel file didn't look right

ACH_FAILED_SYSCALL 

a system call failed

ACH_EAGAIN 

no new data in the channel

ACH_MISSED_FRAME 

we missed the next frame

ACH_TIMEOUT 

timeout before frame received

ACH_EEXIST 

channel file already exists

ACH_ENOENT 

channel file doesn't exist

ACH_CLOSED 

unused

ACH_BUG 

internal ach error

ACH_EINVAL 

invalid parameter

ACH_CORRUPT 

channel memory has been corrupted

ACH_BAD_HEADER 

an invalid header was given

ACH_EACCES 

permission denied

ACH_CANCELED 

operation canceled

ACH_EFAULT 

bad address for data copy

ACH_EINTR 

operation interrupted.

Only used internally and not returned to library callers.

ACH_ENOTSUP 

not supported.

Function Documentation

enum ach_status ach_get_fun ( void *  cx,
void **  obj_dst,
const void *  chan_src,
size_t  frame_size 
)

Function type to transfer data out of the channel.

This function could, for example, perform tasks such as de-serialization and memory allocation.

Returns
0 on success, nonzero on failure
enum ach_status ach_put_fun ( void *  cx,
void *  chan_dst,
const void *  obj_src 
)

Function type to transfer data into the channel.

This function could, for example, perform tasks such as serialization.

Returns
0 on success, nonzero on failure