Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
The change Arnaud wanted so much: Big Star Erradication
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 2 Nov 2004 11:34:14 +0000 (11:34 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 2 Nov 2004 11:34:14 +0000 (11:34 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@450 48e7efb5-ca39-0410-a469-dd3cf9ba447f

14 files changed:
include/Makefile.am
include/gras/cond.h
include/gras/datadesc.h
include/gras/messages.h
include/gras/process.h
include/gras/transport.h
include/gras/virtu.h
include/xbt/config.h
include/xbt/dict.h
include/xbt/dynar.h
include/xbt/error.h
include/xbt/log.h
include/xbt/set.h
include/xbt/sysdep.h

index 30bddb4..272953e 100644 (file)
@@ -12,8 +12,6 @@ nobase_include_HEADERS = \
        \
        gras/messages.h \
        \
        \
        gras/messages.h \
        \
-       gras/core.h\
-       \
        gras/modules/base.h \
        gras/modules/bandwidth.h
 
        gras/modules/base.h \
        gras/modules/bandwidth.h
 
index b39485a..42ca8db 100644 (file)
 #ifndef GRAS_COND_H
 #define GRAS_COND_H
 
 #ifndef GRAS_COND_H
 #define GRAS_COND_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++ */
+#include "xbt/misc.h" /* BEGIN_DECL */
 
 BEGIN_DECL
 
 
 BEGIN_DECL
 
index d3e5796..eb5491d 100644 (file)
 #ifndef GRAS_DATADESC_H
 #define GRAS_DATADESC_H
 
 #ifndef GRAS_DATADESC_H
 #define GRAS_DATADESC_H
 
-#include <stddef.h>    /* offsetof() */
-#include <sys/types.h>  /* size_t */
-#include <stdarg.h>
-
 #include "xbt/misc.h" /* BEGIN_DECL */
 
 BEGIN_DECL
 #include "xbt/misc.h" /* BEGIN_DECL */
 
 BEGIN_DECL
@@ -24,132 +20,131 @@ BEGIN_DECL
  * 
  * Opaque type describing a type description you don't want to open.
  */
  * 
  * Opaque type describing a type description you don't want to open.
  */
-typedef struct s_gras_datadesc_type gras_datadesc_type_t;
+typedef struct s_gras_datadesc_type *gras_datadesc_type_t;
 
 
-typedef struct s_gras_cbps gras_cbps_t;
+typedef struct s_gras_cbps *gras_cbps_t;
 
 /* callbacks prototypes */
 
 /* callbacks prototypes */
-typedef void (*gras_datadesc_type_cb_void_t)(gras_cbps_t *vars, void *data);
-typedef int (*gras_datadesc_type_cb_int_t)(gras_cbps_t *vars, void *data);
-typedef gras_datadesc_type_t *(*gras_datadesc_selector_t)(gras_cbps_t *vars, void *data);
+typedef void (*gras_datadesc_type_cb_void_t)(gras_cbps_t vars, void *data);
+typedef int (*gras_datadesc_type_cb_int_t)(gras_cbps_t vars, void *data);
+typedef gras_datadesc_type_t (*gras_datadesc_selector_t)(gras_cbps_t vars, void *data);
 
 /***********************************************
  **** Search and retrieve declared datatype ****
  ***********************************************/
 
 /***********************************************
  **** Search and retrieve declared datatype ****
  ***********************************************/
-gras_datadesc_type_t *gras_datadesc_by_name(const char *name);
+gras_datadesc_type_t gras_datadesc_by_name(const char *name);
 
 /******************************************
  **** Declare datadescription yourself ****
  ******************************************/
 
 
 /******************************************
  **** Declare datadescription yourself ****
  ******************************************/
 
-gras_datadesc_type_t *
-  gras_datadesc_struct(const char *name);
+gras_datadesc_type_t gras_datadesc_struct(const char *name);
 
 void
 
 void
-  gras_datadesc_struct_append(gras_datadesc_type_t    *struct_type,
-                             const char              *name,
-                             gras_datadesc_type_t    *field_type);
+  gras_datadesc_struct_append(gras_datadesc_type_t  struct_type,
+                             const char           *name,
+                             gras_datadesc_type_t  field_type);
 void
 void
-  gras_datadesc_struct_close(gras_datadesc_type_t     *struct_type);
+  gras_datadesc_struct_close(gras_datadesc_type_t   struct_type);
 
 
-gras_datadesc_type_t *
-  gras_datadesc_union(const char                      *name,
-                     gras_datadesc_type_cb_int_t      selector);
+gras_datadesc_type_t 
+  gras_datadesc_union(const char                   *name,
+                     gras_datadesc_type_cb_int_t   selector);
 void
 void
-  gras_datadesc_union_append(gras_datadesc_type_t     *union_type,
-                            const char               *name,
-                            gras_datadesc_type_t     *field_type);
+  gras_datadesc_union_append(gras_datadesc_type_t   union_type,
+                            const char            *name,
+                            gras_datadesc_type_t   field_type);
 void
 void
-  gras_datadesc_union_close(gras_datadesc_type_t      *union_type);
+  gras_datadesc_union_close(gras_datadesc_type_t    union_type);
 
 
-gras_datadesc_type_t *
-  gras_datadesc_ref(const char                      *name,
-                   gras_datadesc_type_t            *referenced_type);
-gras_datadesc_type_t *
+gras_datadesc_type_t 
+  gras_datadesc_ref(const char                     *name,
+                   gras_datadesc_type_t            referenced_type);
+gras_datadesc_type_t 
   gras_datadesc_ref_generic(const char                *name,
                            gras_datadesc_selector_t   selector);
 
   gras_datadesc_ref_generic(const char                *name,
                            gras_datadesc_selector_t   selector);
 
-gras_datadesc_type_t *
-  gras_datadesc_array_fixed(const char                    *name,
-                           gras_datadesc_type_t          *element_type,
-                           long int                       fixed_size);
-gras_datadesc_type_t *
-  gras_datadesc_array_dyn(const char                      *name,
-                         gras_datadesc_type_t            *element_type,
-                         gras_datadesc_type_cb_int_t      dynamic_size);
+gras_datadesc_type_t 
+  gras_datadesc_array_fixed(const char             *name,
+                           gras_datadesc_type_t    element_type,
+                           long int                fixed_size);
+gras_datadesc_type_t 
+  gras_datadesc_array_dyn(const char                 *name,
+                         gras_datadesc_type_t        element_type,
+                         gras_datadesc_type_cb_int_t dynamic_size);
 
 
-gras_datadesc_type_t *
-  gras_datadesc_ref_pop_arr(gras_datadesc_type_t  *element_type);
+gras_datadesc_type_t 
+  gras_datadesc_ref_pop_arr(gras_datadesc_type_t  element_type);
 
 /*********************************
  * Change stuff within datadescs *
  *********************************/
 
 
 /*********************************
  * 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_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,
+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,
                           gras_datadesc_type_cb_void_t  post);
                           gras_datadesc_type_cb_void_t  post);
-void gras_datadesc_cb_field_send (gras_datadesc_type_t    *type,
-                                 const char *field_name,
+void gras_datadesc_cb_field_send (gras_datadesc_type_t   type,
+                                 const char            *field_name,
                                  gras_datadesc_type_cb_void_t  pre);
                                  gras_datadesc_type_cb_void_t  pre);
-void gras_datadesc_cb_field_recv(gras_datadesc_type_t    *type,
-                                const char *field_name,
+void gras_datadesc_cb_field_recv(gras_datadesc_type_t    type,
+                                const char             *field_name,
                                 gras_datadesc_type_cb_void_t  post);
                                 gras_datadesc_type_cb_void_t  post);
-void gras_datadesc_cb_field_push (gras_datadesc_type_t         *type,
-                                 const char                   *field_name);
+void gras_datadesc_cb_field_push (gras_datadesc_type_t   type,
+                                 const char            *field_name);
 
 /******************************
  * Get stuff within datadescs *
  ******************************/
 
 /******************************
  * Get stuff within datadescs *
  ******************************/
-char * gras_datadesc_get_name(gras_datadesc_type_t *ddt);
-int gras_datadesc_get_id(gras_datadesc_type_t *ddt);
+char * gras_datadesc_get_name(gras_datadesc_type_t ddt);
+int gras_datadesc_get_id(gras_datadesc_type_t ddt);
 
 /********************************************************
  * Advanced data describing: callback persistent states *
  ********************************************************/
 /* simple one: push/pop sizes of arrays */
 void
 
 /********************************************************
  * Advanced data describing: callback persistent states *
  ********************************************************/
 /* simple one: push/pop sizes of arrays */
 void
-gras_cbps_i_push(gras_cbps_t *ps, int val);
+gras_cbps_i_push(gras_cbps_t ps, int val);
 int 
 int 
-gras_cbps_i_pop(gras_cbps_t *ps);
+gras_cbps_i_pop(gras_cbps_t ps);
 
 
-int gras_datadesc_cb_pop(gras_cbps_t *vars, void *data);
-void gras_datadesc_cb_push_int(gras_cbps_t *vars, void *data);
-void gras_datadesc_cb_push_uint(gras_cbps_t *vars, void *data);
-void gras_datadesc_cb_push_lint(gras_cbps_t *vars, void *data);
-void gras_datadesc_cb_push_ulint(gras_cbps_t *vars, void *data);
+int gras_datadesc_cb_pop(gras_cbps_t vars, void *data);
+void gras_datadesc_cb_push_int(gras_cbps_t vars, void *data);
+void gras_datadesc_cb_push_uint(gras_cbps_t vars, void *data);
+void gras_datadesc_cb_push_lint(gras_cbps_t vars, void *data);
+void gras_datadesc_cb_push_ulint(gras_cbps_t vars, void *data);
 
 
 
 /* complex one: complete variable environment support */
 gras_error_t
 
 
 
 /* complex one: complete variable environment support */
 gras_error_t
-gras_cbps_v_pop (gras_cbps_t        *ps, 
-                   const char            *name,
-                   gras_datadesc_type_t **ddt,
-                 void                 **res);
+  gras_cbps_v_pop (gras_cbps_t            ps, 
+                  const char            *name,
+        /* OUT */ gras_datadesc_type_t  *ddt,
+        /* OUT */ void                 **res);
 gras_error_t
 gras_error_t
-gras_cbps_v_push(gras_cbps_t        *ps,
-                   const char            *name,
-                   void                  *data,
-                   gras_datadesc_type_t  *ddt);
+gras_cbps_v_push(gras_cbps_t            ps,
+                const char            *name,
+                void                  *data,
+                gras_datadesc_type_t   ddt);
 void
 void
-gras_cbps_v_set (gras_cbps_t        *ps,
-                   const char            *name,
-                   void                  *data,
-                   gras_datadesc_type_t  *ddt);
+gras_cbps_v_set (gras_cbps_t            ps,
+                const char            *name,
+                void                  *data,
+                gras_datadesc_type_t   ddt);
 
 void *
 
 void *
-gras_cbps_v_get (gras_cbps_t        *ps, 
-                   const char            *name,
-                   gras_datadesc_type_t **ddt);
+gras_cbps_v_get (gras_cbps_t            ps, 
+                const char            *name,
+       /* OUT */ gras_datadesc_type_t  *ddt);
 
 void
 
 void
-gras_cbps_block_begin(gras_cbps_t *ps);
+gras_cbps_block_begin(gras_cbps_t ps);
 void
 void
-gras_cbps_block_end(gras_cbps_t *ps);
+gras_cbps_block_end(gras_cbps_t ps);
 
 
 
 
 
 
@@ -162,7 +157,7 @@ int gras_arch_selfid(void); /* ID of this arch */
 /****************************
  **** Parse C statements ****
  ****************************/
 /****************************
  **** Parse C statements ****
  ****************************/
-gras_datadesc_type_t *
+gras_datadesc_type_t 
 gras_datadesc_parse(const char *name,
                    const char *Cdefinition);
 #define GRAS_DEFINE_TYPE(name,def) \
 gras_datadesc_parse(const char *name,
                    const char *Cdefinition);
 #define GRAS_DEFINE_TYPE(name,def) \
@@ -223,8 +218,8 @@ typedef struct DataDescriptorStruct {
 gras_error_t
 gras_datadesc_import_nws(const char           *name,
                         const DataDescriptor *desc,
 gras_error_t
 gras_datadesc_import_nws(const char           *name,
                         const DataDescriptor *desc,
-                        size_t                howmany,
-                        gras_datadesc_type_t **dst);
+                        unsigned long         howmany,
+              /* OUT */ gras_datadesc_type_t *dst);
 
 END_DECL
 
 
 END_DECL
 
index 96e8152..032bbc2 100644 (file)
 BEGIN_DECL
 
 /* msgtype declaration and retrival */
 BEGIN_DECL
 
 /* msgtype declaration and retrival */
-typedef struct s_gras_msgtype gras_msgtype_t;
+typedef struct s_gras_msgtype *gras_msgtype_t;
 
 
-void gras_msgtype_declare  (const char            *name,
-                           gras_datadesc_type_t  *payload);
-void gras_msgtype_declare_v(const char            *name,
-                           short int              version,
-                           gras_datadesc_type_t  *payload);
+void gras_msgtype_declare  (const char           *name,
+                           gras_datadesc_type_t  payload);
+void gras_msgtype_declare_v(const char           *name,
+                           short int             version,
+                           gras_datadesc_type_t  payload);
 
 
-gras_msgtype_t *gras_msgtype_by_name (const char     *name);
-gras_msgtype_t *gras_msgtype_by_namev(const char      *name,
-                                     short int        version);
+gras_msgtype_t gras_msgtype_by_name (const char     *name);
+gras_msgtype_t gras_msgtype_by_namev(const char     *name,
+                                    short int       version);
 
 /**
  * gras_cb_t:
 
 /**
  * gras_cb_t:
@@ -44,20 +44,20 @@ gras_msgtype_t *gras_msgtype_by_namev(const char      *name,
  *
  * If the callback accepts the message, it should free it after use.
  */
  *
  * If the callback accepts the message, it should free it after use.
  */
-typedef int (*gras_cb_t)(gras_socket_t        *expeditor,
-                        void                 *payload);
-void gras_cb_register  (gras_msgtype_t *msgtype,
-                       gras_cb_t       cb);
-void gras_cb_unregister(gras_msgtype_t *msgtype,
-                       gras_cb_t     cb);
-
-gras_error_t gras_msg_send(gras_socket_t  *sock,
-                          gras_msgtype_t *msgtype,
+typedef int (*gras_cb_t)(gras_socket_t  expeditor,
+                        void          *payload);
+void gras_cb_register  (gras_msgtype_t msgtype,
+                       gras_cb_t      cb);
+void gras_cb_unregister(gras_msgtype_t msgtype,
+                       gras_cb_t      cb);
+
+gras_error_t gras_msg_send(gras_socket_t   sock,
+                          gras_msgtype_t  msgtype,
+                          void           *payload);
+gras_error_t gras_msg_wait(double          timeout,    
+                          gras_msgtype_t  msgt_want,
+                          gras_socket_t  *expeditor,
                           void           *payload);
                           void           *payload);
-gras_error_t gras_msg_wait(double                 timeout,    
-                          gras_msgtype_t        *msgt_want,
-                          gras_socket_t        **expeditor,
-                          void                  *payload);
 gras_error_t gras_msg_handle(double timeOut);
 
 
 gras_error_t gras_msg_handle(double timeOut);
 
 
index 5b528a4..761647f 100644 (file)
@@ -3,7 +3,7 @@
 /* gras/core.h - Unsorted part of the GRAS public interface                 */
 
 /* Authors: Martin Quinson                                                  */
 /* gras/core.h - Unsorted part of the GRAS public interface                 */
 
 /* 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. */
 
 /* 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_PROCESS_H
 #define GRAS_PROCESS_H
 
 #ifndef GRAS_PROCESS_H
 #define GRAS_PROCESS_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++ */
+#include "xbt/misc.h" /* BEGIN_DECL */
 
 BEGIN_DECL
 
 
 BEGIN_DECL
 
index 32a5cdb..ca99c83 100644 (file)
 
 #include "xbt/error.h"
 
 
 #include "xbt/error.h"
 
-typedef struct s_gras_socket gras_socket_t;
+typedef struct s_gras_socket *gras_socket_t;
 
 gras_error_t gras_socket_client(const char *host,
                                unsigned short port,
 
 gras_error_t gras_socket_client(const char *host,
                                unsigned short port,
-                               /* OUT */ gras_socket_t **dst);
+                               /* OUT */ gras_socket_t *dst);
 gras_error_t gras_socket_server(unsigned short port,
 gras_error_t gras_socket_server(unsigned short port,
-                               /* OUT */ gras_socket_t **dst);
-void         gras_socket_close(gras_socket_t *sd);
+                               /* OUT */ gras_socket_t *dst);
+void         gras_socket_close(gras_socket_t sd);
 
 /* get information about socket */
 
 /* get information about socket */
-int   gras_socket_my_port  (gras_socket_t *sock);
-int   gras_socket_peer_port(gras_socket_t *sock);
-char *gras_socket_peer_name(gras_socket_t *sock);
+int   gras_socket_my_port  (gras_socket_t sock);
+int   gras_socket_peer_port(gras_socket_t sock);
+char *gras_socket_peer_name(gras_socket_t sock);
 
 /* extended interface to get all details */
 gras_error_t gras_socket_client_ext(const char *host,
                                    unsigned short port,
                                    unsigned long int bufSize,
                                    int raw, 
 
 /* extended interface to get all details */
 gras_error_t gras_socket_client_ext(const char *host,
                                    unsigned short port,
                                    unsigned long int bufSize,
                                    int raw, 
-                                   /* OUT */ gras_socket_t **dst);
+                                   /* OUT */ gras_socket_t *dst);
 gras_error_t gras_socket_server_ext(unsigned short port,
                                    unsigned long int bufSize,
                                    int raw,
 gras_error_t gras_socket_server_ext(unsigned short port,
                                    unsigned long int bufSize,
                                    int raw,
-                                   /* OUT */ gras_socket_t **dst);
+                                   /* OUT */ gras_socket_t *dst);
 
 /* using raw sockets */
 
 /* using raw sockets */
-gras_error_t gras_socket_raw_send(gras_socket_t *peer, 
+gras_error_t gras_socket_raw_send(gras_socket_t peer, 
                                  unsigned int timeout,
                                  unsigned long int expSize, 
                                  unsigned long int msgSize);
                                  unsigned int timeout,
                                  unsigned long int expSize, 
                                  unsigned long int msgSize);
-gras_error_t gras_socket_raw_recv(gras_socket_t *peer, 
+gras_error_t gras_socket_raw_recv(gras_socket_t peer, 
                                  unsigned int timeout,
                                  unsigned long int expSize, 
                                  unsigned long int msgSize);
 
 /* debuging functions */
 gras_error_t gras_socket_client_from_file(const char*path,
                                  unsigned int timeout,
                                  unsigned long int expSize, 
                                  unsigned long int msgSize);
 
 /* debuging functions */
 gras_error_t gras_socket_client_from_file(const char*path,
-                                         /* OUT */ gras_socket_t **dst);
+                                         /* OUT */ gras_socket_t *dst);
 gras_error_t gras_socket_server_from_file(const char*path,
 gras_error_t gras_socket_server_from_file(const char*path,
-                                         /* OUT */ gras_socket_t **dst);
+                                         /* OUT */ gras_socket_t *dst);
                                          
    
 #endif /* GRAS_TRANSPORT_H */
                                          
    
 #endif /* GRAS_TRANSPORT_H */
index 8da06b2..2669f23 100644 (file)
 #ifndef GRAS_VIRTU_H
 #define GRAS_VIRTU_H
 
 #ifndef GRAS_VIRTU_H
 #define GRAS_VIRTU_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++ */
+#include "xbt/misc.h" /* BEGIN_DECL */
 
 BEGIN_DECL
 
 
 BEGIN_DECL
 
@@ -55,6 +33,16 @@ double gras_os_time(void);
  */
 void gras_os_sleep(unsigned long sec, unsigned long usec);
 
  */
 void gras_os_sleep(unsigned long sec, unsigned long usec);
 
+/**
+ * gras_get_my_fqdn:
+ *
+ * Returns the fully-qualified name of the host machine, or NULL if the name
+ * cannot be determined.  Always returns the same value, so multiple calls
+ * cause no problems.
+ */
+const char *
+gras_get_my_fqdn(void);
+
 END_DECL
 
 #endif /* GRAS_VIRTU_H */
 END_DECL
 
 #endif /* GRAS_VIRTU_H */
index a4ff04f..f12386e 100644 (file)
@@ -5,7 +5,7 @@
 /* This is useful to build named structs, like option or property sets.     */
 
 /* Authors: Martin Quinson                                                  */
 /* This is useful to build named structs, like option or property sets.     */
 
 /* Authors: Martin Quinson                                                  */
-/* Copyright (C) 2001,2002,2003,2004 the OURAGAN project.                   */
+/* Copyright (C) 2001,2002,2003,2004 da GRAS posse.                         */
 
 /* 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. */
 #ifndef _GRAS_CONFIG_H_
 #define _GRAS_CONFIG_H_
 
 #ifndef _GRAS_CONFIG_H_
 #define _GRAS_CONFIG_H_
 
+#include "xbt/dynar.h"
+
+BEGIN_DECL
+  
 /* 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;
 /* 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;
@@ -21,33 +25,34 @@ typedef gras_dynar_t gras_cfg_t;
 typedef enum {
   gras_cfgelm_int=0, gras_cfgelm_double, gras_cfgelm_string, gras_cfgelm_host,
   gras_cfgelm_type_count
 typedef enum {
   gras_cfgelm_int=0, gras_cfgelm_double, gras_cfgelm_string, gras_cfgelm_host,
   gras_cfgelm_type_count
-} gras_cfgelm_type_t;
+} e_gras_cfgelm_type_t;
 
 /*----[ Memory management ]-----------------------------------------------*/
 
 /*----[ Memory management ]-----------------------------------------------*/
-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);
+gras_cfg_t gras_cfg_new (void);
+void gras_cfg_cpy(gras_cfg_t tocopy,
+        /* OUT */ gras_cfg_t *whereto);
+void gras_cfg_free(gras_cfg_t *cfg);
+void gras_cfg_dump(const char *name,const char*indent,gras_cfg_t cfg);
 
 /*----[ Registering stuff ]-----------------------------------------------*/
 /* Register a possible cell */
 
 /*----[ Registering stuff ]-----------------------------------------------*/
 /* Register a possible cell */
-void gras_cfg_register(gras_cfg_t *cfg,
-                      const char *name, gras_cfgelm_type_t type,
+void gras_cfg_register(gras_cfg_t cfg,
+                      const char *name, e_gras_cfgelm_type_t type,
                       int min, int max);
 /* Unregister a possible cell */
                       int min, int max);
 /* Unregister a possible cell */
-gras_error_t gras_cfg_unregister(gras_cfg_t *cfg, const char *name);
+gras_error_t gras_cfg_unregister(gras_cfg_t cfg, const char *name);
 
 /* Parse the configuration descriptor and register it */
 /* Should be of the form "<name>:<min nb>_to_<max nb>_<type>", */
 /*  with type being one of 'string','int', 'host' or 'double'  */
 
 /* Parse the configuration descriptor and register it */
 /* Should be of the form "<name>:<min nb>_to_<max nb>_<type>", */
 /*  with type being one of 'string','int', 'host' or 'double'  */
-gras_error_t gras_cfg_register_str(gras_cfg_t *cfg, const char *entry);
+gras_error_t gras_cfg_register_str(gras_cfg_t cfg, const char *entry);
 
 /* Check that each cell have the right amount of elements */
 
 /* Check that each cell have the right amount of elements */
-gras_error_t gras_cfg_check(gras_cfg_t *cfg);
+gras_error_t gras_cfg_check(gras_cfg_t cfg);
 
 /* Get the type of this option in that repository */
 
 /* Get the type of this option in that repository */
-gras_error_t gras_cfg_get_type(gras_cfg_t *cfg, const char *name, 
-                              /* OUT */ gras_cfgelm_type_t *type);
+gras_error_t gras_cfg_get_type(gras_cfg_t cfg, const char *name, 
+                              /* OUT */ e_gras_cfgelm_type_t *type);
 
 /*----[ Setting ]---------------------------------------------------------
  * gras_cfg_set_* functions.
 
 /*----[ Setting ]---------------------------------------------------------
  * gras_cfg_set_* functions.
@@ -58,61 +63,62 @@ gras_error_t gras_cfg_get_type(gras_cfg_t *cfg, const char *name,
  *
  * string values are strdup'ed before use, so you have to free your copy  */
 
  *
  * string values are strdup'ed before use, so you have to free your copy  */
 
-gras_error_t gras_cfg_set_vargs(gras_cfg_t *cfg, va_list pa);
-gras_error_t gras_cfg_set(gras_cfg_t *cfg, ...);
+gras_error_t gras_cfg_set_vargs(gras_cfg_t cfg, va_list pa);
+gras_error_t gras_cfg_set(gras_cfg_t cfg, ...);
 
 /*
   Add the cells described in a string to a typed hash.
  */
 
 /*
   Add the cells described in a string to a typed hash.
  */
-gras_error_t gras_cfg_set_parse(gras_cfg_t *cfg, const char *options);
+gras_error_t gras_cfg_set_parse(gras_cfg_t cfg, const char *options);
 
 
 /*
   Set the value of the cell @name in @cfg with the provided value.
  */
 
 
 /*
   Set the value of the cell @name in @cfg with the provided value.
  */
-gras_error_t gras_cfg_set_int   (gras_cfg_t *cfg, const char *name, 
+gras_error_t gras_cfg_set_int   (gras_cfg_t cfg, const char *name, 
                                 int val);
                                 int val);
-gras_error_t gras_cfg_set_double(gras_cfg_t *cfg, const char *name, 
+gras_error_t gras_cfg_set_double(gras_cfg_t cfg, const char *name, 
                                 double val);
                                 double val);
-gras_error_t gras_cfg_set_string(gras_cfg_t *cfg, const char *name, 
+gras_error_t gras_cfg_set_string(gras_cfg_t cfg, const char *name, 
                                 const char *val);
                                 const char *val);
-gras_error_t gras_cfg_set_host  (gras_cfg_t *cfg, const char *name, 
+gras_error_t gras_cfg_set_host  (gras_cfg_t cfg, const char *name, 
                                 const char *host,int port);
 
 /*
  Remove the provided value from the cell @name in @cfg.
  */
                                 const char *host,int port);
 
 /*
  Remove the provided value from the cell @name in @cfg.
  */
-gras_error_t gras_cfg_rm_int   (gras_cfg_t *cfg, const char *name, 
+gras_error_t gras_cfg_rm_int   (gras_cfg_t cfg, const char *name, 
                                int val);
                                int val);
-gras_error_t gras_cfg_rm_double(gras_cfg_t *cfg, const char *name, 
+gras_error_t gras_cfg_rm_double(gras_cfg_t cfg, const char *name, 
                                double val);
                                double val);
-gras_error_t gras_cfg_rm_string(gras_cfg_t *cfg, const char *name, 
+gras_error_t gras_cfg_rm_string(gras_cfg_t cfg, const char *name, 
                                const char *val);
                                const char *val);
-gras_error_t gras_cfg_rm_host  (gras_cfg_t *cfg, const char *name, 
+gras_error_t gras_cfg_rm_host  (gras_cfg_t cfg, const char *name, 
                                const char *host,int port);
 
 /* rm every values */
                                const char *host,int port);
 
 /* rm every values */
-gras_error_t gras_cfg_empty(gras_cfg_t *cfg, const char *name);        
+gras_error_t gras_cfg_empty(gras_cfg_t cfg, const char *name); 
 
 /*----[ Getting ]---------------------------------------------------------*/
 /* Returns a pointer to the values actually stored in the cache. Do not   */
 /* modify them unless you really know what you're doing.                  */
 
 /*----[ Getting ]---------------------------------------------------------*/
 /* Returns a pointer to the values actually stored in the cache. Do not   */
 /* modify them unless you really know what you're doing.                  */
-gras_error_t gras_cfg_get_int   (gras_cfg_t *cfg,
+gras_error_t gras_cfg_get_int   (gras_cfg_t  cfg,
                                 const char *name,
                                 int        *val);
                                 const char *name,
                                 int        *val);
-gras_error_t gras_cfg_get_double(gras_cfg_t *cfg,
+gras_error_t gras_cfg_get_double(gras_cfg_t  cfg,
                                 const char *name,
                                 double     *val);
                                 const char *name,
                                 double     *val);
-gras_error_t gras_cfg_get_string(gras_cfg_t *cfg,
+gras_error_t gras_cfg_get_string(gras_cfg_t  cfg,
                                 const char *name, 
                                 char      **val);
                                 const char *name, 
                                 char      **val);
-gras_error_t gras_cfg_get_host  (gras_cfg_t *cfg, 
+gras_error_t gras_cfg_get_host  (gras_cfg_t  cfg, 
                                 const char *name, 
                                 char      **host,
                                 int        *port);
                                 const char *name, 
                                 char      **host,
                                 int        *port);
-gras_error_t gras_cfg_get_dynar (gras_cfg_t    *cfg,
-                                const char    *name,
-                                gras_dynar_t **dynar);
-
+gras_error_t gras_cfg_get_dynar (gras_cfg_t    cfg,
+                                const char   *name,
+                      /* OUT */ gras_dynar_t *dynar);
 
 
+END_DECL
+  
 #endif /* _GRAS_CONFIG_H_ */
 #endif /* _GRAS_CONFIG_H_ */
index a209155..cb020d4 100644 (file)
@@ -17,19 +17,19 @@ extern "C"
 #endif
 
 /*####[ Type definition ]####################################################*/
 #endif
 
 /*####[ Type definition ]####################################################*/
-typedef struct gras_dict_ gras_dict_t;
+typedef struct gras_dict_ *gras_dict_t;
 
 /*####[ Simple dict  functions ]#############################################*/
 
 
 /*####[ Simple dict  functions ]#############################################*/
 
-gras_dict_t *gras_dict_new(void);
-void gras_dict_free(gras_dict_t **dict);
+gras_dict_t gras_dict_new(void);
+void gras_dict_free(gras_dict_t *dict);
 
 
 
 
-void gras_dict_set    (gras_dict_t    *head,
+void gras_dict_set    (gras_dict_t     head,
                       const char     *key,
                       void           *data,
                       void_f_pvoid_t *free_ctn);
                       const char     *key,
                       void           *data,
                       void_f_pvoid_t *free_ctn);
-void gras_dict_set_ext(gras_dict_t    *head,
+void gras_dict_set_ext(gras_dict_t     head,
                       const char     *key,
                       int             key_len,
                       void           *data,
                       const char     *key,
                       int             key_len,
                       void           *data,
@@ -39,25 +39,25 @@ void gras_dict_set_ext(gras_dict_t    *head,
 /* Search the given #key#. data=NULL when not found.                         */
 /* Returns true if anything went ok, and false on internal error.            */
 /*---------------------------------------------------------------------------*/
 /* Search the given #key#. data=NULL when not found.                         */
 /* Returns true if anything went ok, and false on internal error.            */
 /*---------------------------------------------------------------------------*/
-gras_error_t gras_dict_get(gras_dict_t *head,const char *key,
+gras_error_t gras_dict_get(gras_dict_t head,const char *key,
                           /* OUT */void **data);
                           /* OUT */void **data);
-gras_error_t gras_dict_get_ext(gras_dict_t *head,const char *key,
+gras_error_t gras_dict_get_ext(gras_dict_t head,const char *key,
                               int key_len,
                               /* OUT */void **data);
 /*----[ gras_dict_remove ]---------------------------------------------------*/
 /* Remove the entry associated with the given #key#.                         */
 /* Returns if ok. Removing a non-existant key is ok.                         */
 /*---------------------------------------------------------------------------*/
                               int key_len,
                               /* OUT */void **data);
 /*----[ gras_dict_remove ]---------------------------------------------------*/
 /* Remove the entry associated with the given #key#.                         */
 /* Returns if ok. Removing a non-existant key is ok.                         */
 /*---------------------------------------------------------------------------*/
-gras_error_t gras_dict_remove(gras_dict_t *head,const char *key);
+gras_error_t gras_dict_remove(gras_dict_t head,const char *key);
 
 
-gras_error_t gras_dict_remove_ext(gras_dict_t *head,const char *key,
-                                  int key_len);
+gras_error_t gras_dict_remove_ext(gras_dict_t head,
+                                 const char *key, int key_len);
 
 /*----[ gras_dict_dump ]-----------------------------------------------------*/
 /* Outputs the content of the structure. (for debuging purpose)              */
 /* #output# is a function to output the data.If NULL, data won't be displayed*/
 /*---------------------------------------------------------------------------*/
 
 /*----[ gras_dict_dump ]-----------------------------------------------------*/
 /* Outputs the content of the structure. (for debuging purpose)              */
 /* #output# is a function to output the data.If NULL, data won't be displayed*/
 /*---------------------------------------------------------------------------*/
-void gras_dict_dump(gras_dict_t *head,
+void gras_dict_dump(gras_dict_t head,
                    void (*output)(void*));
 /*----[ gras_dict_print ]----------------------------------------------------*/
 /* To dump multicache, this function dump a cache                            */
                    void (*output)(void*));
 /*----[ gras_dict_print ]----------------------------------------------------*/
 /* To dump multicache, this function dump a cache                            */
@@ -81,11 +81,11 @@ void gras_dict_prints(void *data);
 /* The key are destroyed in the process. Think to strdup it before.          */
 /* Returns if it was ok or not                                               */
 /*---------------------------------------------------------------------------*/
 /* The key are destroyed in the process. Think to strdup it before.          */
 /* Returns if it was ok or not                                               */
 /*---------------------------------------------------------------------------*/
-gras_error_t gras_multidict_set(gras_dict_t **head,
+gras_error_t gras_multidict_set(gras_dict_t *head,
                                int keycount,char **key,
                                void *data,void (*free_ctn)(void*));
 
                                int keycount,char **key,
                                void *data,void (*free_ctn)(void*));
 
-gras_error_t gras_multidict_set_ext(gras_dict_t **head,
+gras_error_t gras_multidict_set_ext(gras_dict_t *head,
                                    int keycount,char **key,int *key_len,
                                    void *data,void_f_pvoid_t *free_ctn);
 
                                    int keycount,char **key,int *key_len,
                                    void *data,void_f_pvoid_t *free_ctn);
 
@@ -93,11 +93,11 @@ gras_error_t gras_multidict_set_ext(gras_dict_t **head,
 /* Search the given #key#. data=NULL when not found.                         */
 /* Returns true if anything went ok, and false on internal error.            */
 /*---------------------------------------------------------------------------*/
 /* Search the given #key#. data=NULL when not found.                         */
 /* Returns true if anything went ok, and false on internal error.            */
 /*---------------------------------------------------------------------------*/
-gras_error_t gras_multidict_get(gras_dict_t *head,
+gras_error_t gras_multidict_get(gras_dict_t head,
                                int keycount,const char **key,
                                /* OUT */void **data);
 
                                int keycount,const char **key,
                                /* OUT */void **data);
 
-gras_error_t gras_multidict_get_ext(gras_dict_t *head,
+gras_error_t gras_multidict_get_ext(gras_dict_t head,
                                    int keycount,const char **key,int *key_len,
                                    /* OUT */void **data);
 
                                    int keycount,const char **key,int *key_len,
                                    /* OUT */void **data);
 
@@ -105,40 +105,40 @@ gras_error_t gras_multidict_get_ext(gras_dict_t *head,
 /* Remove the entry associated with the given #key#.                         */
 /* Returns if ok. Removing a non-existant key is ok.                         */
 /*---------------------------------------------------------------------------*/
 /* Remove the entry associated with the given #key#.                         */
 /* Returns if ok. Removing a non-existant key is ok.                         */
 /*---------------------------------------------------------------------------*/
-gras_error_t gras_multidict_remove(gras_dict_t *head,
+gras_error_t gras_multidict_remove(gras_dict_t head,
                                   int keycount,const char **key);
 
                                   int keycount,const char **key);
 
-gras_error_t gras_multidict_remove_ext(gras_dict_t *head,
+gras_error_t gras_multidict_remove_ext(gras_dict_t head,
                                        int keycount,const char **key,int *key_len);
 
 /*####[ Cache cursor functions ]#############################################*/
 /* To traverse (simple) caches                                               */
 /* Don't add or remove entries to the cache while traversing !!!             */
 /*###########################################################################*/
                                        int keycount,const char **key,int *key_len);
 
 /*####[ Cache cursor functions ]#############################################*/
 /* To traverse (simple) caches                                               */
 /* Don't add or remove entries to the cache while traversing !!!             */
 /*###########################################################################*/
-typedef struct gras_dict_cursor_ gras_dict_cursor_t;
+typedef struct gras_dict_cursor_ *gras_dict_cursor_t;
 /* creator/destructor */
 /* creator/destructor */
-gras_dict_cursor_t *gras_dict_cursor_new(const gras_dict_t *head);
-void                gras_dict_cursor_free(gras_dict_cursor_t *cursor);
+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*/
 
 /* back to first element 
    it is not enough to reinit the cache after an add/remove in cache*/
-void gras_dict_cursor_rewind(gras_dict_cursor_t *cursor);
+void gras_dict_cursor_rewind(gras_dict_cursor_t cursor);
 
 
 
 
-gras_error_t gras_dict_cursor_get_key     (gras_dict_cursor_t *cursor,
+gras_error_t gras_dict_cursor_get_key     (gras_dict_cursor_t cursor,
                                           /*OUT*/char **key);
                                           /*OUT*/char **key);
-gras_error_t gras_dict_cursor_get_data    (gras_dict_cursor_t *cursor,
+gras_error_t gras_dict_cursor_get_data    (gras_dict_cursor_t cursor,
                                           /*OUT*/void **data);
 
                                           /*OUT*/void **data);
 
-void gras_dict_cursor_first (const gras_dict_t   *dict,
-                            gras_dict_cursor_t **cursor);
-void         gras_dict_cursor_step        (gras_dict_cursor_t  *cursor);
-int          gras_dict_cursor_get_or_free (gras_dict_cursor_t **cursor,
-                                          char               **key,
-                                          void               **data);
-#define gras_dict_foreach(dict,cursor,key,data)                        \
-  for (cursor=NULL, gras_dict_cursor_first((dict),&(cursor)) ;         \
-       gras_dict_cursor_get_or_free(&(cursor),&(key),(void**)(&data)); \
+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,
+                                          void              **data);
+#define gras_dict_foreach(dict,cursor,key,data)                       \
+  for (cursor=NULL, gras_dict_cursor_first((dict),&(cursor)) ;        \
+       gras_dict_cursor_get_or_free(&(cursor),&(key),(void**)(&data));\
        gras_dict_cursor_step(cursor) )
 
 #ifdef  __cplusplus
        gras_dict_cursor_step(cursor) )
 
 #ifdef  __cplusplus
index 2a86250..801180a 100644 (file)
 #ifndef _GRAS_DYNAR_H
 #define _GRAS_DYNAR_H
 
 #ifndef _GRAS_DYNAR_H
 #define _GRAS_DYNAR_H
 
-typedef struct gras_dynar_s gras_dynar_t;
+#include "xbt/misc.h" /* BEGIN_DECL */
+
+BEGIN_DECL
+
+typedef struct gras_dynar_s *gras_dynar_t;
 
 /* pointer to a function freeing something */
 typedef   void (void_f_ppvoid_t)(void**);
 typedef   void (void_f_pvoid_t) (void*);
 
 
 /* pointer to a function freeing something */
 typedef   void (void_f_ppvoid_t)(void**);
 typedef   void (void_f_pvoid_t) (void*);
 
-gras_dynar_t *gras_dynar_new(unsigned long elm_size, 
+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);
 
                             void_f_pvoid_t *free_func);
 void          gras_dynar_free(gras_dynar_t *dynar);
 void          gras_dynar_free_container(gras_dynar_t *dynar);
 
-unsigned long gras_dynar_length(const gras_dynar_t *dynar);
-void          gras_dynar_reset(gras_dynar_t *dynar);
+unsigned long gras_dynar_length(const gras_dynar_t dynar);
+void          gras_dynar_reset(gras_dynar_t dynar);
 
 
 /* regular array functions */
 
 
 /* regular array functions */
-void gras_dynar_get_cpy(const gras_dynar_t *dynar, int idx, void *const dst);
-void *gras_dynar_get_ptr(const gras_dynar_t * const dynar,
-                        const int                  idx);
+void gras_dynar_get_cpy(const gras_dynar_t dynar, int idx, void *const dst);
+void *gras_dynar_get_ptr(const gras_dynar_t dynar,
+                        const int          idx);
 
 #define gras_dynar_get_as(dynar,idx,type) *(type*)gras_dynar_get_ptr(dynar,idx)
   
 
 #define gras_dynar_get_as(dynar,idx,type) *(type*)gras_dynar_get_ptr(dynar,idx)
   
-void gras_dynar_set(gras_dynar_t *dynar, int  idx, const void *src);
-void gras_dynar_replace(gras_dynar_t *dynar,
+void gras_dynar_set(gras_dynar_t dynar, int  idx, const void *src);
+void gras_dynar_replace(gras_dynar_t dynar,
                        int idx, const void *object);
 
 /* perl array function */
                        int idx, const void *object);
 
 /* perl array function */
-void gras_dynar_insert_at(gras_dynar_t *dynar,
-                          int  idx, const void *src);
-void gras_dynar_remove_at(gras_dynar_t *dynar,
-                          int  idx, void *object);
-void gras_dynar_push     (gras_dynar_t *dynar, const void *src);
-void gras_dynar_pop      (gras_dynar_t *dynar, void *const dst);
-void gras_dynar_unshift  (gras_dynar_t *dynar, const void *src);
-void gras_dynar_shift    (gras_dynar_t *dynar, void *const dst);
-void gras_dynar_map      (const gras_dynar_t *dynar, void_f_pvoid_t *operator);
+
+void gras_dynar_insert_at(gras_dynar_t dynar,
+                         int  idx, const void *src);
+void gras_dynar_remove_at(gras_dynar_t dynar,
+                         int  idx, void *object);
+void gras_dynar_push     (gras_dynar_t dynar, const void *src);
+void gras_dynar_pop      (gras_dynar_t dynar, void *const dst);
+void gras_dynar_unshift  (gras_dynar_t dynar, const void *src);
+void gras_dynar_shift    (gras_dynar_t dynar, void *const dst);
+void gras_dynar_map      (const gras_dynar_t dynar, void_f_pvoid_t *operator);
+
+/* speed-optimized versions */
+void *gras_dynar_insert_at_ptr(gras_dynar_t const dynar,
+                              const int          idx);
+void *gras_dynar_push_ptr(gras_dynar_t dynar);
+void *gras_dynar_pop_ptr(gras_dynar_t dynar);
+
+#define gras_dynar_insert_at_as(dynar,idx,type,value) *(type*)gras_dynar_insert_at_ptr(dynar,idx)=value
+#define gras_dynar_push_as(dynar,type,value) *(type*)gras_dynar_push_ptr(dynar)=value
+#define gras_dynar_pop_as(dynar,type) *(type*)gras_dynar_pop_ptr(dynar)
+
 
 /* cursor functions */
 
 /* 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_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);
 
 /**
  * gras_dynar_foreach:
 
 /**
  * gras_dynar_foreach:
@@ -79,7 +95,8 @@ int  gras_dynar_cursor_get   (const gras_dynar_t *dynar, int *cursor, void *wher
            gras_dynar_length(_dynar) && gras_dynar_cursor_get(_dynar,&_cursor,&_data); \
             gras_dynar_cursor_step(_dynar,&_cursor))
 */
            gras_dynar_length(_dynar) && gras_dynar_cursor_get(_dynar,&_cursor,&_data); \
             gras_dynar_cursor_step(_dynar,&_cursor))
 */
-void gras_dynar_cursor_rm(gras_dynar_t dynar,
-                         int          * const cursor);
+void gras_dynar_cursor_rm(gras_dynar_t dynar,
+                         int          *const cursor);
 
 
+END_DECL
 #endif /* _GRAS_DYNAR_H */
 #endif /* _GRAS_DYNAR_H */
index 9aa54b2..4dabcc8 100644 (file)
@@ -3,7 +3,7 @@
 /* gras/error.h - Error tracking support                                    */
 
 /* Authors: Martin Quinson                                                  */
 /* gras/error.h - Error tracking support                                    */
 
 /* Authors: Martin Quinson                                                  */
-/* Copyright (C) 2003 the OURAGAN project.                                  */
+/* Copyright (C) 2003,2004 da GRAS posse.                                   */
 
 /* 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. */
 #ifndef GRAS_ERROR_H
 #define GRAS_ERROR_H
 
 #ifndef GRAS_ERROR_H
 #define GRAS_ERROR_H
 
-#include <stddef.h>    /* offsetof() */
-#include <sys/types.h>  /* size_t */
-#include <stdarg.h>
-
 #include <stdio.h> /* FIXME: Get rid of it */
 
 #include <stdio.h> /* FIXME: Get rid of it */
 
+#include "xbt/misc.h" /* BEGIN_DECL */
 #include "xbt/log.h"
 
 #ifdef HAVE_EXECINFO_H
 #include <execinfo.h>  /* to print the backtrace */
 #endif
 
 #include "xbt/log.h"
 
 #ifdef HAVE_EXECINFO_H
 #include <execinfo.h>  /* to print the backtrace */
 #endif
 
-/* 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
 
 typedef enum {
 BEGIN_DECL
 
 typedef enum {
-  no_error=0,     /* succes */
-//  malloc_error,   /* Well known error */
-  mismatch_error, /* The provided ID does not match */
-  system_error,   /* a syscall did fail */
-  network_error,  /* error while sending/receiving data */
-  timeout_error,  /* not quick enough, dude */
-  thread_error,   /* error while [un]locking */
-  unknown_error 
+  no_error=0,       /* succes */
+  mismatch_error=1, /* The provided ID does not match */
+  system_error=2,   /* a syscall did fail */
+  network_error=3,  /* error while sending/receiving data */
+  timeout_error=4,  /* not quick enough, dude */
+  thread_error=5,   /* error while [un]locking */
+  unknown_error=6,
+     
+  /* remote errors: result of a RMI/RPC.
+     no_error(=0) is the same for both */   
+  remote_mismatch_error=129,
+  remote_system_error,
+  remote_network_error,
+  remote_timeout_error,
+  remote_thread_error,
+  remote_unknown_error
 } gras_error_t;
 
 /*@observer@*/ const char *gras_error_name(gras_error_t errcode);
 } gras_error_t;
 
 /*@observer@*/ const char *gras_error_name(gras_error_t errcode);
@@ -108,7 +94,7 @@ typedef enum {
   return code;                                                 \
 } while (0)
 
   return code;                                                 \
 } while (0)
 
-#else
+#else /* if 0 */
 #define _GRAS_ERR_PRE do {
 #define _GRAS_ERR_POST(code)                                   \
   return code;                                                 \
 #define _GRAS_ERR_PRE do {
 #define _GRAS_ERR_POST(code)                                   \
   return code;                                                 \
@@ -168,6 +154,8 @@ typedef enum {
 #define gras_assert6(cond,msg,a,b,c,d,e,f) if (!(cond)) { CRITICAL6(msg,a,b,c,d,e,f); gras_abort(); }
 #endif
 
 #define gras_assert6(cond,msg,a,b,c,d,e,f) if (!(cond)) { CRITICAL6(msg,a,b,c,d,e,f); gras_abort(); }
 #endif
 
+void gras_die(const char *msg);
+
 #define DIE_IMPOSSIBLE gras_assert0(0,"The Impossible did happen (yet again)")
 #define gras_assert_error(a) gras_assert1(errcode == (a), "Error %s unexpected",gras_error_name(errcode))
 
 #define DIE_IMPOSSIBLE gras_assert0(0,"The Impossible did happen (yet again)")
 #define gras_assert_error(a) gras_assert1(errcode == (a), "Error %s unexpected",gras_error_name(errcode))
 
index d95838a..b2e83b5 100644 (file)
@@ -21,7 +21,7 @@
 #include "xbt/sysdep.h"
 
 /**
 #include "xbt/sysdep.h"
 
 /**
- * gras_log_priority_t:
+ * e_gras_log_priority_t:
  * @gras_log_priority_none:          used internally (don't poke with)
  * @gras_log_priority_debug:         crufty output 
  * @gras_log_priority_verbose:       verbose output for the user wanting more
  * @gras_log_priority_none:          used internally (don't poke with)
  * @gras_log_priority_debug:         crufty output 
  * @gras_log_priority_verbose:       verbose output for the user wanting more
@@ -47,7 +47,7 @@ typedef enum {
   gras_log_priority_infinite      = 8, 
 
   gras_log_priority_uninitialized = -1 
   gras_log_priority_infinite      = 8, 
 
   gras_log_priority_uninitialized = -1 
-} gras_log_priority_t;
+} e_gras_log_priority_t;
              
 
 /**
              
 
 /**
@@ -93,8 +93,8 @@ typedef enum {
  * Defines a new subcategory of the parent. 
  */
 #define GRAS_LOG_NEW_SUBCATEGORY(catName, parent, desc) \
  * Defines a new subcategory of the parent. 
  */
 #define GRAS_LOG_NEW_SUBCATEGORY(catName, parent, desc) \
-    extern gras_log_category_t _GRAS_LOGV(parent);    \
-    gras_log_category_t _GRAS_LOGV(catName) = {       \
+    extern s_gras_log_category_t _GRAS_LOGV(parent);    \
+    s_gras_log_category_t _GRAS_LOGV(catName) = {       \
         &_GRAS_LOGV(parent), 0, 0,                    \
         #catName, gras_log_priority_uninitialized, 1, \
         0, 1                                          \
         &_GRAS_LOGV(parent), 0, 0,                    \
         #catName, gras_log_priority_uninitialized, 1, \
         0, 1                                          \
@@ -120,7 +120,7 @@ typedef enum {
 # define GRAS_LOG_DEFAULT_CATEGORY(cname)
 #else
 # define GRAS_LOG_DEFAULT_CATEGORY(cname) \
 # define GRAS_LOG_DEFAULT_CATEGORY(cname)
 #else
 # define GRAS_LOG_DEFAULT_CATEGORY(cname) \
-        static gras_log_category_t* _GRAS_LOGV(default) = &_GRAS_LOGV(cname)
+        static gras_log_category_t _GRAS_LOGV(default) = &_GRAS_LOGV(cname)
 #endif
 
 /**
 #endif
 
 /**
@@ -157,41 +157,41 @@ typedef enum {
  */
 
 #define GRAS_LOG_EXTERNAL_CATEGORY(cname) \
  */
 
 #define GRAS_LOG_EXTERNAL_CATEGORY(cname) \
-   extern gras_log_category_t _GRAS_LOGV(cname)
+   extern s_gras_log_category_t _GRAS_LOGV(cname)
 
 /* Functions you may call */
 
 extern void gras_log_control_set(const char* cs);
 
 /* Forward declarations */
 
 /* Functions you may call */
 
 extern void gras_log_control_set(const char* cs);
 
 /* Forward declarations */
-typedef struct gras_log_appender_s gras_log_appender_t;
-typedef struct gras_log_event_s    gras_log_event_t;
-typedef struct gras_log_category_s gras_log_category_t;
+typedef struct gras_log_appender_s s_gras_log_appender_t,*gras_log_appender_t;
+typedef struct gras_log_event_s    s_gras_log_event_t,   *gras_log_event_t;
+typedef struct gras_log_category_s s_gras_log_category_t,*gras_log_category_t;
 
 /**
 
 /**
- * Do NOT access any members of this structure directly.
+ * Do NOT access any members of this structure directly. FIXME: move to private?
  */
 struct gras_log_category_s {
  */
 struct gras_log_category_s {
-            gras_log_category_t *parent;
-/*@null@*/  gras_log_category_t *firstChild; 
-/*@null@*/  gras_log_category_t *nextSibling;
+            gras_log_category_t parent;
+/*@null@*/  gras_log_category_t firstChild; 
+/*@null@*/  gras_log_category_t nextSibling;
             const char *name;
             int threshold;
             int isThreshInherited;
             const char *name;
             int threshold;
             int isThreshInherited;
-/*@null@*/  gras_log_appender_t *appender;
+/*@null@*/  gras_log_appender_t appender;
             int willLogToParent;
   /* TODO: Formats? */
 };
 
 struct gras_log_appender_s {
             int willLogToParent;
   /* TODO: Formats? */
 };
 
 struct gras_log_appender_s {
-  void (*do_append) (gras_log_appender_t* thisLogAppender,
-                   gras_log_event_t* event, const char *fmt);
+  void (*do_append) (gras_log_appender_t thisLogAppender,
+                   gras_log_event_t event, const char *fmt);
   void *appender_data;
 };
 
 struct gras_log_event_s {
   void *appender_data;
 };
 
 struct gras_log_event_s {
-  gras_log_category_t* cat;
-  gras_log_priority_t priority;
+  gras_log_category_t cat;
+  e_gras_log_priority_t priority;
   const char* fileName;
   const char* functionName;
   int lineNum;
   const char* fileName;
   const char* functionName;
   int lineNum;
@@ -205,8 +205,8 @@ struct gras_log_event_s {
  *
  * Programatically alters a category's threshold priority (don't use).
  */
  *
  * Programatically alters a category's threshold priority (don't use).
  */
-extern void gras_log_threshold_set(gras_log_category_t* cat,
-                                  gras_log_priority_t thresholdPriority);
+extern void gras_log_threshold_set(gras_log_category_t cat,
+                                  e_gras_log_priority_t thresholdPriority);
 
 /**
  * gras_log_parent_set:
 
 /**
  * gras_log_parent_set:
@@ -215,8 +215,8 @@ extern void gras_log_threshold_set(gras_log_category_t* cat,
  *
  * Programatically alter a category's parent (don't use).
  */
  *
  * Programatically alter a category's parent (don't use).
  */
-extern void gras_log_parent_set(gras_log_category_t* cat, 
-                               gras_log_category_t* parent);
+extern void gras_log_parent_set(gras_log_category_t cat,
+                               gras_log_category_t parent);
 
 /**
  * gras_log_appender_set:
 
 /**
  * gras_log_appender_set:
@@ -225,21 +225,21 @@ extern void gras_log_parent_set(gras_log_category_t* cat,
  *
  * Programatically sets the category's appender (don't use).
  */
  *
  * Programatically sets the category's appender (don't use).
  */
-extern void gras_log_appender_set(gras_log_category_t* cat,
-                                 gras_log_appender_t* app);
+extern void gras_log_appender_set(gras_log_category_t cat,
+                                 gras_log_appender_t app);
 
 /* Functions that you shouldn't call. */
 
 /* Functions that you shouldn't call. */
-extern void _gras_log_event_log(gras_log_event_t*ev,
+extern void _gras_log_event_log(gras_log_event_t ev,
                                const char *fmt,
                                ...) _GRAS_GNUC_PRINTF(2,3);
 
                                const char *fmt,
                                ...) _GRAS_GNUC_PRINTF(2,3);
 
-extern int _gras_log_cat_init(gras_log_priority_t priority, 
-                             gras_log_category_t* category);
+extern int _gras_log_cat_init(e_gras_log_priority_t priority, 
+                             gras_log_category_t   category);
 
 
 
 
-extern gras_log_category_t _GRAS_LOGV(GRAS_LOG_ROOT_CAT);
+extern s_gras_log_category_t _GRAS_LOGV(GRAS_LOG_ROOT_CAT);
 GRAS_LOG_EXTERNAL_CATEGORY(GRAS);
 GRAS_LOG_EXTERNAL_CATEGORY(GRAS);
-extern gras_log_appender_t *gras_log_default_appender;
+extern gras_log_appender_t gras_log_default_appender;
 
 /**
  * GRAS_LOG_ISENABLED:
 
 /**
  * GRAS_LOG_ISENABLED:
@@ -282,7 +282,7 @@ extern gras_log_appender_t *gras_log_default_appender;
 
 #define _GRAS_LOG_PRE(catv, priority) do {                              \
      if (_GRAS_LOG_ISENABLEDV(catv, priority)) {                        \
 
 #define _GRAS_LOG_PRE(catv, priority) do {                              \
      if (_GRAS_LOG_ISENABLEDV(catv, priority)) {                        \
-         gras_log_event_t _log_ev =                                     \
+         s_gras_log_event_t _log_ev =                                   \
              {&(catv),priority,__FILE__,_GRAS_GNUC_FUNCTION,__LINE__};         \
          _gras_log_event_log(&_log_ev
 
              {&(catv),priority,__FILE__,_GRAS_GNUC_FUNCTION,__LINE__};         \
          _gras_log_event_log(&_log_ev
 
index 5ab5d1c..dc4a66a 100644 (file)
 #ifndef _GRAS_SET_H
 #define _GRAS_SET_H
 
 #ifndef _GRAS_SET_H
 #define _GRAS_SET_H
 
-#ifdef  __cplusplus
-extern "C" 
-#endif
+#include "xbt/misc.h" /* BEGIN_DECL */
+
+BEGIN_DECL
 
 /*####[ Type definition ]####################################################*/
 
 /*####[ Type definition ]####################################################*/
-typedef struct gras_set_ gras_set_t;
+typedef struct gras_set_ *gras_set_t;
 typedef struct gras_set_elm_ {
   unsigned int ID;
   char        *name;
   unsigned int name_len;
 typedef struct gras_set_elm_ {
   unsigned int ID;
   char        *name;
   unsigned int name_len;
-} gras_set_elm_t;
+} s_gras_set_elm_t,*gras_set_elm_t;
 
 /*####[ Functions ]##########################################################*/
 
 
 /*####[ Functions ]##########################################################*/
 
-gras_set_t *gras_set_new (void);
-void gras_set_free(gras_set_t **set);
+gras_set_t gras_set_new (void);
+void gras_set_free(gras_set_t *set);
 
 
 
 
-void gras_set_add (gras_set_t     *set,
-                  gras_set_elm_t *elm,
+void gras_set_add (gras_set_t      set,
+                  gras_set_elm_t  elm,
                   void_f_pvoid_t *free_func);
 
 /*----[ gras_set_retrieve ]-------------------------------------------------*/
 /* Search the given #key#. data=NULL when not found.                         */
 /*---------------------------------------------------------------------------*/
                   void_f_pvoid_t *free_func);
 
 /*----[ gras_set_retrieve ]-------------------------------------------------*/
 /* Search the given #key#. data=NULL when not found.                         */
 /*---------------------------------------------------------------------------*/
-gras_error_t gras_set_get_by_name    (gras_set_t     *set,
+gras_error_t gras_set_get_by_name    (gras_set_t      set,
                                      const char     *key,
                                      const char     *key,
-                                     /* OUT */gras_set_elm_t **dst);
-gras_error_t gras_set_get_by_name_ext(gras_set_t     *set,
+                                     /* OUT */gras_set_elm_t *dst);
+gras_error_t gras_set_get_by_name_ext(gras_set_t      set,
                                      const char     *name,
                                      int             name_len,
                                      const char     *name,
                                      int             name_len,
-                                     /* OUT */gras_set_elm_t **dst);
-gras_error_t gras_set_get_by_id      (gras_set_t     *set,
+                                     /* OUT */gras_set_elm_t *dst);
+gras_error_t gras_set_get_by_id      (gras_set_t      set,
                                      int             id,
                                      int             id,
-                                     /* OUT */gras_set_elm_t **dst);
+                                     /* OUT */gras_set_elm_t *dst);
                                      
 /*####[ Cache cursor functions ]#############################################*/
 /* To traverse (simple) caches                                               */
 /* Don't add or remove entries to the cache while traversing !!!             */
 /*###########################################################################*/
                                      
 /*####[ Cache cursor functions ]#############################################*/
 /* To traverse (simple) caches                                               */
 /* Don't add or remove entries to the cache while traversing !!!             */
 /*###########################################################################*/
-typedef struct gras_set_cursor_ gras_set_cursor_t;
-/* creator/destructor */
-void         gras_set_cursor_first       (gras_set_t   *set,
-                                         gras_set_cursor_t **cursor);
-void         gras_set_cursor_step        (gras_set_cursor_t  *cursor);
-int          gras_set_cursor_get_or_free (gras_set_cursor_t **cursor,
-                                         gras_set_elm_t    **elm);
+typedef struct gras_set_cursor_ *gras_set_cursor_t;
+
+void         gras_set_cursor_first       (gras_set_t         set,
+                                         gras_set_cursor_t *cursor);
+void         gras_set_cursor_step        (gras_set_cursor_t  cursor);
+int          gras_set_cursor_get_or_free (gras_set_cursor_t *cursor,
+                                         gras_set_elm_t    *elm);
 
 #define gras_set_foreach(set,cursor,elm)                       \
   for ((cursor) = NULL, gras_set_cursor_first((set),&(cursor)) ;   \
 
 #define gras_set_foreach(set,cursor,elm)                       \
   for ((cursor) = NULL, gras_set_cursor_first((set),&(cursor)) ;   \
-       gras_set_cursor_get_or_free(&(cursor),(gras_set_elm_t**)&(elm));          \
+       gras_set_cursor_get_or_free(&(cursor),(gras_set_elm_t*)&(elm));          \
        gras_set_cursor_step(cursor) )
 
        gras_set_cursor_step(cursor) )
 
-#ifdef  __cplusplus
-}
-#endif
+END_DECL
 
 #endif /* _GRAS_SET_H */
 
 #endif /* _GRAS_SET_H */
index 852c466..59df441 100644 (file)
 
 #include <time.h> /* FIXME: remove */
 #include <unistd.h> /* FIXME: remove */
 
 #include <time.h> /* FIXME: remove */
 #include <unistd.h> /* FIXME: remove */
-
-#ifdef  __cplusplus
-extern "C" 
+#include <stdlib.h> 
+
+#include "xbt/misc.h"
+BEGIN_DECL
+#if 0
+#define __CALLOC_OP(n, s)  calloc((n), (s))
+  #define __REALLOC_OP(n, s)  realloc((n), (s))
+#define CALLOC(n, s)  ((__CALLOC_OP  ((n)?:(FAILURE("attempt to alloc 0 bytes"), 0), (s)?:(FAILURE("attempt to alloc 0 bytes"), 0)))?:(FAILURE("memory allocation error"), NULL))
+  /* #define REALLOC(p, s) ((__REALLOC_OP ((p), (s)?:(FAILURE("attempt to alloc 0 bytes"), 0)))?:(FAILURE("memory reallocation error"), NULL)) */
+  #define REALLOC(p, s) (__REALLOC_OP ((p), (s)))
 #endif
 #endif
-
-char* gras_strdup  (const char *str);
-void* gras_malloc  (long int bytes);
-void* gras_malloc0 (long int bytes);
-void* gras_realloc (void  *memory, long int bytes);
-void  gras_free    (void  *memory);
-
+  
+#define gras_strdup(s)  ((s)?(strdup(s)?:(gras_die("memory allocation error"),NULL))\
+                           :(NULL))
+#define gras_malloc(n)   (malloc(n) ?: (gras_die("memory allocation error"),NULL))
+#define gras_malloc0(n)  (calloc( (n),1 ) ?: (gras_die("memory allocation error"),NULL))
+#define gras_realloc(p,s) (s? (p? (realloc(p,s)?:gras_die("memory allocation error"),NULL) \
+                               : gras_malloc(s)) \
+                           : (p? (free(p),NULL) \
+                               : NULL))
+#define gras_free free /*nothing specific to do here. A poor valgrind replacement?*/
+#define gras_free_fct free /* replacement with the guareenty of being a function */
+   
 #define gras_new(type, count)  ((type*)gras_malloc (sizeof (type) * (count)))
 #define gras_new0(type, count) ((type*)gras_malloc0 (sizeof (type) * (count)))
 
 #define gras_new(type, count)  ((type*)gras_malloc (sizeof (type) * (count)))
 #define gras_new0(type, count) ((type*)gras_malloc0 (sizeof (type) * (count)))
 
@@ -71,10 +83,6 @@ long int strtol(const char *nptr, char **endptr, int base);
 double strtod(const char *nptr, char **endptr);
 int atoi(const char *nptr);
 
 double strtod(const char *nptr, char **endptr);
 int atoi(const char *nptr);
 
-
-   
-#ifdef  __cplusplus
-}
-#endif
+END_DECL   
 
 #endif /* _GRAS_SYSDEP_H */
 
 #endif /* _GRAS_SYSDEP_H */