|
BB2 C port
API reference: Blitz libraries in C and the shared code
|
Data Structures | |
| struct | portnode |
Macros | |
| #define | PORTBLOCK 0x2a |
Functions | |
| void | _CreateMsgPort (void) |
| void | _DeleteMsgPort (void) |
| ULONG | _dowait (void) |
| Wait - wait for any allocated signal of the task. | |
| void | _taskname (void) |
| void | _startup (void) |
| void | utillib_CloseRoutine (void) |
| void | delportchk (void) |
| static ULONG | taskname_c (struct Task *task) |
| TaskName$(task) - the name of a task. | |
| BLITZ_ALIAS (_taskname, taskname_c) | |
| static ULONG | startup_c (void) |
| init - CLR.l signals:MOVE.l signals,d0. | |
| static struct portnode * | findlistend (void) |
| static ULONG | createmsgport_c (const UBYTE *name, const ULONG *lens) |
| CreateMsgPort(PortName$) - create a message port. | |
| BLITZ_ALIAS (_CreateMsgPort, createmsgport_c) | |
| static void | deletemsgport_c (struct MsgPort *port) |
| DeleteMsgPort *UserPort - delete a port made by CreateMsgPort. | |
| BLITZ_ALIAS (_DeleteMsgPort, deletemsgport_c) | |
| static void | closeroutine_c (void) |
| static void | delportchk_c (const struct MsgPort *port) |
| The error check of DeleteMsgPort (debugger only). | |
Variables | |
| static ULONG | signals |
| struct { | |
| struct portnode * next | |
| struct portnode * prev | |
| } | PortListStart |
| static const char | NoMem [] = "Failed to allocate memory for Port" |
| static const char | NoSig [] = "Failed to allocate signal for Port" |
| #define PORTBLOCK 0x2a |
| void _CreateMsgPort | ( | void | ) |
| void _DeleteMsgPort | ( | void | ) |
| ULONG _dowait | ( | void | ) |
Wait - wait for any allocated signal of the task.
Wait(FindTask(0)->tc_SigAlloc) - all allocated signals (not a bug: the intended semantics); the result also goes to signals.
| void _startup | ( | void | ) |
| void _taskname | ( | void | ) |
| BLITZ_ALIAS | ( | _CreateMsgPort | , |
| createmsgport_c | ) |
| BLITZ_ALIAS | ( | _DeleteMsgPort | , |
| deletemsgport_c | ) |
| BLITZ_ALIAS | ( | _taskname | , |
| taskname_c | ) |
|
static |
|
static |
CreateMsgPort(PortName$) - create a message port.
Allocates the $2A byte block (memlib globalloc, MEMF_PUBLIC|MEMF_CLEAR), allocates a signal, initialises the port (PA_SIGNAL, this task) and links it into utillib's port list (freed by the finit). A non-empty name is copied into its own block {size.l, characters, 0} and the port made public (AddPort). Returns with a3 = the name argument ("Protect BB2 String area from corruption") and copies (UWORD)len+1 bytes of the name (DBRA on the length's low word; not a bug: a port name of 64 KB does not occur).
Errors: "Failed to allocate memory for Port" (runtime error; the port block stays allocated if the name allocation fails). DIFF (K, #300): after a returning TRAP #0 the original runs into its message text; the C version returns 0.
Fixed (#298): a failed AllocSignal (-1) frees the block ($2A bytes) and gives the runtime error "Failed to allocate signal for Port" (the original tested for signal 0 and made a port with mp_SigBit $FF; its error path would have freed the port address with $22 bytes).
| name | d0: the port name ("" = a private port) |
| lens | a2: the compiler's argument pointer: -4(a2) = the name's length |
|
static |
DeleteMsgPort *UserPort - delete a port made by CreateMsgPort.
RemPort and frees the name if there is one, replies the messages still queued, frees the signal, unlinks the port from utillib's list and frees its block. Keeps all registers.
Fixed (#299): the queued messages are replied (the original freed the port with them); replies that came back to the port (NT_REPLYMSG) are only removed. Errors (debugger only, delportchk): "Port Not Created By CreateMsgPort" (fixed, #1041: the original took any address; without the debugger a port that utillib did not create still corrupts memory, an invalid argument).
| port | d0: the port |
| void delportchk | ( | void | ) |
|
static |
The error check of DeleteMsgPort (debugger only).
Fixed (#1041), not in the original (DeleteMsgPort took any address): the port must be one of utillib's list, made by CreateMsgPort and not deleted yet.
Errors: "Port Not Created By CreateMsgPort".
| port | d0: the port |
|
static |
|
static |
init - CLR.l signals:MOVE.l signals,d0.
"other libs access using #utillib,#la0 then btst sigbit,(a0)".
|
static |
TaskName$(task) - the name of a task.
Copies the name to a3 including the 0.
Not a bug: a3 is left BEHIND the terminating 0 (no SUBQ #1,a3; no visible effect). Fixed (#297): a task without a name has the empty name (the original copied from address 0).
| task | d0: the task, 0 = this task (FindTask(0)) |
| void utillib_CloseRoutine | ( | void | ) |
| struct portnode* next |
|
static |
|
static |
| struct { ... } PortListStart |
| struct portnode * prev |
|
static |