result = strtol(string, &p, 10);
if (*p != '\0')
- THROW2(arg_error, 0,
+ THROWF(arg_error, 0,
"Error while converting %s: this does not seem to be a valid number (problem at '%s')",
string, p);
msg_size, 120); // sturation of the link with msg_size to compute a concurent bandwidth MA //MB
}
CATCH(e) {
- RETHROW0("Cannot ask hosts to saturate the link: %s");
+ RETHROWF("Cannot ask hosts to saturate the link: %s");
}
// gras_os_sleep(1.0);
0 /* no timeout */ );
}
CATCH(e) {
- RETHROW0("Cannot ask peers to saturate the link: %s");
+ RETHROWF("Cannot ask peers to saturate the link: %s");
}
gras_os_sleep(5);
CATCH(e) {
if (e.category != system_error)
/* dunno what happened, let the exception go through */
- RETHROW0("Unable to connect to the server: %s");
+ RETHROWF("Unable to connect to the server: %s");
xbt_ex_free(e);
gras_os_sleep(0.05);
}
}
CATCH(e) {
gras_socket_close(toserver);
- RETHROW0("Failed to send PING to server: %s");
+ RETHROWF("Failed to send PING to server: %s");
}
XBT_INFO(">>>>>>>> Message PING(%d) sent to %s:%d <<<<<<<<",
ping,
}
CATCH(e) {
gras_socket_close(toserver);
- RETHROW0("Why can't I get my PONG message like everyone else: %s");
+ RETHROWF("Why can't I get my PONG message like everyone else: %s");
}
/* 8. Keep the user informed of what's going on, again */
/* 6. Deal with errors: add some details to the exception */
} CATCH(e) {
gras_socket_close(globals->sock);
- RETHROW0("Unable answer with PONG: %s");
+ RETHROWF("Unable answer with PONG: %s");
}
XBT_INFO(">>>>>>>> Answered with PONG(4321) <<<<<<<<");
sock = gras_socket_server(port);
}
CATCH(e) {
- RETHROW0("Unable to establish a server socket: %s");
+ RETHROWF("Unable to establish a server socket: %s");
}
/* 4. Register the known messages and payloads. */
toserver = gras_socket_client(host, port);
}
CATCH(e) {
- RETHROW0("Unable to connect to the server: %s");
+ RETHROWF("Unable to connect to the server: %s");
}
XBT_INFO("Connected to %s:%d.", host, port);
}
CATCH(e) {
if (e.category != system_error)
- RETHROW0("Unable to connect to the server: %s");
+ RETHROWF("Unable to connect to the server: %s");
xbt_ex_free(e);
gras_os_sleep(0.05);
}
sock = gras_socket_server(port);
}
CATCH(e) {
- RETHROW0("Unable to establish a server socket: %s");
+ RETHROWF("Unable to establish a server socket: %s");
}
/* 4. Register the known messages and payloads. */
}
CATCH(e) {
gras_socket_close(globals->sock);
- RETHROW0("Unable to forward token: %s");
+ RETHROWF("Unable to forward token: %s");
}
}
TRY {
gras_msg_send(globals->tosuccessor, "stoken", &token);
} CATCH(e) {
- RETHROW0("Unable to send the freshly created token: %s");
+ RETHROWF("Unable to send the freshly created token: %s");
}
}
TRY {
temp_sock = gras_socket_client(host, port);
} CATCH(e) {
- RETHROW0("Unable to connect!: %s");
+ RETHROWF("Unable to connect!: %s");
}
TRY {
gras_msg_send(temp_sock, "can_get_suc", &msg);
} CATCH(e) {
- RETHROW0("Unable to send!: %s");
+ RETHROWF("Unable to send!: %s");
}
XBT_INFO("Forwarding a get_successor message to %s for (%d;%d)", host,
msg.xId, msg.yId);
temp_sock = gras_socket_client(incoming->host, incoming->port);
}
CATCH(e) {
- RETHROW0
+ RETHROWF
("Unable to connect to the node wich has requested for an area!: %s");
}
TRY {
XBT_INFO("Environment informations sent!");
}
CATCH(e) {
- RETHROW2("%s:Timeout sending environment informations to %s: %s",
+ RETHROWF("%s:Timeout sending environment informations to %s: %s",
globals->host, gras_socket_peer_name(expeditor));
}
gras_socket_close(temp_sock);
temp_sock = gras_socket_client(argv[4], atoi(argv[5]));
}
CATCH(e) {
- RETHROW0("Unable to connect known host to request for an area!: %s");
+ RETHROWF("Unable to connect known host to request for an area!: %s");
}
}
CATCH(e) {
gras_socket_close(temp_sock);
- RETHROW0("Unable to contact known host to get an area!: %s");
+ RETHROWF("Unable to contact known host to get an area!: %s");
}
gras_socket_close(temp_sock);
gras_msg_wait(6000, "can_rep_suc", &temp_sock2, &rep_suc_msg);
}
CATCH(e) {
- RETHROW1("%s: Error waiting for an area:%s", globals->host);
+ RETHROWF("%s: Error waiting for an area:%s", globals->host);
}
// retreiving the data of the response.
TRY { // contacting the bad guy that will launch the War.
temp_sock = gras_socket_client(gras_os_myname(), atoi(argv[1]));
} CATCH(e) {
- RETHROW0("Unable to connect known host so as to declare WAR!: %s");
+ RETHROWF("Unable to connect known host so as to declare WAR!: %s");
}
gras_msg_send(temp_sock, "can_nuke", &nuke_msg);
} CATCH(e) {
gras_socket_close(temp_sock);
- RETHROW0
+ RETHROWF
("Unable to contact known host so as to declare WAR!!!!!!!!!!!!!!!!!!!!!: %s");
}
gras_socket_close(temp_sock); // spare.
temp_sock = gras_socket_client(host, port);
}
CATCH(e) {
- RETHROW0("Unable to connect the nuke!: %s");
+ RETHROWF("Unable to connect the nuke!: %s");
}
//XBT_INFO("%s ON %s %d %d <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<",globals->host,host,xId,yId);
TRY {
gras_msg_send(temp_sock, "can_nuke", msg);
}
CATCH(e) {
- RETHROW0("Unable to send the nuke!: %s");
+ RETHROWF("Unable to send the nuke!: %s");
}
gras_socket_close(temp_sock);
XBT_INFO("Nuke launched by %s to %s for (%d;%d)", globals->host, host,
temp_sock = gras_socket_client(host, port);
}
CATCH(e) {
- RETHROW0("Unable to connect the nuke!: %s");
+ RETHROWF("Unable to connect the nuke!: %s");
}
TRY {
gras_msg_send(temp_sock, "can_nuke", incoming);
}
CATCH(e) {
- RETHROW0("Unable to send the nuke!: %s");
+ RETHROWF("Unable to send the nuke!: %s");
}
XBT_INFO("Nuke re-aimed by %s to %s for (%d;%d)", globals->host, host,
incoming->xId, incoming->yId);
globals->finger[contact].port);
}
CATCH(e) {
- RETHROW0("Unable to connect!: %s");
+ RETHROWF("Unable to connect!: %s");
}
TRY {
gras_msg_send(temp_sock, "chord_get_suc", &asking);
}
CATCH(e) {
- RETHROW0("Unable to ask!: %s");
+ RETHROWF("Unable to ask!: %s");
}
gras_msg_wait(10., "chord_rep_suc", &temp_sock, &outgoing);
}
XBT_INFO("Successor information sent!");
}
CATCH(e) {
- RETHROW2("%s:Timeout sending successor information to %s: %s",
+ RETHROWF("%s:Timeout sending successor information to %s: %s",
globals->host, gras_socket_peer_name(expeditor));
}
gras_socket_close(expeditor);
TRY {
temp_sock = gras_socket_client(globals->host, globals->port);
} CATCH(e) {
- RETHROW0("Unable to contact known host: %s");
+ RETHROWF("Unable to contact known host: %s");
}
get_suc_msg.id = globals->id;
gras_msg_send(temp_sock, "chord_get_suc", &get_suc_msg);
} CATCH(e) {
gras_socket_close(temp_sock);
- RETHROW0("Unable to contact known host to get successor!: %s");
+ RETHROWF("Unable to contact known host to get successor!: %s");
}
TRY {
XBT_INFO("Waiting for reply!");
gras_msg_wait(6000, "chord_rep_suc", &temp_sock2, &rep_suc_msg);
} CATCH(e) {
- RETHROW1("%s: Error waiting for successor:%s", globals->host);
+ RETHROWF("%s: Error waiting for successor:%s", globals->host);
}
globals->finger[0].id = rep_suc_msg.id;
snprintf(globals->finger[0].host, 1024, rep_suc_msg.host);
temp_sock = gras_socket_client(other_host, other_port);
}
CATCH(e) {
- RETHROW0("Unable to contact known host: %s");
+ RETHROWF("Unable to contact known host: %s");
}
get_suc_msg.id = globals->id;
}
CATCH(e) {
gras_socket_close(temp_sock);
- RETHROW0("Unable to contact known host to get successor!: %s");
+ RETHROWF("Unable to contact known host to get successor!: %s");
}
TRY {
gras_msg_wait(10., "chord_rep_suc", &temp_sock2, &rep_suc_msg);
}
CATCH(e) {
- RETHROW1("%s: Error waiting for successor:%s", globals->host);
+ RETHROWF("%s: Error waiting for successor:%s", globals->host);
}
globals->finger[0].id = rep_suc_msg.id;
snprintf(globals->finger[0].host, 1024, rep_suc_msg.host);
globals->finger[0].port);
}
CATCH(e) {
- RETHROW0("Unable to contact successor: %s");
+ RETHROWF("Unable to contact successor: %s");
}
notify_msg.id = globals->id;
gras_msg_send(temp_sock, "chord_notify", ¬ify_msg);
}
CATCH(e) {
- RETHROW0("Unable to notify successor! %s");
+ RETHROWF("Unable to notify successor! %s");
}
}
CATCH(e) {
if (e.category != system_error)
/* dunno what happened, let the exception go through */
- RETHROW0("Unable to connect to the server: %s");
+ RETHROWF("Unable to connect to the server: %s");
xbt_ex_free(e);
gras_os_sleep(0.05);
}
}
CATCH(e) {
gras_socket_close(toserver);
- RETHROW0("Failed to send PING to server: %s");
+ RETHROWF("Failed to send PING to server: %s");
}
XBT_INFO(">>>>>>>> Message PING(%d) sent to %s:%d <<<<<<<<",
ping, gras_socket_peer_name(toserver), gras_socket_peer_port(toserver));
}
CATCH(e) {
gras_socket_close(toserver);
- RETHROW0("Why can't I get my PONG message like everyone else: %s");
+ RETHROWF("Why can't I get my PONG message like everyone else: %s");
}
/* 8. Keep the user informed of what's going on, again */
/* 6. Deal with errors: add some details to the exception */
} CATCH(e) {
gras_socket_close(globals->sock);
- RETHROW0("Unable answer with PONG: %s");
+ RETHROWF("Unable answer with PONG: %s");
}
XBT_INFO(">>>>>>>> Answered with PONG(4321) <<<<<<<<");
gras_msg_wait(600, "dataB", &from, &bB);
}
CATCH(e) {
- RETHROW0("Can't get a data message from line : %s");
+ RETHROWF("Can't get a data message from line : %s");
}
XBT_VERB("LINE: step(%d) <> Myline(%d). Receive data from %s", step,
myline, gras_socket_peer_name(from));
gras_msg_wait(1200, "dataA", &from, &bA);
}
CATCH(e) {
- RETHROW0("Can't get a data message from row : %s");
+ RETHROWF("Can't get a data message from row : %s");
}
XBT_VERB("ROW: step(%d)<>myrow(%d). Receive data from %s", step, myrow,
gras_socket_peer_name(from));
gras_msg_send(master, "result", &result);
}
CATCH(e) {
- RETHROW0("Failed to send answer to server: %s");
+ RETHROWF("Failed to send answer to server: %s");
}
XBT_VERB(">>>>>>>> Result sent to %s:%d <<<<<<<<",
gras_socket_peer_name(master), gras_socket_peer_port(master));
}
CATCH(e) {
SIMIX_display_process_status();
- RETHROW2("Exception while waiting for %f bytes from %s: %s",
+ RETHROWF("Exception while waiting for %f bytes from %s: %s",
cmd->d_arg, cmd->str_arg);
}
xbt_workload_data_chunk_free(chunk);
int client(int argc, char *argv[]);
#define exception_msg "Error for the client"
-#define exception_raising() THROW0(unknown_error,42,exception_msg)
+#define exception_raising() THROWF(unknown_error,42,exception_msg)
static void exception_catching(void)
{
gotit = 1;
}
if (!gotit) {
- THROW0(unknown_error, 0, "Didn't got the remote exception!");
+ THROWF(unknown_error, 0, "Didn't got the remote exception!");
}
xbt_assert2(e.category == unknown_error,
"Got wrong category: %d (instead of %d)", e.category,
toforwarder = gras_socket_client(argv[3], atoi(argv[4]));
}
CATCH(e) {
- RETHROW0("Unable to connect to the server: %s");
+ RETHROWF("Unable to connect to the server: %s");
}
XBT_INFO("Connected to %s:%d.", host, port);
}
CATCH(e) {
gras_socket_close(toserver);
- RETHROW0("Failed to execute a PING rpc on the server: %s");
+ RETHROWF("Failed to execute a PING rpc on the server: %s");
}
exception_catching();
}
if (!gotit)
- THROW0(unknown_error, 0, "Didn't got the remote exception!");
+ THROWF(unknown_error, 0, "Didn't got the remote exception!");
XBT_INFO("Called the exception raising RPC");
exception_catching();
xbt_ex_free(e);
}
if (!gotit) {
- THROW0(unknown_error, 0, "Didn't got the remote exception!");
+ THROWF(unknown_error, 0, "Didn't got the remote exception!");
}
}
/* doxygen_resume */
gotit = 1;
}
if (!gotit) {
- THROW0(unknown_error, 0, "Didn't got the remote exception!");
+ THROWF(unknown_error, 0, "Didn't got the remote exception!");
}
xbt_assert1(e.value == 42, "Got wrong value: %d (!=42)", e.value);
xbt_assert1(!strncmp(e.msg, exception_msg, strlen(exception_msg)),
value = strtod(string, &endptr);
if (*endptr != '\0')
- THROW1(unknown_error, 0, "%s is not a double", string);
+ THROWF(unknown_error, 0, "%s is not a double", string);
return value;
}
#else
/** @brief The condition which failed will be displayed.
@hideinitializer */
-#define xbt_assert(cond) do { if (!(cond)) THROW1(0,0,"Assertion %s failed", #cond); } while (0)
+#define xbt_assert(cond) do { if (!(cond)) THROWF(0,0,"Assertion %s failed", #cond); } while (0)
/** @hideinitializer */
-#define xbt_assert0(cond,msg) do { if (!(cond)) THROW0(0,0,msg); } while (0)
+#define xbt_assert0(cond,msg) do { if (!(cond)) THROWF(0,0,msg); } while (0)
/** @hideinitializer */
-#define xbt_assert1(cond,msg,a) do { if (!(cond)) THROW1(0,0,msg,a); } while (0)
+#define xbt_assert1(cond,msg,a) do { if (!(cond)) THROWF(0,0,msg,a); } while (0)
/** @hideinitializer */
-#define xbt_assert2(cond,msg,a,b) do { if (!(cond)) THROW2(0,0,msg,a,b); } while (0)
+#define xbt_assert2(cond,msg,a,b) do { if (!(cond)) THROWF(0,0,msg,a,b); } while (0)
/** @hideinitializer */
-#define xbt_assert3(cond,msg,a,b,c) do { if (!(cond)) THROW3(0,0,msg,a,b,c); } while (0)
+#define xbt_assert3(cond,msg,a,b,c) do { if (!(cond)) THROWF(0,0,msg,a,b,c); } while (0)
/** @hideinitializer */
-#define xbt_assert4(cond,msg,a,b,c,d) do { if (!(cond)) THROW4(0,0,msg,a,b,c,d); } while (0)
+#define xbt_assert4(cond,msg,a,b,c,d) do { if (!(cond)) THROWF(0,0,msg,a,b,c,d); } while (0)
/** @hideinitializer */
-#define xbt_assert5(cond,msg,a,b,c,d,e) do { if (!(cond)) THROW5(0,0,msg,a,b,c,d,e); } while (0)
+#define xbt_assert5(cond,msg,a,b,c,d,e) do { if (!(cond)) THROWF(0,0,msg,a,b,c,d,e); } while (0)
/** @hideinitializer */
-#define xbt_assert6(cond,msg,a,b,c,d,e,f) do { if (!(cond)) THROW6(0,0,msg,a,b,c,d,e,f); } while (0)
+#define xbt_assert6(cond,msg,a,b,c,d,e,f) do { if (!(cond)) THROWF(0,0,msg,a,b,c,d,e,f); } while (0)
#endif
/** @} */
SG_END_DECL()
/** @brief Display a previously captured backtrace */
XBT_PUBLIC(void) xbt_backtrace_display(xbt_ex_t * e);
-#if 1 || defined(XBT_USE_DEPRECATED)
+#ifdef XBT_USE_DEPRECATED
/* Kept for backward compatibility. */
CATCH(e) {
measMasterIn = NULL;
if (port == 10000 - 1) {
- RETHROW0("Error caught while opening a measurement socket: %s");
+ RETHROWF("Error caught while opening a measurement socket: %s");
} else {
xbt_ex_free(e);
}
gras_msg_rpccall(peer, 15, "BW handshake", &request, &request_ack);
}
CATCH(e) {
- RETHROW0("Error encountered while sending the BW request: %s");
+ RETHROWF("Error encountered while sending the BW request: %s");
}
measIn = gras_socket_meas_accept(measMasterIn);
request->buf_size, 1);
}
CATCH(e) {
- RETHROW2
+ RETHROWF
("Error encountered while opening the measurement socket to %s:%d for BW test: %s",
gras_socket_peer_name(peer), request_ack->peer.port);
}
gras_socket_close(measOut);
gras_socket_close(measMasterIn);
gras_socket_close(measIn);
- RETHROW0("Unable to conduct the experiment: %s");
+ RETHROWF("Unable to conduct the experiment: %s");
}
*sec = gras_os_time() - *sec;
if (*sec != 0.0) {
xbt_ex_free(e);
else
/* FIXME: tell error to remote */
- RETHROW0
+ RETHROWF
("Error encountered while opening a measurement server socket: %s");
}
}
CATCH(e) {
gras_socket_close(measMasterIn);
/* FIXME: tell error to remote */
- RETHROW0("Error encountered while sending the answer: %s");
+ RETHROWF("Error encountered while sending the answer: %s");
}
request->buf_size, 1);
}
CATCH(e) {
- RETHROW2
+ RETHROWF
("Error encountered while opening a measurement socket back to %s:%d : %s",
gras_socket_peer_name(expeditor), request->peer.port);
/* FIXME: tell error to remote */
gras_socket_close(measIn);
gras_socket_close(measOut);
/* FIXME: tell error to remote ? */
- RETHROW0("Error encountered while opening the meas socket: %s");
+ RETHROWF("Error encountered while opening the meas socket: %s");
}
if (!msgtwaited) {
gras_socket_close(measIn);
gras_socket_close(measOut);
/* FIXME: tell error to remote ? */
- RETHROW0("Error encountered while receiving the experiment: %s");
+ RETHROWF("Error encountered while receiving the experiment: %s");
}
gras_msg_wait_or(60, msgtwaited, &ctx_reask, &msggot, &payload);
switch (msggot) {
if (port < 10000)
xbt_ex_free(e);
else
- RETHROW0
+ RETHROWF
("Error encountered while opening a measurement server socket: %s");
}
if (measMaster == NULL)
}
CATCH(e) {
gras_socket_close(measMaster);
- RETHROW0("Error during saturation handshake: %s");
+ RETHROWF("Error during saturation handshake: %s");
}
while (saturate_further) {
TRY {
gras_msg_rpccall(sock, 60, "amok_bw_sat stop", NULL, &answer);
} CATCH(e) {
- RETHROW2("Cannot ask %s:%d to stop saturation: %s", from_name,
+ RETHROWF("Cannot ask %s:%d to stop saturation: %s", from_name,
from_port);
}
gras_socket_close(sock);
RETHROW;
xbt_ex_free(e);
- THROW1(not_found_error, 1, "Asked to pop the non-existant %s", name);
+ THROWF(not_found_error, 1, "Asked to pop the non-existant %s", name);
}
xbt_dynar_pop(varstack, &var);
xbt_ex_free(e);
}
if (!found)
- THROW1(not_found_error, 0, "No registred datatype of that name: %s",
+ THROWF(not_found_error, 0, "No registred datatype of that name: %s",
name);
return res;
/* retrieve the field number */
gras_dd_recv_int(sock, r_arch, &field_num);
if (field_num < 0)
- THROW1(mismatch_error, 0,
+ THROWF(mismatch_error, 0,
"Received union field for %s is negative", type->name);
if (field_num > xbt_dynar_length(union_data.fields))
- THROW3(mismatch_error, 0,
+ THROWF(mismatch_error, 0,
"Received union field for %s is said to be #%d but there is only %lu fields",
type->name, field_num, xbt_dynar_length(union_data.fields));
if (count == -1)
gras_dd_recv_int(sock, r_arch, &count);
if (count == -1)
- THROW1(mismatch_error, 0,
+ THROWF(mismatch_error, 0,
"Invalid (=-1) array size for type %s", type->name);
/* receive the content */
gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump();
if (gras_ddt_parse_tok_num == GRAS_DDT_PARSE_TOKEN_RA) {
XBT_OUT();
- THROW0(mismatch_error, 0, "End of the englobing structure or union");
+ THROWF(mismatch_error, 0, "End of the englobing structure or union");
}
if (XBT_LOG_ISENABLED(gras_ddt_parse, xbt_log_priority_debug)) {
now = gras_os_time();
if (now - start + 0.001 > timeout) {
- THROW1(timeout_error, now - start + 0.001 - timeout,
+ THROWF(timeout_error, now - start + 0.001 - timeout,
"Timeout while waiting for msg '%s'",
msgt_want ? msgt_want->name : "(any)");
}
}
CATCH(e) {
if (e.category != timeout_error)
- RETHROW0("Error while waiting for messages: %s");
+ RETHROWF("Error while waiting for messages: %s");
xbt_ex_free(e);
}
/* Epsilon to avoid numerical stability issues were the waited interval is so small that the global clock cannot notice the increment */
XBT_WARN
("No timer elapsed, in contrary to expectations (next in %f sec)",
untiltimer);
- THROW1(timeout_error, 0,
+ THROWF(timeout_error, 0,
"No timer elapsed, in contrary to expectations (next in %f sec)",
untiltimer);
}
} else {
/* select timeouted, and no timer elapsed. Nothing to do */
- THROW1(timeout_error, 0, "No new message or timer (delay was %f)",
+ THROWF(timeout_error, 0, "No new message or timer (delay was %f)",
timeOut);
}
ctx.answer_due = 0;
ran_ok = 1;
} else {
- RETHROW4
+ RETHROWF
("Callback #%d (@%p) to message '%s' (payload size: %d) raised an exception: %s",
cpt + 1, cb, msg.type->name, msg.payl_size);
}
"AND IN SIMGRID (process wasn't killed by an assert)",
msg.type->name);
if (!ran_ok)
- THROW1(mismatch_error, 0,
+ THROWF(mismatch_error, 0,
"Message '%s' refused by all registered callbacks (maybe your callback misses a 'return 0' at the end)",
msg.type->name);
/* FIXME: gras_datadesc_free not implemented => leaking the payload */
return;
default:
- THROW1(unknown_error, 0,
+ THROWF(unknown_error, 0,
"Cannot handle messages of kind %d yet", msg.type->kind);
}
xbt_ex_free(e);
}
if (!found)
- THROW1(not_found_error, 0, "No registred message of that name: %s",
+ THROWF(not_found_error, 0, "No registred message of that name: %s",
name);
free(namev);
break;
default:
- THROW1(unknown_error, 0, "Unknown msg kind %d", kind);
+ THROWF(unknown_error, 0, "Unknown msg kind %d", kind);
}
gras_datadesc_send(sock, string_type, &msgtype->name);
msg->kind = (e_gras_msg_kind_t) c_kind;
}
CATCH(e) {
- RETHROW0
+ RETHROWF
("Exception caught while trying to get the message header: %s");
}
for (cpt = 0; cpt < 4; cpt++)
if (header[cpt] != _GRAS_header[cpt])
- THROW2(mismatch_error, 0,
+ THROWF(mismatch_error, 0,
"Incoming bytes do not look like a GRAS message (header='%s' not '%.4s')",
hexa_str((unsigned char *) header, 4, 0), _GRAS_header);
if (header[4] != _GRAS_header[4])
- THROW2(mismatch_error, 0, "GRAS protocol mismatch (got %d, use %d)",
+ THROWF(mismatch_error, 0, "GRAS protocol mismatch (got %d, use %d)",
(int) header[4], (int) _GRAS_header[4]);
r_arch = (int) header[5];
/* FIXME: Survive unknown messages */
if (e.category == not_found_error) {
xbt_ex_free(e);
- THROW1(not_found_error, 0,
+ THROWF(not_found_error, 0,
"Received an unknown message: %s (FIXME: should survive to these)",
msg_name);
} else
- RETHROW1
+ RETHROWF
("Exception caught while retrieving the type associated to messages '%s' : %s",
msg_name);
}
}
if (!found)
- THROW2(mismatch_error, 0,
+ THROWF(mismatch_error, 0,
"Cannot remove the action %p delayed of %f second: not found",
action, interval);
}
if (!found)
- THROW2(mismatch_error, 0,
+ THROWF(mismatch_error, 0,
"Cannot remove the action %p delayed of %f second: not found",
action, interval);
}
}
if (!found)
- THROW0(mismatch_error, 0, "No delayed action to remove");
+ THROWF(mismatch_error, 0, "No delayed action to remove");
}
}
if (!found)
- THROW0(mismatch_error, 0, "No repetitive action to remove");
+ THROWF(mismatch_error, 0, "No repetitive action to remove");
}
/** @brief Cancel all delayed and repetitive tasks */
XBT_DEBUG("wakeup=%f now=%f", wakeup, now);
if (now == -1 || now >= wakeup) {
/* didn't find anything; no need to update _gras_lastly_selected_socket since its moredata is 0 (or we would have returned it directly) */
- THROW1(timeout_error, 0,
+ THROWF(timeout_error, 0,
"Timeout (%f) elapsed with selecting for incomming connexions",
timeout);
}
if (timeout > 0) {
XBT_DEBUG("No socket to select onto. Sleep %f sec instead.", timeout);
gras_os_sleep(timeout);
- THROW1(timeout_error, 0,
+ THROWF(timeout_error, 0,
"No socket to select onto. Sleep %f sec instead", timeout);
} else {
XBT_DEBUG("No socket to select onto. Return directly.");
- THROW0(timeout_error, 0,
+ THROWF(timeout_error, 0,
"No socket to select onto. Return directly.");
}
}
/* if we cared, we would have set an handler */
continue;
case EINVAL: /* invalid value */
- THROW3(system_error, EINVAL,
+ THROWF(system_error, EINVAL,
"invalid select: nb fds: %d, timeout: %d.%d", max_fds,
(int) tout.tv_sec, (int) tout.tv_usec);
case ENOMEM:
xbt_die("Malloc error during the select");
default:
- THROW2(system_error, errno, "Error during select: %s (%d)",
+ THROWF(system_error, errno, "Error during select: %s (%d)",
strerror(errno), errno);
}
THROW_IMPOSSIBLE;
/* No socket found. Maybe we had timeout=0 and nothing to do */
XBT_DEBUG("TIMEOUT");
- THROW0(timeout_error, 0, "Timeout");
+ THROWF(timeout_error, 0, "Timeout");
}
void gras_trp_sg_setup(gras_trp_plugin_t plug)
{
- THROW0(mismatch_error, 0, "No SG transport on live platforms");
+ THROWF(mismatch_error, 0, "No SG transport on live platforms");
}
if (active_socket == NULL) {
XBT_DEBUG("TIMEOUT");
- THROW0(timeout_error, 0, "Timeout");
+ THROWF(timeout_error, 0, "Timeout");
}
active_socket_data = (gras_trp_sg_sock_data_t *) active_socket->data;
void gras_trp_tcp_setup(gras_trp_plugin_t plug)
{
- THROW0(mismatch_error, 0, NULL);
+ THROW(mismatch_error, 0);
}
void gras_trp_file_setup(gras_trp_plugin_t plug)
{
- THROW0(mismatch_error, 0, NULL);
+ THROW(mismatch_error, 0);
}
void gras_trp_iov_setup(gras_trp_plugin_t plug)
{
- THROW0(mismatch_error, 0, NULL);
+ THROW(mismatch_error, 0);
}
gras_socket_t gras_trp_buf_init_sock(gras_socket_t sock)
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);
+ 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);
+ THROWF(unknown_error,0,"Function peer_port unimplemented in plugin %s",sock->plugin->name);
return (*sock->plugin->peer_port)(sock);
}
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);
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())
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,
S_IRUSR | S_IWUSR | S_IRGRP);
if (res->sd < 0) {
- THROW2(system_error, 0,
+ THROWF(system_error, 0,
"Cannot create a client socket from file %s: %s",
path, strerror(errno));
}
res->sd = open(path, O_RDONLY | O_BINARY);
if (res->sd < 0) {
- THROW2(system_error, 0,
+ THROWF(system_error, 0,
"Cannot create a server socket from file %s: %s",
path, strerror(errno));
}
status = write(sock->sd, data, (long int) size);
if (status == -1) {
- THROW4(system_error, 0, "write(%d,%p,%d) failed: %s",
+ THROWF(system_error, 0, "write(%d,%p,%d) failed: %s",
sock->sd, data, (int) size, strerror(errno));
}
size -= status;
data += status;
} else {
- THROW0(system_error, 0, "file descriptor closed");
+ THROWF(system_error, 0, "file descriptor closed");
}
}
}
XBT_DEBUG("read(%d, %p, %ld);", sock->sd, data + got, size);
if (status < 0) {
- THROW4(system_error, 0, "read(%d,%p,%d) failed: %s",
+ THROWF(system_error, 0, "read(%d,%p,%d) failed: %s",
sock->sd, data + got, (int) size, strerror(errno));
}
size -= status;
got += status;
} else {
- THROW1(system_error, errno, "file descriptor closed after %d bytes",
+ THROWF(system_error, errno, "file descriptor closed after %d bytes",
got);
}
}
/* make sure this socket will reach someone */
if (!(peer = SIMIX_req_host_get_by_name(host)))
- THROW1(mismatch_error, 0,
+ THROWF(mismatch_error, 0,
"Can't connect to %s: no such host.\n", host);
if (!(hd = (gras_hostdata_t *) SIMIX_req_host_get_data(peer)))
- THROW1(mismatch_error, 0,
+ THROWF(mismatch_error, 0,
"can't connect to %s: no process on this host",
host);
pr = find_port(hd, port);
if (pr == NULL) {
- THROW2(mismatch_error, 0,
+ THROWF(mismatch_error, 0,
"can't connect to %s:%d, no process listen on this port",
host, port);
}
/* Ensure that the listener is expecting the kind of stuff we want to send */
if (pr->meas && !sock->meas) {
- THROW2(mismatch_error, 0,
+ THROWF(mismatch_error, 0,
"can't connect to %s:%d in regular mode, the process listen "
"in measurement mode on this port", host,
port);
}
if (!pr->meas && sock->meas) {
- THROW2(mismatch_error, 0,
+ THROWF(mismatch_error, 0,
"can't connect to %s:%d in measurement mode, the process listen "
"in regular mode on this port", host,
port);
pr = find_port(hd, port);
if (pr)
- THROW2(mismatch_error, 0,
+ THROWF(mismatch_error, 0,
"can't listen on address %s:%d: port already in use.",
SIMIX_host_self_get_name(), port);
&remote_socket, 60);
if (remote_socket == NULL) {
- THROW0(timeout_error, 0, "Timeout");
+ THROWF(timeout_error, 0, "Timeout");
}
remote_sock_data = (gras_trp_sg_sock_data_t *) remote_socket->data;
SIMIX_req_cond_wait(remote_sock_data->cond, remote_sock_data->mutex);
if (msg_got->payl_size != size)
- THROW5(mismatch_error, 0,
+ THROWF(mismatch_error, 0,
"Got %d bytes when %ld where expected (in %s->%s:%d)",
msg_got->payl_size, size,
SIMIX_req_host_get_name(sock_data->to_host),
sock->sd = socket(AF_INET, SOCK_STREAM, 0);
if (sock->sd < 0) {
- THROW1(system_error, 0, "Failed to create socket: %s",
+ THROWF(system_error, 0, "Failed to create socket: %s",
sock_errstr(sock_errno));
}
he = gethostbyname(sockdata->peer_name);
if (he == NULL) {
- THROW2(system_error, 0, "Failed to lookup hostname %s: %s",
+ THROWF(system_error, 0, "Failed to lookup hostname %s: %s",
sockdata->peer_name, sock_errstr(sock_errno));
}
if (connect(sock->sd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
tcp_close(sock->sd);
- THROW3(system_error, 0,
+ THROWF(system_error, 0,
"Failed to connect socket to %s:%d (%s)",
sockdata->peer_name, sockdata->peer_port, sock_errstr(sock_errno));
}
server.sin_addr.s_addr = INADDR_ANY;
server.sin_family = AF_INET;
if ((sock->sd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
- THROW1(system_error, 0, "Socket allocation failed: %s",
+ THROWF(system_error, 0, "Socket allocation failed: %s",
sock_errstr(sock_errno));
if (setsockopt
(sock->sd, SOL_SOCKET, SO_REUSEADDR, (char *) &on, sizeof(on)))
- THROW1(system_error, 0,
+ THROWF(system_error, 0,
"setsockopt failed, cannot condition the socket: %s",
sock_errstr(sock_errno));
if (bind(sock->sd, (struct sockaddr *) &server, sizeof(server)) == -1) {
tcp_close(sock->sd);
- THROW2(system_error, 0,
+ THROWF(system_error, 0,
"Cannot bind to port %d: %s", sockdata->port,
sock_errstr(sock_errno));
}
XBT_DEBUG("Listen on port %d (sd=%d)", sockdata->port, sock->sd);
if (listen(sock->sd, 5) < 0) {
tcp_close(sock->sd);
- THROW2(system_error, 0,
+ THROWF(system_error, 0,
"Cannot listen on port %d: %s",
sockdata->port, sock_errstr(sock_errno));
}
if (sd == -1) {
gras_socket_close(sock);
- THROW1(system_error, 0,
+ THROWF(system_error, 0,
"Accept failed (%s). Droping server socket.",
sock_errstr(tmp_errno));
}
if (setsockopt(sd, SOL_SOCKET, SO_KEEPALIVE, (char *) &i, s)
|| setsockopt(sd, _gras_tcp_proto_number(), TCP_NODELAY, (char *) &i,
s))
- THROW1(system_error, 0,
+ THROWF(system_error, 0,
"setsockopt failed, cannot condition the socket: %s",
sock_errstr(tmp_errno));
#endif
continue;
- THROW4(system_error, 0, "write(%d,%p,%ld) failed: %s",
+ THROWF(system_error, 0, "write(%d,%p,%ld) failed: %s",
sock->sd, data, size, sock_errstr(sock_errno));
}
size -= status;
data += status;
} else {
- THROW1(system_error, 0, "file descriptor closed (%s)",
+ THROWF(system_error, 0, "file descriptor closed (%s)",
sock_errstr(sock_errno));
}
}
status = tcp_read(sock->sd, data + got, (size_t) bufsize);
if (status < 0) {
- THROW7(system_error, 0,
+ THROWF(system_error, 0,
"read(%d,%p,%d) from %s:%d failed: %s; got %d so far",
sock->sd, data + got, (int) size, gras_socket_peer_name(sock),
gras_socket_peer_port(sock), sock_errstr(sock_errno), got);
bufsize -= status;
got += status;
} else {
- THROW1(system_error, errno,
+ THROWF(system_error, errno,
"Socket closed by remote side (got %d bytes before this)",
got);
}
res = xbt_set_get_by_name(pd->libdata, name);
}
CATCH(e) {
- RETHROW1("Cannot retrieve the libdata associated to %s: %s", name);
+ RETHROWF("Cannot retrieve the libdata associated to %s: %s", name);
}
return res;
}
found = 0;
}
if (found)
- THROW1(unknown_error, 0,
+ THROWF(unknown_error, 0,
"MayDay: two modules use '%s' as libdata name", fab.name);
/* Add the data in place, after some more sanity checking */
length = xbt_dynar_length(dynar);
if (src == dst)
- THROW1(arg_error, 0,
+ THROWF(arg_error, 0,
"Cannot add a dependency between task '%s' and itself",
SD_task_get_name(src));
if (!__SD_task_is_not_scheduled(src) && !__SD_task_is_schedulable(src)
&& !__SD_task_is_scheduled_or_runnable(src))
- THROW1(arg_error, 0,
+ THROWF(arg_error, 0,
"Task '%s' must be SD_NOT_SCHEDULED, SD_SCHEDULABLE, SD_SCHEDULED or SD_RUNNABLE",
SD_task_get_name(src));
if (!__SD_task_is_not_scheduled(dst) && !__SD_task_is_schedulable(dst)
&& !__SD_task_is_scheduled_or_runnable(dst))
- THROW1(arg_error, 0,
+ THROWF(arg_error, 0,
"Task '%s' must be SD_NOT_SCHEDULED, SD_SCHEDULABLE, SD_SCHEDULED or SD_RUNNABLE",
SD_task_get_name(dst));
}
if (found)
- THROW2(arg_error, 0,
+ THROWF(arg_error, 0,
"A dependency already exists between task '%s' and task '%s'",
SD_task_get_name(src), SD_task_get_name(dst));
}
}
if (!found)
- THROW4(arg_error, 0,
+ THROWF(arg_error, 0,
"No dependency found between task '%s' and '%s': task '%s' is not a successor of task '%s'",
SD_task_get_name(src), SD_task_get_name(dst),
SD_task_get_name(dst), SD_task_get_name(src));
found = (dependency->dst == dst);
}
if (!found)
- THROW2(arg_error, 0, "No dependency found between task '%s' and '%s'",
+ THROWF(arg_error, 0, "No dependency found between task '%s' and '%s'",
SD_task_get_name(src), SD_task_get_name(dst));
return dependency->data;
}
xbt_assert0(task != NULL, "Invalid parameter");
if (state & SD_NOT_SCHEDULED)
- THROW0(arg_error, 0,
+ THROWF(arg_error, 0,
"Cannot add a watch point for state SD_NOT_SCHEDULED");
task->watch_points = task->watch_points | state;
SD_CHECK_INIT_DONE();
if (!__SD_task_is_not_scheduled(task) && !__SD_task_is_schedulable(task))
- THROW1(arg_error, 0, "Task '%s' has already been scheduled",
+ THROWF(arg_error, 0, "Task '%s' has already been scheduled",
SD_task_get_name(task));
/* update the task state */
task->state_set != sd_global->runnable_task_set &&
task->state_set != sd_global->running_task_set &&
task->state_set != sd_global->failed_task_set)
- THROW1(arg_error, 0,
+ THROWF(arg_error, 0,
"Task %s: the state must be SD_SCHEDULED, SD_RUNNABLE, SD_RUNNING or SD_FAILED",
SD_task_get_name(task));
SD_CHECK_INIT_DONE();
if (!__SD_task_is_scheduled_or_runnable(task)
&& !__SD_task_is_in_fifo(task))
- THROW1(arg_error, 0,
+ THROWF(arg_error, 0,
"Task '%s' must be SD_SCHEDULED, SD_RUNNABLE or SD_IN_FIFO",
SD_task_get_name(task));
if (nb_threads > 1) {
#ifndef CONTEXT_THREADS
- THROW0(arg_error, 0, "No thread support for parallel context execution");
+ THROWF(arg_error, 0, "No thread support for parallel context execution");
#endif
}
(*factory)->self = smx_ctx_sysv_self_parallel;
(*factory)->get_thread_id = smx_ctx_sysv_get_thread_id;
#else
- THROW0(arg_error, 0, "No thread support for parallel context execution");
+ THROWF(arg_error, 0, "No thread support for parallel context execution");
#endif
}else{
(*factory)->runall = smx_ctx_sysv_runall;
msg = tmp;
}
SIMIX_display_process_status();
- THROW1(arg_error, 0, "%s", msg);
+ THROWF(arg_error, 0, "%s", msg);
}
xbt_swag_free(host->process_list);
case SIMIX_FAILED:
TRY {
XBT_DEBUG("SIMIX_execution_finished: host '%s' failed", req->issuer->smx_host->name);
- THROW0(host_error, 0, "Host failed");
+ THROWF(host_error, 0, "Host failed");
}
CATCH(req->issuer->running_ctx->exception) {
req->issuer->doexception = 1;
case SIMIX_CANCELED:
TRY {
XBT_DEBUG("SIMIX_execution_finished: execution canceled");
- THROW0(cancel_error, 0, "Canceled");
+ THROWF(cancel_error, 0, "Canceled");
}
CATCH(req->issuer->running_ctx->exception) {
req->issuer->doexception = 1;
case SIMIX_SRC_TIMEOUT:
TRY {
- THROW0(timeout_error, 0, "Communication timeouted because of sender");
+ THROWF(timeout_error, 0, "Communication timeouted because of sender");
}
CATCH(req->issuer->running_ctx->exception) {
req->issuer->doexception = 1;
case SIMIX_DST_TIMEOUT:
TRY {
- THROW0(timeout_error, 0, "Communication timeouted because of receiver");
+ THROWF(timeout_error, 0, "Communication timeouted because of receiver");
}
CATCH(req->issuer->running_ctx->exception) {
req->issuer->doexception = 1;
case SIMIX_SRC_HOST_FAILURE:
TRY {
if (req->issuer == action->comm.src_proc)
- THROW0(host_error, 0, "Host failed");
+ THROWF(host_error, 0, "Host failed");
else
- THROW0(network_error, 0, "Remote peer failed");
+ THROWF(network_error, 0, "Remote peer failed");
}
CATCH(req->issuer->running_ctx->exception) {
req->issuer->doexception = 1;
case SIMIX_DST_HOST_FAILURE:
TRY {
if (req->issuer == action->comm.dst_proc)
- THROW0(host_error, 0, "Host failed");
+ THROWF(host_error, 0, "Host failed");
else
- THROW0(network_error, 0, "Remote peer failed");
+ THROWF(network_error, 0, "Remote peer failed");
}
CATCH(req->issuer->running_ctx->exception) {
req->issuer->doexception = 1;
XBT_DEBUG("Link failure in action %p between '%s' and '%s': posting an exception to the issuer: %s (%p)",
action, action->comm.src_proc->smx_host->name, action->comm.dst_proc->smx_host->name,
req->issuer->name, req->issuer);
- THROW0(network_error, 0, "Link failure");
+ THROWF(network_error, 0, "Link failure");
}
CATCH(req->issuer->running_ctx->exception) {
req->issuer->doexception = 1;
/* check if the host is active */
if (surf_workstation_model->extension.
workstation.get_state(host->host) != SURF_RESOURCE_ON) {
- THROW1(host_error, 0, "Host %s failed, you cannot call this function",
+ THROWF(host_error, 0, "Host %s failed, you cannot call this function",
host->name);
}
break;
case REQ_NO_REQ:
- THROW2(arg_error,0,"Asked to do the noop syscall on %s@%s",
+ THROWF(arg_error,0,"Asked to do the noop syscall on %s@%s",
SIMIX_process_get_name(req->issuer),
SIMIX_host_get_name(SIMIX_process_get_host(req->issuer))
);
case SIMIX_SRC_TIMEOUT:
TRY {
- THROW0(timeout_error, 0, "Synchro's wait timeout");
+ THROWF(timeout_error, 0, "Synchro's wait timeout");
} CATCH(req->issuer->running_ctx->exception) {
req->issuer->doexception = 1;
}
case SIMIX_FAILED:
TRY {
- THROW0(host_error, 0, "Host failed");
+ THROWF(host_error, 0, "Host failed");
} CATCH(req->issuer->running_ctx->exception) {
req->issuer->doexception = 1;
}
/* Check user stupidities */
if (max < min)
- THROW2(arg_error, 0, "random->max < random->min (%f < %f)", max, min);
+ THROWF(arg_error, 0, "random->max < random->min (%f < %f)", max, min);
if (mean < min)
- THROW2(arg_error, 0, "random->mean < random->min (%f < %f)", mean,
+ THROWF(arg_error, 0, "random->mean < random->min (%f < %f)", mean,
min);
if (mean > max)
- THROW2(arg_error, 0, "random->mean > random->max (%f > %f)", mean,
+ THROWF(arg_error, 0, "random->mean > random->max (%f > %f)", mean,
max);
/* normalize the mean and standard deviation before storing */
random->std = std / (max - min);
if (random->mean * (1 - random->mean) < random->std * random->std)
- THROW2(arg_error, 0, "Invalid mean and standard deviation (%f and %f)",
+ THROWF(arg_error, 0, "Invalid mean and standard deviation (%f and %f)",
random->mean, random->std);
return random;
static void parse_S_route_new_and_endpoints(const char *src_id, const char *dst_id)
{
if (src != NULL && dst != NULL && link_list != NULL)
- THROW2(arg_error, 0, "Route between %s to %s can not be defined",
+ THROWF(arg_error, 0, "Route between %s to %s can not be defined",
src_id, dst_id);
src = src_id;
dst = dst_id;
static void parse_S_ASroute_new_and_endpoints(void)
{
if (src != NULL && dst != NULL && link_list != NULL)
- THROW2(arg_error, 0, "Route between %s to %s can not be defined",
+ THROWF(arg_error, 0, "Route between %s to %s can not be defined",
A_surfxml_ASroute_src, A_surfxml_ASroute_dst);
src = A_surfxml_ASroute_src;
dst = A_surfxml_ASroute_dst;
static void parse_S_bypassRoute_new_and_endpoints(void)
{
if (src != NULL && dst != NULL && link_list != NULL)
- THROW2(arg_error, 0,
+ THROWF(arg_error, 0,
"Bypass Route between %s to %s can not be defined",
A_surfxml_bypassRoute_src, A_surfxml_bypassRoute_dst);
src = A_surfxml_bypassRoute_src;
(*(current_routing->routing->unload)) ();
} else {
- THROW0(arg_error, 0, "All defined components must be belong to a AS");
+ THROWF(arg_error, 0, "All defined components must be belong to a AS");
}
/* set the new parse rules */
(*(new_routing->routing->load)) ();
{
if (current_routing == NULL) {
- THROW1(arg_error, 0, "Close AS(%s), that never open", AS_id);
+ THROWF(arg_error, 0, "Close AS(%s), that never open", AS_id);
} else {
network_element_info_t info = NULL;
xbt_assert1(!xbt_lib_get_or_null(as_router_lib,current_routing->name, ROUTING_ASR_LEVEL),
if (link)
xbt_dynar_push(links_list, &link);
else
- THROW1(mismatch_error, 0, "Link %s not found", new_link_name);
+ THROWF(mismatch_error, 0, "Link %s not found", new_link_name);
xbt_free(new_link_name);
}
}
else
xbt_dynar_unshift(links_id, &link);
} else
- THROW1(mismatch_error, 0, "Link %s not found", link_name);
+ THROWF(mismatch_error, 0, "Link %s not found", link_name);
}
return new_route;
else
xbt_dynar_unshift(links_id, &link);
} else
- THROW1(mismatch_error, 0, "Link %s not found", link_name);
+ THROWF(mismatch_error, 0, "Link %s not found", link_name);
}
return new_e_route;
/* Check user stupidities */
if (max < min)
- THROW2(arg_error, 0, "random->max < random->min (%f < %f)", max, min);
+ THROWF(arg_error, 0, "random->max < random->min (%f < %f)", max, min);
if (mean < min)
- THROW2(arg_error, 0, "random->mean < random->min (%f < %f)", mean,
+ THROWF(arg_error, 0, "random->mean < random->min (%f < %f)", mean,
min);
if (mean > max)
- THROW2(arg_error, 0, "random->mean > random->max (%f > %f)", mean,
+ THROWF(arg_error, 0, "random->mean > random->max (%f > %f)", mean,
max);
/* normalize the mean and standard deviation before storing */
random->std = std / (max - min);
if (random->mean * (1 - random->mean) < random->std * random->std)
- THROW2(arg_error, 0, "Invalid mean and standard deviation (%f and %f)",
+ THROWF(arg_error, 0, "Invalid mean and standard deviation (%f and %f)",
random->mean, random->std);
XBT_DEBUG("id = '%s' min = '%f' max = '%f' mean = '%f' std_deviatinon = '%f' generator = '%d' seed = '%ld' radical = '%s'",
XBT_DEBUG("Looking for symbol %d, addr = '%s'", i, addrs[i]);
fgets_res = fgets(line_func, 1024, pipe);
if (fgets_res == NULL)
- THROW2(system_error, 0,
+ THROWF(system_error, 0,
"Cannot run fgets to look for symbol %d, addr %s", i,
addrs[i]);
line_func[strlen(line_func) - 1] = '\0';
fgets_res = fgets(line_pos, 1024, pipe);
if (fgets_res == NULL)
- THROW2(system_error, 0,
+ THROWF(system_error, 0,
"Cannot run fgets to look for symbol %d, addr %s", i,
addrs[i]);
line_pos[strlen(line_pos) - 1] = '\0';
}
fgets_res = fgets(line_func, 1024, subpipe);
if (fgets_res == NULL)
- THROW1(system_error, 0, "Cannot read result of subcommand %s",
+ THROWF(system_error, 0, "Cannot read result of subcommand %s",
subcmd);
line_func[strlen(line_func) - 1] = '\0';
fgets_res = fgets(line_pos, 1024, subpipe);
if (fgets_res == NULL)
- THROW1(system_error, 0, "Cannot read result of subcommand %s",
+ THROWF(system_error, 0, "Cannot read result of subcommand %s",
subcmd);
line_pos[strlen(line_pos) - 1] = '\0';
pclose(subpipe);
size = xbt_dynar_length(variable->content);
if (variable->min > size) {
xbt_dict_cursor_free(&cursor);
- THROW4(mismatch_error, 0,
+ THROWF(mismatch_error, 0,
"Config elem %s needs at least %d %s, but there is only %d values.",
name, variable->min, xbt_cfgelm_type_name[variable->type],
size);
if (variable->max > 0 && variable->max < size) {
xbt_dict_cursor_free(&cursor);
- THROW4(mismatch_error, 0,
+ THROWF(mismatch_error, 0,
"Config elem %s accepts at most %d %s, but there is %d values.",
name, variable->max, xbt_cfgelm_type_name[variable->type],
size);
res = xbt_dict_get_or_null((xbt_dict_t) cfg, name);
if (!res) {
xbt_cfg_help(cfg);
- THROW1(not_found_error, 0,
+ THROWF(not_found_error, 0,
"No registered variable '%s' in this config set", name);
}
variable = xbt_dict_get_or_null((xbt_dict_t) cfg, name);
if (!variable)
- THROW1(not_found_error, 0,
+ THROWF(not_found_error, 0,
"Can't get the type of '%s' since this variable does not exist",
name);
} CATCH(e) {
if (e.category == not_found_error) {
xbt_ex_free(e);
- THROW1(not_found_error, 0,
+ THROWF(not_found_error, 0,
"Can't set the property '%s' since it's not registered",
name);
}
free(optionlist_cpy);
if (e.category == not_found_error) {
xbt_ex_free(e);
- THROW1(not_found_error, 0,
+ THROWF(not_found_error, 0,
"No registered variable corresponding to '%s'.", name);
}
RETHROW;
break;
default:
- THROW1(unknown_error, 0, "Type of config element %s is not valid.",
+ THROWF(unknown_error, 0, "Type of config element %s is not valid.",
name);
}
}
if (variable->max
&& xbt_dynar_length(variable->content) ==
(unsigned long) variable->max)
- THROW3(mismatch_error, 0,
+ THROWF(mismatch_error, 0,
"Cannot add value %d to the config element %s since it's already full (size=%d)",
val, name, variable->max);
} else {
if (variable->max
&& xbt_dynar_length(variable->content) == variable->max)
- THROW3(mismatch_error, 0,
+ THROWF(mismatch_error, 0,
"Cannot add value %f to the config element %s since it's already full (size=%d)",
val, name, variable->max);
} else {
if (variable->max
&& xbt_dynar_length(variable->content) == variable->max)
- THROW3(mismatch_error, 0,
+ THROWF(mismatch_error, 0,
"Cannot add value %s to the config element %s since it's already full (size=%d)",
name, val, variable->max);
} else {
if (variable->max
&& xbt_dynar_length(variable->content) == variable->max)
- THROW4(mismatch_error, 0,
+ THROWF(mismatch_error, 0,
"Cannot add value %s:%d to the config element %s since it's already full (size=%d)",
peer, port, name, variable->max);
variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_int);
if (xbt_dynar_length(variable->content) == variable->min)
- THROW3(mismatch_error, 0,
+ THROWF(mismatch_error, 0,
"Cannot remove value %d from the config element %s since it's already at its minimal size (=%d)",
val, name, variable->min);
}
}
- THROW2(not_found_error, 0,
+ THROWF(not_found_error, 0,
"Can't remove the value %d of config element %s: value not found.",
val, name);
}
variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_double);
if (xbt_dynar_length(variable->content) == variable->min)
- THROW3(mismatch_error, 0,
+ THROWF(mismatch_error, 0,
"Cannot remove value %f from the config element %s since it's already at its minimal size (=%d)",
val, name, variable->min);
}
}
- THROW2(not_found_error, 0,
+ THROWF(not_found_error, 0,
"Can't remove the value %f of config element %s: value not found.",
val, name);
}
variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_string);
if (xbt_dynar_length(variable->content) == variable->min)
- THROW3(mismatch_error, 0,
+ THROWF(mismatch_error, 0,
"Cannot remove value %s from the config element %s since it's already at its minimal size (=%d)",
name, val, variable->min);
}
}
- THROW2(not_found_error, 0,
+ THROWF(not_found_error, 0,
"Can't remove the value %s of config element %s: value not found.",
val, name);
}
variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_peer);
if (xbt_dynar_length(variable->content) == variable->min)
- THROW4(mismatch_error, 0,
+ THROWF(mismatch_error, 0,
"Cannot remove value %s:%d from the config element %s since it's already at its minimal size (=%d)",
peer, port, name, variable->min);
}
}
- THROW3(not_found_error, 0,
+ THROWF(not_found_error, 0,
"Can't remove the value %s:%d of config element %s: value not found.",
peer, port, name);
}
variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_any);
if (xbt_dynar_length(variable->content) == variable->min)
- THROW3(mismatch_error, 0,
+ THROWF(mismatch_error, 0,
"Cannot remove %dth value from the config element %s since it's already at its minimal size (=%d)",
pos, name, variable->min);
RETHROW;
xbt_ex_free(e);
- THROW1(not_found_error, 0,
+ THROWF(not_found_error, 0,
"Can't empty '%s' since this config element does not exist",
name);
}
} CATCH(e) {
if (e.category == not_found_error) {
xbt_ex_free(e);
- THROW1(not_found_error, 0,
+ THROWF(not_found_error, 0,
"No registered variable %s in this config set", name);
}
RETHROW;
}
if (current == NULL)
- THROW2(not_found_error, 0, "key %.*s not found", key_len, key);
+ THROWF(not_found_error, 0, "key %.*s not found", key_len, key);
return current->content;
}
current = current->next;
if (current == NULL)
- THROW1(not_found_error, 0, "key %s not found", key);
+ THROWF(not_found_error, 0, "key %s not found", key);
return current->content;
}
}
if (current == NULL)
- THROW2(not_found_error, 0, "key %.*s not found", key_len, key);
+ THROWF(not_found_error, 0, "key %.*s not found", key_len, key);
if (previous != NULL) {
previous->next = current->next;
}
if (current == NULL)
- THROW1(not_found_error, 0, "key %zu not found", key);
+ THROWF(not_found_error, 0, "key %zu not found", key);
if (previous != NULL) {
previous->next = current->next;
TRY {
data = xbt_dict_get(head, data);
- THROW1(unknown_error, 0,
+ THROWF(unknown_error, 0,
"Found something which shouldn't be there (%s)", data);
} CATCH(e) {
if (e.category != not_found_error)
{
if (idx < 0 || idx >= dynar->used) {
_dynar_unlock(dynar);
- THROW2(bound_error, idx,
+ THROWF(bound_error, idx,
"dynar is not that long. You asked %d, but it's only %lu long",
(int) (idx), (unsigned long) dynar->used);
}
{
if (idx > dynar->used) {
_dynar_unlock(dynar);
- THROW2(bound_error, idx,
+ THROWF(bound_error, idx,
"dynar is not that long. You asked %d, but it's only %lu long (could have been equal to it)",
(int) (idx), (unsigned long) dynar->used);
}
{
if (dynar->used == 0) {
_dynar_unlock(dynar);
- THROW1(bound_error, 0, "dynar %p is empty", dynar);
+ THROWF(bound_error, 0, "dynar %p is empty", dynar);
}
}
}
_dynar_unlock(dynar);
- THROW2(not_found_error, 0, "Element %p not part of dynar %p", elem,
+ THROWF(not_found_error, 0, "Element %p not part of dynar %p", elem,
dynar);
}
if (n != 2)
xbt_test_fail("M2: n=%d (!= 2)", n);
n++;
- THROW0(unknown_error, 0, "something");
+ THROWF(unknown_error, 0, "something");
}
CATCH(ex) {
if (n != 3)
if (n != 5)
xbt_test_fail("M2: n=%d (!= 5)", n);
n++;
- THROW0(unknown_error, 0, "something");
+ THROWF(unknown_error, 0, "something");
}
CATCH(ex) {
if (n != 6)
xbt_ex_t ex;
TRY {
- THROW0(unknown_error, 2, "toto");
+ THROWF(unknown_error, 2, "toto");
}
CATCH(ex) {
xbt_test_add("exception value passing");
TRY {
r2 = 5678;
v2 = 5678;
- THROW0(unknown_error, 0, "toto");
+ THROWF(unknown_error, 0, "toto");
} CATCH(ex) {
xbt_test_add("variable preservation");
if (r1 != 1234)
c = 0;
TRY {
v1 = 5678;
- THROW0(1, 2, "blah");
+ THROWF(1, 2, "blah");
} TRY_CLEANUP {
if (v1 != 5678)
xbt_test_fail("v1 = %d (!= 5678)", v1);
if (*((int *) (n->xbtdata)) == ALREADY_EXPLORED)
return;
else if (*((int *) (n->xbtdata)) == CURRENTLY_EXPLORING)
- THROW0(0, 0, "There is a cycle");
+ THROWF(0, 0, "There is a cycle");
else {
*((int *) (n->xbtdata)) = CURRENTLY_EXPLORING;
if (i < xbt_log_priority_infinite) {
set->thresh = (e_xbt_log_priority_t) i;
} else {
- THROW1(arg_error, 0,
+ THROWF(arg_error, 0,
"Unknown priority name: %s (must be one of: trace,debug,verbose,info,warning,error,critical)",
eq + 1);
}
if (!strncmp(neweq, "file:", 5)) {
set->appender = xbt_log_appender_file_new(neweq + 5);
} else {
- THROW1(arg_error, 0, "Unknown appender log type: '%s'", neweq);
+ THROWF(arg_error, 0, "Unknown appender log type: '%s'", neweq);
}
free(neweq);
} else if (!strncmp(dot + 1, "fmt", (size_t) (eq - dot - 1))) {
} else {
char buff[512];
snprintf(buff, min(512, eq - dot), "%s", dot + 1);
- THROW1(arg_error, 0, "Unknown setting of the log category: '%s'",
+ THROWF(arg_error, 0, "Unknown setting of the log category: '%s'",
buff);
}
set->catname = (char *) xbt_malloc(dot - name + 1);
res = xbt_dynar_get_as(set->dynar, id, xbt_set_elm_t);
if (res == NULL) {
- THROW1(not_found_error, 0, "Invalid id: %d", id);
+ THROWF(not_found_error, 0, "Invalid id: %d", id);
}
XBT_DEBUG("Lookup type of id %d (of %lu): %s",
id, xbt_dynar_length(set->dynar), res->name);
xbt_test_log(" Found %s (under ID %d)\n",
elm ? elm->data : "(null)", elm ? elm->ID : -1);
if (strcmp(key, elm->name))
- THROW2(mismatch_error, 0, "The key (%s) is not the one expected (%s)",
+ THROWF(mismatch_error, 0, "The key (%s) is not the one expected (%s)",
key, elm->name);
if (strcmp(elm->name, elm->data))
- THROW2(mismatch_error, 0, "The name (%s) != data (%s)", key,
+ THROWF(mismatch_error, 0, "The name (%s) != data (%s)", key,
elm->name);
fflush(stdout);
}
xbt_test_log("Found %s (data %s)",
elm ? elm->name : "(null)", elm ? elm->data : "(null)");
if (id != elm->ID)
- THROW2(mismatch_error, 0,
+ THROWF(mismatch_error, 0,
"The found ID (%d) is not the one expected (%d)", elm->ID, id);
if (strcmp(key, elm->name))
- THROW2(mismatch_error, 0, "The key (%s) is not the one expected (%s)",
+ THROWF(mismatch_error, 0, "The key (%s) is not the one expected (%s)",
elm->name, key);
if (strcmp(elm->name, elm->data))
- THROW2(mismatch_error, 0, "The name (%s) != data (%s)",
+ THROWF(mismatch_error, 0, "The name (%s) != data (%s)",
elm->name, elm->data);
}
xbt_test_add("Search %s (expected not to be found)", data);
TRY {
xbt_set_get_by_name(set, data);
- THROW1(unknown_error, 0,
+ THROWF(unknown_error, 0,
"Found something which shouldn't be there (%s)", data);
} CATCH(e) {
if (e.category != not_found_error)
return;
if ((errcode = pthread_key_create(&xbt_self_thread_key, NULL)))
- THROW0(system_error, errcode,
+ THROWF(system_error, errcode,
"pthread_key_create failed for xbt_self_thread_key");
main_thread = xbt_new(s_xbt_os_thread_t, 1);
XBT_RUNNING_CTX_INITIALIZE(main_thread->running_ctx);
if ((errcode = pthread_setspecific(xbt_self_thread_key, main_thread)))
- THROW0(system_error, errcode,
+ THROWF(system_error, errcode,
"pthread_setspecific failed for xbt_self_thread_key");
// int errcode;
// if ((errcode=pthread_key_delete(xbt_self_thread_key)))
- // THROW0(system_error,errcode,"pthread_key_delete failed for xbt_self_thread_key");
+ // THROWF(system_error,errcode,"pthread_key_delete failed for xbt_self_thread_key");
free(main_thread->running_ctx);
free(main_thread);
main_thread = NULL;
int errcode;
if ((errcode = pthread_setspecific(xbt_self_thread_key, t)))
- THROW0(system_error, errcode,
+ THROWF(system_error, errcode,
"pthread_setspecific failed for xbt_self_thread_key");
void *res = (*(t->start_routine)) (t->param);
if ((errcode = pthread_create(&(res_thread->t), NULL,
wrapper_start_routine, res_thread)))
- THROW1(system_error, errcode,
+ THROWF(system_error, errcode,
"pthread_create failed: %s", strerror(errcode));
return res_thread;
int errcode;
if ((errcode = pthread_join(thread->t, thread_return)))
- THROW1(system_error, errcode, "pthread_join failed: %s",
+ THROWF(system_error, errcode, "pthread_join failed: %s",
strerror(errcode));
xbt_os_thread_free_thread_data(thread);
}
int errcode;
if ((errcode = pthread_mutex_init(&(res->m), NULL)))
- THROW1(system_error, errcode, "pthread_mutex_init() failed: %s",
+ THROWF(system_error, errcode, "pthread_mutex_init() failed: %s",
strerror(errcode));
return res;
int errcode;
if ((errcode = pthread_mutex_lock(&(mutex->m))))
- THROW2(system_error, errcode, "pthread_mutex_lock(%p) failed: %s",
+ THROWF(system_error, errcode, "pthread_mutex_lock(%p) failed: %s",
mutex, strerror(errcode));
}
case 0:
return;
case ETIMEDOUT:
- THROW1(timeout_error, 0, "mutex %p not ready", mutex);
+ THROWF(timeout_error, 0, "mutex %p not ready", mutex);
default:
- THROW2(system_error, errcode,
+ THROWF(system_error, errcode,
"xbt_mutex_timedacquire(%p) failed: %s", mutex,
strerror(errcode));
}
return;
case ETIMEDOUT:
- THROW2(timeout_error, delay,
+ THROWF(timeout_error, delay,
"mutex %p wasn't signaled before timeout (%f)", mutex, delay);
default:
- THROW3(system_error, errcode,
+ THROWF(system_error, errcode,
"pthread_mutex_timedlock(%p,%f) failed: %s", mutex, delay,
strerror(errcode));
}
int errcode;
if ((errcode = pthread_mutex_unlock(&(mutex->m))))
- THROW2(system_error, errcode, "pthread_mutex_unlock(%p) failed: %s",
+ THROWF(system_error, errcode, "pthread_mutex_unlock(%p) failed: %s",
mutex, strerror(errcode));
}
return;
if ((errcode = pthread_mutex_destroy(&(mutex->m))))
- THROW2(system_error, errcode, "pthread_mutex_destroy(%p) failed: %s",
+ THROWF(system_error, errcode, "pthread_mutex_destroy(%p) failed: %s",
mutex, strerror(errcode));
free(mutex);
}
xbt_os_cond_t res = xbt_new(s_xbt_os_cond_t, 1);
int errcode;
if ((errcode = pthread_cond_init(&(res->c), NULL)))
- THROW1(system_error, errcode, "pthread_cond_init() failed: %s",
+ THROWF(system_error, errcode, "pthread_cond_init() failed: %s",
strerror(errcode));
return res;
{
int errcode;
if ((errcode = pthread_cond_wait(&(cond->c), &(mutex->m))))
- THROW3(system_error, errcode, "pthread_cond_wait(%p,%p) failed: %s",
+ THROWF(system_error, errcode, "pthread_cond_wait(%p,%p) failed: %s",
cond, mutex, strerror(errcode));
}
case 0:
return;
case ETIMEDOUT:
- THROW3(timeout_error, errcode,
+ THROWF(timeout_error, errcode,
"condition %p (mutex %p) wasn't signaled before timeout (%f)",
cond, mutex, delay);
default:
- THROW4(system_error, errcode,
+ THROWF(system_error, errcode,
"pthread_cond_timedwait(%p,%p,%f) failed: %s", cond, mutex,
delay, strerror(errcode));
}
{
int errcode;
if ((errcode = pthread_cond_signal(&(cond->c))))
- THROW2(system_error, errcode, "pthread_cond_signal(%p) failed: %s",
+ THROWF(system_error, errcode, "pthread_cond_signal(%p) failed: %s",
cond, strerror(errcode));
}
{
int errcode;
if ((errcode = pthread_cond_broadcast(&(cond->c))))
- THROW2(system_error, errcode, "pthread_cond_broadcast(%p) failed: %s",
+ THROWF(system_error, errcode, "pthread_cond_broadcast(%p) failed: %s",
cond, strerror(errcode));
}
return;
if ((errcode = pthread_cond_destroy(&(cond->c))))
- THROW2(system_error, errcode, "pthread_cond_destroy(%p) failed: %s",
+ THROWF(system_error, errcode, "pthread_cond_destroy(%p) failed: %s",
cond, strerror(errcode));
free(cond);
}
*/
#ifdef HAVE_SEM_INIT
if (sem_init(&(res->s), 0, value) != 0)
- THROW1(system_error, errno, "sem_init() failed: %s", strerror(errno));
+ THROWF(system_error, errno, "sem_init() failed: %s", strerror(errno));
res->ps = &(res->s);
#else /* damn, no sem_init(). Reimplement it */
res->ps = sem_open(res->name, O_CREAT, 0644, 1);
}
if ((res->ps == (sem_t *) SEM_FAILED))
- THROW1(system_error, errno, "sem_open() failed: %s", strerror(errno));
+ THROWF(system_error, errno, "sem_open() failed: %s", strerror(errno));
/* Remove the name from the semaphore namespace: we never join on it */
if (sem_unlink(res->name) < 0)
- THROW1(system_error, errno, "sem_unlink() failed: %s",
+ THROWF(system_error, errno, "sem_unlink() failed: %s",
strerror(errno));
#endif
void xbt_os_sem_acquire(xbt_os_sem_t sem)
{
if (!sem)
- THROW0(arg_error, EINVAL, "Cannot acquire of the NULL semaphore");
+ THROWF(arg_error, EINVAL, "Cannot acquire of the NULL semaphore");
if (sem_wait(sem->ps) < 0)
- THROW1(system_error, errno, "sem_wait() failed: %s", strerror(errno));
+ THROWF(system_error, errno, "sem_wait() failed: %s", strerror(errno));
}
void xbt_os_sem_timedacquire(xbt_os_sem_t sem, double delay)
int errcode;
if (!sem)
- THROW0(arg_error, EINVAL, "Cannot acquire of the NULL semaphore");
+ THROWF(arg_error, EINVAL, "Cannot acquire of the NULL semaphore");
if (delay < 0) {
xbt_os_sem_acquire(sem);
case 0:
return;
case ETIMEDOUT:
- THROW1(timeout_error, 0, "semaphore %p not ready", sem);
+ THROWF(timeout_error, 0, "semaphore %p not ready", sem);
default:
- THROW2(system_error, errcode,
+ THROWF(system_error, errcode,
"xbt_os_sem_timedacquire(%p) failed: %s", sem,
strerror(errcode));
}
return;
case ETIMEDOUT:
- THROW2(timeout_error, delay,
+ THROWF(timeout_error, delay,
"semaphore %p wasn't signaled before timeout (%f)", sem,
delay);
default:
- THROW3(system_error, errcode, "sem_timedwait(%p,%f) failed: %s", sem,
+ THROWF(system_error, errcode, "sem_timedwait(%p,%f) failed: %s", sem,
delay, strerror(errcode));
}
}
void xbt_os_sem_release(xbt_os_sem_t sem)
{
if (!sem)
- THROW0(arg_error, EINVAL, "Cannot release of the NULL semaphore");
+ THROWF(arg_error, EINVAL, "Cannot release of the NULL semaphore");
if (sem_post(sem->ps) < 0)
- THROW1(system_error, errno, "sem_post() failed: %s", strerror(errno));
+ THROWF(system_error, errno, "sem_post() failed: %s", strerror(errno));
}
void xbt_os_sem_destroy(xbt_os_sem_t sem)
{
if (!sem)
- THROW0(arg_error, EINVAL, "Cannot destroy the NULL sempahore");
+ THROWF(arg_error, EINVAL, "Cannot destroy the NULL sempahore");
#ifdef HAVE_SEM_INIT
if (sem_destroy(sem->ps) < 0)
- THROW1(system_error, errno, "sem_destroy() failed: %s",
+ THROWF(system_error, errno, "sem_destroy() failed: %s",
strerror(errno));
#else
if (sem_close(sem->ps) < 0)
- THROW1(system_error, errno, "sem_close() failed: %s", strerror(errno));
+ THROWF(system_error, errno, "sem_close() failed: %s", strerror(errno));
xbt_free(sem->name);
#endif
void xbt_os_sem_get_value(xbt_os_sem_t sem, int *svalue)
{
if (!sem)
- THROW0(arg_error, EINVAL,
+ THROWF(arg_error, EINVAL,
"Cannot get the value of the NULL semaphore");
if (sem_getvalue(&(sem->s), svalue) < 0)
- THROW1(system_error, errno, "sem_getvalue() failed: %s",
+ THROWF(system_error, errno, "sem_getvalue() failed: %s",
strerror(errno));
}
{
if (!TlsFree(xbt_self_thread_key))
- THROW0(system_error, (int) GetLastError(),
+ THROWF(system_error, (int) GetLastError(),
"TlsFree() failed to cleanup the thread submodule");
}
DWORD *rv;
if (!TlsSetValue(xbt_self_thread_key, t))
- THROW0(system_error, (int) GetLastError(),
+ THROWF(system_error, (int) GetLastError(),
"TlsSetValue of data describing the created thread failed");
rv = (DWORD *) ((t->start_routine) (t->param));
if (!t->handle) {
xbt_free(t);
- THROW0(system_error, (int) GetLastError(), "CreateThread failed");
+ THROWF(system_error, (int) GetLastError(), "CreateThread failed");
}
return t;
{
if (WAIT_OBJECT_0 != WaitForSingleObject(thread->handle, INFINITE))
- THROW0(system_error, (int) GetLastError(),
+ THROWF(system_error, (int) GetLastError(),
"WaitForSingleObject failed");
if (thread_return) {
if (!GetExitCodeThread(thread->handle, (DWORD *) (*thread_return)))
- THROW0(system_error, (int) GetLastError(),
+ THROWF(system_error, (int) GetLastError(),
"GetExitCodeThread failed");
}
void xbt_os_thread_cancel(xbt_os_thread_t t)
{
if (!TerminateThread(t->handle, 0))
- THROW0(system_error, (int) GetLastError(), "TerminateThread failed");
+ THROWF(system_error, (int) GetLastError(), "TerminateThread failed");
}
/****** mutex related functions ******/
if (!res->events[SIGNAL]) {
DeleteCriticalSection(&res->waiters_count_lock);
free(res);
- THROW0(system_error, 0, "CreateEvent failed for the signals");
+ THROWF(system_error, 0, "CreateEvent failed for the signals");
}
/* Create a manual-reset event. */
DeleteCriticalSection(&res->waiters_count_lock);
CloseHandle(res->events[SIGNAL]);
free(res);
- THROW0(system_error, 0, "CreateEvent failed for the broadcasts");
+ THROWF(system_error, 0, "CreateEvent failed for the broadcasts");
}
return res;
wait_result = WaitForMultipleObjects(2, cond->events, FALSE, INFINITE);
if (wait_result == WAIT_FAILED)
- THROW0(system_error, 0,
+ THROWF(system_error, 0,
"WaitForMultipleObjects failed, so we cannot wait on the condition");
/* we have a signal lock the condition */
*/
if (is_last_waiter)
if (!ResetEvent(cond->events[BROADCAST]))
- THROW0(system_error, 0, "ResetEvent failed");
+ THROWF(system_error, 0, "ResetEvent failed");
/* relock the mutex associated with the condition in accordance with the posix thread specification */
EnterCriticalSection(&mutex->lock);
switch (wait_result) {
case WAIT_TIMEOUT:
- THROW3(timeout_error, GetLastError(),
+ THROWF(timeout_error, GetLastError(),
"condition %p (mutex %p) wasn't signaled before timeout (%f)",
cond, mutex, delay);
case WAIT_FAILED:
- THROW0(system_error, GetLastError(),
+ THROWF(system_error, GetLastError(),
"WaitForMultipleObjects failed, so we cannot wait on the condition");
}
*/
if (is_last_waiter)
if (!ResetEvent(cond->events[BROADCAST]))
- THROW0(system_error, 0, "ResetEvent failed");
+ THROWF(system_error, 0, "ResetEvent failed");
/* relock the mutex associated with the condition in accordance with the posix thread specification */
EnterCriticalSection(&mutex->lock);
if (have_waiters)
if (!SetEvent(cond->events[SIGNAL]))
- THROW0(system_error, 0, "SetEvent failed");
+ THROWF(system_error, 0, "SetEvent failed");
xbt_os_thread_yield();
}
xbt_free(cond);
if (error)
- THROW0(system_error, 0, "Error while destroying the condition");
+ THROWF(system_error, 0, "Error while destroying the condition");
}
typedef struct xbt_os_sem_ {
xbt_os_sem_t res;
if (value > INT_MAX)
- THROW1(arg_error, value,
+ THROWF(arg_error, value,
"Semaphore initial value too big: %ud cannot be stored as a signed int",
value);
res = (xbt_os_sem_t) xbt_new0(s_xbt_os_sem_t, 1);
if (!(res->h = CreateSemaphore(NULL, value, (long) INT_MAX, NULL))) {
- THROW1(system_error, GetLastError(), "CreateSemaphore() failed: %s",
+ THROWF(system_error, GetLastError(), "CreateSemaphore() failed: %s",
strerror(GetLastError()));
return NULL;
}
void xbt_os_sem_acquire(xbt_os_sem_t sem)
{
if (!sem)
- THROW0(arg_error, EINVAL, "Cannot acquire the NULL semaphore");
+ THROWF(arg_error, EINVAL, "Cannot acquire the NULL semaphore");
/* wait failure */
if (WAIT_OBJECT_0 != WaitForSingleObject(sem->h, INFINITE))
- THROW1(system_error, GetLastError(),
+ THROWF(system_error, GetLastError(),
"WaitForSingleObject() failed: %s", strerror(GetLastError()));
EnterCriticalSection(&(sem->value_lock));
sem->value--;
double end = timeout + xbt_os_time();
if (!sem)
- THROW0(arg_error, EINVAL, "Cannot acquire the NULL semaphore");
+ THROWF(arg_error, EINVAL, "Cannot acquire the NULL semaphore");
if (timeout < 0) {
xbt_os_sem_acquire(sem);
return;
case WAIT_TIMEOUT:
- THROW2(timeout_error, GetLastError(),
+ THROWF(timeout_error, GetLastError(),
"semaphore %p wasn't signaled before timeout (%f)", sem,
timeout);
return;
default:
- THROW3(system_error, GetLastError(),
+ THROWF(system_error, GetLastError(),
"WaitForSingleObject(%p,%f) failed: %s", sem, timeout,
strerror(GetLastError()));
}
void xbt_os_sem_release(xbt_os_sem_t sem)
{
if (!sem)
- THROW0(arg_error, EINVAL, "Cannot release the NULL semaphore");
+ THROWF(arg_error, EINVAL, "Cannot release the NULL semaphore");
if (!ReleaseSemaphore(sem->h, 1, NULL))
- THROW1(system_error, GetLastError(), "ReleaseSemaphore() failed: %s",
+ THROWF(system_error, GetLastError(), "ReleaseSemaphore() failed: %s",
strerror(GetLastError()));
EnterCriticalSection(&(sem->value_lock));
sem->value++;
void xbt_os_sem_destroy(xbt_os_sem_t sem)
{
if (!sem)
- THROW0(arg_error, EINVAL, "Cannot destroy the NULL semaphore");
+ THROWF(arg_error, EINVAL, "Cannot destroy the NULL semaphore");
if (!CloseHandle(sem->h))
- THROW1(system_error, GetLastError(), "CloseHandle() failed: %s",
+ THROWF(system_error, GetLastError(), "CloseHandle() failed: %s",
strerror(GetLastError()));
DeleteCriticalSection(&(sem->value_lock));
void xbt_os_sem_get_value(xbt_os_sem_t sem, int *svalue)
{
if (!sem)
- THROW0(arg_error, EINVAL,
+ THROWF(arg_error, EINVAL,
"Cannot get the value of the NULL semaphore");
EnterCriticalSection(&(sem->value_lock));
queue->capacity == xbt_dynar_length(queue->data)) {
xbt_mutex_release(queue->mutex);
- THROW2(timeout_error, 0,
+ THROWF(timeout_error, 0,
"Capacity of %p exceded (=%d), and delay = 0", queue,
queue->capacity);
}
if (delay == 0) {
if (xbt_dynar_length(queue->data) == 0) {
xbt_mutex_release(queue->mutex);
- THROW0(timeout_error, 0, "Delay = 0, and queue is empty");
+ THROWF(timeout_error, 0, "Delay = 0, and queue is empty");
}
} else {
while ((xbt_dynar_length(queue->data) == 0) &&
queue->capacity == xbt_dynar_length(queue->data)) {
xbt_mutex_release(queue->mutex);
- THROW2(timeout_error, 0,
+ THROWF(timeout_error, 0,
"Capacity of %p exceded (=%d), and delay = 0", queue,
queue->capacity);
}
if (delay == 0) {
if (xbt_dynar_length(queue->data) == 0) {
xbt_mutex_release(queue->mutex);
- THROW0(timeout_error, 0, "Delay = 0, and queue is empty");
+ THROWF(timeout_error, 0, "Delay = 0, and queue is empty");
}
} else {
while ((xbt_dynar_length(queue->data) == 0) &&
if (xbt_dynar_length(queue->data) == 0) {
xbt_mutex_release(queue->mutex);
- THROW1(timeout_error, 0, "Timeout (%f) elapsed, but queue still empty",
+ THROWF(timeout_error, 0, "Timeout (%f) elapsed, but queue still empty",
delay);
}
/* Protected char; move it closer */
memmove(end, end + 1, strlen(end));
if (*end == '\0')
- THROW0(arg_error, 0, "String ends with \\");
+ THROWF(arg_error, 0, "String ends with \\");
end++; /* Pass the protected char */
break;
case '\n':
case '\0':
if (*end == '\0' && (in_simple_quote || in_double_quote)) {
- THROW2(arg_error, 0,
+ THROWF(arg_error, 0,
"End of string found while searching for %c in %s",
(in_simple_quote ? '\'' : '"'), s);
}
} else if (i <= 0 && j <= 0) {
return;
} else {
- THROW2(arg_error, 0, "Invalid values: i=%d, j=%d", i, j);
+ THROWF(arg_error, 0, "Invalid values: i=%d, j=%d", i, j);
}
}
int needed_space;
if (!b)
- THROW0(arg_error, 0, "Asked to append stuff to NULL buffer");
+ THROWF(arg_error, 0, "Asked to append stuff to NULL buffer");
addlen = strlen(toadd);
needed_space = b->used + addlen + 1;
/* Protected char; pass the protection */
end++;
if (*end == '\0')
- THROW0(arg_error, 0, "String ends with \\");
+ THROWF(arg_error, 0, "String ends with \\");
break;
case '\'':
while (*p != '\0' && *p != '}')
p++;
if (*p == '\0')
- THROW0(arg_error, 0,
+ THROWF(arg_error, 0,
"Variable default value not terminated ('}' missing)");
default_value = xbt_malloc(p - end_var - 1);
end_var++;
}
if (*end_var == '\0')
- THROW0(arg_error, 0,
+ THROWF(arg_error, 0,
"Variable name not terminated ('}' missing)");
if (!end_subst) /* already set if there's a default value */
end_subst = end_var + 1; /* also kill the } in the name */
if (end_var == beg_var)
- THROW0(arg_error, 0, "Variable name empty (${} is not valid)");
+ THROWF(arg_error, 0, "Variable name empty (${} is not valid)");
} else {
end_var++;
end_subst = end_var;
if (end_var == beg_var)
- THROW0(arg_error, 0, "Variable name empty ($ is not valid)");
+ THROWF(arg_error, 0, "Variable name empty ($ is not valid)");
}
/* XBT_DEBUG("var='%.*s'; subst='%.*s'; End_var = '%s'",
end_var-beg_var,beg_var,
TRY {
me = gras_socket_server(myport);
} CATCH(e) {
- RETHROW0("Unable to establish a server socket: %s");
+ RETHROWF("Unable to establish a server socket: %s");
}
gras_os_sleep(1); /* Wait for pal to startup */
TRY {
pal = gras_socket_client_from_string(palstr);
} CATCH(e) {
- RETHROW1("Unable to establish a socket to %s: %s", palstr);
+ RETHROWF("Unable to establish a socket to %s: %s", palstr);
}
XBT_INFO("Initialization done.");
now = gras_os_time();
got_expected = 1;
xbt_ex_free(e);
} else {
- RETHROW0("Didn't got the expected timeout: %s");
+ RETHROWF("Didn't got the expected timeout: %s");
}
}
xbt_assert0(got_expected,
got_expected = 1;
xbt_ex_free(e);
} else {
- RETHROW0("Didn't got the expected timeout: %s");
+ RETHROWF("Didn't got the expected timeout: %s");
}
}
xbt_assert0(got_expected,
TRY {
me = gras_socket_server(myport);
} CATCH(e) {
- RETHROW0("Unable to establish a server socket: %s");
+ RETHROWF("Unable to establish a server socket: %s");
}
gras_os_sleep(1); /* Wait for pal to startup */
TRY {
pal = gras_socket_client_from_string(palstr);
} CATCH(e) {
- RETHROW1("Unable to establish a socket to %s: %s", palstr);
+ RETHROWF("Unable to establish a socket to %s: %s", palstr);
}
XBT_INFO("Initialization done.");
TRY {
gras_msg_handle(-1);
} CATCH(e) {
- RETHROW0("No exception expected during handle(-1), but got %s");
+ RETHROWF("No exception expected during handle(-1), but got %s");
}
XBT_INFO("gras_msg_handle(-1) works as expected (locked)");
xbt_str_trim(filename, NULL);
OUT = fopen(filename, "w");
if (!OUT) {
- THROW3(system_error, errno, "%s: Cannot create file %s: %s",
+ THROWF(system_error, errno, "%s: Cannot create file %s: %s",
rctx->filepos, filename, strerror(errno));
}
err = (fprintf(OUT, "%s", rctx->input->data) < 0);
err = (fclose(OUT) == -1) || err;
if (err) {
- THROW3(system_error, errno, "%s: Cannot write file %s: %s",
+ THROWF(system_error, errno, "%s: Cannot write file %s: %s",
rctx->filepos, filename, strerror(errno));
}
free(filename);
rctx_dump(rctx, "wait");
if (!rctx->is_stoppable)
- THROW1(unknown_error, 0, "Cmd '%s' not started yet. Cannot wait it",
+ THROWF(unknown_error, 0, "Cmd '%s' not started yet. Cannot wait it",
rctx->cmd);
/* Wait for the child to die or the timeout to happen (or an armageddon to happen) */