gras_trp_plugin_t plug = xbt_new0(s_gras_trp_plugin_t, 1);
- DEBUG1("Create plugin %s", name);
+ XBT_DEBUG("Create plugin %s", name);
plug->name = xbt_strdup(name);
TRY {
setup(plug);
- } CATCH(e) {
+ }
+ CATCH(e) {
if (e.category == mismatch_error) {
/* SG plugin raise mismatch when in RL mode (and vice versa) */
free(plug->name);
}
if (plug)
- xbt_dict_set(_gras_trp_plugins, name, plug, gras_trp_plugin_free);
+ xbt_dict_set(_gras_trp_plugins, name, plug, NULL);
}
void gras_trp_init(void)
{
if (!_gras_trp_started) {
/* make room for all plugins */
- _gras_trp_plugins = xbt_dict_new();
+ _gras_trp_plugins = xbt_dict_new_homogeneous(gras_trp_plugin_free);
#ifdef HAVE_WINSOCK2_H
/* initialize the windows mechanism */
WSADATA wsaData;
wVersionRequested = MAKEWORD(2, 0);
- xbt_assert0(WSAStartup(wVersionRequested, &wsaData) == 0,
- "Cannot find a usable WinSock DLL");
+ int res;
+ res = WSAStartup(wVersionRequested, &wsaData);
+ xbt_assert(res == 0, "Cannot find a usable WinSock DLL");
/* Confirm that the WinSock DLL supports 2.0. */
/* Note that if the DLL supports versions greater */
/* 2.0 in wVersion since that is the version we */
/* requested. */
- xbt_assert0(LOBYTE(wsaData.wVersion) == 2 &&
+ xbt_assert(LOBYTE(wsaData.wVersion) == 2 &&
HIBYTE(wsaData.wVersion) == 0,
"Cannot find a usable WinSock DLL");
- INFO0("Found and initialized winsock2");
+ XBT_INFO("Found and initialized winsock2");
} /* The WinSock DLL is acceptable. Proceed. */
#elif HAVE_WINSOCK_H
{
WSADATA wsaData;
- xbt_assert0(WSAStartup(0x0101, &wsaData) == 0,
- "Cannot find a usable WinSock DLL");
- INFO0("Found and initialized winsock");
+ int res;
+ res = WSAStartup(0x0101, &wsaData);
+ xbt_assert(res == 0, "Cannot find a usable WinSock DLL");
+ XBT_INFO("Found and initialized winsock");
}
#endif
void gras_trp_exit(void)
{
- DEBUG1("gras_trp value %d", _gras_trp_started);
+ XBT_DEBUG("gras_trp value %d", _gras_trp_started);
if (_gras_trp_started == 0) {
return;
}
if (plug->exit) {
plug->exit(plug);
} else if (plug->data) {
- DEBUG1("Plugin %s lacks exit(). Free data anyway.", plug->name);
+ XBT_DEBUG("Plugin %s lacks exit(). Free data anyway.", plug->name);
free(plug->data);
}
gras_socket_t sock = xbt_new0(s_gras_socket_t, 1);
- VERB1("Create a new socket (%p)", (void *) sock);
+ XBT_VERB("Create a new socket (%p)", (void *) sock);
sock->plugin = NULL;
*dst = sock;
- XBT_OUT;
+ XBT_OUT();
}
/**
gras_socket_server_ext(unsigned short port,
unsigned long int buf_size, int measurement)
{
-
- xbt_ex_t e;
gras_trp_plugin_t trp;
gras_socket_t sock;
- DEBUG2("Create a server socket from plugin %s on port %d",
+ XBT_DEBUG("Create a server socket from plugin %s on port %d",
gras_if_RL()? "tcp" : "sg", port);
trp = gras_trp_plugin_get_by_name(gras_if_SG()? "sg" : "tcp");
sock->meas = measurement;
/* Call plugin socket creation function */
- DEBUG1("Prepare socket with plugin (fct=%p)", trp->socket_server);
+ XBT_DEBUG("Prepare socket with plugin (fct=%p)", trp->socket_server);
TRY {
trp->socket_server(trp, port, sock);
- DEBUG3("in=%c out=%c accept=%c",
+ XBT_DEBUG("in=%c out=%c accept=%c",
sock->incoming ? 'y' : 'n',
sock->outgoing ? 'y' : 'n', sock->accepting ? 'y' : 'n');
- } CATCH(e) {
-
+ }
+ CATCH_ANONYMOUS {
free(sock);
RETHROW;
}
unsigned short port,
unsigned long int buf_size, int measurement)
{
-
- xbt_ex_t e;
gras_trp_plugin_t trp;
gras_socket_t sock;
trp = gras_trp_plugin_get_by_name(gras_if_SG()? "sg" : "tcp");
- DEBUG1("Create a client socket from plugin %s",
+ XBT_DEBUG("Create a client socket from plugin %s",
gras_if_RL()? "tcp" : "sg");
/* defaults settings */
gras_trp_socket_new(0, &sock);
/* plugin-specific */
TRY {
(*trp->socket_client) (trp,host,port,sock);
- DEBUG3("in=%c out=%c accept=%c",
+ XBT_DEBUG("in=%c out=%c accept=%c",
sock->incoming ? 'y' : 'n',
sock->outgoing ? 'y' : 'n', sock->accepting ? 'y' : 'n');
- } CATCH(e) {
+ }
+ CATCH_ANONYMOUS {
free(sock);
RETHROW;
}
gras_socket_t sock_iter = NULL;
unsigned int cursor;
- XBT_IN;
- VERB1("Close %p", sock);
+ XBT_IN("");
+ XBT_VERB("Close %p", sock);
if (sock == _gras_lastly_selected_socket) {
- xbt_assert0(!gras_opt_trp_nomoredata_on_close || !sock->moredata,
+ xbt_assert(!gras_opt_trp_nomoredata_on_close || !sock->moredata,
"Closing a socket having more data in buffer while the nomoredata_on_close option is activated");
if (sock->moredata)
- CRITICAL0
+ XBT_CRITICAL
("Closing a socket having more data in buffer. Option nomoredata_on_close disabled, so continuing.");
_gras_lastly_selected_socket = NULL;
}
/* FIXME: Issue an event when the socket is closed */
- DEBUG1("sockets pointer before %p", sockets);
+ XBT_DEBUG("sockets pointer before %p", sockets);
if (sock) {
/* FIXME: Cannot get the dynar mutex, because it can be already locked */
// _xbt_dynar_foreach(sockets,cursor,sock_iter) {
for (cursor = 0; cursor < xbt_dynar_length(sockets); cursor++) {
_xbt_dynar_cursor_get(sockets, cursor, &sock_iter);
if (sock == sock_iter) {
- DEBUG2("remove sock cursor %d dize %lu\n", cursor,
+ XBT_DEBUG("remove sock cursor %d dize %lu\n", cursor,
xbt_dynar_length(sockets));
xbt_dynar_cursor_rm(sockets, &cursor);
if (sock->plugin->socket_close)
/* free the memory */
free(sock);
- XBT_OUT;
+ XBT_OUT();
return;
}
}
- WARN1
+ XBT_WARN
("Ignoring request to free an unknown socket (%p). Execution stack:",
sock);
xbt_backtrace_display_current();
}
- XBT_OUT;
+ XBT_OUT();
}
/**
*/
void gras_trp_send(gras_socket_t sd, char *data, long int size, int stable)
{
- xbt_assert0(sd->outgoing, "Socket not suited for data send");
- (*sd->plugin->send) (sd, data, size, stable);
+ xbt_assert(sd->outgoing, "Socket not suited for data send");
+ sd->plugin->send(sd, data, size, stable);
}
/**
*/
void gras_trp_recv(gras_socket_t sd, char *data, long int size)
{
- xbt_assert0(sd->incoming, "Socket not suited for data receive");
+ xbt_assert(sd->incoming, "Socket not suited for data receive");
(sd->plugin->recv) (sd, data, size);
}
int gras_socket_my_port(gras_socket_t sock)
{
if (!sock->plugin->my_port)
- THROW1(unknown_error,0,"Function my_port unimplemented in plugin %s",sock->plugin->name);
- return (*sock->plugin->my_port)(sock);
+ THROWF(unknown_error,0,"Function my_port unimplemented in plugin %s",sock->plugin->name);
+ return sock->plugin->my_port(sock);
}
int gras_socket_peer_port(gras_socket_t sock)
{
if (!sock->plugin->peer_port)
- THROW1(unknown_error,0,"Function peer_port unimplemented in plugin %s",sock->plugin->name);
- return (*sock->plugin->peer_port)(sock);
+ THROWF(unknown_error,0,"Function peer_port unimplemented in plugin %s",sock->plugin->name);
+ return sock->plugin->peer_port(sock);
}
const char *gras_socket_peer_name(gras_socket_t sock)
{
xbt_assert(sock->plugin);
- return (*sock->plugin->peer_name)(sock);
+ return sock->plugin->peer_name(sock);
}
const char *gras_socket_peer_proc(gras_socket_t sock)
{
- return (*sock->plugin->peer_proc)(sock);
+ return sock->plugin->peer_proc(sock);
}
void gras_socket_peer_proc_set(gras_socket_t sock, char *peer_proc)
{
- return (*sock->plugin->peer_proc_set)(sock,peer_proc);
+ return sock->plugin->peer_proc_set(sock,peer_proc);
}
/** \brief Check if the provided socket is a measurement one (or a regular one) */
char *chunk = NULL;
unsigned long int sent_sofar;
- XBT_IN;
- THROW0(unknown_error,0,"measurement sockets were broken in this release of SimGrid and should be ported back in the future."
+ XBT_IN("");
+ THROWF(unknown_error,0,"measurement sockets were broken in this release of SimGrid and should be ported back in the future."
"If you depend on it, sorry, you have to use an older version, or wait for the future version using it...");
if (gras_if_RL())
chunk = xbt_malloc0(msg_size);
- xbt_assert0(peer->meas,
+ xbt_assert(peer->meas,
"Asked to send measurement data on a regular socket");
- xbt_assert0(peer->outgoing,
+ xbt_assert(peer->outgoing,
"Socket not suited for data send (was created with gras_socket_server(), not gras_socket_client())");
for (sent_sofar = 0; sent_sofar < msg_amount; sent_sofar++) {
- CDEBUG5(gras_trp_meas,
+ XBT_CDEBUG(gras_trp_meas,
"Sent %lu msgs of %lu (size of each: %ld) to %s:%d",
sent_sofar, msg_amount, msg_size, gras_socket_peer_name(peer),
gras_socket_peer_port(peer));
- (*peer->plugin->raw_send) (peer, chunk, msg_size);
+ peer->plugin->raw_send(peer, chunk, msg_size);
}
- CDEBUG5(gras_trp_meas,
+ XBT_CDEBUG(gras_trp_meas,
"Sent %lu msgs of %lu (size of each: %ld) to %s:%d", sent_sofar,
msg_amount, msg_size, gras_socket_peer_name(peer),
gras_socket_peer_port(peer));
if (gras_if_RL())
free(chunk);
- XBT_OUT;
+ XBT_OUT();
}
/** \brief Receive a chunk of data over a measurement socket
char *chunk = NULL;
unsigned long int got_sofar;
- XBT_IN;
- THROW0(unknown_error,0,"measurement sockets were broken in this release of SimGrid and should be ported back in the future."
+ XBT_IN("");
+ THROWF(unknown_error,0,"measurement sockets were broken in this release of SimGrid and should be ported back in the future."
"If you depend on it, sorry, you have to use an older version, or wait for the future version using it...");
if (gras_if_RL())
chunk = xbt_malloc(msg_size);
- xbt_assert0(peer->meas,
+ xbt_assert(peer->meas,
"Asked to receive measurement data on a regular socket");
- xbt_assert0(peer->incoming, "Socket not suited for data receive");
+ xbt_assert(peer->incoming, "Socket not suited for data receive");
for (got_sofar = 0; got_sofar < msg_amount; got_sofar++) {
- CDEBUG5(gras_trp_meas,
+ XBT_CDEBUG(gras_trp_meas,
"Recvd %ld msgs of %lu (size of each: %ld) from %s:%d",
got_sofar, msg_amount, msg_size, gras_socket_peer_name(peer),
gras_socket_peer_port(peer));
(peer->plugin->raw_recv) (peer, chunk, msg_size);
}
- CDEBUG5(gras_trp_meas,
+ XBT_CDEBUG(gras_trp_meas,
"Recvd %ld msgs of %lu (size of each: %ld) from %s:%d",
got_sofar, msg_amount, msg_size, gras_socket_peer_name(peer),
gras_socket_peer_port(peer));
if (gras_if_RL())
free(chunk);
- XBT_OUT;
+ XBT_OUT();
}
/**
gras_socket_t gras_socket_meas_accept(gras_socket_t peer)
{
gras_socket_t res;
- THROW0(unknown_error,0,"measurement sockets were broken in this release of SimGrid and should be ported back in the future."
+ THROWF(unknown_error,0,"measurement sockets were broken in this release of SimGrid and should be ported back in the future."
"If you depend on it, sorry, you have to use an older version, or wait for the future version using it...");
- xbt_assert0(peer->meas,
+ xbt_assert(peer->meas,
"No need to accept on non-measurement sockets (it's automatic)");
if (!peer->accepting) {
res = (peer->plugin->socket_accept) (peer);
res->meas = peer->meas;
- CDEBUG1(gras_trp_meas, "meas_accepted onto %d", res->sd);
+ XBT_CDEBUG(gras_trp_meas, "meas_accepted onto %d", res->sd);
return res;
}
unsigned int it;
gras_socket_t s;
- INFO1("** Dump the socket set %s", name);
+ XBT_INFO("** Dump the socket set %s", name);
xbt_dynar_foreach(procdata->sockets, it, s) {
- INFO4(" %p -> %s:%d %s",
+ XBT_INFO(" %p -> %s:%d %s",
s, gras_socket_peer_name(s), gras_socket_peer_port(s),
s->valid ? "(valid)" : "(peer dead)");
}
- INFO1("** End of socket set %s", name);
+ XBT_INFO("** End of socket set %s", name);
}
/*