ReactOS 0.4.15-dev-7842-g558ab78
atonexit.c File Reference
#include <oscalls.h>
#include <internal.h>
#include <stdlib.h>
#include <crtdefs.h>
#include <limits.h>
Include dependency graph for atonexit.c:

Go to the source code of this file.

Macros

#define _DLL
 
#define _EXIT_LOCK1   8
 

Functions

void __cdecl _lock (int _File)
 
void __cdecl _unlock (int _File)
 
_onexit_t __cdecl __dllonexit (_onexit_t, _PVFV **, _PVFV **)
 
 _onexit_t (__cdecl *__MINGW_IMP_SYMBOL(_onexit))(_onexit_t func)
 
void __call_atexit (void)
 
_onexit_t __cdecl _onexit (_onexit_t func)
 
int __cdecl atexit (_PVFV func)
 

Variables

_PVFV__onexitbegin
 
_PVFV__onexitend
 

Macro Definition Documentation

◆ _DLL

#define _DLL

This file has no copyright assigned and is placed in the Public Domain. This file is part of the w64 mingw-runtime package. No warranty is given; refer to the file DISCLAIMER.PD within this package.

Definition at line 8 of file atonexit.c.

◆ _EXIT_LOCK1

#define _EXIT_LOCK1   8

Definition at line 18 of file atonexit.c.

Function Documentation

◆ __call_atexit()

void __call_atexit ( void  )

Definition at line 30 of file atonexit.c.

31{
32 /* Note: should only be called with the exit lock held */
33 _PVFV *first, *last;
34
35 if (!__onexitbegin)
36 return;
37
40
41 while (--last >= first)
42 if (*last)
43 (**last)();
44
45 free(first);
46
48}
_PVFV * __onexitend
Definition: atonexit.c:24
_PVFV * __onexitbegin
Definition: atonexit.c:23
#define free
Definition: debug_ros.c:5
#define NULL
Definition: types.h:112
const GLint * first
Definition: glext.h:5794
static UINT UINT last
Definition: font.c:45
void *__cdecl _decode_pointer(void *)
Definition: mingw_helpers.c:19
void(__cdecl * _PVFV)(void)
Definition: internal.h:33

Referenced by _cexit().

◆ __dllonexit()

_onexit_t __cdecl __dllonexit ( _onexit_t  ,
_PVFV **  ,
_PVFV **   
)

Referenced by _onexit().

◆ _lock()

void __cdecl _lock ( int  _File)

Definition at line 97 of file lock.c.

98{
99 TRACE( "(%d)\n", locknum );
100
101 /* If the lock doesn't exist yet, create it */
102 if( lock_table[ locknum ].bInit == FALSE )
103 {
104 /* Lock while we're changing the lock table */
106
107 /* Check again if we've got a bit of a race on lock creation */
108 if( lock_table[ locknum ].bInit == FALSE )
109 {
110 TRACE( ": creating lock #%d\n", locknum );
111 msvcrt_initialize_mlock( locknum );
112 }
113
114 /* Unlock ourselves */
116 }
117
118 EnterCriticalSection( &(lock_table[ locknum ].crit) );
119}
#define FALSE
Definition: types.h:117
#define _LOCKTAB_LOCK
Definition: mtdll.h:54
static __inline void msvcrt_initialize_mlock(int locknum)
Definition: lock.c:35
static LOCKTABLEENTRY lock_table[_TOTAL_LOCKS]
Definition: lock.c:28
void _unlock(int locknum)
Definition: lock.c:126
void _lock(int locknum)
Definition: lock.c:97
#define TRACE(s)
Definition: solgame.cpp:4
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)

Referenced by _lock(), _lock_file(), and _onexit().

◆ _onexit()

_onexit_t __cdecl _onexit ( _onexit_t  func)

Definition at line 53 of file atonexit.c.

54{
55 _PVFV *onexitbegin;
56 _PVFV *onexitend;
57 _onexit_t retval;
58
59#ifndef CRTDLL
60 if (__onexitbegin == (_PVFV *) -1)
61 return (* __MINGW_IMP_SYMBOL(_onexit)) (func);
62#endif
63
65
66 if (!__onexitbegin)
67 {
68 /* First time we are called. Initialize our array */
69 onexitbegin = calloc(1, sizeof(*onexitbegin));
70 if (!onexitbegin)
71 {
73 return NULL;
74 }
75 onexitend = onexitbegin;
76 }
77 else
78 {
79 onexitbegin = (_PVFV *) _decode_pointer (__onexitbegin);
80 onexitend = (_PVFV *) _decode_pointer (__onexitend);
81 }
82
83 retval = __dllonexit (func, &onexitbegin, &onexitend);
84
85 if (retval != NULL)
86 {
87 /* Update our globals in case of success */
88 __onexitbegin = (_PVFV *) _encode_pointer (onexitbegin);
89 __onexitend = (_PVFV *) _encode_pointer (onexitend);
90 }
91
93 return retval;
94}
#define __MINGW_IMP_SYMBOL(sym)
Definition: _mingw_mac.h:53
#define _EXIT_LOCK1
Definition: atonexit.c:18
void __cdecl _unlock(int _File)
Definition: lock.c:126
void __cdecl _lock(int _File)
Definition: lock.c:97
_onexit_t __cdecl __dllonexit(_onexit_t, _PVFV **, _PVFV **)
_onexit_t __cdecl _onexit(_onexit_t func)
Definition: atonexit.c:53
GLenum func
Definition: glext.h:6028
int(__cdecl * _onexit_t)(void)
Definition: stdlib.h:28
#define calloc
Definition: rosglue.h:14
void *__cdecl _encode_pointer(void *)
Definition: mingw_helpers.c:25

Referenced by _onexit(), and atexit().

◆ _onexit_t()

_onexit_t ( __cdecl __MINGW_IMP_SYMBOL_onexit)

◆ _unlock()

void __cdecl _unlock ( int  _File)

Definition at line 126 of file lock.c.

127{
128 TRACE( "(%d)\n", locknum );
129
130 LeaveCriticalSection( &(lock_table[ locknum ].crit) );
131}
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by _lock(), _onexit(), and _unlock_file().

◆ atexit()

int __cdecl atexit ( _PVFV  func)

Definition at line 97 of file atonexit.c.

98{
99 return (_onexit((_onexit_t)func) == NULL) ? -1 : 0;
100}

Referenced by main(), openlog(), Test_atexit(), and xmlInitParser().

Variable Documentation

◆ __onexitbegin

_PVFV* __onexitbegin

Definition at line 23 of file atonexit.c.

Referenced by __call_atexit(), and _onexit().

◆ __onexitend

_PVFV* __onexitend

Definition at line 24 of file atonexit.c.

Referenced by __call_atexit(), and _onexit().