+2004-11-04 Martin Quinson
+ - Allow to (en/dis)able the cycle detection at run time.
+
+ Whether we should check for cycle or not is now a property of each
+ datatype. When you think there may be some cycle, use datadesc_cycle_set.
+ datadesc_cycle_unset allow to remove this property when previously set.
+
+ Note that the cycle detection is off by default since it impacts the
+ performance. Watch the data you feed GRAS with ;)
+
+ This property is hereditary. Any element embeeded in a structure having it
+ set have it set for the time of this data exchange.
+
+ You should set it both on sender and receiver side. If you don't set it on
+ sender side, it will enter an endless loop. If you forget on receiver
+ side, the cycles won't be recreated after communication.
+
+ - Header reorganization.
+ Kill gras_private.h, each submodule must load the headers it needs.
+
+2004-10-04 Martin Quinson
+ - Interface revolution: do not try to survive to malloc failure.
+
+ Now, gras_malloc and friends call gras_abort() on failure.
+ As a conclusion, malloc_error is not a valid error anymore, and all
+ functions for which it was the only gras_error_t return value are
+ changed. They now return void, or there result directly.
+ This simplify the API a lot.
+
2004-09-29 Martin Quinson
- Re-enable raw sockets.
Created by gras_socket_{client,server}_ext;
Used with gras_raw_{send,recv}
+ No select possible.
- It should allow to kill the last bits of gras first version.
+ It should allow to kill the last bits of gras first version soon.
This is not completely satisfactory yet (dupplicate code with
chunk_{send,recv}; a bit out of the plugin mecanism), but it should
work.
- - Simplify transport plugin interface by not passing any argument to
- _server and _client, but embeeding them in the socket struct directly.
+ - Simplify transport plugin (internal) interface by not passing any
+ argument to _server and _client, but embeeding them in the socket
+ struct directly.
2004-09-28 Martin Quinson
- Finish the port to AIX.
2004-09-07 Martin Quinson
- Source code reorganization to allow Arnaud to surf all over there.
- - Allow to document the logging categories
+ - Allow to document the logging categories.
- Remove all uppercase from logging categories and useless cleanup in names.
2004-08-18 Martin Quinson
Version 0.5 (protocol not changed; ABI changed)
- Allow to off turn the cycle detection code in data exchange at
compilation time. It should be at run time, but I'm short of time (and
- the config stuff is still broken). That way, we keep dict of of the
+ the config stuff is still broken). That way, we keep dict out of the
critical path, which is good because the performance is poor:
- search not dichotomial yet
- dynar give no way to access their content and memcpy everytime
of the critical path, which is good since they rely on dynar and
dictionnaries. The only loose of that is that we cannot detect the
redeclaration of a structure/union with another content (but I'm not sure
- the code detected this error well before anyway). We still can detect
+ the code detected well this error before anyway). We still can detect
the redefinition discrepancy for the other types.
- Use a whole bunch of optimisation flags (plus -fno-strict-aliasing since
it breaks the code because of type-punning used all over the place).
include/Makefile
src/Makefile
examples/Makefile
- examples/ping/Makefile
- examples/ping/test_sg
+ examples/ping/Makefile examples/ping/test_sg
doc/Makefile
tools/compile-remote-worker
testsuite/Makefile
chmod +x $srcdir/examples/ping/test_rl
])
-# src/gros/Makefile
-# src/gras/Makefile
-
-# testsuite/gras/Makefile
-#
-# testsuite/gras/trp_tcp_usage
-# testsuite/gras/trp_file_usage
+# src/amok/Makefile
+# examples/bandwidth/Makefile examples/bandwidth/test_sg
+# examples/saturate/Makefile examples/saturate/test_sg
+# examples/alnem/Makefile examples/alnem/test_sg
-# src/examples/pastry/Makefile
-# src/amok/Makefile
-# src/examples/bandwidth/Makefile src/examples/saturate/Makefile
-# src/examples/alnem/Makefile
+# examples/pastry/Makefile examples/pastry/test_sg
AC_OUTPUT
-SUBDIRS=ping
+SUBDIRS=ping # saturate
EXTRA_DIST=gras_stub_generator WAN_3.platform.txt WAN_3.platform_2.txt
#bandwidth saturate alnem
_ping_client.c _ping_server.c _ping_simulator.c: ping_deployment.txt $(top_srcdir)/examples/gras_stub_generator
$(top_srcdir)/examples/gras_stub_generator ping ping_deployment.txt >/dev/null
-
-# support vpath build
-#test_rl test_sg:
-# cp $(srcdir)/$@ . && chmod +x $@
-DISTCLEANFILES=Makefile.in
-INCLUDES= -I$(top_srcdir)/src/include
+INCLUDES= -I$(top_srcdir)/include
AM_CFLAGS=-g
-check_PROGRAMS=saturate_simulator saturate_sensor saturate_maestro
+TESTS=test_rl test_sg
+EXTRA_DIST=saturate_deployment.txt $(TESTS)
+
+if HAVE_SG
+ check_PROGRAMS=saturate_simulator saturate_sensor saturate_maestro
+
+ saturate_simulator_SOURCES=_saturate_simulator.c saturate.c
+ saturate_simulator_LDADD= $(top_builddir)/src/libgrassg.la @LIBS_SimGrid@ # $(top_srcdir)/src/modules/libgrasmodules.la
+else
+ check_PROGRAMS=saturate_sensor saturate_maestro
+endif
-saturate_simulator_SOURCES= _saturate_simulator.c saturate.c
saturate_sensor_SOURCES= _saturate_sensor.c saturate.c
saturate_maestro_SOURCES= _saturate_maestro.c saturate.c
-saturate_simulator_LDADD= $(top_srcdir)/src/base/libgrassg.a $(top_srcdir)/src/modules/libgrasmodules.a @LIBS_SimGrid@
-saturate_sensor_LDADD= $(top_srcdir)/src/base/libgrasrl.a $(top_srcdir)/src/modules/libgrasmodules.a
-saturate_maestro_LDADD= $(top_srcdir)/src/base/libgrasrl.a $(top_srcdir)/src/modules/libgrasmodules.a
+saturate_sensor_LDADD= $(top_srcdir)/src/libgrasrl.la # $(top_srcdir)/src/modules/libgrasmodules.a
+saturate_maestro_LDADD= $(top_srcdir)/src/libgrasrl.la # $(top_srcdir)/src/modules/libgrasmodules.a
# cleanup templates
CLEANFILES= _saturate_simulator.c _saturate_sensor.c _saturate_maestro.c
# generate templates
_saturate_sensor.c _saturate_maestro.c _saturate_simulator.c: saturate_deployment.txt
- ../gras_stub_generator saturate saturate_deployment.txt >/dev/null
+ $(top_srcdir)/examples/gras_stub_generator saturate saturate_deployment.txt >/dev/null
#include <gras.h>
+GRAS_LOG_NEW_DEFAULT_CATEGORY(saturate,"Messages specific to this example");
+
/* **********************************************************************
* Sensor code
* **********************************************************************/
/* Global private data */
typedef struct {
- gras_sock_t *sock;
+ gras_socket_t *sock;
} sensor_data_t;
/* Function prototypes */
gras_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));
+ if ((errcode=gras_socket_server(4000,&(g->sock)))) {
+ CRITICAL1("Sensor: Error %s encountered while opening the server socket",gras_error_name(errcode));
return 1;
}
if (grasbw_register_messages()) {
- gras_sock_close(g->sock);
+ gras_socket_close(g->sock);
return 1;
}
while (1) {
- if ((errcode=gras_msg_handle(60.0)) && errcode != timeout_error) {
- fprintf(stderr,"Sensor: Error '%s' while handling message\n",
+ if ((errcode=gras_msg_handle(60.0)) && errcode != timeout_error) {
+ CRITICAL1("Sensor: Error '%s' while handling message",
gras_error_name(errcode));
}
}
- gras_sleep(5,0);
- return gras_sock_close(g->sock);
+ gras_os_sleep(5,0);
+ gras_socket_close(g->sock);
+
+ return 0;
}
/* **********************************************************************
/* Global private data */
typedef struct {
- gras_sock_t *sock;
+ gras_socket_t *sock;
} maestro_data_t;
/* Function prototypes */
gras_error_name(errcode));
return -1;
}
- gras_sleep(1,0);
+ 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));
return -1;
int a,b,c,d,begin;
- if ((errcode=gras_sock_server_open(4000,5000,&(g->sock)))) {
+ if ((errcode=gras_socket_server(4000,&(g->sock)))) {
fprintf(stderr,"MAESTRO: Error %s encountered while opening the server socket\n",gras_error_name(errcode));
return 1;
}
if (grasbw_register_messages()) {
- gras_sock_close(g->sock);
+ gras_socket_close(g->sock);
return 1;
}
begin=time(NULL);
- beginSim=gras_time();
+ beginSim=gras_os_time();
for (a=0; a<MAXHOSTS; a++) {
for (b=0; b<MAXHOSTS; b++) {
if (a==b) continue;
}
}
fprintf(stderr,"Did all BW tests in %ld sec (%.2f simulated sec)\n",
- time(NULL)-begin,gras_time()-beginSim);
+ time(NULL)-begin,gras_os_time()-beginSim);
for (a=0; a<MAXHOSTS; a++) {
for (b=0; b<MAXHOSTS; b++) {
gras_error_name(errcode));
return -1;
}
- gras_sleep(1,0);
+ gras_os_sleep(1,0);
begin=time(NULL);
- beginSim=gras_time();
+ beginSim=gras_os_time();
for (c=0 ;c<MAXHOSTS; c++) {
if (a==c) continue;
if (b==c) continue;
return 1;
}
fprintf(stderr, "MAESTRO[%.2f sec]: SATURATED BW XP(%s %s // %s %s) => %f (%f vs %f)%s\n",
- gras_time(),
+ gras_os_time(),
hosts[c],hosts[d],hosts[a],hosts[b],
bw_sat[c][d]/bw[c][d],bw[c][d],bw_sat[c][d],
return -1;
}
fprintf(stderr,"Did an iteration on saturation pair in %ld sec (%.2f simulated sec)\n",
- time(NULL)-begin, gras_time()-beginSim);
+ time(NULL)-begin, gras_os_time()-beginSim);
}
}
- gras_sleep(5,0);
+ gras_os_sleep(5,0);
exit(0);
#if 0
return 0;
return 1;
}
fprintf(stderr,"MAESTRO: Saturation started\n");
- gras_sleep(5,0);
+ gras_os_sleep(5,0);
/* test with saturation */
if ((errcode=grasbw_request(argv[1],atoi(argv[2]),argv[3],atoi(argv[4]),
expSize/1024,msgSize/1024,
sec,bw);
- gras_sleep(5,0);
+ gras_os_sleep(5,0);
#endif
- return gras_sock_close(g->sock);
+ gras_socket_close(g->sock);
+
+ return 0;
}
include_HEADERS = gras.h xbt.h
nobase_include_HEADERS = \
+ xbt/misc.h \
xbt/sysdep.h \
xbt/log.h xbt/error.h \
xbt/module.h \
#include <gras/datadesc.h>
#include <gras/messages.h>
-/* FIXME: This is amok */
-
-#include <gras/modules/base.h>
-#include <gras/modules/bandwidth.h>
-
#endif /* GRAS_H */
#include <sys/types.h> /* size_t */
#include <stdarg.h>
-
-/*! C++ users need love */
-#ifndef BEGIN_DECL
-# ifdef __cplusplus
-# define BEGIN_DECL extern "C" {
-# else
-# define BEGIN_DECL
-# endif
-#endif
-
-/*! C++ users need love */
-#ifndef END_DECL
-# ifdef __cplusplus
-# define END_DECL }
-# else
-# define END_DECL
-# endif
-#endif
-/* End of cruft for C++ */
+#include "xbt/misc.h" /* BEGIN_DECL */
BEGIN_DECL
-
/**
* gras_datadesc_type_t:
*
* Change stuff within datadescs *
*********************************/
+void gras_datadesc_cycle_set(gras_datadesc_type_t *type);
+void gras_datadesc_cycle_unset(gras_datadesc_type_t *type);
+
void gras_datadesc_cb_send (gras_datadesc_type_t *type,
gras_datadesc_type_cb_void_t pre);
void gras_datadesc_cb_recv(gras_datadesc_type_t *type,
#ifndef GRAS_MESSAGES_H
#define GRAS_MESSAGES_H
-/*! C++ users need love */
-#ifndef BEGIN_DECL
-# ifdef __cplusplus
-# define BEGIN_DECL extern "C" {
-# else
-# define BEGIN_DECL
-# endif
-#endif
-
-/*! C++ users need love */
-#ifndef END_DECL
-# ifdef __cplusplus
-# define END_DECL }
-# else
-# define END_DECL
-# endif
-#endif
-/* End of cruft for C++ */
+#include "xbt/misc.h"
+#include "gras/transport.h"
+#include "gras/datadesc.h"
BEGIN_DECL
#ifndef GRAS_TRANSPORT_H
#define GRAS_TRANSPORT_H
+#include "xbt/error.h"
+
typedef struct s_gras_socket gras_socket_t;
gras_error_t gras_socket_client(const char *host,
#ifndef _GRAS_CONFIG_H_
#define _GRAS_CONFIG_H_
-typedef struct {
- char *name;
- int port;
-} gras_host_t;
-
/* 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;
} gras_cfgelm_type_t;
/*----[ Memory management ]-----------------------------------------------*/
-void gras_cfg_new (gras_cfg_t **whereto); /* (whereto == NULL) is ok */
+gras_cfg_t *gras_cfg_new (void);
void gras_cfg_cpy(gras_cfg_t **whereto, gras_cfg_t *tocopy);
void gras_cfg_free(gras_cfg_t **cfg);
void gras_cfg_dump(const char *name,const char*indent,gras_cfg_t *cfg);
/*####[ Simple dict functions ]#############################################*/
-void gras_dict_new(gras_dict_t **dict);
+gras_dict_t *gras_dict_new(void);
void gras_dict_free(gras_dict_t **dict);
/*###########################################################################*/
typedef struct gras_dict_cursor_ gras_dict_cursor_t;
/* creator/destructor */
-void gras_dict_cursor_new(const gras_dict_t *head,
- /*OUT*/gras_dict_cursor_t **cursor);
-void gras_dict_cursor_free(gras_dict_cursor_t *cursor);
+gras_dict_cursor_t *gras_dict_cursor_new(const gras_dict_t *head);
+void gras_dict_cursor_free(gras_dict_cursor_t *cursor);
/* back to first element
it is not enough to reinit the cache after an add/remove in cache*/
gras_error_t gras_dict_cursor_get_data (gras_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_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,
char **key,
typedef void (void_f_ppvoid_t)(void**);
typedef void (void_f_pvoid_t) (void*);
-void gras_dynar_new(gras_dynar_t **whereto,
- size_t elm_size,
- void_f_pvoid_t *free_func);
+gras_dynar_t *gras_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);
/* regular array functions */
-void gras_dynar_get(const gras_dynar_t *dynar,
- int idx, void *dst);
-void gras_dynar_set(gras_dynar_t *dynar,
- int idx, const void *src);
+void gras_dynar_get(const gras_dynar_t *dynar, int idx, void *const dst);
+void gras_dynar_set(gras_dynar_t *dynar, int idx, const void *src);
void gras_dynar_remplace(gras_dynar_t *dynar,
- int idx, const void *object);
+ int idx, const void *object);
/* perl array function */
void gras_dynar_insert_at(gras_dynar_t *dynar,
- int idx, const void *src);
+ int idx, const void *src);
void gras_dynar_remove_at(gras_dynar_t *dynar,
- int idx, void *object);
+ int idx, void *object);
void gras_dynar_push (gras_dynar_t *dynar, const void *src);
-void gras_dynar_pop (gras_dynar_t *dynar, void *dst);
+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 *dst);
+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);
/* 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 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);
/**
* gras_dynar_foreach:
#include <stdio.h> /* FIXME: Get rid of it */
+#include "xbt/log.h"
+
#ifdef HAVE_EXECINFO_H
#include <execinfo.h> /* to print the backtrace */
#endif
#undef GRAS_LOG_MAYDAY
/*#define GRAS_LOG_MAYDAY*/
-
#ifndef _GRAS_LOG_H_
#define _GRAS_LOG_H_
#include <stdarg.h>
+#include "xbt/sysdep.h"
+
/**
* gras_log_priority_t:
* @gras_log_priority_none: used internally (don't poke with)
/*####[ Functions ]##########################################################*/
-void gras_set_new (gras_set_t **dst);
+gras_set_t *gras_set_new (void);
void gras_set_free(gras_set_t **set);
gras_set_elm_t **elm);
#define gras_set_foreach(set,cursor,elm) \
- for (cursor=NULL, gras_set_cursor_first((set),&(cursor)) ; \
+ 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) )
-SUBDIRS=.
-# amok not ported to GRAS NG yet
+SUBDIRS= . # amok
AM_CFLAGS= -g
#AM_CFLAGS= -DNDEBUG
INCLUDES= -I$(top_srcdir)/include \
@CFLAGS_SimGrid@
EXTRA_DIST= \
- gras_private.h\
\
xbt/dict_private.h \
\
gras/Virtu/virtu_sg.h \
gras/DataDesc/ddt_parse.yy.l gras/DataDesc/ddt_parse.yy.c
+# gras_private.h
+
#LIBRARY_VERSION= 0:0:0
# | | |
# +------+ | +---+
COMMON_S=\
\
- xbt/xbt_interface.h \
+ xbt_modinter.h gras_modinter.h \
+ \
xbt/sysdep.c \
xbt/log.c xbt/log_default_appender.c xbt/error.c \
xbt/dynar.c \
DISTCLEANFILES=Makefile.in
-INCLUDES= -I$(top_srcdir)/src/include @CFLAGS_SimGrid@
+INCLUDES= -I$(top_srcdir)/src -I$(top_srcdir)/include @CFLAGS_SimGrid@
-lib_LIBRARIES= libgrasmodules.a
+lib_LTLIBRARIES= libamok.la
-libgrasmodules_a_SOURCES= \
+libamok_la_SOURCES= \
base.c bandwidth.c
+VERSION_INFO= -release 20040722 -version-info 0:0:0
+
/* $Id$ */
-/* gras_bandwidth - GRAS mecanism to do Bandwidth tests between to hosts */
+/* amok_bandwidth - Bandwidth tests facilities */
/* Authors: Martin Quinson */
-/* Copyright (C) 2003 the OURAGAN project. */
+/* Copyright (C) 2003, 2004 the OURAGAN project. */
/* 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 <stdlib.h>
#include <string.h>
-#include <gras.h>
+#include "gras/messages.h"
+#include "amok/bandwidth.h"
/**
- * BwExp_t:
+ * bw_request_t:
*
- * Description of a BW experiment (payload when asking an host to do a BW experiment with us)
+ * Request for a BW experiment.
+ * If host==NULL, it should be between the sender and the receiver.
+ * If not, it should be between between the receiver and @host (3-tiers).
*/
typedef struct {
- unsigned int bufSize;
- unsigned int expSize;
- unsigned int msgSize;
- unsigned int port; /* raw socket to use */
-} BwExp_t;
-
-static const DataDescriptor BwExp_Desc[] =
- { SIMPLE_MEMBER(UNSIGNED_INT_TYPE, 1, offsetof(BwExp_t,bufSize)),
- SIMPLE_MEMBER(UNSIGNED_INT_TYPE, 1, offsetof(BwExp_t,expSize)),
- SIMPLE_MEMBER(UNSIGNED_INT_TYPE, 1, offsetof(BwExp_t,msgSize)),
- SIMPLE_MEMBER(UNSIGNED_INT_TYPE, 1, offsetof(BwExp_t,port))};
-#define BwExp_Len 4
+ gras_host_t host; /* host+raw socket to use */
+ unsigned int buf_size;
+ unsigned int exp_size;
+ unsigned int msg_size;
+} bw_request_t;
/**
- * SatExp_t:
+ * bw_res_t:
*
- * Description of a BW experiment (payload when asking an host to do a BW experiment with us)
+ * Result of a BW experiment (payload when answering).
+ * if err.msg != NULL, it wasn't sucessful. Check err.msg and err.code to see why.
+ * else
*/
typedef struct {
- unsigned int msgSize;
- unsigned int timeout;
- unsigned int port; /* raw socket to use */
-} SatExp_t;
+ amok_remoterr_t err;
+ unsigned int timestamp;
+ double seconds;
+ double bw;
+} bw_res_t;
-static const DataDescriptor SatExp_Desc[] =
- { SIMPLE_MEMBER(UNSIGNED_INT_TYPE, 1, offsetof(SatExp_t,msgSize)),
- SIMPLE_MEMBER(UNSIGNED_INT_TYPE, 1, offsetof(SatExp_t,timeout)),
- SIMPLE_MEMBER(UNSIGNED_INT_TYPE, 1, offsetof(SatExp_t,port))};
-#define SatExp_Len 3
+/**
+ * sat_request_t:
+ *
+ * Description of a saturation experiment (payload asking some host to collaborate for that)
+ */
+typedef struct {
+ gras_host_t host; /* host+raw socket to use */
+ unsigned int msg_size;
+ unsigned int timeout;
+} sat_request_t;
/* Prototypes of local callbacks */
-int grasbw_cbBWHandshake(gras_msg_t *msg);
-int grasbw_cbBWRequest(gras_msg_t *msg);
+int amok_bw_cb_bw_handshake(gras_socket_t *expeditor,
+ void *payload);
+int amok_bw_cb_bw_request(gras_socket_t *expeditor,
+ void *payload);
-int grasbw_cbSatStart(gras_msg_t *msg);
-int grasbw_cbSatBegin(gras_msg_t *msg);
+int amok_bw_cb_sat_start(gras_socket_t *expeditor,
+ void *payload);
+int amok_bw_cb_sat_begin(gras_socket_t *expeditor,
+ void *payload);
/**** code ****/
-gras_error_t grasbw_register_messages(void) {
+void amok_bw_init(void) {
gras_error_t errcode;
-
-
- if ( /* Bandwidth */
- (errcode=gras_msgtype_register(GRASMSG_BW_REQUEST,"BW request",2,
- msgHostDesc,msgHostLen,
- BwExp_Desc,BwExp_Len)) ||
- (errcode=gras_msgtype_register(GRASMSG_BW_RESULT, "BW result",2,
- msgErrorDesc,msgErrorLen,
- msgResultDesc,msgResultLen /* first=seconds, second=bw */)) ||
-
- (errcode=gras_msgtype_register(GRASMSG_BW_HANDSHAKE, "BW handshake",1,
- BwExp_Desc,BwExp_Len)) ||
- (errcode=gras_msgtype_register(GRASMSG_BW_HANDSHAKED, "BW handshake ACK",1,
- BwExp_Desc,BwExp_Len)) ||
-
- /* Saturation */
- (errcode=gras_msgtype_register(GRASMSG_SAT_START,"SAT_START",2,
- msgHostDesc,msgHostLen,
- SatExp_Desc,SatExp_Len)) ||
- (errcode=gras_msgtype_register(GRASMSG_SAT_STARTED, "SAT_STARTED",1,
- msgErrorDesc,msgErrorLen)) ||
-
- (errcode=gras_msgtype_register(GRASMSG_SAT_BEGIN,"SAT_BEGIN",1,
- SatExp_Desc,SatExp_Len)) ||
- (errcode=gras_msgtype_register(GRASMSG_SAT_BEGUN, "SAT_BEGUN",2,
- msgErrorDesc,msgErrorLen,
- SatExp_Desc,SatExp_Len)) ||
-
- (errcode=gras_msgtype_register(GRASMSG_SAT_END,"SAT_END",0)) ||
- (errcode=gras_msgtype_register(GRASMSG_SAT_ENDED, "SAT_ENDED",1,
- msgErrorDesc,msgErrorLen)) ||
-
- (errcode=gras_msgtype_register(GRASMSG_SAT_STOP,"SAT_STOP",0)) ||
- (errcode=gras_msgtype_register(GRASMSG_SAT_STOPPED, "SAT_STOPPED",1,
- msgErrorDesc,msgErrorLen)) )
- {
-
- fprintf(stderr,"GRASBW: Unable register the messages (got error %s)\n",
- gras_error_name(errcode));
- return errcode;
- }
-
- if ((errcode=gras_cb_register(GRASMSG_BW_HANDSHAKE,-1,&grasbw_cbBWHandshake)) ||
- (errcode=gras_cb_register(GRASMSG_BW_REQUEST,-1,&grasbw_cbBWRequest)) ||
-
- (errcode=gras_cb_register(GRASMSG_SAT_START,-1,&grasbw_cbSatStart)) ||
- (errcode=gras_cb_register(GRASMSG_SAT_BEGIN,-1,&grasbw_cbSatBegin)) ) {
-
- fprintf(stderr,"GRASBW: Unable register the callbacks (got error %s)\n",
- gras_error_name(errcode));
- return errcode;
- }
-
- return no_error;
+ 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,"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"));
+ gras_datadesc_struct_close(bw_request_desc);
+ bw_request_desc = gras_datadesc_ref("bw_request_t*",bw_request_desc);
+
+ bw_res_desc = gras_datadesc_struct("bw_res_t");
+ gras_datadesc_struct_append(bw_res_desc,"err",gras_datadesc_by_name("amok_remoterr_t"));
+ gras_datadesc_struct_append(bw_res_desc,"timestamp",gras_datadesc_by_name("unsigned int"));
+ gras_datadesc_struct_append(bw_res_desc,"seconds",gras_datadesc_by_name("double"));
+ gras_datadesc_struct_append(bw_res_desc,"bw",gras_datadesc_by_name("double"));
+ gras_datadesc_struct_close(bw_res_desc);
+ 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,"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);
+ sat_request_desc = gras_datadesc_ref("sat_request_t*",sat_request_desc);
+
+ /* Register the bandwidth messages */
+ gras_msgtype_declare("BW request", bw_request_desc);
+ gras_msgtype_declare("BW result", bw_res_desc);
+ gras_msgtype_declare("BW handshake", bw_request_desc);
+ gras_msgtype_declare("BW handshake ACK", bw_request_desc);
+
+ /* Register the saturation messages */
+ gras_msgtype_declare("SAT start", sat_request_desc);
+ gras_msgtype_declare("SAT started", gras_datadesc_by_name("amok_remoterr_t"));
+ gras_msgtype_declare("SAT begin", sat_request_desc);
+ gras_msgtype_declare("SAT begun", gras_datadesc_by_name("amok_remoterr_t"));
+ gras_msgtype_declare("SAT end", NULL);
+ gras_msgtype_declare("SAT ended", gras_datadesc_by_name("amok_remoterr_t"));
+ gras_msgtype_declare("SAT stop", NULL);
+ gras_msgtype_declare("SAT stopped", gras_datadesc_by_name("amok_remoterr_t"));
+
+ /* Register the callbacks */
+ gras_cb_register(gras_msgtype_by_name("BW request"),
+ &amok_bw_cb_bw_request);
+ gras_cb_register(gras_msgtype_by_name("BW handshake"),
+ &amok_bw_cb_bw_handshake);
+
+ gras_cb_register(gras_msgtype_by_name("SAT start"),
+ &amok_bw_cb_sat_start);
+ gras_cb_register(gras_msgtype_by_name("SAT begin"),
+ &amok_bw_cb_sat_begin);
}
/* ***************************************************************************
* Bandwidth tests
* ***************************************************************************/
/* Function to do a test from local to given host */
-gras_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) {
- gras_rawsock_t *rawIn,*rawOut;
- gras_sock_t *sock;
+/**
+ * amok_bw_test:
+ *
+ * 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,
+ 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;
- BwExp_t *request;
+ bw_request_t *request;
gras_msg_t *answer;
- if((errcode=gras_sock_client_open(to_name,to_port,&sock))) {
- fprintf(stderr,"grasbw_test(): Error %s encountered while contacting peer\n",
- gras_error_name(errcode));
- return errcode;
- }
- if ((errcode=gras_rawsock_server_open(6666,8000,bufSize,&rawIn))) {
- fprintf(stderr,"grasbw_test(): Error %s encountered while opening a raw socket\n",
- gras_error_name(errcode));
+ for (port = 5000, errcode = system_error;
+ errcode == system_error;
+ 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));
return errcode;
}
- if (!(request=(BwExp_t *)malloc(sizeof(BwExp_t)))) {
- fprintf(stderr,"grasbw_test(): Malloc error\n");
- gras_sock_close(sock);
- return malloc_error;
- }
+ request=gras_new(bw_request_t);
request->bufSize=bufSize;
request->expSize=expSize;
request->msgSize=msgSize;
- request->port=gras_rawsock_get_peer_port(rawIn);
+ request->host.name = NULL;
+ request->host.port = gras_socket_peer_port(rawIn);
- if ((errcode=gras_msg_new_and_send(sock,GRASMSG_BW_HANDSHAKE, 1,
- request,1))) {
- fprintf(stderr,"grasbw_test(): Error %s encountered while sending the request.\n",
- gras_error_name(errcode));
+ if ((errcode=gras_send(peer,gras_msgtype_by_name("BW handshake"),request))) {
+ ERROR1("Error %s encountered while sending the request.", gras_error_name(errcode));
gras_sock_close(sock);
return errcode;
}
return no_error;
}
+#if 0
+
+
/* Callback to the GRASMSG_BW_HANDSHAKE message:
opens a server raw socket,
indicate its port in an answer GRASMSG_BW_HANDSHAKED message,
return no_error;
}
+#endif
/* $Id$ */
-/* gras_addons - several addons to do specific stuff not in GRAS itself */
+/* base - several addons to do specific stuff not in GRAS itself */
/* Authors: Martin Quinson */
/* Copyright (C) 2003 the OURAGAN project. */
#include <stdlib.h>
#include <stdio.h>
+#include <strings.h>
-#include <gras.h>
+#include "xbt/error.h"
+#include "gras/datadesc.h"
+#include "amok/base.h"
-void
-grasRepportError (gras_sock_t *sock, gras_msgid_t id, int SeqCount,
- const char *severeError,
- gras_error_t errcode, const char* format,...) {
- msgError_t *error;
+GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(amok,GRAS_LOG_ROOT_CAT,"All AMOK categories");
+
+amok_remoterr_t *amok_remoterr_new(gras_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;
+}
- if (!(error=(msgError_t*)malloc(sizeof(msgError_t)))) {
- fprintf(stderr,severeError);
- return;
+amok_remoterr_t *amok_remoterr_new_va(gras_error_t param_errcode,
+ const char* format,va_list ap) {
+ amok_remoterr_t *res=gras_new(amok_remoterr_t,1);
+ res->code=param_errcode;
+ if (format) {
+ res->msg=(char*)gras_malloc(1024);
+ vsnprintf(res->msg,1024,format,ap);
+ } else {
+ res->msg = NULL;
}
+
+ return res;
+}
+
+void amok_remoterr_free(amok_remoterr_t*err) {
+ if (err) {
+ if (err->msg) gras_free(err->msg);
+ gras_free(err);
+ }
+}
+
- error->errcode=errcode;
+void
+amok_repport_error (gras_socket_t *sock, gras_msgtype_t *msgtype,
+ gras_error_t param_errcode, const char* format,...) {
+ amok_remoterr_t *error;
+ gras_error_t errcode;
+ va_list ap;
+
+ error=gras_new(amok_remoterr_t,1);
+ error->code=param_errcode;
+ error->msg=(char*)gras_malloc(1024); /* FIXME */
va_start(ap,format);
- vsprintf(error->errmsg,format,ap);
+ vsnprintf(error->msg,1024,format,ap);
va_end(ap);
- /* FIXME: If message id have more than 17 sequences, the following won't work */
- if (gras_msg_new_and_send(sock,id,SeqCount, error,1,NULL,0,NULL,0,NULL,0,NULL,0,NULL,0,NULL,0,
- NULL,0,NULL,0,NULL,0,NULL,0,NULL,0,NULL,0,NULL,0,NULL,0,NULL,0,NULL,0)) {
- fprintf(stderr,severeError);
+ 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,
+ gras_socket_peer_name(sock),gras_socket_peer_port(sock) );
}
}
+
+void amok_base_init(void) {
+ gras_datadesc_type_t *host_desc, *remoterr_desc;
+
+ /* Build the datatype descriptions */
+ host_desc = gras_datadesc_struct("gras_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);
+
+ remoterr_desc = gras_datadesc_struct("amok_remoterr_t");
+ gras_datadesc_struct_append(remoterr_desc,"msg",gras_datadesc_by_name("string"));
+ gras_datadesc_struct_append(remoterr_desc,"code",gras_datadesc_by_name("unsigned int"));
+ gras_datadesc_struct_close(remoterr_desc);
+ remoterr_desc = gras_datadesc_ref("amok_remoterr_t*",remoterr_desc);
+}
+
+void amok_base_exit(void) {
+ /* No real module mecanism in GRAS so far, nothing to do. */
+}
+
res=gras_new(gras_cbps_t,1);
- gras_dynar_new(&(res->lints), sizeof(int), NULL);
- gras_dict_new(&(res->space));
+ res->lints = gras_dynar_new(sizeof(int), NULL);
+ res->space = gras_dict_new();
/* no leak, the content is freed manually on block_end */
- gras_dynar_new(&(res->frames), sizeof(gras_dynar_t*), NULL);
- gras_dynar_new(&(res->globals), sizeof(char*), NULL);
+ res->frames = gras_dynar_new(sizeof(gras_dynar_t*), NULL);
+ res->globals = gras_dynar_new(sizeof(char*), NULL);
gras_cbps_block_begin(res);
if (errcode == mismatch_error) {
DEBUG1("Create a new variable stack for '%s' into the space",name);
- gras_dynar_new(&varstack, sizeof (gras_cbps_elm_t *), NULL);
+ varstack = gras_dynar_new(sizeof (gras_cbps_elm_t *), NULL);
gras_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) {
errcode = gras_dict_get(ps->space, name, (void **)&p_dynar);
if (errcode == mismatch_error) {
- gras_dynar_new(&p_dynar, sizeof (gras_cbps_elm_t *), NULL);
+ p_dynar = gras_dynar_new(sizeof (gras_cbps_elm_t *), NULL);
gras_dict_set(ps->space, name, (void **)p_dynar, NULL);
p_elm = gras_new0(gras_cbps_elm_t,1);
gras_dynar_t *p_dynar = NULL;
DEBUG0(">>> Block begin");
- gras_dynar_new(&p_dynar, sizeof (char *), NULL);
+ p_dynar = gras_dynar_new(sizeof (char *), NULL);
gras_dynar_push(ps->frames, &p_dynar);
}
VERB0("Initializing DataDesc");
- gras_set_new(&gras_datadesc_set_local);
+ gras_datadesc_set_local = gras_set_new();
ddt = gras_datadesc_scalar("signed char",
gras_ddt_scalar_char,
#ifndef GRAS_DATADESC_PRIVATE_H
#define GRAS_DATADESC_PRIVATE_H
-#include "gras_private.h"
-#include "gras/DataDesc/datadesc_interface.h"
+#include "xbt/sysdep.h"
+#include "xbt/log.h"
+#include "xbt/error.h"
+#include "xbt/dynar.h"
+#include "xbt/dict.h"
+#include "xbt/set.h"
+
+#include "gras_config.h" /* GRAS_THISARCH */
+
+#include "gras/transport.h" /* socket handling */
+
+#include "gras_modinter.h" /* module init/exit */
+#include "gras/datadesc.h" /* rest of module public interface */
+
+#include "gras/DataDesc/datadesc_interface.h" /* semi-public API */
/**
* aligned:
gras_datadesc_type_cb_void_t send;
gras_datadesc_type_cb_void_t recv;
+
+ int cycle; /* true if the datatype may contain cycle */
};
/***************************
/* 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 "xbt/misc.h" /* min()/max() */
#include "gras/DataDesc/datadesc_private.h"
GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(ddt_create,datadesc,"Creating new datadescriptions");
}
}
-static void
-gras_ddt_new(const char *name,
- gras_datadesc_type_t **dst) {
+static gras_datadesc_type_t *gras_ddt_new(const char *name) {
gras_error_t errcode;
gras_datadesc_type_t *res;
res->name = (char*)strdup(name);
res->name_len = strlen(name);
+ res->cycle = 0;
- *dst=res;
gras_set_add(gras_datadesc_set_local,
(gras_set_elm_t*)res,&gras_ddt_freev);
GRAS_OUT;
+ return res;
}
/**
VERB1("Discarding redefinition of %s",name);
return res;
}
- gras_ddt_new(name,&res);
+ res = gras_ddt_new(name);
for (arch = 0; arch < gras_arch_count; arch ++) {
long int sz;
VERB1("Discarding redefinition of %s",name);
return res;
}
- gras_ddt_new(name,&res);
+ res = gras_ddt_new(name);
for (arch=0; arch<gras_arch_count; arch ++) {
res->size[arch] = 0;
res->aligned_size[arch] = 0;
}
res->category_code = e_gras_datadesc_type_cat_struct;
- gras_dynar_new(&(res->category.struct_data.fields),
- sizeof(gras_dd_cat_field_t*),
- &gras_dd_cat_field_free);
+ res->category.struct_data.fields =
+ gras_dynar_new(sizeof(gras_dd_cat_field_t*),
+ &gras_dd_cat_field_free);
GRAS_OUT;
return res;
struct_type->category.struct_data.closed = 1;
}
+/**
+ * gras_datadesc_cycle_set:
+ *
+ * Tell GRAS that the pointers of the type described by @ddt may present
+ * some loop, and that the cycle detection mecanism is needed.
+ *
+ * Note that setting this option when not needed have a rather bad effect
+ * on the performance (several times slower on big data).
+ */
+void
+gras_datadesc_cycle_set(gras_datadesc_type_t *ddt) {
+ ddt->cycle = 1;
+}
+/**
+ * gras_datadesc_cycle_unset:
+ *
+ * Tell GRAS that the pointers of the type described by @ddt do not present
+ * any loop and that cycle detection mecanism are not needed.
+ * (default)
+ */
+void
+gras_datadesc_cycle_unset(gras_datadesc_type_t *ddt) {
+ ddt->cycle = 0;
+}
+
/**
* gras_datadesc_union:
*
return res;
}
- gras_ddt_new(name,&res);
+ res = gras_ddt_new(name);
for (arch=0; arch<gras_arch_count; arch ++) {
res->size[arch] = 0;
}
res->category_code = e_gras_datadesc_type_cat_union;
- gras_dynar_new(&(res->category.union_data.fields),
- sizeof(gras_dd_cat_field_t*),
- &gras_dd_cat_field_free);
+ res->category.union_data.fields =
+ gras_dynar_new(sizeof(gras_dd_cat_field_t*),
+ &gras_dd_cat_field_free);
res->category.union_data.selector = selector;
return res;
return res;
}
- gras_ddt_new(name,&res);
+ res = gras_ddt_new(name);
gras_assert0(pointer_type, "Cannot get the description of data pointer");
VERB1("Discarding redefinition of %s",name);
return res;
}
- gras_ddt_new(name,&res);
+ res = gras_ddt_new(name);
gras_assert0(pointer_type, "Cannot get the description of data pointer");
return res;
}
- gras_ddt_new(name,&res);
+ res = gras_ddt_new(name);
gras_assert1(fixed_size > 0, "'%s' is a array of null fixed size",name);
for (arch=0; arch<gras_arch_count; arch ++) {
return res;
}
- gras_ddt_new(name,&res);
+ res = gras_ddt_new(name);
for (arch=0; arch<gras_arch_count; arch ++) {
res->size[arch] = 0; /* make sure it indicates "dynamic" */
GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(ddt_exchange,datadesc,
"Sending data over the network");
-
-#undef DETECT_CYCLE
-/* CRUDE HACK to turn all cycle detection of */
-#ifndef DETECT_CYCLE
-#define gras_dict_get_ext(a,b,c,d) mismatch_error
-#define gras_dict_set_ext(a,b,c,d,e) no_error
-#endif
-
const char *gras_datadesc_cat_names[9] = {
"undefined",
"scalar", "struct", "union", "ref", "array", "ignored",
static _GRAS_INLINE gras_error_t
gras_dd_alloc_ref(gras_dict_t *refs, long int size,
char **r_ref, long int r_len,
- char **l_ref);
-static _GRAS_INLINE int
+ char **l_ref, int detect_cycle);
+
+static _GRAS_INLINE int
gras_dd_is_r_null(char **r_ptr, long int length);
static gras_error_t
gras_cbps_t *state,
gras_dict_t *refs,
gras_datadesc_type_t *type,
- char *data);
+ char *data,
+ int detect_cycle);
static gras_error_t
gras_datadesc_recv_rec(gras_socket_t *sock,
gras_cbps_t *state,
char **r_data,
long int r_lgr,
char *dst,
- int subsize);
+ int subsize,
+ int detect_cycle);
static _GRAS_INLINE gras_error_t
long int size,
char **r_ref,
long int r_len, /* pointer_type->size[r_arch] */
- char **l_ref) {
+ char **l_ref,
+ int detect_cycle) {
char *l_data = NULL;
gras_assert1(size>0,"Cannot allocate %ld bytes!", size);
DEBUG3("alloc_ref: r_ref=%p; *r_ref=%p, r_len=%ld",
(void*)r_ref, (void*)(r_ref?*r_ref:NULL), r_len);
-#ifdef DETECT_CYCLE
- if (r_ref && !gras_dd_is_r_null( r_ref, 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 *));
DEBUG2("Insert %p under %p",*(void**)ptr, *(void**)r_ref);
- TRY(gras_dict_set_ext(refs,(const char *) r_ref, r_len, ptr, gras_free));
+ if (detect_cycle)
+ gras_dict_set_ext(refs,(const char *) r_ref, r_len, ptr, gras_free);
}
-#endif
return no_error;
}
gras_cbps_t *state,
gras_dict_t *refs,
gras_datadesc_type_t *type,
- char *data) {
+ char *data,
+ int detect_cycle) {
gras_error_t errcode;
int cpt;
field->pre(state,field_data);
VERB1("Send field %s",field->name);
- TRY(gras_datadesc_send_rec(sock,state,refs,sub_type, field_data));
+ TRY(gras_datadesc_send_rec(sock,state,refs,sub_type, field_data, detect_cycle || sub_type->cycle));
if (field->post)
field->post(state,field_data);
if (field->pre)
field->pre(state,data);
- TRY(gras_datadesc_send_rec(sock,state,refs, sub_type, data));
+ TRY(gras_datadesc_send_rec(sock,state,refs, sub_type, data, detect_cycle || sub_type->cycle));
if (field->post)
field->post(state,data);
gras_dd_cat_ref_t ref_data;
void **ref=(void**)data;
-#ifdef DETECT_CYCLE
void *dummy;
-#endif
ref_data = type->category.ref_data;
VERB0("Not sending NULL referenced data");
break;
}
- errcode = gras_dict_get_ext(refs,(char*)ref, sizeof(void*), &dummy);
+ errcode = detect_cycle
+ ? gras_dict_get_ext(refs,(char*)ref, sizeof(void*), &dummy)
+ : mismatch_error;
if (errcode == mismatch_error) {
- VERB1("Sending data referenced at %p", (void*)*ref);
- TRY(gras_dict_set_ext(refs, (char*)ref, sizeof(void*), ref, NULL));
- TRY(gras_datadesc_send_rec(sock,state,refs, sub_type, *ref));
-
+ VERB1("Sending data referenced at %p", (void*)*ref);
+ if (detect_cycle)
+ gras_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) {
- VERB1("Not sending data referenced at %p (already done)", (void*)*ref);
+ VERB1("Not sending data referenced at %p (already done)", (void*)*ref);
} else {
- return errcode;
+ return errcode;
}
break;
sub_type->aligned_size[GRAS_THISARCH] * count));
} else {
for (cpt=0; cpt<count; cpt++) {
- TRY(gras_datadesc_send_rec(sock,state,refs, sub_type, ptr));
+ TRY(gras_datadesc_send_rec(sock,state,refs, sub_type, ptr, detect_cycle || sub_type->cycle));
ptr += elm_size;
}
}
gras_cbps_t *state = NULL;
gras_dict_t *refs; /* all references already sent */
- gras_dict_new(&refs);
+ refs = gras_dict_new();
state = gras_cbps_new();
- errcode = gras_datadesc_send_rec(sock,state,refs,type,(char*)src);
+ errcode = gras_datadesc_send_rec(sock,state,refs,type,(char*)src, type->cycle);
gras_dict_free(&refs);
gras_cbps_free(&state);
char **r_data,
long int r_lgr,
char *l_data,
- int subsize) {
+ int subsize,
+ int detect_cycle) {
gras_error_t errcode;
int cpt;
TRY(gras_datadesc_recv_rec(sock,state,refs, sub_type,
r_arch,NULL,0,
- field_data,-1));
+ field_data,-1,
+ detect_cycle || sub_type->cycle));
}
VERB1("<< Received all fields of the structure %s", type->name);
TRY(gras_datadesc_recv_rec(sock,state,refs, sub_type,
r_arch,NULL,0,
- l_data,-1));
+ l_data,-1,
+ detect_cycle || sub_type->cycle));
break;
}
gras_free(r_ref);
break;
}
- errcode = gras_dict_get_ext(refs,
+
+ errcode = detect_cycle
+ ? gras_dict_get_ext(refs,
(char*)r_ref, pointer_type->size[r_arch],
- (void**)&l_ref);
-
+ (void**)&l_ref)
+ : mismatch_error;
if (errcode == mismatch_error) {
int subsubcount = 0;
TRY(gras_dd_alloc_ref(refs,
subsub_type->size[GRAS_THISARCH] * subsubcount,
r_ref,pointer_type->size[r_arch],
- (char**)&l_referenced));
+ (char**)&l_referenced,
+ detect_cycle));
} else {
TRY(gras_dd_alloc_ref(refs,sub_type->size[GRAS_THISARCH],
r_ref,pointer_type->size[r_arch],
- (char**)&l_referenced));
+ (char**)&l_referenced,
+ detect_cycle));
}
TRY(gras_datadesc_recv_rec(sock,state,refs, sub_type,
r_arch,r_ref,pointer_type->size[r_arch],
- (char*)l_referenced, subsubcount));
+ (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);
ptr = l_data;
for (cpt=0; cpt<count; cpt++) {
TRY(gras_datadesc_recv_rec(sock,state,refs, sub_type,
- r_arch, NULL, 0, ptr,-1));
+ r_arch, NULL, 0, ptr,-1,
+ detect_cycle || sub_type->cycle));
ptr += elm_size;
}
}
gras_cbps_t *state = NULL; /* callback persistent state */
gras_dict_t *refs; /* all references already sent */
- gras_dict_new(&refs);
+ refs = gras_dict_new();
state = gras_cbps_new();
errcode = gras_datadesc_recv_rec(sock, state, refs, type,
r_arch, NULL, 0,
- (char *) dst,-1);
+ (char *) dst,-1,
+ type->cycle);
gras_dict_free(&refs);
gras_cbps_free(&state);
gras_datadesc_type_t *struct_type;
GRAS_IN;
- gras_dynar_new(&identifiers,sizeof(identifier_t),NULL);
- gras_dynar_new(&fields_to_push,sizeof(char*),NULL);
+ identifiers = gras_dynar_new(sizeof(identifier_t),NULL);
+ fields_to_push = gras_dynar_new(sizeof(char*),NULL);
/* Create the struct descriptor */
if (gras_ddt_parse_tok_num == GRAS_DDT_PARSE_TOKEN_WORD) {
VERB0("Initializing Msg");
- gras_set_new(&_gras_msgtype_set);
+ _gras_msgtype_set = gras_set_new();
memcpy(GRAS_header,"GRAS", 4);
GRAS_header[4]=GRAS_PROTOCOL_VERSION;
/* First cb? Create room */
list = gras_new(gras_cblist_t,1);
list->id = msgtype->code;
- gras_dynar_new(&(list->cbs), sizeof(gras_cb_t), NULL);
+ list->cbs = gras_dynar_new(sizeof(gras_cb_t), NULL);
gras_dynar_push(pd->cbl_list,&list);
}
#ifndef GRAS_MESSAGE_PRIVATE_H
#define GRAS_MESSAGE_PRIVATE_H
-#include "gras_private.h"
+#include "gras_config.h"
+
+#include "xbt/sysdep.h"
+#include "xbt/log.h"
+#include "xbt/error.h"
+#include "xbt/dynar.h"
+#include "xbt/set.h"
+#include "gras/transport.h"
+#include "gras/datadesc.h"
+#include "gras/virtu.h"
+
+#include "gras/messages.h"
+#include "gras_modinter.h"
+
#include "gras/Msg/msg_interface.h"
/**
}
-void
-gras_trp_init(void){
-
+void gras_trp_init(void){
/* make room for all plugins */
- gras_dict_new(&_gras_trp_plugins);
+ _gras_trp_plugins=gras_dict_new();
/* Add them */
gras_trp_plugin_new("tcp", gras_trp_tcp_setup);
gras_error_t gras_socket_raw_send(gras_socket_t *peer,
unsigned int timeout,
- unsigned long int expSize,
- unsigned long int msgSize) {
-
+ unsigned long int exp_size,
+ unsigned long int msg_size) {
+ gras_error_t errcode;
+ char *chunk = gras_malloc(msg_size);
+ int exp_sofar;
+
gras_assert0(peer->raw,"Asked to send raw data on a regular socket\n");
- return gras_socket_raw_exchange(peer,1,timeout,expSize,msgSize);
+ for (exp_sofar=0; exp_sofar < exp_size; exp_sofar += msg_size) {
+ TRY(gras_trp_chunk_send(peer,chunk,msg_size));
+ }
+
+ gras_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,
unsigned int timeout,
- unsigned long int expSize,
- unsigned long int msgSize){
+ unsigned long int exp_size,
+ unsigned long int msg_size){
+ gras_error_t errcode;
+ char *chunk = gras_malloc(msg_size);
+ int exp_sofar;
+
gras_assert0(peer->raw,"Asked to recveive raw data on a regular socket\n");
- return gras_socket_raw_exchange(peer,0,timeout,expSize,msgSize);
+ for (exp_sofar=0; exp_sofar < exp_size; exp_sofar += msg_size) {
+ TRY(gras_trp_chunk_send(peer,chunk,msg_size));
+ }
+
+ gras_free(chunk);
+ return no_error;//gras_socket_raw_exchange(peer,0,timeout,expSize,msgSize);
}
#include <stdlib.h>
#include <string.h> /* memset */
-#include "gras_private.h"
+#include "xbt/misc.h"
#include "transport_private.h"
GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(trp_buf,transport,
#include <fcntl.h>
#include <unistd.h>
-#include "gras_private.h"
#include "transport_private.h"
GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(trp_file,transport,
#include <msg.h>
-#include "gras_private.h"
#include "transport_private.h"
#include "gras/Virtu/virtu_sg.h"
#include <stdlib.h>
#include <string.h> /* memset */
-#include "gras_private.h"
#include "transport_private.h"
GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(trp_tcp,transport,"TCP transport");
struct timeval timeOut;
chunk = gras_malloc(msg_size);
-
- for (exp_sofar=0; exp_sofar < exp_size; exp_size += msg_sofar) {
- for(msg_sofar=0; msg_sofar < msg_size; msg_size += res_last) {
+
+ for (exp_sofar=0; exp_sofar < exp_size; exp_sofar += msg_size) {
+ for(msg_sofar=0; msg_sofar < msg_size; msg_sofar += res_last) {
if(sender) {
res_last = send(peer->sd, chunk, msg_size - msg_sofar, 0);
#ifndef GRAS_TRP_PRIVATE_H
#define GRAS_TRP_PRIVATE_H
-#include "gras_private.h"
-#include "gras/Transport/transport_interface.h"
+#include "xbt/sysdep.h"
+#include "xbt/log.h"
+#include "xbt/error.h"
+#include "xbt/dynar.h"
+#include "xbt/dict.h"
+
+#include "gras/cond.h" /* gras_if_RL() */
+
+#include "gras_modinter.h" /* module init/exit */
+#include "gras/transport.h" /* rest of module interface */
+
+#include "gras/Transport/transport_interface.h" /* semi-public API */
#include "gras/Virtu/virtu_interface.h" /* socketset_get() */
/**
/* 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 "gras_private.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"
+
#include "gras/Virtu/virtu_interface.h"
#include "gras/Msg/msg_interface.h" /* FIXME: Get rid of this cyclic */
void
gras_procdata_init() {
gras_procdata_t *pd=gras_procdata_get();
- pd->userdata = NULL;
- gras_dynar_new(&(pd->msg_queue), sizeof(gras_msg_t), NULL);
- gras_dynar_new(&(pd->cbl_list), sizeof(gras_cblist_t *),gras_cbl_free);
- gras_dynar_new(&(pd->sockets), sizeof(gras_socket_t*), NULL);
+ pd->userdata = NULL;
+ pd->msg_queue = gras_dynar_new(sizeof(gras_msg_t), NULL);
+ pd->cbl_list = gras_dynar_new(sizeof(gras_cblist_t *),gras_cbl_free);
+ pd->sockets = gras_dynar_new(sizeof(gras_socket_t*), NULL);
}
void
/* 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 "gras/cond.h"
#include "gras/Virtu/virtu_rl.h"
int gras_if_RL(void) {
/* 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 "gras_private.h"
+#include "xbt/sysdep.h"
+#include "gras/virtu.h"
#include <sys/time.h> /* gettimeofday() */
double gras_os_time() {
/* 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 "gras/cond.h"
#include "gras/Virtu/virtu_sg.h"
int gras_if_RL(void) {
if (!hd) {
hd=gras_new(gras_hostdata_t,1);
- gras_dynar_new(&(hd->ports),sizeof(gras_sg_portrec_t),NULL);
+ hd->ports = gras_dynar_new(sizeof(gras_sg_portrec_t),NULL);
memset(hd->proc, 0, sizeof(hd->proc[0]) * GRAS_MAX_CHANNEL);
#ifndef GRAS_VIRTU_INTERFACE_H
#define GRAS_VIRTU_INTERFACE_H
+#include "xbt/sysdep.h"
+#include "xbt/log.h"
+#include "xbt/error.h"
+#include "xbt/dynar.h"
+#include "gras/virtu.h"
+#include "gras/process.h"
+
/**
* gras_process_data_t:
*
#ifndef VIRTU_RL_H
#define VIRTU_RL_H
-#include "gras_private.h"
#include "gras/Virtu/virtu_interface.h"
#endif /* VIRTU_RL_H */
#ifndef VIRTU_SG_H
#define VIRTU_SG_H
-#include "gras_private.h"
#include "gras/Virtu/virtu_interface.h"
#include <msg.h> /* SimGrid header */
+++ /dev/null
-/* $Id$ */
-
-/* gras_private.h - GRAS private definitions */
-
-/* Authors: Martin Quinson */
-/* Copyright (C) 2003 the OURAGAN project. */
-
-/* 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_PRIVATE_H
-#define GRAS_PRIVATE_H
-
-#define max(a, b) (((a) > (b))?(a):(b))
-#define min(a, b) (((a) < (b))?(a):(b))
-
-#define TRUE 1
-#define FALSE 0
-
-#define GRAS_MAX_CHANNEL 10 /* FIXME: killme */
-
-#include "gras_config.h"
-
-#include "xbt/sysdep.h"
-
-#include "xbt/error.h"
-#include "xbt/log.h"
-#include "xbt/module.h"
-#include "xbt/dynar.h"
-#include "xbt/dict.h"
-#include "xbt/set.h"
-#include "xbt/config.h"
-
-#include "gras/core.h"
-#include "gras/process.h"
-#include "gras/virtu.h"
-#include "gras/cond.h"
-
-#include "gras/transport.h"
-#include "gras/datadesc.h"
-#include "gras/messages.h"
-
-/* modules initialization functions */
-void gras_msg_init(void);
-void gras_msg_exit(void);
-void gras_trp_init(void);
-void gras_trp_exit(void);
-void gras_datadesc_init(void);
-void gras_datadesc_exit(void);
-
-#endif /* GRAS_PRIVATE_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. */
-#include "gras_private.h" /* prototypes of this module */
+#include "xbt/misc.h"
+#include "xbt/sysdep.h"
+#include "xbt/log.h"
+#include "xbt/error.h"
+#include "xbt/dynar.h"
+#include "xbt/dict.h"
-GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(config,gros,"configuration support");
+#include "xbt/config.h" /* prototypes of this module */
+
+GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(config,xbt,"configuration support");
/* gras_cfgelm_t: the typedef corresponding to a config cell.
*/
-void gras_cfg_new(gras_cfg_t **whereto) {
- gras_dict_new((gras_dict_t**)whereto);
+gras_cfg_t *gras_cfg_new(void) {
+ return (gras_cfg_t *)gras_dict_new();
}
/**
switch (type) {
case gras_cfgelm_int:
- gras_dynar_new(&(res->content), sizeof(int), NULL);
+ res->content = gras_dynar_new(sizeof(int), NULL);
break;
case gras_cfgelm_double:
- gras_dynar_new(&(res->content), sizeof(double), NULL);
+ res->content = gras_dynar_new(sizeof(double), NULL);
break;
case gras_cfgelm_string:
- gras_dynar_new(&(res->content),sizeof(char*),&gras_cfg_str_free);
+ res->content = gras_dynar_new(sizeof(char*),&gras_cfg_str_free);
break;
case gras_cfgelm_host:
- gras_dynar_new(&(res->content),sizeof(gras_host_t*),&gras_cfg_host_free);
+ res->content = gras_dynar_new(sizeof(gras_host_t*),&gras_cfg_host_free);
break;
default:
/* 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 "gras_private.h"
#include "dict_private.h"
#include <stdlib.h> /* malloc() */
#include <stdio.h>
-GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(dict,gros,
+GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(dict,xbt,
"Dictionaries provide the same functionnalities than hash tables");
/*####[ Private prototypes ]#################################################*/
*
* Creates and initialize a new dictionnary
*/
-void
-gras_dict_new(gras_dict_t **whereto) {
-
- (*whereto) = gras_new(gras_dict_t,1);
- (*whereto)->head=NULL;
-
+gras_dict_t *
+gras_dict_new(void) {
+ gras_dict_t *res= gras_new(gras_dict_t,1);
+ res->head=NULL;
+ return res;
}
/**
* gras_dict_free:
/* 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 "gras_private.h"
+#include "xbt/misc.h"
#include "dict_private.h"
#include <string.h> /* strlen() */
*
* Structure creator
*/
-void
-gras_dict_cursor_new(const gras_dict_t *p_head,
- /*OUT*/gras_dict_cursor_t **pp_cursor) {
+gras_dict_cursor_t *
+gras_dict_cursor_new(const gras_dict_t *p_head) {
gras_error_t errcode = no_error;
- gras_dict_cursor_t *p_cursor = NULL;
-
- p_cursor = gras_new(gras_dict_cursor_t,1);
-
- gras_dynar_new(&p_cursor->keys, sizeof(char **), NULL);
- gras_dynar_new(&p_cursor->key_lens, sizeof(int *), NULL);
-
- p_cursor->pos = 0;
- p_cursor->pos_len = 0;
- p_cursor->head = p_head ? p_head->head : NULL;
+ gras_dict_cursor_t *res = NULL;
- gras_dict_cursor_rewind(p_cursor);
+ res = gras_new(gras_dict_cursor_t,1);
+ res->keys = gras_dynar_new(sizeof(char **), NULL);
+ res->key_lens = gras_dynar_new(sizeof(int *), NULL);
+ res->pos = 0;
+ res->pos_len = 0;
+ res->head = p_head ? p_head->head : NULL;
- *pp_cursor = p_cursor;
+ gras_dict_cursor_rewind(res);
+ return res;
}
/**
*
* Create the cursor if it does not exists. Rewind it in any case.
*/
-void gras_dict_cursor_first (const gras_dict_t *dict,
- gras_dict_cursor_t **cursor){
+void gras_dict_cursor_first (const gras_dict_t *dict,
+ gras_dict_cursor_t **cursor){
if (!*cursor) {
DEBUG0("Create the cursor on first use");
- gras_dict_cursor_new(dict,cursor);
+ *cursor=gras_dict_cursor_new(dict);
}
gras_dict_cursor_rewind(*cursor);
/* 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 "gras_private.h"
#include "dict_private.h" /* prototypes of this module */
GRAS_LOG_EXTERNAL_CATEGORY(dict);
p_elm->offset = offset;
p_elm->content = data;
p_elm->free_ctn = free_ctn;
-
- gras_dynar_new(&(p_elm->sub), sizeof(gras_dictelm_t*), _dictelm_wrapper_free);
+ p_elm->sub = gras_dynar_new(sizeof(gras_dictelm_t*), _dictelm_wrapper_free);
*pp_elm = p_elm;
#ifndef _GRAS_DICT_ELM_T_
#define _GRAS_DICT_ELM_T_
+#include "xbt/sysdep.h"
+#include "xbt/log.h"
+#include "xbt/error.h"
+#include "xbt/dynar.h"
+#include "xbt/dict.h"
+
/*####[ Type definition ]####################################################*/
typedef struct gras_dictelm_ {
char *key;
/* 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 "gras_private.h"
+#include "xbt/misc.h"
+#include "xbt/sysdep.h"
+#include "xbt/log.h"
+#include "xbt/error.h"
+#include "xbt/dynar.h"
#include <sys/types.h>
-GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(dynar,gros,"Dynamic arrays");
+GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(dynar,xbt,"Dynamic arrays");
struct gras_dynar_s {
- size_t size;
- size_t used;
- size_t elmsize;
+ unsigned long size;
+ unsigned long used;
+ unsigned long elmsize;
void *data;
void_f_pvoid_t *free;
};
static _GRAS_INLINE
void _gras_clear_mem(void * const ptr,
- const size_t length) {
+ const unsigned long length) {
memset(ptr, 0, length);
}
_gras_dynar_expand(gras_dynar_t * const dynar,
const int nb) {
gras_error_t errcode = no_error;
- const size_t old_size = dynar->size;
+ const unsigned long old_size = dynar->size;
if (nb > old_size) {
char * const old_data = dynar->data;
- const size_t elmsize = dynar->elmsize;
- const size_t old_length = old_size*elmsize;
+ const unsigned long elmsize = dynar->elmsize;
+ const unsigned long old_length = old_size*elmsize;
- const size_t used = dynar->used;
- const size_t used_length = used*elmsize;
+ const unsigned long used = dynar->used;
+ const unsigned long used_length = used*elmsize;
- const size_t new_size = nb > (2*(old_size+1)) ? nb : (2*(old_size+1));
- const size_t new_length = new_size*elmsize;
+ const unsigned long new_size = nb > (2*(old_size+1)) ? nb : (2*(old_size+1));
+ const unsigned long new_length = new_size*elmsize;
char * const new_data = gras_malloc0(elmsize*new_size);
DEBUG3("expend %p from %lu to %d elements", (void*)dynar, (unsigned long)old_size, nb);
static _GRAS_INLINE
void *
_gras_dynar_elm(const gras_dynar_t * const dynar,
- const size_t idx) {
+ const unsigned long idx) {
char * const data = dynar->data;
- const size_t elmsize = dynar->elmsize;
+ const unsigned long elmsize = dynar->elmsize;
return data + idx*elmsize;
}
void
_gras_dynar_get_elm(void * const dst,
const gras_dynar_t * const dynar,
- const size_t idx) {
+ const unsigned long idx) {
void * const elm = _gras_dynar_elm(dynar, idx);
- const size_t elmsize = dynar->elmsize;
+ const unsigned long elmsize = dynar->elmsize;
memcpy(dst, elm, elmsize);
}
static _GRAS_INLINE
void
_gras_dynar_put_elm(const gras_dynar_t * const dynar,
- const size_t idx,
+ const unsigned long idx,
const void * const src) {
void * const elm = _gras_dynar_elm(dynar, idx);
- const size_t elmsize = dynar->elmsize;
+ const unsigned long elmsize = dynar->elmsize;
memcpy(elm, src, elmsize);
}
/**
* gras_dynar_new:
- * @whereto: pointer to where the dynar should be created
* @elm_size: size of each element in the dynar
* @free_func: function to call each time we want to get rid of an element (or NULL if nothing to do).
*
* pointer of pointer. That is to say that dynars can contain either base
* types (int, char, double, etc) or pointer of pointers (struct **).
*/
-void
-gras_dynar_new(gras_dynar_t ** const p_dynar,
- const size_t elmsize,
- void_f_pvoid_t * const free_func) {
+gras_dynar_t *
+gras_dynar_new(const unsigned long elmsize,
+ void_f_pvoid_t * const free_func) {
gras_dynar_t *dynar = gras_new0(gras_dynar_t,1);
dynar->data = NULL;
dynar->free = free_func;
- *p_dynar = dynar;
+ return dynar;
}
/**
__check_sloppy_inbound_idx(dynar, idx);
{
- const size_t old_used = dynar->used;
- const size_t new_used = old_used + 1;
+ const unsigned long old_used = dynar->used;
+ const unsigned long new_used = old_used + 1;
_gras_dynar_expand(dynar, new_used);
{
- const size_t nb_shift = old_used - idx;
- const size_t elmsize = dynar->elmsize;
+ const unsigned long nb_shift = old_used - idx;
+ const unsigned long elmsize = dynar->elmsize;
- const size_t offset = nb_shift*elmsize;
+ const unsigned long offset = nb_shift*elmsize;
void * const elm_src = _gras_dynar_elm(dynar, idx);
void * const elm_dst = _gras_dynar_elm(dynar, idx+1);
_gras_dynar_get_elm(object, dynar, idx);
{
- const size_t old_used = dynar->used;
- const size_t new_used = old_used - 1;
+ const unsigned long old_used = dynar->used;
+ const unsigned long new_used = old_used - 1;
- const size_t nb_shift = old_used-1 - idx;
- const size_t elmsize = dynar->elmsize;
+ const unsigned long nb_shift = old_used-1 - idx;
+ const unsigned long elmsize = dynar->elmsize;
- const size_t offset = nb_shift*elmsize;
+ const unsigned long offset = nb_shift*elmsize;
void * const elm_src = _gras_dynar_elm(dynar, idx+1);
void * const elm_dst = _gras_dynar_elm(dynar, idx);
{
char elm[64];
- const size_t used = dynar->used;
- size_t i = 0;
+ const unsigned long used = dynar->used;
+ unsigned long i = 0;
for (i = 0; i < used; i++) {
_gras_dynar_get_elm(elm, dynar, i);
/* 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 "gras_private.h"
+#include "xbt/error.h"
/**
* gras_error_name:
/* 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 "xbt_interface.h"
-#include "gras_private.h"
#include <stdarg.h>
-#include <assert.h>
#include <ctype.h>
+#include "xbt_modinter.h"
+
+#include "xbt/misc.h"
+#include "xbt/sysdep.h"
+#include "xbt/log.h"
+#include "xbt/error.h"
+#include "xbt/dynar.h"
+
typedef struct {
char *catname;
gras_log_priority_t thresh;
};
GRAS_LOG_NEW_SUBCATEGORY(gras,GRAS_LOG_ROOT_CAT,"All GRAS categories");
-GRAS_LOG_NEW_SUBCATEGORY(gros,GRAS_LOG_ROOT_CAT,"All GROS categories (gras toolbox)");
-GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(log,gros,"Loggings from the logging mecanism itself");
+GRAS_LOG_NEW_SUBCATEGORY(xbt,GRAS_LOG_ROOT_CAT,"All XBT categories (gras toolbox)");
+GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(log,xbt,"Loggings from the logging mecanism itself");
static void _apply_control(gras_log_category_t* cat) {
while(*cpp != cat && *cpp != NULL) {
cpp = &(*cpp)->nextSibling;
}
- assert(*cpp == cat);
+ gras_assert(*cpp == cat);
*cpp = cat->nextSibling;
}
if (control_string == NULL)
return;
if (gras_log_settings == NULL)
- gras_dynar_new(&gras_log_settings,sizeof(gras_log_setting_t*),
- _free_setting);
+ gras_log_settings = gras_dynar_new(sizeof(gras_log_setting_t*),
+ _free_setting);
set = gras_new(gras_log_setting_t,1);
cs=gras_strdup(control_string);
/* 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 "gras_private.h"
+#include "xbt/sysdep.h"
+#include "xbt/log.h"
+#include "xbt/error.h"
#include <stdio.h>
GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(log_app,log,"default logging handler");
/* 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 "gras_private.h"
+#include "xbt/sysdep.h"
+#include "xbt/log.h"
+#include "xbt/error.h"
+#include "xbt/dynar.h"
+#include "xbt/config.h"
-GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(module,gros, "module handling");
+#include "gras/process.h" /* FIXME: bad loop */
+
+#include "xbt/module.h" /* this module */
+
+#include "xbt_modinter.h" /* prototype of other module's init/exit in XBT */
+#include "gras_modinter.h" /* same in GRAS */
+
+GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(module,xbt, "module handling");
-extern void gras_log_exit(void);
static int gras_running_process = 0;
struct gras_module_ {
/* 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 "gras_private.h"
+#include "xbt/misc.h"
+#include "xbt/sysdep.h"
+#include "xbt/log.h"
+#include "xbt/error.h"
+#include "xbt/dynar.h"
+#include "xbt/dict.h"
-GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(set,gros,"data container consisting in dict+dynar");
+#include "xbt/set.h"
+
+GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(set,xbt,"data container consisting in dict+dynar");
/*####[ Type definition ]####################################################*/
struct gras_set_ {
*
* Creates a new set.
*/
-void gras_set_new (gras_set_t **dst) {
+gras_set_t *gras_set_new (void) {
gras_set_t *res=gras_new(gras_set_t,1);
gras_error_t errcode;
- gras_dict_new (&(res->dict));
- gras_dynar_new(&(res->dynar), sizeof(void*),NULL);
+ res->dict=gras_dict_new ();
+ res->dynar=gras_dynar_new(sizeof(void*),NULL);
- *dst=res;
+ return res;
}
/**
/* 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 "gras_private.h"
+#include "xbt/sysdep.h"
+#include "xbt/log.h"
+#include "xbt/error.h"
#include <stdlib.h>
-GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(sysdep, gros, "System dependency");
+GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(sysdep, xbt, "System dependency");
/****
**** Memory management
+++ /dev/null
-/* $Id$ */
-
-/* core - very basic functionnalities of GRAS (logs, data container, ...) */
-
-/* module's public interface exported within GRAS, but not to end user. */
-
-/* Authors: Martin Quinson */
-/* Copyright (C) 2004 Martin Quinson. */
-
-/* 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 XBT_INTERFACE_H
-#define XBT_INTERFACE_H
-
-/* Modules definitions */
-void gras_log_exit(void);
-
-#endif /* XBT_INTERFACE_H */
i->l->l->l = i;
j = NULL;
+ gras_datadesc_cycle_set(gras_datadesc_by_name("chained_list_t*"));
TRY(write_read(gras_datadesc_by_name("chained_list_t*"),
&i,&j, sock,direction));
if (direction == READ || direction == RW) {
TRYFAIL(declare_chained_list_type());
TRYFAIL(test_chain_list(sock,direction));
- /* TRYFAIL(test_graph(sock,direction)); */
+ TRYFAIL(test_graph(sock,direction));
TRYFAIL(test_pbio(sock,direction));
gras_cfg_t *set=NULL;
gras_error_t errcode;
- gras_cfg_new(&set);
+ set = gras_cfg_new();
TRYFAIL(gras_cfg_register_str(set,"speed:1_to_2_int"));
TRYFAIL(gras_cfg_register_str(set,"hostname:1_to_1_string"));
TRYFAIL(gras_cfg_register_str(set,"user:1_to_10_string"));
printf(" (a point is a test)\n");
for (i=0;i<20;i++) {
- gras_dict_new(&head);
+ head=gras_dict_new();
if (i%10) printf("."); else printf("%d",i/10); fflush(stdout);
nb=0;
for (j=0;j<1000;j++) {
}
- gras_dict_new(&head);
+ head=gras_dict_new();
printf("\n Fill 20 000 elements, with keys being the number of element\n");
printf(" (a point is 1 000 elements)\n");
for (j=0;j<NB_ELM;j++) {
static void fill(gras_dict_t **head) {
printf("\n Fill in the dictionnary\n");
- gras_dict_new(head);
+ *head = gras_dict_new();
debuged_add(*head,"12");
debuged_add(*head,"12a");
debuged_add(*head,"12b");
gras_init_defaultlog(&argc,argv,"dynar.thresh=debug");
INFO0("==== Traverse the empty dynar");
- gras_dynar_new(&d,sizeof(int),NULL);
+ d=gras_dynar_new(sizeof(int),NULL);
gras_dynar_foreach(d,cursor,cpt){
gras_assert0(FALSE,
"Damnit, there is something in the empty dynar");
gras_dynar_free(d);
INFO0("==== Push/shift 5000 doubles");
- gras_dynar_new(&d,sizeof(double),NULL);
+ d=gras_dynar_new(sizeof(double),NULL);
for (cpt=0; cpt< 5000; cpt++) {
d1=(double)cpt;
gras_dynar_push(d,&d1);
INFO0("==== Unshift/pop 5000 doubles");
- gras_dynar_new(&d,sizeof(double),NULL);
+ d=gras_dynar_new(sizeof(double),NULL);
for (cpt=0; cpt< 5000; cpt++) {
d1=(double)cpt;
gras_dynar_unshift(d,&d1);
INFO0("==== Push 5000 doubles, insert 1000 doubles in the middle, shift everything");
- gras_dynar_new(&d,sizeof(double),NULL);
+ d=gras_dynar_new(sizeof(double),NULL);
for (cpt=0; cpt< 5000; cpt++) {
d1=(double)cpt;
gras_dynar_push(d,&d1);
INFO0("==== Push 5000 double, remove 2000-4000. free the rest");
- gras_dynar_new(&d,sizeof(double),NULL);
+ d=gras_dynar_new(sizeof(double),NULL);
for (cpt=0; cpt< 5000; cpt++) {
d1=(double)cpt;
gras_dynar_push(d,&d1);
gras_init_defaultlog(&argc,argv,"dynar.thresh=debug");
INFO0("==== Traverse the empty dynar");
- gras_dynar_new(&d,sizeof(int),NULL);
+ d=gras_dynar_new(sizeof(int),NULL);
gras_dynar_foreach(d,cursor,i){
gras_assert0(0,"Damnit, there is something in the empty dynar");
}
INFO1("==== Push %d int, set them again 3 times, traverse them, shift them",
NB_ELEM);
- gras_dynar_new(&d,sizeof(int),NULL);
+ d=gras_dynar_new(sizeof(int),NULL);
for (cpt=0; cpt< NB_ELEM; cpt++) {
gras_dynar_push(d,&cpt);
DEBUG2("Push %d, length=%lu",cpt, gras_dynar_length(d));
INFO1("==== Unshift/pop %d int",NB_ELEM);
- gras_dynar_new(&d,sizeof(int),NULL);
+ d=gras_dynar_new(sizeof(int),NULL);
for (cpt=0; cpt< NB_ELEM; cpt++) {
gras_dynar_unshift(d,&cpt);
DEBUG2("Push %d, length=%lu",cpt, gras_dynar_length(d));
INFO1("==== Push %d int, insert 1000 int in the middle, shift everything",NB_ELEM);
- gras_dynar_new(&d,sizeof(int),NULL);
+ d=gras_dynar_new(sizeof(int),NULL);
for (cpt=0; cpt< NB_ELEM; cpt++) {
gras_dynar_push(d,&cpt);
DEBUG2("Push %d, length=%lu",cpt, gras_dynar_length(d));
INFO1("==== Push %d int, remove 2000-4000. free the rest",NB_ELEM);
- gras_dynar_new(&d,sizeof(int),NULL);
+ d=gras_dynar_new(sizeof(int),NULL);
for (cpt=0; cpt< NB_ELEM; cpt++)
gras_dynar_push(d,&cpt);
gras_init_defaultlog(&argc,argv,"dynar.thresh=debug");
INFO0("==== Traverse the empty dynar");
- gras_dynar_new(&d,sizeof(char *),&free_string);
+ d=gras_dynar_new(sizeof(char *),&free_string);
gras_dynar_foreach(d,cpt,s1){
gras_assert0(FALSE,
"Damnit, there is something in the empty dynar");
gras_dynar_free(d);
INFO1("==== Push %d strings, set them again 3 times, shift them",NB_ELEM);
- gras_dynar_new(&d,sizeof(char*),&free_string);
+ d=gras_dynar_new(sizeof(char*),&free_string);
for (cpt=0; cpt< NB_ELEM; cpt++) {
sprintf(buf,"%d",cpt);
s1=strdup(buf);
INFO1("==== Unshift, traverse and pop %d strings",NB_ELEM);
- gras_dynar_new(&d,sizeof(char**),&free_string);
+ d=gras_dynar_new(sizeof(char**),&free_string);
for (cpt=0; cpt< NB_ELEM; cpt++) {
sprintf(buf,"%d",cpt);
s1=strdup(buf);
INFO2("==== Push %d strings, insert %d strings in the middle, shift everything",NB_ELEM,NB_ELEM/5);
- gras_dynar_new(&d,sizeof(char*),&free_string);
+ d=gras_dynar_new(sizeof(char*),&free_string);
for (cpt=0; cpt< NB_ELEM; cpt++) {
sprintf(buf,"%d",cpt);
s1=strdup(buf);
INFO3("==== Push %d strings, remove %d-%d. free the rest",NB_ELEM,2*(NB_ELEM/5),4*(NB_ELEM/5));
- gras_dynar_new(&d,sizeof(char*),&free_string);
+ d=gras_dynar_new(sizeof(char*),&free_string);
for (cpt=0; cpt< NB_ELEM; cpt++) {
sprintf(buf,"%d",cpt);
s1=strdup(buf);
static void fill(gras_set_t **set) {
printf("\n Fill in the data set\n");
- gras_set_new(set);
+ *set=gras_set_new();
debuged_add(*set,"12");
debuged_add(*set,"12a");
debuged_add(*set,"12b");