mirror of
https://github.com/clearlinux/graphene.git
synced 2026-09-07 14:21:56 +00:00
* Several memory allocation fixes, primarily motivated by the fact that the Diffie-Hellman implementation in mbedtls is sensitive to misaligned allocations. All malloc's are now 16-byte aligned. This PR has several other points where remalloc was used instead of realloc, or memory needed to be zeroed upon allocation. Finally, this PR also standardizes the definition of assert across layers, so that code in the lib directory can both use assertions and link properly in the PAL and shim.
36 lines
1.2 KiB
C
36 lines
1.2 KiB
C
/* -*- mode:c; c-file-style:"k&r"; c-basic-offset: 4; tab-width:4; indent-tabs-mode:nil; mode:auto-fill; fill-column:78; -*- */
|
|
/* vim: set ts=4 sw=4 et tw=78 fo=cqt wm=0: */
|
|
|
|
/*
|
|
* assert.h
|
|
*
|
|
* Define a common interface for assertions that builds for both the PAL
|
|
* and libOS.
|
|
*
|
|
*/
|
|
|
|
#ifndef ASSERT_H
|
|
#define ASSERT_H
|
|
|
|
/* All environments should implement warn, which prints a non-optional debug
|
|
* message. All environments should also implement __abort, which
|
|
* terminates the process.
|
|
*/
|
|
|
|
void warn (const char *format, ...);
|
|
void __abort(void);
|
|
|
|
# define assert(test) \
|
|
({ \
|
|
long _val = (long) (test); \
|
|
(!(_val)) \
|
|
? ({ \
|
|
warn("assert failed " __FILE__ ":%d " #test " (value:%x)\n", \
|
|
__LINE__, _val); \
|
|
__abort(); }) \
|
|
: (void) 0; \
|
|
})
|
|
|
|
#endif
|
|
|