diff options
author | Aaron Durbin <adurbin@chromium.org> | 2015-01-22 08:53:02 -0600 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2015-03-19 23:23:41 +0100 |
commit | c88cca1c38bb2752a7284590ec70a55caf3e490d (patch) | |
tree | da76a520b4440e382e6ff0f62e622613c80702a5 /payloads/libpayload/include | |
parent | e5be1dc336d460f4bc4781b5e8ee5eb0b7e04a2e (diff) |
libpayload: add xmemalign()
Similarly to xzalloc() and xmalloc() provide an xmemalign() function
to do the approriate assertions on allocation failure.
BUG=None
BRANCH=None
TEST=Built and booted using xmemalign().
Change-Id: I59579d9ee973af3bb34037b7df5b1024b60e348d
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 3001822656024dbfc34d6b849a0245274b8c0f46
Original-Change-Id: Ie307d4c9c1882bba25745afe38455f2682303e37
Original-Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/242455
Original-Reviewed-by: Patrick Georgi <pgeorgi@chromium.org>
Reviewed-on: http://review.coreboot.org/8728
Tested-by: build bot (Jenkins)
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'payloads/libpayload/include')
-rw-r--r-- | payloads/libpayload/include/stdlib.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/payloads/libpayload/include/stdlib.h b/payloads/libpayload/include/stdlib.h index 04acec54e1..e571d18f0b 100644 --- a/payloads/libpayload/include/stdlib.h +++ b/payloads/libpayload/include/stdlib.h @@ -174,6 +174,20 @@ static inline void *xzalloc_work(size_t size, const char *file, return ret; } #define xzalloc(size) xzalloc_work((size), __FILE__, __FUNCTION__, __LINE__) + +static inline void *xmemalign_work(size_t align, size_t size, const char *file, + const char *func, int line) +{ + void *ret = memalign(align, size); + if (!ret && size) { + die_work(file, func, line, + "Failed to memalign %zu bytes with %zu alignment.\n", + size, align); + } + return ret; +} +#define xmemalign(align, size) \ + xmemalign_work((align), (size), __FILE__, __func__, __LINE__) /** @} */ /** |