Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Reduce overengeneering around datadesc, put stubs in place so that the kernel compile...
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 3 Feb 2004 23:35:05 +0000 (23:35 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 3 Feb 2004 23:35:05 +0000 (23:35 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@26 48e7efb5-ca39-0410-a469-dd3cf9ba447f

14 files changed:
configure
cruft/doc/gras-sections.txt
cruft/doc/tmpl/core_dico.sgml
include/Makefile.am
include/datadesc.h
include/datadesc_simple.h [new file with mode: 0644]
include/error.h
include/gras.h
include/messages.h
include/transport.h [new file with mode: 0644]
src/gras/Makefile.am
src/gras/SG/gras_sg.c
src/gras/gras_private.h
testsuite/xbt/dynar_string.c

index 7121fe3..b642979 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
 #! /bin/sh
-# From configure.ac Revision: 1.1.1.1 .
+# From configure.ac Revision: 1.2 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.59 for GRAS 0.0.040129.
 #
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.59 for GRAS 0.0.040129.
 #
index a82a232..593b903 100644 (file)
@@ -160,6 +160,7 @@ gras_dynar_foreach
 
 <SECTION>
 <FILE>core_dico</FILE>
 
 <SECTION>
 <FILE>core_dico</FILE>
+gras_dict_new
 gras_dict_free
 gras_dict_insert
 gras_dict_retrieve
 gras_dict_free
 gras_dict_insert
 gras_dict_retrieve
index 5159d33..43618d0 100644 (file)
@@ -14,6 +14,15 @@ Data container associating data to a string key.
 
 </para>
 
 
 </para>
 
+<!-- ##### FUNCTION gras_dict_new ##### -->
+<para>
+
+</para>
+
+@dict: 
+@Returns: 
+
+
 <!-- ##### FUNCTION gras_dict_free ##### -->
 <para>
 
 <!-- ##### FUNCTION gras_dict_free ##### -->
 <para>
 
index 84ea0db..8f2d145 100644 (file)
@@ -8,7 +8,7 @@ EXTRA_DIST=    \
        dict.h \
        config.h \
        \
        dict.h \
        config.h \
        \
-       datadesc.h \
+       datadesc_simple.h \
        data_description.h dd_type_bag.h \
        \
        socket.h messages.h \
        data_description.h dd_type_bag.h \
        \
        socket.h messages.h \
index 1948e24..189dcc8 100644 (file)
@@ -77,6 +77,23 @@ typedef struct DataDescriptorStruct {
   sizeof(structType) - offsetof(structType, lastMember) - \
   sizeof(memberType) * repetitions
 
   sizeof(structType) - offsetof(structType, lastMember) - \
   sizeof(memberType) * repetitions
 
+
+gras_error_t gras_datadesc_parse(const char       *def,
+                                gras_datadesc_t **dst);
+gras_error_t gras_datadesc_from_nws(const DataDescriptor *desc,
+                                   size_t                howmany,
+                                   gras_datadesc_t     **dst);
+gras_error_t gras_datadesc_eq(const gras_datadesc_t *d1,
+                             const gras_datadesc_t *d2);
+gras_error_t gras_datadesc_cpy(gras_datadesc_t  *src,
+                              gras_datadesc_t **dst);
+gras_error_t gras_datadesc_sizeof_host(gras_datadesc_t *desc,
+                                      size_t          *dst);
+gras_error_t gras_datadesc_sizeof_network(gras_datadesc_t *desc,
+                                         size_t          *dst);
+
+
+
 END_DECL
 
 #endif /* GRAS_DATADESC_H */
 END_DECL
 
 #endif /* GRAS_DATADESC_H */
diff --git a/include/datadesc_simple.h b/include/datadesc_simple.h
new file mode 100644 (file)
index 0000000..5b2b211
--- /dev/null
@@ -0,0 +1,110 @@
+/* $Id$ */
+
+/* gras/datadesc.h - Describing the data you want to exchange               */
+
+/* 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_DATADESC_SIMPLE_H
+#define GRAS_DATADESC_SIMPLE_H
+
+#include <stddef.h>    /* offsetof() */
+#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++ */
+
+BEGIN_DECL
+
+/****
+ **** The NWS type and constructors 
+ ****/
+
+typedef enum
+  {CHAR_TYPE, DOUBLE_TYPE, FLOAT_TYPE, INT_TYPE, LONG_TYPE, SHORT_TYPE,
+   UNSIGNED_INT_TYPE, UNSIGNED_LONG_TYPE, UNSIGNED_SHORT_TYPE, STRUCT_TYPE}
+  DataTypes;
+#define SIMPLE_TYPE_COUNT 9
+
+typedef struct DataDescriptorStruct {
+  DataTypes type;
+  size_t repetitions;
+  size_t offset;
+  struct DataDescriptorStruct *members;
+  size_t length;
+  size_t tailPadding;
+} DataDescriptor;
+#ifndef NULL
+#define NULL 0
+#endif
+#define SIMPLE_DATA(type,repetitions) {type, repetitions, 0, NULL, 0, 0}
+#define SIMPLE_MEMBER(type,repetitions,offset) \
+  {type, repetitions, offset, NULL, 0, 0}
+#define PAD_BYTES(structType,lastMember,memberType,repetitions) \
+  sizeof(structType) - offsetof(structType, lastMember) - \
+  sizeof(memberType) * repetitions
+
+/****
+ **** Gras (opaque) type, constructors and functions
+ ****/
+
+typedef struct gras_datadesc_ gras_datadesc_t;
+
+/* constructors, memory management */
+gras_error_t gras_datadesc_parse(const char       *def,
+                                gras_datadesc_t **dst);
+gras_error_t gras_datadesc_from_nws(const DataDescriptor *desc,
+                                   size_t                howmany,
+                                   gras_datadesc_t     **dst);
+
+gras_error_t gras_datadesc_cpy(gras_datadesc_t  *src,
+                              gras_datadesc_t **dst);
+void         gras_datadesc_free(gras_datadesc_t **dd);
+
+/* basic functionnalities */
+int          gras_datadesc_cmp(const gras_datadesc_t *d1,
+                              const gras_datadesc_t *d2);
+
+gras_error_t gras_datadesc_sizeof_host(gras_datadesc_t *desc,
+                                      size_t          *dst);
+gras_error_t gras_datadesc_sizeof_network(gras_datadesc_t *desc,
+                                         size_t          *dst);
+
+/* high level function needed in SG */
+gras_error_t gras_datadesc_data_cpy(const gras_datadesc_t *dd,
+                                   const void *src,
+                                   void **dst);
+
+/* high level functions needed in RL */
+gras_error_t gras_datadesc_convert_recv(const gras_datadesc_t *dd,
+                                       gras_trp_plugin_t *trp,
+                                       void **dst);
+gras_error_t gras_datadesc_convert_send(const gras_datadesc_t *dd,
+                                       gras_trp_plugin_t *trp,
+                                       void *src);
+
+END_DECL
+
+#endif /* GRAS_DATADESC_SIMPLE_H */
+
index 4a45d91..58c89ad 100644 (file)
@@ -125,6 +125,7 @@ typedef enum {
 
 #define RAISE_MALLOC     RAISE0(malloc_error,"Malloc error")
 #define RAISE_IMPOSSIBLE RAISE0(unknown_error,"The Impossible did happen")
 
 #define RAISE_MALLOC     RAISE0(malloc_error,"Malloc error")
 #define RAISE_IMPOSSIBLE RAISE0(unknown_error,"The Impossible did happen")
+#define RAISE_UNIMPLEMENTED RAISE1(unknown_error,"Function %s unimplemented",__FUNCTION__)
 
 #define gras_abort abort
 
 
 #define gras_abort abort
 
index fb941a4..5bb8012 100644 (file)
@@ -40,7 +40,9 @@
 #include <gras/config.h>
 
 #include <gras/core.h>
 #include <gras/config.h>
 
 #include <gras/core.h>
-#include <gras/datadesc.h>
+
+#include <gras/transport.h>
+#include <gras/datadesc_simple.h>
 #include <gras/socket.h>
 #include <gras/messages.h>
 
 #include <gras/socket.h>
 #include <gras/messages.h>
 
index e9d1aa6..5887aa5 100644 (file)
@@ -3,7 +3,7 @@
 /* gras/messages.h - Public interface to GRAS messages                      */
 
 /* Authors: Martin Quinson                                                  */
 /* gras/messages.h - Public interface to GRAS messages                      */
 
 /* Authors: Martin Quinson                                                  */
-/* Copyright (C) 2003 the OURAGAN project.                                  */
+/* Copyright (C) 2003,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. */
 
 /* 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. */
diff --git a/include/transport.h b/include/transport.h
new file mode 100644 (file)
index 0000000..ffe6e6e
--- /dev/null
@@ -0,0 +1,33 @@
+/* $Id$ */
+
+/* trp (transport) - send/receive a bunch of bytes                          */
+
+/* This file implements the public interface of this module, exported to the*/
+/*  other modules of GRAS, but not to the 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 GRAS_TRANSPORT_H
+#define GRAS_TRANSPORT_H
+
+/* each plugin implements the socket the way it wants */
+typedef void gras_trp_sock_t;
+
+/* A plugin type */
+typedef struct gras_trp_plugin_ gras_trp_plugin_t;
+
+/* Module, and get plugin by name */
+gras_error_t gras_trp_init(void);
+
+void         gras_trp_exit(void);
+
+gras_error_t gras_trp_plugin_get_by_name(const char *name,
+                                        gras_trp_plugin_t **dst);
+
+
+
+#endif /* GRAS_TRANSPORT_H */
index 37b8c2e..2341998 100644 (file)
@@ -15,6 +15,7 @@ noinst_LIBRARIES=libgrasutils.a
 
 #                     Core/dict_multi.c
 #  Common/gras.c      Common/gras_datadesc.c        Common/gras_msg.c            
 
 #                     Core/dict_multi.c
 #  Common/gras.c      Common/gras_datadesc.c        Common/gras_msg.c            
+#   Messaging/messaging.c                       
 
 COMMON_S=\
   \
 
 COMMON_S=\
   \
@@ -25,6 +26,11 @@ COMMON_S=\
   \
   Core/config.c                               \
   \
   \
   Core/config.c                               \
   \
+  Messaging/transport.c    Messaging/transport.h \
+  Messaging/transport_sg.c Messaging/transport_tcp.c   \
+  \
+  Messaging/datadesc_simple.c                 \
+  \
   gs/datadesc.c                               \
   gs/tools.c                                  \
   gs/categories.h                             \
   gs/datadesc.c                               \
   gs/tools.c                                  \
   gs/categories.h                             \
@@ -51,7 +57,9 @@ libgrasutils_a_SOURCES = $(COMMON_S) Tests/gras_dummy.c
 libgrasutils_a_LIBADD = $(COMMON_L)
 
 
 libgrasutils_a_LIBADD = $(COMMON_L)
 
 
-libgrasrl_a_SOURCES= $(COMMON_S) RL/gras_rl.c RL/gras_rl.h
+
+# RL/gras_rl.c RL/gras_rl.h FIXME
+libgrasrl_a_SOURCES= $(COMMON_S) Messaging/messaging_rl.c
 libgrasrl_a_LIBADD= \
  $(foreach file,\
   exp_smooth forc median mse_forc protocol \
 libgrasrl_a_LIBADD= \
  $(foreach file,\
   exp_smooth forc median mse_forc protocol \
@@ -60,7 +68,8 @@ libgrasrl_a_LIBADD= \
  $(COMMON_L)
 
        
  $(COMMON_L)
 
        
-libgrassg_a_SOURCES= $(COMMON_S) SG/gras_sg.c SG/gras_sg.h
+# SG/gras_sg.c SG/gras_sg.h FIXME      
+libgrassg_a_SOURCES= $(COMMON_S) Messaging/messaging_sg.c
 libgrassg_a_LIBADD= \
  $(COMMON_L)
 
 libgrassg_a_LIBADD= \
  $(COMMON_L)
 
index 4159c9c..cd24c8a 100644 (file)
 
 GRAS_LOG_DEFAULT_CATEGORY(GRAS);
 
 
 GRAS_LOG_DEFAULT_CATEGORY(GRAS);
 
-gras_error_t
-gras_process_init() {
-  gras_hostdata_t *hd=(gras_hostdata_t *)MSG_host_get_data(MSG_host_self());
-  grasProcessData_t *pd;
-  int i;
-  
-  if (!(pd=(grasProcessData_t *)malloc(sizeof(grasProcessData_t)))) {
-    fprintf(stderr,"grasInit: out of memory\n");
-    return malloc_error;
-  }
-  pd->grasMsgQueueLen=0;
-  pd->grasMsgQueue = NULL;
-
-  pd->grasCblListLen = 0;
-  pd->grasCblList = NULL;
-
-  if (MSG_process_set_data(MSG_process_self(),(void*)pd) != MSG_OK) {
-    return unknown_error;
-  }
-
-  if (!hd) {
-    if (!(hd=(gras_hostdata_t *)malloc(sizeof(gras_hostdata_t)))) {
-      fprintf(stderr,"grasInit: out of memory\n");
-      return malloc_error;
-    }
-    hd->portLen = 0;
-    hd->port=NULL;
-    hd->port2chan=NULL;
-    for (i=0; i<MAX_CHANNEL; i++) {
-      hd->proc[i]=0;
-    }
-
-    if (MSG_host_set_data(MSG_host_self(),(void*)hd) != MSG_OK) {
-      return unknown_error;
-    }
-  }
-  
-  /* take a free channel for this process */
-  for (i=0; i<MAX_CHANNEL && hd->proc[i]; i++);
-  if (i == MAX_CHANNEL) {
-        fprintf(stderr,
-           "GRAS: Can't add a new process on %s, because all channel are already in use. Please increase MAX CHANNEL (which is %d for now) and recompile GRAS\n.",
-           MSG_host_get_name(MSG_host_self()),MAX_CHANNEL);
-       return system_error;
-  }
-  pd->chan = i;
-  hd->proc[ i ] = MSG_process_self_PID();
-
-  /* take a free channel for this process */
-  for (i=0; i<MAX_CHANNEL && hd->proc[i]; i++);
-  if (i == MAX_CHANNEL) {
-        fprintf(stderr,
-           "GRAS: Can't add a new process on %s, because all channel are already in use. Please increase MAX CHANNEL (which is %d for now) and recompile GRAS\n.",
-           MSG_host_get_name(MSG_host_self()),MAX_CHANNEL);
-       return system_error;
-  }
-  pd->rawChan = i;
-  hd->proc[ i ] = MSG_process_self_PID();
-
-  /*
-  fprintf(stderr,"GRAS: Creating process '%s' (%d)\n",
-         MSG_process_get_name(MSG_process_self()),MSG_process_self_PID());
-  */
-  return no_error;
-}
-
-gras_error_t
-gras_process_finalize() {
-  gras_hostdata_t *hd=(gras_hostdata_t *)MSG_host_get_data(MSG_host_self());
-  grasProcessData_t *pd=(grasProcessData_t *)MSG_process_get_data(MSG_process_self());
-  int myPID=MSG_process_self_PID();
-  int i;
-
-  gras_assert0(hd && pd,"Run gras_process_init!!\n");
-
-  
-  fprintf(stderr,"GRAS: Finalizing process '%s' (%d)\n",
-         MSG_process_get_name(MSG_process_self()),MSG_process_self_PID());
-  if (pd->grasMsgQueueLen) {
-    fprintf(stderr,"GRAS: Warning: process %d terminated, but some queued messages where not handled\n",MSG_process_self_PID());
-  }
-    
-  for (i=0; i< MAX_CHANNEL; i++)
-    if (myPID == hd->proc[i])
-      hd->proc[i] = 0;
-
-  for (i=0; i<hd->portLen; i++) {
-    if (hd->port2chan[ i ] == pd->chan) {
-      memmove(&(hd->port[i]),      &(hd->port[i+1]),      (hd->portLen -i -1) * sizeof(int));
-      memmove(&(hd->port2chan[i]), &(hd->port2chan[i+1]), (hd->portLen -i -1) * sizeof(int));
-      hd->portLen--;
-      i--; /* counter the effect of the i++ at the end of the iteration */
-    }
-  }
-
-  return no_error;
-}
 /* **************************************************************************
  * Openning/Maintaining/Closing connexions (private functions for both raw
  * and regular sockets)
 /* **************************************************************************
  * Openning/Maintaining/Closing connexions (private functions for both raw
  * and regular sockets)
index f8d1962..81f9c5e 100644 (file)
@@ -44,7 +44,8 @@
 #include "gras/dd_type_bag.h"
 
 #include "gras/core.h"
 #include "gras/dd_type_bag.h"
 
 #include "gras/core.h"
-#include "gras/datadesc.h"
+#include "gras/transport.h"
+#include "gras/datadesc_simple.h"
 #include "gras/socket.h"
 #include "gras/messages.h"
 
 #include "gras/socket.h"
 #include "gras/messages.h"
 
@@ -250,6 +251,8 @@ void grasSockFree(gras_sock_t *s);
 /* **************************************************************************
  * Handling DataDescriptors
  * **************************************************************************/
 /* **************************************************************************
  * Handling DataDescriptors
  * **************************************************************************/
+#if 0
+FIXME: Kill it
 typedef enum {HOST_FORMAT, NETWORK_FORMAT} FormatTypes;
 size_t DataSize(const DataDescriptor *description,
                size_t length,
 typedef enum {HOST_FORMAT, NETWORK_FORMAT} FormatTypes;
 size_t DataSize(const DataDescriptor *description,
                size_t length,
@@ -258,5 +261,5 @@ void *gras_datadesc_copy_data(const DataDescriptor *dd, unsigned int c, void *da
 int gras_datadesc_cmp(/*@null@*/const DataDescriptor *dd1, unsigned int c1,
                      /*@null@*/const DataDescriptor *dd2, unsigned int c2);
 void gras_datadesc_dump(/*@null@*/const DataDescriptor *dd, unsigned int c);
 int gras_datadesc_cmp(/*@null@*/const DataDescriptor *dd1, unsigned int c1,
                      /*@null@*/const DataDescriptor *dd2, unsigned int c2);
 void gras_datadesc_dump(/*@null@*/const DataDescriptor *dd, unsigned int c);
-
+#endif
 #endif /* GRAS_PRIVATE_H */
 #endif /* GRAS_PRIVATE_H */
index 7fea46b..5ce0dfb 100644 (file)
@@ -29,7 +29,7 @@ int main(int argc,char *argv[]) {
    parse_log_opt(argc,argv,"dynar.thresh=debug");
    
    fprintf(stderr,"==== Traverse the empty dynar\n");
    parse_log_opt(argc,argv,"dynar.thresh=debug");
    
    fprintf(stderr,"==== Traverse the empty dynar\n");
-   TRYFAIL(gras_dynar_new(&d,sizeof(int),NULL));
+   TRYFAIL(gras_dynar_new(&d,sizeof(char *),&free_string));
    gras_dynar_foreach(d,cpt,i){
      fprintf(stderr,
             "Damnit, there is something in the empty dynar\n");
    gras_dynar_foreach(d,cpt,i){
      fprintf(stderr,
             "Damnit, there is something in the empty dynar\n");