getinfo.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010,2011 University of Bordeaux
  4. *
  5. * StarPU is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as published by
  7. * the Free Software Foundation; either version 2.1 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * StarPU is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. *
  14. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. */
  16. #ifndef SOCL_GETINFO_H
  17. #define SOCL_GETINFO_H
  18. #define INFO_CASE_EX2(var) if (param_value != NULL) { \
  19. if (param_value_size < sizeof(var)) \
  20. return CL_INVALID_VALUE; \
  21. memcpy(param_value, &var, sizeof(var)); \
  22. } \
  23. if (param_value_size_ret != NULL) \
  24. *param_value_size_ret = sizeof(var); \
  25. break;
  26. #define INFO_CASE(param, var) case param: \
  27. INFO_CASE_EX2(var)
  28. #define INFO_CASE_STRING_EX2(var) if (param_value != NULL) { \
  29. if (param_value_size < strlen(var)+1) \
  30. return CL_INVALID_VALUE; \
  31. strcpy(param_value, var); \
  32. } \
  33. if (param_value_size_ret != NULL) \
  34. *param_value_size_ret = strlen(var)+1; \
  35. break;
  36. #define INFO_CASE_STRING(param, var) case param: \
  37. INFO_CASE_STRING_EX2(var)
  38. #define INFO_CASE_VALUE(param, type, value) case param: {\
  39. type tmp = (value);\
  40. INFO_CASE_EX2(tmp);\
  41. }
  42. //warning: var is a reference
  43. #define INFO_CASE_EX(param, var, size) case param: \
  44. if (param_value != NULL) { \
  45. if (param_value_size < size) \
  46. return CL_INVALID_VALUE; \
  47. memcpy(param_value, var, size); \
  48. } \
  49. if (param_value_size_ret != NULL) \
  50. *param_value_size_ret = size; \
  51. break;
  52. #endif /* SOCL_GETINFO_H */