From 25d6952dcf52e6ffc1e4a402af0e2d3c17ac3935 Mon Sep 17 00:00:00 2001 From: mquinson Date: Sun, 7 Aug 2005 16:38:23 +0000 Subject: [PATCH] Last bits of convertion from xbt_error_t to exceptions. Some more cleanups (mainly killing dead code encompassed between #if 0/#endif). I now fight to get it running on remote hosts, and I'm ready for SG3 (at least a release candidate) git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@1611 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- examples/gras/ping/ping.c | 2 +- include/Makefile.am | 2 +- include/amok/bandwidth.h | 18 +- include/amok/base.h | 37 -- include/gras/datadesc.h | 49 +- include/gras/modules/bandwidth.h | 134 ------ include/gras/modules/base.h | 89 ---- include/gras/transport.h | 2 - include/xbt.h | 1 - include/xbt/dict.h | 1 - include/xbt/error.h | 2 +- src/Makefile.am | 3 +- src/amok/Bandwidth/bandwidth.c | 404 +--------------- src/amok/Bandwidth/bandwidth_private.h | 1 - src/amok/base.c | 58 --- src/gras/DataDesc/datadesc_interface.h | 10 +- src/gras/DataDesc/datadesc_private.h | 3 +- src/gras/DataDesc/ddt_convert.c | 3 +- src/gras/DataDesc/ddt_exchange.c | 564 +---------------------- src/gras/Msg/msg_interface.h | 6 +- src/gras/Msg/msg_private.h | 1 - src/gras/Transport/transport_plugin_sg.c | 73 --- src/gras/Transport/transport_private.h | 6 +- src/gras/Virtu/process.c | 1 - src/gras/Virtu/virtu_interface.h | 1 - src/msg/deployment.c | 6 +- src/msg/environment.c | 6 +- src/msg/global.c | 6 +- src/msg/gos.c | 6 +- src/msg/host.c | 6 +- src/msg/m_process.c | 6 +- src/msg/msg_config.c | 2 +- src/msg/task.c | 6 +- src/surf/maxmin.c | 2 +- src/surf/surf_parse.c | 2 +- src/surf/trace_mgr.c | 2 +- src/xbt/context.c | 2 +- src/xbt/dict.c | 12 +- src/xbt/dict_cursor.c | 4 +- src/xbt/dict_private.h | 1 - src/xbt/dynar.c | 6 +- src/xbt/fifo.c | 1 - src/xbt/heap.c | 2 +- src/xbt/log_default_appender.c | 1 - src/xbt/module.c | 1 - src/xbt/set.c | 6 +- src/xbt/swag.c | 2 +- testsuite/gras/mk_datadesc_structs.pl | 2 +- testsuite/xbt/dict_crash.c | 19 +- tools/gras/stub_generator.c | 1 + 50 files changed, 119 insertions(+), 1462 deletions(-) delete mode 100644 include/gras/modules/bandwidth.h delete mode 100644 include/gras/modules/base.h diff --git a/examples/gras/ping/ping.c b/examples/gras/ping/ping.c index 6cdd2d73c8..b422cbc8e6 100644 --- a/examples/gras/ping/ping.c +++ b/examples/gras/ping/ping.c @@ -116,7 +116,7 @@ int server (int argc,char *argv[]) { gras_exit(); INFO0("Done."); - return no_error; + return 0; } /* end_of_server */ /* ********************************************************************** diff --git a/include/Makefile.am b/include/Makefile.am index 417ef3f7ac..d560ab377e 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -2,7 +2,7 @@ include_HEADERS = gras.h xbt.h nobase_include_HEADERS = \ xbt/misc.h \ xbt/sysdep.h \ - xbt/asserts.h xbt/error.h xbt/ex.h \ + xbt/asserts.h xbt/ex.h \ xbt/log.h \ xbt/module.h \ xbt/dynar.h xbt/dict.h xbt/set.h \ diff --git a/include/amok/bandwidth.h b/include/amok/bandwidth.h index ec2d1b6c70..a4dc5f6e91 100644 --- a/include/amok/bandwidth.h +++ b/include/amok/bandwidth.h @@ -36,14 +36,14 @@ void amok_bw_init(void); void amok_bw_exit(void); -xbt_error_t amok_bw_test(gras_socket_t peer, - unsigned long int buf_size,unsigned long int exp_size,unsigned long int msg_size, - /*OUT*/ double *sec, double *bw); +void amok_bw_test(gras_socket_t peer, + unsigned long int buf_size,unsigned long int exp_size,unsigned long int msg_size, + /*OUT*/ double *sec, double *bw); -xbt_error_t amok_bw_request(const char* from_name,unsigned int from_port, - const char* to_name,unsigned int to_port, - unsigned long int bufSize,unsigned long int expSize,unsigned long int msgSize, - /*OUT*/ double *sec, double*bw); +void amok_bw_request(const char* from_name,unsigned int from_port, + const char* to_name,unsigned int to_port, + unsigned long int bufSize,unsigned long int expSize,unsigned long int msgSize, + /*OUT*/ double *sec, double*bw); /** @} */ #if 0 @@ -66,7 +66,7 @@ xbt_error_t amok_bw_request(const char* from_name,unsigned int from_port, * Ask the process 'from_name:from_port' to start to saturate the link between itself * and to_name:to_name. */ -xbt_error_t grasbw_saturate_start(const char* from_name,unsigned int from_port, +void 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); @@ -82,7 +82,7 @@ xbt_error_t grasbw_saturate_start(const char* from_name,unsigned int from_port, * Ask the process 'from_name:from_port' to stop saturating the link between itself * and to_name:to_name. */ -xbt_error_t grasbw_saturate_stop(const char* from_name,unsigned int from_port, +void grasbw_saturate_stop(const char* from_name,unsigned int from_port, const char* to_name,unsigned int to_port); diff --git a/include/amok/base.h b/include/amok/base.h index 033fe8769b..8a87862041 100644 --- a/include/amok/base.h +++ b/include/amok/base.h @@ -16,24 +16,6 @@ * The common types used as payload in the messages and their definitions * ****************************************************************************/ -/** - * amok_remoterr_t: - * - * how to indicate an eventual error - */ - -typedef struct { - char *msg; - unsigned int code; -} s_amok_remoterr_t,*amok_remoterr_t; - -amok_remoterr_t amok_remoterr_new(xbt_error_t errcode, - const char* format, ...); -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); - - /** * amok_result_t: * @@ -45,25 +27,6 @@ typedef struct { double value; } amok_result_t; -/** - * amok_repport_error: - * - * Repports an error to the process listening on socket sock. - * - * The information will be embeeded in a message of type id, which must take a msgError_t as first - * sequence (and SeqCount sequences in total). Other sequences beside the error one will be of - * length 0. - * - * The message will be builded as sprintf would, using the given format and extra args. - * - * If the message cannot be builded and sent to recipient, the string severeError will be printed - * on localhost's stderr. - */ -void -amok_repport_error (gras_socket_t sock, gras_msgtype_t msgtype, - xbt_error_t errcode, const char* format,...); - - void amok_base_init(void); void amok_base_exit(void); diff --git a/include/gras/datadesc.h b/include/gras/datadesc.h index 4d82e96d02..3ac22b8ddc 100644 --- a/include/gras/datadesc.h +++ b/include/gras/datadesc.h @@ -302,31 +302,25 @@ void gras_datadesc_cb_push_ulint(gras_datadesc_type_t typedesc, gras_cbps_t vars /* @{ */ -xbt_error_t - gras_cbps_v_pop (gras_cbps_t ps, - const char *name, - /* OUT */ gras_datadesc_type_t *ddt, - /* OUT */ void **res); -xbt_error_t -gras_cbps_v_push(gras_cbps_t ps, - const char *name, - void *data, - gras_datadesc_type_t ddt); -void -gras_cbps_v_set (gras_cbps_t ps, - const char *name, - void *data, - gras_datadesc_type_t ddt); - -void * -gras_cbps_v_get (gras_cbps_t ps, - const char *name, - /* OUT */ gras_datadesc_type_t *ddt); - -void -gras_cbps_block_begin(gras_cbps_t ps); -void -gras_cbps_block_end(gras_cbps_t ps); +void gras_cbps_v_pop (gras_cbps_t ps, + const char *name, + /* OUT */ gras_datadesc_type_t *ddt, + /* OUT */ void **res); +void gras_cbps_v_push(gras_cbps_t ps, + const char *name, + void *data, + gras_datadesc_type_t ddt); +void gras_cbps_v_set (gras_cbps_t ps, + const char *name, + void *data, + gras_datadesc_type_t ddt); + +void * gras_cbps_v_get (gras_cbps_t ps, + const char *name, + /* OUT */ gras_datadesc_type_t *ddt); + +void gras_cbps_block_begin(gras_cbps_t ps); +void gras_cbps_block_end(gras_cbps_t ps); /* @} */ /* @} */ @@ -382,11 +376,10 @@ typedef struct DataDescriptorStruct { sizeof(structType) - offsetof(structType, lastMember) - \ sizeof(memberType) * repetitions -xbt_error_t +gras_datadesc_type_t gras_datadesc_import_nws(const char *name, const DataDescriptor *desc, - unsigned long howmany, - /* OUT */ gras_datadesc_type_t *dst); + unsigned long howmany); END_DECL() diff --git a/include/gras/modules/bandwidth.h b/include/gras/modules/bandwidth.h deleted file mode 100644 index aa2e7ca6b2..0000000000 --- a/include/gras/modules/bandwidth.h +++ /dev/null @@ -1,134 +0,0 @@ -/* $Id$ */ - -/* gras_bandwidth - GRAS mecanism to do Bandwidth tests between to hosts */ - -/* Copyright (c) 2003, 2004 Martin Quinson. All rights reserved. */ - -/* This program is free software; you can redistribute it and/or modify it - * under the terms of the license (GNU LGPL) which comes with this package. */ - -#ifndef GRAS_BANDWIDTH_H -#define GRAS_BANDWIDTH_H - -#include - -/* **************************************************************************** - * The messages themselves - * ****************************************************************************/ - -#ifndef GRAS_BANDWIDTH_FIRST_MESSAGE -#define GRAS_BANDWIDTH_FIRST_MESSAGE 0 -#endif - -#define GRASMSG_BW_REQUEST GRAS_BANDWIDTH_FIRST_MESSAGE -#define GRASMSG_BW_RESULT GRAS_BANDWIDTH_FIRST_MESSAGE+1 -#define GRASMSG_BW_HANDSHAKE GRAS_BANDWIDTH_FIRST_MESSAGE+2 -#define GRASMSG_BW_HANDSHAKED GRAS_BANDWIDTH_FIRST_MESSAGE+3 - -#define GRASMSG_SAT_START GRAS_BANDWIDTH_FIRST_MESSAGE+4 -#define GRASMSG_SAT_STARTED GRAS_BANDWIDTH_FIRST_MESSAGE+5 -#define GRASMSG_SAT_STOP GRAS_BANDWIDTH_FIRST_MESSAGE+6 -#define GRASMSG_SAT_STOPPED GRAS_BANDWIDTH_FIRST_MESSAGE+7 - -#define GRASMSG_SAT_BEGIN GRAS_BANDWIDTH_FIRST_MESSAGE+8 -#define GRASMSG_SAT_BEGUN GRAS_BANDWIDTH_FIRST_MESSAGE+9 -#define GRASMSG_SAT_END GRAS_BANDWIDTH_FIRST_MESSAGE+10 -#define GRASMSG_SAT_ENDED GRAS_BANDWIDTH_FIRST_MESSAGE+11 - -/* **************************************************************************** - * The functions to triger those messages - * ****************************************************************************/ - -/** - * grasbw_register_messages: - * - * Register all messages and callbacks needed for the current process to be ready - * to do BW tests - */ -xbt_error_t grasbw_register_messages(void); - -/* *************************************************************************** - * Bandwidth tests - * ***************************************************************************/ -/** - * grasbw_test: - * @to_name: Name of the host with which we should conduct the experiment - * @to_port: port on which the peer process is listening (for message, do not - * give a raw socket here. The needed raw socket will be negociated between - * the peers) - * @bufSize: Size of the socket buffer - * @expSize: Total size of data sent across the network - * @msgSize: Size of each message sent. Ie, (@expSize % @msgSize) messages will be sent. - * @sec: where the result (in seconds) should be stored. - * @bw: observed Bandwidth (in Mb/s) - * - * Conduct a bandwidth test from the local process to the given peer. - * This call is blocking until the end of the experiment. - */ -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); - -/** - * grasbw_request: - * @from_name: Name of the host we are asking to do a experiment with (to_name:to_port) - * @from_port: port on which the process we are asking for an experiment is listening for message - * @to_name: Name of the host with which we should conduct the experiment - * @to_port: port on which the peer process is listening (for message, do not - * give a raw socket here. The needed raw socket will be negociated between - * the peers) - * @bufSize: Size of the socket buffer - * @expSize: Total size of data sent across the network - * @msgSize: Size of each message sent. Ie, (@expSize % @msgSize) messages will be sent. - * @sec: where the result (in seconds) should be stored. - * @bw: observed Bandwidth (in Mb/s) - * - * 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. - */ -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); - - -/* *************************************************************************** - * Link saturation - * ***************************************************************************/ - -/** - * grasbw_saturate_start: - * @from_name: Name of the host we are asking to do a experiment with (to_name:to_port) - * @from_port: port on which the process we are asking for an experiment is listening - * (for message, do not give a raw socket here. The needed raw socket will be negociated - * between the peers) - * @to_name: Name of the host with which we should conduct the experiment - * @to_port: port on which the peer process is listening for message - * @msgSize: Size of each message sent. - * @timeout: How long in maximum should be the saturation. - * - * Ask the process 'from_name:from_port' to start to saturate the link between itself - * and to_name:to_name. - */ -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); - -/** - * grasbw_saturate_stop: - * @from_name: Name of the host we are asking to do a experiment with (to_name:to_port) - * @from_port: port on which the process we are asking for an experiment is listening - * (for message, do not give a raw socket here. The needed raw socket will be negociated - * between the peers) - * @to_name: Name of the host with which we should conduct the experiment - * @to_port: port on which the peer process is listening for message - * - * Ask the process 'from_name:from_port' to stop saturating the link between itself - * and to_name:to_name. - */ -xbt_error_t grasbw_saturate_stop(const char* from_name,unsigned int from_port, - const char* to_name,unsigned int to_port); - - - -#endif /* GRAS_BANDWIDTH_H */ diff --git a/include/gras/modules/base.h b/include/gras/modules/base.h deleted file mode 100644 index f0f678dccb..0000000000 --- a/include/gras/modules/base.h +++ /dev/null @@ -1,89 +0,0 @@ -/* $Id$ */ - -/* gras_addons - several addons to do specific stuff not in GRAS itself */ - -/* Copyright (c) 2003, 2004 Martin Quinson. All rights reserved. */ - -/* This program is free software; you can redistribute it and/or modify it - * under the terms of the license (GNU LGPL) which comes with this package. */ - -#ifndef GRAS_ADDONS_H -#define GRAS_ADDONS_H - -#include - -#define HOSTNAME_LEN 256 -#define ERRMSG_LEN 50 - -/* **************************************************************************** - * The common types used as payload in the messages and their definitions - * ****************************************************************************/ - -/** - * msgHost_t: - * - * Description of an host - */ - -typedef struct { - char host[HOSTNAME_LEN]; - unsigned int port; -} msgHost_t; - -static const DataDescriptor msgHostDesc[] = - { SIMPLE_MEMBER(CHAR_TYPE,HOSTNAME_LEN,offsetof(msgHost_t,host)), - SIMPLE_MEMBER(UNSIGNED_INT_TYPE,1, offsetof(msgHost_t,port))}; -#define msgHostLen 2 - -/** - * msgError_t: - * - * how to indicate an eventual error - */ - -typedef struct { - char errmsg[ERRMSG_LEN]; - unsigned int errcode; -} msgError_t; - -static const DataDescriptor msgErrorDesc[] = - { SIMPLE_MEMBER(CHAR_TYPE, ERRMSG_LEN,offsetof(msgError_t,errmsg)), - SIMPLE_MEMBER(UNSIGNED_INT_TYPE, 1, offsetof(msgError_t,errcode))}; -#define msgErrorLen 2 - -/** - * msgResult_t: - * - * how to report the result of an experiment - */ - -typedef struct { - unsigned int timestamp; - double value; -} msgResult_t; - -static const DataDescriptor msgResultDesc[] = - { SIMPLE_MEMBER(UNSIGNED_INT_TYPE, 1, offsetof(msgResult_t,timestamp)), - SIMPLE_MEMBER(DOUBLE_TYPE, 1, offsetof(msgResult_t,value))}; -#define msgResultLen 2 - -/** - * grasRepportError: - * - * Repports an error to the process listening on socket sock. - * - * The information will be embeeded in a message of type id, which must take a msgError_t as first - * sequence (and SeqCount sequences in total). Other sequences beside the error one will be of - * length 0. - * - * The message will be builded as sprintf would, using the given format and extra args. - * - * If the message cannot be builded and sent to recipient, the string severeError will be printed - * on localhost's stderr. - */ -void -grasRepportError (gras_socket_t *sock, int id, int SeqCount, - const char *severeError, - xbt_error_t errcode, const char* format,...); - -#endif /* GRAS_ADDONS_H */ diff --git a/include/gras/transport.h b/include/gras/transport.h index 0d0f9a16ae..1e7ceac73e 100644 --- a/include/gras/transport.h +++ b/include/gras/transport.h @@ -11,8 +11,6 @@ #ifndef GRAS_TRANSPORT_H #define GRAS_TRANSPORT_H -#include "xbt/error.h" - /** \addtogroup GRAS_sock * \brief Socket handling (Communication facility). */ diff --git a/include/xbt.h b/include/xbt.h index 8be0e35e68..52a918980f 100644 --- a/include/xbt.h +++ b/include/xbt.h @@ -13,7 +13,6 @@ #include #include -#include #include #include diff --git a/include/xbt/dict.h b/include/xbt/dict.h index 9d3406348e..395f53e9bd 100644 --- a/include/xbt/dict.h +++ b/include/xbt/dict.h @@ -13,7 +13,6 @@ #include "xbt/misc.h" /* BEGIN_DECL */ #include "xbt/dynar.h" /* void_f_pvoid_t */ -#include "xbt/error.h" BEGIN_DECL() diff --git a/include/xbt/error.h b/include/xbt/error.h index 0616168614..a715a80564 100644 --- a/include/xbt/error.h +++ b/include/xbt/error.h @@ -10,7 +10,7 @@ #ifndef XBT_ERROR_H #define XBT_ERROR_H -//#error do not use this crap anymore +#error do not use this crap anymore #include "xbt/misc.h" /* BEGIN_DECL */ #include "xbt/log.h" diff --git a/src/Makefile.am b/src/Makefile.am index a8d60efd9a..6bd9e43d2a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -103,7 +103,8 @@ COMMON_SRC=\ xbt_modinter.h gras_modinter.h \ \ xbt/sysdep.c \ - xbt/log.c xbt/log_default_appender.c xbt/error.c \ + xbt/asserts.c \ + xbt/log.c xbt/log_default_appender.c \ xbt/dynar.c \ xbt/dict.c xbt/dict_elm.c xbt/dict_cursor.c \ xbt/dict_multi.c \ diff --git a/src/amok/Bandwidth/bandwidth.c b/src/amok/Bandwidth/bandwidth.c index 74fff4e289..4d23b5c9ac 100644 --- a/src/amok/Bandwidth/bandwidth.c +++ b/src/amok/Bandwidth/bandwidth.c @@ -119,16 +119,15 @@ void amok_bw_exit(void) { * * Results are reported in last args, and sizes are in kb. */ -xbt_error_t amok_bw_test(gras_socket_t peer, - unsigned long int buf_size, - unsigned long int exp_size, - unsigned long int msg_size, - /*OUT*/ double *sec, double *bw) { +void amok_bw_test(gras_socket_t peer, + unsigned long int buf_size, + unsigned long int exp_size, + unsigned long int msg_size, + /*OUT*/ double *sec, double *bw) { /* Measurement sockets for the experiments */ gras_socket_t measMasterIn=NULL,measIn,measOut; int port; - xbt_error_t errcode; bw_request_t request,request_ack; xbt_ex_t e; @@ -181,16 +180,15 @@ xbt_error_t amok_bw_test(gras_socket_t peer, DEBUG1("Got ACK; conduct the experiment (msg_size=%ld)",request->msg_size); *sec=gras_os_time(); - gras_socket_meas_send(measOut,120,request->exp_size,request->msg_size); - gras_socket_meas_recv(measIn,120,1,1); - - /*catch - ERROR1("Error %s encountered while sending the BW experiment.", - xbt_error_name(errcode)); + TRY { + gras_socket_meas_send(measOut,120,request->exp_size,request->msg_size); + gras_socket_meas_recv(measIn,120,1,1); + } CATCH(e) { gras_socket_close(measOut); gras_socket_close(measMasterIn); gras_socket_close(measIn); - */ + RETHROW0("Unable to conduct the experiment: %s"); + } *sec = gras_os_time() - *sec; *bw = ((double)exp_size) / *sec; @@ -201,7 +199,6 @@ xbt_error_t amok_bw_test(gras_socket_t peer, gras_socket_close(measIn); gras_socket_close(measMasterIn); gras_socket_close(measOut); - return errcode; } @@ -311,12 +308,12 @@ int amok_bw_cb_bw_handshake(gras_socket_t expeditor, * * Results are reported in last args, and sizes are in kb. */ -xbt_error_t amok_bw_request(const char* from_name,unsigned int from_port, - const char* to_name,unsigned int to_port, - unsigned long int buf_size, - unsigned long int exp_size, - unsigned long int msg_size, - /*OUT*/ double *sec, double*bw) { +void amok_bw_request(const char* from_name,unsigned int from_port, + const char* to_name,unsigned int to_port, + unsigned long int buf_size, + unsigned long int exp_size, + unsigned long int msg_size, + /*OUT*/ double *sec, double*bw) { gras_socket_t sock; /* The request */ @@ -346,7 +343,6 @@ xbt_error_t amok_bw_request(const char* from_name,unsigned int from_port, gras_socket_close(sock); free(result); - return no_error; } int amok_bw_cb_bw_request(gras_socket_t expeditor, @@ -370,37 +366,6 @@ int amok_bw_cb_bw_request(gras_socket_t expeditor, free(result); return 1; - -#if 0 - char* to_name=gras_msg_ctn(msg,0,0,msgHost_t).host; - unsigned int to_port=gras_msg_ctn(msg,0,0,msgHost_t).port; - - unsigned int bufSize=gras_msg_ctn(msg,1,0,BwExp_t).bufSize; - unsigned int expSize=gras_msg_ctn(msg,1,0,BwExp_t).expSize; - unsigned int msgSize=gras_msg_ctn(msg,1,0,BwExp_t).msgSize; - /* our answer */ - msgError_t *error; - msgResult_t *res; - - if ((error->errcode=grasbw_test(to_name,to_port,bufSize,expSize,msgSize, - &(res[0].value),&(res[1].value) ))) { - fprintf(stderr, - "%s:%d:grasbw_cbRequest: Error %s encountered while doing the test\n", - __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, - res,2); - return 1; - } - res[0].timestamp = (unsigned int) gras_time(); - res[1].timestamp = (unsigned int) gras_time(); - gras_msg_new_and_send(msg->sock,GRASMSG_BW_RESULT,2, - error,1, - res,2); - gras_msg_free(msg); - return 1; -#endif } int amok_bw_cb_sat_start(gras_socket_t expeditor, @@ -413,338 +378,3 @@ int amok_bw_cb_sat_begin(gras_socket_t expeditor, CRITICAL0("amok_bw_cb_sat_begin: not implemented"); return 1; } -#if 0 -/* *************************************************************************** - * Link saturation - * ***************************************************************************/ - -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; - xbt_error_t errcode; - /* The request */ - SatExp_t *request; - msgHost_t *target; - /* answer */ - gras_msg_t *answer; - - 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__,xbt_error_name(errcode)); - return errcode; - } - if (!(request=(SatExp_t *)malloc(sizeof(SatExp_t))) || - !(target=(msgHost_t*)malloc(sizeof(msgHost_t)))) { - fprintf(stderr,"%s:%d:saturate_start(): Malloc error\n",__FILE__,__LINE__); - gras_sock_close(sock); - return malloc_error; - } - - request->timeout=timeout; - request->msgSize=msgSize; - - strcpy(target->host,to_name); - target->port=to_port; - - if ((errcode=gras_msg_new_and_send(sock,GRASMSG_SAT_START, 2, - target,1, - request,1))) { - fprintf(stderr,"%s:%d:saturate_start(): Error %s encountered while sending the request.\n", - __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__,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__,xbt_error_name(errcode),gras_msg_ctn(answer,0,0,msgError_t).errmsg); - gras_msg_free(answer); - gras_sock_close(sock); - return errcode; - } - - gras_msg_free(answer); - gras_sock_close(sock); - return no_error; -} - -int grasbw_cbSatStart(gras_msg_t *msg) { - gras_rawsock_t *raw; - gras_sock_t *sock; - xbt_error_t errcode; - double start; /* time to timeout */ - - /* specification of the test to run */ - char* to_name=gras_msg_ctn(msg,0,0,msgHost_t).host; - unsigned int to_port=gras_msg_ctn(msg,0,0,msgHost_t).port; - - unsigned int msgSize=gras_msg_ctn(msg,1,0,SatExp_t).msgSize; - unsigned int timeout=gras_msg_ctn(msg,1,0,SatExp_t).timeout; - unsigned int raw_port; - - /* The request */ - SatExp_t *request; - /* answer */ - gras_msg_t *answer; - - /* - fprintf(stderr,"grasbw_cbSatStart(sd=%p)\n",msg->sock); - fprintf(stderr,"(server=%d,raw=%d,fromPID=%d,toPID=%d,toHost=%p,toPort=%d,toChan=%d)\n", - msg->sock->server_sock,msg->sock->raw_sock,msg->sock->from_PID, - msg->sock->to_PID,msg->sock->to_host,msg->sock->to_port,msg->sock->to_chan); - */ - - /* 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", - 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"); - return 1; - } - if (!(request=(SatExp_t *)malloc(sizeof(SatExp_t)))) { - fprintf(stderr,"cbSatStart(): Malloc error\n"); - gras_sock_close(sock); - grasRepportError(msg->sock,GRASMSG_SAT_STARTED,1, - "cbSatStart: Severe error: Cannot send error status to requester!!\n", - malloc_error,"Cannot build request.\n"); - return 1; - } - - request->timeout=gras_msg_ctn(msg,1,0,SatExp_t).timeout; - request->msgSize=gras_msg_ctn(msg,1,0,SatExp_t).msgSize; - - 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", - 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"); - gras_sock_close(sock); - return 1; - } - - if ((errcode=gras_msg_wait(120,GRASMSG_SAT_BEGUN,&answer))) { - fprintf(stderr,"cbSatStart(): Error %s encountered while waiting for the ACK.\n", - xbt_error_name(errcode)); - gras_sock_close(sock); - - grasRepportError(msg->sock,GRASMSG_SAT_STARTED,1, - "cbSatStart: Severe error: Cannot send error status to requester!!\n", - errcode, - "Cannot receive the ACK.\n"); - return 1; - } - - if((errcode=gras_msg_ctn(answer,0,0,msgError_t).errcode)) { - fprintf(stderr,"cbSatStart(): Peer reported error %s (%s).\n", - 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", - errcode, - "Peer repported '%s'.\n",gras_msg_ctn(answer,0,0,msgError_t).errmsg); - gras_msg_free(answer); - gras_sock_close(sock); - return 1; - } - - raw_port=gras_msg_ctn(answer,1,0,SatExp_t).port; - - 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", - 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", - errcode,"Cannot open raw socket.\n"); - gras_sock_close(sock); - return 1; - } - - /* 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",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"); - gras_sock_close(sock); - gras_rawsock_close(raw); - return 1; - } - - grasRepportError(msg->sock,GRASMSG_SAT_STARTED,1, - "cbSatStart: Severe error: Cannot send error status to requester!!\n", - no_error,"Saturation started"); - gras_msg_free(answer); - gras_msg_free(msg); - - /* Do the saturation until we get a SAT_STOP message or until we timeout the whole XP*/ - start=gras_time(); - 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",xbt_error_name(errcode)); - /* our error message do not interess anyone. SAT_STOP will do nothing. */ - gras_sock_close(sock); - gras_rawsock_close(raw); - return 1; - } - } - if (gras_time()-start > timeout) { - fprintf(stderr,"The saturation experiment did timeout. Stop it NOW\n"); - gras_sock_close(sock); - gras_rawsock_close(raw); - return 1; - } - - /* Handle the SAT_STOP which broke the previous while */ - - if ((errcode=gras_msg_new_and_send(sock, GRASMSG_SAT_END,0))) { - fprintf(stderr,"cbSatStart(): Cannot tell peer to stop saturation\n"); - - grasRepportError(msg->sock,GRASMSG_SAT_STOPPED,1, - "cbSatStart: Severe error: Cannot send error status to requester!!\n", - errcode,"Sending SAT_END to peer failed.\n"); - gras_sock_close(sock); - gras_rawsock_close(raw); - return 1; - } - - if ((errcode=gras_msg_wait(60,GRASMSG_SAT_ENDED,&answer))) { - fprintf(stderr,"cbSatStart(): Peer didn't ACK the end\n"); - - grasRepportError(msg->sock,GRASMSG_SAT_STOPPED,1, - "cbSatStart: Severe error: Cannot send error status to requester!!\n", - errcode,"Receiving SAT_ENDED from peer failed.\n"); - gras_sock_close(sock); - gras_rawsock_close(raw); - return 1; - } - grasRepportError(msg->sock,GRASMSG_SAT_STOPPED,1, - "cbSatStart: Severe error: Cannot send error status to requester!!\n", - no_error,""); - - gras_sock_close(sock); - gras_rawsock_close(raw); - gras_msg_free(answer); - gras_msg_free(msg); - - return 1; -} - -int grasbw_cbSatBegin(gras_msg_t *msg) { - gras_rawsock_t *raw; - xbt_error_t errcode; - double start; /* timer */ - /* request */ - unsigned int msgSize=gras_msg_ctn(msg,0,0,SatExp_t).msgSize; - unsigned int timeout=gras_msg_ctn(msg,0,0,SatExp_t).timeout; - /* answer */ - SatExp_t *request; - msgError_t *error; - - if (!(request=(SatExp_t*)malloc(sizeof(SatExp_t))) || - !(error=(msgError_t *)malloc(sizeof(msgError_t)))) { - fprintf(stderr,"cbSatBegin(): Malloc error\n"); - grasRepportError(msg->sock,GRASMSG_SAT_BEGUN,2, - "cbSatBegin: Severe error: Cannot send error status to requester!!\n", - malloc_error,"Malloc error"); - return 1; - } - - if ((errcode=gras_rawsock_server_open(6666,8000,msgSize,&raw))) { - fprintf(stderr,"cbSatBegin(): Error %s encountered while opening a raw socket\n", - 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"); - return 1; - } - request->port=gras_rawsock_get_peer_port(raw); - request->msgSize=msgSize; - error->errcode=no_error; - error->errmsg[0]='\0'; - if ((errcode=gras_msg_new_and_send(msg->sock,GRASMSG_SAT_BEGUN,2, - error,1, - request,1))) { - fprintf(stderr,"cbSatBegin(): Error %s encountered while send ACK to peer\n", - xbt_error_name(errcode)); - return 1; - } - gras_msg_free(msg); - - start=gras_time(); - while (gras_msg_wait(0,GRASMSG_SAT_END,&msg)==timeout_error && - 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",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; - } - } - if (gras_time()-start > timeout) { - fprintf(stderr,"The saturation experiment did timeout. Stop it NOW.\n"); - gras_rawsock_close(raw); - return 1; - } - - grasRepportError(msg->sock,GRASMSG_SAT_ENDED,1, - "cbSatBegin: Cannot send SAT_ENDED.\n", - no_error,""); - gras_rawsock_close(raw); - gras_msg_free(msg); - return 1; -} - -xbt_error_t grasbw_saturate_stop(const char* from_name,unsigned int from_port, - const char* to_name,unsigned int to_port) { - 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", - 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", - 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", - 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", - xbt_error_name(errcode),gras_msg_ctn(answer,0,0,msgError_t).errmsg); - gras_msg_free(answer); - gras_sock_close(sock); - return errcode; - } - - gras_msg_free(answer); - gras_sock_close(sock); - - return no_error; -} -#endif diff --git a/src/amok/Bandwidth/bandwidth_private.h b/src/amok/Bandwidth/bandwidth_private.h index d9423456ec..04b7789b4e 100644 --- a/src/amok/Bandwidth/bandwidth_private.h +++ b/src/amok/Bandwidth/bandwidth_private.h @@ -31,7 +31,6 @@ typedef struct { * if err.msg != NULL, it wasn't sucessful. Check err.msg and err.code to see why. */ typedef struct { - s_amok_remoterr_t err; unsigned int timestamp; double sec; double bw; diff --git a/src/amok/base.c b/src/amok/base.c index 31bb98fc83..8fb4907344 100644 --- a/src/amok/base.c +++ b/src/amok/base.c @@ -12,64 +12,6 @@ XBT_LOG_NEW_SUBCATEGORY(amok,XBT_LOG_ROOT_CAT,"All AMOK categories"); -amok_remoterr_t amok_remoterr_new(xbt_error_t param_errcode, - const char* format,...) { - - amok_remoterr_t res; - - va_list ap; - va_start(ap,format); - res = amok_remoterr_new_va(param_errcode,format,ap); - va_end(ap); - return res; -} - -amok_remoterr_t amok_remoterr_new_va(xbt_error_t param_errcode, - const char* format,va_list ap) { - amok_remoterr_t res=xbt_new(s_amok_remoterr_t,1); - res->code=param_errcode; - if (format) { - res->msg=(char*)xbt_malloc(1024); - vsnprintf(res->msg,1024,format,ap); - } else { - res->msg = NULL; - } - - return res; -} - -void amok_remoterr_free(amok_remoterr_t *err) { - if (err && *err) { - if ((*err)->msg) free((*err)->msg); - free(*err); - err=NULL; - } -} - - -void -amok_repport_error (gras_socket_t sock, gras_msgtype_t msgtype, - xbt_error_t param_errcode, const char* format,...) { - amok_remoterr_t error; - va_list ap; - - error=xbt_new(s_amok_remoterr_t,1); - error->code=param_errcode; - error->msg=(char*)xbt_malloc(1024); /* FIXME */ - va_start(ap,format); - vsnprintf(error->msg,1024,format,ap); - va_end(ap); - - gras_msg_send(sock,msgtype,error); - /* FIXME: error handling while error reporting :-/ - if (errcode != no_error) { - CRITICAL4("Error '%s' while reporting error '%s' to %s:%d", - xbt_error_name(errcode),error->msg, - gras_socket_peer_name(sock),gras_socket_peer_port(sock) ); - } - */ -} - void amok_base_init(void) { gras_datadesc_type_t host_desc, remoterr_desc; diff --git a/src/gras/DataDesc/datadesc_interface.h b/src/gras/DataDesc/datadesc_interface.h index bef1819afc..9cf3c3e10e 100644 --- a/src/gras/DataDesc/datadesc_interface.h +++ b/src/gras/DataDesc/datadesc_interface.h @@ -28,15 +28,15 @@ gras_datadesc_type_cmp(const gras_datadesc_type_t d1, /* Access function */ int gras_datadesc_size(gras_datadesc_type_t type); /* Described data exchanges: direct use */ -xbt_error_t gras_datadesc_cpy(gras_datadesc_type_t type, void *src, void **dst); +void gras_datadesc_cpy(gras_datadesc_type_t type, void *src, void **dst); void gras_datadesc_send(gras_socket_t sock, gras_datadesc_type_t type, void *src); void gras_datadesc_recv(gras_socket_t sock, gras_datadesc_type_t type, int r_arch, void *dst); -/* Described data exchanges: IDL compilation */ -xbt_error_t gras_datadesc_gen_cpy(gras_datadesc_type_t type, void *src, void **dst); -xbt_error_t gras_datadesc_gen_send(gras_socket_t sock, gras_datadesc_type_t type, void *src); -xbt_error_t gras_datadesc_gen_recv(gras_socket_t sock, gras_datadesc_type_t type, +/* Described data exchanges: IDL compilation FIXME: not implemented*/ +void gras_datadesc_gen_cpy(gras_datadesc_type_t type, void *src, void **dst); +void gras_datadesc_gen_send(gras_socket_t sock, gras_datadesc_type_t type, void *src); +void gras_datadesc_gen_recv(gras_socket_t sock, gras_datadesc_type_t type, int r_arch, void *dst); diff --git a/src/gras/DataDesc/datadesc_private.h b/src/gras/DataDesc/datadesc_private.h index 1d842fca93..f6b43c5a0c 100644 --- a/src/gras/DataDesc/datadesc_private.h +++ b/src/gras/DataDesc/datadesc_private.h @@ -16,7 +16,6 @@ #include "xbt/sysdep.h" #include "xbt/log.h" -#include "xbt/error.h" #include "xbt/dynar.h" #include "xbt/dict.h" #include "xbt/set.h" @@ -253,7 +252,7 @@ void gras_cbps_free(gras_cbps_t *state); /*************** * Convertions * ***************/ -xbt_error_t +void gras_dd_convert_elm(gras_datadesc_type_t type, int count, int r_arch, void *src, void *dst); diff --git a/src/gras/DataDesc/ddt_convert.c b/src/gras/DataDesc/ddt_convert.c index 142be9df7e..5f1842e69c 100644 --- a/src/gras/DataDesc/ddt_convert.c +++ b/src/gras/DataDesc/ddt_convert.c @@ -86,7 +86,7 @@ gras_dd_reverse_bytes(void *to, * 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. */ -xbt_error_t +void gras_dd_convert_elm(gras_datadesc_type_t type, int count, int r_arch, void *src, void *dst) { @@ -221,7 +221,6 @@ gras_dd_convert_elm(gras_datadesc_type_t type, int count, } } - return no_error; } static void diff --git a/src/gras/DataDesc/ddt_exchange.c b/src/gras/DataDesc/ddt_exchange.c index 111a6748d4..8f57a97391 100644 --- a/src/gras/DataDesc/ddt_exchange.c +++ b/src/gras/DataDesc/ddt_exchange.c @@ -25,7 +25,7 @@ static gras_datadesc_type_t pointer_type = NULL; static _XBT_INLINE void gras_dd_send_int(gras_socket_t sock, int i); static _XBT_INLINE void gras_dd_recv_int(gras_socket_t sock, int r_arch, int *i); -static _XBT_INLINE xbt_error_t +static _XBT_INLINE void gras_dd_alloc_ref(xbt_dict_t refs, long int size, char **r_ref, long int r_len, char **l_ref, int detect_cycle); @@ -86,7 +86,7 @@ gras_dd_is_r_null(char **r_ptr, long int length) { return 1; } -static _XBT_INLINE xbt_error_t +static _XBT_INLINE void gras_dd_alloc_ref(xbt_dict_t refs, long int size, char **r_ref, @@ -113,7 +113,6 @@ gras_dd_alloc_ref(xbt_dict_t refs, if (detect_cycle) xbt_dict_set_ext(refs,(const char *) r_ref, r_len, ptr, free); } - return no_error; } /** @@ -123,9 +122,9 @@ gras_dd_alloc_ref(xbt_dict_t refs, * to a new location, and store a pointer to it in dst. * */ -xbt_error_t gras_datadesc_cpy(gras_datadesc_type_t type, - void *src, - void **dst) { +void gras_datadesc_cpy(gras_datadesc_type_t type, + void *src, + void **dst) { THROW_UNIMPLEMENTED; } @@ -688,556 +687,3 @@ gras_datadesc_recv(gras_socket_t sock, } } -#if 0 -/*** - *** IDL compiling functions - ***/ - -#define gras_datadesc_send_rec foo /* Just to make sure the copypast was ok */ -#define gras_datadesc_send foo /* Just to make sure the copypast was ok */ -#define gras_datadesc_recv_rec foo /* Just to make sure the copypast was ok */ -#define gras_datadesc_recv foo /* Just to make sure the copypast was ok */ - -static xbt_error_t -gras_datadesc_gen_send_rec(gras_socket_t sock, - gras_cbps_t state, - xbt_dict_t refs, - gras_datadesc_type_t type, - char *data, - int detect_cycle) { - - xbt_error_t errcode; - int cpt; - gras_datadesc_type_t sub_type; /* type on which we recurse */ - - printf(" VERB2(\"Send a %s (%s)\");\n", - type->name, gras_datadesc_cat_names[type->category_code]); - - xbt_assert0(!type->send, "Callbacks not implemented in IDL compiler"); - - switch (type->category_code) { - case e_gras_datadesc_type_cat_scalar: - printf(" TRYOLD(gras_trp_chunk_send(sock, data, %lu));\n",type->size[GRAS_THISARCH]); - break; - - case e_gras_datadesc_type_cat_struct: { - gras_dd_cat_struct_t struct_data; - gras_dd_cat_field_t field; - char *field_data; - - struct_data = type->category.struct_data; - xbt_assert1(struct_data.closed, - "Please call gras_datadesc_declare_struct_close on %s before sending it", - type->name); - printf(" VERB1(\">> Send all fields of the structure %s\");\n",type->name); - xbt_dynar_foreach(struct_data.fields, cpt, field) { - field_data = data; - field_data += field->offset[GRAS_THISARCH]; - - sub_type = field->type; - - xbt_assert0(!field->send, "Callbacks not implemented in IDL compiler"); - - printf(" VERB1(\"Send field %s\");\n",field->name); - printf(" data += %lu;\n",field->offset[GRAS_THISARCH]); - TRYOLD(gras_datadesc_gen_send_rec(sock,state,refs,sub_type, field_data, - detect_cycle || sub_type->cycle)); - printf(" data -= %lu;\n",field->offset[GRAS_THISARCH]); - - xbt_assert0(!field->recv, "Callbacks not implemented in IDL compiler"); - } - printf(" VERB1(\"<< Sent all fields of the structure %s\"", type->name); - - break; - } - - case e_gras_datadesc_type_cat_union: { - gras_dd_cat_union_t union_data; - gras_dd_cat_field_t field=NULL; - int field_num; - - union_data = type->category.union_data; - - xbt_assert1(union_data.closed, - "Please call gras_datadesc_declare_union_close on %s before sending it", - type->name); - /* retrieve the field number */ - printf(" field_num = union_data.selector(state, data);\n"); - - printf(" xbt_assert0(field_num > 0,\n"); - printf(" \"union field selector of %s gave a negative value\");\n",type->name); - - printf(" xbt_assert3(field_num < xbt_dynar_length(union_data.fields),\n"); - printf(" \"union field selector of %s returned %%d but there is only %lu fields\",field_num);\n", - type->name, xbt_dynar_length(union_data.fields)); - - /* Send the field number */ - printf("TRYOLD(gras_dd_send_int(sock, field_num));\n"); - - /* Send the content */ - field = xbt_dynar_get_as(union_data.fields, field_num, gras_dd_cat_field_t); - sub_type = field->type; - - if (field->send) - field->send(state,data); - - TRYOLD(gras_datadesc_gen_send_rec(sock,state,refs, sub_type, data, - detect_cycle || sub_type->cycle)); - - break; - } - - case e_gras_datadesc_type_cat_ref: { - gras_dd_cat_ref_t ref_data; - - void **ref=(void**)data; - void *dummy; - - ref_data = type->category.ref_data; - - /* Detect the referenced type and send it to peer if needed */ - sub_type = ref_data.type; - if (sub_type == NULL) { - sub_type = (*ref_data.selector)(state,data); - TRYOLD(gras_dd_send_int(sock, sub_type->code)); - } - - /* Send the actual value of the pointer for cycle handling */ - if (!pointer_type) { - pointer_type = gras_datadesc_by_name("data pointer"); - xbt_assert(pointer_type); - } - - TRYOLD(gras_trp_chunk_send(sock, (char*)data, - pointer_type->size[GRAS_THISARCH])); - - /* Send the pointed data only if not already sent */ - if (*(void**)data == NULL) { - VERB0("Not sending NULL referenced data"); - break; - } - errcode = detect_cycle - ? 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) - xbt_dict_set_ext(refs, (char*)ref, sizeof(void*), ref, NULL); - TRYOLD(gras_datadesc_gen_send_rec(sock,state,refs, sub_type, *ref, - detect_cycle || sub_type->cycle)); - - } else if (errcode == no_error) { - VERB1("Not sending data referenced at %p (already done)", (void*)*ref); - } else { - return errcode; - } - - break; - } - - case e_gras_datadesc_type_cat_array: { - gras_dd_cat_array_t array_data; - long int count; - char *ptr=data; - long int elm_size; - - array_data = type->category.array_data; - - /* determine and send the element count */ - count = array_data.fixed_size; - if (count == 0) { - count = array_data.dynamic_size(state,data); - xbt_assert1(count >=0, - "Invalid (negative) array size for type %s",type->name); - TRYOLD(gras_dd_send_int(sock, count)); - } - - /* send the content */ - sub_type = array_data.type; - elm_size = sub_type->aligned_size[GRAS_THISARCH]; - if (sub_type->category_code == e_gras_datadesc_type_cat_scalar) { - VERB1("Array of %ld scalars, send it in one shot",count); - TRYOLD(gras_trp_chunk_send(sock, data, - sub_type->aligned_size[GRAS_THISARCH] * count)); - } else if (sub_type->category_code == e_gras_datadesc_type_cat_array && - sub_type->category.array_data.fixed_size > 0 && - sub_type->category.array_data.type->category_code == e_gras_datadesc_type_cat_scalar) { - - VERB1("Array of %ld fixed array of scalars, send it in one shot",count); - TRYOLD(gras_trp_chunk_send(sock, data, - sub_type->category.array_data.type->aligned_size[GRAS_THISARCH] - * count * sub_type->category.array_data.fixed_size)); - - } else { - for (cpt=0; cptcycle)); - ptr += elm_size; - } - } - break; - } - - default: - xbt_assert0(0, "Invalid type"); - } - - return no_error; -} - -/** - * gras_datadesc_gen_send: - * - * Copy the data pointed by src and described by type to the socket - * - */ -xbt_error_t gras_datadesc_gen_send(gras_socket_t sock, - gras_datadesc_type_t type, - void *src) { - - xbt_error_t errcode; - gras_cbps_t state; - xbt_dict_t refs; /* all references already sent */ - - refs = xbt_dict_new(); - state = gras_cbps_new(); - - printf("xbt_error_t gras_%s_send(gras_socket_t sock,void *dst){\n", - type->name); - errcode = gras_datadesc_gen_send_rec(sock,state,refs,type,(char*)src, - detect_cycle || sub_type->cycle); - printf("}\n"); - - xbt_dict_free(&refs); - gras_cbps_free(&state); - - return errcode; -} - -/** - * gras_datadesc_gen_recv_rec: - * - * Do the data reception job recursively. - * - * subsize used only to deal with vicious case of reference to dynamic array. - * This size is needed at the reference reception level (to allocate enough - * space) and at the array reception level (to fill enough room). - * - * 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 ;) - */ -static xbt_error_t -gras_datadesc_gen_recv_rec(gras_socket_t sock, - gras_cbps_t state, - xbt_dict_t refs, - gras_datadesc_type_t type, - int r_arch, - char **r_data, - long int r_lgr, - char *l_data, - int subsize, - int detect_cycle) { - - xbt_error_t errcode; - int cpt; - gras_datadesc_type_t sub_type; - - VERB2("Recv a %s @%p", type->name, (void*)l_data); - xbt_assert(l_data); - - switch (type->category_code) { - case e_gras_datadesc_type_cat_scalar: - if (type->size[GRAS_THISARCH] == type->size[r_arch]) { - TRYOLD(gras_trp_chunk_recv(sock, (char*)l_data, type->size[r_arch])); - if (r_arch != GRAS_THISARCH) - TRYOLD(gras_dd_convert_elm(type,1,r_arch, l_data,l_data)); - } else { - void *ptr = xbt_malloc(type->size[r_arch]); - - TRYOLD(gras_trp_chunk_recv(sock, (char*)ptr, type->size[r_arch])); - if (r_arch != GRAS_THISARCH) - TRYOLD(gras_dd_convert_elm(type,1,r_arch, ptr,l_data)); - free(ptr); - } - break; - - case e_gras_datadesc_type_cat_struct: { - gras_dd_cat_struct_t struct_data; - gras_dd_cat_field_t field; - - struct_data = type->category.struct_data; - - 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); - xbt_dynar_foreach(struct_data.fields, cpt, field) { - char *field_data = l_data + field->offset[GRAS_THISARCH]; - - sub_type = field->type; - - TRYOLD(gras_datadesc_gen_recv_rec(sock,state,refs, sub_type, - r_arch,NULL,0, - field_data,-1, - detect_cycle || sub_type->cycle)); - if (field->recv) - field->recv(type,state,data); - - } - VERB1("<< Received all fields of the structure %s", type->name); - - break; - } - - case e_gras_datadesc_type_cat_union: { - gras_dd_cat_union_t union_data; - gras_dd_cat_field_t field=NULL; - int field_num; - - union_data = type->category.union_data; - - xbt_assert1(union_data.closed, - "Please call gras_datadesc_declare_union_close on %s before receiving it", - type->name); - /* retrieve the field number */ - TRYOLD(gras_dd_recv_int(sock, r_arch, &field_num)); - if (field_num < 0) - RAISE1(mismatch_error, - "Received union field for %s is negative", type->name); - 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, xbt_dynar_length(union_data.fields)); - - /* Recv the content */ - field = xbt_dynar_get_as(union_data.fields, field_num, gras_dd_cat_field_t); - sub_type = field->type; - - TRYOLD(gras_datadesc_gen_recv_rec(sock,state,refs, sub_type, - r_arch,NULL,0, - l_data,-1, - detect_cycle || sub_type->cycle)); - if (field->recv) - field->recv(type,state,data); - - break; - } - - case e_gras_datadesc_type_cat_ref: { - char **r_ref = NULL; - char **l_ref = NULL; - gras_dd_cat_ref_t ref_data; - - ref_data = type->category.ref_data; - - /* Get the referenced type locally or from peer */ - sub_type = ref_data.type; - if (sub_type == NULL) { - int ref_code; - TRYOLD(gras_dd_recv_int(sock, r_arch, &ref_code)); - TRYOLD(gras_datadesc_by_id(ref_code, &sub_type)); - } - - /* Get the actual value of the pointer for cycle handling */ - if (!pointer_type) { - pointer_type = gras_datadesc_by_name("data pointer"); - xbt_assert(pointer_type); - } - - r_ref = xbt_malloc(pointer_type->size[r_arch]); - - TRYOLD(gras_trp_chunk_recv(sock, (char*)r_ref, - pointer_type->size[r_arch])); - - /* Receive the pointed data only if not already sent */ - if (gras_dd_is_r_null(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; - free(r_ref); - break; - } - - errcode = detect_cycle - ? xbt_dict_get_ext(refs, - (char*)r_ref, pointer_type->size[r_arch], - (void**)&l_ref) - : mismatch_error; - - if (errcode == mismatch_error) { - int subsubcount = 0; - void *l_referenced=NULL; - - VERB2("Receiving a ref to '%s', remotely @%p", - sub_type->name, *(void**)r_ref); - if (sub_type->category_code == e_gras_datadesc_type_cat_array) { - /* Damn. Reference to a dynamic array. Allocating the size for it - is more complicated */ - gras_dd_cat_array_t array_data = sub_type->category.array_data; - gras_datadesc_type_t subsub_type; - - subsubcount = array_data.fixed_size; - if (subsubcount == 0) - TRYOLD(gras_dd_recv_int(sock, r_arch, &subsubcount)); - - subsub_type = array_data.type; - - - TRYOLD(gras_dd_alloc_ref(refs, - subsub_type->size[GRAS_THISARCH] * subsubcount, - r_ref,pointer_type->size[r_arch], - (char**)&l_referenced, - detect_cycle)); - } else { - TRYOLD(gras_dd_alloc_ref(refs,sub_type->size[GRAS_THISARCH], - r_ref,pointer_type->size[r_arch], - (char**)&l_referenced, - detect_cycle)); - } - - TRYOLD(gras_datadesc_gen_recv_rec(sock,state,refs, sub_type, - r_arch,r_ref,pointer_type->size[r_arch], - (char*)l_referenced, subsubcount, - detect_cycle || sub_type->cycle)); - - *(void**)l_data=l_referenced; - VERB3("'%s' remotely referenced at %p locally at %p", - sub_type->name, *(void**)r_ref, l_referenced); - - } else if (errcode == no_error) { - VERB2("NOT receiving data remotely referenced @%p (already done, @%p here)", - *(void**)r_ref, *(void**)l_ref); - - *(void**)l_data=*l_ref; - - } else { - return errcode; - } - free(r_ref); - break; - } - - case e_gras_datadesc_type_cat_array: { - gras_dd_cat_array_t array_data; - int count; - char *ptr; - long int elm_size; - - array_data = type->category.array_data; - /* determine element count locally, or from caller, or from peer */ - count = array_data.fixed_size; - if (count == 0) - count = subsize; - if (count == 0) - TRYOLD(gras_dd_recv_int(sock, r_arch, &count)); - if (count == 0) - RAISE1(mismatch_error, - "Invalid (=0) array size for type %s",type->name); - - /* receive the content */ - sub_type = array_data.type; - if (sub_type->category_code == e_gras_datadesc_type_cat_scalar) { - VERB1("Array of %d scalars, get it in one shoot", count); - if (sub_type->aligned_size[GRAS_THISARCH] >= - sub_type->aligned_size[r_arch]) { - TRYOLD(gras_trp_chunk_recv(sock, (char*)l_data, - sub_type->aligned_size[r_arch] * count)); - if (r_arch != GRAS_THISARCH) - TRYOLD(gras_dd_convert_elm(sub_type,count,r_arch, l_data,l_data)); - } else { - ptr = xbt_malloc(sub_type->aligned_size[r_arch] * count); - - TRYOLD(gras_trp_chunk_recv(sock, (char*)ptr, - sub_type->size[r_arch] * count)); - if (r_arch != GRAS_THISARCH) - TRYOLD(gras_dd_convert_elm(sub_type,count,r_arch, ptr,l_data)); - free(ptr); - } - } else if (sub_type->category_code == e_gras_datadesc_type_cat_array && - sub_type->category.array_data.fixed_size > 0 && - sub_type->category.array_data.type->category_code == e_gras_datadesc_type_cat_scalar) { - gras_datadesc_type_t subsub_type; - array_data = sub_type->category.array_data; - subsub_type = array_data.type; - - VERB1("Array of %d fixed array of scalars, get it in one shot",count); - if (subsub_type->aligned_size[GRAS_THISARCH] >= - subsub_type->aligned_size[r_arch]) { - TRYOLD(gras_trp_chunk_recv(sock, (char*)l_data, - subsub_type->aligned_size[r_arch] * count * - array_data.fixed_size)); - if (r_arch != GRAS_THISARCH) - TRYOLD(gras_dd_convert_elm(subsub_type,count*array_data.fixed_size,r_arch, l_data,l_data)); - } else { - ptr = xbt_malloc(subsub_type->aligned_size[r_arch] * count*array_data.fixed_size); - - TRYOLD(gras_trp_chunk_recv(sock, (char*)ptr, - subsub_type->size[r_arch] * count*array_data.fixed_size)); - if (r_arch != GRAS_THISARCH) - TRYOLD(gras_dd_convert_elm(subsub_type,count*array_data.fixed_size,r_arch, ptr,l_data)); - free(ptr); - } - - - } else { - /* not scalar content, get it recursively (may contain pointers) */ - elm_size = sub_type->aligned_size[GRAS_THISARCH]; - VERB2("Receive a %d-long array of %s",count, sub_type->name); - - ptr = l_data; - for (cpt=0; cptcycle)); - - ptr += elm_size; - } - } - break; - } - - default: - xbt_assert0(0, "Invalid type"); - } - - if (type->recv) - type->recv(type,state,l_data); - - return no_error; -} - -/** - * gras_datadesc_gen_recv: - * - * Get an instance of the datatype described by @type from the @socket, - * and store a pointer to it in @dst - * - */ -xbt_error_t -gras_datadesc_gen_recv(gras_socket_t sock, - gras_datadesc_type_t type, - int r_arch, - void *dst) { - - xbt_error_t errcode; - gras_cbps_t state; /* callback persistent state */ - xbt_dict_t refs; /* all references already sent */ - - refs = xbt_dict_new(); - state = gras_cbps_new(); - - printf("xbt_error_t gras_%s_recv(gras_socket_t sock,void *dst){\n", - type->name); - - errcode = gras_datadesc_gen_recv_rec(sock, state, refs, type, - r_arch, NULL, 0, - (char *) dst,-1, - sub_type->cycle); - - printf("}\n"); - xbt_dict_free(&refs); - gras_cbps_free(&state); - - return errcode; -} -#endif diff --git a/src/gras/Msg/msg_interface.h b/src/gras/Msg/msg_interface.h index b16ed5a3d6..1f8f3b0183 100644 --- a/src/gras/Msg/msg_interface.h +++ b/src/gras/Msg/msg_interface.h @@ -32,9 +32,9 @@ typedef struct { } s_gras_msg_procdata_t,*gras_msg_procdata_t; -xbt_error_t gras_msg_send_namev(gras_socket_t sock, - const char *namev, - void *payload); +void gras_msg_send_namev(gras_socket_t sock, + const char *namev, + void *payload); #define GRAS_PROTOCOL_VERSION '\0'; diff --git a/src/gras/Msg/msg_private.h b/src/gras/Msg/msg_private.h index 782bdcf805..7923f49504 100644 --- a/src/gras/Msg/msg_private.h +++ b/src/gras/Msg/msg_private.h @@ -16,7 +16,6 @@ #include "xbt/sysdep.h" #include "xbt/log.h" -#include "xbt/error.h" #include "xbt/dynar.h" #include "xbt/set.h" #include "gras/transport.h" diff --git a/src/gras/Transport/transport_plugin_sg.c b/src/gras/Transport/transport_plugin_sg.c index f3243a25da..e777b589a7 100644 --- a/src/gras/Transport/transport_plugin_sg.c +++ b/src/gras/Transport/transport_plugin_sg.c @@ -303,76 +303,3 @@ void gras_trp_sg_chunk_recv(gras_socket_t sock, XBT_OUT; } -#if 0 -/* Data exchange over measurement sockets */ -xbt_error_t gras_socket_meas_exchange(gras_socket_t peer, - int sender, - unsigned int timeout, - unsigned long int expSize, - unsigned long int msgSize) { - unsigned int bytesTotal; - static unsigned int count=0; - m_task_t task=NULL; - char name[256]; - gras_trp_sg_sock_data_t *sock_data = (gras_trp_sg_sock_data_t *)peer->data; - - gras_trp_procdata_t pd=(gras_trp_procdata_t)gras_libdata_get("gras_trp"); - double startTime; - - startTime=gras_os_time(); /* used only in sender mode */ - - for(bytesTotal = 0; bytesTotal < expSize; bytesTotal += msgSize) { - - if (sender) { - - sprintf(name,"meas data[%d]",count++); - - task=MSG_task_create(name,0,((double)msgSize)/(1024.0*1024.0),NULL); - - DEBUG5("%f:%s: gras_socket_meas_send(%f %s -> %s) BEGIN", - gras_os_time(), MSG_process_get_name(MSG_process_self()), - ((double)msgSize)/(1024.0*1024.0), - MSG_host_get_name( MSG_host_self()), peer->peer_name); - - if (MSG_task_put(task, sock_data->to_host,sock_data->to_chan) != MSG_OK) - RAISE0(system_error,"Problem during the MSG_task_put()"); - - DEBUG5("%f:%s: gras_socket_meas_send(%f %s -> %s) END", - gras_os_time(), MSG_process_get_name(MSG_process_self()), - ((double)msgSize)/(1024.0*1024.0), - MSG_host_get_name( MSG_host_self()), peer->peer_name); - - } else { /* we are receiver, simulate a select */ - - task=NULL; - DEBUG2("%f:%s: gras_socket_meas_recv() BEGIN\n", - gras_os_time(), MSG_process_get_name(MSG_process_self())); - do { - if (MSG_task_Iprobe((m_channel_t) pd->measChan)) { - if (MSG_task_get(&task, (m_channel_t) pd->measChan) != MSG_OK) { - fprintf(stderr,"GRAS: Error in MSG_task_get()\n"); - return unknown_error; - } - - if (MSG_task_destroy(task) != MSG_OK) { - fprintf(stderr,"GRAS: Error in MSG_task_destroy()\n"); - return unknown_error; - } - - DEBUG2("%f:%s: gras_socket_meas_recv() END\n", - gras_os_time(), MSG_process_get_name(MSG_process_self())); - break; - } else { - MSG_process_sleep(0.0001); - } - - } while (gras_os_time() - startTime < timeout); - - if (gras_os_time() - startTime > timeout) - return timeout_error; - } /* receiver part */ - } /* foreach msg */ - - return no_error; -} -#endif diff --git a/src/gras/Transport/transport_private.h b/src/gras/Transport/transport_private.h index 6d3857f2e6..0a8d031c6c 100644 --- a/src/gras/Transport/transport_private.h +++ b/src/gras/Transport/transport_private.h @@ -14,7 +14,6 @@ #include "xbt/sysdep.h" #include "xbt/log.h" -#include "xbt/error.h" #include "xbt/dynar.h" #include "xbt/dict.h" @@ -87,12 +86,13 @@ void gras_trp_buf_init_sock(gras_socket_t sock); /* Data exchange over measurement sockets */ /* FIXME: KILLME */ -xbt_error_t gras_socket_meas_exchange(gras_socket_t peer, +/* +void gras_socket_meas_exchange(gras_socket_t peer, int sender, unsigned int timeout, unsigned long int expSize, unsigned long int msgSize); - +*/ xbt_dynar_t gras_socketset_get(void); /* FIXME:KILLME */ #endif /* GRAS_TRP_PRIVATE_H */ diff --git a/src/gras/Virtu/process.c b/src/gras/Virtu/process.c index e61fa71e2d..d38324d9b2 100644 --- a/src/gras/Virtu/process.c +++ b/src/gras/Virtu/process.c @@ -10,7 +10,6 @@ #include "xbt/ex.h" #include "xbt/sysdep.h" #include "xbt/log.h" -#include "xbt/error.h" #include "gras/transport.h" #include "gras/datadesc.h" #include "gras/messages.h" diff --git a/src/gras/Virtu/virtu_interface.h b/src/gras/Virtu/virtu_interface.h index 178a39b424..0f79d15543 100644 --- a/src/gras/Virtu/virtu_interface.h +++ b/src/gras/Virtu/virtu_interface.h @@ -14,7 +14,6 @@ #include "xbt/sysdep.h" #include "xbt/log.h" -#include "xbt/error.h" #include "xbt/dynar.h" #include "xbt/dict.h" #include "gras/virtu.h" diff --git a/src/msg/deployment.c b/src/msg/deployment.c index 520b2b8478..3910e4944f 100644 --- a/src/msg/deployment.c +++ b/src/msg/deployment.c @@ -5,9 +5,9 @@ /* 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. */ -#include"private.h" -#include"xbt/sysdep.h" -#include "xbt/error.h" +#include "private.h" +#include "xbt/sysdep.h" +#include "xbt/log.h" #include "surf/surf_parse.h" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(deployment, msg, "Logging specific to MSG (environment)"); diff --git a/src/msg/environment.c b/src/msg/environment.c index a107bb1da6..4ed51ca99a 100644 --- a/src/msg/environment.c +++ b/src/msg/environment.c @@ -5,9 +5,9 @@ /* 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. */ -#include"private.h" -#include"xbt/sysdep.h" -#include "xbt/error.h" +#include "private.h" +#include "xbt/sysdep.h" +#include "xbt/log.h" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(environment, msg, "Logging specific to MSG (environment)"); diff --git a/src/msg/global.c b/src/msg/global.c index 353a8c8900..f1633a90b0 100644 --- a/src/msg/global.c +++ b/src/msg/global.c @@ -5,9 +5,9 @@ /* 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. */ -#include"private.h" -#include"xbt/sysdep.h" -#include "xbt/error.h" +#include "private.h" +#include "xbt/sysdep.h" +#include "xbt/log.h" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(global, msg, "Logging specific to MSG (global)"); diff --git a/src/msg/gos.c b/src/msg/gos.c index c57e07869e..c7e34c24a7 100644 --- a/src/msg/gos.c +++ b/src/msg/gos.c @@ -5,9 +5,9 @@ /* 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. */ -#include"private.h" -#include"xbt/sysdep.h" -#include "xbt/error.h" +#include "private.h" +#include "xbt/sysdep.h" +#include "xbt/log.h" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(gos, msg, "Logging specific to MSG (gos)"); diff --git a/src/msg/host.c b/src/msg/host.c index 21f3c09868..17249ba62d 100644 --- a/src/msg/host.c +++ b/src/msg/host.c @@ -5,9 +5,9 @@ /* 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. */ -#include"private.h" -#include"xbt/sysdep.h" -#include "xbt/error.h" +#include "private.h" +#include "xbt/sysdep.h" +#include "xbt/log.h" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(host, msg, "Logging specific to MSG (host)"); diff --git a/src/msg/m_process.c b/src/msg/m_process.c index aea547cfdd..cf14c1358f 100644 --- a/src/msg/m_process.c +++ b/src/msg/m_process.c @@ -5,9 +5,9 @@ /* 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. */ -#include"private.h" -#include"xbt/sysdep.h" -#include "xbt/error.h" +#include "private.h" +#include "xbt/sysdep.h" +#include "xbt/log.h" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(m_process, msg, "Logging specific to MSG (process)"); diff --git a/src/msg/msg_config.c b/src/msg/msg_config.c index 0e895027fb..f7cd0942dc 100644 --- a/src/msg/msg_config.c +++ b/src/msg/msg_config.c @@ -10,7 +10,7 @@ #include "private.h" #include "xbt/sysdep.h" -#include "xbt/error.h" +#include "xbt/log.h" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_cfg, msg, "Configuration support in \ref MSG_API"); diff --git a/src/msg/task.c b/src/msg/task.c index 22a8717f74..75b98041a7 100644 --- a/src/msg/task.c +++ b/src/msg/task.c @@ -5,9 +5,9 @@ /* 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. */ -#include"private.h" -#include"xbt/sysdep.h" -#include "xbt/error.h" +#include "private.h" +#include "xbt/sysdep.h" +#include "xbt/log.h" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(task, msg, "Logging specific to MSG (task)"); diff --git a/src/surf/maxmin.c b/src/surf/maxmin.c index d26f1de265..c962d74965 100644 --- a/src/surf/maxmin.c +++ b/src/surf/maxmin.c @@ -7,7 +7,7 @@ #include "xbt/sysdep.h" -#include "xbt/error.h" +#include "xbt/log.h" #include "maxmin_private.h" #include XBT_LOG_NEW_DEFAULT_SUBCATEGORY(maxmin, surf, diff --git a/src/surf/surf_parse.c b/src/surf/surf_parse.c index 776cb64109..b8101062bd 100644 --- a/src/surf/surf_parse.c +++ b/src/surf/surf_parse.c @@ -6,7 +6,7 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "xbt/misc.h" -#include "xbt/error.h" +#include "xbt/log.h" #include "surf/surf_parse.h" #include "surf/surf_private.h" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(parse, surf ,"Logging specific to the SURF module"); diff --git a/src/surf/trace_mgr.c b/src/surf/trace_mgr.c index 25545f92d3..b5ddf8526e 100644 --- a/src/surf/trace_mgr.c +++ b/src/surf/trace_mgr.c @@ -6,7 +6,7 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "xbt/sysdep.h" -#include "xbt/error.h" +#include "xbt/log.h" #include "xbt/dict.h" #include "trace_mgr_private.h" #include "surf_private.h" diff --git a/src/xbt/context.c b/src/xbt/context.c index c2426085df..0d3f5876e9 100644 --- a/src/xbt/context.c +++ b/src/xbt/context.c @@ -11,7 +11,7 @@ #include "portable.h" #include "context_private.h" -#include "xbt/error.h" +#include "xbt/log.h" #include "xbt/dynar.h" #include "gras_config.h" diff --git a/src/xbt/dict.c b/src/xbt/dict.c index b10cab7431..37bc17511d 100644 --- a/src/xbt/dict.c +++ b/src/xbt/dict.c @@ -100,10 +100,9 @@ xbt_dict_set(xbt_dict_t dict, * \param dict the dealer of data * \param key the key to find data * \param key_len the size of the \a key - * \param data the data that we are looking for - * \return xbt_error + * \returns the data that we are looking for * - * Search the given \a key. mismatch_error when not found. + * Search the given \a key. throws not_found_error when not found. */ void * xbt_dict_get_ext(xbt_dict_t dict, @@ -120,8 +119,7 @@ xbt_dict_get_ext(xbt_dict_t dict, * * \param dict the dealer of data * \param key the key to find data - * \param data the data that we are looking for - * \return xbt_error + * \returns the data that we are looking for * * Search the given \a key. THROWs mismatch_error when not found. * Check xbt_dict_get_or_null() for a version returning NULL without exception when @@ -161,9 +159,9 @@ xbt_dict_get_or_null(xbt_dict_t dict, * \param dict the trash can * \param key the key of the data to be removed * \param key_len the size of the \a key - * \return xbt_error_t + * * - * Remove the entry associated with the given \a key + * Remove the entry associated with the given \a key (throws not_found) */ void xbt_dict_remove_ext(xbt_dict_t dict, diff --git a/src/xbt/dict_cursor.c b/src/xbt/dict_cursor.c index 9cce7166cf..1827eeb8b3 100644 --- a/src/xbt/dict_cursor.c +++ b/src/xbt/dict_cursor.c @@ -199,7 +199,7 @@ xbt_dict_cursor_get_or_free(xbt_dict_cursor_t *cursor, /** * @brief Get current key * @param cursor: the cursor - * @param key where to put the key + * @returns the current key */ char * xbt_dict_cursor_get_key(xbt_dict_cursor_t cursor) { @@ -211,7 +211,7 @@ xbt_dict_cursor_get_key(xbt_dict_cursor_t cursor) { /** * @brief Get current data * @param cursor the cursor - * @param data where to put the data + * @returns the current data */ void * xbt_dict_cursor_get_data(xbt_dict_cursor_t cursor) { diff --git a/src/xbt/dict_private.h b/src/xbt/dict_private.h index 1a8a9f547d..7ad68349fa 100644 --- a/src/xbt/dict_private.h +++ b/src/xbt/dict_private.h @@ -13,7 +13,6 @@ #include "xbt/sysdep.h" #include "xbt/log.h" -#include "xbt/error.h" #include "xbt/ex.h" #include "xbt/dynar.h" #include "xbt/dict.h" diff --git a/src/xbt/dynar.c b/src/xbt/dynar.c index f41d17fff4..41602f93a3 100644 --- a/src/xbt/dynar.c +++ b/src/xbt/dynar.c @@ -11,7 +11,6 @@ #include "xbt/misc.h" #include "xbt/sysdep.h" #include "xbt/log.h" -#include "xbt/error.h" #include "xbt/dynar.h" #include @@ -47,10 +46,9 @@ void _xbt_clear_mem(void * const ptr, } static _XBT_INLINE -xbt_error_t +void _xbt_dynar_expand(xbt_dynar_t const dynar, const int nb) { - xbt_error_t errcode = no_error; const unsigned long old_size = dynar->size; if (nb > old_size) { @@ -79,8 +77,6 @@ _xbt_dynar_expand(xbt_dynar_t const dynar, dynar->size = new_size; dynar->data = new_data; } - - return errcode; } static _XBT_INLINE diff --git a/src/xbt/fifo.c b/src/xbt/fifo.c index 70983fbb60..ed8b30e599 100644 --- a/src/xbt/fifo.c +++ b/src/xbt/fifo.c @@ -6,7 +6,6 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "xbt/sysdep.h" -#include "xbt/error.h" #include "fifo_private.h" /*XBT_LOG_NEW_DEFAULT_SUBCATEGORY(fifo,xbt,"FIFO"); UNUSED SO FAR */ diff --git a/src/xbt/heap.c b/src/xbt/heap.c index c6207b9540..c5d1649aa8 100644 --- a/src/xbt/heap.c +++ b/src/xbt/heap.c @@ -8,7 +8,7 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "xbt/sysdep.h" -#include "xbt/error.h" +#include "xbt/log.h" #include "heap_private.h" diff --git a/src/xbt/log_default_appender.c b/src/xbt/log_default_appender.c index 7aeb17023e..6a04917f13 100644 --- a/src/xbt/log_default_appender.c +++ b/src/xbt/log_default_appender.c @@ -9,7 +9,6 @@ #include "xbt/sysdep.h" #include "xbt/log.h" -#include "xbt/error.h" #include #include "gras/virtu.h" diff --git a/src/xbt/module.c b/src/xbt/module.c index a79815f017..32dc9ad3f0 100644 --- a/src/xbt/module.c +++ b/src/xbt/module.c @@ -9,7 +9,6 @@ #include "xbt/sysdep.h" #include "xbt/log.h" -#include "xbt/error.h" #include "xbt/dynar.h" #include "xbt/config.h" diff --git a/src/xbt/set.c b/src/xbt/set.c index e00677a860..efada3837e 100644 --- a/src/xbt/set.c +++ b/src/xbt/set.c @@ -101,7 +101,7 @@ void xbt_set_add (xbt_set_t set, * * \param set * \param name Name of the searched cell - * \param dst where to put the found data into + * \returns the data you're looking for */ xbt_set_elm_t xbt_set_get_by_name (xbt_set_t set, const char *name) { @@ -114,7 +114,7 @@ xbt_set_elm_t xbt_set_get_by_name (xbt_set_t set, * \param set * \param name Name of the searched cell * \param name_len length of the name, when strlen cannot be trusted - * \param dst where to put the found data into + * \returns the data you're looking for * * This is useful when strlen cannot be trusted because you don't use a char* * as name, you weirdo. @@ -130,7 +130,7 @@ xbt_set_elm_t xbt_set_get_by_name_ext(xbt_set_t set, * * \param set * \param id what you're looking for - * \param dst where to put the found data into + * \returns the data you're looking for * * @warning, if the ID does not exists, you're getting into trouble */ diff --git a/src/xbt/swag.c b/src/xbt/swag.c index 1b2fb7b165..d20cd5ee43 100644 --- a/src/xbt/swag.c +++ b/src/xbt/swag.c @@ -12,7 +12,7 @@ /* This type should be added to a type that is to be used in such a swag */ #include "xbt/sysdep.h" -#include "xbt/error.h" +#include "xbt/log.h" #include "xbt/swag.h" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(swag,xbt,"Swag : O(1) set library"); diff --git a/testsuite/gras/mk_datadesc_structs.pl b/testsuite/gras/mk_datadesc_structs.pl index a9b520a33a..8e62de0362 100755 --- a/testsuite/gras/mk_datadesc_structs.pl +++ b/testsuite/gras/mk_datadesc_structs.pl @@ -26,7 +26,7 @@ print "XBT_LOG_NEW_DEFAULT_SUBCATEGORY(structs,test,\"Logs about the gigantic st print "#define READ 0\n#define WRITE 1\n#define RW 2\n\n"; -print "xbt_error_t write_read(gras_datadesc_type_t type,void *src, void *dst, gras_socket_t *sock, int direction);\n\n"; +print "void write_read(gras_datadesc_type_t type,void *src, void *dst, gras_socket_t *sock, int direction);\n\n"; my ($i,$j,$k,$l); my $max=scalar @types; diff --git a/testsuite/xbt/dict_crash.c b/testsuite/xbt/dict_crash.c index 47533999f3..c16121fd6a 100644 --- a/testsuite/xbt/dict_crash.c +++ b/testsuite/xbt/dict_crash.c @@ -22,7 +22,7 @@ static void print_str(void *str) { XBT_LOG_NEW_DEFAULT_CATEGORY(test,"Logging specific to this test"); -static xbt_error_t traverse(xbt_dict_t head) { +static void traverse(xbt_dict_t head) { xbt_dict_cursor_t cursor=NULL; char *key; char *data; @@ -32,23 +32,21 @@ static xbt_error_t traverse(xbt_dict_t head) { xbt_assert2 (!strcmp(key,data), "Key(%s) != value(%s). Abording\n",key,data); } - return no_error; } -static xbt_error_t countelems(xbt_dict_t head,int*count) { +static int countelems(xbt_dict_t head) { xbt_dict_cursor_t cursor; char *key; void *data; - *count=0; + int res = 0; xbt_dict_foreach(head,cursor,key,data) { - (*count)++; + res++; } - return no_error; + return res; } int main(int argc,char **argv) { - xbt_error_t errcode; xbt_dict_t head=NULL; int i,j,k, nb; char *key; @@ -78,14 +76,13 @@ int main(int argc,char **argv) { /* printf("[%d %s]\n",j,key); */ xbt_dict_set(head,key,key,&free); } - nb=0; /* xbt_dict_dump(head,(void (*)(void*))&printf); */ - TRYFAIL(countelems(head,&nb)); + nb = countelems(head); if (nb != 1000) { printf ("\nI found %d elements, and not 1000\n",nb); abort(); } - TRYFAIL(traverse(head)); + traverse(head); xbt_dict_free(&head); xbt_dict_free(&head); } @@ -109,7 +106,7 @@ int main(int argc,char **argv) { } printf("\n Count the elements (retrieving the key and data for each): \n"); - TRYFAIL(countelems(head,&i)); + i = countelems(head); printf(" There is %d elements\n",i); printf("\n Search my 20 000 elements 20 times. (a point is a test)\n"); diff --git a/tools/gras/stub_generator.c b/tools/gras/stub_generator.c index 2e15a95a12..28fb684dae 100644 --- a/tools/gras/stub_generator.c +++ b/tools/gras/stub_generator.c @@ -9,6 +9,7 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "xbt/sysdep.h" +#include "xbt/log.h" #include "surf/surf_parse.h" #include "surf/surf.h" -- 2.20.1