Changeset e8d3c6f5 in mainline for uspace/lib/c/include/assert.h


Ignore:
Timestamp:
2018-01-13T00:38:49Z (6 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
36f0738
Parents:
9ba415e
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-01-12 23:46:12)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-01-13 00:38:49)
Message:

Align <assert.h> with standards, remove it from libposix,
and do not let malloc() use printf() with corrupted heap.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/include/assert.h

    r9ba415e re8d3c6f5  
    3434 */
    3535
     36// XXX: The definition of `assert()` is not guarded.
     37// One must not use `#pragma once` in this header.
     38// This is in accordance with the C standard.
     39
    3640#ifndef LIBC_ASSERT_H_
    3741#define LIBC_ASSERT_H_
    3842
    3943#define static_assert(expr)     _Static_assert(expr, "")
     44
     45extern void __helenos_assert_abort(const char *, const char *, unsigned int)
     46    __attribute__((noreturn));
     47
     48extern void __helenos_assert_quick_abort(const char *, const char *, unsigned int)
     49    __attribute__((noreturn));
     50
     51#endif
    4052
    4153/** Debugging assert macro
     
    4961 */
    5062
     63#undef assert
     64
    5165#ifndef NDEBUG
     66        #define assert(expr) ((expr) ? (void) 0 : __helenos_assert_abort(#expr, __FILE__, __LINE__))
     67#else
     68        #define assert(expr) ((void) 0)
     69#endif
    5270
    53 #define assert(expr) \
    54         do { \
    55                 if (!(expr)) \
    56                         assert_abort(#expr, __FILE__, __LINE__); \
    57         } while (0)
     71#ifdef _HELENOS_SOURCE
    5872
    59 #else /* NDEBUG */
     73#undef safe_assert
    6074
    61 #define assert(expr)
     75#ifndef NDEBUG
     76        #define safe_assert(expr) ((expr) ? (void) 0 : __helenos_assert_quick_abort(#expr, __FILE__, __LINE__))
     77#else
     78        #define safe_assert(expr) ((void) 0)
     79#endif
    6280
    63 #endif /* NDEBUG */
    64 
    65 extern void assert_abort(const char *, const char *, unsigned int)
    66     __attribute__((noreturn));
    67 
    68 #endif
     81#endif /* _HELENOS_SOURCE */
    6982
    7083/** @}
Note: See TracChangeset for help on using the changeset viewer.