ProcessContext impl

Implements the global context of the running system process.  See ProcessContext.

Summary
ProcessContext implImplements the global context of the running system process.
CopyrightThis program is free software.
Files
C-kern/api/context/processcontext.hHeader file ProcessContext.
C-kern/context/processcontext.cImplementation file ProcessContext impl.
processcontext_t
static variables
s_processcontext_errtimerSimulates an error in <init_processcontext>.
helper
INITOBJECTInitializes object.
FREEOBJECTFrees object.
inithelperX_processcontext
freehelperX_processcontext
lifetime
query
test

Copyright

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.

Author

© 2012 Jörg Seebohn

Files

C-kern/api/context/processcontext.h

Header file ProcessContext.

C-kern/context/processcontext.c

Implementation file ProcessContext impl.

processcontext_t

static variables

s_processcontext_errtimer

static test_errortimer_t s_processcontext_errtimer

Simulates an error in <init_processcontext>.

helper

INITOBJECT

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

FREEOBJECT

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

inithelperX_processcontext

  • Generated inithelper functions to init modules with calls to initonce_module.
  • Generated inithelper functions to init objects with calls init_module.

freehelperX_processcontext

  • Generated freehelper functions to free modules with calls to freeonce_module.
  • Generated freehelper functions to free objects with calls free_module.

lifetime

query

test

Defines the global context of the running system process.
Implements the global context of the running system process.
static test_errortimer_t s_processcontext_errtimer
Simulates an error in init_processcontext.
#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.
#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.
Close