[inc][utils] Add a utils.h for miscellaneous helpers
Add a utils.h file containing miscellaneous convenience helpers.
This commit is contained in:
committed by
Travis Geiselbrecht
parent
8fc673fe4a
commit
9165714702
21
top/include/lk/utils.h
Normal file
21
top/include/lk/utils.h
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Copyright (C) 2020-2023 Google LLC.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define ARRAY_SIZE(_a) (sizeof(_a) / sizeof(*(_a)))
|
||||
|
||||
#define KB (1024UL)
|
||||
#define MB (1024UL * 1024UL)
|
||||
#define GB (1024UL * 1024UL * 1024UL)
|
||||
|
||||
#define RETURN_IF_ERROR(expr) \
|
||||
do { \
|
||||
status_t err_ = (expr); \
|
||||
if (err_ != NO_ERROR) { \
|
||||
return err_; \
|
||||
} \
|
||||
} while (0)
|
||||
Reference in New Issue
Block a user