Skip to content

Commit c8e50b0

Browse files
LukeBoyercopybara-github
authored andcommitted
Generalize litert ensure macro
LiteRT-PiperOrigin-RevId: 775375219
1 parent 83b742e commit c8e50b0

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

litert/cc/litert_macros.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,12 +357,15 @@ class LogBeforeAbort {
357357
#define LITERT_CHECK_STATUS_OK(expr) \
358358
LITERT_CHECK_STATUS_HAS_CODE(expr, kLiteRtStatusOk);
359359

360-
#define LITERT_ENSURE_SUPPORTED(cond, msg) \
361-
if (!(cond)) { \
362-
LITERT_LOG(LITERT_ERROR, "%s", msg); \
363-
return kLiteRtStatusErrorUnsupported; \
360+
#define LITERT_ENSURE(cond, status, msg) \
361+
if (!(cond)) { \
362+
LITERT_LOG(LITERT_ERROR, "%s", msg); \
363+
return status; \
364364
}
365365

366+
#define LITERT_ENSURE_SUPPORTED(cond, msg) \
367+
LITERT_ENSURE(cond, kLiteRtStatusErrorUnsupported, msg);
368+
366369
#define LITERT_RETURN_IF_ERROR_OR_NOT_MATCHED(expr) \
367370
if (LiteRtStatus status = expr; \
368371
(status != kLiteRtStatusOk && status != kLiteRtStatusLegalizeNoMatch)) \

0 commit comments

Comments
 (0)