[process] Add PROC_INIT() for initialising static processes

Signed-off-by: Michael Brown <mcb30@ipxe.org>
pull/94/head
Michael Brown 2019-08-16 21:20:05 +01:00
parent c63ef427a2
commit 6df2c6ab76
1 changed files with 13 additions and 5 deletions

View File

@ -122,6 +122,18 @@ extern void process_add ( struct process *process );
extern void process_del ( struct process *process ); extern void process_del ( struct process *process );
extern void step ( void ); extern void step ( void );
/**
* Initialise a static process
*
* @v process Process
* @v desc Process descriptor
*/
#define PROC_INIT( _process, _desc ) { \
.list = LIST_HEAD_INIT ( (_process).list ), \
.desc = (_desc), \
.refcnt = NULL, \
}
/** /**
* Initialise process without adding to process list * Initialise process without adding to process list
* *
@ -180,11 +192,7 @@ process_running ( struct process *process ) {
*/ */
#define PERMANENT_PROCESS( name, step ) \ #define PERMANENT_PROCESS( name, step ) \
static struct process_descriptor name ## _desc = PROC_DESC_PURE ( step ); \ static struct process_descriptor name ## _desc = PROC_DESC_PURE ( step ); \
struct process name __permanent_process = { \ struct process name __permanent_process = PROC_INIT ( name, & name ## _desc );
.list = LIST_HEAD_INIT ( name.list ), \
.desc = & name ## _desc, \
.refcnt = NULL, \
};
/** /**
* Find debugging colourisation for a process * Find debugging colourisation for a process