/* *Kernel : Linux2.6.32.63 *File : \scripts\mod\modpost.h \scripts\mod\modpost.c *Author : DavidLin *Date : 2014-12-25pm *Email : [email protected] or [email protected] *world : the city of SZ, in China *Ver : 000.000.001 *history : editor time do * 1)LinPeng 2014-12-25 created this file! * 2) */ /* modpost.h */ #define NOFAIL(ptr) do_nofail((ptr), #ptr) void* do_nofail (void* ptr, const char* expr); /* end of modpost.h */ /* modpost.c */ void* do_nofail(void* ptr, const char* expr) { if(!ptr) fatal("modpost: Memory allocation failure:%s.\n", expr); return ptr; } static struct module* new_module(char* modname) { struct module* mod; char *p, *s; mod = NOFAIL(malloc(sizeof(*mod))); memset(mod, 0, sizeof(*mod)); p = NOFAIL(strdup(modname)); /* strip trailing .o */ s = strrchr(p, ‘.‘); if(s != NULL) if(strcmp(s, ".o") == 0) *s = ‘\0‘; /* add to list */ mod->name = p; mod->gpl_compatible = -1; mod->next = modules; modules = mod; return mod; }
时间: 2024-10-06 12:56:09