support.c
来自「Jazmyn is a 32-bit, protected mode, mult」· C语言 代码 · 共 44 行
C
44 行
/*
* Copyright (C) 2004, Thejesh AP. All rights reserved.
*/
#include <jazmyn\support.h>
#include <jazmyn\const.h>
void _main()
{
//_CTOR_LIST__ is defined in the linker script
extern void (*_CTOR_LIST__)();
//constructor is a list of pointers to constructors of global objects
void (**constructor)() = &_CTOR_LIST__;
int total = *(int*)constructor; //total number of global constructors
constructor++; //increment to first constructor
while(total)
{
void (*ptr)() = *constructor;
ptr();
total--;
constructor++;
}
}
void _atexit()
{
//_DTOR_LIST__ is defined in the linker script
extern void(*_DTOR_LIST__)();
//destructor is a list of pointers to destructors of global objects
void (**destructor)() = &_DTOR_LIST__;
int total = *(int*)destructor; //first dword contains number of destructors
destructor++;
while(total)
{
void (*ptr)() = *destructor;
ptr();
(*destructor)();
total--;
destructor++;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?