And ignore any empty uname field in case the backend gives incomplete info.
extern void hwloc_set_hpux_hooks(struct hwloc_binding_hooks *binding_hooks, struct hwloc_topology_support *support);
#endif /* HWLOC_HPUX_SYS */
-/* Insert uname-specific names/values in the object infos array */
-extern void hwloc_add_uname_info(struct hwloc_topology *topology);
+/* Insert uname-specific names/values in the object infos array.
+ * If cached_uname isn't NULL, it is used as a struct utsname instead of recalling uname.
+ * Any field that starts with \0 is ignored.
+ */
+extern void hwloc_add_uname_info(struct hwloc_topology *topology, void *cached_uname);
/* Free obj and its attributes assuming it doesn't have any children/parent anymore */
extern void hwloc_free_unlinked_object(hwloc_obj_t obj);
/*
* Copyright © 2009 CNRS
- * Copyright © 2009-2012 Inria. All rights reserved.
+ * Copyright © 2009-2014 Inria. All rights reserved.
* Copyright © 2009-2010 Université Bordeaux 1
* Copyright © 2009-2011 Cisco Systems, Inc. All rights reserved.
* See COPYING in top-level directory.
return i < n;
}
-void hwloc_add_uname_info(struct hwloc_topology *topology __hwloc_attribute_unused)
+void hwloc_add_uname_info(struct hwloc_topology *topology __hwloc_attribute_unused,
+ void *cached_uname __hwloc_attribute_unused)
{
#ifdef HAVE_UNAME
- struct utsname utsname;
-
- if (uname(&utsname) < 0)
- return;
+ struct utsname _utsname, *utsname;
if (hwloc_obj_get_info_by_name(topology->levels[0][0], "OSName"))
/* don't annotate twice */
return;
- hwloc_obj_add_info(topology->levels[0][0], "OSName", utsname.sysname);
- hwloc_obj_add_info(topology->levels[0][0], "OSRelease", utsname.release);
- hwloc_obj_add_info(topology->levels[0][0], "OSVersion", utsname.version);
- hwloc_obj_add_info(topology->levels[0][0], "HostName", utsname.nodename);
- hwloc_obj_add_info(topology->levels[0][0], "Architecture", utsname.machine);
+ if (cached_uname)
+ utsname = (struct utsname *) cached_uname;
+ else {
+ utsname = &_utsname;
+ if (uname(utsname) < 0)
+ return;
+ }
+
+ if (*utsname->sysname)
+ hwloc_obj_add_info(topology->levels[0][0], "OSName", utsname->sysname);
+ if (*utsname->release)
+ hwloc_obj_add_info(topology->levels[0][0], "OSRelease", utsname->release);
+ if (*utsname->version)
+ hwloc_obj_add_info(topology->levels[0][0], "OSVersion", utsname->version);
+ if (*utsname->nodename)
+ hwloc_obj_add_info(topology->levels[0][0], "HostName", utsname->nodename);
+ if (*utsname->machine)
+ hwloc_obj_add_info(topology->levels[0][0], "Architecture", utsname->machine);
#endif /* HAVE_UNAME */
}
hwloc_obj_add_info(topology->levels[0][0], "Backend", "AIX");
if (topology->is_thissystem)
- hwloc_add_uname_info(topology);
+ hwloc_add_uname_info(topology, NULL);
return 1;
}
hwloc_obj_add_info(topology->levels[0][0], "Backend", "BGQ");
if (topology->is_thissystem)
- hwloc_add_uname_info(topology);
+ hwloc_add_uname_info(topology, NULL);
return 1;
}
hwloc_obj_add_info(topology->levels[0][0], "Backend", "Darwin");
if (topology->is_thissystem)
- hwloc_add_uname_info(topology);
+ hwloc_add_uname_info(topology, NULL);
return 1;
}
#endif
hwloc_obj_add_info(topology->levels[0][0], "Backend", "FreeBSD");
if (topology->is_thissystem)
- hwloc_add_uname_info(topology);
+ hwloc_add_uname_info(topology, NULL);
return 1;
}
hwloc_obj_add_info(topology->levels[0][0], "Backend", "HP-UX");
if (topology->is_thissystem)
- hwloc_add_uname_info(topology);
+ hwloc_add_uname_info(topology, NULL);
return 1;
}
/* gather uname info if fsroot wasn't changed */
if (topology->is_thissystem)
- hwloc_add_uname_info(topology);
+ hwloc_add_uname_info(topology, NULL);
return 1;
}
hwloc_obj_add_info(topology->levels[0][0], "Backend", "NetBSD");
if (topology->is_thissystem)
- hwloc_add_uname_info(topology);
+ hwloc_add_uname_info(topology, NULL);
return 1;
}
hwloc_alloc_obj_cpusets(topology->levels[0][0]);
hwloc_setup_pu_level(topology, hwloc_fallback_nbprocessors(topology));
if (topology->is_thissystem)
- hwloc_add_uname_info(topology);
+ hwloc_add_uname_info(topology, NULL);
return 1;
}
hwloc_obj_add_info(topology->levels[0][0], "Backend", "OSF");
if (topology->is_thissystem)
- hwloc_add_uname_info(topology);
+ hwloc_add_uname_info(topology, NULL);
return 1;
}
hwloc_obj_add_info(topology->levels[0][0], "Backend", "Solaris");
if (topology->is_thissystem)
- hwloc_add_uname_info(topology);
+ hwloc_add_uname_info(topology, NULL);
return 1;
}
hwloc_obj_add_info(topology->levels[0][0], "Backend", "Windows");
if (topology->is_thissystem)
- hwloc_add_uname_info(topology);
+ hwloc_add_uname_info(topology, NULL);
return 1;
}
hwloc_obj_add_info(topology->levels[0][0], "Backend", "x86");
#ifdef HAVE_UNAME
- hwloc_add_uname_info(topology); /* we already know is_thissystem() is true */
+ hwloc_add_uname_info(topology, NULL); /* we already know is_thissystem() is true */
#else
/* uname isn't available, manually setup the "Architecture" info */
#ifdef HWLOC_X86_64_ARCH