target_config.h 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. /* Copyright 2019-2020 Canaan Inc.
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. #pragma once
  16. #include <cassert>
  17. // clang-format off
  18. #define NNCASE_STRINGFY(x) #x
  19. #define NNCASE_CONCAT_2(a, b) a/b
  20. #define NNCASE_CONCAT_3(a, b, c) NNCASE_CONCAT_2(NNCASE_CONCAT_2(a, b), c)
  21. // clang-format on
  22. #define NNCASE_TARGET_HEADER_(prefix, target, name) <NNCASE_CONCAT_3(prefix, target, name)>
  23. #define NNCASE_TARGET_HEADER(prefix, name) NNCASE_TARGET_HEADER_(prefix, NNCASE_TARGET, name)
  24. #ifndef NNCASE_NO_EXCEPTIONS
  25. #include <stdexcept>
  26. #define NNCASE_THROW(exception, ...) throw exception(__VA_ARGS__)
  27. #else
  28. #define NNCASE_THROW(exception, ...) assert(0 && #exception)
  29. #endif