utils.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* GCC-StarPU
  2. Copyright (C) 2012 Inria
  3. GCC-StarPU is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. GCC-StarPU is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with GCC-StarPU. If not, see <http://www.gnu.org/licenses/>. */
  13. /* Various utilities. */
  14. #pragma once
  15. /* GCC 4.7 requires compilation with `g++', and C++ lacks a number of GNU C
  16. features, so work around that. */
  17. #ifdef __cplusplus
  18. /* G++ doesn't implement nested functions, so use C++11 lambdas instead. */
  19. # include <functional>
  20. # define local_define(ret, name, parms) auto name = [=]parms
  21. # define function_parm(ret, name, parms) std::function<ret parms> name
  22. /* G++ lacks designated initializers. */
  23. # define designated_field_init(name, value) value /* XXX: cross fingers */
  24. #else /* !__cplusplus */
  25. /* GNU C nested functions. */
  26. # define local_define(ret, name, parms) ret name parms
  27. # define function_parm(ret, name, parms) ret (*name) parms
  28. /* Designated field initializer. */
  29. # define designated_field_init(name, value) .name = value
  30. #endif /* !__cplusplus */
  31. extern bool verbose_output_p;
  32. extern const char task_attribute_name[];
  33. extern bool task_p (const_tree decl);
  34. #include <tree.h>
  35. /* This declaration is from `c-tree.h', but that header doesn't get
  36. installed. */
  37. extern tree xref_tag (enum tree_code, tree);
  38. /* Don't warn about the unused `gcc_version' variable, from
  39. <plugin-version.h>. */
  40. static const struct plugin_gcc_version *starpu_gcc_version
  41. __attribute__ ((__unused__));
  42. static const struct plugin_gcc_version *starpu_gcc_version = &gcc_version;