make (array) of ArrayObject return the contents
[hiphop-php.git] / hphp / util / assertions.cpp
blob6b8f03c29fb617af7c231a45b560786fb4b2f8cd
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
16 #include "hphp/util/assertions.h"
18 namespace HPHP {
20 static AssertFailLogger s_logger;
22 // In builds without NDEBUG, we don't have __assert_fail from the GNU
23 // library, so we implement it here for always_assert().
24 void impl_assert_fail(const char* e, const char* file,
25 unsigned int line, const char* func) {
26 fprintf(stderr, "%s:%d: %s: assertion `%s' failed.", file, line, func, e);
27 std::abort();
30 void assert_fail_log(const char* title, const std::string& msg) {
31 if (s_logger) {
32 s_logger(title, msg);
34 fprintf(stderr, "Assertion failure: %s\n", msg.c_str());
37 void register_assert_fail_logger(AssertFailLogger l) {
38 s_logger = l;