TEMU
4.4
The Terma Emulator
|
Go to the source code of this file.
Data Structures | |
struct | temu_Buff |
Macros | |
#define | TEMU_BUFF_DEFINED |
Functions | |
TEMU_API temu_Buff | temu_buffCreate (uint32_t size) |
TEMU_API temu_Buff | temu_buffCopy (const temu_Buff *B) |
TEMU_API void | temu_buffDispose (temu_Buff *B) |
TEMU_API uint8_t * | temu_buffWritableData (temu_Buff *B) |
const TEMU_API uint8_t * | temu_buffReadableData (const temu_Buff *B) |
TEMU_API uint32_t | temu_buffLen (const temu_Buff *B) |
TEMU_API void | temu_buffRemoveHead (temu_Buff *B, uint32_t len) |
TEMU_API void | temu_buffRemoveTail (temu_Buff *B, uint32_t len) |
#define TEMU_BUFF_DEFINED |
Copy-On-Write (COW) buffer. The content is private and should not be manipulated directly.
NOTE: The COW buffers are currently an EXPERIMENTAL feature. The API may change. Further, the temu_Buff type itself may change without notice in future versions of TEMU. The type is internal for the buffer API, but is exposed as a struct here to save on memory allocations when creating a temporary buffer object copy on the stack.
The COW buffer objects are suitable for network simulation. Where a receiver may need to queue up multiple received packets.
Currently, there is no way to prepend or append (e.g. injecting extra headers). However, it is possible to delete bytes from the head of the buffer without causing copies of the actual buffered data. This is enough to support efficient SpaceWire simulation.
Typically a device model would use the buffers in this way:
Copy COW buffer. This will make a new buff object, but the underlying data will not be copied.
B | The buffer to copy. |
Create a new COW buffer of size bytes.
size | Size of buffer in bytes |
Delete buffer. The buffer B will be deleted. If there are no more copies of the buffer data anywhere, the data will be deallocated.
B | buffer to delete. |
Get buffer length
B | buffer |
Get a pointer to readable buffer data
The pointer to the readable data will be returned.
B | Buffer to get read pointer from |
Remove len bytes from the start of the buffer.
Removing bytes from the buffer start will not change the underlying buffer object. And is not seen as a write for the purpose of the data block.
This does not affect other copies of this buffer.
B | buffer to remove data from |
len | Number of bytes to remove. |
Remove len bytes from the end of the buffer.
Removing bytes from the buffer tail will not change the underlying buffer object. And is not seen as a write for the purpose of the data block.
This does not affect other copies of this buffer.
B | buffer to remove data from |
len | Number of bytes to remove. |