home *** CD-ROM | disk | FTP | other *** search
/ ftp.parl.clemson.edu / 2015-02-07.ftp.parl.clemson.edu.tar / ftp.parl.clemson.edu / pub / pvfs2 / orangefs-2.8.3-20110323.tar.gz / orangefs-2.8.3-20110323.tar / orangefs / src / io / description / pint-dist-utils.h < prev    next >
C/C++ Source or Header  |  2010-12-21  |  3KB  |  90 lines

  1. /*
  2.  * (C) 2002 Clemson University and The University of Chicago.
  3.  *
  4.  * See COPYING in top-level directory.
  5.  */
  6.  
  7. #ifndef __PINT_DIST_UTILS_H
  8. #define __PINT_DIST_UTILS_H
  9.  
  10. #include "pint-distribution.h"
  11. #include "server-config.h"
  12.  
  13. /**
  14.  * Perform initialization tasks for distributions
  15.  *   - register the default distributions
  16.  */
  17. int PINT_dist_initialize(server_configuration_s* server_config);
  18.  
  19. /**
  20.  * Perform cleanup actions before exiting
  21.  */
  22. void PINT_dist_finalize(void);
  23.  
  24. /**
  25.  * Utility default implmentation for PINT_dist_methods get_num_dfiles
  26.  *
  27.  * Returns the number of dfiles suggested by hint parameter if non-zero
  28.  * else returns the number of servers requested
  29.  */
  30. int PINT_dist_default_get_num_dfiles(void* params,
  31.                                      uint32_t num_servers_requested,
  32.                                      uint32_t num_dfiles_requested);
  33.  
  34. /**
  35.  * Utility default implmentation for PINT_dist_methods set_param
  36.  *
  37.  * Sets the specified parameter.  The parameter must have been registered
  38.  * with PINT_dist_register_param or PINT_dist_register_param_offset, so
  39.  * implementation may not work correctly with complex structs or pointer
  40.  * values.
  41.  */
  42. int PINT_dist_default_set_param(const char* dist_name, void* params,
  43.                                 const char* param_name, void* value);
  44.  
  45. /**
  46.  * Register the parameter offset.
  47.  *
  48.  * Use PINT_dist_register_param to avoid having to determine the offset
  49.  * and field size.
  50.  */
  51. int PINT_dist_register_param_offset(const char* dist_name,
  52.                              const char* param_name,
  53.                              size_t offset,
  54.                              size_t field_size);
  55.  
  56. /**
  57.  * Unregister the parameter offset.
  58.  *
  59.  * Just helper to make register/unregister look complete
  60.  */
  61. int PINT_dist_unregister_param_offset(const char* dist_name,
  62.                             const char* param_name);
  63.  
  64. /**
  65.  * Wrapper macro to make adding parameter fields easy.
  66.  *
  67.  * Uses the offsetof trick to locate the offset for the struct field
  68.  * and the sizeof operator to determine the size.  This is only reliable
  69.  * with POD data, complex structs and pointers may not work as expected.
  70.  */
  71. #define PINT_dist_register_param(dname, pname, param_type, param_member) \
  72.     PINT_dist_register_param_offset(dname, pname, \
  73.                                     (size_t)&((param_type*)0)->param_member, \
  74.                                     sizeof(((param_type*)0)->param_member))
  75.  
  76. #define PINT_dist_unregister_param(dname, pname) \
  77.     PINT_dist_unregister_param_offset(dname, pname)
  78.  
  79. #endif
  80.  
  81. /*
  82.  * Local variables:
  83.  *  mode: c
  84.  *  c-indent-level: 4
  85.  *  c-basic-offset: 4
  86.  * End:
  87.  *
  88.  * vim: ft=c ts=8 sts=4 sw=4 expandtab
  89.  */
  90.