1 /****************************************************************************** 2 * Copyright (c) 2004, 2008, 2012 IBM Corporation 3 * All rights reserved. 4 * This program and the accompanying materials 5 * are made available under the terms of the BSD License 6 * which accompanies this distribution, and is available at 7 * http://www.opensource.org/licenses/bsd-license.php 8 * 9 * Contributors: 10 * IBM Corporation - initial implementation 11 *****************************************************************************/ 12 13 #ifndef _ASSERT_H 14 #define _ASSERT_H 15 16 #define assert(cond) \ 17 do { if (!(cond)) { \ 18 assert_fail(__FILE__ \ 19 ":" stringify(__LINE__) \ 20 ":" stringify(cond)); } \ 21 } while(0) 22 23 void __attribute__((noreturn)) assert_fail(const char *msg); 24 25 #define stringify(expr) stringify_1(expr) 26 /* Double-indirection required to stringify expansions */ 27 #define stringify_1(expr) #expr 28 29 #endif 30