#include "common.h"
#include "pmsg.h"
#include "lib/zalloc.h"
#include "lib/walloc.h"
#include "lib/override.h"
Data Structures | |
struct | pmsg_ext |
An extended message block. More... | |
Defines | |
#define | implies(a, b) (!(a) || (b)) |
#define | valid_ptr(a) (((gulong) (a)) > 100L) |
#define | EMBEDDED_OFFSET G_STRUCT_OFFSET(pdata_t, d_embedded) |
Typedefs | |
typedef pmsg_ext | pmsg_ext_t |
An extended message block. | |
Functions | |
RCSID ("$Id:pmsg.c, v 1.9 2005/06/25 01:37:40 daichik Exp $") | |
void | pmsg_init (void) |
Allocate internal variables. | |
void | pmsg_close (void) |
Free internal variables. | |
int | pmsg_size (pmsg_t *mb) |
Compute message's size. | |
pmsg_t * | pmsg_fill (pmsg_t *mb, pdata_t *db, gint prio, gconstpointer buf, gint len) |
Fill newly created message block. | |
pmsg_t * | pmsg_new (gint prio, gconstpointer buf, gint len) |
Create new message from user provided data, which are copied into the allocated data block. | |
pmsg_t * | pmsg_new_extend (gint prio, gconstpointer buf, gint len, pmsg_free_t free_cb, gpointer arg) |
Like pmsg_new() but returns an extended form with a free routine callback. | |
pmsg_t * | pmsg_alloc (gint prio, pdata_t *db, gint roff, gint woff) |
Allocate new message using existing data block `db'. | |
pmsg_t * | pmsg_clone_extend (pmsg_t *mb, pmsg_free_t free_cb, gpointer arg) |
Extended cloning of message, adds a free routine callback. | |
pmsg_free_t | pmsg_replace_ext (pmsg_t *mb, pmsg_free_t nfree, gpointer narg, gpointer *oarg) |
Replace free routine from an extended message block. | |
gpointer | pmsg_get_metadata (pmsg_t *mb) |
Get the "meta data" from an extended message block (the argument passed to the embedded free routine). | |
pmsg_check_t | pmsg_set_check (pmsg_t *mb, pmsg_check_t check) |
Set the pre-send checking routine for the buffer. | |
pmsg_t * | pmsg_clone_ext (pmsg_ext_t *mb) |
Shallow cloning of extended message, result is referencing the same data. | |
pmsg_t * | pmsg_clone (pmsg_t *mb) |
Shallow cloning of message, result is referencing the same data. | |
void | pmsg_free (pmsg_t *mb) |
Free all message blocks, and decrease ref count on all data buffers. | |
gint | pmsg_write (pmsg_t *mb, gconstpointer data, gint len) |
Write data at the end of the message. | |
gint | pmsg_read (pmsg_t *mb, gpointer data, gint len) |
Read data from the message, returning the amount of bytes transferred. | |
pdata_t * | pdata_new (int len) |
Allocate a new data block of given size. | |
pdata_t * | pdata_allocb (void *buf, gint len, pdata_free_t freecb, gpointer freearg) |
Create an embedded data buffer out of existing arena. | |
pdata_t * | pdata_allocb_ext (void *buf, gint len, pdata_free_t freecb, gpointer freearg) |
Create an external (arena not embedded) data buffer out of existing arena. | |
void | pdata_free_nop (gpointer unused_p, gpointer unused_arg) |
This free routine can be used when there is nothing to be freed for the buffer, probably because it was made out of a static buffer. | |
void | pdata_free (pdata_t *db) |
Free data block when its reference count has reached 0. | |
void | pdata_unref (pdata_t *db) |
Decrease reference count on buffer, and free it when it reaches 0. | |
Variables | |
zone_t * | mb_zone = NULL |
|
|
|
|
|
|
|
An extended message block. Relies on C's structural equivalence for the first 4 fields. An extended message block can be identified by its `m_prio' field having the PMSG_PF_EXT flag set. |
|
Create an embedded data buffer out of existing arena. The optional `freecb' structure supplies the free routine callback to be used to free the arena, with freearg as additional argument. |
|
Create an external (arena not embedded) data buffer out of existing arena. The optional `freecb' structure supplies the free routine callback to be used to free the arena, with freearg as additional argument. |
|
Free data block when its reference count has reached 0.
|
|
This free routine can be used when there is nothing to be freed for the buffer, probably because it was made out of a static buffer.
|
|
Allocate a new data block of given size. The block header is at the start of the allocated block. |
|
Decrease reference count on buffer, and free it when it reaches 0.
|
|
Allocate new message using existing data block `db'. The `roff' and `woff' are used to delimit the start and the end (first unwritten byte) of the message within the data buffer.
|
|
Shallow cloning of message, result is referencing the same data.
|
|
Shallow cloning of extended message, result is referencing the same data.
|
|
Extended cloning of message, adds a free routine callback.
|
|
Free internal variables.
|
|
Fill newly created message block.
|
|
Free all message blocks, and decrease ref count on all data buffers.
|
|
Get the "meta data" from an extended message block (the argument passed to the embedded free routine).
|
|
Allocate internal variables.
|
|
Create new message from user provided data, which are copied into the allocated data block. If no user buffer is provided, an empty message is created and the length is used to size the data block.
|
|
Like pmsg_new() but returns an extended form with a free routine callback.
|
|
Read data from the message, returning the amount of bytes transferred.
|
|
Replace free routine from an extended message block. The original free routine and its argument are returned. This is used when wrapping an existing extended message and its metadata in another extension structure.
|
|
Set the pre-send checking routine for the buffer. This routine, if it exists (non-NULL) is called just before enqueueing the message for sending. If it returns FALSE, the message is immediately dropped. The callback routine must not modify the message, as the buffer can be shared among multiple messages, unless its refcount is 1.
|
|
Compute message's size.
|
|
Write data at the end of the message. The message must be the only reference to the underlying data.
|
|
|
|
|