getinfo.h 2.0 KB

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