esp_compiler.h 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. // Copyright 2016-2019 Espressif Systems (Shanghai) PTE LTD
  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. #ifndef __ESP_COMPILER_H
  15. #define __ESP_COMPILER_H
  16. /*
  17. * The likely and unlikely macro pairs:
  18. * These macros are useful to place when application
  19. * knows the majority ocurrence of a decision paths,
  20. * placing one of these macros can hint the compiler
  21. * to reorder instructions producing more optimized
  22. * code.
  23. */
  24. #if (CONFIG_COMPILER_OPTIMIZATION_PERF)
  25. #define likely(x) __builtin_expect(!!(x), 1)
  26. #define unlikely(x) __builtin_expect(!!(x), 0)
  27. #else
  28. #define likely(x) (x)
  29. #define unlikely(x) (x)
  30. #endif
  31. #endif