include/topology.h

Go to the documentation of this file.
00001 /*
00002  * libtopology - a library for discovering Linux system topology
00003  *
00004  * Copyright 2008 Nathan Lynch, IBM Corporation
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public License
00008  * version 2.1 as published by the Free Software Foundation.
00009  *
00010  * This library is distributed in the hope that it will be useful, but
00011  * WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Lesser General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Lesser General Public
00016  * License along with this library; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00018  * 02110-1301 USA
00019  */
00020 
00027 #ifndef _TOPOLOGY_H_
00028 #define _TOPOLOGY_H_
00029 
00030 #ifdef __cplusplus
00031 extern "C" {
00032 #endif
00033 
00034 #ifndef LIBTOPOLOGY_DOXYGEN_SKIP
00035 
00036 #include <sched.h> /* for cpu_set_t */
00037 
00038 #endif /* LIBTOPOLOGY_DOXYGEN_SKIP */
00039 
00040 typedef unsigned long topo_context_t;
00041 typedef unsigned long topo_procent_t;
00042 typedef unsigned long topo_device_t;
00043 
00044 typedef enum topology_level {
00045         TOPOLOGY_THREAD = 1,
00046         TOPOLOGY_CORE,
00047         TOPOLOGY_PACKAGE,
00048         TOPOLOGY_NODE,
00049         TOPOLOGY_SYSTEM,
00050 } topo_level_t;
00051 
00069 extern int topology_init_context(topo_context_t *ctx, topo_procent_t *system);
00070 
00084 extern void topology_free_context(topo_context_t ctx);
00085 
00106 extern size_t topology_sizeof_cpumask(topo_context_t ctx);
00107 
00125 extern topo_procent_t
00126 topology_traverse(topo_procent_t start,
00127                   topo_procent_t iter,
00128                   topo_level_t to_level);
00141 extern void topology_procent_cpumask(topo_procent_t ent, cpu_set_t *dest);
00142 
00159 extern topo_device_t
00160 topology_find_device_by_type(topo_context_t ctx,
00161                              topo_device_t prev,
00162                              const char *type);
00163 
00164 
00177 extern void topology_device_cpumask(topo_device_t dev, cpu_set_t *dest);
00178 
00191 extern const char *
00192 topology_device_get_attribute(topo_device_t dev, const char *name);
00193 
00203 #define topology_for_each_device_of_type(ctx, dev, type)                            \
00204         for ((dev) = topology_find_device_by_type((ctx), (topo_device_t)0, (type)); \
00205              (dev) != 0;                                                            \
00206              (dev) = topology_find_device_by_type((ctx), (dev), (type)))
00207 
00208 #ifdef __cplusplus
00209 }
00210 #endif
00211 
00212 #endif /* _TOPOLOGY_H_ */

Generated on Tue Dec 30 23:48:39 2008 for libtopology by  doxygen 1.4.7