From: Martin Quinson Date: Sun, 2 Nov 2014 00:32:06 +0000 (+0100) Subject: [popping] cosmetics in doc and generator X-Git-Tag: v3_12~732^2~254 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/0efcfe60e36cdc4e20e4deebe3abb38d22842b49 [popping] cosmetics in doc and generator --- diff --git a/doc/doxygen/inside_extending.doc b/doc/doxygen/inside_extending.doc index 27d1acad8b..546a6c69ef 100644 --- a/doc/doxygen/inside_extending.doc +++ b/doc/doxygen/inside_extending.doc @@ -131,13 +131,14 @@ The workflow of a simcall is the following: - If not, call `SIMIX_process_yield` to give back the control to maestro - ========== KERNEL MODE ========== - `SIMIX_simcall_handle` large switch (on simcall) doing for each: - - `SIMIX_pre_(simcall, )` + - `simcall_HANDLER_(simcall, )` - `SIMIX_simcall_answer(simcall)` To simplify the simcall creation, a python script generates most of the code and give helpers for the remaining stuff. That script reads -the simcall definitions from src/simix/simcalls.in and generates the -following files: +the simcall definitions from src/simix/simcalls.in, checks that both +`simcall_()` and `simcall_HANDLER()` are defined somewhere, and +generates the following files: - smx_popping_accessors.h: Helper functions to get and set simcall arguments and results @@ -149,9 +150,6 @@ following files: Definitions of `simcall_names[]` (debug name of each simcall), and SIMIX_simcall_enter() that deals with the simcall from within the kernel -Furthermode if the simcall_ or the SIMIX_pre_ function are missing, -a warning will show up with a prototype of the corresponding fonction to fill. - The simcall.in file list all the simcalls in sections. A line starting by "##" define a new section which will be replace by a "ifdef" in the generated code. There is a simcall by line which follow this format: diff --git a/src/simix/simcalls.py b/src/simix/simcalls.py index 7adcb74767..354dddd1dc 100755 --- a/src/simix/simcalls.py +++ b/src/simix/simcalls.py @@ -55,12 +55,7 @@ class Simcall(object): self.has_answer = has_answer def check(self): - # smx_user.c simcall_BODY_ - # smx_*.c void simcall_HANDLER_host_on(smx_simcall_t simcall, smx_host_t h) - self.check_body() - self.check_pre() - - def check_body(self): + # libsmx.c simcall_BODY_ if self.simcalls_BODY is None: f = open('libsmx.c') self.simcalls_BODY = set(re.findall('simcall_BODY_(.*?)\(', f.read())) @@ -68,38 +63,30 @@ class Simcall(object): if self.name not in self.simcalls_BODY: print '# ERROR: No function calling simcall_BODY_%s'%self.name print '# Add something like this to libsmx.c:' - print '''%s simcall_%s(%s) -{ - return simcall_BODY_%s(%s); -}\n'''%(self.res.ret() - ,self.name - ,', '.join('%s %s'%(arg.ret(), arg.name) - for arg in self.args) - ,self.name - ,', '.join(arg.name for arg in self.args)) + print '%s simcall_%s(%s) {'%(self.res.ret() ,self.name ,', '.join('%s %s'%(arg.ret(), arg.name) for arg in self.args)) + print ' return simcall_BODY_%s(%s);'%(self.name) + print '}' + return False + + # smx_*.c void simcall_HANDLER_host_on(smx_simcall_t simcall, smx_host_t h) + if self.simcalls_PRE is None: + self.simcalls_PRE = set() + for fn in glob.glob('smx_*') + glob.glob('../mc/*'): + f = open(fn) + self.simcalls_PRE |= set(re.findall('simcall_HANDLER_(.*?)\(', f.read())) + f.close() + if self.name not in self.simcalls_PRE: + print '# ERROR: No function called simcall_HANDLER_%s'%self.name + print '# Add something like this to the relevant C file (like smx_io.c if it\'s an IO call):' + print '%s simcall_HANDLER_%s(smx_simcall_t simcall%s) {'%(self.res.ret() + ,self.name + ,''.join(', %s %s'%(arg.ret(), arg.name) + for arg in self.args)) + print ' // Your code handling the simcall' + print '}' return False return True - def check_pre(self): - if self.simcalls_PRE is None: - self.simcalls_PRE = set() - for fn in glob.glob('smx_*') + glob.glob('../mc/*'): - f = open(fn) - self.simcalls_PRE |= set(re.findall('simcall_HANDLER_(.*?)\(', f.read())) - f.close() - if self.name not in self.simcalls_PRE: - print '# ERROR: No function called simcall_HANDLER_%s'%self.name - print '# Add something like this to smx_.*.c:' - print '''%s simcall_HANDLER_%s(smx_simcall_t simcall%s) -{ - // Your code handling the simcall -}\n'''%(self.res.ret() - ,self.name - ,''.join(', %s %s'%(arg.ret(), arg.name) - for arg in self.args)) - return False - return True - def enum(self): return ' SIMCALL_%s,'%(self.name.upper())