BB2 C port
API reference: Blitz libraries in C and the shared code
Loading...
Searching...
No Matches
edstub.h File Reference
#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).

Macro Definition Documentation

◆ EDSTUB_PATHLEN

#define EDSTUB_PATHLEN   256

Length of edstub_logname.

Function Documentation

◆ edstub_abort()

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.

◆ edstub_callregs()

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.

Parameters
fnthe routine to call
rthe registers: in before the call, out after it
Returns
d0 after the call

◆ edstub_create_ioreq()

struct IORequest * edstub_create_ioreq ( struct MsgPort * port,
ULONG size )

An IO request for a port, with Kickstart 1.x calls (CreateIORequest of V36).

Parameters
portthe reply port (NULL: fails)
sizethe size of the request in bytes (cleared)
Returns
the request, or NULL if port is NULL or out of memory

◆ edstub_create_port()

struct MsgPort * edstub_create_port ( void )

A message port with a signal of its own, with Kickstart 1.x calls (CreateMsgPort of V36).

Returns
the port, or NULL if out of memory or signals

◆ edstub_delete_ioreq()

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).

Parameters
iothe request (NULL: nothing)

◆ edstub_delete_port()

void edstub_delete_port ( struct MsgPort * port)

Free a port of edstub_create_port() and its signal.

Parameters
portthe port (NULL: nothing)

◆ edstub_log()

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.

Parameters
sthe line, without its line feed

◆ edstub_main()

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.

Parameters
argthe argument blitz2 got (a0 of the main entry: the file name)

◆ edstub_open_requests()

int edstub_open_requests ( void )

The number of requesters open now (openreq not yet closed).

Returns
the depth of the requester stack

◆ edstub_prefix()

int edstub_prefix ( const char * s,
const char * pre )

1 if s starts with pre, else 0.

◆ edstub_req_port()

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".

Returns
the port

◆ edstub_reset_requests()

void edstub_reset_requests ( void )

A new job: the counters of the requester answers start again.

◆ edstub_set_bitmap()

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).

Parameters
bmapmulbytes per row (at least 80)
guardguard bytes before and after the bitmap
Returns
1, or 0 if out of memory (the bitmap stays as it was)

◆ edstub_set_log()

int edstub_set_log ( const char * path)

Set the log file: create it (a new file) and write the lines kept so far.

Parameters
paththe file name (cut to EDSTUB_PATHLEN - 1 characters)
Returns
1, or 0 if the file cannot be created (no log file then)

◆ edstub_set_progress()

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.

◆ edstub_strcat()

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).

◆ 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).

◆ edstub_streq()

int edstub_streq ( const char * a,
const char * b )

1 if the strings are equal, else 0.

◆ edstub_stripe_log()

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.

Parameters
idthe job's id

◆ edstub_strlen()

ULONG edstub_strlen ( const char * s)

The length of the string s.

◆ edstub_udiv10()

ULONG edstub_udiv10 ( ULONG u,
ULONG * rem )

u / 10 without libgcc (no __udivsi3 in a -nostdlib build); the remainder to *rem.

◆ memcpy()

void * memcpy ( void * d,
const void * s,
size_t n )

◆ memset()

void * memset ( void * d,
int c,
size_t n )

◆ sbc()

void sbc ( struct sb * b,
char c )

Append the character c.

◆ sbn()

void sbn ( struct sb * b,
LONG v )

Append v in decimal.

◆ sbq()

void sbq ( struct sb * b,
const char * s )

Append s quoted, controls (< 32 and 127) as \xNN.

◆ sbs()

void sbs ( struct sb * b,
const char * s )

Append the string s ("(null)" for NULL).

◆ sbx()

void sbx ( struct sb * b,
ULONG v,
int digits )

Append the low digits hex digits of v, upper case.

Variable Documentation

◆ edstub_abort_hook

void(* edstub_abort_hook) (const char *why) ( const char * why)
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.

◆ edstub_busy

int edstub_busy
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.

◆ edstub_closeio_hook

void(* edstub_closeio_hook) (void) ( void )
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.

◆ edstub_ed

struct edstruct* edstub_ed
extern

The edstruct blitz2 passed to outside (a1).

◆ edstub_error_hook

void(* edstub_error_hook) (const char *msg) ( const char * msg)
extern

The compiler's error message (default: logged).

◆ edstub_ezfreq_hook

const char *(* edstub_ezfreq_hook) (const char *title) ( const char * title)
extern

ezfreq: the file name for the requester with this title, or NULL (default: cancelled).

◆ edstub_getinput2_hook

UWORD(* edstub_getinput2_hook) (void) ( void )
extern

getinput2 (the compiler polls the stop requester, chkrealstop): the id of the gadget hit, 0 = nothing (default: nothing).

◆ edstub_logname

char edstub_logname[EDSTUB_PATHLEN]
extern

The log file's name; empty while there is none.

◆ edstub_openio_hook

void(* edstub_openio_hook) (void) ( void )
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.

◆ edstub_quiet

int edstub_quiet
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).

◆ edstub_tokone_hook

void(* edstub_tokone_hook) (UBYTE *line) ( UBYTE * line)
extern

tokone: tokenise the line (default: logged, line left as is).