Skip to content

Commit ce4793c

Browse files
committed
Enable detection of c++11. Replace throw() with noexcept.
1 parent 54cd721 commit ce4793c

25 files changed

+148
-142
lines changed

bktrace.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
namespace ustl {
1717

1818
/// Default constructor. The backtrace is obtained here.
19-
CBacktrace::CBacktrace (void) throw()
19+
CBacktrace::CBacktrace (void) noexcept
2020
: m_Symbols (NULL),
2121
m_nFrames (0),
2222
m_SymbolsSize (0)
@@ -26,7 +26,7 @@ CBacktrace::CBacktrace (void) throw()
2626
}
2727

2828
/// Copy constructor.
29-
CBacktrace::CBacktrace (const CBacktrace& v) throw()
29+
CBacktrace::CBacktrace (const CBacktrace& v) noexcept
3030
: m_Symbols (NULL),
3131
m_nFrames (0),
3232
m_SymbolsSize (0)
@@ -35,7 +35,7 @@ CBacktrace::CBacktrace (const CBacktrace& v) throw()
3535
}
3636

3737
/// Copy operator.
38-
const CBacktrace& CBacktrace::operator= (const CBacktrace& v) throw()
38+
const CBacktrace& CBacktrace::operator= (const CBacktrace& v) noexcept
3939
{
4040
memcpy (m_Addresses, v.m_Addresses, sizeof(m_Addresses));
4141
m_Symbols = strdup (v.m_Symbols);
@@ -45,7 +45,7 @@ const CBacktrace& CBacktrace::operator= (const CBacktrace& v) throw()
4545
}
4646

4747
/// Converts a string returned by backtrace_symbols into readable form.
48-
static size_t ExtractAbiName (const char* isym, char* nmbuf) throw()
48+
static size_t ExtractAbiName (const char* isym, char* nmbuf) noexcept
4949
{
5050
// Prepare the demangled name, if possible
5151
size_t nmSize = 0;
@@ -68,7 +68,7 @@ static size_t ExtractAbiName (const char* isym, char* nmbuf) throw()
6868
}
6969

