int sensor (int argc,char *argv[]);
int sensor (int argc,char *argv[]) {
- gras_error_t errcode;
+ xbt_error_t errcode;
sensor_data_t *g=gras_userdata_new(sensor_data_t);
if ((errcode=gras_sock_server_open(4000,4000,&(g->sock)))) {
- fprintf(stderr,"Sensor: Error %s encountered while opening the server socket\n",gras_error_name(errcode));
+ fprintf(stderr,"Sensor: Error %s encountered while opening the server socket\n",xbt_error_name(errcode));
return 1;
}
while (1) {
if ((errcode=gras_msg_handle(3600.0)) && errcode != timeout_error) {
fprintf(stderr,"Sensor: Error '%s' while handling message\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
}
}
int msgSize=expSize;
int satSize=msgSize * 100;
double dummy,beginSim;
- gras_error_t errcode;
+ xbt_error_t errcode;
maestro_data_t *g=gras_userdata_new(maestro_data_t);
double bw[MAXHOSTS][MAXHOSTS];
}
if ((errcode=gras_sock_server_open(4000,5000,&(g->sock)))) {
- fprintf(stderr,"MAESTRO: Error %s encountered while opening the server socket\n",gras_error_name(errcode));
+ fprintf(stderr,"MAESTRO: Error %s encountered while opening the server socket\n",xbt_error_name(errcode));
return 1;
}
}
}
if (errcode) {
- fprintf(stderr,"MAESTRO: Error %s encountered while doing the test\n",gras_error_name(errcode));
+ fprintf(stderr,"MAESTRO: Error %s encountered while doing the test\n",xbt_error_name(errcode));
return 1;
}
fprintf(stderr,"%f Mb/s in %f sec\n",bw[a][b],dummy);
if ((errcode=grasbw_saturate_start(argv[a],4000,argv[b],4000,satSize,360000000))) {
fprintf(stderr,"MAESTRO: Error %s encountered while starting saturation\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
return -1;
}
gras_sleep(1,0);
if ((errcode=grasbw_request(argv[c],4000,argv[d],4000,bufSize,expSize,msgSize,
&dummy,&(bw_sat[c][d])))) {
- fprintf(stderr,"MAESTRO: Error %s encountered in test\n",gras_error_name(errcode));
+ fprintf(stderr,"MAESTRO: Error %s encountered in test\n",xbt_error_name(errcode));
return 1;
}
fprintf(stderr, "MAESTRO[%.2f sec]: SATURATED BW XP(%s %s // %s %s) => %f (%f vs %f)%s\n",
if ((errcode=grasbw_saturate_stop(argv[a],4000,argv[b],4000))) {
fprintf(stderr,"MAESTRO: Error %s encountered while stopping saturation\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
return -1;
}
fprintf(stderr,"Did an iteration on saturation pair in %ld sec (%.2f simulated sec)\n",
#include "gras.h"
#include "amok/bandwidth.h"
-GRAS_LOG_NEW_DEFAULT_CATEGORY(Bandwidth,"Messages specific to this example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(Bandwidth,"Messages specific to this example");
/* **********************************************************************
* Sensor code
int sensor (int argc,char *argv[]);
int sensor (int argc,char *argv[]) {
- gras_error_t errcode;
+ xbt_error_t errcode;
sensor_data_t g;
- gras_init(&argc,argv);
+ xbt_init(&argc,argv);
g=gras_userdata_new(s_sensor_data_t);
amok_bw_init();
if ((errcode=gras_socket_server(atoi(argv[1]),&(g->sock)))) {
- ERROR1("Sensor: Error %s encountered while opening the server socket",gras_error_name(errcode));
+ ERROR1("Sensor: Error %s encountered while opening the server socket",xbt_error_name(errcode));
return 1;
}
errcode=gras_msg_handle(60.0);
if (errcode != no_error) {
- ERROR1("Sensor: Error '%s' while handling message",gras_error_name(errcode));
+ ERROR1("Sensor: Error '%s' while handling message",xbt_error_name(errcode));
gras_socket_close(g->sock);
return errcode;
}
int maestro (int argc,char *argv[]);
int maestro(int argc,char *argv[]) {
- gras_error_t errcode;
+ xbt_error_t errcode;
maestro_data_t g;
double sec, bw;
int buf_size=32;
int msg_size=64;
gras_socket_t peer;
- gras_init(&argc,argv);
+ xbt_init(&argc,argv);
g=gras_userdata_new(s_maestro_data_t);
amok_bw_init();
gras_os_sleep(1,0);
if ((errcode=gras_socket_server(6000,&(g->sock)))) {
- ERROR1("Maestro: Error %s encountered while opening the server socket",gras_error_name(errcode));
+ ERROR1("Maestro: Error %s encountered while opening the server socket",xbt_error_name(errcode));
return 1;
}
if ((errcode=gras_socket_client(argv[1],atoi(argv[2]),&peer))) {
ERROR3("Client: Unable to connect to my peer on %s:%s. Got %s",
- argv[1],argv[2],gras_error_name(errcode));
+ argv[1],argv[2],xbt_error_name(errcode));
return 1;
}
buf_size,exp_size,msg_size,&sec,&bw))) {*/
if ((errcode=amok_bw_test(peer,buf_size,exp_size,msg_size,&sec,&bw))) {
- ERROR1("maestro: Error %s encountered while doing the test",gras_error_name(errcode));
+ ERROR1("maestro: Error %s encountered while doing the test",xbt_error_name(errcode));
return 1;
}
#include "gras.h"
-GRAS_LOG_NEW_DEFAULT_CATEGORY(Ping,"Messages specific to this example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(Ping,"Messages specific to this example");
/* **********************************************************************
* Comon code
int server_cb_ping_handler(gras_socket_t expeditor,
void *payload_data) {
- gras_error_t errcode;
+ xbt_error_t errcode;
int msg=*(int*)payload_data;
gras_msgtype_t *pong_t=NULL;
errcode = gras_msg_send(expeditor, gras_msgtype_by_name("pong"), &msg);
if (errcode != no_error) {
- ERROR1("SERVER: Unable answer with PONG: %s\n", gras_error_name(errcode));
+ ERROR1("SERVER: Unable answer with PONG: %s\n", xbt_error_name(errcode));
gras_socket_close(g->sock);
return 1;
}
}
int server (int argc,char *argv[]) {
- gras_error_t errcode;
+ xbt_error_t errcode;
server_data_t *g;
gras_msgtype_t *ping_msg=NULL;
int port = 4000;
- gras_init(&argc,argv);
+ xbt_init(&argc,argv);
g=gras_userdata_new(server_data_t);
if (argc == 2) {
if ((errcode=gras_socket_server(port,&(g->sock)))) {
CRITICAL1("Error %s encountered while opening the server socket",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
return 1;
}
gras_os_sleep(1,0);
gras_socket_close(g->sock);
free(g);
- gras_exit();
+ xbt_exit();
INFO0("SERVER: Done.");
return no_error;
}
int client (int argc,char *argv[]);
int client(int argc,char *argv[]) {
- gras_error_t errcode;
+ xbt_error_t errcode;
client_data_t *g;
gras_socket_t from;
const char *host = "127.0.0.1";
int port = 4000;
- gras_init(&argc, argv);
+ xbt_init(&argc, argv);
g=gras_userdata_new(client_data_t);
if (argc == 3) {
gras_os_sleep(1,0); /* Wait for the server startup */
if ((errcode=gras_socket_client(host,port,&(g->sock)))) {
ERROR1("Client: Unable to connect to the server. Got %s",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
return 1;
}
INFO2("Client: Connected to %s:%d.",host,port);
errcode = gras_msg_send(g->sock, gras_msgtype_by_name("ping"), &ping);
if (errcode != no_error) {
fprintf(stderr, "Client: Unable send PING to server (%s)\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
gras_socket_close(g->sock);
return 1;
}
if ((errcode=gras_msg_wait(6000,gras_msgtype_by_name("pong"),
&from,&pong))) {
ERROR1("Client: Why can't I get my PONG message like everyone else (%s)?",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
gras_socket_close(g->sock);
return 1;
}
gras_socket_close(g->sock);
free(g);
- gras_exit();
+ xbt_exit();
INFO0("Client: Done.");
return 0;
}
#include <gras.h>
-GRAS_LOG_NEW_DEFAULT_CATEGORY(saturate,"Messages specific to this example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(saturate,"Messages specific to this example");
/* **********************************************************************
* Sensor code
int sensor (int argc,char *argv[]);
int sensor (int argc,char *argv[]) {
- gras_error_t errcode;
+ xbt_error_t errcode;
sensor_data_t *g=gras_userdata_new(sensor_data_t);
if ((errcode=gras_socket_server(4000,&(g->sock)))) {
- CRITICAL1("Sensor: Error %s encountered while opening the server socket",gras_error_name(errcode));
+ CRITICAL1("Sensor: Error %s encountered while opening the server socket",xbt_error_name(errcode));
return 1;
}
while (1) {
if ((errcode=gras_msg_handle(60.0)) && errcode != timeout_error) {
CRITICAL1("Sensor: Error '%s' while handling message",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
}
}
double XP(const char *bw1, const char *bw2, const char *sat1, const char *sat2);
double XP(const char *bw1, const char *bw2, const char *sat1, const char *sat2) {
- gras_error_t errcode;
+ xbt_error_t errcode;
int bufSize=32 * 1024;
int expSize=64 * 1024;
int msgSize=64 * 1024;
double sec, bw, sec_sat,bw_sat;
if ((errcode=grasbw_request(bw1,4000,bw2,4000,bufSize,expSize,msgSize,&sec,&bw))) {
- fprintf(stderr,"MAESTRO: Error %s encountered while doing the test\n",gras_error_name(errcode));
+ fprintf(stderr,"MAESTRO: Error %s encountered while doing the test\n",xbt_error_name(errcode));
return -1;
}
if ((errcode=grasbw_saturate_start(sat1,4000,sat2,4000,satSize,60))) {
fprintf(stderr,"MAESTRO: Error %s encountered while starting saturation\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
return -1;
}
gras_os_sleep(1,0);
if ((errcode=grasbw_request(bw1,4000,bw2,4000,bufSize,expSize,msgSize,&sec_sat,&bw_sat))) {
- fprintf(stderr,"MAESTRO: Error %s encountered while doing the test\n",gras_error_name(errcode));
+ fprintf(stderr,"MAESTRO: Error %s encountered while doing the test\n",xbt_error_name(errcode));
return -1;
}
if ((errcode=grasbw_saturate_stop(sat1,4000,sat2,4000))) {
fprintf(stderr,"MAESTRO: Error %s encountered while stopping saturation\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
return -1;
}
int msgSize=expSize;
int satSize=msgSize * 100;
double dummy,beginSim;
- gras_error_t errcode;
+ xbt_error_t errcode;
maestro_data_t *g=gras_userdata_new(maestro_data_t);
// const char *hosts[MAXHOSTS] = { "61", "62", "63", "69", "70", "77", "81", "83", "85", "87", "88", "95", "98", "107", "109", "111", "112", "121", "124", "125", "131", "145", "150", "156", "157", "162", "165", "168", "169", "170", "175", "177", "178" };
const char *hosts[MAXHOSTS] = { "A", "B", "C", "D" };
int a,b,c,d,begin;
if ((errcode=gras_socket_server(4000,&(g->sock)))) {
- fprintf(stderr,"MAESTRO: Error %s encountered while opening the server socket\n",gras_error_name(errcode));
+ fprintf(stderr,"MAESTRO: Error %s encountered while opening the server socket\n",xbt_error_name(errcode));
return 1;
}
fprintf(stderr,"BW XP(%s %s)=",hosts[a],hosts[b]);
if ((errcode=grasbw_request(hosts[a],4000,hosts[b],4000,bufSize,expSize,msgSize,
&dummy,&(bw[a][b])))) {
- fprintf(stderr,"MAESTRO: Error %s encountered while doing the test\n",gras_error_name(errcode));
+ fprintf(stderr,"MAESTRO: Error %s encountered while doing the test\n",xbt_error_name(errcode));
return 1;
}
fprintf(stderr,"%f Mb/s in %f sec\n",bw[a][b],dummy);
if ((errcode=grasbw_saturate_start(hosts[a],4000,hosts[b],4000,satSize,360000000))) {
fprintf(stderr,"MAESTRO: Error %s encountered while starting saturation\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
return -1;
}
gras_os_sleep(1,0);
if ((errcode=grasbw_request(hosts[c],4000,hosts[d],4000,bufSize,expSize,msgSize,
&dummy,&(bw_sat[c][d])))) {
- fprintf(stderr,"MAESTRO: Error %s encountered in test\n",gras_error_name(errcode));
+ fprintf(stderr,"MAESTRO: Error %s encountered in test\n",xbt_error_name(errcode));
return 1;
}
fprintf(stderr, "MAESTRO[%.2f sec]: SATURATED BW XP(%s %s // %s %s) => %f (%f vs %f)%s\n",
if ((errcode=grasbw_saturate_stop(hosts[a],4000,hosts[b],4000))) {
fprintf(stderr,"MAESTRO: Error %s encountered while stopping saturation\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
return -1;
}
fprintf(stderr,"Did an iteration on saturation pair in %ld sec (%.2f simulated sec)\n",
fprintf(stderr,"MAESTRO: Start saturation with size %d\n",msgSize);
if ((errcode=grasbw_saturate_start(argv[5],atoi(argv[6]),argv[7],atoi(argv[8]),msgSize*10,60))) {
fprintf(stderr,"MAESTRO: Error %s encountered while starting saturation\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
return 1;
}
fprintf(stderr,"MAESTRO: Saturation started\n");
/* test with saturation */
if ((errcode=grasbw_request(argv[1],atoi(argv[2]),argv[3],atoi(argv[4]),
bufSize,expSize,msgSize,&sec,&bw))) {
- fprintf(stderr,"MAESTRO: Error %s encountered while doing the test\n",gras_error_name(errcode));
+ fprintf(stderr,"MAESTRO: Error %s encountered while doing the test\n",xbt_error_name(errcode));
return 1;
}
/* stop saturation */
if ((errcode=grasbw_saturate_stop(argv[5],atoi(argv[6]),argv[7],atoi(argv[8])))) {
fprintf(stderr,"MAESTRO: Error %s encountered while stopping saturation\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
return 1;
}
/* test without saturation */
if ((errcode=grasbw_request(argv[1],atoi(argv[2]),argv[3],atoi(argv[4]),
bufSize,expSize,msgSize,&sec,&bw))) {
- fprintf(stderr,"MAESTRO: Error %s encountered while doing the test\n",gras_error_name(errcode));
+ fprintf(stderr,"MAESTRO: Error %s encountered while doing the test\n",xbt_error_name(errcode));
return 1;
}
* Conduct a bandwidth test from the local process to the given peer.
* This call is blocking until the end of the experiment.
*/
-gras_error_t amok_bw_test(gras_socket_t peer,
+xbt_error_t amok_bw_test(gras_socket_t peer,
unsigned int buf_size,unsigned int exp_size,unsigned int msg_size,
/*OUT*/ double *sec, double *bw);
* Conduct a bandwidth test from the process from_host:from_port to to_host:to_port.
* This call is blocking until the end of the experiment.
*/
-gras_error_t grasbw_request(const char* from_name,unsigned int from_port,
+xbt_error_t grasbw_request(const char* from_name,unsigned int from_port,
const char* to_name,unsigned int to_port,
unsigned int bufSize,unsigned int expSize,unsigned int msgSize,
/*OUT*/ double *sec, double*bw);
* Ask the process 'from_name:from_port' to start to saturate the link between itself
* and to_name:to_name.
*/
-gras_error_t grasbw_saturate_start(const char* from_name,unsigned int from_port,
+xbt_error_t grasbw_saturate_start(const char* from_name,unsigned int from_port,
const char* to_name,unsigned int to_port,
unsigned int msgSize, unsigned int timeout);
* Ask the process 'from_name:from_port' to stop saturating the link between itself
* and to_name:to_name.
*/
-gras_error_t grasbw_saturate_stop(const char* from_name,unsigned int from_port,
+xbt_error_t grasbw_saturate_stop(const char* from_name,unsigned int from_port,
const char* to_name,unsigned int to_port);
unsigned int code;
} s_amok_remoterr_t,*amok_remoterr_t;
-amok_remoterr_t amok_remoterr_new(gras_error_t errcode,
+amok_remoterr_t amok_remoterr_new(xbt_error_t errcode,
const char* format, ...);
-amok_remoterr_t amok_remoterr_new_va(gras_error_t param_errcode,
+amok_remoterr_t amok_remoterr_new_va(xbt_error_t param_errcode,
const char* format,va_list ap);
void amok_remoterr_free(amok_remoterr_t *err);
*/
void
amok_repport_error (gras_socket_t sock, gras_msgtype_t msgtype,
- gras_error_t errcode, const char* format,...);
+ xbt_error_t errcode, const char* format,...);
void amok_base_init(void);
/* **************************************************************************
* Garbage collection support
* **************************************************************************/
-typedef enum { free_after_use, free_never } e_gras_free_directive_t;
+typedef enum { free_after_use, free_never } e_xbt_free_directive_t;
/* **************************************************************************
/* complex one: complete variable environment support */
-gras_error_t
+xbt_error_t
gras_cbps_v_pop (gras_cbps_t ps,
const char *name,
/* OUT */ gras_datadesc_type_t *ddt,
/* OUT */ void **res);
-gras_error_t
+xbt_error_t
gras_cbps_v_push(gras_cbps_t ps,
const char *name,
void *data,
sizeof(structType) - offsetof(structType, lastMember) - \
sizeof(memberType) * repetitions
-gras_error_t
+xbt_error_t
gras_datadesc_import_nws(const char *name,
const DataDescriptor *desc,
unsigned long howmany,
void gras_cb_unregister(gras_msgtype_t msgtype,
gras_cb_t cb);
-gras_error_t gras_msg_send(gras_socket_t sock,
+xbt_error_t gras_msg_send(gras_socket_t sock,
gras_msgtype_t msgtype,
void *payload);
-gras_error_t gras_msg_wait(double timeout,
+xbt_error_t gras_msg_wait(double timeout,
gras_msgtype_t msgt_want,
gras_socket_t *expeditor,
void *payload);
-gras_error_t gras_msg_handle(double timeOut);
+xbt_error_t gras_msg_handle(double timeOut);
END_DECL
* Register all messages and callbacks needed for the current process to be ready
* to do BW tests
*/
-gras_error_t grasbw_register_messages(void);
+xbt_error_t grasbw_register_messages(void);
/* ***************************************************************************
* Bandwidth tests
* Conduct a bandwidth test from the local process to the given peer.
* This call is blocking until the end of the experiment.
*/
-gras_error_t grasbw_test(const char*to_name,unsigned int to_port,
+xbt_error_t grasbw_test(const char*to_name,unsigned int to_port,
unsigned int bufSize,unsigned int expSize,unsigned int msgSize,
/*OUT*/ double *sec, double*bw);
* Conduct a bandwidth test from the process from_host:from_port to to_host:to_port.
* This call is blocking until the end of the experiment.
*/
-gras_error_t grasbw_request(const char* from_name,unsigned int from_port,
+xbt_error_t grasbw_request(const char* from_name,unsigned int from_port,
const char* to_name,unsigned int to_port,
unsigned int bufSize,unsigned int expSize,unsigned int msgSize,
/*OUT*/ double *sec, double*bw);
* Ask the process 'from_name:from_port' to start to saturate the link between itself
* and to_name:to_name.
*/
-gras_error_t grasbw_saturate_start(const char* from_name,unsigned int from_port,
+xbt_error_t grasbw_saturate_start(const char* from_name,unsigned int from_port,
const char* to_name,unsigned int to_port,
unsigned int msgSize, unsigned int timeout);
* Ask the process 'from_name:from_port' to stop saturating the link between itself
* and to_name:to_name.
*/
-gras_error_t grasbw_saturate_stop(const char* from_name,unsigned int from_port,
+xbt_error_t grasbw_saturate_stop(const char* from_name,unsigned int from_port,
const char* to_name,unsigned int to_port);
void
grasRepportError (gras_socket_t *sock, int id, int SeqCount,
const char *severeError,
- gras_error_t errcode, const char* format,...);
+ xbt_error_t errcode, const char* format,...);
#endif /* GRAS_ADDONS_H */
*
* Perform the various intialisations needed by gras. Each process must run it
*/
-gras_error_t gras_process_init(void);
+xbt_error_t gras_process_init(void);
/**
* gras_process_exit:
*
* Frees the memory allocated by gras. Processes should run it
*/
-gras_error_t gras_process_exit(void);
+xbt_error_t gras_process_exit(void);
/****************************************************************************/
/* Manipulating User Data */
typedef struct s_gras_socket *gras_socket_t;
-gras_error_t gras_socket_client(const char *host,
+xbt_error_t gras_socket_client(const char *host,
unsigned short port,
/* OUT */ gras_socket_t *dst);
-gras_error_t gras_socket_server(unsigned short port,
+xbt_error_t gras_socket_server(unsigned short port,
/* OUT */ gras_socket_t *dst);
void gras_socket_close(gras_socket_t sd);
char *gras_socket_peer_name(gras_socket_t sock);
/* extended interface to get all details */
-gras_error_t gras_socket_client_ext(const char *host,
+xbt_error_t gras_socket_client_ext(const char *host,
unsigned short port,
unsigned long int bufSize,
int raw,
/* OUT */ gras_socket_t *dst);
-gras_error_t gras_socket_server_ext(unsigned short port,
+xbt_error_t gras_socket_server_ext(unsigned short port,
unsigned long int bufSize,
int raw,
/* OUT */ gras_socket_t *dst);
/* using raw sockets */
-gras_error_t gras_socket_raw_send(gras_socket_t peer,
+xbt_error_t gras_socket_raw_send(gras_socket_t peer,
unsigned int timeout,
unsigned long int expSize,
unsigned long int msgSize);
-gras_error_t gras_socket_raw_recv(gras_socket_t peer,
+xbt_error_t gras_socket_raw_recv(gras_socket_t peer,
unsigned int timeout,
unsigned long int expSize,
unsigned long int msgSize);
/* debuging functions */
-gras_error_t gras_socket_client_from_file(const char*path,
+xbt_error_t gras_socket_client_from_file(const char*path,
/* OUT */ gras_socket_t *dst);
-gras_error_t gras_socket_server_from_file(const char*path,
+xbt_error_t gras_socket_server_from_file(const char*path,
/* OUT */ gras_socket_t *dst);
#define TRUE 1
#define FALSE 0
-#define GRAS_MAX_CHANNEL 10 /* FIXME: killme */
+#define XBT_MAX_CHANNEL 10 /* FIXME: killme */
#include <xbt/sysdep.h>
/* 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. */
-#ifndef _GRAS_CONFIG_H_
-#define _GRAS_CONFIG_H_
+#ifndef _XBT_CONFIG_H_
+#define _XBT_CONFIG_H_
#include "xbt/dynar.h"
/* For now, a config is only a special dynar. But don't rely on it, */
/* it may change in the future. */
-typedef gras_dynar_t gras_cfg_t;
+typedef xbt_dynar_t xbt_cfg_t;
/* type of a typed hash cell */
typedef enum {
- gras_cfgelm_int=0, gras_cfgelm_double, gras_cfgelm_string, gras_cfgelm_host,
- gras_cfgelm_type_count
-} e_gras_cfgelm_type_t;
+ xbt_cfgelm_int=0, xbt_cfgelm_double, xbt_cfgelm_string, xbt_cfgelm_host,
+ xbt_cfgelm_type_count
+} e_xbt_cfgelm_type_t;
/*----[ Memory management ]-----------------------------------------------*/
-gras_cfg_t gras_cfg_new (void);
-void gras_cfg_cpy(gras_cfg_t tocopy,
- /* OUT */ gras_cfg_t *whereto);
-void gras_cfg_free(gras_cfg_t *cfg);
-void gras_cfg_dump(const char *name,const char*indent,gras_cfg_t cfg);
+xbt_cfg_t xbt_cfg_new (void);
+void xbt_cfg_cpy(xbt_cfg_t tocopy,
+ /* OUT */ xbt_cfg_t *whereto);
+void xbt_cfg_free(xbt_cfg_t *cfg);
+void xbt_cfg_dump(const char *name,const char*indent,xbt_cfg_t cfg);
/*----[ Registering stuff ]-----------------------------------------------*/
/* Register a possible cell */
-void gras_cfg_register(gras_cfg_t cfg,
- const char *name, e_gras_cfgelm_type_t type,
+void xbt_cfg_register(xbt_cfg_t cfg,
+ const char *name, e_xbt_cfgelm_type_t type,
int min, int max);
/* Unregister a possible cell */
-gras_error_t gras_cfg_unregister(gras_cfg_t cfg, const char *name);
+xbt_error_t xbt_cfg_unregister(xbt_cfg_t cfg, const char *name);
/* Parse the configuration descriptor and register it */
/* Should be of the form "<name>:<min nb>_to_<max nb>_<type>", */
/* with type being one of 'string','int', 'host' or 'double' */
-gras_error_t gras_cfg_register_str(gras_cfg_t cfg, const char *entry);
+xbt_error_t xbt_cfg_register_str(xbt_cfg_t cfg, const char *entry);
/* Check that each cell have the right amount of elements */
-gras_error_t gras_cfg_check(gras_cfg_t cfg);
+xbt_error_t xbt_cfg_check(xbt_cfg_t cfg);
/* Get the type of this option in that repository */
-gras_error_t gras_cfg_get_type(gras_cfg_t cfg, const char *name,
- /* OUT */ e_gras_cfgelm_type_t *type);
+xbt_error_t xbt_cfg_get_type(xbt_cfg_t cfg, const char *name,
+ /* OUT */ e_xbt_cfgelm_type_t *type);
/*----[ Setting ]---------------------------------------------------------
- * gras_cfg_set_* functions.
+ * xbt_cfg_set_* functions.
*
* If the registered maximum is equal to 1, those functions remplace the
* current value with the provided one. If max>1, the provided value is
*
* string values are strdup'ed before use, so you have to free your copy */
-gras_error_t gras_cfg_set_vargs(gras_cfg_t cfg, va_list pa);
-gras_error_t gras_cfg_set(gras_cfg_t cfg, ...);
+xbt_error_t xbt_cfg_set_vargs(xbt_cfg_t cfg, va_list pa);
+xbt_error_t xbt_cfg_set(xbt_cfg_t cfg, ...);
/*
Add the cells described in a string to a typed hash.
*/
-gras_error_t gras_cfg_set_parse(gras_cfg_t cfg, const char *options);
+xbt_error_t xbt_cfg_set_parse(xbt_cfg_t cfg, const char *options);
/*
Set the value of the cell @name in @cfg with the provided value.
*/
-gras_error_t gras_cfg_set_int (gras_cfg_t cfg, const char *name,
+xbt_error_t xbt_cfg_set_int (xbt_cfg_t cfg, const char *name,
int val);
-gras_error_t gras_cfg_set_double(gras_cfg_t cfg, const char *name,
+xbt_error_t xbt_cfg_set_double(xbt_cfg_t cfg, const char *name,
double val);
-gras_error_t gras_cfg_set_string(gras_cfg_t cfg, const char *name,
+xbt_error_t xbt_cfg_set_string(xbt_cfg_t cfg, const char *name,
const char *val);
-gras_error_t gras_cfg_set_host (gras_cfg_t cfg, const char *name,
+xbt_error_t xbt_cfg_set_host (xbt_cfg_t cfg, const char *name,
const char *host,int port);
/*
Remove the provided value from the cell @name in @cfg.
*/
-gras_error_t gras_cfg_rm_int (gras_cfg_t cfg, const char *name,
+xbt_error_t xbt_cfg_rm_int (xbt_cfg_t cfg, const char *name,
int val);
-gras_error_t gras_cfg_rm_double(gras_cfg_t cfg, const char *name,
+xbt_error_t xbt_cfg_rm_double(xbt_cfg_t cfg, const char *name,
double val);
-gras_error_t gras_cfg_rm_string(gras_cfg_t cfg, const char *name,
+xbt_error_t xbt_cfg_rm_string(xbt_cfg_t cfg, const char *name,
const char *val);
-gras_error_t gras_cfg_rm_host (gras_cfg_t cfg, const char *name,
+xbt_error_t xbt_cfg_rm_host (xbt_cfg_t cfg, const char *name,
const char *host,int port);
/* rm every values */
-gras_error_t gras_cfg_empty(gras_cfg_t cfg, const char *name);
+xbt_error_t xbt_cfg_empty(xbt_cfg_t cfg, const char *name);
/*----[ Getting ]---------------------------------------------------------*/
/* Returns a pointer to the values actually stored in the cache. Do not */
/* modify them unless you really know what you're doing. */
-gras_error_t gras_cfg_get_int (gras_cfg_t cfg,
+xbt_error_t xbt_cfg_get_int (xbt_cfg_t cfg,
const char *name,
int *val);
-gras_error_t gras_cfg_get_double(gras_cfg_t cfg,
+xbt_error_t xbt_cfg_get_double(xbt_cfg_t cfg,
const char *name,
double *val);
-gras_error_t gras_cfg_get_string(gras_cfg_t cfg,
+xbt_error_t xbt_cfg_get_string(xbt_cfg_t cfg,
const char *name,
char **val);
-gras_error_t gras_cfg_get_host (gras_cfg_t cfg,
+xbt_error_t xbt_cfg_get_host (xbt_cfg_t cfg,
const char *name,
char **host,
int *port);
-gras_error_t gras_cfg_get_dynar (gras_cfg_t cfg,
+xbt_error_t xbt_cfg_get_dynar (xbt_cfg_t cfg,
const char *name,
- /* OUT */ gras_dynar_t *dynar);
+ /* OUT */ xbt_dynar_t *dynar);
END_DECL
-#endif /* _GRAS_CONFIG_H_ */
+#endif /* _XBT_CONFIG_H_ */
/* $Id$ */
-/* gras/dict.h -- api to a generic dictionary */
+/* xbt/dict.h -- api to a generic dictionary */
/* Authors: Martin Quinson */
/* Copyright (C) 2003 the OURAGAN project. */
under the terms of the license (GNU LGPL) which comes with this package. */
-#ifndef _GRAS_DICT_H
-#define _GRAS_DICT_H
+#ifndef _XBT_DICT_H
+#define _XBT_DICT_H
#ifdef __cplusplus
extern "C"
#endif
/*####[ Type definition ]####################################################*/
-typedef struct gras_dict_ *gras_dict_t;
+typedef struct xbt_dict_ *xbt_dict_t;
/*####[ Simple dict functions ]#############################################*/
-gras_dict_t gras_dict_new(void);
-void gras_dict_free(gras_dict_t *dict);
+xbt_dict_t xbt_dict_new(void);
+void xbt_dict_free(xbt_dict_t *dict);
-void gras_dict_set (gras_dict_t head,
+void xbt_dict_set (xbt_dict_t head,
const char *key,
void *data,
void_f_pvoid_t *free_ctn);
-void gras_dict_set_ext(gras_dict_t head,
+void xbt_dict_set_ext(xbt_dict_t head,
const char *key,
int key_len,
void *data,
void_f_pvoid_t *free_ctn);
-/*----[ gras_dict_get ]------------------------------------------------------*/
+/*----[ xbt_dict_get ]------------------------------------------------------*/
/* Search the given #key#. data=NULL when not found. */
/* Returns true if anything went ok, and false on internal error. */
/*---------------------------------------------------------------------------*/
-gras_error_t gras_dict_get(gras_dict_t head,const char *key,
+xbt_error_t xbt_dict_get(xbt_dict_t head,const char *key,
/* OUT */void **data);
-gras_error_t gras_dict_get_ext(gras_dict_t head,const char *key,
+xbt_error_t xbt_dict_get_ext(xbt_dict_t head,const char *key,
int key_len,
/* OUT */void **data);
-/*----[ gras_dict_remove ]---------------------------------------------------*/
+/*----[ xbt_dict_remove ]---------------------------------------------------*/
/* Remove the entry associated with the given #key#. */
/* Returns if ok. Removing a non-existant key is ok. */
/*---------------------------------------------------------------------------*/
-gras_error_t gras_dict_remove(gras_dict_t head,const char *key);
+xbt_error_t xbt_dict_remove(xbt_dict_t head,const char *key);
-gras_error_t gras_dict_remove_ext(gras_dict_t head,
+xbt_error_t xbt_dict_remove_ext(xbt_dict_t head,
const char *key, int key_len);
-/*----[ gras_dict_dump ]-----------------------------------------------------*/
+/*----[ xbt_dict_dump ]-----------------------------------------------------*/
/* Outputs the content of the structure. (for debuging purpose) */
/* #output# is a function to output the data.If NULL, data won't be displayed*/
/*---------------------------------------------------------------------------*/
-void gras_dict_dump(gras_dict_t head,
+void xbt_dict_dump(xbt_dict_t head,
void (*output)(void*));
-/*----[ gras_dict_print ]----------------------------------------------------*/
+/*----[ xbt_dict_print ]----------------------------------------------------*/
/* To dump multicache, this function dump a cache */
/*---------------------------------------------------------------------------*/
-void gras_dict_print(void *data);
+void xbt_dict_print(void *data);
/* To dump multicache, this one dumps a string */
-void gras_dict_prints(void *data);
+void xbt_dict_prints(void *data);
/*####[ Multi cache functions ]##############################################*/
/* than their simple cache counterpart. */
/*###############################"###########################################*/
-/*----[ gras_multidict_free ]------------------------------------------------*/
-/* This function does not exist. Use gras_dict_free instead. */
+/*----[ xbt_multidict_free ]------------------------------------------------*/
+/* This function does not exist. Use xbt_dict_free instead. */
/*---------------------------------------------------------------------------*/
-/*----[ gras_multidict_set ]-------------------------------------------------*/
+/*----[ xbt_multidict_set ]-------------------------------------------------*/
/* Insert the data in the structure under the #keycount# #key#s. */
/* The key are destroyed in the process. Think to strdup it before. */
/* Returns if it was ok or not */
/*---------------------------------------------------------------------------*/
-gras_error_t gras_multidict_set(gras_dict_t *head,
+xbt_error_t xbt_multidict_set(xbt_dict_t *head,
int keycount,char **key,
void *data,void (*free_ctn)(void*));
-gras_error_t gras_multidict_set_ext(gras_dict_t *head,
+xbt_error_t xbt_multidict_set_ext(xbt_dict_t *head,
int keycount,char **key,int *key_len,
void *data,void_f_pvoid_t *free_ctn);
-/*----[ gras_multidict_get ]-------------------------------------------------*/
+/*----[ xbt_multidict_get ]-------------------------------------------------*/
/* Search the given #key#. data=NULL when not found. */
/* Returns true if anything went ok, and false on internal error. */
/*---------------------------------------------------------------------------*/
-gras_error_t gras_multidict_get(gras_dict_t head,
+xbt_error_t xbt_multidict_get(xbt_dict_t head,
int keycount,const char **key,
/* OUT */void **data);
-gras_error_t gras_multidict_get_ext(gras_dict_t head,
+xbt_error_t xbt_multidict_get_ext(xbt_dict_t head,
int keycount,const char **key,int *key_len,
/* OUT */void **data);
-/*----[ gras_multidict_remove ]----------------------------------------------*/
+/*----[ xbt_multidict_remove ]----------------------------------------------*/
/* Remove the entry associated with the given #key#. */
/* Returns if ok. Removing a non-existant key is ok. */
/*---------------------------------------------------------------------------*/
-gras_error_t gras_multidict_remove(gras_dict_t head,
+xbt_error_t xbt_multidict_remove(xbt_dict_t head,
int keycount,const char **key);
-gras_error_t gras_multidict_remove_ext(gras_dict_t head,
+xbt_error_t xbt_multidict_remove_ext(xbt_dict_t head,
int keycount,const char **key,int *key_len);
/*####[ Cache cursor functions ]#############################################*/
/* To traverse (simple) caches */
/* Don't add or remove entries to the cache while traversing !!! */
/*###########################################################################*/
-typedef struct gras_dict_cursor_ *gras_dict_cursor_t;
+typedef struct xbt_dict_cursor_ *xbt_dict_cursor_t;
/* creator/destructor */
-gras_dict_cursor_t gras_dict_cursor_new(const gras_dict_t head);
-void gras_dict_cursor_free(gras_dict_cursor_t *cursor);
+xbt_dict_cursor_t xbt_dict_cursor_new(const xbt_dict_t head);
+void xbt_dict_cursor_free(xbt_dict_cursor_t *cursor);
/* back to first element
it is not enough to reinit the cache after an add/remove in cache*/
-void gras_dict_cursor_rewind(gras_dict_cursor_t cursor);
+void xbt_dict_cursor_rewind(xbt_dict_cursor_t cursor);
-gras_error_t gras_dict_cursor_get_key (gras_dict_cursor_t cursor,
+xbt_error_t xbt_dict_cursor_get_key (xbt_dict_cursor_t cursor,
/*OUT*/char **key);
-gras_error_t gras_dict_cursor_get_data (gras_dict_cursor_t cursor,
+xbt_error_t xbt_dict_cursor_get_data (xbt_dict_cursor_t cursor,
/*OUT*/void **data);
-void gras_dict_cursor_first (const gras_dict_t dict,
- gras_dict_cursor_t *cursor);
-void gras_dict_cursor_step (gras_dict_cursor_t cursor);
-int gras_dict_cursor_get_or_free (gras_dict_cursor_t *cursor,
+void xbt_dict_cursor_first (const xbt_dict_t dict,
+ xbt_dict_cursor_t *cursor);
+void xbt_dict_cursor_step (xbt_dict_cursor_t cursor);
+int xbt_dict_cursor_get_or_free (xbt_dict_cursor_t *cursor,
char **key,
void **data);
-#define gras_dict_foreach(dict,cursor,key,data) \
- for (cursor=NULL, gras_dict_cursor_first((dict),&(cursor)) ; \
- gras_dict_cursor_get_or_free(&(cursor),&(key),(void**)(&data));\
- gras_dict_cursor_step(cursor) )
+#define xbt_dict_foreach(dict,cursor,key,data) \
+ for (cursor=NULL, xbt_dict_cursor_first((dict),&(cursor)) ; \
+ xbt_dict_cursor_get_or_free(&(cursor),&(key),(void**)(&data));\
+ xbt_dict_cursor_step(cursor) )
#ifdef __cplusplus
}
#endif
-#endif /* _GRAS_DICT_H */
+#endif /* _XBT_DICT_H */
/* 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. */
-#ifndef _GRAS_DYNAR_H
-#define _GRAS_DYNAR_H
+#ifndef _XBT_DYNAR_H
+#define _XBT_DYNAR_H
#include "xbt/misc.h" /* BEGIN_DECL */
BEGIN_DECL
-typedef struct gras_dynar_s *gras_dynar_t;
+typedef struct xbt_dynar_s *xbt_dynar_t;
/* pointer to a function freeing something */
typedef void (void_f_ppvoid_t)(void**);
typedef void (void_f_pvoid_t) (void*);
-gras_dynar_t gras_dynar_new(unsigned long elm_size,
+xbt_dynar_t xbt_dynar_new(unsigned long elm_size,
void_f_pvoid_t *free_func);
-void gras_dynar_free(gras_dynar_t *dynar);
-void gras_dynar_free_container(gras_dynar_t *dynar);
+void xbt_dynar_free(xbt_dynar_t *dynar);
+void xbt_dynar_free_container(xbt_dynar_t *dynar);
-unsigned long gras_dynar_length(const gras_dynar_t dynar);
-void gras_dynar_reset(gras_dynar_t dynar);
+unsigned long xbt_dynar_length(const xbt_dynar_t dynar);
+void xbt_dynar_reset(xbt_dynar_t dynar);
/* regular array functions */
-void gras_dynar_get_cpy(const gras_dynar_t dynar, int idx, void *const dst);
-void *gras_dynar_get_ptr(const gras_dynar_t dynar,
+void xbt_dynar_get_cpy(const xbt_dynar_t dynar, int idx, void *const dst);
+void *xbt_dynar_get_ptr(const xbt_dynar_t dynar,
const int idx);
-#define gras_dynar_get_as(dynar,idx,type) *(type*)gras_dynar_get_ptr(dynar,idx)
+#define xbt_dynar_get_as(dynar,idx,type) *(type*)xbt_dynar_get_ptr(dynar,idx)
-void gras_dynar_set(gras_dynar_t dynar, int idx, const void *src);
-void gras_dynar_replace(gras_dynar_t dynar,
+void xbt_dynar_set(xbt_dynar_t dynar, int idx, const void *src);
+void xbt_dynar_replace(xbt_dynar_t dynar,
int idx, const void *object);
/* perl array function */
-void gras_dynar_insert_at(gras_dynar_t dynar,
+void xbt_dynar_insert_at(xbt_dynar_t dynar,
int idx, const void *src);
-void gras_dynar_remove_at(gras_dynar_t dynar,
+void xbt_dynar_remove_at(xbt_dynar_t dynar,
int idx, void *object);
-void gras_dynar_push (gras_dynar_t dynar, const void *src);
-void gras_dynar_pop (gras_dynar_t dynar, void *const dst);
-void gras_dynar_unshift (gras_dynar_t dynar, const void *src);
-void gras_dynar_shift (gras_dynar_t dynar, void *const dst);
-void gras_dynar_map (const gras_dynar_t dynar, void_f_pvoid_t *operator);
+void xbt_dynar_push (xbt_dynar_t dynar, const void *src);
+void xbt_dynar_pop (xbt_dynar_t dynar, void *const dst);
+void xbt_dynar_unshift (xbt_dynar_t dynar, const void *src);
+void xbt_dynar_shift (xbt_dynar_t dynar, void *const dst);
+void xbt_dynar_map (const xbt_dynar_t dynar, void_f_pvoid_t *operator);
/* speed-optimized versions */
-void *gras_dynar_insert_at_ptr(gras_dynar_t const dynar,
+void *xbt_dynar_insert_at_ptr(xbt_dynar_t const dynar,
const int idx);
-void *gras_dynar_push_ptr(gras_dynar_t dynar);
-void *gras_dynar_pop_ptr(gras_dynar_t dynar);
+void *xbt_dynar_push_ptr(xbt_dynar_t dynar);
+void *xbt_dynar_pop_ptr(xbt_dynar_t dynar);
-#define gras_dynar_insert_at_as(dynar,idx,type,value) *(type*)gras_dynar_insert_at_ptr(dynar,idx)=value
-#define gras_dynar_push_as(dynar,type,value) *(type*)gras_dynar_push_ptr(dynar)=value
-#define gras_dynar_pop_as(dynar,type) *(type*)gras_dynar_pop_ptr(dynar)
+#define xbt_dynar_insert_at_as(dynar,idx,type,value) *(type*)xbt_dynar_insert_at_ptr(dynar,idx)=value
+#define xbt_dynar_push_as(dynar,type,value) *(type*)xbt_dynar_push_ptr(dynar)=value
+#define xbt_dynar_pop_as(dynar,type) *(type*)xbt_dynar_pop_ptr(dynar)
/* cursor functions */
-void gras_dynar_cursor_first (const gras_dynar_t dynar, int *cursor);
-void gras_dynar_cursor_step (const gras_dynar_t dynar, int *cursor);
-int gras_dynar_cursor_get (const gras_dynar_t dynar, int *cursor, void *whereto);
+void xbt_dynar_cursor_first (const xbt_dynar_t dynar, int *cursor);
+void xbt_dynar_cursor_step (const xbt_dynar_t dynar, int *cursor);
+int xbt_dynar_cursor_get (const xbt_dynar_t dynar, int *cursor, void *whereto);
/**
- * gras_dynar_foreach:
+ * xbt_dynar_foreach:
* @_dynar: what to iterate over
* @_cursor: an integer used as cursor
* @_data:
* Iterates over the whole dynar. Example:
*
* <programlisting>
- * gras_dynar_t *dyn;
+ * xbt_dynar_t *dyn;
* int cpt;
* string *str;
- * gras_dynar_foreach (dyn,cpt,str) {
+ * xbt_dynar_foreach (dyn,cpt,str) {
* printf("Seen %s\n",str);
* }</programlisting>
*/
-#define gras_dynar_foreach(_dynar,_cursor,_data) \
- for (gras_dynar_cursor_first(_dynar,&(_cursor)) ; \
- gras_dynar_cursor_get(_dynar,&(_cursor),&_data) ; \
- gras_dynar_cursor_step(_dynar,&(_cursor)) )
+#define xbt_dynar_foreach(_dynar,_cursor,_data) \
+ for (xbt_dynar_cursor_first(_dynar,&(_cursor)) ; \
+ xbt_dynar_cursor_get(_dynar,&(_cursor),&_data) ; \
+ xbt_dynar_cursor_step(_dynar,&(_cursor)) )
/*
- for (gras_dynar_length(_dynar) && (_gras_dynar_cursor_first(_dynar,&_cursor), \
+ for (xbt_dynar_length(_dynar) && (_xbt_dynar_cursor_first(_dynar,&_cursor), \
1); \
- gras_dynar_length(_dynar) && gras_dynar_cursor_get(_dynar,&_cursor,&_data); \
- gras_dynar_cursor_step(_dynar,&_cursor))
+ xbt_dynar_length(_dynar) && xbt_dynar_cursor_get(_dynar,&_cursor,&_data); \
+ xbt_dynar_cursor_step(_dynar,&_cursor))
*/
-void gras_dynar_cursor_rm(gras_dynar_t dynar,
+void xbt_dynar_cursor_rm(xbt_dynar_t dynar,
int *const cursor);
END_DECL
-#endif /* _GRAS_DYNAR_H */
+#endif /* _XBT_DYNAR_H */
/* $Id$ */
-/* gras/error.h - Error tracking support */
+/* xbt/error.h - Error tracking support */
/* Authors: Martin Quinson */
/* Copyright (C) 2003,2004 da GRAS posse. */
under the terms of the license (GNU LGPL) which comes with this package. */
-#ifndef GRAS_ERROR_H
-#define GRAS_ERROR_H
+#ifndef XBT_ERROR_H
+#define XBT_ERROR_H
#include <stdio.h> /* FIXME: Get rid of it */
remote_timeout_error,
remote_thread_error,
remote_unknown_error
-} gras_error_t;
+} xbt_error_t;
-/*@observer@*/ const char *gras_error_name(gras_error_t errcode);
+/*@observer@*/ const char *xbt_error_name(xbt_error_t errcode);
#define TRY(a) do { \
if ((errcode=a) != no_error) { \
fprintf (stderr, "%s:%d: '%s' error raising...\n", \
__FILE__,__LINE__, \
- gras_error_name(errcode)); \
+ xbt_error_name(errcode)); \
return errcode; \
} } while (0)
if ((errcode=a) != no_error) { \
fprintf(stderr,"%s:%d: Got '%s' error !\n", \
__FILE__,__LINE__, \
- gras_error_name(errcode)); \
+ xbt_error_name(errcode)); \
fflush(stdout); \
- gras_abort(); \
+ xbt_abort(); \
} } while(0)
#define TRYEXPECT(action,expected_error) do { \
errcode=action; \
if (errcode != expected_error) { \
fprintf(stderr,"Got error %s (instead of %s expected)\n", \
- gras_error_name(errcode), \
- gras_error_name(expected_error)); \
- gras_abort(); \
+ xbt_error_name(errcode), \
+ xbt_error_name(expected_error)); \
+ xbt_abort(); \
} \
} while(0)
} while(0)
#if 0 /* FIXME: We don't use backtrace. Drop it? */
-#define _GRAS_ERR_PRE do { \
+#define _XBT_ERR_PRE do { \
void *_gs_array[30]; \
size_t _gs_size= backtrace (_gs_array, 30); \
char **_gs_strings= backtrace_symbols (_gs_array, _gs_size); \
size_t _gs_i;
-#define _GRAS_ERR_POST(code) \
+#define _XBT_ERR_POST(code) \
fprintf(stderr,"Backtrace follows\n"); \
for (_gs_i = 0; _gs_i < _gs_size; _gs_i++) \
fprintf (stderr," %s\n", _gs_strings[_gs_i]); \
} while (0)
#else /* if 0 */
-#define _GRAS_ERR_PRE do {
-#define _GRAS_ERR_POST(code) \
+#define _XBT_ERR_PRE do {
+#define _XBT_ERR_POST(code) \
return code; \
} while (0)
#endif
-#define RAISE0(code,fmt) _GRAS_ERR_PRE \
+#define RAISE0(code,fmt) _XBT_ERR_PRE \
fprintf(stderr,"%s:%d:%s: " fmt "\n", \
__FILE__,__LINE__,__FUNCTION__); \
- _GRAS_ERR_POST(code)
-#define RAISE1(code,fmt,a1) _GRAS_ERR_PRE \
+ _XBT_ERR_POST(code)
+#define RAISE1(code,fmt,a1) _XBT_ERR_PRE \
fprintf(stderr,"%s:%d:%s: " fmt "\n", \
__FILE__,__LINE__,__FUNCTION__,a1); \
- _GRAS_ERR_POST(code)
-#define RAISE2(code,fmt,a1,a2) _GRAS_ERR_PRE \
+ _XBT_ERR_POST(code)
+#define RAISE2(code,fmt,a1,a2) _XBT_ERR_PRE \
fprintf(stderr,"%s:%d:%s: " fmt "\n", \
__FILE__,__LINE__,__FUNCTION__,a1,a2); \
- _GRAS_ERR_POST(code)
-#define RAISE3(code,fmt,a1,a2,a3) _GRAS_ERR_PRE \
+ _XBT_ERR_POST(code)
+#define RAISE3(code,fmt,a1,a2,a3) _XBT_ERR_PRE \
fprintf(stderr,"%s:%d:%s: " fmt "\n", \
__FILE__,__LINE__,__FUNCTION__,a1,a2,a3); \
- _GRAS_ERR_POST(code)
-#define RAISE4(code,fmt,a1,a2,a3,a4) _GRAS_ERR_PRE \
+ _XBT_ERR_POST(code)
+#define RAISE4(code,fmt,a1,a2,a3,a4) _XBT_ERR_PRE \
fprintf(stderr,"%s:%d:%s: " fmt "\n", \
__FILE__,__LINE__,__FUNCTION__,a1,a2,a3,a4); \
- _GRAS_ERR_POST(code)
-#define RAISE5(code,fmt,a1,a2,a3,a4,a5) _GRAS_ERR_PRE \
+ _XBT_ERR_POST(code)
+#define RAISE5(code,fmt,a1,a2,a3,a4,a5) _XBT_ERR_PRE \
fprintf(stderr,"%s:%d:%s: " fmt "\n", \
__FILE__,__LINE__,__FUNCTION__,a1,a2,a3,a4,a5); \
- _GRAS_ERR_POST(code)
-#define RAISE6(code,fmt,a1,a2,a3,a4,a5,a6) _GRAS_ERR_PRE \
+ _XBT_ERR_POST(code)
+#define RAISE6(code,fmt,a1,a2,a3,a4,a5,a6) _XBT_ERR_PRE \
fprintf(stderr,"%s:%d:%s: " fmt "\n", \
__FILE__,__LINE__,__FUNCTION__,a1,a2,a3,a4,a5,a6); \
- _GRAS_ERR_POST(code)
+ _XBT_ERR_POST(code)
//#define RAISE_MALLOC RAISE0(malloc_error,"Malloc error")
#define RAISE_IMPOSSIBLE RAISE0(unknown_error,"The Impossible did happen")
#define RAISE_UNIMPLEMENTED RAISE1(unknown_error,"Function %s unimplemented",__FUNCTION__)
#ifdef NDEBUG
-#define gras_assert(cond)
-#define gras_assert0(cond,msg)
-#define gras_assert1(cond,msg,a)
-#define gras_assert2(cond,msg,a,b)
-#define gras_assert3(cond,msg,a,b,c)
-#define gras_assert4(cond,msg,a,b,c,d)
-#define gras_assert5(cond,msg,a,b,c,d,e)
-#define gras_assert6(cond,msg,a,b,c,d,e,f)
+#define xbt_assert(cond)
+#define xbt_assert0(cond,msg)
+#define xbt_assert1(cond,msg,a)
+#define xbt_assert2(cond,msg,a,b)
+#define xbt_assert3(cond,msg,a,b,c)
+#define xbt_assert4(cond,msg,a,b,c,d)
+#define xbt_assert5(cond,msg,a,b,c,d,e)
+#define xbt_assert6(cond,msg,a,b,c,d,e,f)
#else
-#define gras_assert(cond) if (!(cond)) { CRITICAL1("Assertion %s failed", #cond); gras_abort(); }
-#define gras_assert0(cond,msg) if (!(cond)) { CRITICAL0(msg); gras_abort(); }
-#define gras_assert1(cond,msg,a) if (!(cond)) { CRITICAL1(msg,a); gras_abort(); }
-#define gras_assert2(cond,msg,a,b) if (!(cond)) { CRITICAL2(msg,a,b); gras_abort(); }
-#define gras_assert3(cond,msg,a,b,c) if (!(cond)) { CRITICAL3(msg,a,b,c); gras_abort(); }
-#define gras_assert4(cond,msg,a,b,c,d) if (!(cond)) { CRITICAL4(msg,a,b,c,d); gras_abort(); }
-#define gras_assert5(cond,msg,a,b,c,d,e) if (!(cond)) { CRITICAL5(msg,a,b,c,d,e); gras_abort(); }
-#define gras_assert6(cond,msg,a,b,c,d,e,f) if (!(cond)) { CRITICAL6(msg,a,b,c,d,e,f); gras_abort(); }
+#define xbt_assert(cond) if (!(cond)) { CRITICAL1("Assertion %s failed", #cond); xbt_abort(); }
+#define xbt_assert0(cond,msg) if (!(cond)) { CRITICAL0(msg); xbt_abort(); }
+#define xbt_assert1(cond,msg,a) if (!(cond)) { CRITICAL1(msg,a); xbt_abort(); }
+#define xbt_assert2(cond,msg,a,b) if (!(cond)) { CRITICAL2(msg,a,b); xbt_abort(); }
+#define xbt_assert3(cond,msg,a,b,c) if (!(cond)) { CRITICAL3(msg,a,b,c); xbt_abort(); }
+#define xbt_assert4(cond,msg,a,b,c,d) if (!(cond)) { CRITICAL4(msg,a,b,c,d); xbt_abort(); }
+#define xbt_assert5(cond,msg,a,b,c,d,e) if (!(cond)) { CRITICAL5(msg,a,b,c,d,e); xbt_abort(); }
+#define xbt_assert6(cond,msg,a,b,c,d,e,f) if (!(cond)) { CRITICAL6(msg,a,b,c,d,e,f); xbt_abort(); }
#endif
-void gras_die(const char *msg);
+void xbt_die(const char *msg);
-#define DIE_IMPOSSIBLE gras_assert0(0,"The Impossible did happen (yet again)")
-#define gras_assert_error(a) gras_assert1(errcode == (a), "Error %s unexpected",gras_error_name(errcode))
+#define DIE_IMPOSSIBLE xbt_assert0(0,"The Impossible did happen (yet again)")
+#define xbt_assert_error(a) xbt_assert1(errcode == (a), "Error %s unexpected",xbt_error_name(errcode))
END_DECL
-#endif /* GRAS_ERROR_H */
+#endif /* XBT_ERROR_H */
/* 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. */
-/* GRAS_LOG_MAYDAY: define this to replace the logging facilities with basic
+/* XBT_LOG_MAYDAY: define this to replace the logging facilities with basic
printf function. Useful to debug the logging facilities themselves */
-#undef GRAS_LOG_MAYDAY
-/*#define GRAS_LOG_MAYDAY*/
+#undef XBT_LOG_MAYDAY
+/*#define XBT_LOG_MAYDAY*/
-#ifndef _GRAS_LOG_H_
-#define _GRAS_LOG_H_
+#ifndef _XBT_LOG_H_
+#define _XBT_LOG_H_
#include <stdarg.h>
#include "xbt/sysdep.h"
/**
- * e_gras_log_priority_t:
- * @gras_log_priority_none: used internally (don't poke with)
- * @gras_log_priority_debug: crufty output
- * @gras_log_priority_verbose: verbose output for the user wanting more
- * @gras_log_priority_info: output about the regular functionning
- * @gras_log_priority_warning: minor issue encountered
- * @gras_log_priority_error: issue encountered
- * @gras_log_priority_critical: major issue encountered
- * @gras_log_priority_infinite: value for GRAS_LOG_STATIC_THRESHOLD to not log
- * @gras_log_priority_uninitialized: used internally (don't poke with)
+ * e_xbt_log_priority_t:
+ * @xbt_log_priority_none: used internally (don't poke with)
+ * @xbt_log_priority_debug: crufty output
+ * @xbt_log_priority_verbose: verbose output for the user wanting more
+ * @xbt_log_priority_info: output about the regular functionning
+ * @xbt_log_priority_warning: minor issue encountered
+ * @xbt_log_priority_error: issue encountered
+ * @xbt_log_priority_critical: major issue encountered
+ * @xbt_log_priority_infinite: value for XBT_LOG_STATIC_THRESHOLD to not log
+ * @xbt_log_priority_uninitialized: used internally (don't poke with)
*
* The different existing priorities.
*/
typedef enum {
- gras_log_priority_none = 0,
- gras_log_priority_trace = 1,
- gras_log_priority_debug = 2,
- gras_log_priority_verbose = 3,
- gras_log_priority_info = 4,
- gras_log_priority_warning = 5,
- gras_log_priority_error = 6,
- gras_log_priority_critical = 7,
-
- gras_log_priority_infinite = 8,
-
- gras_log_priority_uninitialized = -1
-} e_gras_log_priority_t;
+ xbt_log_priority_none = 0,
+ xbt_log_priority_trace = 1,
+ xbt_log_priority_debug = 2,
+ xbt_log_priority_verbose = 3,
+ xbt_log_priority_info = 4,
+ xbt_log_priority_warning = 5,
+ xbt_log_priority_error = 6,
+ xbt_log_priority_critical = 7,
+
+ xbt_log_priority_infinite = 8,
+
+ xbt_log_priority_uninitialized = -1
+} e_xbt_log_priority_t;
/**
/**
- * GRAS_LOG_STATIC_THRESHOLD:
+ * XBT_LOG_STATIC_THRESHOLD:
*
- * All logging with priority < GRAS_LOG_STATIC_THRESHOLD is disabled at
+ * All logging with priority < XBT_LOG_STATIC_THRESHOLD is disabled at
* compile time, i.e., compiled out.
*/
#ifdef NLOG
-# define GRAS_LOG_STATIC_THRESHOLD gras_log_priority_infinite
+# define XBT_LOG_STATIC_THRESHOLD xbt_log_priority_infinite
#else
# ifdef NDEBUG
-# define GRAS_LOG_STATIC_THRESHOLD gras_log_priority_verbose
+# define XBT_LOG_STATIC_THRESHOLD xbt_log_priority_verbose
# else /* !NLOG && !NDEBUG */
-# ifndef GRAS_LOG_STATIC_THRESHOLD
-# define GRAS_LOG_STATIC_THRESHOLD gras_log_priority_none
-# endif /* !GRAS_LOG_STATIC_THRESHOLD */
+# ifndef XBT_LOG_STATIC_THRESHOLD
+# define XBT_LOG_STATIC_THRESHOLD xbt_log_priority_none
+# endif /* !XBT_LOG_STATIC_THRESHOLD */
# endif /* NDEBUG */
#endif /* !defined(NLOG) */
/* Transforms a category name to a global variable name. */
-#define _GRAS_LOGV(cat) _GRAS_LOG_CONCAT(_gras_this_log_category_does_not_exist__, cat)
-#define _GRAS_LOG_CONCAT(x,y) x ## y
+#define _XBT_LOGV(cat) _XBT_LOG_CONCAT(_gras_this_log_category_does_not_exist__, cat)
+#define _XBT_LOG_CONCAT(x,y) x ## y
/* The root of the category hierarchy. */
-#define GRAS_LOG_ROOT_CAT root
+#define XBT_LOG_ROOT_CAT root
/**
- * GRAS_LOG_NEW_SUBCATEGORY:
+ * XBT_LOG_NEW_SUBCATEGORY:
* @catName: name of new category
* @parent: father of the new category in the tree
* @desc: string describing the purpose of this category
*
* Defines a new subcategory of the parent.
*/
-#define GRAS_LOG_NEW_SUBCATEGORY(catName, parent, desc) \
- extern s_gras_log_category_t _GRAS_LOGV(parent); \
- s_gras_log_category_t _GRAS_LOGV(catName) = { \
- &_GRAS_LOGV(parent), 0, 0, \
- #catName, gras_log_priority_uninitialized, 1, \
+#define XBT_LOG_NEW_SUBCATEGORY(catName, parent, desc) \
+ extern s_xbt_log_category_t _XBT_LOGV(parent); \
+ s_xbt_log_category_t _XBT_LOGV(catName) = { \
+ &_XBT_LOGV(parent), 0, 0, \
+ #catName, xbt_log_priority_uninitialized, 1, \
0, 1 \
}
/**
- * GRAS_LOG_NEW_CATEGORY:
+ * XBT_LOG_NEW_CATEGORY:
* @catName: name of new category
* @desc: string describing the purpose of this category
*
* Creates a new subcategory of the root category.
*/
-#define GRAS_LOG_NEW_CATEGORY(catName,desc) GRAS_LOG_NEW_SUBCATEGORY(catName, GRAS_LOG_ROOT_CAT, desc)
+#define XBT_LOG_NEW_CATEGORY(catName,desc) XBT_LOG_NEW_SUBCATEGORY(catName, XBT_LOG_ROOT_CAT, desc)
/**
- * GRAS_LOG_DEFAULT_CATEGORY:
+ * XBT_LOG_DEFAULT_CATEGORY:
* @cname: name of the cat
*
* Indicates which category is the default one.
*/
-#if defined(GRAS_LOG_MAYDAY) /*|| defined (NLOG) * turning logging off */
-# define GRAS_LOG_DEFAULT_CATEGORY(cname)
+#if defined(XBT_LOG_MAYDAY) /*|| defined (NLOG) * turning logging off */
+# define XBT_LOG_DEFAULT_CATEGORY(cname)
#else
-# define GRAS_LOG_DEFAULT_CATEGORY(cname) \
- static gras_log_category_t _GRAS_LOGV(default) = &_GRAS_LOGV(cname)
+# define XBT_LOG_DEFAULT_CATEGORY(cname) \
+ static xbt_log_category_t _XBT_LOGV(default) = &_XBT_LOGV(cname)
#endif
/**
- * GRAS_LOG_NEW_DEFAULT_CATEGORY:
+ * XBT_LOG_NEW_DEFAULT_CATEGORY:
* @cname: name of the cat
* @desc: string describing the purpose of this category
*
* Creates a new subcategory of the root category and makes it the default
* (used by macros that don't explicitly specify a category).
*/
-#define GRAS_LOG_NEW_DEFAULT_CATEGORY(cname,desc) \
- GRAS_LOG_NEW_CATEGORY(cname,desc); \
- GRAS_LOG_DEFAULT_CATEGORY(cname)
+#define XBT_LOG_NEW_DEFAULT_CATEGORY(cname,desc) \
+ XBT_LOG_NEW_CATEGORY(cname,desc); \
+ XBT_LOG_DEFAULT_CATEGORY(cname)
/**
- * GRAS_LOG_NEW_DEFAULT_SUBCATEGORY:
+ * XBT_LOG_NEW_DEFAULT_SUBCATEGORY:
* @cname: name of the cat
* @parent: name of the parent
* @desc: string describing the purpose of this category
* Creates a new subcategory of the parent category and makes it the default
* (used by macros that don't explicitly specify a category).
*/
-#define GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(cname, parent, desc) \
- GRAS_LOG_NEW_SUBCATEGORY(cname, parent, desc); \
- GRAS_LOG_DEFAULT_CATEGORY(cname)
+#define XBT_LOG_NEW_DEFAULT_SUBCATEGORY(cname, parent, desc) \
+ XBT_LOG_NEW_SUBCATEGORY(cname, parent, desc); \
+ XBT_LOG_DEFAULT_CATEGORY(cname)
/**
- * GRAS_LOG_EXTERNAL_CATEGORY:
+ * XBT_LOG_EXTERNAL_CATEGORY:
* @cname: name of the cat
*
* Indicates that a category you'll use in this file (to get subcategories of it,
* for example) really lives in another file.
*/
-#define GRAS_LOG_EXTERNAL_CATEGORY(cname) \
- extern s_gras_log_category_t _GRAS_LOGV(cname)
+#define XBT_LOG_EXTERNAL_CATEGORY(cname) \
+ extern s_xbt_log_category_t _XBT_LOGV(cname)
/* Functions you may call */
-extern void gras_log_control_set(const char* cs);
+extern void xbt_log_control_set(const char* cs);
/* Forward declarations */
-typedef struct gras_log_appender_s s_gras_log_appender_t,*gras_log_appender_t;
-typedef struct gras_log_event_s s_gras_log_event_t, *gras_log_event_t;
-typedef struct gras_log_category_s s_gras_log_category_t,*gras_log_category_t;
+typedef struct xbt_log_appender_s s_xbt_log_appender_t,*xbt_log_appender_t;
+typedef struct xbt_log_event_s s_xbt_log_event_t, *xbt_log_event_t;
+typedef struct xbt_log_category_s s_xbt_log_category_t,*xbt_log_category_t;
/**
* Do NOT access any members of this structure directly. FIXME: move to private?
*/
-struct gras_log_category_s {
- gras_log_category_t parent;
-/*@null@*/ gras_log_category_t firstChild;
-/*@null@*/ gras_log_category_t nextSibling;
+struct xbt_log_category_s {
+ xbt_log_category_t parent;
+/*@null@*/ xbt_log_category_t firstChild;
+/*@null@*/ xbt_log_category_t nextSibling;
const char *name;
int threshold;
int isThreshInherited;
-/*@null@*/ gras_log_appender_t appender;
+/*@null@*/ xbt_log_appender_t appender;
int willLogToParent;
/* TODO: Formats? */
};
-struct gras_log_appender_s {
- void (*do_append) (gras_log_appender_t thisLogAppender,
- gras_log_event_t event, const char *fmt);
+struct xbt_log_appender_s {
+ void (*do_append) (xbt_log_appender_t thisLogAppender,
+ xbt_log_event_t event, const char *fmt);
void *appender_data;
};
-struct gras_log_event_s {
- gras_log_category_t cat;
- e_gras_log_priority_t priority;
+struct xbt_log_event_s {
+ xbt_log_category_t cat;
+ e_xbt_log_priority_t priority;
const char* fileName;
const char* functionName;
int lineNum;
};
/**
- * gras_log_threshold_set:
+ * xbt_log_threshold_set:
* @cat: the category (not only its name, but the variable)
* @thresholdPriority: the priority
*
* Programatically alters a category's threshold priority (don't use).
*/
-extern void gras_log_threshold_set(gras_log_category_t cat,
- e_gras_log_priority_t thresholdPriority);
+extern void xbt_log_threshold_set(xbt_log_category_t cat,
+ e_xbt_log_priority_t thresholdPriority);
/**
- * gras_log_parent_set:
+ * xbt_log_parent_set:
* @cat: the category (not only its name, but the variable)
* @parent: the parent cat
*
* Programatically alter a category's parent (don't use).
*/
-extern void gras_log_parent_set(gras_log_category_t cat,
- gras_log_category_t parent);
+extern void xbt_log_parent_set(xbt_log_category_t cat,
+ xbt_log_category_t parent);
/**
- * gras_log_appender_set:
+ * xbt_log_appender_set:
* @cat: the category (not only its name, but the variable)
* @app: the appender
*
* Programatically sets the category's appender (don't use).
*/
-extern void gras_log_appender_set(gras_log_category_t cat,
- gras_log_appender_t app);
+extern void xbt_log_appender_set(xbt_log_category_t cat,
+ xbt_log_appender_t app);
/* Functions that you shouldn't call. */
-extern void _gras_log_event_log(gras_log_event_t ev,
+extern void _xbt_log_event_log(xbt_log_event_t ev,
const char *fmt,
- ...) _GRAS_GNUC_PRINTF(2,3);
+ ...) _XBT_GNUC_PRINTF(2,3);
-extern int _gras_log_cat_init(e_gras_log_priority_t priority,
- gras_log_category_t category);
+extern int _xbt_log_cat_init(e_xbt_log_priority_t priority,
+ xbt_log_category_t category);
-extern s_gras_log_category_t _GRAS_LOGV(GRAS_LOG_ROOT_CAT);
-GRAS_LOG_EXTERNAL_CATEGORY(GRAS);
-extern gras_log_appender_t gras_log_default_appender;
+extern s_xbt_log_category_t _XBT_LOGV(XBT_LOG_ROOT_CAT);
+XBT_LOG_EXTERNAL_CATEGORY(GRAS);
+extern xbt_log_appender_t xbt_log_default_appender;
/**
- * GRAS_LOG_ISENABLED:
+ * XBT_LOG_ISENABLED:
* @catName: name of the category
* @priority: minimal priority to be enabled to return true
*
* command and used only within it, you should make its evaluation conditional
* using this macro.
*/
-#define GRAS_LOG_ISENABLED(catName, priority) \
- _GRAS_LOG_ISENABLEDV(_GRAS_LOGV(catName), priority)
+#define XBT_LOG_ISENABLED(catName, priority) \
+ _XBT_LOG_ISENABLEDV(_XBT_LOGV(catName), priority)
/*
- * Helper function that implements GRAS_LOG_ISENABLED.
+ * Helper function that implements XBT_LOG_ISENABLED.
*
* NOTES
* First part is a compile-time constant.
* Call to _log_initCat only happens once.
*/
-#define _GRAS_LOG_ISENABLEDV(catv, priority) \
- (priority >= GRAS_LOG_STATIC_THRESHOLD \
+#define _XBT_LOG_ISENABLEDV(catv, priority) \
+ (priority >= XBT_LOG_STATIC_THRESHOLD \
&& priority >= catv.threshold \
- && (catv.threshold != gras_log_priority_uninitialized \
- || _gras_log_cat_init(priority, &catv)) )
+ && (catv.threshold != xbt_log_priority_uninitialized \
+ || _xbt_log_cat_init(priority, &catv)) )
/*
* Internal Macros
* Setting the LogEvent's valist member is done inside _log_logEvent.
*/
-#define _GRAS_LOG_PRE(catv, priority) do { \
- if (_GRAS_LOG_ISENABLEDV(catv, priority)) { \
- s_gras_log_event_t _log_ev = \
- {&(catv),priority,__FILE__,_GRAS_GNUC_FUNCTION,__LINE__}; \
- _gras_log_event_log(&_log_ev
+#define _XBT_LOG_PRE(catv, priority) do { \
+ if (_XBT_LOG_ISENABLEDV(catv, priority)) { \
+ s_xbt_log_event_t _log_ev = \
+ {&(catv),priority,__FILE__,_XBT_GNUC_FUNCTION,__LINE__}; \
+ _xbt_log_event_log(&_log_ev
-#define _GRAS_LOG_POST \
+#define _XBT_LOG_POST \
); \
} } while(0)
/* Logging Macros */
-#ifdef GRAS_LOG_MAYDAY
+#ifdef XBT_LOG_MAYDAY
# define CLOG0(c, p, f) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__)
# define CLOG1(c, p, f,a1) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1)
# define CLOG2(c, p, f,a1,a2) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2)
# define CLOG7(c, p, f,a1,a2,a3,a4,a5,a6,a7) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3,a4,a5,a6,a7)
# define CLOG8(c, p, f,a1,a2,a3,a4,a5,a6,a7,a8) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3,a4,a5,a6,a7,a8)
#else
-# define CLOG0(c, p, f) _GRAS_LOG_PRE(_GRAS_LOGV(c),p) ,f _GRAS_LOG_POST
-# define CLOG1(c, p, f,a1) _GRAS_LOG_PRE(_GRAS_LOGV(c),p) ,f,a1 _GRAS_LOG_POST
-# define CLOG2(c, p, f,a1,a2) _GRAS_LOG_PRE(_GRAS_LOGV(c),p) ,f,a1,a2 _GRAS_LOG_POST
-# define CLOG3(c, p, f,a1,a2,a3) _GRAS_LOG_PRE(_GRAS_LOGV(c),p) ,f,a1,a2,a3 _GRAS_LOG_POST
-# define CLOG4(c, p, f,a1,a2,a3,a4) _GRAS_LOG_PRE(_GRAS_LOGV(c),p) ,f,a1,a2,a3,a4 _GRAS_LOG_POST
-# define CLOG5(c, p, f,a1,a2,a3,a4,a5) _GRAS_LOG_PRE(_GRAS_LOGV(c),p) ,f,a1,a2,a3,a4,a5 _GRAS_LOG_POST
-# define CLOG6(c, p, f,a1,a2,a3,a4,a5,a6) _GRAS_LOG_PRE(_GRAS_LOGV(c),p) ,f,a1,a2,a3,a4,a5,a6 _GRAS_LOG_POST
-# define CLOG7(c, p, f,a1,a2,a3,a4,a5,a6,a7) _GRAS_LOG_PRE(_GRAS_LOGV(c),p) ,f,a1,a2,a3,a4,a5,a6,a7 _GRAS_LOG_POST
-# define CLOG8(c, p, f,a1,a2,a3,a4,a5,a6,a7,a8) _GRAS_LOG_PRE(_GRAS_LOGV(c),p) ,f,a1,a2,a3,a4,a5,a6,a7,a8 _GRAS_LOG_POST
+# define CLOG0(c, p, f) _XBT_LOG_PRE(_XBT_LOGV(c),p) ,f _XBT_LOG_POST
+# define CLOG1(c, p, f,a1) _XBT_LOG_PRE(_XBT_LOGV(c),p) ,f,a1 _XBT_LOG_POST
+# define CLOG2(c, p, f,a1,a2) _XBT_LOG_PRE(_XBT_LOGV(c),p) ,f,a1,a2 _XBT_LOG_POST
+# define CLOG3(c, p, f,a1,a2,a3) _XBT_LOG_PRE(_XBT_LOGV(c),p) ,f,a1,a2,a3 _XBT_LOG_POST
+# define CLOG4(c, p, f,a1,a2,a3,a4) _XBT_LOG_PRE(_XBT_LOGV(c),p) ,f,a1,a2,a3,a4 _XBT_LOG_POST
+# define CLOG5(c, p, f,a1,a2,a3,a4,a5) _XBT_LOG_PRE(_XBT_LOGV(c),p) ,f,a1,a2,a3,a4,a5 _XBT_LOG_POST
+# define CLOG6(c, p, f,a1,a2,a3,a4,a5,a6) _XBT_LOG_PRE(_XBT_LOGV(c),p) ,f,a1,a2,a3,a4,a5,a6 _XBT_LOG_POST
+# define CLOG7(c, p, f,a1,a2,a3,a4,a5,a6,a7) _XBT_LOG_PRE(_XBT_LOGV(c),p) ,f,a1,a2,a3,a4,a5,a6,a7 _XBT_LOG_POST
+# define CLOG8(c, p, f,a1,a2,a3,a4,a5,a6,a7,a8) _XBT_LOG_PRE(_XBT_LOGV(c),p) ,f,a1,a2,a3,a4,a5,a6,a7,a8 _XBT_LOG_POST
#endif
-#define CDEBUG0(c, f) CLOG0(c, gras_log_priority_debug, f)
-#define CDEBUG1(c, f,a1) CLOG1(c, gras_log_priority_debug, f,a1)
-#define CDEBUG2(c, f,a1,a2) CLOG2(c, gras_log_priority_debug, f,a1,a2)
-#define CDEBUG3(c, f,a1,a2,a3) CLOG3(c, gras_log_priority_debug, f,a1,a2,a3)
-#define CDEBUG4(c, f,a1,a2,a3,a4) CLOG4(c, gras_log_priority_debug, f,a1,a2,a3,a4)
-#define CDEBUG5(c, f,a1,a2,a3,a4,a5) CLOG5(c, gras_log_priority_debug, f,a1,a2,a3,a4,a5)
-#define CDEBUG6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, gras_log_priority_debug, f,a1,a2,a3,a4,a5,a6)
-#define CDEBUG7(c, f,a1,a2,a3,a4,a5,a6,a7) CLOG7(c, gras_log_priority_debug, f,a1,a2,a3,a4,a5,a6,a7)
-#define CDEBUG8(c, f,a1,a2,a3,a4,a5,a6,a7,a8) CLOG8(c, gras_log_priority_debug, f,a1,a2,a3,a4,a5,a6,a7,a8)
-
-#define CVERB0(c, f) CLOG0(c, gras_log_priority_verbose, f)
-#define CVERB1(c, f,a1) CLOG1(c, gras_log_priority_verbose, f,a1)
-#define CVERB2(c, f,a1,a2) CLOG2(c, gras_log_priority_verbose, f,a1,a2)
-#define CVERB3(c, f,a1,a2,a3) CLOG3(c, gras_log_priority_verbose, f,a1,a2,a3)
-#define CVERB4(c, f,a1,a2,a3,a4) CLOG4(c, gras_log_priority_verbose, f,a1,a2,a3,a4)
-#define CVERB5(c, f,a1,a2,a3,a4,a5) CLOG5(c, gras_log_priority_verbose, f,a1,a2,a3,a4,a5)
-#define CVERB6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, gras_log_priority_verbose, f,a1,a2,a3,a4,a5,a6)
-
-#define CINFO0(c, f) CLOG0(c, gras_log_priority_info, f)
-#define CINFO1(c, f,a1) CLOG1(c, gras_log_priority_info, f,a1)
-#define CINFO2(c, f,a1,a2) CLOG2(c, gras_log_priority_info, f,a1,a2)
-#define CINFO3(c, f,a1,a2,a3) CLOG3(c, gras_log_priority_info, f,a1,a2,a3)
-#define CINFO4(c, f,a1,a2,a3,a4) CLOG4(c, gras_log_priority_info, f,a1,a2,a3,a4)
-#define CINFO5(c, f,a1,a2,a3,a4,a5) CLOG5(c, gras_log_priority_info, f,a1,a2,a3,a4,a5)
-#define CINFO6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, gras_log_priority_info, f,a1,a2,a3,a4,a5,a6)
-
-#define CWARN0(c, f) CLOG0(c, gras_log_priority_warning, f)
-#define CWARN1(c, f,a1) CLOG1(c, gras_log_priority_warning, f,a1)
-#define CWARN2(c, f,a1,a2) CLOG2(c, gras_log_priority_warning, f,a1,a2)
-#define CWARN3(c, f,a1,a2,a3) CLOG3(c, gras_log_priority_warning, f,a1,a2,a3)
-#define CWARN4(c, f,a1,a2,a3,a4) CLOG4(c, gras_log_priority_warning, f,a1,a2,a3,a4)
-#define CWARN5(c, f,a1,a2,a3,a4,a5) CLOG5(c, gras_log_priority_warning, f,a1,a2,a3,a4,a5)
-#define CWARN6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, gras_log_priority_warning, f,a1,a2,a3,a4,a5,a6)
-
-#define CERROR0(c, f) CLOG0(c, gras_log_priority_error, f)
-#define CERROR1(c, f,a1) CLOG1(c, gras_log_priority_error, f,a1)
-#define CERROR2(c, f,a1,a2) CLOG2(c, gras_log_priority_error, f,a1,a2)
-#define CERROR3(c, f,a1,a2,a3) CLOG3(c, gras_log_priority_error, f,a1,a2,a3)
-#define CERROR4(c, f,a1,a2,a3,a4) CLOG4(c, gras_log_priority_error, f,a1,a2,a3,a4)
-#define CERROR5(c, f,a1,a2,a3,a4,a5) CLOG5(c, gras_log_priority_error, f,a1,a2,a3,a4,a5)
-#define CERROR6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, gras_log_priority_error, f,a1,a2,a3,a4,a5,a6)
+#define CDEBUG0(c, f) CLOG0(c, xbt_log_priority_debug, f)
+#define CDEBUG1(c, f,a1) CLOG1(c, xbt_log_priority_debug, f,a1)
+#define CDEBUG2(c, f,a1,a2) CLOG2(c, xbt_log_priority_debug, f,a1,a2)
+#define CDEBUG3(c, f,a1,a2,a3) CLOG3(c, xbt_log_priority_debug, f,a1,a2,a3)
+#define CDEBUG4(c, f,a1,a2,a3,a4) CLOG4(c, xbt_log_priority_debug, f,a1,a2,a3,a4)
+#define CDEBUG5(c, f,a1,a2,a3,a4,a5) CLOG5(c, xbt_log_priority_debug, f,a1,a2,a3,a4,a5)
+#define CDEBUG6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, xbt_log_priority_debug, f,a1,a2,a3,a4,a5,a6)
+#define CDEBUG7(c, f,a1,a2,a3,a4,a5,a6,a7) CLOG7(c, xbt_log_priority_debug, f,a1,a2,a3,a4,a5,a6,a7)
+#define CDEBUG8(c, f,a1,a2,a3,a4,a5,a6,a7,a8) CLOG8(c, xbt_log_priority_debug, f,a1,a2,a3,a4,a5,a6,a7,a8)
+
+#define CVERB0(c, f) CLOG0(c, xbt_log_priority_verbose, f)
+#define CVERB1(c, f,a1) CLOG1(c, xbt_log_priority_verbose, f,a1)
+#define CVERB2(c, f,a1,a2) CLOG2(c, xbt_log_priority_verbose, f,a1,a2)
+#define CVERB3(c, f,a1,a2,a3) CLOG3(c, xbt_log_priority_verbose, f,a1,a2,a3)
+#define CVERB4(c, f,a1,a2,a3,a4) CLOG4(c, xbt_log_priority_verbose, f,a1,a2,a3,a4)
+#define CVERB5(c, f,a1,a2,a3,a4,a5) CLOG5(c, xbt_log_priority_verbose, f,a1,a2,a3,a4,a5)
+#define CVERB6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, xbt_log_priority_verbose, f,a1,a2,a3,a4,a5,a6)
+
+#define CINFO0(c, f) CLOG0(c, xbt_log_priority_info, f)
+#define CINFO1(c, f,a1) CLOG1(c, xbt_log_priority_info, f,a1)
+#define CINFO2(c, f,a1,a2) CLOG2(c, xbt_log_priority_info, f,a1,a2)
+#define CINFO3(c, f,a1,a2,a3) CLOG3(c, xbt_log_priority_info, f,a1,a2,a3)
+#define CINFO4(c, f,a1,a2,a3,a4) CLOG4(c, xbt_log_priority_info, f,a1,a2,a3,a4)
+#define CINFO5(c, f,a1,a2,a3,a4,a5) CLOG5(c, xbt_log_priority_info, f,a1,a2,a3,a4,a5)
+#define CINFO6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, xbt_log_priority_info, f,a1,a2,a3,a4,a5,a6)
+
+#define CWARN0(c, f) CLOG0(c, xbt_log_priority_warning, f)
+#define CWARN1(c, f,a1) CLOG1(c, xbt_log_priority_warning, f,a1)
+#define CWARN2(c, f,a1,a2) CLOG2(c, xbt_log_priority_warning, f,a1,a2)
+#define CWARN3(c, f,a1,a2,a3) CLOG3(c, xbt_log_priority_warning, f,a1,a2,a3)
+#define CWARN4(c, f,a1,a2,a3,a4) CLOG4(c, xbt_log_priority_warning, f,a1,a2,a3,a4)
+#define CWARN5(c, f,a1,a2,a3,a4,a5) CLOG5(c, xbt_log_priority_warning, f,a1,a2,a3,a4,a5)
+#define CWARN6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, xbt_log_priority_warning, f,a1,a2,a3,a4,a5,a6)
+
+#define CERROR0(c, f) CLOG0(c, xbt_log_priority_error, f)
+#define CERROR1(c, f,a1) CLOG1(c, xbt_log_priority_error, f,a1)
+#define CERROR2(c, f,a1,a2) CLOG2(c, xbt_log_priority_error, f,a1,a2)
+#define CERROR3(c, f,a1,a2,a3) CLOG3(c, xbt_log_priority_error, f,a1,a2,a3)
+#define CERROR4(c, f,a1,a2,a3,a4) CLOG4(c, xbt_log_priority_error, f,a1,a2,a3,a4)
+#define CERROR5(c, f,a1,a2,a3,a4,a5) CLOG5(c, xbt_log_priority_error, f,a1,a2,a3,a4,a5)
+#define CERROR6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, xbt_log_priority_error, f,a1,a2,a3,a4,a5,a6)
/**
* CCRITICAL6:
* along with the format string.
*/
-#define CCRITICAL0(c, f) CLOG0(c, gras_log_priority_critical, f)
-#define CCRITICAL1(c, f,a1) CLOG1(c, gras_log_priority_critical, f,a1)
-#define CCRITICAL2(c, f,a1,a2) CLOG2(c, gras_log_priority_critical, f,a1,a2)
-#define CCRITICAL3(c, f,a1,a2,a3) CLOG3(c, gras_log_priority_critical, f,a1,a2,a3)
-#define CCRITICAL4(c, f,a1,a2,a3,a4) CLOG4(c, gras_log_priority_critical, f,a1,a2,a3,a4)
-#define CCRITICAL5(c, f,a1,a2,a3,a4,a5) CLOG5(c, gras_log_priority_critical, f,a1,a2,a3,a4,a5)
-#define CCRITICAL6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, gras_log_priority_critical, f,a1,a2,a3,a4,a5,a6)
+#define CCRITICAL0(c, f) CLOG0(c, xbt_log_priority_critical, f)
+#define CCRITICAL1(c, f,a1) CLOG1(c, xbt_log_priority_critical, f,a1)
+#define CCRITICAL2(c, f,a1,a2) CLOG2(c, xbt_log_priority_critical, f,a1,a2)
+#define CCRITICAL3(c, f,a1,a2,a3) CLOG3(c, xbt_log_priority_critical, f,a1,a2,a3)
+#define CCRITICAL4(c, f,a1,a2,a3,a4) CLOG4(c, xbt_log_priority_critical, f,a1,a2,a3,a4)
+#define CCRITICAL5(c, f,a1,a2,a3,a4,a5) CLOG5(c, xbt_log_priority_critical, f,a1,a2,a3,a4,a5)
+#define CCRITICAL6(c, f,a1,a2,a3,a4,a5,a6) CLOG6(c, xbt_log_priority_critical, f,a1,a2,a3,a4,a5,a6)
-#ifdef GRAS_LOG_MAYDAY
+#ifdef XBT_LOG_MAYDAY
# define LOG0(p, f) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__)
# define LOG1(p, f,a1) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1)
# define LOG2(p, f,a1,a2) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2)
# define LOG7(p, f,a1,a2,a3,a4,a5,a6,a7) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3,a4,a5,a6,a7)
# define LOG8(p, f,a1,a2,a3,a4,a5,a6,a7,a8) fprintf(stderr,"%s:%d:" f "\n",__FILE__,__LINE__,a1,a2,a3,a4,a5,a6,a7,a8)
#else
-# define LOG0(p, f) _GRAS_LOG_PRE((*_GRAS_LOGV(default)),p) ,f _GRAS_LOG_POST
-# define LOG1(p, f,a1) _GRAS_LOG_PRE((*_GRAS_LOGV(default)),p) ,f,a1 _GRAS_LOG_POST
-# define LOG2(p, f,a1,a2) _GRAS_LOG_PRE((*_GRAS_LOGV(default)),p) ,f,a1,a2 _GRAS_LOG_POST
-# define LOG3(p, f,a1,a2,a3) _GRAS_LOG_PRE((*_GRAS_LOGV(default)),p) ,f,a1,a2,a3 _GRAS_LOG_POST
-# define LOG4(p, f,a1,a2,a3,a4) _GRAS_LOG_PRE((*_GRAS_LOGV(default)),p) ,f,a1,a2,a3,a4 _GRAS_LOG_POST
-# define LOG5(p, f,a1,a2,a3,a4,a5) _GRAS_LOG_PRE((*_GRAS_LOGV(default)),p) ,f,a1,a2,a3,a4,a5 _GRAS_LOG_POST
-# define LOG6(p, f,a1,a2,a3,a4,a5,a6) _GRAS_LOG_PRE((*_GRAS_LOGV(default)),p) ,f,a1,a2,a3,a4,a5,a6 _GRAS_LOG_POST
-# define LOG7(p, f,a1,a2,a3,a4,a5,a6,a7) _GRAS_LOG_PRE((*_GRAS_LOGV(default)),p) ,f,a1,a2,a3,a4,a5,a6,a7 _GRAS_LOG_POST
-# define LOG8(p, f,a1,a2,a3,a4,a5,a6,a7,a8) _GRAS_LOG_PRE((*_GRAS_LOGV(default)),p) ,f,a1,a2,a3,a4,a5,a6,a7,a8 _GRAS_LOG_POST
+# define LOG0(p, f) _XBT_LOG_PRE((*_XBT_LOGV(default)),p) ,f _XBT_LOG_POST
+# define LOG1(p, f,a1) _XBT_LOG_PRE((*_XBT_LOGV(default)),p) ,f,a1 _XBT_LOG_POST
+# define LOG2(p, f,a1,a2) _XBT_LOG_PRE((*_XBT_LOGV(default)),p) ,f,a1,a2 _XBT_LOG_POST
+# define LOG3(p, f,a1,a2,a3) _XBT_LOG_PRE((*_XBT_LOGV(default)),p) ,f,a1,a2,a3 _XBT_LOG_POST
+# define LOG4(p, f,a1,a2,a3,a4) _XBT_LOG_PRE((*_XBT_LOGV(default)),p) ,f,a1,a2,a3,a4 _XBT_LOG_POST
+# define LOG5(p, f,a1,a2,a3,a4,a5) _XBT_LOG_PRE((*_XBT_LOGV(default)),p) ,f,a1,a2,a3,a4,a5 _XBT_LOG_POST
+# define LOG6(p, f,a1,a2,a3,a4,a5,a6) _XBT_LOG_PRE((*_XBT_LOGV(default)),p) ,f,a1,a2,a3,a4,a5,a6 _XBT_LOG_POST
+# define LOG7(p, f,a1,a2,a3,a4,a5,a6,a7) _XBT_LOG_PRE((*_XBT_LOGV(default)),p) ,f,a1,a2,a3,a4,a5,a6,a7 _XBT_LOG_POST
+# define LOG8(p, f,a1,a2,a3,a4,a5,a6,a7,a8) _XBT_LOG_PRE((*_XBT_LOGV(default)),p) ,f,a1,a2,a3,a4,a5,a6,a7,a8 _XBT_LOG_POST
#endif
/**
* along with the format string.
*/
-#define DEBUG0(f) LOG0(gras_log_priority_debug, f)
-#define DEBUG1(f,a1) LOG1(gras_log_priority_debug, f,a1)
-#define DEBUG2(f,a1,a2) LOG2(gras_log_priority_debug, f,a1,a2)
-#define DEBUG3(f,a1,a2,a3) LOG3(gras_log_priority_debug, f,a1,a2,a3)
-#define DEBUG4(f,a1,a2,a3,a4) LOG4(gras_log_priority_debug, f,a1,a2,a3,a4)
-#define DEBUG5(f,a1,a2,a3,a4,a5) LOG5(gras_log_priority_debug, f,a1,a2,a3,a4,a5)
-#define DEBUG6(f,a1,a2,a3,a4,a5,a6) LOG6(gras_log_priority_debug, f,a1,a2,a3,a4,a5,a6)
-#define DEBUG7(f,a1,a2,a3,a4,a5,a6,a7) LOG7(gras_log_priority_debug, f,a1,a2,a3,a4,a5,a6,a7)
-#define DEBUG8(f,a1,a2,a3,a4,a5,a6,a7,a8) LOG8(gras_log_priority_debug, f,a1,a2,a3,a4,a5,a6,a7,a8)
+#define DEBUG0(f) LOG0(xbt_log_priority_debug, f)
+#define DEBUG1(f,a1) LOG1(xbt_log_priority_debug, f,a1)
+#define DEBUG2(f,a1,a2) LOG2(xbt_log_priority_debug, f,a1,a2)
+#define DEBUG3(f,a1,a2,a3) LOG3(xbt_log_priority_debug, f,a1,a2,a3)
+#define DEBUG4(f,a1,a2,a3,a4) LOG4(xbt_log_priority_debug, f,a1,a2,a3,a4)
+#define DEBUG5(f,a1,a2,a3,a4,a5) LOG5(xbt_log_priority_debug, f,a1,a2,a3,a4,a5)
+#define DEBUG6(f,a1,a2,a3,a4,a5,a6) LOG6(xbt_log_priority_debug, f,a1,a2,a3,a4,a5,a6)
+#define DEBUG7(f,a1,a2,a3,a4,a5,a6,a7) LOG7(xbt_log_priority_debug, f,a1,a2,a3,a4,a5,a6,a7)
+#define DEBUG8(f,a1,a2,a3,a4,a5,a6,a7,a8) LOG8(xbt_log_priority_debug, f,a1,a2,a3,a4,a5,a6,a7,a8)
/**
* VERB6:
* along with the format string.
*/
-#define VERB0(f) LOG0(gras_log_priority_verbose, f)
-#define VERB1(f,a1) LOG1(gras_log_priority_verbose, f,a1)
-#define VERB2(f,a1,a2) LOG2(gras_log_priority_verbose, f,a1,a2)
-#define VERB3(f,a1,a2,a3) LOG3(gras_log_priority_verbose, f,a1,a2,a3)
-#define VERB4(f,a1,a2,a3,a4) LOG4(gras_log_priority_verbose, f,a1,a2,a3,a4)
-#define VERB5(f,a1,a2,a3,a4,a5) LOG5(gras_log_priority_verbose, f,a1,a2,a3,a4,a5)
-#define VERB6(f,a1,a2,a3,a4,a5,a6) LOG6(gras_log_priority_verbose, f,a1,a2,a3,a4,a5,a6)
+#define VERB0(f) LOG0(xbt_log_priority_verbose, f)
+#define VERB1(f,a1) LOG1(xbt_log_priority_verbose, f,a1)
+#define VERB2(f,a1,a2) LOG2(xbt_log_priority_verbose, f,a1,a2)
+#define VERB3(f,a1,a2,a3) LOG3(xbt_log_priority_verbose, f,a1,a2,a3)
+#define VERB4(f,a1,a2,a3,a4) LOG4(xbt_log_priority_verbose, f,a1,a2,a3,a4)
+#define VERB5(f,a1,a2,a3,a4,a5) LOG5(xbt_log_priority_verbose, f,a1,a2,a3,a4,a5)
+#define VERB6(f,a1,a2,a3,a4,a5,a6) LOG6(xbt_log_priority_verbose, f,a1,a2,a3,a4,a5,a6)
/**
* INFO6:
* along with the format string.
*/
-#define INFO0(f) LOG0(gras_log_priority_info, f)
-#define INFO1(f,a1) LOG1(gras_log_priority_info, f,a1)
-#define INFO2(f,a1,a2) LOG2(gras_log_priority_info, f,a1,a2)
-#define INFO3(f,a1,a2,a3) LOG3(gras_log_priority_info, f,a1,a2,a3)
-#define INFO4(f,a1,a2,a3,a4) LOG4(gras_log_priority_info, f,a1,a2,a3,a4)
-#define INFO5(f,a1,a2,a3,a4,a5) LOG5(gras_log_priority_info, f,a1,a2,a3,a4,a5)
-#define INFO6(f,a1,a2,a3,a4,a5,a6) LOG6(gras_log_priority_info, f,a1,a2,a3,a4,a5,a6)
+#define INFO0(f) LOG0(xbt_log_priority_info, f)
+#define INFO1(f,a1) LOG1(xbt_log_priority_info, f,a1)
+#define INFO2(f,a1,a2) LOG2(xbt_log_priority_info, f,a1,a2)
+#define INFO3(f,a1,a2,a3) LOG3(xbt_log_priority_info, f,a1,a2,a3)
+#define INFO4(f,a1,a2,a3,a4) LOG4(xbt_log_priority_info, f,a1,a2,a3,a4)
+#define INFO5(f,a1,a2,a3,a4,a5) LOG5(xbt_log_priority_info, f,a1,a2,a3,a4,a5)
+#define INFO6(f,a1,a2,a3,a4,a5,a6) LOG6(xbt_log_priority_info, f,a1,a2,a3,a4,a5,a6)
/**
* WARN6:
* along with the format string.
*/
-#define WARN0(f) LOG0(gras_log_priority_warning, f)
-#define WARN1(f,a1) LOG1(gras_log_priority_warning, f,a1)
-#define WARN2(f,a1,a2) LOG2(gras_log_priority_warning, f,a1,a2)
-#define WARN3(f,a1,a2,a3) LOG3(gras_log_priority_warning, f,a1,a2,a3)
-#define WARN4(f,a1,a2,a3,a4) LOG4(gras_log_priority_warning, f,a1,a2,a3,a4)
-#define WARN5(f,a1,a2,a3,a4,a5) LOG5(gras_log_priority_warning, f,a1,a2,a3,a4,a5)
-#define WARN6(f,a1,a2,a3,a4,a5,a6) LOG6(gras_log_priority_warning, f,a1,a2,a3,a4,a5,a6)
+#define WARN0(f) LOG0(xbt_log_priority_warning, f)
+#define WARN1(f,a1) LOG1(xbt_log_priority_warning, f,a1)
+#define WARN2(f,a1,a2) LOG2(xbt_log_priority_warning, f,a1,a2)
+#define WARN3(f,a1,a2,a3) LOG3(xbt_log_priority_warning, f,a1,a2,a3)
+#define WARN4(f,a1,a2,a3,a4) LOG4(xbt_log_priority_warning, f,a1,a2,a3,a4)
+#define WARN5(f,a1,a2,a3,a4,a5) LOG5(xbt_log_priority_warning, f,a1,a2,a3,a4,a5)
+#define WARN6(f,a1,a2,a3,a4,a5,a6) LOG6(xbt_log_priority_warning, f,a1,a2,a3,a4,a5,a6)
/**
* ERROR6:
* along with the format string.
*/
-#define ERROR0(f) LOG0(gras_log_priority_error, f)
-#define ERROR1(f,a1) LOG1(gras_log_priority_error, f,a1)
-#define ERROR2(f,a1,a2) LOG2(gras_log_priority_error, f,a1,a2)
-#define ERROR3(f,a1,a2,a3) LOG3(gras_log_priority_error, f,a1,a2,a3)
-#define ERROR4(f,a1,a2,a3,a4) LOG4(gras_log_priority_error, f,a1,a2,a3,a4)
-#define ERROR5(f,a1,a2,a3,a4,a5) LOG5(gras_log_priority_error, f,a1,a2,a3,a4,a5)
-#define ERROR6(f,a1,a2,a3,a4,a5,a6) LOG6(gras_log_priority_error, f,a1,a2,a3,a4,a5,a6)
+#define ERROR0(f) LOG0(xbt_log_priority_error, f)
+#define ERROR1(f,a1) LOG1(xbt_log_priority_error, f,a1)
+#define ERROR2(f,a1,a2) LOG2(xbt_log_priority_error, f,a1,a2)
+#define ERROR3(f,a1,a2,a3) LOG3(xbt_log_priority_error, f,a1,a2,a3)
+#define ERROR4(f,a1,a2,a3,a4) LOG4(xbt_log_priority_error, f,a1,a2,a3,a4)
+#define ERROR5(f,a1,a2,a3,a4,a5) LOG5(xbt_log_priority_error, f,a1,a2,a3,a4,a5)
+#define ERROR6(f,a1,a2,a3,a4,a5,a6) LOG6(xbt_log_priority_error, f,a1,a2,a3,a4,a5,a6)
/**
* CRITICAL6:
* for sake of clarity. They just differ in the number of arguments passed
* along with the format string.
*/
-#define CRITICAL0(f) LOG0(gras_log_priority_critical, f)
-#define CRITICAL1(f,a1) LOG1(gras_log_priority_critical, f,a1)
-#define CRITICAL2(f,a1,a2) LOG2(gras_log_priority_critical, f,a1,a2)
-#define CRITICAL3(f,a1,a2,a3) LOG3(gras_log_priority_critical, f,a1,a2,a3)
-#define CRITICAL4(f,a1,a2,a3,a4) LOG4(gras_log_priority_critical, f,a1,a2,a3,a4)
-#define CRITICAL5(f,a1,a2,a3,a4,a5) LOG5(gras_log_priority_critical, f,a1,a2,a3,a4,a5)
-#define CRITICAL6(f,a1,a2,a3,a4,a5,a6) LOG6(gras_log_priority_critical, f,a1,a2,a3,a4,a5,a6)
-
-#define GRAS_IN LOG1(gras_log_priority_trace, ">> begin of %s", _GRAS_GNUC_FUNCTION)
-#define GRAS_IN1(fmt,a) LOG2(gras_log_priority_trace, ">> begin of %s" fmt, _GRAS_GNUC_FUNCTION, a)
-#define GRAS_IN2(fmt,a,b) LOG3(gras_log_priority_trace, ">> begin of %s" fmt, _GRAS_GNUC_FUNCTION, a,b)
-#define GRAS_IN3(fmt,a,b,c) LOG4(gras_log_priority_trace, ">> begin of %s" fmt, _GRAS_GNUC_FUNCTION, a,b,c)
-#define GRAS_IN4(fmt,a,b,c,d) LOG5(gras_log_priority_trace, ">> begin of %s" fmt, _GRAS_GNUC_FUNCTION, a,b,c,d)
-#define GRAS_OUT LOG1(gras_log_priority_trace, "<< end of %s", _GRAS_GNUC_FUNCTION)
-
-#endif /* ! _GRAS_LOG_H_ */
+#define CRITICAL0(f) LOG0(xbt_log_priority_critical, f)
+#define CRITICAL1(f,a1) LOG1(xbt_log_priority_critical, f,a1)
+#define CRITICAL2(f,a1,a2) LOG2(xbt_log_priority_critical, f,a1,a2)
+#define CRITICAL3(f,a1,a2,a3) LOG3(xbt_log_priority_critical, f,a1,a2,a3)
+#define CRITICAL4(f,a1,a2,a3,a4) LOG4(xbt_log_priority_critical, f,a1,a2,a3,a4)
+#define CRITICAL5(f,a1,a2,a3,a4,a5) LOG5(xbt_log_priority_critical, f,a1,a2,a3,a4,a5)
+#define CRITICAL6(f,a1,a2,a3,a4,a5,a6) LOG6(xbt_log_priority_critical, f,a1,a2,a3,a4,a5,a6)
+
+#define XBT_IN LOG1(xbt_log_priority_trace, ">> begin of %s", _XBT_GNUC_FUNCTION)
+#define XBT_IN1(fmt,a) LOG2(xbt_log_priority_trace, ">> begin of %s" fmt, _XBT_GNUC_FUNCTION, a)
+#define XBT_IN2(fmt,a,b) LOG3(xbt_log_priority_trace, ">> begin of %s" fmt, _XBT_GNUC_FUNCTION, a,b)
+#define XBT_IN3(fmt,a,b,c) LOG4(xbt_log_priority_trace, ">> begin of %s" fmt, _XBT_GNUC_FUNCTION, a,b,c)
+#define XBT_IN4(fmt,a,b,c,d) LOG5(xbt_log_priority_trace, ">> begin of %s" fmt, _XBT_GNUC_FUNCTION, a,b,c,d)
+#define XBT_OUT LOG1(xbt_log_priority_trace, "<< end of %s", _XBT_GNUC_FUNCTION)
+
+#endif /* ! _XBT_LOG_H_ */
#define TRUE 1
#define FALSE 0
-#define GRAS_MAX_CHANNEL 10 /* FIXME: killme */
+#define XBT_MAX_CHANNEL 10 /* FIXME: killme */
/*! C++ users need love */
#ifndef BEGIN_DECL
# ifdef __cplusplus
typedef struct {
char *name;
int port;
-} gras_host_t;
+} xbt_host_t;
END_DECL
/* 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. */
-#ifndef _GRAS_MODULE_H
-#define _GRAS_MODULE_H
+#ifndef _XBT_MODULE_H
+#define _XBT_MODULE_H
-typedef struct gras_module_ gras_module_t;
+typedef struct xbt_module_ xbt_module_t;
-typedef gras_module_t (*gras_module_new_fct_t)(int argc, char **argv);
-typedef int (*gras_module_finalize_fct_t)(void);
+typedef xbt_module_t (*xbt_module_new_fct_t)(int argc, char **argv);
+typedef int (*xbt_module_finalize_fct_t)(void);
-void gras_init(int *argc,char **argv);
-void gras_init_defaultlog(int *argc,char **argv, const char *defaultlog);
-void gras_exit(void);
-#endif /* _GRAS_MODULE_H */
+void xbt_init(int *argc,char **argv);
+void xbt_init_defaultlog(int *argc,char **argv, const char *defaultlog);
+void xbt_exit(void);
+#endif /* _XBT_MODULE_H */
/* $Id$ */
-/* gras/set.h -- api to a generic dictionary */
+/* xbt/set.h -- api to a generic dictionary */
/* Authors: Martin Quinson */
/* Copyright (C) 2004 the OURAGAN project. */
under the terms of the license (GNU LGPL) which comes with this package. */
-#ifndef _GRAS_SET_H
-#define _GRAS_SET_H
+#ifndef _XBT_SET_H
+#define _XBT_SET_H
#include "xbt/misc.h" /* BEGIN_DECL */
BEGIN_DECL
/*####[ Type definition ]####################################################*/
-typedef struct gras_set_ *gras_set_t;
-typedef struct gras_set_elm_ {
+typedef struct xbt_set_ *xbt_set_t;
+typedef struct xbt_set_elm_ {
unsigned int ID;
char *name;
unsigned int name_len;
-} s_gras_set_elm_t,*gras_set_elm_t;
+} s_xbt_set_elm_t,*xbt_set_elm_t;
/*####[ Functions ]##########################################################*/
-gras_set_t gras_set_new (void);
-void gras_set_free(gras_set_t *set);
+xbt_set_t xbt_set_new (void);
+void xbt_set_free(xbt_set_t *set);
-void gras_set_add (gras_set_t set,
- gras_set_elm_t elm,
+void xbt_set_add (xbt_set_t set,
+ xbt_set_elm_t elm,
void_f_pvoid_t *free_func);
-/*----[ gras_set_retrieve ]-------------------------------------------------*/
+/*----[ xbt_set_retrieve ]-------------------------------------------------*/
/* Search the given #key#. data=NULL when not found. */
/*---------------------------------------------------------------------------*/
-gras_error_t gras_set_get_by_name (gras_set_t set,
+xbt_error_t xbt_set_get_by_name (xbt_set_t set,
const char *key,
- /* OUT */gras_set_elm_t *dst);
-gras_error_t gras_set_get_by_name_ext(gras_set_t set,
+ /* OUT */xbt_set_elm_t *dst);
+xbt_error_t xbt_set_get_by_name_ext(xbt_set_t set,
const char *name,
int name_len,
- /* OUT */gras_set_elm_t *dst);
-gras_error_t gras_set_get_by_id (gras_set_t set,
+ /* OUT */xbt_set_elm_t *dst);
+xbt_error_t xbt_set_get_by_id (xbt_set_t set,
int id,
- /* OUT */gras_set_elm_t *dst);
+ /* OUT */xbt_set_elm_t *dst);
/*####[ Cache cursor functions ]#############################################*/
/* To traverse (simple) caches */
/* Don't add or remove entries to the cache while traversing !!! */
/*###########################################################################*/
-typedef struct gras_set_cursor_ *gras_set_cursor_t;
+typedef struct xbt_set_cursor_ *xbt_set_cursor_t;
-void gras_set_cursor_first (gras_set_t set,
- gras_set_cursor_t *cursor);
-void gras_set_cursor_step (gras_set_cursor_t cursor);
-int gras_set_cursor_get_or_free (gras_set_cursor_t *cursor,
- gras_set_elm_t *elm);
+void xbt_set_cursor_first (xbt_set_t set,
+ xbt_set_cursor_t *cursor);
+void xbt_set_cursor_step (xbt_set_cursor_t cursor);
+int xbt_set_cursor_get_or_free (xbt_set_cursor_t *cursor,
+ xbt_set_elm_t *elm);
-#define gras_set_foreach(set,cursor,elm) \
- for ((cursor) = NULL, gras_set_cursor_first((set),&(cursor)) ; \
- gras_set_cursor_get_or_free(&(cursor),(gras_set_elm_t*)&(elm)); \
- gras_set_cursor_step(cursor) )
+#define xbt_set_foreach(set,cursor,elm) \
+ for ((cursor) = NULL, xbt_set_cursor_first((set),&(cursor)) ; \
+ xbt_set_cursor_get_or_free(&(cursor),(xbt_set_elm_t*)&(elm)); \
+ xbt_set_cursor_step(cursor) )
END_DECL
-#endif /* _GRAS_SET_H */
+#endif /* _XBT_SET_H */
/* $Id$ */
-/* gras/sysdep.h -- all system dependency */
+/* xbt/sysdep.h -- all system dependency */
/* no system header should be loaded out of this file so that we have only */
/* one file to check when porting to another OS */
under the terms of the license (GNU LGPL) which comes with this package. */
-#ifndef _GRAS_SYSDEP_H
-#define _GRAS_SYSDEP_H
+#ifndef _XBT_SYSDEP_H
+#define _XBT_SYSDEP_H
#include <string.h> /* Included directly for speed */
#define REALLOC(p, s) (__REALLOC_OP ((p), (s)))
#endif
-#define gras_strdup(s) ((s)?(strdup(s)?:(gras_die("memory allocation error"),NULL))\
+#define xbt_strdup(s) ((s)?(strdup(s)?:(xbt_die("memory allocation error"),NULL))\
:(NULL))
-#define gras_malloc(n) (malloc(n) ?: (gras_die("memory allocation error"),NULL))
-#define gras_malloc0(n) (calloc( (n),1 ) ?: (gras_die("memory allocation error"),NULL))
-#define gras_realloc(p,s) (s? (p? (realloc(p,s)?:gras_die("memory allocation error"),NULL) \
- : gras_malloc(s)) \
+#define xbt_malloc(n) (malloc(n) ?: (xbt_die("memory allocation error"),NULL))
+#define xbt_malloc0(n) (calloc( (n),1 ) ?: (xbt_die("memory allocation error"),NULL))
+#define xbt_realloc(p,s) (s? (p? (realloc(p,s)?:xbt_die("memory allocation error"),NULL) \
+ : xbt_malloc(s)) \
: (p? (free(p),NULL) \
: NULL))
-#define gras_free free /*nothing specific to do here. A poor valgrind replacement?*/
-#define gras_free_fct free /* replacement with the guareenty of being a function */
+#define xbt_free free /*nothing specific to do here. A poor valgrind replacement?*/
+#define xbt_free_fct free /* replacement with the guareenty of being a function */
-#define gras_new(type, count) ((type*)gras_malloc (sizeof (type) * (count)))
-#define gras_new0(type, count) ((type*)gras_malloc0 (sizeof (type) * (count)))
+#define xbt_new(type, count) ((type*)xbt_malloc (sizeof (type) * (count)))
+#define xbt_new0(type, count) ((type*)xbt_malloc0 (sizeof (type) * (count)))
/* Attributes are only in recent versions of GCC */
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
-# define _GRAS_GNUC_PRINTF( format_idx, arg_idx ) \
+# define _XBT_GNUC_PRINTF( format_idx, arg_idx ) \
__attribute__((__format__ (__printf__, format_idx, arg_idx)))
-# define _GRAS_GNUC_SCANF( format_idx, arg_idx ) \
+# define _XBT_GNUC_SCANF( format_idx, arg_idx ) \
__attribute__((__format__ (__scanf__, format_idx, arg_idx)))
-# define _GRAS_GNUC_FORMAT( arg_idx ) \
+# define _XBT_GNUC_FORMAT( arg_idx ) \
__attribute__((__format_arg__ (arg_idx)))
-# define _GRAS_GNUC_NORETURN __attribute__((__noreturn__))
+# define _XBT_GNUC_NORETURN __attribute__((__noreturn__))
#else /* !__GNUC__ */
-# define _GRAS_GNUC_PRINTF( format_idx, arg_idx )
-# define _GRAS_GNUC_SCANF( format_idx, arg_idx )
-# define _GRAS_GNUC_FORMAT( arg_idx )
-# define _GRAS_GNUC_NORETURN
+# define _XBT_GNUC_PRINTF( format_idx, arg_idx )
+# define _XBT_GNUC_SCANF( format_idx, arg_idx )
+# define _XBT_GNUC_FORMAT( arg_idx )
+# define _XBT_GNUC_NORETURN
#endif /* !__GNUC__ */
#if defined(__GNUC__) && ! defined(__STRICT_ANSI__)
-# define _GRAS_GNUC_FUNCTION __FUNCTION__
-# define _GRAS_INLINE inline
+# define _XBT_GNUC_FUNCTION __FUNCTION__
+# define _XBT_INLINE inline
#else
-# define _GRAS_GNUC_FUNCTION "function"
-# define _GRAS_INLINE
+# define _XBT_GNUC_FUNCTION "function"
+# define _XBT_INLINE
#endif
-void gras_abort(void) _GRAS_GNUC_NORETURN;
+void xbt_abort(void) _XBT_GNUC_NORETURN;
/* FIXME: This is a very good candidate to rewrite (along with a proper string stuff)
but I'm too lazy right now, so copy the definition */
END_DECL
-#endif /* _GRAS_SYSDEP_H */
+#endif /* _XBT_SYSDEP_H */
#include "amok/Bandwidth/bandwidth_private.h"
#include "gras/messages.h"
-GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(bw,amok,"Bandwidth testing");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(bw,amok,"Bandwidth testing");
static short _amok_bw_initialized = 0;
/**** code ****/
void amok_bw_init(void) {
- gras_error_t errcode;
+ xbt_error_t errcode;
gras_datadesc_type_t bw_request_desc, bw_res_desc, sat_request_desc;
if (_amok_bw_initialized)
/* Build the datatype descriptions */
bw_request_desc = gras_datadesc_struct("s_bw_request_t");
- gras_datadesc_struct_append(bw_request_desc,"host",gras_datadesc_by_name("gras_host_t"));
+ gras_datadesc_struct_append(bw_request_desc,"host",gras_datadesc_by_name("xbt_host_t"));
gras_datadesc_struct_append(bw_request_desc,"buf_size",gras_datadesc_by_name("unsigned int"));
gras_datadesc_struct_append(bw_request_desc,"exp_size",gras_datadesc_by_name("unsigned int"));
gras_datadesc_struct_append(bw_request_desc,"msg_size",gras_datadesc_by_name("unsigned int"));
bw_res_desc = gras_datadesc_ref("bw_res_t",bw_res_desc);
sat_request_desc = gras_datadesc_struct("s_sat_request_desc_t");
- gras_datadesc_struct_append(sat_request_desc,"host",gras_datadesc_by_name("gras_host_t"));
+ gras_datadesc_struct_append(sat_request_desc,"host",gras_datadesc_by_name("xbt_host_t"));
gras_datadesc_struct_append(sat_request_desc,"msg_size",gras_datadesc_by_name("unsigned int"));
gras_datadesc_struct_append(sat_request_desc,"timeout",gras_datadesc_by_name("unsigned int"));
gras_datadesc_struct_close(sat_request_desc);
* Conduct a test between the local host and @peer, and
* report the result in last args
*/
-gras_error_t amok_bw_test(gras_socket_t peer,
+xbt_error_t amok_bw_test(gras_socket_t peer,
unsigned int buf_size,unsigned int exp_size,unsigned int msg_size,
/*OUT*/ double *sec, double *bw) {
gras_socket_t rawIn,rawOut; /* raw sockets for the experiments */
gras_socket_t sock_dummy; /* ignored arg to msg_wait */
int port;
- gras_error_t errcode;
+ xbt_error_t errcode;
bw_request_t request,request_ack;
for (port = 5000, errcode = system_error;
errcode = gras_socket_server_ext(++port,buf_size,1,&rawIn));
if (errcode != no_error) {
ERROR1("Error %s encountered while opening a raw socket",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
return errcode;
}
- request=gras_new0(s_bw_request_t,1);
+ request=xbt_new0(s_bw_request_t,1);
request->buf_size=buf_size;
request->exp_size=exp_size;
request->msg_size=msg_size;
INFO1("Send an handshake to get the dude connect to port %d on me", request->host.port);
if ((errcode=gras_msg_send(peer,gras_msgtype_by_name("BW handshake"),&request))) {
- ERROR1("Error %s encountered while sending the BW request.", gras_error_name(errcode));
+ ERROR1("Error %s encountered while sending the BW request.", xbt_error_name(errcode));
return errcode;
}
if ((errcode=gras_msg_wait(60,gras_msgtype_by_name("BW handshake ACK"),&sock_dummy,&request_ack))) {
ERROR1("Error %s encountered while waiting for the answer to BW request.\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
return errcode;
}
if((errcode=gras_socket_client_ext(gras_socket_peer_name(peer),request_ack->host.port, buf_size,1,&rawOut))) {
ERROR3("Error %s encountered while opening the raw socket to %s:%d for BW test\n",
- gras_error_name(errcode),gras_socket_peer_name(peer),request_ack->host.port);
+ xbt_error_name(errcode),gras_socket_peer_name(peer),request_ack->host.port);
return errcode;
}
- gras_free(request_ack);
+ xbt_free(request_ack);
INFO0("Got ACK");
*sec=gras_os_time();
if ((errcode=gras_socket_raw_send(rawOut,120,exp_size,msg_size)) ||
(errcode=gras_socket_raw_recv(rawIn,120,1,1))) {
ERROR1("Error %s encountered while sending the BW experiment.",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
gras_socket_close(rawOut);
gras_socket_close(rawIn);
return errcode;
gras_socket_t rawIn,rawOut;
bw_request_t request=*(bw_request_t*)payload;
bw_request_t answer;
- gras_error_t errcode;
+ xbt_error_t errcode;
int port;
INFO2("Got an handshake to connect to %s:%d",
request->host.name,request->host.port);
- answer = gras_new0(s_bw_request_t,1);
+ answer = xbt_new0(s_bw_request_t,1);
for (port = 5000, errcode = system_error;
errcode == system_error;
errcode = gras_socket_server_ext(++port,request->buf_size,1,&rawIn));
if (errcode != no_error) {
- ERROR1("Error %s encountered while opening a raw socket", gras_error_name(errcode));
+ ERROR1("Error %s encountered while opening a raw socket", xbt_error_name(errcode));
/* FIXME: tell error to remote */
return 1;
}
if ((errcode=gras_socket_client_ext(gras_socket_peer_name(expeditor),request->host.port,
request->buf_size,1,&rawOut))) {
ERROR3("Error '%s' encountered while opening a raw socket to %s:%d",
- gras_error_name(errcode),gras_socket_peer_name(expeditor),request->host.port);
+ xbt_error_name(errcode),gras_socket_peer_name(expeditor),request->host.port);
/* FIXME: tell error to remote */
return 1;
}
if ((errcode=gras_msg_send(expeditor,gras_msgtype_by_name("BW handshake ACK"),&answer))) {
ERROR1("Error %s encountered while sending the answer.",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
gras_socket_close(rawIn);
gras_socket_close(rawOut);
/* FIXME: tell error to remote */
if ((errcode=gras_socket_raw_recv(rawIn, 120,request->exp_size,request->msg_size)) ||
(errcode=gras_socket_raw_send(rawOut,120,1,1))) {
ERROR1("Error %s encountered while receiving the experiment.",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
gras_socket_close(rawIn);
gras_socket_close(rawOut);
/* FIXME: tell error to remote ? */
#if 0
/* function to request a BW test between two external hosts */
-gras_error_t grasbw_request(const char* from_name,unsigned int from_port,
+xbt_error_t grasbw_request(const char* from_name,unsigned int from_port,
const char* to_name,unsigned int to_port,
unsigned int bufSize,unsigned int expSize,unsigned int msgSize,
/*OUT*/ double *sec, double*bw) {
gras_sock_t *sock;
gras_msg_t *answer;
- gras_error_t errcode;
+ xbt_error_t errcode;
/* The request */
BwExp_t *request;
msgHost_t *target;
if((errcode=gras_sock_client_open(from_name,from_port,&sock))) {
fprintf(stderr,"grasbw_request(): Error %s encountered while contacting the actuator\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
return errcode;
}
if (!(request=(BwExp_t *)malloc(sizeof(BwExp_t))) ||
target,1,
request,1))) {
fprintf(stderr,"grasbw_request(): Error %s encountered while sending the request.\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
gras_sock_close(sock);
return errcode;
}
if ((errcode=gras_msg_wait(240,GRASMSG_BW_RESULT,&answer))) {
fprintf(stderr,"grasbw_request(): Error %s encountered while waiting for the answer.\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
gras_sock_close(sock);
return errcode;
}
if((errcode=gras_msg_ctn(answer,0,0,msgError_t).errcode)) {
fprintf(stderr,"grasbw_request(): Peer reported error %s (%s).\n",
- gras_error_name(errcode),gras_msg_ctn(answer,0,0,msgError_t).errmsg);
+ xbt_error_name(errcode),gras_msg_ctn(answer,0,0,msgError_t).errmsg);
gras_msg_free(answer);
gras_sock_close(sock);
return errcode;
&(res[0].value),&(res[1].value) ))) {
fprintf(stderr,
"%s:%d:grasbw_cbRequest: Error %s encountered while doing the test\n",
- __FILE__,__LINE__,gras_error_name(error->errcode));
+ __FILE__,__LINE__,xbt_error_name(error->errcode));
strncpy(error->errmsg,"Error within grasbw_test",ERRMSG_LEN);
gras_msg_new_and_send(msg->sock,GRASMSG_BW_RESULT,2,
error,1,
* Link saturation
* ***************************************************************************/
-gras_error_t grasbw_saturate_start(const char* from_name,unsigned int from_port,
+xbt_error_t grasbw_saturate_start(const char* from_name,unsigned int from_port,
const char* to_name,unsigned int to_port,
unsigned int msgSize, unsigned int timeout) {
gras_sock_t *sock;
- gras_error_t errcode;
+ xbt_error_t errcode;
/* The request */
SatExp_t *request;
msgHost_t *target;
if((errcode=gras_sock_client_open(from_name,from_port,&sock))) {
fprintf(stderr,"%s:%d:saturate_start(): Error %s encountered while contacting peer\n",
- __FILE__,__LINE__,gras_error_name(errcode));
+ __FILE__,__LINE__,xbt_error_name(errcode));
return errcode;
}
if (!(request=(SatExp_t *)malloc(sizeof(SatExp_t))) ||
target,1,
request,1))) {
fprintf(stderr,"%s:%d:saturate_start(): Error %s encountered while sending the request.\n",
- __FILE__,__LINE__,gras_error_name(errcode));
+ __FILE__,__LINE__,xbt_error_name(errcode));
gras_sock_close(sock);
return errcode;
}
if ((errcode=gras_msg_wait(120,GRASMSG_SAT_STARTED,&answer))) {
fprintf(stderr,"%s:%d:saturate_start(): Error %s encountered while waiting for the ACK.\n",
- __FILE__,__LINE__,gras_error_name(errcode));
+ __FILE__,__LINE__,xbt_error_name(errcode));
gras_sock_close(sock);
return errcode;
}
if((errcode=gras_msg_ctn(answer,0,0,msgError_t).errcode)) {
fprintf(stderr,"%s:%d:saturate_start(): Peer reported error %s (%s).\n",
- __FILE__,__LINE__,gras_error_name(errcode),gras_msg_ctn(answer,0,0,msgError_t).errmsg);
+ __FILE__,__LINE__,xbt_error_name(errcode),gras_msg_ctn(answer,0,0,msgError_t).errmsg);
gras_msg_free(answer);
gras_sock_close(sock);
return errcode;
int grasbw_cbSatStart(gras_msg_t *msg) {
gras_rawsock_t *raw;
gras_sock_t *sock;
- gras_error_t errcode;
+ xbt_error_t errcode;
double start; /* time to timeout */
/* specification of the test to run */
/* Negociate the saturation with the peer */
if((errcode=gras_sock_client_open(to_name,to_port,&sock))) {
fprintf(stderr,"cbSatStart(): Error %s encountered while contacting peer\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
grasRepportError(msg->sock,GRASMSG_SAT_STARTED,1,
"cbSatStart: Severe error: Cannot send error status to requester!!\n",
errcode,"Cannot contact peer.\n");
if ((errcode=gras_msg_new_and_send(sock,GRASMSG_SAT_BEGIN, 1,
request,1))) {
fprintf(stderr,"cbSatStart(): Error %s encountered while sending the request.\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
grasRepportError(msg->sock,GRASMSG_SAT_STARTED,1,
"cbSatStart: Severe error: Cannot send error status to requester!!\n",
errcode,"Cannot send request.\n");
if ((errcode=gras_msg_wait(120,GRASMSG_SAT_BEGUN,&answer))) {
fprintf(stderr,"cbSatStart(): Error %s encountered while waiting for the ACK.\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
gras_sock_close(sock);
grasRepportError(msg->sock,GRASMSG_SAT_STARTED,1,
if((errcode=gras_msg_ctn(answer,0,0,msgError_t).errcode)) {
fprintf(stderr,"cbSatStart(): Peer reported error %s (%s).\n",
- gras_error_name(errcode),gras_msg_ctn(answer,0,0,msgError_t).errmsg);
+ xbt_error_name(errcode),gras_msg_ctn(answer,0,0,msgError_t).errmsg);
grasRepportError(msg->sock,GRASMSG_SAT_STARTED,1,
"cbSatStart: Severe error: Cannot send error status to requester!!\n",
if ((errcode=gras_rawsock_client_open(to_name,raw_port,msgSize,&raw))) {
fprintf(stderr,"cbSatStart(): Error %s while opening raw socket to %s:%d.\n",
- gras_error_name(errcode),to_name,gras_msg_ctn(answer,1,0,SatExp_t).port);
+ xbt_error_name(errcode),to_name,gras_msg_ctn(answer,1,0,SatExp_t).port);
grasRepportError(msg->sock,GRASMSG_SAT_STARTED,1,
"cbSatStart: Severe error: Cannot send error status to requester!!\n",
/* send a train of data before repporting that XP is started */
if ((errcode=gras_rawsock_send(raw,msgSize,msgSize))) {
- fprintf(stderr,"cbSatStart: Failure %s during raw send\n",gras_error_name(errcode));
+ fprintf(stderr,"cbSatStart: Failure %s during raw send\n",xbt_error_name(errcode));
grasRepportError(msg->sock,GRASMSG_SAT_STARTED,1,
"cbSatStart: Severe error: Cannot send error status to requester!!\n",
errcode,"Cannot raw send.\n");
while (gras_msg_wait(0,GRASMSG_SAT_STOP,&msg)==timeout_error &&
gras_time()-start < timeout) {
if ((errcode=gras_rawsock_send(raw,msgSize,msgSize))) {
- fprintf(stderr,"cbSatStart: Failure %s during raw send\n",gras_error_name(errcode));
+ fprintf(stderr,"cbSatStart: Failure %s during raw send\n",xbt_error_name(errcode));
/* our error message do not interess anyone. SAT_STOP will do nothing. */
gras_sock_close(sock);
gras_rawsock_close(raw);
int grasbw_cbSatBegin(gras_msg_t *msg) {
gras_rawsock_t *raw;
- gras_error_t errcode;
+ xbt_error_t errcode;
double start; /* timer */
/* request */
unsigned int msgSize=gras_msg_ctn(msg,0,0,SatExp_t).msgSize;
if ((errcode=gras_rawsock_server_open(6666,8000,msgSize,&raw))) {
fprintf(stderr,"cbSatBegin(): Error %s encountered while opening a raw socket\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
grasRepportError(msg->sock,GRASMSG_SAT_BEGUN,2,
"cbSatBegin: Severe error: Cannot send error status to requester!!\n",
errcode,"Cannot open raw socket");
error,1,
request,1))) {
fprintf(stderr,"cbSatBegin(): Error %s encountered while send ACK to peer\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
return 1;
}
gras_msg_free(msg);
gras_time() - start < timeout) {
errcode=gras_rawsock_recv(raw,msgSize,msgSize,1);
if (errcode != timeout_error && errcode != no_error) {
- fprintf(stderr,"cbSatBegin: Failure %s during raw receive\n",gras_error_name(errcode));
+ fprintf(stderr,"cbSatBegin: Failure %s during raw receive\n",xbt_error_name(errcode));
/* our error message do not interess anyone. SAT_END will do nothing. */
/* (if timeout'ed, it may be because the sender stopped emission. so survive it) */
return 1;
return 1;
}
-gras_error_t grasbw_saturate_stop(const char* from_name,unsigned int from_port,
+xbt_error_t grasbw_saturate_stop(const char* from_name,unsigned int from_port,
const char* to_name,unsigned int to_port) {
- gras_error_t errcode;
+ xbt_error_t errcode;
gras_sock_t *sock;
gras_msg_t *answer;
if((errcode=gras_sock_client_open(from_name,from_port,&sock))) {
fprintf(stderr,"saturate_stop(): Error %s encountered while contacting peer\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
return errcode;
}
if ((errcode=gras_msg_new_and_send(sock,GRASMSG_SAT_STOP,0))) {
fprintf(stderr,"saturate_stop(): Error %s encountered while sending request\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
gras_sock_close(sock);
return errcode;
}
if ((errcode=gras_msg_wait(120,GRASMSG_SAT_STOPPED,&answer))) {
fprintf(stderr,"saturate_stop(): Error %s encountered while receiving ACK\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
gras_sock_close(sock);
return errcode;
}
if((errcode=gras_msg_ctn(answer,0,0,msgError_t).errcode)) {
fprintf(stderr,"saturate_stop(): Peer reported error %s (%s).\n",
- gras_error_name(errcode),gras_msg_ctn(answer,0,0,msgError_t).errmsg);
+ xbt_error_name(errcode),gras_msg_ctn(answer,0,0,msgError_t).errmsg);
gras_msg_free(answer);
gras_sock_close(sock);
return errcode;
* If not, it should be between between the receiver and @host (3-tiers).
*/
typedef struct {
- gras_host_t host; /* host+raw socket to use */
+ xbt_host_t host; /* host+raw socket to use */
unsigned int buf_size;
unsigned int exp_size;
unsigned int msg_size;
* Description of a saturation experiment (payload asking some host to collaborate for that)
*/
typedef struct {
- gras_host_t host; /* host+raw socket to use */
+ xbt_host_t host; /* host+raw socket to use */
unsigned int msg_size;
unsigned int timeout;
} s_sat_request_t,*sat_request_t;
#include "amok/Bandwidth/bandwidth_private.h"
-GRAS_LOG_EXTERNAL_CATEGORY(bw);
-GRAS_LOG_DEFAULT_CATEGORY(bw);
+XBT_LOG_EXTERNAL_CATEGORY(bw);
+XBT_LOG_DEFAULT_CATEGORY(bw);
#if 0
/* ***************************************************************************
* Link saturation
* ***************************************************************************/
-gras_error_t grasbw_saturate_start(const char* from_name,unsigned int from_port,
+xbt_error_t grasbw_saturate_start(const char* from_name,unsigned int from_port,
const char* to_name,unsigned int to_port,
unsigned int msgSize, unsigned int timeout) {
gras_sock_t *sock;
- gras_error_t errcode;
+ xbt_error_t errcode;
/* The request */
SatExp_t *request;
msgHost_t *target;
if((errcode=gras_sock_client_open(from_name,from_port,&sock))) {
fprintf(stderr,"%s:%d:saturate_start(): Error %s encountered while contacting peer\n",
- __FILE__,__LINE__,gras_error_name(errcode));
+ __FILE__,__LINE__,xbt_error_name(errcode));
return errcode;
}
if (!(request=(SatExp_t *)malloc(sizeof(SatExp_t))) ||
target,1,
request,1))) {
fprintf(stderr,"%s:%d:saturate_start(): Error %s encountered while sending the request.\n",
- __FILE__,__LINE__,gras_error_name(errcode));
+ __FILE__,__LINE__,xbt_error_name(errcode));
gras_sock_close(sock);
return errcode;
}
if ((errcode=gras_msg_wait(120,GRASMSG_SAT_STARTED,&answer))) {
fprintf(stderr,"%s:%d:saturate_start(): Error %s encountered while waiting for the ACK.\n",
- __FILE__,__LINE__,gras_error_name(errcode));
+ __FILE__,__LINE__,xbt_error_name(errcode));
gras_sock_close(sock);
return errcode;
}
if((errcode=gras_msg_ctn(answer,0,0,msgError_t).errcode)) {
fprintf(stderr,"%s:%d:saturate_start(): Peer reported error %s (%s).\n",
- __FILE__,__LINE__,gras_error_name(errcode),gras_msg_ctn(answer,0,0,msgError_t).errmsg);
+ __FILE__,__LINE__,xbt_error_name(errcode),gras_msg_ctn(answer,0,0,msgError_t).errmsg);
gras_msg_free(answer);
gras_sock_close(sock);
return errcode;
int grasbw_cbSatStart(gras_msg_t *msg) {
gras_rawsock_t *raw;
gras_sock_t *sock;
- gras_error_t errcode;
+ xbt_error_t errcode;
double start; /* time to timeout */
/* specification of the test to run */
/* Negociate the saturation with the peer */
if((errcode=gras_sock_client_open(to_name,to_port,&sock))) {
fprintf(stderr,"cbSatStart(): Error %s encountered while contacting peer\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
grasRepportError(msg->sock,GRASMSG_SAT_STARTED,1,
"cbSatStart: Severe error: Cannot send error status to requester!!\n",
errcode,"Cannot contact peer.\n");
if ((errcode=gras_msg_new_and_send(sock,GRASMSG_SAT_BEGIN, 1,
request,1))) {
fprintf(stderr,"cbSatStart(): Error %s encountered while sending the request.\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
grasRepportError(msg->sock,GRASMSG_SAT_STARTED,1,
"cbSatStart: Severe error: Cannot send error status to requester!!\n",
errcode,"Cannot send request.\n");
if ((errcode=gras_msg_wait(120,GRASMSG_SAT_BEGUN,&answer))) {
fprintf(stderr,"cbSatStart(): Error %s encountered while waiting for the ACK.\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
gras_sock_close(sock);
grasRepportError(msg->sock,GRASMSG_SAT_STARTED,1,
if((errcode=gras_msg_ctn(answer,0,0,msgError_t).errcode)) {
fprintf(stderr,"cbSatStart(): Peer reported error %s (%s).\n",
- gras_error_name(errcode),gras_msg_ctn(answer,0,0,msgError_t).errmsg);
+ xbt_error_name(errcode),gras_msg_ctn(answer,0,0,msgError_t).errmsg);
grasRepportError(msg->sock,GRASMSG_SAT_STARTED,1,
"cbSatStart: Severe error: Cannot send error status to requester!!\n",
if ((errcode=gras_rawsock_client_open(to_name,raw_port,msgSize,&raw))) {
fprintf(stderr,"cbSatStart(): Error %s while opening raw socket to %s:%d.\n",
- gras_error_name(errcode),to_name,gras_msg_ctn(answer,1,0,SatExp_t).port);
+ xbt_error_name(errcode),to_name,gras_msg_ctn(answer,1,0,SatExp_t).port);
grasRepportError(msg->sock,GRASMSG_SAT_STARTED,1,
"cbSatStart: Severe error: Cannot send error status to requester!!\n",
/* send a train of data before repporting that XP is started */
if ((errcode=gras_rawsock_send(raw,msgSize,msgSize))) {
- fprintf(stderr,"cbSatStart: Failure %s during raw send\n",gras_error_name(errcode));
+ fprintf(stderr,"cbSatStart: Failure %s during raw send\n",xbt_error_name(errcode));
grasRepportError(msg->sock,GRASMSG_SAT_STARTED,1,
"cbSatStart: Severe error: Cannot send error status to requester!!\n",
errcode,"Cannot raw send.\n");
while (gras_msg_wait(0,GRASMSG_SAT_STOP,&msg)==timeout_error &&
gras_time()-start < timeout) {
if ((errcode=gras_rawsock_send(raw,msgSize,msgSize))) {
- fprintf(stderr,"cbSatStart: Failure %s during raw send\n",gras_error_name(errcode));
+ fprintf(stderr,"cbSatStart: Failure %s during raw send\n",xbt_error_name(errcode));
/* our error message do not interess anyone. SAT_STOP will do nothing. */
gras_sock_close(sock);
gras_rawsock_close(raw);
int grasbw_cbSatBegin(gras_msg_t *msg) {
gras_rawsock_t *raw;
- gras_error_t errcode;
+ xbt_error_t errcode;
double start; /* timer */
/* request */
unsigned int msgSize=gras_msg_ctn(msg,0,0,SatExp_t).msgSize;
if ((errcode=gras_rawsock_server_open(6666,8000,msgSize,&raw))) {
fprintf(stderr,"cbSatBegin(): Error %s encountered while opening a raw socket\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
grasRepportError(msg->sock,GRASMSG_SAT_BEGUN,2,
"cbSatBegin: Severe error: Cannot send error status to requester!!\n",
errcode,"Cannot open raw socket");
error,1,
request,1))) {
fprintf(stderr,"cbSatBegin(): Error %s encountered while send ACK to peer\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
return 1;
}
gras_msg_free(msg);
gras_time() - start < timeout) {
errcode=gras_rawsock_recv(raw,msgSize,msgSize,1);
if (errcode != timeout_error && errcode != no_error) {
- fprintf(stderr,"cbSatBegin: Failure %s during raw receive\n",gras_error_name(errcode));
+ fprintf(stderr,"cbSatBegin: Failure %s during raw receive\n",xbt_error_name(errcode));
/* our error message do not interess anyone. SAT_END will do nothing. */
/* (if timeout'ed, it may be because the sender stopped emission. so survive it) */
return 1;
return 1;
}
-gras_error_t grasbw_saturate_stop(const char* from_name,unsigned int from_port,
+xbt_error_t grasbw_saturate_stop(const char* from_name,unsigned int from_port,
const char* to_name,unsigned int to_port) {
- gras_error_t errcode;
+ xbt_error_t errcode;
gras_sock_t *sock;
gras_msg_t *answer;
if((errcode=gras_sock_client_open(from_name,from_port,&sock))) {
fprintf(stderr,"saturate_stop(): Error %s encountered while contacting peer\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
return errcode;
}
if ((errcode=gras_msg_new_and_send(sock,GRASMSG_SAT_STOP,0))) {
fprintf(stderr,"saturate_stop(): Error %s encountered while sending request\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
gras_sock_close(sock);
return errcode;
}
if ((errcode=gras_msg_wait(120,GRASMSG_SAT_STOPPED,&answer))) {
fprintf(stderr,"saturate_stop(): Error %s encountered while receiving ACK\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
gras_sock_close(sock);
return errcode;
}
if((errcode=gras_msg_ctn(answer,0,0,msgError_t).errcode)) {
fprintf(stderr,"saturate_stop(): Peer reported error %s (%s).\n",
- gras_error_name(errcode),gras_msg_ctn(answer,0,0,msgError_t).errmsg);
+ xbt_error_name(errcode),gras_msg_ctn(answer,0,0,msgError_t).errmsg);
gras_msg_free(answer);
gras_sock_close(sock);
return errcode;
* If not, it should be between between the receiver and @host (3-tiers).
*/
typedef struct {
- gras_host_t host; /* host+raw socket to use */
+ xbt_host_t host; /* host+raw socket to use */
unsigned int buf_size;
unsigned int exp_size;
unsigned int msg_size;
* Description of a saturation experiment (payload asking some host to collaborate for that)
*/
typedef struct {
- gras_host_t host; /* host+raw socket to use */
+ xbt_host_t host; /* host+raw socket to use */
unsigned int msg_size;
unsigned int timeout;
} sat_request_t;
/**** code ****/
void amok_bw_init(void) {
- gras_error_t errcode;
+ xbt_error_t errcode;
gras_datadesc_type_t *bw_request_desc, *bw_res_desc, *sat_request_desc;
amok_base_init();
/* Build the datatype descriptions */
bw_request_desc = gras_datadesc_struct("bw_request_t");
- gras_datadesc_struct_append(bw_request_desc,"host",gras_datadesc_by_name("gras_host_t*"));
+ gras_datadesc_struct_append(bw_request_desc,"host",gras_datadesc_by_name("xbt_host_t*"));
gras_datadesc_struct_append(bw_request_desc,"buf_size",gras_datadesc_by_name("unsigned int"));
gras_datadesc_struct_append(bw_request_desc,"exp_size",gras_datadesc_by_name("unsigned int"));
gras_datadesc_struct_append(bw_request_desc,"msg_size",gras_datadesc_by_name("unsigned int"));
bw_res_desc = gras_datadesc_ref("bw_res_t*",bw_res_desc);
sat_request_desc = gras_datadesc_struct("sat_request_desc");
- gras_datadesc_struct_append(sat_request_desc,"host",gras_datadesc_by_name("gras_host_t"));
+ gras_datadesc_struct_append(sat_request_desc,"host",gras_datadesc_by_name("xbt_host_t"));
gras_datadesc_struct_append(sat_request_desc,"msg_size",gras_datadesc_by_name("unsigned int"));
gras_datadesc_struct_append(sat_request_desc,"timeout",gras_datadesc_by_name("unsigned int"));
gras_datadesc_struct_close(sat_request_desc);
* Conduct a test between the local host and @peer, and
* report the result in last args
*/
-gras_error_t amok_bw_test(gras_socket_t *peer,
+xbt_error_t amok_bw_test(gras_socket_t *peer,
unsigned int bufSize,unsigned int expSize,unsigned int msgSize,
/*OUT*/ double *sec, double *bw) {
gras_socket_t *rawIn,*rawOut;
int port;
- gras_error_t errcode;
+ xbt_error_t errcode;
bw_request_t *request;
gras_msg_t *answer;
errcode = gras_socket_server_ext(++port,bufSize,1,&rawIn));
if (errcode != no_error) {
ERROR1("Error %s encountered while opening a raw socket\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
return errcode;
}
- request=gras_new(bw_request_t);
+ request=xbt_new(bw_request_t);
request->bufSize=bufSize;
request->expSize=expSize;
request->msgSize=msgSize;
request->host.port = gras_socket_peer_port(rawIn);
if ((errcode=gras_send(peer,gras_msgtype_by_name("BW handshake"),request))) {
- ERROR1("Error %s encountered while sending the request.", gras_error_name(errcode));
+ ERROR1("Error %s encountered while sending the request.", xbt_error_name(errcode));
gras_sock_close(sock);
return errcode;
}
if ((errcode=gras_msg_wait(60,GRASMSG_BW_HANDSHAKED,&answer))) {
fprintf(stderr,"grasbw_test(): Error %s encountered while waiting for the answer.\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
gras_sock_close(sock);
return errcode;
}
if((errcode=gras_rawsock_client_open(to_name,gras_msg_ctn(answer,0,0,BwExp_t).port,
bufSize,&rawOut))) {
fprintf(stderr,"grasbw_test(): Error %s encountered while opening the raw socket to %s:%d\n",
- gras_error_name(errcode),to_name,gras_msg_ctn(answer,0,0,BwExp_t).port);
+ xbt_error_name(errcode),to_name,gras_msg_ctn(answer,0,0,BwExp_t).port);
return errcode;
}
if ((errcode=gras_rawsock_send(rawOut,expSize,msgSize)) ||
(errcode=gras_rawsock_recv(rawIn,1,1,120))) {
fprintf(stderr,"grasbw_test(): Error %s encountered while sending the experiment.\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
gras_rawsock_close(rawOut);
gras_rawsock_close(rawIn);
return errcode;
int grasbw_cbBWHandshake(gras_msg_t *msg) {
gras_rawsock_t *rawIn,*rawOut;
BwExp_t *ans;
- gras_error_t errcode;
+ xbt_error_t errcode;
if ((errcode=gras_rawsock_server_open(6666,8000,gras_msg_ctn(msg,0,0,BwExp_t).bufSize,&rawIn))) {
fprintf(stderr,"grasbw_cbHandshake(): Error %s encountered while opening a raw socket\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
return 1;
}
if ((errcode=gras_rawsock_client_open(gras_sock_get_peer_name(msg->sock),gras_msg_ctn(msg,0,0,BwExp_t).port,
gras_msg_ctn(msg,0,0,BwExp_t).bufSize,&rawOut))) {
fprintf(stderr,"grasbw_cbHandshake(): Error %s encountered while opening a raw socket\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
return 1;
}
if (!(ans=(BwExp_t *)malloc(sizeof(BwExp_t)))) {
if ((errcode=gras_msg_new_and_send(msg->sock,GRASMSG_BW_HANDSHAKED, 1,
ans, 1))) {
fprintf(stderr,"grasbw_cbHandshake(): Error %s encountered while sending the answer.\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
gras_rawsock_close(rawIn);
gras_rawsock_close(rawOut);
return 1;
120)) ||
(errcode=gras_rawsock_send(rawOut,1,1))) {
fprintf(stderr,"grasbw_cbHandshake(): Error %s encountered while receiving the experiment.\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
gras_rawsock_close(rawIn);
gras_rawsock_close(rawOut);
return 1;
}
/* function to request a BW test between to external hosts */
-gras_error_t grasbw_request(const char* from_name,unsigned int from_port,
+xbt_error_t grasbw_request(const char* from_name,unsigned int from_port,
const char* to_name,unsigned int to_port,
unsigned int bufSize,unsigned int expSize,unsigned int msgSize,
/*OUT*/ double *sec, double*bw) {
gras_sock_t *sock;
gras_msg_t *answer;
- gras_error_t errcode;
+ xbt_error_t errcode;
/* The request */
BwExp_t *request;
msgHost_t *target;
if((errcode=gras_sock_client_open(from_name,from_port,&sock))) {
fprintf(stderr,"grasbw_request(): Error %s encountered while contacting the actuator\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
return errcode;
}
if (!(request=(BwExp_t *)malloc(sizeof(BwExp_t))) ||
target,1,
request,1))) {
fprintf(stderr,"grasbw_request(): Error %s encountered while sending the request.\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
gras_sock_close(sock);
return errcode;
}
if ((errcode=gras_msg_wait(240,GRASMSG_BW_RESULT,&answer))) {
fprintf(stderr,"grasbw_request(): Error %s encountered while waiting for the answer.\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
gras_sock_close(sock);
return errcode;
}
if((errcode=gras_msg_ctn(answer,0,0,msgError_t).errcode)) {
fprintf(stderr,"grasbw_request(): Peer reported error %s (%s).\n",
- gras_error_name(errcode),gras_msg_ctn(answer,0,0,msgError_t).errmsg);
+ xbt_error_name(errcode),gras_msg_ctn(answer,0,0,msgError_t).errmsg);
gras_msg_free(answer);
gras_sock_close(sock);
return errcode;
&(res[0].value),&(res[1].value) ))) {
fprintf(stderr,
"%s:%d:grasbw_cbRequest: Error %s encountered while doing the test\n",
- __FILE__,__LINE__,gras_error_name(error->errcode));
+ __FILE__,__LINE__,xbt_error_name(error->errcode));
strncpy(error->errmsg,"Error within grasbw_test",ERRMSG_LEN);
gras_msg_new_and_send(msg->sock,GRASMSG_BW_RESULT,2,
error,1,
* Link saturation
* ***************************************************************************/
-gras_error_t grasbw_saturate_start(const char* from_name,unsigned int from_port,
+xbt_error_t grasbw_saturate_start(const char* from_name,unsigned int from_port,
const char* to_name,unsigned int to_port,
unsigned int msgSize, unsigned int timeout) {
gras_sock_t *sock;
- gras_error_t errcode;
+ xbt_error_t errcode;
/* The request */
SatExp_t *request;
msgHost_t *target;
if((errcode=gras_sock_client_open(from_name,from_port,&sock))) {
fprintf(stderr,"%s:%d:saturate_start(): Error %s encountered while contacting peer\n",
- __FILE__,__LINE__,gras_error_name(errcode));
+ __FILE__,__LINE__,xbt_error_name(errcode));
return errcode;
}
if (!(request=(SatExp_t *)malloc(sizeof(SatExp_t))) ||
target,1,
request,1))) {
fprintf(stderr,"%s:%d:saturate_start(): Error %s encountered while sending the request.\n",
- __FILE__,__LINE__,gras_error_name(errcode));
+ __FILE__,__LINE__,xbt_error_name(errcode));
gras_sock_close(sock);
return errcode;
}
if ((errcode=gras_msg_wait(120,GRASMSG_SAT_STARTED,&answer))) {
fprintf(stderr,"%s:%d:saturate_start(): Error %s encountered while waiting for the ACK.\n",
- __FILE__,__LINE__,gras_error_name(errcode));
+ __FILE__,__LINE__,xbt_error_name(errcode));
gras_sock_close(sock);
return errcode;
}
if((errcode=gras_msg_ctn(answer,0,0,msgError_t).errcode)) {
fprintf(stderr,"%s:%d:saturate_start(): Peer reported error %s (%s).\n",
- __FILE__,__LINE__,gras_error_name(errcode),gras_msg_ctn(answer,0,0,msgError_t).errmsg);
+ __FILE__,__LINE__,xbt_error_name(errcode),gras_msg_ctn(answer,0,0,msgError_t).errmsg);
gras_msg_free(answer);
gras_sock_close(sock);
return errcode;
int grasbw_cbSatStart(gras_msg_t *msg) {
gras_rawsock_t *raw;
gras_sock_t *sock;
- gras_error_t errcode;
+ xbt_error_t errcode;
double start; /* time to timeout */
/* specification of the test to run */
/* Negociate the saturation with the peer */
if((errcode=gras_sock_client_open(to_name,to_port,&sock))) {
fprintf(stderr,"cbSatStart(): Error %s encountered while contacting peer\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
grasRepportError(msg->sock,GRASMSG_SAT_STARTED,1,
"cbSatStart: Severe error: Cannot send error status to requester!!\n",
errcode,"Cannot contact peer.\n");
if ((errcode=gras_msg_new_and_send(sock,GRASMSG_SAT_BEGIN, 1,
request,1))) {
fprintf(stderr,"cbSatStart(): Error %s encountered while sending the request.\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
grasRepportError(msg->sock,GRASMSG_SAT_STARTED,1,
"cbSatStart: Severe error: Cannot send error status to requester!!\n",
errcode,"Cannot send request.\n");
if ((errcode=gras_msg_wait(120,GRASMSG_SAT_BEGUN,&answer))) {
fprintf(stderr,"cbSatStart(): Error %s encountered while waiting for the ACK.\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
gras_sock_close(sock);
grasRepportError(msg->sock,GRASMSG_SAT_STARTED,1,
if((errcode=gras_msg_ctn(answer,0,0,msgError_t).errcode)) {
fprintf(stderr,"cbSatStart(): Peer reported error %s (%s).\n",
- gras_error_name(errcode),gras_msg_ctn(answer,0,0,msgError_t).errmsg);
+ xbt_error_name(errcode),gras_msg_ctn(answer,0,0,msgError_t).errmsg);
grasRepportError(msg->sock,GRASMSG_SAT_STARTED,1,
"cbSatStart: Severe error: Cannot send error status to requester!!\n",
if ((errcode=gras_rawsock_client_open(to_name,raw_port,msgSize,&raw))) {
fprintf(stderr,"cbSatStart(): Error %s while opening raw socket to %s:%d.\n",
- gras_error_name(errcode),to_name,gras_msg_ctn(answer,1,0,SatExp_t).port);
+ xbt_error_name(errcode),to_name,gras_msg_ctn(answer,1,0,SatExp_t).port);
grasRepportError(msg->sock,GRASMSG_SAT_STARTED,1,
"cbSatStart: Severe error: Cannot send error status to requester!!\n",
/* send a train of data before repporting that XP is started */
if ((errcode=gras_rawsock_send(raw,msgSize,msgSize))) {
- fprintf(stderr,"cbSatStart: Failure %s during raw send\n",gras_error_name(errcode));
+ fprintf(stderr,"cbSatStart: Failure %s during raw send\n",xbt_error_name(errcode));
grasRepportError(msg->sock,GRASMSG_SAT_STARTED,1,
"cbSatStart: Severe error: Cannot send error status to requester!!\n",
errcode,"Cannot raw send.\n");
while (gras_msg_wait(0,GRASMSG_SAT_STOP,&msg)==timeout_error &&
gras_time()-start < timeout) {
if ((errcode=gras_rawsock_send(raw,msgSize,msgSize))) {
- fprintf(stderr,"cbSatStart: Failure %s during raw send\n",gras_error_name(errcode));
+ fprintf(stderr,"cbSatStart: Failure %s during raw send\n",xbt_error_name(errcode));
/* our error message do not interess anyone. SAT_STOP will do nothing. */
gras_sock_close(sock);
gras_rawsock_close(raw);
int grasbw_cbSatBegin(gras_msg_t *msg) {
gras_rawsock_t *raw;
- gras_error_t errcode;
+ xbt_error_t errcode;
double start; /* timer */
/* request */
unsigned int msgSize=gras_msg_ctn(msg,0,0,SatExp_t).msgSize;
if ((errcode=gras_rawsock_server_open(6666,8000,msgSize,&raw))) {
fprintf(stderr,"cbSatBegin(): Error %s encountered while opening a raw socket\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
grasRepportError(msg->sock,GRASMSG_SAT_BEGUN,2,
"cbSatBegin: Severe error: Cannot send error status to requester!!\n",
errcode,"Cannot open raw socket");
error,1,
request,1))) {
fprintf(stderr,"cbSatBegin(): Error %s encountered while send ACK to peer\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
return 1;
}
gras_msg_free(msg);
gras_time() - start < timeout) {
errcode=gras_rawsock_recv(raw,msgSize,msgSize,1);
if (errcode != timeout_error && errcode != no_error) {
- fprintf(stderr,"cbSatBegin: Failure %s during raw receive\n",gras_error_name(errcode));
+ fprintf(stderr,"cbSatBegin: Failure %s during raw receive\n",xbt_error_name(errcode));
/* our error message do not interess anyone. SAT_END will do nothing. */
/* (if timeout'ed, it may be because the sender stopped emission. so survive it) */
return 1;
return 1;
}
-gras_error_t grasbw_saturate_stop(const char* from_name,unsigned int from_port,
+xbt_error_t grasbw_saturate_stop(const char* from_name,unsigned int from_port,
const char* to_name,unsigned int to_port) {
- gras_error_t errcode;
+ xbt_error_t errcode;
gras_sock_t *sock;
gras_msg_t *answer;
if((errcode=gras_sock_client_open(from_name,from_port,&sock))) {
fprintf(stderr,"saturate_stop(): Error %s encountered while contacting peer\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
return errcode;
}
if ((errcode=gras_msg_new_and_send(sock,GRASMSG_SAT_STOP,0))) {
fprintf(stderr,"saturate_stop(): Error %s encountered while sending request\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
gras_sock_close(sock);
return errcode;
}
if ((errcode=gras_msg_wait(120,GRASMSG_SAT_STOPPED,&answer))) {
fprintf(stderr,"saturate_stop(): Error %s encountered while receiving ACK\n",
- gras_error_name(errcode));
+ xbt_error_name(errcode));
gras_sock_close(sock);
return errcode;
}
if((errcode=gras_msg_ctn(answer,0,0,msgError_t).errcode)) {
fprintf(stderr,"saturate_stop(): Peer reported error %s (%s).\n",
- gras_error_name(errcode),gras_msg_ctn(answer,0,0,msgError_t).errmsg);
+ xbt_error_name(errcode),gras_msg_ctn(answer,0,0,msgError_t).errmsg);
gras_msg_free(answer);
gras_sock_close(sock);
return errcode;
#include "gras/datadesc.h"
#include "amok/base.h"
-GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(amok,GRAS_LOG_ROOT_CAT,"All AMOK categories");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(amok,XBT_LOG_ROOT_CAT,"All AMOK categories");
-amok_remoterr_t amok_remoterr_new(gras_error_t param_errcode,
+amok_remoterr_t amok_remoterr_new(xbt_error_t param_errcode,
const char* format,...) {
amok_remoterr_t res;
return res;
}
-amok_remoterr_t amok_remoterr_new_va(gras_error_t param_errcode,
+amok_remoterr_t amok_remoterr_new_va(xbt_error_t param_errcode,
const char* format,va_list ap) {
- amok_remoterr_t res=gras_new(s_amok_remoterr_t,1);
+ amok_remoterr_t res=xbt_new(s_amok_remoterr_t,1);
res->code=param_errcode;
if (format) {
- res->msg=(char*)gras_malloc(1024);
+ res->msg=(char*)xbt_malloc(1024);
vsnprintf(res->msg,1024,format,ap);
} else {
res->msg = NULL;
void amok_remoterr_free(amok_remoterr_t *err) {
if (err && *err) {
- if ((*err)->msg) gras_free((*err)->msg);
- gras_free(*err);
+ if ((*err)->msg) xbt_free((*err)->msg);
+ xbt_free(*err);
err=NULL;
}
}
void
amok_repport_error (gras_socket_t sock, gras_msgtype_t msgtype,
- gras_error_t param_errcode, const char* format,...) {
+ xbt_error_t param_errcode, const char* format,...) {
amok_remoterr_t error;
- gras_error_t errcode;
+ xbt_error_t errcode;
va_list ap;
- error=gras_new(s_amok_remoterr_t,1);
+ error=xbt_new(s_amok_remoterr_t,1);
error->code=param_errcode;
- error->msg=(char*)gras_malloc(1024); /* FIXME */
+ error->msg=(char*)xbt_malloc(1024); /* FIXME */
va_start(ap,format);
vsnprintf(error->msg,1024,format,ap);
va_end(ap);
errcode = gras_msg_send(sock,msgtype,error);
if (errcode != no_error) {
CRITICAL4("Error '%s' while reporting error '%s' to %s:%d",
- gras_error_name(errcode),error->msg,
+ xbt_error_name(errcode),error->msg,
gras_socket_peer_name(sock),gras_socket_peer_port(sock) );
}
}
gras_datadesc_type_t host_desc, remoterr_desc;
/* Build the datatype descriptions */
- host_desc = gras_datadesc_struct("gras_host_t");
+ host_desc = gras_datadesc_struct("xbt_host_t");
gras_datadesc_struct_append(host_desc,"name",gras_datadesc_by_name("string"));
gras_datadesc_struct_append(host_desc,"exp_size",gras_datadesc_by_name("int"));
gras_datadesc_struct_close(host_desc);
- host_desc = gras_datadesc_ref("gras_host_t*",host_desc);
+ host_desc = gras_datadesc_ref("xbt_host_t*",host_desc);
remoterr_desc = gras_datadesc_struct("s_amok_remoterr_t");
gras_datadesc_struct_append(remoterr_desc,"msg",gras_datadesc_by_name("string"));
under the terms of the license (GNU LGPL) which comes with this package. */
#include "gras/DataDesc/datadesc_private.h"
-GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(ddt_cbps,datadesc,"callback persistant state");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ddt_cbps,datadesc,"callback persistant state");
typedef struct {
gras_datadesc_type_t type;
} s_gras_cbps_elm_t, *gras_cbps_elm_t;
typedef struct s_gras_cbps {
- gras_dynar_t lints; /* simple stack of long integers (easy interface) */
+ xbt_dynar_t lints; /* simple stack of long integers (easy interface) */
- gras_dict_t space; /* varname x dynar of gras_cbps_elm_t */
- gras_dynar_t frames; /* of dynar of names defined within this frame
+ xbt_dict_t space; /* varname x dynar of gras_cbps_elm_t */
+ xbt_dynar_t frames; /* of dynar of names defined within this frame
(and to pop when we leave it) */
- gras_dynar_t globals;
+ xbt_dynar_t globals;
} s_gras_cbps_t;
static void free_string(void *d);
static void free_string(void *d){
- gras_free(*(void**)d);
+ xbt_free(*(void**)d);
}
gras_cbps_t gras_cbps_new(void) {
- gras_error_t errcode;
+ xbt_error_t errcode;
gras_cbps_t res;
- res=gras_new(s_gras_cbps_t,1);
+ res=xbt_new(s_gras_cbps_t,1);
- res->lints = gras_dynar_new(sizeof(int), NULL);
- res->space = gras_dict_new();
+ res->lints = xbt_dynar_new(sizeof(int), NULL);
+ res->space = xbt_dict_new();
/* no leak, the content is freed manually on block_end */
- res->frames = gras_dynar_new(sizeof(gras_dynar_t), NULL);
- res->globals = gras_dynar_new(sizeof(char*), NULL);
+ res->frames = xbt_dynar_new(sizeof(xbt_dynar_t), NULL);
+ res->globals = xbt_dynar_new(sizeof(char*), NULL);
gras_cbps_block_begin(res);
void gras_cbps_free(gras_cbps_t *state) {
- gras_dynar_free( &( (*state)->lints ) );
+ xbt_dynar_free( &( (*state)->lints ) );
gras_cbps_block_end(*state);
- gras_dict_free ( &( (*state)->space ) );
- gras_dynar_free( &( (*state)->frames ) );
- gras_dynar_free( &( (*state)->globals ) );
+ xbt_dict_free ( &( (*state)->space ) );
+ xbt_dynar_free( &( (*state)->frames ) );
+ xbt_dynar_free( &( (*state)->globals ) );
- gras_free(*state);
+ xbt_free(*state);
*state = NULL;
}
* name already exists, it is masked by the one given here, and will be
* seeable again only after a pop to remove the value this push adds.
*/
-gras_error_t
+xbt_error_t
gras_cbps_v_push(gras_cbps_t ps,
const char *name,
void *data,
gras_datadesc_type_t ddt) {
- gras_dynar_t varstack,frame;
+ xbt_dynar_t varstack,frame;
gras_cbps_elm_t var;
- gras_error_t errcode;
+ xbt_error_t errcode;
char *varname = (char*)strdup(name);
DEBUG2("push(%s,%p)",name,(void*)data);
- errcode = gras_dict_get(ps->space, name, (void **)&varstack);
+ errcode = xbt_dict_get(ps->space, name, (void **)&varstack);
if (errcode == mismatch_error) {
DEBUG1("Create a new variable stack for '%s' into the space",name);
- varstack = gras_dynar_new(sizeof (gras_cbps_elm_t *), NULL);
- gras_dict_set(ps->space, varname, (void **)varstack, NULL);
+ varstack = xbt_dynar_new(sizeof (gras_cbps_elm_t *), NULL);
+ xbt_dict_set(ps->space, varname, (void **)varstack, NULL);
/* leaking, you think? only if you do not close all the openned blocks ;)*/
} else if (errcode != no_error) {
return errcode;
}
- var = gras_new0(s_gras_cbps_elm_t,1);
+ var = xbt_new0(s_gras_cbps_elm_t,1);
var->type = ddt;
var->data = data;
- gras_dynar_push(varstack, &var);
+ xbt_dynar_push(varstack, &var);
- gras_dynar_pop(ps->frames, &frame);
+ xbt_dynar_pop(ps->frames, &frame);
DEBUG4("Push %s (%p @%p) into frame %p",varname,(void*)varname,(void*)&varname,(void*)frame);
- gras_dynar_push(frame, &varname);
- gras_dynar_push(ps->frames, &frame);
+ xbt_dynar_push(frame, &varname);
+ xbt_dynar_push(ps->frames, &frame);
return no_error;
}
* present in the current block, it will fail (with abort) and not search
* in upper blocks since this denotes a programmation error.
*/
-gras_error_t
+xbt_error_t
gras_cbps_v_pop (gras_cbps_t ps,
const char *name,
gras_datadesc_type_t *ddt,
void **res) {
- gras_dynar_t varstack,frame;
+ xbt_dynar_t varstack,frame;
gras_cbps_elm_t var = NULL;
void *data = NULL;
- gras_error_t errcode;
+ xbt_error_t errcode;
DEBUG1("pop(%s)",name);
/* FIXME: Error handling */
- errcode = gras_dict_get(ps->space, name, (void **)&varstack);
+ errcode = xbt_dict_get(ps->space, name, (void **)&varstack);
if (errcode == mismatch_error) {
RAISE1(mismatch_error,"Asked to pop the non-existant %s",
name);
}
- gras_dynar_pop(varstack, &var);
+ xbt_dynar_pop(varstack, &var);
- if (!gras_dynar_length(varstack)) {
+ if (!xbt_dynar_length(varstack)) {
DEBUG1("Last incarnation of %s poped. Kill it",name);
- gras_dict_remove(ps->space, name);
- gras_dynar_free(&varstack);
+ xbt_dict_remove(ps->space, name);
+ xbt_dynar_free(&varstack);
}
if (ddt)
*ddt = var->type;
data = var->data;
- gras_free(var);
+ xbt_free(var);
- gras_dynar_pop(ps->frames, &frame);
+ xbt_dynar_pop(ps->frames, &frame);
{
- int l = gras_dynar_length(frame);
+ int l = xbt_dynar_length(frame);
while (l--) {
char *_name = NULL;
- _name = gras_dynar_get_as(frame, l, char*);
+ _name = xbt_dynar_get_as(frame, l, char*);
if (!strcmp(name, _name)) {
- gras_dynar_remove_at(frame, l, &_name);
- gras_free(_name);
+ xbt_dynar_remove_at(frame, l, &_name);
+ xbt_free(_name);
break;
}
}
}
- gras_dynar_push(ps->frames, &frame);
+ xbt_dynar_push(ps->frames, &frame);
*res = data;
return no_error;
void *data,
gras_datadesc_type_t ddt) {
- gras_dynar_t dynar = NULL;
+ xbt_dynar_t dynar = NULL;
gras_cbps_elm_t elm = NULL;
- gras_error_t errcode;
+ xbt_error_t errcode;
DEBUG1("set(%s)",name);
- errcode = gras_dict_get(ps->space, name, (void **)&dynar);
+ errcode = xbt_dict_get(ps->space, name, (void **)&dynar);
if (errcode == mismatch_error) {
- dynar = gras_dynar_new(sizeof (gras_cbps_elm_t), NULL);
- gras_dict_set(ps->space, name, (void **)dynar, NULL);
+ dynar = xbt_dynar_new(sizeof (gras_cbps_elm_t), NULL);
+ xbt_dict_set(ps->space, name, (void **)dynar, NULL);
- elm = gras_new0(s_gras_cbps_elm_t,1);
- gras_dynar_push(ps->globals, &name);
+ elm = xbt_new0(s_gras_cbps_elm_t,1);
+ xbt_dynar_push(ps->globals, &name);
} else {
- gras_dynar_pop(dynar, &elm);
+ xbt_dynar_pop(dynar, &elm);
}
elm->type = ddt;
elm->data = data;
- gras_dynar_push(dynar, &elm);
+ xbt_dynar_push(dynar, &elm);
}
const char *name,
/* OUT */gras_datadesc_type_t *ddt) {
- gras_dynar_t dynar = NULL;
+ xbt_dynar_t dynar = NULL;
gras_cbps_elm_t elm = NULL;
DEBUG1("get(%s)",name);
/* FIXME: Error handling */
- gras_dict_get(ps->space, name, (void **)&dynar);
- gras_dynar_pop(dynar, &elm);
- gras_dynar_push(dynar, &elm);
+ xbt_dict_get(ps->space, name, (void **)&dynar);
+ xbt_dynar_pop(dynar, &elm);
+ xbt_dynar_push(dynar, &elm);
if (ddt) {
*ddt = elm->type;
void
gras_cbps_block_begin(gras_cbps_t ps) {
- gras_dynar_t dynar = NULL;
+ xbt_dynar_t dynar = NULL;
DEBUG0(">>> Block begin");
- dynar = gras_dynar_new(sizeof (char *), NULL);
- gras_dynar_push(ps->frames, &dynar);
+ dynar = xbt_dynar_new(sizeof (char *), NULL);
+ xbt_dynar_push(ps->frames, &dynar);
}
/**
void
gras_cbps_block_end(gras_cbps_t ps) {
- gras_dynar_t frame = NULL;
+ xbt_dynar_t frame = NULL;
int cursor = 0;
char *name = NULL;
- gras_assert0(gras_dynar_length(ps->frames),
+ xbt_assert0(xbt_dynar_length(ps->frames),
"More block_end than block_begin");
- gras_dynar_pop(ps->frames, &frame);
+ xbt_dynar_pop(ps->frames, &frame);
- gras_dynar_foreach(frame, cursor, name) {
+ xbt_dynar_foreach(frame, cursor, name) {
- gras_dynar_t varstack = NULL;
+ xbt_dynar_t varstack = NULL;
gras_cbps_elm_t var = NULL;
DEBUG2("Get ride of %s (%p)",name,(void*)name);
- gras_dict_get(ps->space, name, (void **)&varstack);
- gras_dynar_pop(varstack, &var);
+ xbt_dict_get(ps->space, name, (void **)&varstack);
+ xbt_dynar_pop(varstack, &var);
- if (!gras_dynar_length(varstack)) {
- gras_dict_remove(ps->space, name);
- gras_dynar_free_container(&varstack); /*already empty, save a test ;) */
+ if (!xbt_dynar_length(varstack)) {
+ xbt_dict_remove(ps->space, name);
+ xbt_dynar_free_container(&varstack); /*already empty, save a test ;) */
}
- if (var->data) gras_free(var->data);
- gras_free(var);
- gras_free(name);
+ if (var->data) xbt_free(var->data);
+ xbt_free(var);
+ xbt_free(name);
}
- gras_dynar_free_container(&frame);/* we just emptied it */
+ xbt_dynar_free_container(&frame);/* we just emptied it */
DEBUG0("<<< Block end");
}
void
gras_cbps_i_push(gras_cbps_t ps,
int val) {
- gras_error_t errcode;
+ xbt_error_t errcode;
DEBUG1("push %d as a size",val);
- gras_dynar_push_as(ps->lints,int,val);
+ xbt_dynar_push_as(ps->lints,int,val);
}
/**
* gras_cbps_i_pop:
gras_cbps_i_pop(gras_cbps_t ps) {
int ret;
- gras_assert0(gras_dynar_length(ps->lints) > 0,
+ xbt_assert0(xbt_dynar_length(ps->lints) > 0,
"gras_cbps_i_pop: no value to pop");
- ret = gras_dynar_pop_as(ps->lints,int);
+ ret = xbt_dynar_pop_as(ps->lints,int);
DEBUG1("pop %d as a size",ret);
return ret;
}
#include "gras/DataDesc/datadesc_private.h"
-GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(datadesc,gras,"Data description");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(datadesc,gras,"Data description");
/* FIXME: make this host-dependent using a trick such as UserData*/
-gras_set_t gras_datadesc_set_local=NULL;
+xbt_set_t gras_datadesc_set_local=NULL;
/* callback for array size when sending strings */
**/
void
gras_datadesc_init(void) {
- gras_error_t errcode;
+ xbt_error_t errcode;
gras_datadesc_type_t ddt; /* What to add */
/* only initialize once */
VERB0("Initializing DataDesc");
- gras_datadesc_set_local = gras_set_new();
+ gras_datadesc_set_local = xbt_set_new();
ddt = gras_datadesc_scalar("signed char",
gras_ddt_scalar_char,
void
gras_datadesc_exit(void) {
VERB0("Exiting DataDesc");
- gras_set_free(&gras_datadesc_set_local);
+ xbt_set_free(&gras_datadesc_set_local);
DEBUG0("Exited DataDesc");
}
gras_dd_cat_field_t field;
struct_data = ddt->category.struct_data;
- gras_dynar_foreach(struct_data.fields, cpt, field) {
+ xbt_dynar_foreach(struct_data.fields, cpt, field) {
printf(">>> Dump field #%d (%s) (offset=%ld)\n",
cpt,field->name,field->offset[GRAS_THISARCH]);
gras_datadesc_type_dump(field->type);
#ifndef GRAS_DATADESC_INTERFACE_H
#define GRAS_DATADESC_INTERFACE_H
-gras_error_t gras_datadesc_by_id (long int code,
+xbt_error_t gras_datadesc_by_id (long int code,
gras_datadesc_type_t *type);
/* to debug */
/* Access function */
int gras_datadesc_size(gras_datadesc_type_t type);
/* Described data exchanges */
-gras_error_t gras_datadesc_cpy(gras_datadesc_type_t type, void *src, void **dst);
-gras_error_t gras_datadesc_send(gras_socket_t sock, gras_datadesc_type_t type, void *src);
-gras_error_t gras_datadesc_recv(gras_socket_t sock, gras_datadesc_type_t type,
+xbt_error_t gras_datadesc_cpy(gras_datadesc_type_t type, void *src, void **dst);
+xbt_error_t gras_datadesc_send(gras_socket_t sock, gras_datadesc_type_t type, void *src);
+xbt_error_t gras_datadesc_recv(gras_socket_t sock, gras_datadesc_type_t type,
int r_arch, void *dst);
*/
#define aligned(v, a) (((v) + (a - 1)) & ~(a - 1))
-extern gras_set_t gras_datadesc_set_local;
+extern xbt_set_t gras_datadesc_set_local;
void gras_ddt_freev(void *ddt);
/*******************************************
* Descriptions of all known architectures *
* Specific fields of a struct
*/
typedef struct s_gras_dd_cat_struct {
- gras_dynar_t fields; /* elm type = gras_dd_cat_field_t */
+ xbt_dynar_t fields; /* elm type = gras_dd_cat_field_t */
int closed; /* gras_datadesc_declare_struct_close() was called */
} gras_dd_cat_struct_t;
*/
typedef struct s_gras_dd_cat_union {
gras_datadesc_type_cb_int_t selector;
- gras_dynar_t fields; /* elm type = gras_dd_cat_field_t */
+ xbt_dynar_t fields; /* elm type = gras_dd_cat_field_t */
int closed; /* gras_datadesc_declare_union_close() was called */
} gras_dd_cat_union_t;
/***************
* Convertions *
***************/
-gras_error_t
+xbt_error_t
gras_dd_convert_elm(gras_datadesc_type_t type, int count,
int r_arch,
void *src, void *dst);
#include "gras/DataDesc/datadesc_private.h"
-GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(ddt_convert,datadesc,
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ddt_convert,datadesc,
"Inter-architecture convertions");
/***
* The data to be converted is stored in @src, and is to be stored in @dst.
* Both pointers may be the same location if no resizing is needed.
*/
-gras_error_t
+xbt_error_t
gras_dd_convert_elm(gras_datadesc_type_t type, int count,
int r_arch,
void *src, void *dst) {
} tester;
*/
- gras_assert(type->category_code == e_gras_datadesc_type_cat_scalar);
- gras_assert(r_arch != GRAS_THISARCH);
+ xbt_assert(type->category_code == e_gras_datadesc_type_cat_scalar);
+ xbt_assert(r_arch != GRAS_THISARCH);
r_size = type->size[r_arch];
l_size = type->size[GRAS_THISARCH];
DEBUG5("Resize integer %d from %lu @%p to %lu @%p",
cpt, r_size,r_data, l_size,l_data);
- gras_assert0(r_data != l_data, "Impossible to resize in place");
+ xbt_assert0(r_data != l_data, "Impossible to resize in place");
if(sizeChange < 0) {
DEBUG3("Truncate %d bytes (%s,%s)", -sizeChange,
#include "xbt/misc.h" /* min()/max() */
#include "gras/DataDesc/datadesc_private.h"
-GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(ddt_create,datadesc,"Creating new datadescriptions");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ddt_create,datadesc,"Creating new datadescriptions");
/**
* gras_ddt_freev:
}
static gras_datadesc_type_t gras_ddt_new(const char *name) {
- gras_error_t errcode;
+ xbt_error_t errcode;
gras_datadesc_type_t res;
- GRAS_IN1("(%s)",name);
- res=gras_new0(s_gras_datadesc_type_t,1);
+ XBT_IN1("(%s)",name);
+ res=xbt_new0(s_gras_datadesc_type_t,1);
res->name = (char*)strdup(name);
res->name_len = strlen(name);
res->cycle = 0;
- gras_set_add(gras_datadesc_set_local,
- (gras_set_elm_t)res,&gras_ddt_freev);
- GRAS_OUT;
+ xbt_set_add(gras_datadesc_set_local,
+ (xbt_set_elm_t)res,&gras_ddt_freev);
+ XBT_OUT;
return res;
}
gras_datadesc_type_t type;
- GRAS_IN1("(%s)",name);
- if (gras_set_get_by_name(gras_datadesc_set_local,
- name,(gras_set_elm_t*)&type) == no_error) {
- GRAS_OUT;
+ XBT_IN1("(%s)",name);
+ if (xbt_set_get_by_name(gras_datadesc_set_local,
+ name,(xbt_set_elm_t*)&type) == no_error) {
+ XBT_OUT;
return type;
} else {
- GRAS_OUT;
+ XBT_OUT;
return NULL;
}
}
*
* Retrieve a type from its code
*/
-gras_error_t gras_datadesc_by_id(long int code,
+xbt_error_t gras_datadesc_by_id(long int code,
gras_datadesc_type_t *type) {
- GRAS_IN;
- return gras_set_get_by_id(gras_datadesc_set_local,
- code,(gras_set_elm_t*)type);
+ XBT_IN;
+ return xbt_set_get_by_id(gras_datadesc_set_local,
+ code,(xbt_set_elm_t*)type);
}
/**
gras_datadesc_type_t res;
long int arch;
- GRAS_IN;
+ XBT_IN;
res = gras_datadesc_by_name(name);
if (res) {
- gras_assert1(res->category_code == e_gras_datadesc_type_cat_scalar,
+ xbt_assert1(res->category_code == e_gras_datadesc_type_cat_scalar,
"Redefinition of type %s does not match", name);
- gras_assert1(res->category.scalar_data.encoding == encoding,
+ xbt_assert1(res->category.scalar_data.encoding == encoding,
"Redefinition of type %s does not match", name);
- gras_assert1(res->category.scalar_data.type == type,
+ xbt_assert1(res->category.scalar_data.type == type,
"Redefinition of type %s does not match", name);
VERB1("Discarding redefinition of %s",name);
return res;
/* size is not a power of 2 */
/* alignment= next power of 2 after size */
res->alignment[arch] = (res->size[arch] & ~(mask >> 1)) << 1;
- gras_assert0(res->alignment[arch] != 0,
+ xbt_assert0(res->alignment[arch] != 0,
"scalar type too large");
res->aligned_size[arch] = aligned(res->size[arch], res->alignment[arch]);
- gras_assert0 (res->aligned_size[arch] >= 0,
+ xbt_assert0 (res->aligned_size[arch] >= 0,
"scalar type too large");
} else {
res->category_code = e_gras_datadesc_type_cat_scalar;
res->category.scalar_data.encoding = encoding;
res->category.scalar_data.type = type;
- GRAS_OUT;
+ XBT_OUT;
return res;
}
*/
void gras_dd_cat_field_free(void *f) {
gras_dd_cat_field_t field = *(gras_dd_cat_field_t *)f;
- GRAS_IN;
+ XBT_IN;
if (field) {
if (field->name)
- gras_free(field->name);
- gras_free(field);
+ xbt_free(field->name);
+ xbt_free(field);
}
- GRAS_OUT;
+ XBT_OUT;
}
/**
gras_datadesc_type_t
gras_datadesc_struct(const char *name) {
- gras_error_t errcode;
+ xbt_error_t errcode;
gras_datadesc_type_t res;
long int arch;
- GRAS_IN1("(%s)",name);
+ XBT_IN1("(%s)",name);
res = gras_datadesc_by_name(name);
if (res) {
/* FIXME: Check that field redefinition matches */
- gras_assert1(res->category_code == e_gras_datadesc_type_cat_struct,
+ xbt_assert1(res->category_code == e_gras_datadesc_type_cat_struct,
"Redefinition of type %s does not match", name);
VERB1("Discarding redefinition of %s",name);
return res;
}
res->category_code = e_gras_datadesc_type_cat_struct;
res->category.struct_data.fields =
- gras_dynar_new(sizeof(gras_dd_cat_field_t),
+ xbt_dynar_new(sizeof(gras_dd_cat_field_t),
&gras_dd_cat_field_free);
- GRAS_OUT;
+ XBT_OUT;
return res;
}
const char *name,
gras_datadesc_type_t field_type) {
- gras_error_t errcode;
+ xbt_error_t errcode;
gras_dd_cat_field_t field;
int arch;
- gras_assert2(field_type,
+ xbt_assert2(field_type,
"Cannot add the field '%s' into struct '%s': its type is NULL. Typo in get_by_name?",
name,struct_type->name);
- GRAS_IN3("(%s %s.%s;)",field_type->name,struct_type->name,name);
+ XBT_IN3("(%s %s.%s;)",field_type->name,struct_type->name,name);
if (struct_type->category.struct_data.closed) {
VERB1("Ignoring request to add field to struct %s (closed. Redefinition?)",
struct_type->name);
return;
}
- gras_assert1(field_type->size != 0,
+ xbt_assert1(field_type->size != 0,
"Cannot add a dynamically sized field in structure %s",
struct_type->name);
- field=gras_new(s_gras_dd_cat_field_t,1);
+ field=xbt_new(s_gras_dd_cat_field_t,1);
field->name = (char*)strdup(name);
DEBUG0("----------------");
field->pre = NULL;
field->post = NULL;
- gras_dynar_push(struct_type->category.struct_data.fields, &field);
+ xbt_dynar_push(struct_type->category.struct_data.fields, &field);
DEBUG3("Push a %s into %s at offset %ld.",
field_type->name, struct_type->name,field->offset[GRAS_THISARCH]);
struct_type->size[GRAS_THISARCH],
struct_type->alignment[GRAS_THISARCH],
struct_type->aligned_size[GRAS_THISARCH]);
- GRAS_OUT;
+ XBT_OUT;
}
void
gras_datadesc_struct_close(gras_datadesc_type_t struct_type) {
- GRAS_IN;
+ XBT_IN;
struct_type->category.struct_data.closed = 1;
}
gras_datadesc_union(const char *name,
gras_datadesc_type_cb_int_t selector) {
- gras_error_t errcode;
+ xbt_error_t errcode;
gras_datadesc_type_t res;
int arch;
- GRAS_IN1("(%s)",name);
- gras_assert0(selector,
+ XBT_IN1("(%s)",name);
+ xbt_assert0(selector,
"Attempt to creat an union without field_count function");
res = gras_datadesc_by_name(name);
if (res) {
/* FIXME: Check that field redefinition matches */
- gras_assert1(res->category_code == e_gras_datadesc_type_cat_union,
+ xbt_assert1(res->category_code == e_gras_datadesc_type_cat_union,
"Redefinition of type %s does not match", name);
- gras_assert1(res->category.union_data.selector == selector,
+ xbt_assert1(res->category.union_data.selector == selector,
"Redefinition of type %s does not match", name);
VERB1("Discarding redefinition of %s",name);
return res;
res->category_code = e_gras_datadesc_type_cat_union;
res->category.union_data.fields =
- gras_dynar_new(sizeof(gras_dd_cat_field_t*),
+ xbt_dynar_new(sizeof(gras_dd_cat_field_t*),
&gras_dd_cat_field_free);
res->category.union_data.selector = selector;
gras_dd_cat_field_t field;
int arch;
- GRAS_IN3("(%s %s.%s;)",field_type->name,union_type->name,name);
- gras_assert1(field_type->size != 0,
+ XBT_IN3("(%s %s.%s;)",field_type->name,union_type->name,name);
+ xbt_assert1(field_type->size != 0,
"Cannot add a dynamically sized field in union %s",
union_type->name);
return;
}
- field=gras_new0(s_gras_dd_cat_field_t,1);
+ field=xbt_new0(s_gras_dd_cat_field_t,1);
field->name = (char*)strdup(name);
field->type = field_type;
/* All offset are left to 0 in an union */
- gras_dynar_push(union_type->category.union_data.fields, &field);
+ xbt_dynar_push(union_type->category.union_data.fields, &field);
for (arch=0; arch<gras_arch_count; arch ++) {
union_type->size[arch] = max(union_type->size[arch],
gras_datadesc_ref(const char *name,
gras_datadesc_type_t referenced_type) {
- gras_error_t errcode;
+ xbt_error_t errcode;
gras_datadesc_type_t res;
gras_datadesc_type_t pointer_type = gras_datadesc_by_name("data pointer");
int arch;
- GRAS_IN1("(%s)",name);
+ XBT_IN1("(%s)",name);
res = gras_datadesc_by_name(name);
if (res) {
- gras_assert1(res->category_code == e_gras_datadesc_type_cat_ref,
+ xbt_assert1(res->category_code == e_gras_datadesc_type_cat_ref,
"Redefinition of %s does not match",name);
- gras_assert1(res->category.ref_data.type == referenced_type,
+ xbt_assert1(res->category.ref_data.type == referenced_type,
"Redefinition of %s does not match",name);
- gras_assert1(res->category.ref_data.selector == NULL,
+ xbt_assert1(res->category.ref_data.selector == NULL,
"Redefinition of %s does not match",name);
VERB1("Discarding redefinition of %s",name);
return res;
res = gras_ddt_new(name);
- gras_assert0(pointer_type, "Cannot get the description of data pointer");
+ xbt_assert0(pointer_type, "Cannot get the description of data pointer");
for (arch=0; arch<gras_arch_count; arch ++){
res->size[arch] = pointer_type->size[arch];
gras_datadesc_type_t pointer_type = gras_datadesc_by_name("data pointer");
int arch;
- GRAS_IN1("(%s)",name);
+ XBT_IN1("(%s)",name);
res = gras_datadesc_by_name(name);
if (res) {
- gras_assert1(res->category_code == e_gras_datadesc_type_cat_ref,
+ xbt_assert1(res->category_code == e_gras_datadesc_type_cat_ref,
"Redefinition of type %s does not match", name);
- gras_assert1(res->category.ref_data.type == NULL,
+ xbt_assert1(res->category.ref_data.type == NULL,
"Redefinition of type %s does not match", name);
- gras_assert1(res->category.ref_data.selector == selector,
+ xbt_assert1(res->category.ref_data.selector == selector,
"Redefinition of type %s does not match", name);
VERB1("Discarding redefinition of %s",name);
return res;
}
res = gras_ddt_new(name);
- gras_assert0(pointer_type, "Cannot get the description of data pointer");
+ xbt_assert0(pointer_type, "Cannot get the description of data pointer");
for (arch=0; arch<gras_arch_count; arch ++) {
res->size[arch] = pointer_type->size[arch];
gras_datadesc_type_t res;
int arch;
- GRAS_IN1("(%s)",name);
+ XBT_IN1("(%s)",name);
res = gras_datadesc_by_name(name);
if (res) {
- gras_assert1(res->category_code == e_gras_datadesc_type_cat_array,
+ xbt_assert1(res->category_code == e_gras_datadesc_type_cat_array,
"Redefinition of type %s does not match", name);
- gras_assert1(res->category.array_data.type == element_type,
+ xbt_assert1(res->category.array_data.type == element_type,
"Redefinition of type %s does not match", name);
- gras_assert1(res->category.array_data.fixed_size == fixed_size,
+ xbt_assert1(res->category.array_data.fixed_size == fixed_size,
"Redefinition of type %s does not match", name);
- gras_assert1(res->category.array_data.dynamic_size == NULL,
+ xbt_assert1(res->category.array_data.dynamic_size == NULL,
"Redefinition of type %s does not match", name);
VERB1("Discarding redefinition of %s",name);
}
res = gras_ddt_new(name);
- gras_assert1(fixed_size > 0, "'%s' is a array of null fixed size",name);
+ xbt_assert1(fixed_size > 0, "'%s' is a array of null fixed size",name);
for (arch=0; arch<gras_arch_count; arch ++) {
res->size[arch] = fixed_size * element_type->aligned_size[arch];
res->alignment[arch] = element_type->alignment[arch];
gras_datadesc_type_t res;
int arch;
- GRAS_IN1("(%s)",name);
- gras_assert1(dynamic_size,
+ XBT_IN1("(%s)",name);
+ xbt_assert1(dynamic_size,
"'%s' is a dynamic array without size discriminant",
name);
res = gras_datadesc_by_name(name);
if (res) {
- gras_assert1(res->category_code == e_gras_datadesc_type_cat_array,
+ xbt_assert1(res->category_code == e_gras_datadesc_type_cat_array,
"Redefinition of type %s does not match", name);
- gras_assert1(res->category.array_data.type == element_type,
+ xbt_assert1(res->category.array_data.type == element_type,
"Redefinition of type %s does not match", name);
- gras_assert1(res->category.array_data.fixed_size == 0,
+ xbt_assert1(res->category.array_data.fixed_size == 0,
"Redefinition of type %s does not match", name);
- gras_assert1(res->category.array_data.dynamic_size == dynamic_size,
+ xbt_assert1(res->category.array_data.dynamic_size == dynamic_size,
"Redefinition of type %s does not match", name);
VERB1("Discarding redefinition of %s",name);
gras_datadesc_ref_pop_arr(gras_datadesc_type_t element_type) {
gras_datadesc_type_t res;
- char *name=(char*)gras_malloc(strlen(element_type->name) + 4);
+ char *name=(char*)xbt_malloc(strlen(element_type->name) + 4);
sprintf(name,"%s[]",element_type->name);
sprintf(name,"%s[]*",element_type->name);
res = gras_datadesc_ref(name,res);
- gras_free(name);
+ xbt_free(name);
return res;
}
-gras_error_t
+xbt_error_t
gras_datadesc_import_nws(const char *name,
const DataDescriptor *desc,
unsigned long howmany,
gras_dd_find_field(gras_datadesc_type_t type,
const char *field_name) {
gras_datadesc_type_t sub_type=NULL;
- gras_dynar_t field_array;
+ xbt_dynar_t field_array;
gras_dd_cat_field_t field=NULL;
int field_num;
field_array = type->category.struct_data.fields;
} else {
ERROR2("%s (%p) is not a struct nor an union. There is no field.", type->name,(void*)type);
- gras_abort();
+ xbt_abort();
}
- gras_dynar_foreach(field_array,field_num,field) {
+ xbt_dynar_foreach(field_array,field_num,field) {
if (!strcmp(field_name,field->name)) {
return field->type;
}
}
ERROR2("No field nammed %s in %s",field_name,type->name);
- gras_abort();
+ xbt_abort();
}
} else {
ERROR1("Field %s is not an int, unsigned int, long int neither unsigned long int",
sub_type->name);
- gras_abort();
+ xbt_abort();
}
}
/**
/**
* gras_datadesc_free:
*
- * Free a datadesc. Should only be called at gras_exit.
+ * Free a datadesc. Should only be called at xbt_exit.
*/
void gras_datadesc_free(gras_datadesc_type_t *type) {
break;
case e_gras_datadesc_type_cat_struct:
- gras_dynar_free(&( (*type)->category.struct_data.fields ));
+ xbt_dynar_free(&( (*type)->category.struct_data.fields ));
break;
case e_gras_datadesc_type_cat_union:
- gras_dynar_free(&( (*type)->category.union_data.fields ));
+ xbt_dynar_free(&( (*type)->category.union_data.fields ));
break;
default:
/* datadesc was invalid. Killing it is like euthanasy, I guess */
break;
}
- gras_free((*type)->name);
- gras_free(*type);
+ xbt_free((*type)->name);
+ xbt_free(*type);
type=NULL;
}
#include "gras/DataDesc/datadesc_private.h"
#include "gras/Transport/transport_interface.h" /* gras_trp_chunk_send/recv */
-GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(ddt_exchange,datadesc,
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ddt_exchange,datadesc,
"Sending data over the network");
const char *gras_datadesc_cat_names[9] = {
"undefined",
static gras_datadesc_type_t int_type = NULL;
static gras_datadesc_type_t pointer_type = NULL;
-static _GRAS_INLINE gras_error_t gras_dd_send_int(gras_socket_t sock, int i);
-static _GRAS_INLINE gras_error_t gras_dd_recv_int(gras_socket_t sock, int r_arch, int *i);
+static _XBT_INLINE xbt_error_t gras_dd_send_int(gras_socket_t sock, int i);
+static _XBT_INLINE xbt_error_t gras_dd_recv_int(gras_socket_t sock, int r_arch, int *i);
-static _GRAS_INLINE gras_error_t
-gras_dd_alloc_ref(gras_dict_t refs, long int size,
+static _XBT_INLINE xbt_error_t
+gras_dd_alloc_ref(xbt_dict_t refs, long int size,
char **r_ref, long int r_len,
char **l_ref, int detect_cycle);
-static _GRAS_INLINE int
+static _XBT_INLINE int
gras_dd_is_r_null(char **r_ptr, long int length);
-static gras_error_t
+static xbt_error_t
gras_datadesc_send_rec(gras_socket_t sock,
gras_cbps_t state,
- gras_dict_t refs,
+ xbt_dict_t refs,
gras_datadesc_type_t type,
char *data,
int detect_cycle);
-static gras_error_t
+static xbt_error_t
gras_datadesc_recv_rec(gras_socket_t sock,
gras_cbps_t state,
- gras_dict_t refs,
+ xbt_dict_t refs,
gras_datadesc_type_t type,
int r_arch,
char **r_data,
int detect_cycle);
-static _GRAS_INLINE gras_error_t
+static _XBT_INLINE xbt_error_t
gras_dd_send_int(gras_socket_t sock,int i) {
if (!int_type) {
int_type = gras_datadesc_by_name("int");
- gras_assert(int_type);
+ xbt_assert(int_type);
}
DEBUG1("send_int(%d)",i);
return gras_trp_chunk_send(sock, (char*)&i, int_type->size[GRAS_THISARCH]);
}
-static _GRAS_INLINE gras_error_t
+static _XBT_INLINE xbt_error_t
gras_dd_recv_int(gras_socket_t sock, int r_arch, int *i) {
- gras_error_t errcode;
+ xbt_error_t errcode;
if (!int_type) {
int_type = gras_datadesc_by_name("int");
- gras_assert(int_type);
+ xbt_assert(int_type);
}
if (int_type->size[GRAS_THISARCH] >= int_type->size[r_arch]) {
if (r_arch != GRAS_THISARCH)
TRY(gras_dd_convert_elm(int_type,1,r_arch, i,i));
} else {
- void *ptr = gras_malloc(int_type->size[r_arch]);
+ void *ptr = xbt_malloc(int_type->size[r_arch]);
TRY(gras_trp_chunk_recv(sock, (char*)ptr, int_type->size[r_arch]));
if (r_arch != GRAS_THISARCH)
TRY(gras_dd_convert_elm(int_type,1,r_arch, ptr,i));
- gras_free(ptr);
+ xbt_free(ptr);
}
DEBUG1("recv_int(%d)",*i);
* of 'length' bytes set to 0.
* FIXME: Check in configure?
*/
-static _GRAS_INLINE int
+static _XBT_INLINE int
gras_dd_is_r_null(char **r_ptr, long int length) {
int i;
return 1;
}
-static _GRAS_INLINE gras_error_t
-gras_dd_alloc_ref(gras_dict_t refs,
+static _XBT_INLINE xbt_error_t
+gras_dd_alloc_ref(xbt_dict_t refs,
long int size,
char **r_ref,
long int r_len, /* pointer_type->size[r_arch] */
int detect_cycle) {
char *l_data = NULL;
- gras_assert1(size>0,"Cannot allocate %ld bytes!", size);
- l_data = gras_malloc((size_t)size);
+ xbt_assert1(size>0,"Cannot allocate %ld bytes!", size);
+ l_data = xbt_malloc((size_t)size);
*l_ref = l_data;
DEBUG2("l_data=%p, &l_data=%p",(void*)l_data,(void*)&l_data);
DEBUG3("alloc_ref: r_ref=%p; *r_ref=%p, r_len=%ld",
(void*)r_ref, (void*)(r_ref?*r_ref:NULL), r_len);
if (detect_cycle && r_ref && !gras_dd_is_r_null( r_ref, r_len)) {
- gras_error_t errcode;
- void *ptr = gras_malloc(sizeof(void *));
+ xbt_error_t errcode;
+ void *ptr = xbt_malloc(sizeof(void *));
CRITICAL0("detect_cycle");
memcpy(ptr,l_ref, sizeof(void *));
DEBUG2("Insert %p under %p",*(void**)ptr, *(void**)r_ref);
if (detect_cycle)
- gras_dict_set_ext(refs,(const char *) r_ref, r_len, ptr, gras_free_fct);
+ xbt_dict_set_ext(refs,(const char *) r_ref, r_len, ptr, xbt_free_fct);
}
return no_error;
}
break;
case e_gras_datadesc_type_cat_struct:
- if (gras_dynar_length(d1->category.struct_data.fields) !=
- gras_dynar_length(d2->category.struct_data.fields)) {
+ if (xbt_dynar_length(d1->category.struct_data.fields) !=
+ xbt_dynar_length(d2->category.struct_data.fields)) {
DEBUG4("ddt_cmp: %s (having %lu fields) != %s (having %lu fields)",
- d1->name, gras_dynar_length(d1->category.struct_data.fields),
- d2->name, gras_dynar_length(d2->category.struct_data.fields));
+ d1->name, xbt_dynar_length(d1->category.struct_data.fields),
+ d2->name, xbt_dynar_length(d2->category.struct_data.fields));
- return gras_dynar_length(d1->category.struct_data.fields) >
- gras_dynar_length(d2->category.struct_data.fields) ?
+ return xbt_dynar_length(d1->category.struct_data.fields) >
+ xbt_dynar_length(d2->category.struct_data.fields) ?
1 : -1;
}
- gras_dynar_foreach(d1->category.struct_data.fields, cpt, field1) {
+ xbt_dynar_foreach(d1->category.struct_data.fields, cpt, field1) {
- field2 = gras_dynar_get_as(d2->category.struct_data.fields, cpt, gras_dd_cat_field_t);
+ field2 = xbt_dynar_get_as(d2->category.struct_data.fields, cpt, gras_dd_cat_field_t);
field_desc_1 = field1->type;
field_desc_2 = field2->type;
ret = gras_datadesc_type_cmp(field_desc_1,field_desc_2);
if (d1->category.union_data.selector != d2->category.union_data.selector)
return 1; /* ISO C forbids ordered comparisons of pointers to functions */
- if (gras_dynar_length(d1->category.union_data.fields) !=
- gras_dynar_length(d2->category.union_data.fields))
- return gras_dynar_length(d1->category.union_data.fields) >
- gras_dynar_length(d2->category.union_data.fields) ?
+ if (xbt_dynar_length(d1->category.union_data.fields) !=
+ xbt_dynar_length(d2->category.union_data.fields))
+ return xbt_dynar_length(d1->category.union_data.fields) >
+ xbt_dynar_length(d2->category.union_data.fields) ?
1 : -1;
- gras_dynar_foreach(d1->category.union_data.fields, cpt, field1) {
+ xbt_dynar_foreach(d1->category.union_data.fields, cpt, field1) {
- field2 = gras_dynar_get_as(d2->category.union_data.fields, cpt, gras_dd_cat_field_t);
+ field2 = xbt_dynar_get_as(d2->category.union_data.fields, cpt, gras_dd_cat_field_t);
field_desc_1 = field1->type;
field_desc_2 = field2->type;
ret = gras_datadesc_type_cmp(field_desc_1,field_desc_2);
* to a new location, and store a pointer to it in dst.
*
*/
-gras_error_t gras_datadesc_cpy(gras_datadesc_type_t type,
+xbt_error_t gras_datadesc_cpy(gras_datadesc_type_t type,
void *src,
void **dst) {
RAISE_UNIMPLEMENTED;
}
-static gras_error_t
+static xbt_error_t
gras_datadesc_send_rec(gras_socket_t sock,
gras_cbps_t state,
- gras_dict_t refs,
+ xbt_dict_t refs,
gras_datadesc_type_t type,
char *data,
int detect_cycle) {
- gras_error_t errcode;
+ xbt_error_t errcode;
int cpt;
gras_datadesc_type_t sub_type; /* type on which we recurse */
char *field_data;
struct_data = type->category.struct_data;
- gras_assert1(struct_data.closed,
+ xbt_assert1(struct_data.closed,
"Please call gras_datadesc_declare_struct_close on %s before sending it",
type->name);
VERB1(">> Send all fields of the structure %s",type->name);
- gras_dynar_foreach(struct_data.fields, cpt, field) {
+ xbt_dynar_foreach(struct_data.fields, cpt, field) {
field_data = data;
field_data += field->offset[GRAS_THISARCH];
union_data = type->category.union_data;
- gras_assert1(union_data.closed,
+ xbt_assert1(union_data.closed,
"Please call gras_datadesc_declare_union_close on %s before sending it",
type->name);
/* retrieve the field number */
field_num = union_data.selector(state, data);
- gras_assert1(field_num > 0,
+ xbt_assert1(field_num > 0,
"union field selector of %s gave a negative value",
type->name);
- gras_assert3(field_num < gras_dynar_length(union_data.fields),
+ xbt_assert3(field_num < xbt_dynar_length(union_data.fields),
"union field selector of %s returned %d but there is only %lu fields",
- type->name, field_num, gras_dynar_length(union_data.fields));
+ type->name, field_num, xbt_dynar_length(union_data.fields));
/* Send the field number */
TRY(gras_dd_send_int(sock, field_num));
/* Send the content */
- field = gras_dynar_get_as(union_data.fields, field_num, gras_dd_cat_field_t);
+ field = xbt_dynar_get_as(union_data.fields, field_num, gras_dd_cat_field_t);
sub_type = field->type;
if (field->pre)
/* Send the actual value of the pointer for cycle handling */
if (!pointer_type) {
pointer_type = gras_datadesc_by_name("data pointer");
- gras_assert(pointer_type);
+ xbt_assert(pointer_type);
}
TRY(gras_trp_chunk_send(sock, (char*)data,
break;
}
errcode = detect_cycle
- ? gras_dict_get_ext(refs,(char*)ref, sizeof(void*), &dummy)
+ ? xbt_dict_get_ext(refs,(char*)ref, sizeof(void*), &dummy)
: mismatch_error;
if (errcode == mismatch_error) {
VERB1("Sending data referenced at %p", (void*)*ref);
if (detect_cycle)
- gras_dict_set_ext(refs, (char*)ref, sizeof(void*), ref, NULL);
+ xbt_dict_set_ext(refs, (char*)ref, sizeof(void*), ref, NULL);
TRY(gras_datadesc_send_rec(sock,state,refs, sub_type, *ref, detect_cycle || sub_type->cycle));
} else if (errcode == no_error) {
count = array_data.fixed_size;
if (count == 0) {
count = array_data.dynamic_size(state,data);
- gras_assert1(count >=0,
+ xbt_assert1(count >=0,
"Invalid (negative) array size for type %s",type->name);
TRY(gras_dd_send_int(sock, count));
}
}
default:
- gras_assert0(0, "Invalid type");
+ xbt_assert0(0, "Invalid type");
}
return no_error;
* Copy the data pointed by src and described by type to the socket
*
*/
-gras_error_t gras_datadesc_send(gras_socket_t sock,
+xbt_error_t gras_datadesc_send(gras_socket_t sock,
gras_datadesc_type_t type,
void *src) {
- gras_error_t errcode;
+ xbt_error_t errcode;
gras_cbps_t state;
- gras_dict_t refs; /* all references already sent */
+ xbt_dict_t refs; /* all references already sent */
- refs = gras_dict_new();
+ refs = xbt_dict_new();
state = gras_cbps_new();
errcode = gras_datadesc_send_rec(sock,state,refs,type,(char*)src, type->cycle);
- gras_dict_free(&refs);
+ xbt_dict_free(&refs);
gras_cbps_free(&state);
return errcode;
* Having this size passed as an argument of the recursive function is a crude
* hack, but I was told that working code is sometimes better than neat one ;)
*/
-gras_error_t
+xbt_error_t
gras_datadesc_recv_rec(gras_socket_t sock,
gras_cbps_t state,
- gras_dict_t refs,
+ xbt_dict_t refs,
gras_datadesc_type_t type,
int r_arch,
char **r_data,
int subsize,
int detect_cycle) {
- gras_error_t errcode;
+ xbt_error_t errcode;
int cpt;
gras_datadesc_type_t sub_type;
VERB2("Recv a %s @%p", type->name, (void*)l_data);
- gras_assert(l_data);
+ xbt_assert(l_data);
switch (type->category_code) {
case e_gras_datadesc_type_cat_scalar:
if (r_arch != GRAS_THISARCH)
TRY(gras_dd_convert_elm(type,1,r_arch, l_data,l_data));
} else {
- void *ptr = gras_malloc(type->size[r_arch]);
+ void *ptr = xbt_malloc(type->size[r_arch]);
TRY(gras_trp_chunk_recv(sock, (char*)ptr, type->size[r_arch]));
if (r_arch != GRAS_THISARCH)
TRY(gras_dd_convert_elm(type,1,r_arch, ptr,l_data));
- gras_free(ptr);
+ xbt_free(ptr);
}
break;
struct_data = type->category.struct_data;
- gras_assert1(struct_data.closed,
+ xbt_assert1(struct_data.closed,
"Please call gras_datadesc_declare_struct_close on %s before receiving it",
type->name);
VERB1(">> Receive all fields of the structure %s",type->name);
- gras_dynar_foreach(struct_data.fields, cpt, field) {
+ xbt_dynar_foreach(struct_data.fields, cpt, field) {
char *field_data = l_data + field->offset[GRAS_THISARCH];
sub_type = field->type;
union_data = type->category.union_data;
- gras_assert1(union_data.closed,
+ xbt_assert1(union_data.closed,
"Please call gras_datadesc_declare_union_close on %s before receiving it",
type->name);
/* retrieve the field number */
if (field_num < 0)
RAISE1(mismatch_error,
"Received union field for %s is negative", type->name);
- if (field_num < gras_dynar_length(union_data.fields))
+ if (field_num < xbt_dynar_length(union_data.fields))
RAISE3(mismatch_error,
"Received union field for %s is %d but there is only %lu fields",
- type->name, field_num, gras_dynar_length(union_data.fields));
+ type->name, field_num, xbt_dynar_length(union_data.fields));
/* Recv the content */
- field = gras_dynar_get_as(union_data.fields, field_num, gras_dd_cat_field_t);
+ field = xbt_dynar_get_as(union_data.fields, field_num, gras_dd_cat_field_t);
sub_type = field->type;
TRY(gras_datadesc_recv_rec(sock,state,refs, sub_type,
/* Get the actual value of the pointer for cycle handling */
if (!pointer_type) {
pointer_type = gras_datadesc_by_name("data pointer");
- gras_assert(pointer_type);
+ xbt_assert(pointer_type);
}
- r_ref = gras_malloc(pointer_type->size[r_arch]);
+ r_ref = xbt_malloc(pointer_type->size[r_arch]);
TRY(gras_trp_chunk_recv(sock, (char*)r_ref,
pointer_type->size[r_arch]));
VERB1("Not receiving data remotely referenced @%p since it's NULL",
*(void **)r_ref);
*(void**)l_data = NULL;
- gras_free(r_ref);
+ xbt_free(r_ref);
break;
}
errcode = detect_cycle
- ? gras_dict_get_ext(refs,
+ ? xbt_dict_get_ext(refs,
(char*)r_ref, pointer_type->size[r_arch],
(void**)&l_ref)
: mismatch_error;
} else {
return errcode;
}
- gras_free(r_ref);
+ xbt_free(r_ref);
break;
}
if (r_arch != GRAS_THISARCH)
TRY(gras_dd_convert_elm(sub_type,count,r_arch, l_data,l_data));
} else {
- ptr = gras_malloc(sub_type->aligned_size[r_arch] * count);
+ ptr = xbt_malloc(sub_type->aligned_size[r_arch] * count);
TRY(gras_trp_chunk_recv(sock, (char*)ptr,
sub_type->size[r_arch] * count));
if (r_arch != GRAS_THISARCH)
TRY(gras_dd_convert_elm(sub_type,count,r_arch, ptr,l_data));
- gras_free(ptr);
+ xbt_free(ptr);
}
} else if (sub_type->category_code == e_gras_datadesc_type_cat_array &&
sub_type->category.array_data.fixed_size > 0 &&
if (r_arch != GRAS_THISARCH)
TRY(gras_dd_convert_elm(subsub_type,count*array_data.fixed_size,r_arch, l_data,l_data));
} else {
- ptr = gras_malloc(subsub_type->aligned_size[r_arch] * count*array_data.fixed_size);
+ ptr = xbt_malloc(subsub_type->aligned_size[r_arch] * count*array_data.fixed_size);
TRY(gras_trp_chunk_recv(sock, (char*)ptr,
subsub_type->size[r_arch] * count*array_data.fixed_size));
if (r_arch != GRAS_THISARCH)
TRY(gras_dd_convert_elm(subsub_type,count*array_data.fixed_size,r_arch, ptr,l_data));
- gras_free(ptr);
+ xbt_free(ptr);
}
}
default:
- gras_assert0(0, "Invalid type");
+ xbt_assert0(0, "Invalid type");
}
if (type->recv)
* and store a pointer to it in @dst
*
*/
-gras_error_t
+xbt_error_t
gras_datadesc_recv(gras_socket_t sock,
gras_datadesc_type_t type,
int r_arch,
void *dst) {
- gras_error_t errcode;
+ xbt_error_t errcode;
gras_cbps_t state; /* callback persistent state */
- gras_dict_t refs; /* all references already sent */
+ xbt_dict_t refs; /* all references already sent */
- refs = gras_dict_new();
+ refs = xbt_dict_new();
state = gras_cbps_new();
errcode = gras_datadesc_recv_rec(sock, state, refs, type,
(char *) dst,-1,
type->cycle);
- gras_dict_free(&refs);
+ xbt_dict_free(&refs);
gras_cbps_free(&state);
return errcode;
#include "gras/DataDesc/datadesc_private.h"
#include "gras/DataDesc/ddt_parse.yy.h"
-GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(ddt_parse,datadesc,
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ddt_parse,datadesc,
"Parsing C data structures to build GRAS data description");
typedef struct s_type_modifier{
/* local functions */
static void parse_type_modifier(type_modifier_t type_modifier) {
- GRAS_IN;
+ XBT_IN;
do {
if (gras_ddt_parse_tok_num == GRAS_DDT_PARSE_TOKEN_STAR) {
/* This only used when parsing 'short *' since this function returns when int, float, double,... is encountered */
break;
}
} while(1);
- GRAS_OUT;
+ XBT_OUT;
}
static void print_type_modifier(s_type_modifier_t tm) {
int i;
- GRAS_IN;
+ XBT_IN;
if (tm.is_unsigned) printf("(unsigned) ");
if (tm.is_short) printf("(short) ");
for (i=0 ; i<tm.is_long ; i++) printf("(long) ");
if(tm.is_union) printf("(union) ");
for (i=0 ; i<tm.is_ref ; i++) printf("(ref) ");
- GRAS_OUT;
+ XBT_OUT;
}
-static void change_to_fixed_array(gras_dynar_t dynar, long int size) {
+static void change_to_fixed_array(xbt_dynar_t dynar, long int size) {
s_identifier_t former,array;
memset(&array,0,sizeof(array));
- GRAS_IN;
- gras_dynar_pop(dynar,&former);
- array.type_name=(char*)gras_malloc(strlen(former.type->name)+20);
+ XBT_IN;
+ xbt_dynar_pop(dynar,&former);
+ array.type_name=(char*)xbt_malloc(strlen(former.type->name)+20);
DEBUG2("Array specification (size=%ld, elm='%s'), change pushed type",
size,former.type_name);
sprintf(array.type_name,"%s[%ld]",former.type_name,size);
- gras_free(former.type_name);
+ xbt_free(former.type_name);
array.type = gras_datadesc_array_fixed(array.type_name, former.type, size); /* redeclaration are ignored */
array.name = former.name;
- gras_dynar_push(dynar,&array);
- GRAS_OUT;
+ xbt_dynar_push(dynar,&array);
+ XBT_OUT;
}
-static void change_to_ref(gras_dynar_t dynar) {
+static void change_to_ref(xbt_dynar_t dynar) {
s_identifier_t former,ref;
memset(&ref,0,sizeof(ref));
- GRAS_IN;
- gras_dynar_pop(dynar,&former);
- ref.type_name=(char*)gras_malloc(strlen(former.type->name)+2);
+ XBT_IN;
+ xbt_dynar_pop(dynar,&former);
+ ref.type_name=(char*)xbt_malloc(strlen(former.type->name)+2);
DEBUG1("Ref specification (elm='%s'), change pushed type", former.type_name);
sprintf(ref.type_name,"%s*",former.type_name);
- gras_free(former.type_name);
+ xbt_free(former.type_name);
ref.type = gras_datadesc_ref(ref.type_name, former.type); /* redeclaration are ignored */
ref.name = former.name;
- gras_dynar_push(dynar,&ref);
- GRAS_OUT;
+ xbt_dynar_push(dynar,&ref);
+ XBT_OUT;
}
-static void change_to_ref_pop_array(gras_dynar_t dynar) {
+static void change_to_ref_pop_array(xbt_dynar_t dynar) {
s_identifier_t former,ref;
memset(&ref,0,sizeof(ref));
- GRAS_IN;
- gras_dynar_pop(dynar,&former);
+ XBT_IN;
+ xbt_dynar_pop(dynar,&former);
ref.type = gras_datadesc_ref_pop_arr(former.type); /* redeclaration are ignored */
ref.type_name = (char*)strdup(ref.type->name);
ref.name = former.name;
- gras_free(former.type_name);
+ xbt_free(former.type_name);
- gras_dynar_push(dynar,&ref);
- GRAS_OUT;
+ xbt_dynar_push(dynar,&ref);
+ XBT_OUT;
}
-static gras_error_t parse_statement(char *definition,
- gras_dynar_t identifiers,
- gras_dynar_t fields_to_push) {
- gras_error_t errcode;
+static xbt_error_t parse_statement(char *definition,
+ xbt_dynar_t identifiers,
+ xbt_dynar_t fields_to_push) {
+ xbt_error_t errcode;
char buffname[512];
s_identifier_t identifier;
int expect_id_separator = 0;
- GRAS_IN;
+ XBT_IN;
memset(&identifier,0,sizeof(identifier));
gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump();
if(gras_ddt_parse_tok_num == GRAS_DDT_PARSE_TOKEN_RA) {
- GRAS_OUT;
+ XBT_OUT;
return mismatch_error; /* end of the englobing structure or union */
}
- if (GRAS_LOG_ISENABLED(ddt_parse,gras_log_priority_debug)) {
+ if (XBT_LOG_ISENABLED(ddt_parse,xbt_log_priority_debug)) {
int colon_pos;
for (colon_pos = gras_ddt_parse_col_pos;
definition[colon_pos] != ';';
DEBUG2("Anotation: %s=%s",keyname,keyval);
if (!strcmp(keyname,"size")) {
- gras_free(keyname);
+ xbt_free(keyname);
if (!identifier.tm.is_ref)
PARSE_ERROR0("Size annotation for a field not being a reference");
identifier.tm.is_ref--;
if (!strcmp(keyval,"1")) {
change_to_ref(identifiers);
- gras_free(keyval);
+ xbt_free(keyval);
continue;
} else {
char *p;
if (fixed) {
change_to_fixed_array(identifiers,atoi(keyval));
change_to_ref(identifiers);
- gras_free(keyval);
+ xbt_free(keyval);
continue;
} else {
change_to_ref_pop_array(identifiers);
- gras_dynar_push(fields_to_push,&keyval);
+ xbt_dynar_push(fields_to_push,&keyval);
continue;
}
}
identifier.name=(char*)strdup(gras_ddt_parse_text);
DEBUG1("Found the identifier \"%s\"",identifier.name);
- gras_dynar_push(identifiers, &identifier);
- DEBUG1("Dynar_len=%lu",gras_dynar_length(identifiers));
+ xbt_dynar_push(identifiers, &identifier);
+ DEBUG1("Dynar_len=%lu",xbt_dynar_length(identifiers));
expect_id_separator = 1;
continue;
}
PARSE_ERROR0("Unparasable symbol (maybe a def struct in a def struct or a parser bug ;)");
}
- GRAS_OUT;
+ XBT_OUT;
return no_error;
}
static gras_datadesc_type_t parse_struct(char *definition) {
- gras_error_t errcode;
+ xbt_error_t errcode;
char buffname[32];
static int anonymous_struct=0;
- gras_dynar_t identifiers;
+ xbt_dynar_t identifiers;
s_identifier_t field;
int i;
- gras_dynar_t fields_to_push;
+ xbt_dynar_t fields_to_push;
char *name;
gras_datadesc_type_t struct_type;
- GRAS_IN;
- identifiers = gras_dynar_new(sizeof(s_identifier_t),NULL);
- fields_to_push = gras_dynar_new(sizeof(char*),NULL);
+ XBT_IN;
+ identifiers = xbt_dynar_new(sizeof(s_identifier_t),NULL);
+ fields_to_push = xbt_dynar_new(sizeof(char*),NULL);
/* Create the struct descriptor */
if (gras_ddt_parse_tok_num == GRAS_DDT_PARSE_TOKEN_WORD) {
errcode == no_error ;
errcode=parse_statement(definition,identifiers,fields_to_push)) {
- DEBUG1("This statement contained %lu identifiers",gras_dynar_length(identifiers));
+ DEBUG1("This statement contained %lu identifiers",xbt_dynar_length(identifiers));
/* append the identifiers we've found */
- gras_dynar_foreach(identifiers,i, field) {
+ xbt_dynar_foreach(identifiers,i, field) {
if (field.tm.is_ref)
PARSE_ERROR2("Not enough GRAS_ANNOTATE to deal with all dereferencing levels of %s (%d '*' left)",
field.name,field.tm.is_ref);
VERB2("Append field '%s' to %p",field.name, (void*)struct_type);
gras_datadesc_struct_append(struct_type, field.name, field.type);
- gras_free(field.name);
- gras_free(field.type_name);
+ xbt_free(field.name);
+ xbt_free(field.type_name);
}
- gras_dynar_reset(identifiers);
+ xbt_dynar_reset(identifiers);
DEBUG1("struct_type=%p",(void*)struct_type);
/* Make sure that all fields declaring a size push it into the cbps */
- gras_dynar_foreach(fields_to_push,i, name) {
+ xbt_dynar_foreach(fields_to_push,i, name) {
DEBUG1("struct_type=%p",(void*)struct_type);
VERB2("Push field '%s' into size stack of %p", name, (void*)struct_type);
gras_datadesc_cb_field_push(struct_type, name);
- gras_free(name);
+ xbt_free(name);
}
- gras_dynar_reset(fields_to_push);
+ xbt_dynar_reset(fields_to_push);
}
gras_datadesc_struct_close(struct_type);
if (errcode != mismatch_error) {
- GRAS_OUT;
+ XBT_OUT;
return NULL; /* FIXME: LEAK! */
}
gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump();
- gras_dynar_free(&identifiers);
- gras_dynar_free(&fields_to_push);
- GRAS_OUT;
+ xbt_dynar_free(&identifiers);
+ xbt_dynar_free(&fields_to_push);
+ XBT_OUT;
return struct_type;
}
gras_datadesc_type_t struct_desc=NULL;
gras_datadesc_type_t typedef_desc=NULL;
- GRAS_IN;
+ XBT_IN;
memset(&tm,0,sizeof(tm));
/* get the aliased type */
/* (FIXME: should) build the alias */
PARSE_ERROR0("Cannot handle typedef yet");
- GRAS_OUT;
+ XBT_OUT;
return typedef_desc;
}
int semicolon_count=0;
int def_count,C_count;
- GRAS_IN;
+ XBT_IN;
/* reput the \n in place for debug */
for (C_count=0; C_statement[C_count] != '\0'; C_count++)
if (C_statement[C_count] == ';' || C_statement[C_count] == '{')
semicolon_count++;
- definition = (char*)gras_malloc(C_count + semicolon_count + 1);
+ definition = (char*)xbt_malloc(C_count + semicolon_count + 1);
for (C_count=0,def_count=0; C_statement[C_count] != '\0'; C_count++) {
definition[def_count++] = C_statement[C_count];
if (C_statement[C_count] == ';' || C_statement[C_count] == '{') {
} else {
ERROR1("Failed to parse the following symbol (not a struct neither a typedef) :\n%s",definition);
- gras_abort();
+ xbt_abort();
}
gras_ddt_parse_pointer_string_close();
VERB0("end of _gras_ddt_type_parse()");
- gras_free(definition);
+ xbt_free(definition);
/* register it under the name provided as symbol */
if (strcmp(res->name,name)) {
ERROR2("In GRAS_DEFINE_TYPE, the provided symbol (here %s) must be the C type name (here %s)",
name,res->name);
- gras_abort();
+ xbt_abort();
}
- GRAS_OUT;
+ XBT_OUT;
return res;
}
int gras_ddt_parse_char_pos = 0;
int gras_ddt_parse_tok_num = 0;
const char *definition;
- GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(lexer,ddt_parse,"The crude internals of the lexer used for type parsing");
+ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(lexer,ddt_parse,"The crude internals of the lexer used for type parsing");
#define SHOW_WHERE DEBUG4("%d:%d (char #%d): seen '%s'", gras_ddt_parse_line_pos,gras_ddt_parse_col_pos,gras_ddt_parse_char_pos,yytext)
#define annotate 1
#define comment 2
int gras_ddt_parse_lex_destroy (void);
#define PARSE_ERROR_PRE do {
-#define PARSE_ERROR_POST gras_abort();} while (0)
+#define PARSE_ERROR_POST xbt_abort();} while (0)
#define PARSE_ERROR0(fmt) PARSE_ERROR_PRE \
ERROR3(fmt " at %d:%d of :\n%s", gras_ddt_parse_line_pos,gras_ddt_parse_col_pos,definition);\
#include "gras/Transport/transport_interface.h" /* gras_trp_chunk_send/recv */
#include "gras/Virtu/virtu_interface.h"
-GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(msg,gras,"High level messaging");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg,gras,"High level messaging");
-gras_set_t _gras_msgtype_set = NULL;
+xbt_set_t _gras_msgtype_set = NULL;
static char GRAS_header[6];
static char *make_namev(const char *name, short int ver);
* Initialize this submodule.
*/
void gras_msg_init(void) {
- gras_error_t errcode;
+ xbt_error_t errcode;
/* only initialize once */
if (_gras_msgtype_set != NULL)
VERB0("Initializing Msg");
- _gras_msgtype_set = gras_set_new();
+ _gras_msgtype_set = xbt_set_new();
memcpy(GRAS_header,"GRAS", 4);
GRAS_header[4]=GRAS_PROTOCOL_VERSION;
void
gras_msg_exit(void) {
VERB0("Exiting Msg");
- gras_set_free(&_gras_msgtype_set);
+ xbt_set_free(&_gras_msgtype_set);
}
/**
void gras_msgtype_free(void *t) {
gras_msgtype_t msgtype=(gras_msgtype_t)t;
if (msgtype) {
- gras_free(msgtype->name);
- gras_free(msgtype);
+ xbt_free(msgtype->name);
+ xbt_free(msgtype);
}
}
if (!ver)
return (char *)name;
- namev = (char*)gras_malloc(strlen(name)+2+3+1);
+ namev = (char*)xbt_malloc(strlen(name)+2+3+1);
if (namev)
sprintf(namev,"%s_v%d",name,ver);
short int version,
gras_datadesc_type_t payload) {
- gras_error_t errcode;
+ xbt_error_t errcode;
gras_msgtype_t msgtype;
char *namev=make_namev(name,version);
- errcode = gras_set_get_by_name(_gras_msgtype_set,
- namev,(gras_set_elm_t*)&msgtype);
+ errcode = xbt_set_get_by_name(_gras_msgtype_set,
+ namev,(xbt_set_elm_t*)&msgtype);
if (errcode == no_error) {
VERB2("Re-register version %d of message '%s' (same payload, ignored).",
version, name);
- gras_assert3(!gras_datadesc_type_cmp(msgtype->ctn_type, payload),
+ xbt_assert3(!gras_datadesc_type_cmp(msgtype->ctn_type, payload),
"Message %s re-registred with another payload (%s was %s)",
namev,gras_datadesc_get_name(payload),
gras_datadesc_get_name(msgtype->ctn_type));
return ; /* do really ignore it */
}
- gras_assert_error(mismatch_error); /* expect this error */
+ xbt_assert_error(mismatch_error); /* expect this error */
VERB3("Register version %d of message '%s' (payload: %s).",
version, name, gras_datadesc_get_name(payload));
- msgtype = gras_new(s_gras_msgtype_t,1);
+ msgtype = xbt_new(s_gras_msgtype_t,1);
msgtype->name = (namev == name ? strdup(name) : namev);
msgtype->name_len = strlen(namev);
msgtype->version = version;
msgtype->ctn_type = payload;
- gras_set_add(_gras_msgtype_set, (gras_set_elm_t)msgtype,
+ xbt_set_add(_gras_msgtype_set, (xbt_set_elm_t)msgtype,
&gras_msgtype_free);
}
short int version) {
gras_msgtype_t res;
- gras_error_t errcode;
+ xbt_error_t errcode;
char *namev = make_namev(name,version);
- errcode = gras_set_get_by_name(_gras_msgtype_set, namev,
- (gras_set_elm_t*)&res);
+ errcode = xbt_set_get_by_name(_gras_msgtype_set, namev,
+ (xbt_set_elm_t*)&res);
if (errcode != no_error)
res = NULL;
if (!res)
WARN1("msgtype_by_name(%s) returns NULL",namev);
if (name != namev)
- gras_free(namev);
+ xbt_free(namev);
return res;
}
*
* Send the given message on the given socket
*/
-gras_error_t
+xbt_error_t
gras_msg_send(gras_socket_t sock,
gras_msgtype_t msgtype,
void *payload) {
- gras_error_t errcode;
+ xbt_error_t errcode;
static gras_datadesc_type_t string_type=NULL;
if (!msgtype)
if (!string_type) {
string_type = gras_datadesc_by_name("string");
- gras_assert(string_type);
+ xbt_assert(string_type);
}
DEBUG3("send '%s' to %s:%d", msgtype->name,
*
* receive the next message on the given socket.
*/
-gras_error_t
+xbt_error_t
gras_msg_recv(gras_socket_t sock,
gras_msgtype_t *msgtype,
void **payload,
int *payload_size) {
- gras_error_t errcode;
+ xbt_error_t errcode;
static gras_datadesc_type_t string_type=NULL;
char header[6];
int cpt;
if (!string_type) {
string_type=gras_datadesc_by_name("string");
- gras_assert(string_type);
+ xbt_assert(string_type);
}
TRY(gras_trp_chunk_recv(sock, header, 6));
(int)header[4],gras_datadesc_arch_name(r_arch));
TRY(gras_datadesc_recv(sock, string_type, r_arch, &msg_name));
- errcode = gras_set_get_by_name(_gras_msgtype_set,
- msg_name,(gras_set_elm_t*)msgtype);
+ errcode = xbt_set_get_by_name(_gras_msgtype_set,
+ msg_name,(xbt_set_elm_t*)msgtype);
if (errcode != no_error)
RAISE2(errcode,
"Got error %s while retrieving the type associated to messages '%s'",
- gras_error_name(errcode),msg_name);
+ xbt_error_name(errcode),msg_name);
/* FIXME: Survive unknown messages */
- gras_free(msg_name);
+ xbt_free(msg_name);
*payload_size=gras_datadesc_size((*msgtype)->ctn_type);
- gras_assert2(*payload_size > 0,
+ xbt_assert2(*payload_size > 0,
"%s %s",
"Dynamic array as payload is forbided for now (FIXME?).",
"Reference to dynamic array is allowed.");
- *payload = gras_malloc(*payload_size);
+ *payload = xbt_malloc(*payload_size);
TRY(gras_datadesc_recv(sock, (*msgtype)->ctn_type, r_arch, *payload));
return no_error;
* Every message of another type received before the one waited will be queued
* and used by subsequent call to this function or MsgHandle().
*/
-gras_error_t
+xbt_error_t
gras_msg_wait(double timeout,
gras_msgtype_t msgt_want,
gras_socket_t *expeditor,
gras_msgtype_t msgt_got;
void *payload_got;
int payload_size_got;
- gras_error_t errcode;
+ xbt_error_t errcode;
double start, now;
gras_procdata_t *pd=gras_procdata_get();
int cpt;
start = now = gras_os_time();
- gras_dynar_foreach(pd->msg_queue,cpt,msg){
+ xbt_dynar_foreach(pd->msg_queue,cpt,msg){
if (msg.type->code == msgt_want->code) {
*expeditor = msg.expeditor;
memcpy(payload, msg.payload, msg.payload_size);
- gras_free(msg.payload);
- gras_dynar_cursor_rm(pd->msg_queue, &cpt);
+ xbt_free(msg.payload);
+ xbt_dynar_cursor_rm(pd->msg_queue, &cpt);
VERB0("The waited message was queued");
return no_error;
}
TRY(gras_msg_recv(*expeditor, &msgt_got, &payload_got, &payload_size_got));
if (msgt_got->code == msgt_want->code) {
memcpy(payload, payload_got, payload_size_got);
- gras_free(payload_got);
+ xbt_free(payload_got);
VERB0("Got waited message");
return no_error;
}
msg.type = msgt_got;
msg.payload = payload;
msg.payload_size = payload_size_got;
- gras_dynar_push(pd->msg_queue,&msg);
+ xbt_dynar_push(pd->msg_queue,&msg);
now=gras_os_time();
if (now - start + 0.001 < timeout) {
* Waits up to #timeOut# seconds to see if a message comes in; if so, calls the
* registered listener for that message (see RegisterCallback()).
*/
-gras_error_t
+xbt_error_t
gras_msg_handle(double timeOut) {
- gras_error_t errcode;
+ xbt_error_t errcode;
int cpt;
gras_msg_t msg;
VERB1("Handling message within the next %.2fs",timeOut);
/* get a message (from the queue or from the net) */
- if (gras_dynar_length(pd->msg_queue)) {
- gras_dynar_shift(pd->msg_queue,&msg);
+ if (xbt_dynar_length(pd->msg_queue)) {
+ xbt_dynar_shift(pd->msg_queue,&msg);
expeditor = msg.expeditor;
msgtype = msg.type;
payload = msg.payload;
}
/* handle it */
- gras_dynar_foreach(pd->cbl_list,cpt,list) {
+ xbt_dynar_foreach(pd->cbl_list,cpt,list) {
if (list->id == msgtype->code) {
break;
} else {
return no_error;
}
- gras_dynar_foreach(list->cbs,cpt,cb) {
+ xbt_dynar_foreach(list->cbs,cpt,cb) {
INFO3("Use the callback #%d (@%p) for incomming msg %s",
cpt+1,cb,msgtype->name);
if ((*cb)(expeditor,payload)) {
/* cb handled the message */
- gras_free(payload);
+ xbt_free(payload);
return no_error;
}
}
gras_cbl_free(void *data){
gras_cblist_t *list=*(void**)data;
if (list) {
- gras_dynar_free(&( list->cbs ));
- gras_free(list);
+ xbt_dynar_free(&( list->cbs ));
+ xbt_free(list);
}
}
DEBUG2("Register %p as callback to %s",cb,msgtype->name);
/* search the list of cb for this message on this host (creating if NULL) */
- gras_dynar_foreach(pd->cbl_list,cpt,list) {
+ xbt_dynar_foreach(pd->cbl_list,cpt,list) {
if (list->id == msgtype->code) {
break;
} else {
}
if (!list) {
/* First cb? Create room */
- list = gras_new(gras_cblist_t,1);
+ list = xbt_new(gras_cblist_t,1);
list->id = msgtype->code;
- list->cbs = gras_dynar_new(sizeof(gras_cb_t), NULL);
- gras_dynar_push(pd->cbl_list,&list);
+ list->cbs = xbt_dynar_new(sizeof(gras_cb_t), NULL);
+ xbt_dynar_push(pd->cbl_list,&list);
}
/* Insert the new one into the set */
- gras_dynar_insert_at(list->cbs,0,&cb);
+ xbt_dynar_insert_at(list->cbs,0,&cb);
}
void
int found = 0;
/* search the list of cb for this message on this host */
- gras_dynar_foreach(pd->cbl_list,cpt,list) {
+ xbt_dynar_foreach(pd->cbl_list,cpt,list) {
if (list->id == msgtype->code) {
break;
} else {
/* Remove it from the set */
if (list) {
- gras_dynar_foreach(list->cbs,cpt,cb_cpt) {
+ xbt_dynar_foreach(list->cbs,cpt,cb_cpt) {
if (cb == cb_cpt) {
- gras_dynar_cursor_rm(list->cbs, &cpt);
+ xbt_dynar_cursor_rm(list->cbs, &cpt);
found = 1;
}
}
int payload_size;
} gras_msg_t;
-gras_error_t gras_msg_send_namev(gras_socket_t sock,
+xbt_error_t gras_msg_send_namev(gras_socket_t sock,
const char *namev,
void *payload);
gras_datadesc_type_t ctn_type;
} s_gras_msgtype_t;
-extern gras_set_t _gras_msgtype_set; /* of gras_msgtype_t */
+extern xbt_set_t _gras_msgtype_set; /* of gras_msgtype_t */
void gras_msgtype_free(void *msgtype);
-gras_error_t gras_msg_recv(gras_socket_t sock,
+xbt_error_t gras_msg_recv(gras_socket_t sock,
gras_msgtype_t *msgtype,
void **payload,
int *payload_size);
*/
struct s_gras_cblist {
long int id;
- gras_dynar_t cbs; /* of gras_msg_cb_t */
+ xbt_dynar_t cbs; /* of gras_msg_cb_t */
};
void gras_cblist_free(void *cbl);
#include "timeouts.h"
#include "protocol.h"
-GRAS_LOG_NEW_DEFAULT_CATEGORY(rl,"Real Life");
+XBT_LOG_NEW_DEFAULT_CATEGORY(rl,"Real Life");
/* globals */
static grasProcessData_t *_grasProcessData;
/* Prototypes of internal functions */
static int grasConversionRequired(const DataDescriptor *description, size_t howMany);
-static gras_error_t
+static xbt_error_t
_gras_rawsock_exchange(gras_rawsock_t *sd, int sender, unsigned int timeout,
unsigned int expSize, unsigned int msgSize);
-gras_error_t gras_process_init() {
+xbt_error_t gras_process_init() {
if (!(_grasProcessData=(grasProcessData_t *)malloc(sizeof(grasProcessData_t)))) {
fprintf(stderr,"gras_process_init: cannot malloc %d bytes\n",sizeof(grasProcessData_t));
return malloc_error;
_grasProcessData->userdata = NULL;
return no_error;
}
-gras_error_t gras_process_finalize() {
+xbt_error_t gras_process_finalize() {
fprintf(stderr,"FIXME: %s not implemented (=> leaking on exit :)\n",__FUNCTION__);
return no_error;
}
/* **************************************************************************
* Openning/Maintaining/Closing connexions
* **************************************************************************/
-gras_error_t
+xbt_error_t
gras_sock_client_open(const char *host, short port,
/* OUT */ gras_sock_t **sock) {
}
-gras_error_t
+xbt_error_t
gras_sock_server_open(unsigned short startingPort, unsigned short endingPort,
/* OUT */ gras_sock_t **sock) {
return no_error;
}
-gras_error_t gras_sock_close(gras_sock_t *sock) {
+xbt_error_t gras_sock_close(gras_sock_t *sock) {
if (sock) {
DROP_SOCKET(&(sock->sock));
if (sock->peer_addr) free(sock->peer_addr);
return recvResult;
}
-gras_error_t grasDataSend(gras_sock_t *sd,
+xbt_error_t grasDataSend(gras_sock_t *sd,
const void *data,
const DataDescriptor *description,
size_t description_length,
return no_error;
}
-gras_error_t
+xbt_error_t
grasMsgRecv(gras_msg_t **msg,
double timeOut) {
int dummyldap;
* Send a message to the network
*/
-gras_error_t
+xbt_error_t
gras_msg_send(gras_sock_t *sd,
gras_msg_t *msg,
- e_gras_free_directive_t freeDirective) {
+ e_xbt_free_directive_t freeDirective) {
- gras_error_t errcode;
+ xbt_error_t errcode;
int i;
/* arg validity checks */
- gras_assert0(msg,"Trying to send NULL message");
- gras_assert0(sd, "Trying to send over a NULL socket");
+ xbt_assert0(msg,"Trying to send NULL message");
+ xbt_assert0(sd, "Trying to send over a NULL socket");
fprintf(stderr,"Header to send=ver:'%s' msg:%d size:%d seqCount:%d\n",
msg->header,
headerDescriptor,headerDescriptorCount,1))) {
fprintf(stderr,"gras_msg_send: Error '%s' while sending header of message %s to %s:%d\n",
- gras_error_name(errcode),msg->entry->name,gras_sock_get_peer_name(sd),gras_sock_get_peer_port(sd));
+ xbt_error_name(errcode),msg->entry->name,gras_sock_get_peer_name(sd),gras_sock_get_peer_port(sd));
return errcode;
}
msg->dataCount,countDescriptor,countDescriptorCount,
msg->entry->seqCount))) {
fprintf(stderr,"gras_msg_send: Error '%s' while sending sequence counts of message %s to %s\n",
- gras_error_name(errcode),msg->entry->name,gras_sock_get_peer_name(sd));
+ xbt_error_name(errcode),msg->entry->name,gras_sock_get_peer_name(sd));
return errcode;
}
(const DataDescriptor*)msg->entry->dd[i],msg->entry->ddCount[i],
msg->dataCount[i]))) {
fprintf(stderr,"gras_msg_send: Error '%s' while sending sequence %d of message %s to %s\n",
- gras_error_name(errcode),i,msg->entry->name,gras_sock_get_peer_name(sd));
+ xbt_error_name(errcode),i,msg->entry->name,gras_sock_get_peer_name(sd));
return errcode;
}
}
/* **************************************************************************
* Creating/Using raw sockets
* **************************************************************************/
-gras_error_t gras_rawsock_server_open(unsigned short startingPort,
+xbt_error_t gras_rawsock_server_open(unsigned short startingPort,
unsigned short endingPort,
unsigned int bufSize, gras_rawsock_t **sock) {
struct sockaddr_in sockaddr;
return;
}
-gras_error_t gras_rawsock_client_open(const char *host, short port,
+xbt_error_t gras_rawsock_client_open(const char *host, short port,
unsigned int bufSize, gras_rawsock_t **sock) {
int i,addrCount;
IPAddress addresses[10];
return no_error;
}
-gras_error_t gras_rawsock_close(gras_rawsock_t *sd) {
+xbt_error_t gras_rawsock_close(gras_rawsock_t *sd) {
if (sd) {
CloseSocket(&(sd->sock), 0);
free(sd);
}
/* FIXME: RL ignores the provided timeout and compute an appropriate one */
-static gras_error_t
+static xbt_error_t
_gras_rawsock_exchange(gras_rawsock_t *sd, int sender, unsigned int timeout,
unsigned int expSize, unsigned int msgSize){
char *expData;
return no_error;
}
-gras_error_t
+xbt_error_t
gras_rawsock_recv(gras_rawsock_t *sd, unsigned int expSize, unsigned int msgSize,
unsigned int timeout) {
return _gras_rawsock_exchange(sd,0,timeout,expSize,msgSize);
}
-gras_error_t
+xbt_error_t
gras_rawsock_send(gras_rawsock_t *sd, unsigned int expSize, unsigned int msgSize){
return _gras_rawsock_exchange(sd,1,0,expSize,msgSize);
}
*
* Send a sequence of data across the network
*/
-gras_error_t
+xbt_error_t
grasDataSend(gras_sock_t *sd,
const void *data,
const DataDescriptor *description,
#include "gras_sg.h"
-GRAS_LOG_DEFAULT_CATEGORY(GRAS);
+XBT_LOG_DEFAULT_CATEGORY(GRAS);
/* **************************************************************************
* Openning/Maintaining/Closing connexions (private functions for both raw
* and regular sockets)
* **************************************************************************/
-gras_error_t
+xbt_error_t
_gras_sock_server_open(unsigned short startingPort, unsigned short endingPort,
int raw, unsigned int bufSize, /* OUT */ gras_sock_t **sock) {
int port,i;
const char *host=MSG_host_get_name(MSG_host_self());
- gras_assert0(hd,"HostData=NULL !! Please run grasInit on each process\n");
- gras_assert0(pd,"ProcessData=NULL !! Please run grasInit on each process\n");
+ xbt_assert0(hd,"HostData=NULL !! Please run grasInit on each process\n");
+ xbt_assert0(pd,"ProcessData=NULL !! Please run grasInit on each process\n");
for (port=startingPort ; port <= endingPort ; port++) {
for (i=0; i<hd->portLen && hd->port[i] != port; i++);
return mismatch_error;
}
-gras_error_t
+xbt_error_t
_gras_sock_client_open(const char *host, short port, int raw, unsigned int bufSize,
/* OUT */ gras_sock_t **sock) {
m_host_t peer;
return no_error;
}
-gras_error_t _gras_sock_close(int raw, gras_sock_t *sd) {
+xbt_error_t _gras_sock_close(int raw, gras_sock_t *sd) {
gras_hostdata_t *hd=(gras_hostdata_t *)MSG_host_get_data(MSG_host_self());
int i;
- gras_assert0(hd,"HostData=NULL !! Please run grasInit on each process\n");
+ xbt_assert0(hd,"HostData=NULL !! Please run grasInit on each process\n");
if (!sd) return no_error;
if (raw && !sd->raw_sock) {
/* **************************************************************************
* Creating/Using regular sockets
* **************************************************************************/
-gras_error_t
+xbt_error_t
gras_sock_server_open(unsigned short startingPort, unsigned short endingPort,
/* OUT */ gras_sock_t **sock) {
return _gras_sock_server_open(startingPort,endingPort,0,0,sock);
}
-gras_error_t
+xbt_error_t
gras_sock_client_open(const char *host, short port,
/* OUT */ gras_sock_t **sock) {
return _gras_sock_client_open(host,port,0,0,sock);
}
-gras_error_t gras_sock_close(gras_sock_t *sd) {
+xbt_error_t gras_sock_close(gras_sock_t *sd) {
return _gras_sock_close(0,sd);
}
/* **************************************************************************
* Creating/Using raw sockets
* **************************************************************************/
-gras_error_t gras_rawsock_server_open(unsigned short startingPort, unsigned short endingPort,
+xbt_error_t gras_rawsock_server_open(unsigned short startingPort, unsigned short endingPort,
unsigned int bufSize, gras_rawsock_t **sock) {
return _gras_sock_server_open(startingPort,endingPort,1,bufSize,(gras_sock_t**)sock);
}
-gras_error_t gras_rawsock_client_open(const char *host, short port,
+xbt_error_t gras_rawsock_client_open(const char *host, short port,
unsigned int bufSize, gras_rawsock_t **sock) {
return _gras_sock_client_open(host,port,1,bufSize,(gras_sock_t**)sock);
}
-gras_error_t gras_rawsock_close(gras_rawsock_t *sd) {
+xbt_error_t gras_rawsock_close(gras_rawsock_t *sd) {
return _gras_sock_close(1,(gras_sock_t*)sd);
}
return sd->to_port;
}
-gras_error_t
+xbt_error_t
gras_rawsock_send(gras_rawsock_t *sock, unsigned int expSize, unsigned int msgSize) {
unsigned int bytesTotal;
static unsigned int count=0;
m_task_t task=NULL;
char name[256];
- gras_assert0(sock->raw_sock,"Asked to send raw data on a regular socket\n");
+ xbt_assert0(sock->raw_sock,"Asked to send raw data on a regular socket\n");
for(bytesTotal = 0;
bytesTotal < expSize;
return no_error;
}
-gras_error_t
+xbt_error_t
gras_rawsock_recv(gras_rawsock_t *sock, unsigned int expSize, unsigned int msgSize,
unsigned int timeout) {
grasProcessData_t *pd=(grasProcessData_t *)MSG_process_get_data(MSG_process_self());
m_task_t task=NULL;
double startTime;
- gras_assert0(sock->raw_sock,"Asked to receive raw data on a regular socket\n");
+ xbt_assert0(sock->raw_sock,"Asked to receive raw data on a regular socket\n");
startTime=gras_time();
for(bytesTotal = 0;
* Actually exchanging messages
* **************************************************************************/
-gras_error_t
+xbt_error_t
grasMsgRecv(gras_msg_t **msg,
double timeOut) {
return timeout_error;
}
-gras_error_t
+xbt_error_t
gras_msg_send(gras_sock_t *sd,
gras_msg_t *_msg,
- e_gras_free_directive_t freeDirective) {
+ e_xbt_free_directive_t freeDirective) {
grasProcessData_t *pd=grasProcessDataGet();
m_task_t task;
gras_sock_t *answer;
/* arg validity checks */
- gras_assert0(msg,"Trying to send NULL message");
- gras_assert0(sd ,"Trying to send over a NULL socket");
+ xbt_assert0(msg,"Trying to send NULL message");
+ xbt_assert0(sd ,"Trying to send over a NULL socket");
if (!(answer=(gras_sock_t*)malloc(sizeof(gras_sock_t)))) {
RAISE_MALLOC;
#include <sys/socket.h>
#include "gras/Transport/transport_private.h"
-GRAS_LOG_EXTERNAL_CATEGORY(transport);
-GRAS_LOG_DEFAULT_CATEGORY(transport);
+XBT_LOG_EXTERNAL_CATEGORY(transport);
+XBT_LOG_DEFAULT_CATEGORY(transport);
*
* if timeout>0 and no message there, wait at most that amount of time before giving up.
*/
-gras_error_t
+xbt_error_t
gras_trp_select(double timeout,
gras_socket_t *dst) {
- gras_error_t errcode;
- gras_dynar_t sockets= gras_socketset_get();
+ xbt_error_t errcode;
+ xbt_dynar_t sockets= gras_socketset_get();
int done = -1;
double wakeup = gras_os_time() + 1000000*timeout;
double now = 0;
/* construct the set of socket to ear from */
FD_ZERO(&FDS);
- gras_dynar_foreach(sockets,cursor,sock_iter) {
+ xbt_dynar_foreach(sockets,cursor,sock_iter) {
if (sock_iter->incoming) {
if (max_fds < sock_iter->sd)
max_fds = sock_iter->sd;
RAISE3(system_error,"invalid select: nb fds: %d, timeout: %d.%d",
max_fds, (int)tout.tv_sec,(int) tout.tv_usec);
case ENOMEM:
- gras_assert0(0,"Malloc error during the select");
+ xbt_assert0(0,"Malloc error during the select");
default:
RAISE2(system_error,"Error during select: %s (%d)",
strerror(errno),errno);
continue; /* this was a timeout */
}
- gras_dynar_foreach(sockets,cursor,sock_iter) {
+ xbt_dynar_foreach(sockets,cursor,sock_iter) {
if(!FD_ISSET(sock_iter->sd, &FDS)) { /* this socket is not ready */
continue;
}
return timeout_error;
}
-gras_error_t gras_trp_sg_setup(gras_trp_plugin_t *plug) {
+xbt_error_t gras_trp_sg_setup(gras_trp_plugin_t *plug) {
return mismatch_error;
}
#include <msg.h>
#include "gras/Virtu/virtu_sg.h"
-GRAS_LOG_EXTERNAL_CATEGORY(transport);
-GRAS_LOG_DEFAULT_CATEGORY(transport);
+XBT_LOG_EXTERNAL_CATEGORY(transport);
+XBT_LOG_DEFAULT_CATEGORY(transport);
/**
* gras_trp_select:
*
* if timeout>0 and no message there, wait at most that amount of time before giving up.
*/
-gras_error_t
+xbt_error_t
gras_trp_select(double timeout,
gras_socket_t *dst) {
- gras_error_t errcode;
+ xbt_error_t errcode;
double startTime=gras_os_time();
gras_procdata_t *pd=gras_procdata_get();
gras_trp_sg_sock_data_t *sockdata;
r_pid = MSG_task_probe_from((m_channel_t) pd->chan);
if (r_pid >= 0) {
/* Try to reuse an already openned socket to that expeditor */
- gras_dynar_foreach(pd->sockets,cursor,sock_iter) {
+ xbt_dynar_foreach(pd->sockets,cursor,sock_iter) {
DEBUG1("Consider %p as outgoing socket to expeditor",sock_iter);
sockdata = sock_iter->data;
(*dst)->port = -1;
- sockdata = gras_new(gras_trp_sg_sock_data_t,1);
+ sockdata = xbt_new(gras_trp_sg_sock_data_t,1);
sockdata->from_PID = MSG_process_self_PID();
sockdata->to_PID = r_pid;
sockdata->to_host = MSG_process_get_host(MSG_process_from_PID(r_pid));
(*dst)->peer_name = strdup(MSG_host_get_name(sockdata->to_host));
remote_hd=(gras_hostdata_t *)MSG_host_get_data(sockdata->to_host);
- gras_assert0(remote_hd,"Run gras_process_init!!");
+ xbt_assert0(remote_hd,"Run gras_process_init!!");
sockdata->to_chan = -1;
(*dst)->peer_port = -10;
- for (cursor=0; cursor<GRAS_MAX_CHANNEL; cursor++) {
+ for (cursor=0; cursor<XBT_MAX_CHANNEL; cursor++) {
if (remote_hd->proc[cursor] == r_pid) {
sockdata->to_chan = cursor;
DEBUG2("Chan %d on %s is for my pal",
cursor,(*dst)->peer_name);
- gras_dynar_foreach(remote_hd->ports, cpt, pr) {
+ xbt_dynar_foreach(remote_hd->ports, cpt, pr) {
if (sockdata->to_chan == pr.tochan) {
if (pr.raw) {
DEBUG0("Damn, it's raw");
}
}
}
- gras_assert0(sockdata->to_chan != -1,
+ xbt_assert0(sockdata->to_chan != -1,
"Got a message from a process without channel");
return no_error;
/* dummy implementations of the functions used in RL mode */
-gras_error_t gras_trp_tcp_setup(gras_trp_plugin_t *plug) {
+xbt_error_t gras_trp_tcp_setup(gras_trp_plugin_t *plug) {
return mismatch_error;
}
-gras_error_t gras_trp_file_setup(gras_trp_plugin_t *plug) {
+xbt_error_t gras_trp_file_setup(gras_trp_plugin_t *plug) {
return mismatch_error;
}
#include "gras/Transport/transport_private.h"
-GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(transport,gras,"Conveying bytes over the network");
-GRAS_LOG_NEW_SUBCATEGORY(raw_trp,transport,"Conveying bytes over the network without formating");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(transport,gras,"Conveying bytes over the network");
+XBT_LOG_NEW_SUBCATEGORY(raw_trp,transport,"Conveying bytes over the network without formating");
-static gras_dict_t _gras_trp_plugins; /* All registered plugins */
+static xbt_dict_t _gras_trp_plugins; /* All registered plugins */
static void gras_trp_plugin_free(void *p); /* free one of the plugins */
static void gras_trp_socket_free(void *s); /* free one socket */
static void
gras_trp_plugin_new(const char *name, gras_trp_setup_t setup) {
- gras_error_t errcode;
+ xbt_error_t errcode;
- gras_trp_plugin_t *plug = gras_new0(gras_trp_plugin_t, 1);
+ gras_trp_plugin_t *plug = xbt_new0(gras_trp_plugin_t, 1);
DEBUG1("Create plugin %s",name);
- plug->name=gras_strdup(name);
+ plug->name=xbt_strdup(name);
errcode = setup(plug);
switch (errcode) {
case mismatch_error:
/* SG plugin return mismatch when in RL mode (and vice versa) */
- gras_free(plug->name);
- gras_free(plug);
+ xbt_free(plug->name);
+ xbt_free(plug);
break;
case no_error:
- gras_dict_set(_gras_trp_plugins,
+ xbt_dict_set(_gras_trp_plugins,
name, plug, gras_trp_plugin_free);
break;
void gras_trp_init(void){
/* make room for all plugins */
- _gras_trp_plugins=gras_dict_new();
+ _gras_trp_plugins=xbt_dict_new();
/* Add them */
gras_trp_plugin_new("tcp", gras_trp_tcp_setup);
void
gras_trp_exit(void){
- gras_dict_free(&_gras_trp_plugins);
+ xbt_dict_free(&_gras_trp_plugins);
}
plug->exit(plug);
} else if (plug->data) {
DEBUG1("Plugin %s lacks exit(). Free data anyway.",plug->name);
- gras_free(plug->data);
+ xbt_free(plug->data);
}
- gras_free(plug->name);
- gras_free(plug);
+ xbt_free(plug->name);
+ xbt_free(plug);
}
}
void gras_trp_socket_new(int incoming,
gras_socket_t *dst) {
- gras_socket_t sock=gras_new0(s_gras_socket_t,1);
+ gras_socket_t sock=xbt_new0(s_gras_socket_t,1);
DEBUG1("Create a new socket (%p)", (void*)sock);
*dst = sock;
- gras_dynar_push(gras_socketset_get(),dst);
+ xbt_dynar_push(gras_socketset_get(),dst);
}
* Opens a server socket and make it ready to be listened to.
* In real life, you'll get a TCP socket.
*/
-gras_error_t
+xbt_error_t
gras_socket_server_ext(unsigned short port,
unsigned long int bufSize,
/* OUT */ gras_socket_t *dst) {
- gras_error_t errcode;
+ xbt_error_t errcode;
gras_trp_plugin_t *trp;
gras_socket_t sock;
sock->accepting?'y':'n');
if (errcode != no_error) {
- gras_free(sock);
+ xbt_free(sock);
return errcode;
}
* Opens a client socket to a remote host.
* In real life, you'll get a TCP socket.
*/
-gras_error_t
+xbt_error_t
gras_socket_client_ext(const char *host,
unsigned short port,
/* OUT */ gras_socket_t *dst) {
- gras_error_t errcode;
+ xbt_error_t errcode;
gras_trp_plugin_t *trp;
gras_socket_t sock;
sock->accepting?'y':'n');
if (errcode != no_error) {
- gras_free(sock);
+ xbt_free(sock);
return errcode;
}
* Opens a server socket and make it ready to be listened to.
* In real life, you'll get a TCP socket.
*/
-gras_error_t
+xbt_error_t
gras_socket_server(unsigned short port,
/* OUT */ gras_socket_t *dst) {
return gras_socket_server_ext(port,32,0,dst);
* Opens a client socket to a remote host.
* In real life, you'll get a TCP socket.
*/
-gras_error_t
+xbt_error_t
gras_socket_client(const char *host,
unsigned short port,
/* OUT */ gras_socket_t *dst) {
void gras_socket_close(gras_socket_t sock) {
- gras_dynar_t sockets = gras_socketset_get();
+ xbt_dynar_t sockets = gras_socketset_get();
gras_socket_t sock_iter;
int cursor;
/* FIXME: Issue an event when the socket is closed */
if (sock) {
- gras_dynar_foreach(sockets,cursor,sock_iter) {
+ xbt_dynar_foreach(sockets,cursor,sock_iter) {
if (sock == sock_iter) {
- gras_dynar_cursor_rm(sockets,&cursor);
+ xbt_dynar_cursor_rm(sockets,&cursor);
if ( sock->plugin->socket_close)
(* sock->plugin->socket_close)(sock);
/* free the memory */
if (sock->peer_name)
- gras_free(sock->peer_name);
- gras_free(sock);
+ xbt_free(sock->peer_name);
+ xbt_free(sock);
return;
}
}
*
* Send a bunch of bytes from on socket
*/
-gras_error_t
+xbt_error_t
gras_trp_chunk_send(gras_socket_t sd,
char *data,
long int size) {
- gras_assert1(sd->outgoing,
+ xbt_assert1(sd->outgoing,
"Socket not suited for data send (outgoing=%c)",
sd->outgoing?'y':'n');
- gras_assert1(sd->plugin->chunk_send,
+ xbt_assert1(sd->plugin->chunk_send,
"No function chunk_send on transport plugin %s",
sd->plugin->name);
return (*sd->plugin->chunk_send)(sd,data,size);
*
* Receive a bunch of bytes from a socket
*/
-gras_error_t
+xbt_error_t
gras_trp_chunk_recv(gras_socket_t sd,
char *data,
long int size) {
- gras_assert0(sd->incoming,
+ xbt_assert0(sd->incoming,
"Socket not suited for data receive");
- gras_assert1(sd->plugin->chunk_recv,
+ xbt_assert1(sd->plugin->chunk_recv,
"No function chunk_recv on transport plugin %s",
sd->plugin->name);
return (sd->plugin->chunk_recv)(sd,data,size);
*
* Make sure all pending communications are done
*/
-gras_error_t
+xbt_error_t
gras_trp_flush(gras_socket_t sd) {
return (sd->plugin->flush)(sd);
}
-gras_error_t
+xbt_error_t
gras_trp_plugin_get_by_name(const char *name,
gras_trp_plugin_t **dst){
- return gras_dict_get(_gras_trp_plugins,name,(void**)dst);
+ return xbt_dict_get(_gras_trp_plugins,name,(void**)dst);
}
int gras_socket_my_port (gras_socket_t sock) {
return sock->peer_name;
}
-gras_error_t gras_socket_raw_send(gras_socket_t peer,
+xbt_error_t gras_socket_raw_send(gras_socket_t peer,
unsigned int timeout,
unsigned long int exp_size,
unsigned long int msg_size) {
- gras_error_t errcode;
- char *chunk = gras_malloc(msg_size);
+ xbt_error_t errcode;
+ char *chunk = xbt_malloc(msg_size);
int exp_sofar;
- gras_assert0(peer->raw,"Asked to send raw data on a regular socket");
+ xbt_assert0(peer->raw,"Asked to send raw data on a regular socket");
for (exp_sofar=0; exp_sofar < exp_size; exp_sofar += msg_size) {
CDEBUG5(raw_trp,"Sent %d of %lu (msg_size=%ld) to %s:%d",
exp_sofar,exp_size,msg_size,
exp_sofar,exp_size,msg_size,
gras_socket_peer_name(peer), gras_socket_peer_port(peer));
- gras_free(chunk);
+ xbt_free(chunk);
return no_error;//gras_socket_raw_exchange(peer,1,timeout,expSize,msgSize);
}
-gras_error_t gras_socket_raw_recv(gras_socket_t peer,
+xbt_error_t gras_socket_raw_recv(gras_socket_t peer,
unsigned int timeout,
unsigned long int exp_size,
unsigned long int msg_size){
- gras_error_t errcode;
- char *chunk = gras_malloc(msg_size);
+ xbt_error_t errcode;
+ char *chunk = xbt_malloc(msg_size);
int exp_sofar;
- gras_assert0(peer->raw,"Asked to recveive raw data on a regular socket\n");
+ xbt_assert0(peer->raw,"Asked to recveive raw data on a regular socket\n");
for (exp_sofar=0; exp_sofar < exp_size; exp_sofar += msg_size) {
CDEBUG5(raw_trp,"Recvd %d of %lu (msg_size=%ld) from %s:%d",
exp_sofar,exp_size,msg_size,
exp_sofar,exp_size,msg_size,
gras_socket_peer_name(peer), gras_socket_peer_port(peer));
- gras_free(chunk);
+ xbt_free(chunk);
return no_error;//gras_socket_raw_exchange(peer,0,timeout,expSize,msgSize);
}
/***
*** Main user functions
***/
-gras_error_t gras_trp_chunk_send(gras_socket_t sd,
+xbt_error_t gras_trp_chunk_send(gras_socket_t sd,
char *data,
long int size);
-gras_error_t gras_trp_chunk_recv(gras_socket_t sd,
+xbt_error_t gras_trp_chunk_recv(gras_socket_t sd,
char *data,
long int size);
-gras_error_t gras_trp_flush(gras_socket_t sd);
+xbt_error_t gras_trp_flush(gras_socket_t sd);
/* Find which socket needs to be read next */
-gras_error_t
+xbt_error_t
gras_trp_select(double timeout,
gras_socket_t *dst);
/* dst pointers are created and initialized with default values
before call to socket_client/server.
Retrive the info you need from there. */
- gras_error_t (*socket_client)(gras_trp_plugin_t *self,
+ xbt_error_t (*socket_client)(gras_trp_plugin_t *self,
gras_socket_t dst);
- gras_error_t (*socket_server)(gras_trp_plugin_t *self,
+ xbt_error_t (*socket_server)(gras_trp_plugin_t *self,
gras_socket_t dst);
- gras_error_t (*socket_accept)(gras_socket_t sock,
+ xbt_error_t (*socket_accept)(gras_socket_t sock,
gras_socket_t *dst);
but should not free the socket itself (beside the specific part) */
void (*socket_close)(gras_socket_t sd);
- gras_error_t (*chunk_send)(gras_socket_t sd,
+ xbt_error_t (*chunk_send)(gras_socket_t sd,
const char *data,
long int size);
- gras_error_t (*chunk_recv)(gras_socket_t sd,
+ xbt_error_t (*chunk_recv)(gras_socket_t sd,
char *data,
long int size);
/* flush has to make sure that the pending communications are achieved */
- gras_error_t (*flush)(gras_socket_t sd);
+ xbt_error_t (*flush)(gras_socket_t sd);
void *data; /* plugin-specific data */
void (*exit)(gras_trp_plugin_t *);
};
-gras_error_t
+xbt_error_t
gras_trp_plugin_get_by_name(const char *name,
gras_trp_plugin_t **dst);
#include "xbt/misc.h"
#include "transport_private.h"
-GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(trp_buf,transport,
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(trp_buf,transport,
"Generic buffered transport (works on top of TCP or SG)");
/***
*** Prototypes
***/
-gras_error_t gras_trp_buf_socket_client(gras_trp_plugin_t *self,
+xbt_error_t gras_trp_buf_socket_client(gras_trp_plugin_t *self,
gras_socket_t sock);
-gras_error_t gras_trp_buf_socket_server(gras_trp_plugin_t *self,
+xbt_error_t gras_trp_buf_socket_server(gras_trp_plugin_t *self,
gras_socket_t sock);
-gras_error_t gras_trp_buf_socket_accept(gras_socket_t sock,
+xbt_error_t gras_trp_buf_socket_accept(gras_socket_t sock,
gras_socket_t *dst);
void gras_trp_buf_socket_close(gras_socket_t sd);
-gras_error_t gras_trp_buf_chunk_send(gras_socket_t sd,
+xbt_error_t gras_trp_buf_chunk_send(gras_socket_t sd,
const char *data,
long int size);
-gras_error_t gras_trp_buf_chunk_recv(gras_socket_t sd,
+xbt_error_t gras_trp_buf_chunk_recv(gras_socket_t sd,
char *data,
long int size);
-gras_error_t gras_trp_buf_flush(gras_socket_t sock);
+xbt_error_t gras_trp_buf_flush(gras_socket_t sock);
/***
};
void gras_trp_buf_init_sock(gras_socket_t sock) {
- gras_trp_bufdata_t *data=gras_new(gras_trp_bufdata_t,1);
+ gras_trp_bufdata_t *data=xbt_new(gras_trp_bufdata_t,1);
- GRAS_IN;
+ XBT_IN;
data->buffsize = 100 * 1024 ; /* 100k */
data->in.size = 0;
- data->in.data = gras_malloc(data->buffsize);
+ data->in.data = xbt_malloc(data->buffsize);
data->in.pos = 0; /* useless, indeed, since size==pos */
data->out.size = 0;
- data->out.data = gras_malloc(data->buffsize);
+ data->out.data = xbt_malloc(data->buffsize);
data->out.pos = 0;
sock->bufdata = data;
/***
*** Code
***/
-gras_error_t
+xbt_error_t
gras_trp_buf_setup(gras_trp_plugin_t *plug) {
- gras_error_t errcode;
- gras_trp_buf_plug_data_t *data =gras_new(gras_trp_buf_plug_data_t,1);
+ xbt_error_t errcode;
+ gras_trp_buf_plug_data_t *data =xbt_new(gras_trp_buf_plug_data_t,1);
- GRAS_IN;
+ XBT_IN;
TRY(gras_trp_plugin_get_by_name(gras_if_RL() ? "tcp" : "sg",
&(data->super)));
DEBUG1("Derivate a buffer plugin from %s",gras_if_RL() ? "tcp" : "sg");
return no_error;
}
-gras_error_t gras_trp_buf_socket_client(gras_trp_plugin_t *self,
+xbt_error_t gras_trp_buf_socket_client(gras_trp_plugin_t *self,
/* OUT */ gras_socket_t sock){
- gras_error_t errcode;
+ xbt_error_t errcode;
gras_trp_plugin_t *super=((gras_trp_buf_plug_data_t*)self->data)->super;
- GRAS_IN;
+ XBT_IN;
TRY(super->socket_client(super,sock));
sock->plugin = self;
gras_trp_buf_init_sock(sock);
*
* Open a socket used to receive messages.
*/
-gras_error_t gras_trp_buf_socket_server(gras_trp_plugin_t *self,
+xbt_error_t gras_trp_buf_socket_server(gras_trp_plugin_t *self,
/* OUT */ gras_socket_t sock){
- gras_error_t errcode;
+ xbt_error_t errcode;
gras_trp_plugin_t *super=((gras_trp_buf_plug_data_t*)self->data)->super;
- GRAS_IN;
+ XBT_IN;
TRY(super->socket_server(super,sock));
sock->plugin = self;
gras_trp_buf_init_sock(sock);
return no_error;
}
-gras_error_t
+xbt_error_t
gras_trp_buf_socket_accept(gras_socket_t sock,
gras_socket_t *dst) {
- gras_error_t errcode;
+ xbt_error_t errcode;
gras_trp_plugin_t *super=((gras_trp_buf_plug_data_t*)sock->plugin->data)->super;
- GRAS_IN;
+ XBT_IN;
TRY(super->socket_accept(sock,dst));
(*dst)->plugin = sock->plugin;
gras_trp_buf_init_sock(*dst);
gras_trp_plugin_t *super=((gras_trp_buf_plug_data_t*)sock->plugin->data)->super;
gras_trp_bufdata_t *data=sock->bufdata;
- GRAS_IN;
+ XBT_IN;
if (data->in.size || data->out.size)
gras_trp_buf_flush(sock);
if (data->in.data)
- gras_free(data->in.data);
+ xbt_free(data->in.data);
if (data->out.data)
- gras_free(data->out.data);
- gras_free(data);
+ xbt_free(data->out.data);
+ xbt_free(data);
super->socket_close(sock);
}
*
* Send data on a TCP socket
*/
-gras_error_t
+xbt_error_t
gras_trp_buf_chunk_send(gras_socket_t sock,
const char *chunk,
long int size) {
- gras_error_t errcode;
+ xbt_error_t errcode;
gras_trp_bufdata_t *data=(gras_trp_bufdata_t*)sock->bufdata;
int chunk_pos=0;
- GRAS_IN;
+ XBT_IN;
/* Let underneath plugin check for direction, we work even in duplex */
- gras_assert0(size >= 0, "Cannot send a negative amount of data");
+ xbt_assert0(size >= 0, "Cannot send a negative amount of data");
while (chunk_pos < size) {
/* size of the chunck to receive in that shot */
TRY(gras_trp_buf_flush(sock));
}
- GRAS_OUT;
+ XBT_OUT;
return no_error;
}
*
* Receive data on a TCP socket.
*/
-gras_error_t
+xbt_error_t
gras_trp_buf_chunk_recv(gras_socket_t sock,
char *chunk,
long int size) {
- gras_error_t errcode;
+ xbt_error_t errcode;
gras_trp_plugin_t *super=((gras_trp_buf_plug_data_t*)sock->plugin->data)->super;
gras_trp_bufdata_t *data=sock->bufdata;
long int chunck_pos = 0;
/* Let underneath plugin check for direction, we work even in duplex */
- gras_assert0(sock, "Cannot recv on an NULL socket");
- gras_assert0(size >= 0, "Cannot receive a negative amount of data");
+ xbt_assert0(sock, "Cannot recv on an NULL socket");
+ xbt_assert0(size >= 0, "Cannot receive a negative amount of data");
- GRAS_IN;
+ XBT_IN;
while (chunck_pos < size) {
/* size of the chunck to receive in that shot */
data->in.pos,size - chunck_pos,size,(int)chunck_pos,chunk);
}
- GRAS_OUT;
+ XBT_OUT;
return no_error;
}
*
* Make sure the data is sent
*/
-gras_error_t
+xbt_error_t
gras_trp_buf_flush(gras_socket_t sock) {
- gras_error_t errcode;
+ xbt_error_t errcode;
uint32_t size;
gras_trp_plugin_t *super=((gras_trp_buf_