From efb4f45908f62882ef6ebd34742f29d079d99736 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Thu, 5 Dec 2013 21:59:49 +0100 Subject: [PATCH] Use SG_{BEGIN,END}_DECL() for what it's designed to serve. --- include/simgrid/platf.h | 22 ++---------- include/surf/surf_routing.h | 8 ++--- include/xbt/heap.h | 11 +++--- include/xbt/module.h | 12 +++---- src/include/instr/instr_interface.h | 8 ++--- src/include/simgrid/platf_interface.h | 13 +++---- src/include/simgrid/sg_config.h | 8 ++--- src/include/surf/maxmin.h | 8 ++--- src/include/surf/surf.h | 12 ------- src/include/surf/trace_mgr.h | 10 ++---- src/instr/instr_private.h | 16 ++------- src/simix/smx_host_private.h | 11 +++--- src/simix/smx_smurf_private.h | 10 +++--- src/surf/gtnets/gtnets_interface.h | 49 +++++++++++++-------------- src/surf/ns3/ns3_interface.h | 11 +++--- src/surf/surf_interface.hpp | 4 --- src/surf/surf_private.h | 8 ++--- 17 files changed, 69 insertions(+), 152 deletions(-) diff --git a/include/simgrid/platf.h b/include/simgrid/platf.h index 6bf1cbec28..20bb10f269 100644 --- a/include/simgrid/platf.h +++ b/include/simgrid/platf.h @@ -11,16 +11,12 @@ #include +SG_BEGIN_DECL() + typedef void *sg_routing_link_t; /* FIXME:The actual type is model-dependent so use void* instead*/ typedef struct RoutingEdge *sg_routing_edge_t; -#ifdef __cplusplus -extern "C" { -#endif XBT_PUBLIC(sg_routing_edge_t) sg_routing_edge_by_name_or_null(const char *name); -#ifdef __cplusplus -} -#endif /** Defines whether a given resource is working or not */ typedef enum { @@ -53,9 +49,6 @@ typedef struct tmgr_trace *tmgr_trace_t; /**< Opaque structure defining an avail /** opaque structure defining a event generator for availability based on a probability distribution */ typedef struct probabilist_event_generator *probabilist_event_generator_t; -#ifdef __cplusplus -extern "C" { -#endif XBT_PUBLIC(tmgr_trace_t) tmgr_trace_new_from_file(const char *filename); XBT_PUBLIC(tmgr_trace_t) tmgr_trace_new_from_string(const char *id, const char *input, @@ -80,9 +73,6 @@ XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_exponential(c XBT_PUBLIC(probabilist_event_generator_t) tmgr_event_generator_new_weibull(const char* id, double scale, double shape); -#ifdef __cplusplus -} -#endif typedef xbt_dictelm_t sg_host_t; static inline char* sg_host_name(sg_host_t host) { @@ -331,10 +321,6 @@ typedef struct s_sg_platf_gpu_cbarg { /* ***************************************** */ -#ifdef __cplusplus -extern "C" { -#endif - XBT_PUBLIC(void) sg_platf_begin(void); // Start a new platform XBT_PUBLIC(void) sg_platf_end(void); // Finish the creation of the platform @@ -384,8 +370,6 @@ XBT_PUBLIC(void) sg_platf_ASroute_add_link (const char* link_id, sg_platf_route_ typedef void (*sg_platf_process_cb_t)(sg_platf_process_cbarg_t); XBT_PUBLIC(void) sg_platf_process_add_cb(sg_platf_process_cb_t fct); -#ifdef __cplusplus -} -#endif +SG_END_DECL() #endif /* SG_PLATF_H */ diff --git a/include/surf/surf_routing.h b/include/surf/surf_routing.h index 3c2e36a3a6..1e03fdfeef 100644 --- a/include/surf/surf_routing.h +++ b/include/surf/surf_routing.h @@ -10,9 +10,7 @@ #include "xbt/lib.h" #include "simgrid/platf_interface.h" -#ifdef __cplusplus -extern "C" { -#endif +SG_BEGIN_DECL() XBT_PUBLIC(xbt_lib_t) host_lib; XBT_PUBLIC(int) ROUTING_HOST_LEVEL; //Routing level @@ -51,8 +49,6 @@ void routing_AS_end(sg_platf_AS_cbarg_t AS); void routing_cluster_add_backbone(void* bb); -#ifdef __cplusplus -} -#endif +SG_END_DECL() #endif /* _SURF_SURF_H */ diff --git a/include/xbt/heap.h b/include/xbt/heap.h index cc50c023a3..46a1dbc078 100644 --- a/include/xbt/heap.h +++ b/include/xbt/heap.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2004-2007, 2009-2011. The SimGrid Team. +/* Copyright (c) 2004-2007, 2009-2011, 2013. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -10,15 +10,14 @@ #include "xbt/misc.h" #include "xbt/dynar.h" /* void_f_pvoid_t */ +SG_BEGIN_DECL() + /** @addtogroup XBT_heap * @brief This section describes the API to generic heap with O(log(n)) access. * * @{ */ /* @brief heap datatype */ -#ifdef __cplusplus -extern "C" { -#endif typedef struct xbt_heap *xbt_heap_t; XBT_PUBLIC(xbt_heap_t) xbt_heap_new(int init_size, @@ -36,8 +35,6 @@ XBT_PUBLIC(void) xbt_heap_set_update_callback(xbt_heap_t H, *, int)); XBT_PUBLIC(void *) xbt_heap_remove(xbt_heap_t H, int i); -#ifdef __cplusplus -} -#endif /* @} */ +SG_END_DECL() #endif /* _XBT_HEAP_H */ diff --git a/include/xbt/module.h b/include/xbt/module.h index 29cad1bf0f..2e877879fd 100644 --- a/include/xbt/module.h +++ b/include/xbt/module.h @@ -1,6 +1,6 @@ /* module - modularize the code */ -/* Copyright (c) 2004-2007, 2009-2010, 2012. The SimGrid Team. +/* Copyright (c) 2004-2007, 2009-2010, 2012, 2013. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -11,13 +11,11 @@ #include /* XBT_PUBLIC */ -#ifdef __cplusplus -extern "C" { -#endif +SG_BEGIN_DECL() + XBT_PUBLIC(void) xbt_init(int *argc, char **argv); XBT_PUBLIC(void) xbt_exit(void); -#ifdef __cplusplus -} -#endif + +SG_END_DECL() #endif /* _XBT_MODULE_H */ diff --git a/src/include/instr/instr_interface.h b/src/include/instr/instr_interface.h index 0f5c429c94..cb1ccdccbc 100644 --- a/src/include/instr/instr_interface.h +++ b/src/include/instr/instr_interface.h @@ -1,8 +1,6 @@ #include "xbt.h" -#ifdef __cplusplus -extern "C" { -#endif +SG_BEGIN_DECL() XBT_PUBLIC(int) TRACE_start (void); XBT_PUBLIC(int) TRACE_end (void); @@ -13,6 +11,4 @@ XBT_PUBLIC(void) TRACE_surf_resource_utilization_release(void); XBT_PUBLIC(void) TRACE_add_start_function(void (*func)(void)); XBT_PUBLIC(void) TRACE_add_end_function(void (*func)(void)); -#ifdef __cplusplus -} -#endif +SG_END_DECL() diff --git a/src/include/simgrid/platf_interface.h b/src/include/simgrid/platf_interface.h index 7091f049e8..6a8a0054f5 100644 --- a/src/include/simgrid/platf_interface.h +++ b/src/include/simgrid/platf_interface.h @@ -1,6 +1,6 @@ /* platf_interface.h - Internal interface to the SimGrid platforms */ -/* Copyright (c) 2004-2007, 2009-2012. The SimGrid Team. +/* Copyright (c) 2004-2007, 2009-2013. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -12,6 +12,8 @@ #include "simgrid/platf.h" /* public interface */ #include "xbt/RngStream.h" +SG_BEGIN_DECL() + /* Module management functions */ XBT_PUBLIC(void) sg_platf_init(void); XBT_PUBLIC(void) sg_platf_exit(void); @@ -41,10 +43,6 @@ typedef void (*sg_platf_mstorage_cb_t)(sg_platf_mstorage_cbarg_t); /* ***************************************** */ /* TUTORIAL: New TAG */ -#ifdef __cplusplus -extern "C" { -#endif - typedef void (*sg_platf_gpu_cb_t)(sg_platf_gpu_cbarg_t); XBT_PUBLIC(void) sg_platf_gpu_add_cb(sg_platf_gpu_cb_t); /* ***************************************** */ @@ -74,9 +72,6 @@ XBT_PUBLIC(void) sg_platf_mstorage_add_cb(sg_platf_mstorage_cb_t fct); XBT_PUBLIC(void) sg_platf_storage_type_add_cb(sg_platf_storage_type_cb_t fct); XBT_PUBLIC(void) sg_platf_mount_add_cb(sg_platf_mount_cb_t fct); -#ifdef __cplusplus -} -#endif /** \brief Pick the right models for CPU, net and workstation, and call their model_init_preparse * * Must be called within parsing/creating the environment (after the s, if any, and before or friends such as ) @@ -87,4 +82,6 @@ XBT_PUBLIC(void) surf_config_models_setup(void); XBT_PUBLIC(void) sg_platf_rng_stream_init(unsigned long seed[6]); XBT_PUBLIC(RngStream) sg_platf_rng_stream_get(const char* id); +SG_END_DECL() + #endif /* SG_PLATF_INTERFACE_H */ diff --git a/src/include/simgrid/sg_config.h b/src/include/simgrid/sg_config.h index 3d01e63d01..33665a081b 100644 --- a/src/include/simgrid/sg_config.h +++ b/src/include/simgrid/sg_config.h @@ -10,9 +10,7 @@ /*** Config Globals **************************/ /*******************************************/ -#ifdef __cplusplus -extern "C" { -#endif +SG_BEGIN_DECL() XBT_PUBLIC_DATA(xbt_cfg_t) _sg_cfg_set; XBT_PUBLIC_DATA(int) _sg_cfg_init_status; @@ -27,6 +25,4 @@ XBT_PUBLIC(xbt_dynar_t) sg_cfg_get_dynar(const char* name); void sg_config_init(int *argc, char **argv); void sg_config_finalize(void); -#ifdef __cplusplus -} -#endif +SG_END_DECL() diff --git a/src/include/surf/maxmin.h b/src/include/surf/maxmin.h index e4e67c5c78..94a1f7d003 100644 --- a/src/include/surf/maxmin.h +++ b/src/include/surf/maxmin.h @@ -31,9 +31,7 @@ static XBT_INLINE int double_equals(double value1, double value2) return (fabs(value1 - value2) < MAXMIN_PRECISION); } -#ifdef __cplusplus -extern "C" { -#endif +SG_BEGIN_DECL() XBT_PUBLIC(lmm_system_t) lmm_system_new(int selective_update); XBT_PUBLIC(void) lmm_system_free(lmm_system_t sys); @@ -133,8 +131,6 @@ XBT_PUBLIC(double func_vegas_f) (lmm_variable_t var, double x); XBT_PUBLIC(double func_vegas_fp) (lmm_variable_t var, double x); XBT_PUBLIC(double func_vegas_fpi) (lmm_variable_t var, double x); -#ifdef __cplusplus -} -#endif +SG_END_DECL() #endif /* _SURF_MAXMIN_H */ diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index 11f247252c..0620175df7 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -210,9 +210,6 @@ static inline void *surf_storage_resource_by_name(const char *name){ return xbt_lib_get_elm_or_null(storage_lib, name); } -#ifdef __cplusplus -extern "C" { -#endif char *surf_routing_edge_name(sg_routing_edge_t edge); void *surf_as_cluster_get_backbone(AS_t as); void surf_as_cluster_set_backbone(AS_t as, void* backbone); @@ -296,9 +293,6 @@ void surf_cpu_action_set_bound(surf_action_t action, double bound); surf_file_t surf_storage_action_get_file(surf_action_t action); xbt_dict_t surf_storage_action_get_ls_dict(surf_action_t action); surf_model_t surf_resource_model(const void *host, int level); -#ifdef __cplusplus -} -#endif /**************************************/ /* Implementations of model object */ @@ -593,9 +587,6 @@ XBT_PUBLIC(xbt_dict_t) watched_hosts_lib; /*******************************************/ /*** SURF Platform *************************/ /*******************************************/ -#ifdef __cplusplus -extern "C" { -#endif XBT_PUBLIC_DATA(AS_t) surf_AS_get_routing_root(void); XBT_PUBLIC_DATA(const char *) surf_AS_get_name(AS_t as); XBT_PUBLIC_DATA(xbt_dict_t) surf_AS_get_routing_sons(AS_t as); @@ -604,9 +595,6 @@ XBT_PUBLIC_DATA(xbt_dynar_t) surf_AS_get_hosts(AS_t as); XBT_PUBLIC_DATA(void) surf_AS_get_graph(AS_t as, xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges); XBT_PUBLIC_DATA(AS_t) surf_platf_get_root(routing_platf_t platf); XBT_PUBLIC_DATA(e_surf_network_element_type_t) surf_routing_edge_get_rc_type(sg_routing_edge_t edge); -#ifdef __cplusplus -} -#endif /*******************************************/ /*** SURF Globals **************************/ diff --git a/src/include/surf/trace_mgr.h b/src/include/surf/trace_mgr.h index 3343492730..d6bc75064c 100644 --- a/src/include/surf/trace_mgr.h +++ b/src/include/surf/trace_mgr.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2004-2007, 2009-2012. The SimGrid Team. +/* Copyright (c) 2004-2007, 2009-2013. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -13,9 +13,7 @@ #include "surf/datatypes.h" #include "simgrid/platf_interface.h" -#ifdef __cplusplus -extern "C" { -#endif +SG_BEGIN_DECL() /* Creation functions */ XBT_PUBLIC(tmgr_history_t) tmgr_history_new(void); @@ -47,8 +45,6 @@ XBT_PUBLIC(tmgr_trace_event_t) XBT_PUBLIC(void) tmgr_finalize(void); -#ifdef __cplusplus -} -#endif +SG_END_DECL() #endif /* _SURF_TMGR_H */ diff --git a/src/instr/instr_private.h b/src/instr/instr_private.h index 84e81c2d71..10785fe1a4 100644 --- a/src/instr/instr_private.h +++ b/src/instr/instr_private.h @@ -14,6 +14,8 @@ #ifdef HAVE_TRACING +SG_BEGIN_DECL() + /* Need to define function drand48 for Windows */ #ifdef _WIN32 # define drand48() (rand()/(RAND_MAX + 1.0)) @@ -230,10 +232,6 @@ extern xbt_dict_t user_vm_variables; extern xbt_dict_t user_link_variables; extern double TRACE_last_timestamp_to_dump; -#ifdef __cplusplus -extern "C" { -#endif - /* instr_paje_header.c */ void TRACE_header(int basic, int size); @@ -461,10 +459,7 @@ typedef struct s_instr_extra_data { int num_processes; } s_instr_extra_data_t; -#ifdef __cplusplus -} -#endif - +SG_END_DECL() #endif /* HAVE_TRACING */ @@ -472,9 +467,4 @@ typedef struct s_instr_extra_data { #include "instr/jedule/jedule_sd_binding.h" #endif - - - - - #endif /* INSTR_PRIVATE_H_ */ diff --git a/src/simix/smx_host_private.h b/src/simix/smx_host_private.h index 614ce1f834..7ce4beb4e8 100644 --- a/src/simix/smx_host_private.h +++ b/src/simix/smx_host_private.h @@ -10,6 +10,8 @@ #include "simgrid/simix.h" #include "smx_smurf_private.h" +SG_BEGIN_DECL() + /** @brief Host datatype */ typedef struct s_smx_host_priv { xbt_swag_t process_list; @@ -22,10 +24,6 @@ static inline smx_host_priv_t SIMIX_host_priv(smx_host_t host){ return (smx_host_priv_t) xbt_lib_get_level(host, SIMIX_HOST_LEVEL); } - -#ifdef __cplusplus -extern "C" { -#endif void _SIMIX_host_free_process_arg(void *); smx_host_t SIMIX_host_create(const char *name, void *workstation, void *data); void SIMIX_host_destroy(void *host); @@ -160,9 +158,8 @@ void SIMIX_pre_host_get_params(smx_simcall_t simcall, smx_host_t ind_vm, ws_para void SIMIX_host_set_params(smx_host_t ind_vm, ws_params_t params); void SIMIX_pre_host_set_params(smx_simcall_t simcall, smx_host_t ind_vm, ws_params_t params); -#ifdef __cplusplus -} -#endif + +SG_END_DECL() #endif diff --git a/src/simix/smx_smurf_private.h b/src/simix/smx_smurf_private.h index 915c890181..1b20fbe351 100644 --- a/src/simix/smx_smurf_private.h +++ b/src/simix/smx_smurf_private.h @@ -7,6 +7,8 @@ #ifndef _SIMIX_SMURF_PRIVATE_H #define _SIMIX_SMURF_PRIVATE_H +SG_BEGIN_DECL() + /********************************* Simcalls *********************************/ /* we want to build the e_smx_simcall_t enumeration, the table of the @@ -492,14 +494,8 @@ typedef struct s_smx_simcall { }; } s_smx_simcall_t, *smx_simcall_t; -#ifdef __cplusplus -extern "C" { -#endif SIMCALL_LIST(SIMCALL_RES_GETSET, SIMCALL_SEP_NOTHING) SIMCALL_LIST(SIMCALL_ARG_GETSET, SIMCALL_SEP_NOTHING) -#ifdef __cplusplus -} -#endif /******************************** General *************************************/ @@ -519,5 +515,7 @@ typedef smx_action_t (*simcall_handler_t)(u_smx_scalar_t *); extern const char *simcall_types[]; extern simcall_handler_t simcall_table[]; +SG_END_DECL() + #endif diff --git a/src/surf/gtnets/gtnets_interface.h b/src/surf/gtnets/gtnets_interface.h index 0c36743e42..ce72d34072 100644 --- a/src/surf/gtnets/gtnets_interface.h +++ b/src/surf/gtnets/gtnets_interface.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2007-2010. The SimGrid Team. +/* Copyright (c) 2007-2010, 2013. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -8,29 +8,28 @@ #ifndef _GTNETS_INTERFACE_H #define _GTNETS_INTERFACE_H -#ifdef __cplusplus -extern "C" { -#endif +#include "xbt/misc.h" /* SG_{BEGIN,END}_DECL() */ + +SG_BEGIN_DECL() + +int gtnets_initialize(int wsize); +int gtnets_add_link(int id, double bandwidth, double latency); +int gtnets_add_route(int src, int dst, int *links, int nlink); +int gtnets_add_router(int id); +int gtnets_add_onehop_route(int src, int dst, int link); +int gtnets_create_flow(int src, int dst, long datasize, void *metadata); +double gtnets_get_time_to_next_flow_completion(); +double gtnets_run_until_next_flow_completion(void ***metadata, + int *number_of_flows); +double gtnets_get_flow_rx(void *metadata); + +void gtnets_print_topology(void); + +int gtnets_run(double delta); +int gtnets_finalize(); +void gtnets_set_jitter(double); +void gtnets_set_jitter_seed(int); + +SG_END_DECL() - int gtnets_initialize(int wsize); - int gtnets_add_link(int id, double bandwidth, double latency); - int gtnets_add_route(int src, int dst, int *links, int nlink); - int gtnets_add_router(int id); - int gtnets_add_onehop_route(int src, int dst, int link); - int gtnets_create_flow(int src, int dst, long datasize, void *metadata); - double gtnets_get_time_to_next_flow_completion(); - double gtnets_run_until_next_flow_completion(void ***metadata, - int *number_of_flows); - double gtnets_get_flow_rx(void *metadata); - - void gtnets_print_topology(void); - - int gtnets_run(double delta); - int gtnets_finalize(); - void gtnets_set_jitter(double); - void gtnets_set_jitter_seed(int); - -#ifdef __cplusplus -} -#endif #endif diff --git a/src/surf/ns3/ns3_interface.h b/src/surf/ns3/ns3_interface.h index 6105510656..b3b141e63b 100644 --- a/src/surf/ns3/ns3_interface.h +++ b/src/surf/ns3/ns3_interface.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2007-2012. The SimGrid Team. +/* Copyright (c) 2007-2013. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -25,9 +25,7 @@ typedef struct ns3_nodes{ void * data; }s_ns3_nodes_t, *ns3_nodes_t; -#ifdef __cplusplus -extern "C" { -#endif +SG_BEGIN_DECL() XBT_PUBLIC(int) ns3_finalize(void); XBT_PUBLIC(int) ns3_initialize(const char* TcpProtocol); @@ -47,8 +45,7 @@ XBT_PUBLIC(void *) ns3_add_link(int src, e_ns3_network_element_type_t type_src, char * bw,char * lat); XBT_PUBLIC(void *) ns3_end_platform(void); XBT_PUBLIC(void *) ns3_add_cluster(char * bw,char * lat,const char *id); -#ifdef __cplusplus -} -#endif + +SG_END_DECL() #endif diff --git a/src/surf/surf_interface.hpp b/src/surf/surf_interface.hpp index 0e001a9e15..b28e1c0aa3 100644 --- a/src/surf/surf_interface.hpp +++ b/src/surf/surf_interface.hpp @@ -44,13 +44,9 @@ extern int sg_gtnets_jitter_seed; #endif extern xbt_dynar_t surf_path; -#ifdef __cplusplus extern "C" { -#endif XBT_PUBLIC(double) surf_get_clock(void); -#ifdef __cplusplus } -#endif extern double sg_sender_gap; XBT_PUBLIC(int) SURF_CPU_LEVEL; //Surf cpu level diff --git a/src/surf/surf_private.h b/src/surf/surf_private.h index 4240c00fea..f2a889ccf5 100644 --- a/src/surf/surf_private.h +++ b/src/surf/surf_private.h @@ -17,9 +17,7 @@ #define NO_MAX_DURATION -1.0 -#ifdef __cplusplus -extern "C" { -#endif +SG_BEGIN_DECL() extern xbt_dict_t watched_hosts_lib; @@ -92,8 +90,6 @@ XBT_PUBLIC_DATA(int) surfxml_bufferstack_size; void TRACE_surf_host_set_power(double date, const char *resource, double power); void TRACE_surf_link_set_bandwidth(double date, const char *resource, double bandwidth); -#ifdef __cplusplus -} -#endif +SG_END_DECL() #endif /* _SURF_SURF_PRIVATE_H */ -- 2.20.1