gonzui


Format: Advanced Search

tkernel_2/lib/crt/crttk/src/pstartup.cbare sourcepermlink (0.01 seconds)

Search this content:

    1: /*
    2:  *----------------------------------------------------------------------
    3:  *    T-Kernel 2.0 Software Package
    4:  *
    5:  *    Copyright 2011 by Ken Sakamura.
    6:  *    This software is distributed under the latest version of T-License 2.x.
    7:  *----------------------------------------------------------------------
    8:  *
    9:  *    Released by T-Engine Forum(http://www.t-engine.org/) at 2011/05/17.
   10:  *    Modified by TRON Forum(http://www.tron.org/) at 2015/06/01.
   11:  *
   12:  *----------------------------------------------------------------------
   13:  */
   14: 
   15: /*
   16:  *      @(#)pstartup.c (crttk)
   17:  *
   18:  *      Manager startup
   19:  */
   20: 
   21: #include <basic.h>
   22: #include <tk/typedef.h>
   23: #include <tk/errno.h>
   24: 
   25: /*
   26:  * Compiler-dependent initialization/finalization sequence
   27:  */
   28: IMPORT void _init_compiler( void );
   29: IMPORT void _fini_compiler( void );
   30: 
   31: /*
   32:  * Library (libtk) initialization/termination sequence
   33:  */
   34: IMPORT  void     _InitLibtk( void );
   35: IMPORT  void     _FinishLibtk( void );
   36: 
   37: /*
   38:  * Manager entry
   39:  */
   40: IMPORT ER main( INT ac, UB *av[] );
   41: 
   42: /*
   43:  * Manager startup
   44:  */
   45: EXPORT ER _P_startup( INT ac, UB *av[] )
   46: {
   47:         ER     ercd;
   48: 
   49:         if ( ac >= 0 ) {
   50:                 /* Library initialization */
   51:                 _InitLibtk();
   52: 
   53:                 /* Compiler-dependent initialization/finalization sequence */
   54:                 _init_compiler();
   55:         }
   56: 
   57:         /* main() execute */
   58:         ercd = main(ac, av);
   59: 
   60:         /* Library function termination sequence is performed in the
   61:          * event of startup failure (main returns an error during startup)
   62:          * and successful termination (main does not return an error
   63:          * at termination).
   64:          */
   65:         if ( (ac >= 0 && ercd <  E_OK) || (ac <  0 && ercd >= E_OK) ) {
   66:                 /* Compiler-dependent finalization sequence */
   67:                 _fini_compiler();
   68: 
   69:                 /* Library termination sequence */
   70:                 _FinishLibtk();
   71:         }
   72: 
   73:         return ercd;
   74: }