kolibrios/programs/media/ac97snd/trunk/crt.c
heavyiron 3eda462807 Kernel: Smoothing image code from Mario79, build scripts for skin and drivers/build.bat
Programs: fasm updated to 1.67.14, small fixes in desktop, stackcfg, calc, board, pipes, freecell, big cleanup of unused programs, added some applications from 0.6.3.0 distr...

git-svn-id: svn://kolibrios.org@205 a494cfbc-eb01-0410-851d-a64ba20cac60
2006-11-02 14:18:23 +00:00

71 lines
1.1 KiB
C

#include "crt.h"
#define atexitBufferSize 32
char pureCallMessage[] = "PURE function call!";
char *__argv = 0;
void (__cdecl *atExitList[atexitBufferSize])();
int atExitFnNum = 0;
void exit()
{ int i;
for ( i = atExitFnNum - 1; i >= 0; i-- )
atExitList[i]();
__asm
{
mov eax, -1
int 0x40
};
};
int __cdecl atexit( void (__cdecl *func )( void ))
{
//
if ( atExitFnNum < atexitBufferSize )
{
//
atExitList[atExitFnNum++] = func;
return 0;
}
else
{
return 1;
}
}
int __cdecl _purecall()
{
exit();
return 0;
}
#pragma section(".CRT$XCA",long,read,write)
#pragma section(".CRT$XCZ",long,read,write)
typedef void (__cdecl *_PVFV)(void);
__declspec(allocate(".CRT$XCA")) _PVFV __xc_a[1] = { 0 };
__declspec(allocate(".CRT$XCZ")) _PVFV __xc_z[1] = { 0 };
//
#pragma comment(linker, "/merge:.CRT=.rdata")
//
void crtStartUp()
{_PVFV *pbegin;
_asm {fninit};
for ( pbegin = __xc_a; pbegin < __xc_z; pbegin++ )
{
//
if ( *pbegin != 0 )
(**pbegin)();
}
__argv = *((char **)0x1C);
main();
exit();
}