1
0
mirror of https://github.com/esphome/esphome.git synced 2025-11-17 15:26:01 +00:00
This commit is contained in:
J. Nick Koston
2025-10-28 21:58:36 -05:00
parent 1e3195676b
commit 5b5388b3ff
2 changed files with 10 additions and 7 deletions

View File

@@ -3,6 +3,7 @@
#include "esphome/core/component.h" #include "esphome/core/component.h"
#include "esphome/core/helpers.h" #include "esphome/core/helpers.h"
#include "esphome/core/log.h" #include "esphome/core/log.h"
#include "esphome/core/macros.h"
#include "esphome/core/string_ref.h" #include "esphome/core/string_ref.h"
#include <cassert> #include <cassert>
@@ -14,13 +15,6 @@
#define HAS_PROTO_MESSAGE_DUMP #define HAS_PROTO_MESSAGE_DUMP
#endif #endif
// Branch prediction hints for hot paths
#if defined(__GNUC__) || defined(__clang__)
#define ESPHOME_LIKELY(x) __builtin_expect(!!(x), 1)
#else
#define ESPHOME_LIKELY(x) (x)
#endif
namespace esphome::api { namespace esphome::api {
// Protocol Buffer wire type constants // Protocol Buffer wire type constants

View File

@@ -3,6 +3,15 @@
// Helper macro to define a version code, whose value can be compared against other version codes. // Helper macro to define a version code, whose value can be compared against other version codes.
#define VERSION_CODE(major, minor, patch) ((major) << 16 | (minor) << 8 | (patch)) #define VERSION_CODE(major, minor, patch) ((major) << 16 | (minor) << 8 | (patch))
// Branch prediction hints for performance-critical paths
#if defined(__GNUC__) || defined(__clang__)
#define ESPHOME_LIKELY(x) __builtin_expect(!!(x), 1)
#define ESPHOME_UNLIKELY(x) __builtin_expect(!!(x), 0)
#else
#define ESPHOME_LIKELY(x) (x)
#define ESPHOME_UNLIKELY(x) (x)
#endif
#ifdef USE_ARDUINO #ifdef USE_ARDUINO
#include <Arduino.h> #include <Arduino.h>
#endif #endif