Changeset 45c9b7d4 in rtems


Ignore:
Timestamp:
Apr 23, 2013, 1:04:42 PM (6 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
62aa318
Parents:
ea123ca
git-author:
Sebastian Huber <sebastian.huber@…> (04/23/13 13:04:42)
git-committer:
Sebastian Huber <sebastian.huber@…> (04/25/13 09:15:49)
Message:

libcsupport: POSIX conformance for _exit()

According to POSIX the _exit() function shall not call functions
registered with atexit() nor any registered signal handlers.

See also tests libtests/exit01 and libtests/exit02.

Make libc_wrapup() static. Remove out of date comments. Remove
superfluous declarations, defines and includes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libcsupport/src/newlibc_exit.c

    rea123ca r45c9b7d4  
    11/*
    2  *  Implementation of hooks for the CYGNUS newlib libc
    3  *  These hooks set things up so that:
    4  *       + '_REENT' is switched at task switch time.
    5  *
    62 *  COPYRIGHT (c) 1994 by Division Incorporated
    73 *
     
    2218#include <rtems/libcsupport.h>
    2319
    24 /* Since we compile with strict ANSI we need to undef it to get
    25  * prototypes for extensions
    26  */
    27 #undef __STRICT_ANSI__
     20#include <stdio.h>
     21#include <unistd.h>
    2822
    29 #include <stdlib.h>             /* for free() */
    30 #include <string.h>             /* for memset() */
    31 
    32 #include <sys/reent.h>          /* for extern of _REENT (aka _impure_ptr) */
    33 #include <errno.h>
    34 
    35 #include <stdio.h>
    36 
    37 int _fwalk(struct _reent *ptr, int (*function) (FILE *) );
    38 
    39 /* do we think we are reentrant? */
    40 extern int             libc_reentrant;
    41 extern struct _reent * const _global_impure_ptr __ATTRIBUTE_IMPURE_PTR__;
    42 
    43 /*
    44  * CYGNUS newlib routine that does atexit() processing and flushes
    45  *      stdio streams
    46  *      undocumented
    47  */
    48 
    49 extern void _wrapup_reent(struct _reent *);
    50 extern void _reclaim_reent(struct _reent *);
    51 
    52 void libc_wrapup(void)
     23static void libc_wrapup(void)
    5324{
    5425  /*
     
    5930  if (!_System_state_Is_up(_System_state_Get()))
    6031     return;
    61 
    62   /*
    63    *  This was already done if the user called exit() directly .
    64   _wrapup_reent(0);
    65    */
    66 
    67   if (_REENT != _global_impure_ptr) {
    68       _wrapup_reent(_global_impure_ptr);
    69 #if 0
    70       /*  Don't reclaim this one, just in case we do printfs
    71        *  on the way out to ROM.
    72        */
    73       _reclaim_reent(&libc_global_reent);
    74 #endif
    75       _REENT = _global_impure_ptr;
    76   }
    7732
    7833  /*
     
    8843}
    8944
    90 /*
    91  *  Function:   _exit
    92  *  Created:    94/12/10
    93  *
    94  *  Description:
    95  *      Called from exit() after it does atexit() processing and stdio fflush's
    96  *
    97  *      called from bottom of exit() to really delete the task.
    98  *      If we are using reentrant libc, then let the delete extension
    99  *      do all the work, otherwise if a shutdown is in progress,
    100  *      then just do it.
    101  *
    102  *  Parameters:
    103  *      exit status
    104  *
    105  *  Returns:
    106  *      does not return
    107  *
    108  *  Side Effects:
    109  *
    110  *  Notes:
    111  *
    112  *
    113  *  Deficiencies/ToDo:
    114  *
    115  *
    116  */
    117 
    118 #include <unistd.h>
    119 
    12045/* FIXME: These defines are a blatant hack */
    121   #define EXIT_SYMBOL _exit
    12246
    12347  #if defined(__USE_INIT_FINI__)
     
    13357  #endif
    13458
    135 void EXIT_SYMBOL(int status)
     59void _exit(int status)
    13660{
    13761  /*
     
    14367  #endif
    14468
    145   /*
    146    *  We need to do the exit processing on the global reentrancy structure.
    147    *  This has already been done on the per task reentrancy structure
    148    *  associated with this task.
    149    */
    150 
    15169  libc_wrapup();
    15270  rtems_shutdown_executive(status);
     
    15472}
    15573
    156 
    15774#endif
Note: See TracChangeset for help on using the changeset viewer.