1 // utility.h -- Various little utility functions, macros & typedefs.
3 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
4 // Free Software Foundation, Inc
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #ifndef GNASH_UTILITY_H
21 #define GNASH_UTILITY_H
23 // HAVE_FINITE, HAVE_PTHREADS, WIN32, NDEBUG etc.
25 #include "gnashconfig.h"
34 #if defined(__GNUC__) && __GNUC__ > 2
38 #if defined(_WIN32) || defined(WIN32)
41 // On windows, replace ANSI assert with our own, for a less annoying
42 // debugging experience.
45 #define assert(x) if (!(x)) { __asm { int 3 } }
51 #include <stdio.h> //for FILE * in tu_file.h
52 #include <fcntl.h> //for fcntl in Socket.cpp
53 #include <netdb.h> //for hostent in Socket.cpp
54 #include <netinet/tcp.h> //for TCP_NODELAY in Socket.cpp
55 #undef UNUSED //to avoid "already defined" messages
60 typedef std::basic_string
<wchar_t> wstring
;
64 #if defined(__HAIKU__)
66 class wstring
: public std::basic_string
<char>
69 wstring(const char *t
)
70 : std::basic_string
<char>(t
)
76 wstring(const wstring
&that
)
77 : std::basic_string
<char>(that
.c_str())
80 wstring(const std::basic_string
<char> &that
)
81 : std::basic_string
<char>(that
)
90 /// Return (unmangled) name of this instance type. Used for
91 /// logging in various places.
93 std::string
typeName(const T
& inst
)
95 std::string typeName
= typeid(inst
).name();
96 #if defined(__GNUC__) && __GNUC__ > 2
98 char* typeNameUnmangled
=
99 abi::__cxa_demangle (typeName
.c_str(), nullptr, nullptr,
103 typeName
= typeNameUnmangled
;
104 std::free(typeNameUnmangled
);
106 #endif // __GNUC__ > 2
112 // Handy macro to quiet compiler warnings about unused parameters/variables.
113 #define UNUSED(x) static_cast<void>((x))
122 // indent-tabs-mode: t