edk_attribute.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*************************************************************************
  2. * Copyright (C) [2019] by Cambricon, Inc. All rights reserved
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * The above copyright notice and this permission notice shall be included in
  11. * all copies or substantial portions of the Software.
  12. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  13. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  15. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  18. * THE SOFTWARE.
  19. *************************************************************************/
  20. /**
  21. * @file edk_attribute.h
  22. *
  23. * Attribute macros
  24. */
  25. #ifndef EDK_CXXUTIL_ATTRIBUTE_H_
  26. #define EDK_CXXUTIL_ATTRIBUTE_H_
  27. #ifdef __GNUC__
  28. #define attribute_deprecated __attribute__((deprecated))
  29. #elif defined(_MSC_VER)
  30. #define attribute_deprecated __declspec(deprecated)
  31. #else
  32. #pragma message("attribute_deprecated is not defined for this compiler")
  33. #define attribute_deprecated
  34. #endif
  35. #ifdef __GNUC__
  36. #define EDK_LIKELY(x) (__builtin_expect(!!(x), 1))
  37. #define EDK_UNLIKELY(x) (__builtin_expect(!!(x), 0))
  38. #else
  39. #define EDK_UNLIKELY(x) x
  40. #define EDK_LIKELY(x) x
  41. #endif
  42. #endif // EDK_CXXUTIL_ATTRIBUTE_H_