#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# Copyright (c) 2014. The SimGrid Team. All rights reserved.
+# Copyright (c) 2014-2015. The SimGrid Team. All rights reserved.
# 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.
def check(self):
# libsmx.c simcall_BODY_
if self.simcalls_BODY is None:
- f = open('libsmx.c')
+ f = open('libsmx.cpp')
self.simcalls_BODY = set(re.findall('simcall_BODY_(.*?)\(', f.read()))
f.close()
if self.name not in self.simcalls_BODY:
return ' SIMCALL_%s,'%(self.name.upper())
def string(self):
- return ' [SIMCALL_%s] = "SIMCALL_%s",'%(self.name.upper(), self.name.upper())
+ return ' "SIMCALL_%s",'% self.name.upper()
def accessors(self):
res = []
''.join(', %s simcall->args[%d].%s'%(arg.cast(), i, arg.field())
for i, arg in enumerate(self.args))))
else:
- res.append(' %ssimcall_%s(%s);'%('simcall->result.%s = '%self.res.field() if self.call_kind == 'Func' else ' ',
+ res.append(' %sSIMIX_%s(%s);'%('simcall->result.%s = '%self.res.field() if self.call_kind == 'Func' else ' ',
self.name,
','.join('%s simcall->args[%d].%s'%(arg.cast(), i, arg.field())
for i, arg in enumerate(self.args))))
res.append(' if (0) simcall_HANDLER_%s(%s);'%(self.name,
', '.join(["&self->simcall"]+ [arg.name for arg in self.args])))
else:
- res.append(' if (0) simcall_%s(%s);'%(self.name,
+ res.append(' if (0) SIMIX_%s(%s);'%(self.name,
', '.join(arg.name for arg in self.args)))
res.append(' /* end of the guide intended to the poor programmer wanting to go from MSG to Surf */')
res.append('')
res.append(' SIMIX_simcall_handle(&self->simcall, 0);')
res.append(' } ')
if self.res.type != 'void':
- res.append(' return self->simcall.result.%s;'%self.res.field())
+ res.append(' return (%s) self->simcall.result.%s;' %
+ (self.res.rettype(), self.res.field()))
else:
res.append(' ')
res.append(' }')
def handler_prototype(self):
if self.need_handler:
- return "%s simcall_HANDLER_%s(smx_simcall_t simcall%s);"%(self.res.rettype() if self.call_kind == 'Func' else 'void',
+ return "XBT_PRIVATE %s simcall_HANDLER_%s(smx_simcall_t simcall%s);"%(self.res.rettype() if self.call_kind == 'Func' else 'void',
self.name,
''.join(', %s %s'%(arg.rettype(), arg.name)
for i, arg in enumerate(self.args)))
return fd
def handle(fd,func, simcalls, guarded_simcalls):
- fd.write('\n'.join(func(simcall) for simcall in simcalls))
+ def nonempty(e): return e != ''
+ fd.write('\n'.join( filter(nonempty, (func(simcall) for simcall in simcalls))))
+
for guard, list in guarded_simcalls.items():
fd.write('\n#ifdef %s\n'%(guard))
fd.write('\n'.join(func(simcall) for simcall in list))
fd.close()
###
- ### smx_popping_generated.c
+ ### smx_popping_generated.cpp
###
- fd = header("popping_generated.c")
+ fd = header("popping_generated.cpp")
+ fd.write('#include <xbt/base.h>\n');
fd.write('#include "smx_private.h"\n');
fd.write('#ifdef HAVE_MC\n');
- fd.write('#include "mc/mc_private.h"\n');
+ fd.write('#include "src/mc/mc_forward.h"\n');
fd.write('#endif\n');
fd.write('\n');
fd.write('XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_popping);\n\n');
fd.write('/** @brief Simcalls\' names (generated from src/simix/simcalls.in) */\n')
fd.write('const char* simcall_names[] = {\n')
+ fd.write(' "SIMCALL_NONE",');
handle(fd, Simcall.string, simcalls, simcalls_dict)
- fd.write('[SIMCALL_NONE] = "NONE"\n')
fd.write('};\n\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(' SIMIX_process_get_name(simcall->issuer),\n');
- fd.write(' SIMIX_host_get_name(SIMIX_process_get_host(simcall->issuer))\n');
+ fd.write(' sg_host_get_name(SIMIX_process_get_host(simcall->issuer))\n');
fd.write(' );\n');
fd.write(' break;\n');
fd.write('\n');
fd.close()
###
- ### smx_popping_bodies.c
+ ### smx_popping_bodies.cpp
###
- fd = header('popping_bodies.c')
+ fd = header('popping_bodies.cpp')
fd.write('#include "smx_private.h"\n')
- fd.write('#include "mc/mc_interface.h"\n')
+ fd.write('#include "src/mc/mc_forward.h"\n')
fd.write('#include "xbt/ex.h"\n')
+ fd.write('#include <simgrid/simix.hpp>\n')
handle(fd, Simcall.body, simcalls, simcalls_dict)
fd.close()