1 /*
2 * Copyright © 2009 CNRS
3 * Copyright © 2009-2014 Inria. All rights reserved.
4 * Copyright © 2009-2012 Université Bordeaux
5 * Copyright © 2009-2011 Cisco Systems, Inc. All rights reserved.
6 * See COPYING in top-level directory.
7 */
8
9 #include <private/autogen/config.h>
10 #include <hwloc.h>
11 #include <private/private.h>
12
13 static int
hwloc_look_noos(struct hwloc_backend * backend)14 hwloc_look_noos(struct hwloc_backend *backend)
15 {
16 struct hwloc_topology *topology = backend->topology;
17
18 if (topology->levels[0][0]->cpuset)
19 /* somebody discovered things */
20 return 0;
21
22 hwloc_alloc_obj_cpusets(topology->levels[0][0]);
23 hwloc_setup_pu_level(topology, hwloc_fallback_nbprocessors(topology));
24 if (topology->is_thissystem)
25 hwloc_add_uname_info(topology, NULL);
26 return 1;
27 }
28
29 static struct hwloc_backend *
hwloc_noos_component_instantiate(struct hwloc_disc_component * component,const void * _data1 __hwloc_attribute_unused,const void * _data2 __hwloc_attribute_unused,const void * _data3 __hwloc_attribute_unused)30 hwloc_noos_component_instantiate(struct hwloc_disc_component *component,
31 const void *_data1 __hwloc_attribute_unused,
32 const void *_data2 __hwloc_attribute_unused,
33 const void *_data3 __hwloc_attribute_unused)
34 {
35 struct hwloc_backend *backend;
36 backend = hwloc_backend_alloc(component);
37 if (!backend)
38 return NULL;
39 backend->discover = hwloc_look_noos;
40 return backend;
41 }
42
43 static struct hwloc_disc_component hwloc_noos_disc_component = {
44 HWLOC_DISC_COMPONENT_TYPE_CPU,
45 "no_os",
46 HWLOC_DISC_COMPONENT_TYPE_GLOBAL,
47 hwloc_noos_component_instantiate,
48 40, /* lower than native OS component, higher than globals */
49 NULL
50 };
51
52 const struct hwloc_component hwloc_noos_component = {
53 HWLOC_COMPONENT_ABI,
54 NULL, NULL,
55 HWLOC_COMPONENT_TYPE_DISC,
56 0,
57 &hwloc_noos_disc_component
58 };
59