Implements the global context of the running system process. See ProcessContext.
ProcessContext impl | Implements the global context of the running system process. |
Copyright | This program is free software. |
Files | |
C-kern/ | Header file ProcessContext. |
C-kern/ | Implementation file ProcessContext impl. |
processcontext_t | |
static variables | |
s_processcontext_errtimer | Simulates an error in <init_processcontext>. |
helper | |
INITOBJECT | Initializes object. |
FREEOBJECT | Frees object. |
inithelperX_processcontext | |
freehelperX_processcontext | |
lifetime | |
query | |
test |
This program is free software. You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
© 2012 Jörg Seebohn
Header file ProcessContext.
Implementation file ProcessContext impl.
static variables | |
s_processcontext_errtimer | Simulates an error in <init_processcontext>. |
helper | |
INITOBJECT | Initializes object. |
FREEOBJECT | Frees object. |
inithelperX_processcontext | |
freehelperX_processcontext | |
lifetime | |
query | |
test |
#define INITOBJECT( module, objtype_t, object ) int err ; objtype_t * newobj = 0 ; ONERROR_testerrortimer( &s_processcontext_errtimer, &err, ONABORT); newobj = allocstatic_maincontext( sizeof(objtype_t)) ; if (!newobj) { err = ENOMEM ; goto ONABORT ; } ONERROR_testerrortimer( &s_processcontext_errtimer, &err, ONABORT); err = init_##module(newobj) ; if (err) goto ONABORT ; (object) = newobj ; return 0 ; ONABORT: if (newobj) { freestatic_maincontext(sizeof(objtype_t)) ; } return err ;
Initializes object. Calls allocstatic_maincontext to allocate memory. This memory is initialized with call to init_##module() and the address is assigned to object.
#define FREEOBJECT( module, objtype_t, object ) int err ; int err2 ; objtype_t * delobj = (object) ; if (delobj != (0)) { (object) = (0) ; err = free_##module(delobj) ; err2 = freestatic_maincontext( sizeof(objtype_t)) ; if (err2) err = err2 ; return err ; } return 0 ;
Frees object. Calls freestatic_maincontext to free memory as last operation. Calls free_##module() to free object. object is set to 0. Calling it twice has no effect.
Simulates an error in init_processcontext.
static test_errortimer_t s_processcontext_errtimer
Initializes object.
#define INITOBJECT( module, objtype_t, object ) int err ; objtype_t * newobj = 0 ; ONERROR_testerrortimer( &s_processcontext_errtimer, &err, ONABORT); newobj = allocstatic_maincontext( sizeof(objtype_t)) ; if (!newobj) { err = ENOMEM ; goto ONABORT ; } ONERROR_testerrortimer( &s_processcontext_errtimer, &err, ONABORT); err = init_##module(newobj) ; if (err) goto ONABORT ; (object) = newobj ; return 0 ; ONABORT: if (newobj) { freestatic_maincontext(sizeof(objtype_t)) ; } return err ;
Frees object.
#define FREEOBJECT( module, objtype_t, object ) int err ; int err2 ; objtype_t * delobj = (object) ; if (delobj != (0)) { (object) = (0) ; err = free_##module(delobj) ; err2 = freestatic_maincontext( sizeof(objtype_t)) ; if (err2) err = err2 ; return err ; } return 0 ;