7070
/// Tries to get symbol information for the addresses.
71-
void CBacktrace::GetSymbols (void) throw()
71+
void CBacktrace::GetSymbols (void) noexcept
7272
{
7373
char** symbols = backtrace_symbols (m_Addresses, m_nFrames);
7474
if (!symbols)

bktrace.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ class ostream;
2828
///
2929
class CBacktrace {
3030
public:
31-
CBacktrace (void) throw();
32-
CBacktrace (const CBacktrace& v) throw();
33-
inline ~CBacktrace (void) throw() { if (m_Symbols) free (m_Symbols); }
34-
const CBacktrace& operator= (const CBacktrace& v) throw();
31+
CBacktrace (void) noexcept;
32+
CBacktrace (const CBacktrace& v) noexcept;
33+
inline ~CBacktrace (void) noexcept { if (m_Symbols) free (m_Symbols); }
34+
const CBacktrace& operator= (const CBacktrace& v) noexcept;
3535
void text_write (ostringstream& os) const;
3636
void read (istream& is);
3737
void write (ostream& os) const;
3838
size_t stream_size (void) const;
3939
private:
40-
void GetSymbols (void) throw() DLL_LOCAL;
40+
void GetSymbols (void) noexcept DLL_LOCAL;
4141
private:
4242
void* m_Addresses [64]; ///< Addresses of each function on the stack.
4343
char* m_Symbols; ///< Symbols corresponding to each address.

cmemlink.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ class cmemlink {
5353
inline cmemlink (void) : m_Data (NULL), m_Size (0) { }
5454
inline cmemlink (const void* p, size_type n) : m_Data (const_pointer(p)), m_Size (n) { assert (p || !n); }
5555
inline cmemlink (const cmemlink& l) : m_Data (l.m_Data), m_Size (l.m_Size) {}
56-
inline virtual ~cmemlink (void) throw() {}
56+
inline virtual ~cmemlink (void) noexcept {}
5757
void link (const void* p, size_type n);
5858
inline void link (const cmemlink& l) { link (l.begin(), l.size()); }
5959
inline void link (const void* first, const void* last) { link (first, distance (first, last)); }
6060
inline void relink (const void* p, size_type n);
61-
virtual void unlink (void) throw() { m_Data = NULL; m_Size = 0; }
61+
virtual void unlink (void) noexcept { m_Data = NULL; m_Size = 0; }
6262
inline rcself_t operator= (const cmemlink& l) { link (l); return (*this); }
6363
bool operator== (const cmemlink& l) const;
6464
inline void swap (cmemlink& l) { ::ustl::swap (m_Data, l.m_Data); ::ustl::swap (m_Size, l.m_Size); }

config.h.in

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
///
2121
#define WANT_STREAM_BOUNDS_CHECKING 1
2222

23-
#if !defined(WANT_STREAM_BOUNDS_CHECKING) && !defined(NDEBUG)
23+
#if !WANT_STREAM_BOUNDS_CHECKING && !defined(NDEBUG)
2424
#define WANT_STREAM_BOUNDS_CHECKING 1
2525
#endif
2626

@@ -30,7 +30,7 @@
3030
/// even more). By default only the debug build does this.
3131
#undef WANT_NAME_DEMANGLING
3232

33-
#if !defined(WANT_NAME_DEMANGLING) && !defined(NDEBUG)
33+
#if !WANT_NAME_DEMANGLING && !defined(NDEBUG)
3434
#define WANT_NAME_DEMANGLING 1
3535
#endif
3636

@@ -47,7 +47,7 @@
4747
#define __attribute__(p)
4848
#endif
4949
#endif
50-
#if defined(__GNUC__) && __GNUC__ >= 4
50+
#if __GNUC__ >= 4
5151
#define DLL_EXPORT __attribute__((visibility("default")))
5252
#define DLL_LOCAL __attribute__((visibility("hidden")))
5353
#define INLINE __attribute__((always_inline))
@@ -56,13 +56,19 @@
5656
#define DLL_LOCAL
5757
#define INLINE
5858
#endif
59-
#if defined(__GNUC__) && __GNUC__ >= 3 && (__i386__ || __x86_64__)
59+
#if __cplusplus >= 201103L && (!__GNUC__ || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
60+
#define HAVE_CPP11 1
61+
#endif
62+
#if !HAVE_CPP11
63+
#define noexcept throw()
64+
#endif
65+
#if __GNUC__ >= 3 && (__i386__ || __x86_64__)
6066
/// GCC 3+ supports the prefetch directive, which some CPUs use to improve caching
6167
#define prefetch(p,rw,loc) __builtin_prefetch(p,rw,loc)
6268
#else
6369
#define prefetch(p,rw,loc)
6470
#endif
65-
#if !defined(__GNUC__) || __GNUC__ < 3
71+
#if __GNUC__ < 3
6672
/// __alignof__ returns the recommended alignment for the type
6773
#define __alignof__(v) min(sizeof(v), sizeof(void*))
6874
/// This macro returns 1 if the value of x is known at compile time.
@@ -168,19 +174,16 @@
168174
#undef HAVE_RINTF
169175

170176
// STDC_HEADERS is defined to 1 on sane systems.
171-
#if defined(HAVE_ASSERT_H) && defined(HAVE_CTYPE_H) &&\
172-
defined(HAVE_ERRNO_H) && defined(HAVE_FLOAT_H) &&\
173-
defined(HAVE_LIMITS_H) && defined(HAVE_LOCALE_H) &&\
174-
defined(HAVE_MATH_H) && defined(HAVE_SIGNAL_H) &&\
175-
defined(HAVE_STDARG_H) && defined(HAVE_STDDEF_H) &&\
176-
defined(HAVE_STDIO_H) && defined(HAVE_STDLIB_H) &&\
177-
defined(HAVE_STRING_H) && defined(HAVE_TIME_H)
178-
#define STDC_HEADERS 1
177+
#if HAVE_ASSERT_H && HAVE_CTYPE_H && HAVE_ERRNO_H && HAVE_FLOAT_H &&\
178+
HAVE_LIMITS_H && HAVE_LOCALE_H && HAVE_MATH_H && HAVE_SIGNAL_H &&\
179+
HAVE_STDARG_H && HAVE_STDDEF_H && HAVE_STDIO_H && HAVE_STDLIB_H &&\
180+
HAVE_STRING_H && HAVE_TIME_H
181+
#define STDC_HEADERS 1
179182
#endif
180183

181184
// STDC_HEADERS is defined to 1 on unix systems.
182-
#if defined(HAVE_FCNTL_H) && defined(HAVE_SYS_STAT_H) && defined(HAVE_UNISTD_H)
183-
#define STDUNIX_HEADERS 1
185+
#if HAVE_FCNTL_H && HAVE_SYS_STAT_H && HAVE_UNISTD_H
186+
#define STDUNIX_HEADERS 1
184187
#endif
185188

186189
// Define to 1 if your compiler treats char as a separate type along with
@@ -237,11 +240,11 @@
237240
#endif
238241

239242
// GCC vector extensions
240-
#if (defined(CPU_HAS_MMX) || defined(CPU_HAS_SSE)) && __GNUC__ >= 3
243+
#if (CPU_HAS_MMX || CPU_HAS_SSE) && __GNUC__ >= 3
241244
#undef HAVE_VECTOR_EXTENSIONS
242245
#endif
243246

244-
#if CPU_HAS_SSE && defined(__GNUC__)
247+
#if CPU_HAS_SSE && __GNUC__
245248
#define __sse_align __attribute__((aligned(16)))
246249
#else
247250
#define __sse_align

configure

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ int main (void)
230230
printf (SET(CPU_HAS_%s,1), s_CpuCaps[i].name);
231231
#if __GNUC__ >= 3
232232
printf ("s/ \\?@PROCESSOR_OPTS@/");
233+
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
234+
printf (" -std=c++11");
235+
#endif
233236
if (caps & (1<<23))
234237
printf (" -mmmx");
235238
if (caps & ((1<<22)|(1<<25)))

fstream.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fstream::fstream (int nfd, const char* filename)
4545
}
4646

4747
/// Destructor. Closes if still open, but without throwing.
48-
fstream::~fstream (void) throw()
48+
fstream::~fstream (void) noexcept
4949
{
5050
clear (goodbit);
5151
exceptions (goodbit);

fstream.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class fstream : public ios_base {
2727
fstream (void);
2828
explicit fstream (const char* filename, openmode mode = in | out);
2929
explicit fstream (int nfd, const char* filename = "");
30-
~fstream (void) throw();
30+
~fstream (void) noexcept;
3131
void open (const char* filename, openmode mode, mode_t perms = 0644);
3232
void attach (int nfd, const char* filename = "");
3333
void detach (void);

memblock.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ memblock::memblock (size_type n) : memlink (), m_Capacity (0) { resize (n); }
1818
memblock::memblock (const cmemlink& b) : memlink (), m_Capacity (0) { assign (b); }
1919
memblock::memblock (const memlink& b) : memlink (), m_Capacity (0) { assign (b); }
2020
memblock::memblock (const memblock& b) : memlink (), m_Capacity (0) { assign (b); }
21-
memblock::~memblock (void) throw() { deallocate(); }
21+
memblock::~memblock (void) noexcept { deallocate(); }
2222

23-
void memblock::unlink (void) throw()
23+
void memblock::unlink (void) noexcept
2424
{
2525
m_Capacity = 0;
2626
memlink::unlink();
@@ -35,7 +35,7 @@ void memblock::resize (size_type newSize, bool bExact)
3535
}
3636

3737
/// Frees internal data.
38-
void memblock::deallocate (void) throw()
38+
void memblock::deallocate (void) noexcept
3939
{
4040
if (m_Capacity) {
4141
assert (cdata() && "Internal error: space allocated, but the pointer is NULL");
@@ -147,6 +147,6 @@ void memblock::read_file (const char* filename)
147147
resize (fsize);
148148
}
149149

150-
memblock::size_type memblock::minimumFreeCapacity (void) const throw() { return (0); }
150+
memblock::size_type memblock::minimumFreeCapacity (void) const noexcept { return (0); }
151151

152152
} // namespace ustl

memblock.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ class memblock : public memlink {
2828
explicit memblock (const cmemlink& b);
2929
explicit memblock (const memlink& b);
3030
memblock (const memblock& b);
31-
virtual ~memblock (void) throw();
32-
virtual void unlink (void) throw();
31+
virtual ~memblock (void) noexcept;
32+
virtual void unlink (void) noexcept;
3333
inline void assign (const cmemlink& l) { assign (l.cdata(), l.readable_size()); }
3434
inline const memblock& operator= (const cmemlink& l) { assign (l); return (*this); }
3535
inline const memblock& operator= (const memlink& l) { assign (l); return (*this); }
@@ -45,13 +45,13 @@ class memblock : public memlink {
4545
inline bool is_linked (void) const { return (!capacity()); }
4646
inline size_type max_size (void) const { return (is_linked() ? memlink::max_size() : SIZE_MAX); }
4747
inline void manage (memlink& l) { manage (l.begin(), l.size()); }
48-
void deallocate (void) throw();
48+
void deallocate (void) noexcept;
4949
void manage (void* p, size_type n);
5050
void copy_link (void);
5151
void read (istream& is);
5252
void read_file (const char* filename);
5353
protected:
54-
virtual size_type minimumFreeCapacity (void) const throw() __attribute__((const));
54+
virtual size_type minimumFreeCapacity (void) const noexcept __attribute__((const));
5555
private:
5656
size_type m_Capacity; ///< Number of bytes allocated by Resize.
5757
};

mistream.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ istream::istream (const ostream& source)
2828
{
2929
}
3030

31-
void istream::unlink (void) throw() { cmemlink::unlink(); m_Pos = 0; }
32-
void ostream::unlink (void) throw() { memlink::unlink(); m_Pos = 0; }
31+
void istream::unlink (void) noexcept { cmemlink::unlink(); m_Pos = 0; }
32+
void ostream::unlink (void) noexcept { memlink::unlink(); m_Pos = 0; }
3333

3434
/// Writes all unread bytes into \p os.
3535
void istream::write (ostream& os) const

0 commit comments

Comments
 (0)