ctor.cc

来自「南京航空航天大学开发的一个类Unix和Linux的操作系统,好不好看看就知道了,」· CC 代码 · 共 31 行

CC
31
字号
#include <lib/root.h> #include "ctor.h"#if 1#define debug(...)#else#define debug(...) printf(__VA_ARGS__)#endiftypedef void (*ctor_t) ();ctor_t __ctorlist0106[MAXCTOR] __attribute__((section("data")));void doglobalctors(){	ctor_t * ctor = __ctorlist0106, * end = __ctorlist0106 + MAXCTOR;	if (*ctor != (ctor_t) 0x19790106)		panic("head magic not found, check collect\n");	debug("BEGIN DO GLOBAL CTORS\n");	int i = 0;	for (ctor++; ctor < end; i++, ctor++) {		if (*ctor == (ctor_t) 0x19790106) {			debug("END DO GLOBAL CTORS\n");			return;		}		debug("NO.%d %8lx\n", i, **ctor);		(**ctor)();	}	panic("trailing magic not found, check collect\n");}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?