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 */
wVersionRequested = MAKEWORD(2, 0);
int res;
res = WSAStartup(wVersionRequested, &wsaData);
- xbt_assert0(res == 0, "Cannot find a usable WinSock DLL");
+ 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");
XBT_INFO("Found and initialized winsock2");
WSADATA wsaData;
int res;
res = WSAStartup(0x0101, &wsaData);
- xbt_assert0(res == 0, "Cannot find a usable WinSock DLL");
+ xbt_assert(res == 0, "Cannot find a usable WinSock DLL");
XBT_INFO("Found and initialized winsock");
}
#endif
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;
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;
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;
}
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)
*/
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) */
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."
+ 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++) {
"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);
}
XBT_CDEBUG(gras_trp_meas,
"Sent %lu msgs of %lu (size of each: %ld) to %s:%d", sent_sofar,
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."
+ 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++) {
XBT_CDEBUG(gras_trp_meas,
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) {