|
BB2 C port
API reference: Blitz libraries in C and the shared code
|
#include <stddef.h>#include <exec/types.h>Go to the source code of this file.
Data Structures | |
| struct | regs |
| The register frame of the stubs in start.c (movem d0-d7/a0-a6). More... | |
| struct | edstruct |
| The compiler's edstruct (blitz2.s 274; ted.s outside copies its 14 words). More... | |
| struct | sb |
| A bounded string builder: buf of max bytes, len used, always 0-terminated (what does not fit is dropped). More... | |
Macros | |
| #define | EDSTUB_PATHLEN 256 |
| Length of edstub_logname. | |
Functions | |
| void | edstub_main (const char *arg) |
| The program part, provided by the program on this frame. | |
| ULONG | edstub_callregs (APTR fn, struct regs *r) |
| Call code that may change every register (compiler callbacks, TED routines). | |
| void | edstub_abort (void) |
| Back to the compiler as if the editor had quit. | |
| int | edstub_open_requests (void) |
| The number of requesters open now (openreq not yet closed). | |
| struct MsgPort * | edstub_req_port (void) |
| The UserPort of the requester window. | |
| void | edstub_log (const char *s) |
| Log a line: to Output() and appended to the log file. | |
| int | edstub_set_log (const char *path) |
| Set the log file: create it (a new file) and write the lines kept so far. | |
| void | edstub_reset_requests (void) |
| A new job: the counters of the requester answers start again. | |
| struct MsgPort * | edstub_create_port (void) |
| A message port with a signal of its own, with Kickstart 1.x calls (CreateMsgPort of V36). | |
| void | edstub_delete_port (struct MsgPort *port) |
| Free a port of edstub_create_port() and its signal. | |
| struct IORequest * | edstub_create_ioreq (struct MsgPort *port, ULONG size) |
| An IO request for a port, with Kickstart 1.x calls (CreateIORequest of V36). | |
| void | edstub_delete_ioreq (struct IORequest *io) |
| Free a request of edstub_create_ioreq() (as DeleteIORequest: the node's successor and io_Device set to -1 first). | |
| void | sbc (struct sb *b, char c) |
| Append the character c. | |
| void | sbs (struct sb *b, const char *s) |
| Append the string s ("(null)" for NULL). | |
| void | sbn (struct sb *b, LONG v) |
| Append v in decimal. | |
| void | sbx (struct sb *b, ULONG v, int digits) |
| Append the low digits hex digits of v, upper case. | |
| void | sbq (struct sb *b, const char *s) |
| Append s quoted, controls (< 32 and 127) as \xNN. | |
The racing stripe (#980) | |
The compiler's progress bar. The original compiler XORs it into the editor's bitmap (comdata+36, rows 0 to 9, comdata+92 bytes per row); blitz2-c reports its cells through TED-C's progress call (comdata+98 marker 'TEDp', +102 entry: d0 bar, d1 byte column). By default the frame has a bitmap of 80 bytes per row and does not announce the call. | |
| int | edstub_set_bitmap (UWORD bmapmul, ULONG guard) |
| Give the compiler a bitmap of bmapmul bytes per row (comdata+92) with guard bytes before and after it, and record the stripe from now on (edstub_stripe_log). | |
| void | edstub_set_progress (int on) |
| Announce the progress call (comdata+98 = 'TEDp') or not (0). | |
| void | edstub_stripe_log (const char *id) |
| After a compile: log the stripe, then clear the bitmap, refill the guards and the counters. | |
Small libc replacements | |
memset/memcpy for the compiler as well. | |
| void * | memset (void *d, int c, size_t n) |
| void * | memcpy (void *d, const void *s, size_t n) |
| ULONG | edstub_strlen (const char *s) |
| The length of the string s. | |
| int | edstub_streq (const char *a, const char *b) |
| 1 if the strings are equal, else 0. | |
| int | edstub_prefix (const char *s, const char *pre) |
| 1 if s starts with pre, else 0. | |
| void | edstub_strcpy (char *d, const char *s, ULONG max) |
| Copy s to d, at most max - 1 characters and the 0 (nothing if max is 0). | |
| void | edstub_strcat (char *d, const char *s, ULONG max) |
| Append s to d; max is the size of all of d (as edstub_strcpy). | |
| ULONG | edstub_udiv10 (ULONG u, ULONG *rem) |
| u / 10 without libgcc (no __udivsi3 in a -nostdlib build); the remainder to *rem. | |
Variables | |
| struct edstruct * | edstub_ed |
| The edstruct blitz2 passed to outside (a1). | |
| char | edstub_logname [EDSTUB_PATHLEN] |
| The log file's name; empty while there is none. | |
| int | edstub_quiet |
| Non-zero: edstub_log does not write to Output() (a program with a console output of its own; the log file still gets the lines). | |
| int | edstub_busy |
| The busy pointer: sleepon sets it (1), pointeron clears it (ted.s: the window pointer); the frame shows nothing, it only keeps the state. | |
Hooks of the program | |
NULL: the frame's default. | |
| const char *(* | edstub_ezfreq_hook )(const char *title) |
| ezfreq: the file name for the requester with this title, or NULL (default: cancelled). | |
| void(* | edstub_error_hook )(const char *msg) |
| The compiler's error message (default: logged). | |
| void(* | edstub_tokone_hook )(UBYTE *line) |
| tokone: tokenise the line (default: logged, line left as is). | |
| void(* | edstub_abort_hook )(const char *why) |
| Before the frame aborts inside main (compiler waits for input forever, extalloc of the original compiler failed): the program can log its result and free its data. | |
| void(* | edstub_openio_hook )(void) |
| openio/closeio (ted.s: the console window of a program run from the editor): called in the program's process, runtheprog, before and after the program. | |
| void(* | edstub_closeio_hook )(void) |
| openio/closeio (ted.s: the console window of a program run from the editor): called in the program's process, runtheprog, before and after the program. | |
| UWORD(* | edstub_getinput2_hook )(void) |
| getinput2 (the compiler polls the stop requester, chkrealstop): the id of the gadget hit, 0 = nothing (default: nothing). | |
| #define EDSTUB_PATHLEN 256 |
Length of edstub_logname.
| void edstub_abort | ( | void | ) |
Back to the compiler as if the editor had quit.
Drops everything below the main entry's frame (the stack pointer kept by the main entry). Only inside main.
| ULONG edstub_callregs | ( | APTR | fn, |
| struct regs * | r ) |
Call code that may change every register (compiler callbacks, TED routines).
Loads d0-d7/a0-a6 from *r, calls fn and stores all registers back into *r.
| fn | the routine to call |
| r | the registers: in before the call, out after it |
| struct IORequest * edstub_create_ioreq | ( | struct MsgPort * | port, |
| ULONG | size ) |
| struct MsgPort * edstub_create_port | ( | void | ) |
A message port with a signal of its own, with Kickstart 1.x calls (CreateMsgPort of V36).
| void edstub_delete_ioreq | ( | struct IORequest * | io | ) |
Free a request of edstub_create_ioreq() (as DeleteIORequest: the node's successor and io_Device set to -1 first).
| io | the request (NULL: nothing) |
| void edstub_delete_port | ( | struct MsgPort * | port | ) |
Free a port of edstub_create_port() and its signal.
| port | the port (NULL: nothing) |
| void edstub_log | ( | const char * | s | ) |
Log a line: to Output() and appended to the log file.
Before there is a log file, the lines are kept and edstub_set_log() writes them first. The file is opened and closed for every line, so the log survives a crash of the compiler.
| s | the line, without its line feed |
| void edstub_main | ( | const char * | arg | ) |
The program part, provided by the program on this frame.
Called by the main entry; when it returns, the frame closes everything and blitz2 quits.
| arg | the argument blitz2 got (a0 of the main entry: the file name) |
| int edstub_open_requests | ( | void | ) |
The number of requesters open now (openreq not yet closed).
| int edstub_prefix | ( | const char * | s, |
| const char * | pre ) |
1 if s starts with pre, else 0.
| struct MsgPort * edstub_req_port | ( | void | ) |
The UserPort of the requester window.
Its signal is the stop requester's exception (blitz2 openstopreq), a message there is "a gadget was hit".
| void edstub_reset_requests | ( | void | ) |
A new job: the counters of the requester answers start again.
| int edstub_set_bitmap | ( | UWORD | bmapmul, |
| ULONG | guard ) |
Give the compiler a bitmap of bmapmul bytes per row (comdata+92) with guard bytes before and after it, and record the stripe from now on (edstub_stripe_log).
| bmapmul | bytes per row (at least 80) |
| guard | guard bytes before and after the bitmap |
| int edstub_set_log | ( | const char * | path | ) |
Set the log file: create it (a new file) and write the lines kept so far.
| path | the file name (cut to EDSTUB_PATHLEN - 1 characters) |
| void edstub_set_progress | ( | int | on | ) |
Announce the progress call (comdata+98 = 'TEDp') or not (0).
A call toggles the cell as the original compiler XORs it (the byte column of rows bar and 9 - bar of the bitmap) and is counted.
| void edstub_strcat | ( | char * | d, |
| const char * | s, | ||
| ULONG | max ) |
Append s to d; max is the size of all of d (as edstub_strcpy).
| void edstub_strcpy | ( | char * | d, |
| const char * | s, | ||
| ULONG | max ) |
Copy s to d, at most max - 1 characters and the 0 (nothing if max is 0).
| int edstub_streq | ( | const char * | a, |
| const char * | b ) |
1 if the strings are equal, else 0.
| void edstub_stripe_log | ( | const char * | id | ) |
After a compile: log the stripe, then clear the bitmap, refill the guards and the counters.
Lines (tab separated, with the job's id): PROGRESS ID none (no call) or per bar with calls PROGRESS ID bar N COUNTS (the calls per column from column 0, a digit each, '+' above 9, up to the last column called), plus PROGRESS ID bad N for calls with a bar above 3 or a column outside the row; STRIPE ID none (bitmap empty) or per row with set bytes STRIPE ID row R PICTURE ('#' $FF, '.' 0, 'x' else, up to the last byte not 0, columns 0 to 255); GUARD ID ok or GUARD ID before N after M (bytes of the guards changed). The picture and the guards are those of the checkpoints openreq, closereq and the end of the job: the fullest picture, the most changed guard bytes (with two passes the XORs of the second undo those of the first; the requester of the second pass opens between them). Nothing without edstub_set_bitmap.
| id | the job's id |
| ULONG edstub_strlen | ( | const char * | s | ) |
The length of the string s.
| ULONG edstub_udiv10 | ( | ULONG | u, |
| ULONG * | rem ) |
u / 10 without libgcc (no __udivsi3 in a -nostdlib build); the remainder to *rem.
| void * memcpy | ( | void * | d, |
| const void * | s, | ||
| size_t | n ) |
| void * memset | ( | void * | d, |
| int | c, | ||
| size_t | n ) |
| void sbc | ( | struct sb * | b, |
| char | c ) |
Append the character c.
| void sbn | ( | struct sb * | b, |
| LONG | v ) |
Append v in decimal.
| void sbq | ( | struct sb * | b, |
| const char * | s ) |
Append s quoted, controls (< 32 and 127) as \xNN.
| void sbs | ( | struct sb * | b, |
| const char * | s ) |
Append the string s ("(null)" for NULL).
| void sbx | ( | struct sb * | b, |
| ULONG | v, | ||
| int | digits ) |
Append the low digits hex digits of v, upper case.
|
extern |
Before the frame aborts inside main (compiler waits for input forever, extalloc of the original compiler failed): the program can log its result and free its data.
|
extern |
The busy pointer: sleepon sets it (1), pointeron clears it (ted.s: the window pointer); the frame shows nothing, it only keeps the state.
|
extern |
openio/closeio (ted.s: the console window of a program run from the editor): called in the program's process, runtheprog, before and after the program.
|
extern |
The edstruct blitz2 passed to outside (a1).
|
extern |
The compiler's error message (default: logged).
|
extern |
ezfreq: the file name for the requester with this title, or NULL (default: cancelled).
|
extern |
getinput2 (the compiler polls the stop requester, chkrealstop): the id of the gadget hit, 0 = nothing (default: nothing).
|
extern |
The log file's name; empty while there is none.
|
extern |
openio/closeio (ted.s: the console window of a program run from the editor): called in the program's process, runtheprog, before and after the program.
|
extern |
Non-zero: edstub_log does not write to Output() (a program with a console output of its own; the log file still gets the lines).
|
extern |
tokone: tokenise the line (default: logged, line left as is).