# This program is free software; you can redistribute it and/or modify it
# under the terms of the license (GNU LGPL) which comes with this package.
import re
import glob
# This program is free software; you can redistribute it and/or modify it
# under the terms of the license (GNU LGPL) which comes with this package.
import re
import glob
print ('# ERROR: No function calling simcall_BODY_%s' % self.name)
print ('# Add something like this to libsmx.c:')
print ('%s simcall_%s(%s)' % (self.res.rettype(), self.name, ', '.
print ('# ERROR: No function calling simcall_BODY_%s' % self.name)
print ('# Add something like this to libsmx.c:')
print ('%s simcall_%s(%s)' % (self.res.rettype(), self.name, ', '.
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.rettype(), self.name, ''.
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.rettype(), self.name, ''.
res.append('static inline %s simcall_%s__get__%s(smx_simcall_t simcall)' % (
arg.rettype(), self.name, arg.name))
res.append('{')
res.append('static inline %s simcall_%s__get__%s(smx_simcall_t simcall)' % (
arg.rettype(), self.name, arg.name))
res.append('{')
res.append('}')
res.append('static inline %s simcall_%s__getraw__%s(smx_simcall_t simcall)' % (
rawtype, self.name, arg.name))
res.append('{')
res.append('}')
res.append('static inline %s simcall_%s__getraw__%s(smx_simcall_t simcall)' % (
rawtype, self.name, arg.name))
res.append('{')
res.append('}')
res.append('static inline void simcall_%s__set__%s(smx_simcall_t simcall, %s arg)' % (
self.name, arg.name, arg.rettype()))
res.append('{')
res.append('}')
res.append('static inline void simcall_%s__set__%s(smx_simcall_t simcall, %s arg)' % (
self.name, arg.name, arg.rettype()))
res.append('{')
res.append('}')
res.append(
'static inline void simcall_%s__set__result(smx_simcall_t simcall, %s result)' % (self.name, self.res.rettype()))
res.append('{')
res.append('}')
res.append(
'static inline void simcall_%s__set__result(smx_simcall_t simcall, %s result)' % (self.name, self.res.rettype()))
res.append('{')
- args = [ "simgrid::simix::unmarshal<%s>(simcall->args[%d])" % (arg.rettype(), i)
- for i, arg in enumerate(self.args) ]
- res.append('case SIMCALL_%s:' % (self.name.upper()))
+ indent = ' '
+ args = ["simgrid::simix::unmarshal<%s>(simcall.args_[%d])" % (arg.rettype(), i)
+ for i, arg in enumerate(self.args)]
+ res.append(indent + 'case SIMCALL_%s:' % (self.name.upper()))
- call = "simcall_HANDLER_%s(simcall%s%s)" % (self.name,
- ", " if len(args) > 0 else "",
- ', '.join(args))
+ call = "simcall_HANDLER_%s(&simcall%s%s)" % (self.name,
+ ", " if args else "",
+ ', '.join(args))
else:
call = "SIMIX_%s(%s)" % (self.name, ', '.join(args))
if self.call_kind == 'Func':
else:
call = "SIMIX_%s(%s)" % (self.name, ', '.join(args))
if self.call_kind == 'Func':
', '.join(["&SIMIX_process_self()->simcall"] + [arg.name for arg in self.args])))
else:
res.append(' SIMIX_%s(%s);' % (self.name,
', '.join(["&SIMIX_process_self()->simcall"] + [arg.name for arg in self.args])))
else:
res.append(' SIMIX_%s(%s);' % (self.name,
- "".join([ ", " + arg.rettype() for i, arg in enumerate(self.args) ]),
+ "".join([", " + arg.rettype() for i, arg in enumerate(self.args)]),
self.name,
''.join(', %s %s' % (arg.rettype(), arg.name)
for i, arg in enumerate(self.args)))
self.name,
''.join(', %s %s' % (arg.rettype(), arg.name)
for i, arg in enumerate(self.args)))
ret, name, args, attrs = match.groups()
sargs = []
if not re.match(r"^\s*$", args):
ret, name, args, attrs = match.groups()
sargs = []
if not re.match(r"^\s*$", args):
sim = Simcall(name, handler, Arg('result', ret), sargs, ans)
if resdi is None:
simcalls.append(sim)
sim = Simcall(name, handler, Arg('result', ret), sargs, ans)
if resdi is None:
simcalls.append(sim)
for guard, ll in guarded_simcalls.items():
fd.write('\n#if %s\n' % (guard))
fd.write('\n'.join(func(simcall) for simcall in ll))
for guard, ll in guarded_simcalls.items():
fd.write('\n#if %s\n' % (guard))
fd.write('\n'.join(func(simcall) for simcall in ll))
if __name__ == '__main__':
simcalls, simcalls_dict = parse('simcalls.in')
if __name__ == '__main__':
simcalls, simcalls_dict = parse('simcalls.in')
ok &= all(map(Simcall.check, simcalls))
for k, v in simcalls_dict.items():
ok &= all(map(Simcall.check, v))
ok &= all(map(Simcall.check, simcalls))
for k, v in simcalls_dict.items():
ok &= all(map(Simcall.check, v))
handle(fd, Simcall.accessors, simcalls, simcalls_dict)
fd.write(
handle(fd, Simcall.accessors, simcalls, simcalls_dict)
fd.write(
handle(fd, Simcall.handler_prototype, simcalls, simcalls_dict)
fd.close()
handle(fd, Simcall.handler_prototype, simcalls, simcalls_dict)
fd.close()
fd.write(' "SIMCALL_NONE",\n')
handle(fd, Simcall.string, simcalls, simcalls_dict)
fd.write(' "SIMCALL_NONE",\n')
handle(fd, Simcall.string, simcalls, simcalls_dict)
handle(fd, Simcall.case, simcalls, simcalls_dict)
fd.write(' case NUM_SIMCALLS:\n')
fd.write(' break;\n')
fd.write(' case SIMCALL_NONE:\n')
handle(fd, Simcall.case, simcalls, simcalls_dict)
fd.write(' case NUM_SIMCALLS:\n')
fd.write(' break;\n')
fd.write(' case SIMCALL_NONE:\n')
- fd.write(' THROWF(arg_error,0,"Asked to do the noop syscall on %s@%s",\n')
- fd.write(' simcall->issuer->name.c_str(),\n')
- fd.write(' sg_host_get_name(simcall->issuer->host)\n')
- fd.write(' );\n')
- fd.write(' break;\n')
+ fd.write(' throw std::invalid_argument(simgrid::xbt::string_printf("Asked to do the noop syscall on %s@%s",\n')
+ fd.write(' get_cname(),\n')
+ fd.write(' sg_host_get_name(get_host())));\n')
fd.write('#include "xbt/ex.h"\n')
fd.write('#include <functional>\n')
fd.write('#include <simgrid/simix.hpp>\n')
fd.write('#include "xbt/ex.h"\n')
fd.write('#include <functional>\n')
fd.write('#include <simgrid/simix.hpp>\n')
template<class R, class... T>
inline static R simcall(e_smx_simcall_t call, T const&... t)
{
smx_actor_t self = SIMIX_process_self();
simgrid::simix::marshal(&self->simcall, call, t...);
template<class R, class... T>
inline static R simcall(e_smx_simcall_t call, T const&... t)
{
smx_actor_t self = SIMIX_process_self();
simgrid::simix::marshal(&self->simcall, call, t...);
- if (self != simix_global->maestro_process) {
- XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name.c_str(),
- SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call);
- SIMIX_process_yield(self);
+ if (self != simix_global->maestro_) {
+ XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->get_cname(), SIMIX_simcall_name(self->simcall.call_),
+ (int)self->simcall.call_);
+ self->yield();
}
''')
handle(fd, Simcall.body, simcalls, simcalls_dict)
}
''')
handle(fd, Simcall.body, simcalls, simcalls_dict)