From 6636687a97c0b9be68be6b9b78fc070917fcf2a0 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sat, 6 May 2017 23:08:02 +0200 Subject: [PATCH] rename all MSG_zone_* functions (backward compatible) --- ChangeLog | 4 ++ .../platform-properties/platform-properties.c | 8 ++-- include/simgrid/msg.h | 46 +++++++++++++++---- include/xbt/base.h | 6 +-- src/bindings/java/jmsg.cpp | 2 +- src/bindings/java/jmsg_as.cpp | 2 +- src/msg/msg_environment.cpp | 14 +++--- 7 files changed, 58 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7953389df5..e8b8c0383a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -18,6 +18,10 @@ SimGrid (3.16) UNRELEASED simulation round, s/he has to allocate and free a dynar and use it as argument to this function. The former SD_simulate (double how_long) now returns void. + MSG + - The netzone are now available from the MSG API. + The old names still work, but are now deprecated. + SMPI - New algorithm to privatize globals: dlopen, with dynamic loading tricks - New option: smpi/keep-temps to not cleanup temp files diff --git a/examples/msg/platform-properties/platform-properties.c b/examples/msg/platform-properties/platform-properties.c index 83acf804d2..9e1de6daae 100644 --- a/examples/msg/platform-properties/platform-properties.c +++ b/examples/msg/platform-properties/platform-properties.c @@ -65,11 +65,11 @@ static int david(int argc, char *argv[]) {/* Dump what we have on a remote host static int bob(int argc, char *argv[]) { /* this host also tests the properties of the AS*/ - msg_as_t root = MSG_environment_get_routing_root(); + msg_as_t root = MSG_zone_get_root(); XBT_INFO("== Print the properties of the AS"); - XBT_INFO(" Process property: filename -> %s", MSG_environment_as_get_property_value(root, "filename")); - XBT_INFO(" Process property: date -> %s", MSG_environment_as_get_property_value(root, "date")); - XBT_INFO(" Process property: author -> %s", MSG_environment_as_get_property_value(root, "author")); + XBT_INFO(" Process property: filename -> %s", MSG_zone_get_property_value(root, "filename")); + XBT_INFO(" Process property: date -> %s", MSG_zone_get_property_value(root, "date")); + XBT_INFO(" Process property: author -> %s", MSG_zone_get_property_value(root, "author")); /* Get the property list of current bob process */ xbt_dict_t props = MSG_process_get_properties(MSG_process_self()); diff --git a/include/simgrid/msg.h b/include/simgrid/msg.h index df2c744413..bb2c594940 100644 --- a/include/simgrid/msg.h +++ b/include/simgrid/msg.h @@ -176,14 +176,44 @@ XBT_PUBLIC(void) MSG_set_function(const char *host_id, XBT_PUBLIC(double) MSG_get_clock(); XBT_PUBLIC(unsigned long int) MSG_get_sent_msg(); -/************************** Environment ***********************************/ -XBT_PUBLIC(msg_netzone_t) MSG_environment_get_routing_root(); -XBT_PUBLIC(const char*) MSG_environment_as_get_name(msg_netzone_t as); -XBT_PUBLIC(msg_netzone_t) MSG_environment_as_get_by_name(const char* name); -XBT_PUBLIC(xbt_dict_t) MSG_environment_as_get_routing_sons(msg_netzone_t as); -XBT_PUBLIC(const char*) MSG_environment_as_get_property_value(msg_netzone_t as, const char* name); -XBT_PUBLIC(void) MSG_environment_as_set_property_value(msg_netzone_t netzone, const char* name, char* value); -XBT_PUBLIC(xbt_dynar_t) MSG_environment_as_get_hosts(msg_netzone_t as); +/************************** Net Zones ***********************************/ +XBT_PUBLIC(msg_netzone_t) MSG_zone_get_root(); +XBT_PUBLIC(const char*) MSG_zone_get_name(msg_netzone_t zone); +XBT_PUBLIC(msg_netzone_t) MSG_zone_get_by_name(const char* name); +XBT_PUBLIC(xbt_dict_t) MSG_zone_get_sons(msg_netzone_t zone); +XBT_PUBLIC(const char*) MSG_zone_get_property_value(msg_netzone_t as, const char* name); +XBT_PUBLIC(void) MSG_zone_set_property_value(msg_netzone_t netzone, const char* name, char* value); +XBT_PUBLIC(xbt_dynar_t) MSG_zone_get_hosts(msg_netzone_t zone); + +/* Deprecated forms of the previous functions */ +static inline XBT_ATTRIB_DEPRECATED("Please use MSG_zone_get_root since v3.16") + msg_netzone_t MSG_environment_get_routing_root() { + return MSG_zone_get_root(); +} +static inline XBT_ATTRIB_DEPRECATED("Please use MSG_zone_get_name since v3.16") + const char* MSG_environment_as_get_name(msg_netzone_t zone) { + return MSG_zone_get_name(zone); +} +static inline XBT_ATTRIB_DEPRECATED("Please use MSG_zone_get_by_name since v3.16") + msg_netzone_t MSG_environment_as_get_by_name(const char* name) { + return MSG_zone_get_by_name(name); +} +static inline XBT_ATTRIB_DEPRECATED("Please use MSG_zone_get_sons since v3.16") + xbt_dict_t MSG_environment_as_get_routing_sons(msg_netzone_t zone) { + return MSG_zone_get_sons(zone); +} +static inline XBT_ATTRIB_DEPRECATED("Please use MSG_zone_get_property_value since v3.16") + const char* MSG_environment_as_get_property_value(msg_netzone_t zone, const char* name) { + return MSG_zone_get_property_value(zone, name); +} +static inline XBT_ATTRIB_DEPRECATED("Please use MSG_zone_set_property_value since v3.16") + void MSG_environment_as_set_property_value(msg_netzone_t zone, const char* name, char* value) { + MSG_zone_set_property_value(zone, name, value); +} +static inline XBT_ATTRIB_DEPRECATED("Please use MSG_zone_get_hosts since v3.16") + xbt_dynar_t MSG_environment_as_get_hosts(msg_netzone_t zone) { + return MSG_zone_get_hosts(zone); +} /************************** File handling ***********************************/ XBT_PUBLIC(sg_size_t) MSG_file_read(msg_file_t fd, sg_size_t size); diff --git a/include/xbt/base.h b/include/xbt/base.h index de8f8ce509..108003c381 100644 --- a/include/xbt/base.h +++ b/include/xbt/base.h @@ -45,9 +45,9 @@ __attribute__((__format__ (__scanf__, format_idx, arg_idx))) #endif -#define XBT_ATTRIB_NORETURN __attribute__((__noreturn__)) -#define XBT_ATTRIB_UNUSED __attribute__((__unused__)) -#define XBT_ATTRIB_DEPRECATED(m) __attribute__((__deprecated__(m))) +#define XBT_ATTRIB_NORETURN __attribute__((noreturn)) +#define XBT_ATTRIB_UNUSED __attribute__((unused)) +#define XBT_ATTRIB_DEPRECATED(m) __attribute__((deprecated(m))) /* Constructor priorities exist since gcc 4.3. Apparently, they are however not * supported on Macs. */ diff --git a/src/bindings/java/jmsg.cpp b/src/bindings/java/jmsg.cpp index 265fd61ca5..ec98fdec31 100644 --- a/src/bindings/java/jmsg.cpp +++ b/src/bindings/java/jmsg.cpp @@ -186,7 +186,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_createEnvironment(JNIEnv * env, JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Msg_environmentGetRoutingRoot(JNIEnv * env, jclass cls) { - msg_netzone_t as = MSG_environment_get_routing_root(); + msg_netzone_t as = MSG_zone_get_root(); jobject jas = jnetzone_new_instance(env); if (!jas) { jxbt_throw_jni(env, "java As instantiation failed"); diff --git a/src/bindings/java/jmsg_as.cpp b/src/bindings/java/jmsg_as.cpp index 9b4f7bf3ae..cb796c4592 100644 --- a/src/bindings/java/jmsg_as.cpp +++ b/src/bindings/java/jmsg_as.cpp @@ -106,7 +106,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_As_getProperty(JNIEnv *env, jobje } const char *name = env->GetStringUTFChars(static_cast(jname), 0); - const char *property = MSG_environment_as_get_property_value(as, name); + const char* property = MSG_zone_get_property_value(as, name); if (!property) { return nullptr; } diff --git a/src/msg/msg_environment.cpp b/src/msg/msg_environment.cpp index a52541bebb..68c2a1c371 100644 --- a/src/msg/msg_environment.cpp +++ b/src/msg/msg_environment.cpp @@ -48,22 +48,22 @@ void MSG_post_create_environment() { } } -msg_netzone_t MSG_environment_get_routing_root() +msg_netzone_t MSG_zone_get_root() { return simgrid::s4u::Engine::instance()->netRoot(); } -const char* MSG_environment_as_get_name(msg_netzone_t netzone) +const char* MSG_zone_get_name(msg_netzone_t netzone) { return netzone->name(); } -msg_netzone_t MSG_environment_as_get_by_name(const char* name) +msg_netzone_t MSG_zone_get_by_name(const char* name) { return simgrid::s4u::Engine::instance()->netzoneByNameOrNull(name); } -xbt_dict_t MSG_environment_as_get_routing_sons(msg_netzone_t netzone) +xbt_dict_t MSG_zone_get_sons(msg_netzone_t netzone) { xbt_dict_t res = xbt_dict_new_homogeneous(nullptr); for (auto elem : *netzone->children()) { @@ -72,17 +72,17 @@ xbt_dict_t MSG_environment_as_get_routing_sons(msg_netzone_t netzone) return res; } -const char* MSG_environment_as_get_property_value(msg_netzone_t netzone, const char* name) +const char* MSG_zone_get_property_value(msg_netzone_t netzone, const char* name) { return netzone->property(name); } -void MSG_environment_as_set_property_value(msg_netzone_t netzone, const char* name, char* value) +void MSG_zone_set_property_value(msg_netzone_t netzone, const char* name, char* value) { netzone->setProperty(name, value); } -xbt_dynar_t MSG_environment_as_get_hosts(msg_netzone_t netzone) +xbt_dynar_t MSG_zone_get_hosts(msg_netzone_t netzone) { xbt_dynar_t res = xbt_dynar_new(sizeof(sg_host_t), nullptr); -- 2.20.1