From 91605d3f4df9b9fb1490c276053ff274fb728816 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Thu, 3 Dec 2015 18:17:25 +0100 Subject: clang-modernize part 1 (nw) --- src/lib/util/corealloc.cpp | 66 +++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 33 deletions(-) (limited to 'src/lib/util/corealloc.cpp') diff --git a/src/lib/util/corealloc.cpp b/src/lib/util/corealloc.cpp index a635803e463..9ca7af380d3 100644 --- a/src/lib/util/corealloc.cpp +++ b/src/lib/util/corealloc.cpp @@ -90,11 +90,11 @@ const zeromem_t zeromem = { }; // globals for memory_entry UINT64 memory_entry::s_curid = 1; -osd_lock *memory_entry::s_lock = NULL; +osd_lock *memory_entry::s_lock = nullptr; bool memory_entry::s_lock_alloc = false; bool memory_entry::s_tracking = false; -memory_entry *memory_entry::s_hash[memory_entry::k_hash_prime] = { NULL }; -memory_entry *memory_entry::s_freehead = NULL; +memory_entry *memory_entry::s_hash[memory_entry::k_hash_prime] = { nullptr }; +memory_entry *memory_entry::s_freehead = nullptr; //************************************************************************** // OPERATOR REPLACEMENTS @@ -103,15 +103,15 @@ memory_entry *memory_entry::s_freehead = NULL; #ifndef NO_MEM_TRACKING // standard new/delete operators (try to avoid using) -void *operator new(std::size_t size) throw (std::bad_alloc) { return malloc_file_line(size, NULL, 0, false, true, false); } -void *operator new[](std::size_t size) throw (std::bad_alloc) { return malloc_file_line(size, NULL, 0, true, true, false); } -void operator delete(void *ptr) throw() { if (ptr != NULL) free_file_line(ptr, NULL, 0, false); } -void operator delete[](void *ptr) throw() { if (ptr != NULL) free_file_line(ptr, NULL, 0, true); } +void *operator new(std::size_t size) throw (std::bad_alloc) { return malloc_file_line(size, nullptr, 0, false, true, false); } +void *operator new[](std::size_t size) throw (std::bad_alloc) { return malloc_file_line(size, nullptr, 0, true, true, false); } +void operator delete(void *ptr) throw() { if (ptr != nullptr) free_file_line(ptr, nullptr, 0, false); } +void operator delete[](void *ptr) throw() { if (ptr != nullptr) free_file_line(ptr, nullptr, 0, true); } -void* operator new(std::size_t size,const std::nothrow_t&) throw() { return malloc_file_line(size, NULL, 0, false, false, false); } -void* operator new[](std::size_t size, const std::nothrow_t&) throw() { return malloc_file_line(size, NULL, 0, true, false, false); } -void operator delete(void* ptr, const std::nothrow_t&) throw() { if (ptr != NULL) free_file_line(ptr, NULL, 0, false); } -void operator delete[](void* ptr, const std::nothrow_t&) throw() { if (ptr != NULL) free_file_line(ptr, NULL, 0, true); } +void* operator new(std::size_t size,const std::nothrow_t&) throw() { return malloc_file_line(size, nullptr, 0, false, false, false); } +void* operator new[](std::size_t size, const std::nothrow_t&) throw() { return malloc_file_line(size, nullptr, 0, true, false, false); } +void operator delete(void* ptr, const std::nothrow_t&) throw() { if (ptr != nullptr) free_file_line(ptr, nullptr, 0, false); } +void operator delete[](void* ptr, const std::nothrow_t&) throw() { if (ptr != nullptr) free_file_line(ptr, nullptr, 0, true); } #endif @@ -122,14 +122,14 @@ void operator delete[](void* ptr, const std::nothrow_t&) throw() { if (ptr != NU // file/line new/delete operators void *operator new(std::size_t size, const char *file, int line) throw (std::bad_alloc) { return malloc_file_line(size, file, line, false, true, false); } void *operator new[](std::size_t size, const char *file, int line) throw (std::bad_alloc) { return malloc_file_line(size, file, line, true, true, false); } -void operator delete(void *ptr, const char *file, int line) { if (ptr != NULL) free_file_line(ptr, file, line, false); } -void operator delete[](void *ptr, const char *file, int line) { if (ptr != NULL) free_file_line(ptr, file, line, true); } +void operator delete(void *ptr, const char *file, int line) { if (ptr != nullptr) free_file_line(ptr, file, line, false); } +void operator delete[](void *ptr, const char *file, int line) { if (ptr != nullptr) free_file_line(ptr, file, line, true); } // file/line new/delete operators with zeroing void *operator new(std::size_t size, const char *file, int line, const zeromem_t &) throw (std::bad_alloc) { return malloc_file_line(size, file, line, false, true, true); } void *operator new[](std::size_t size, const char *file, int line, const zeromem_t &) throw (std::bad_alloc) { return malloc_file_line(size, file, line, true, true, true); } -void operator delete(void *ptr, const char *file, int line, const zeromem_t &) { if (ptr != NULL) free_file_line(ptr, file, line, false); } -void operator delete[](void *ptr, const char *file, int line, const zeromem_t &) { if (ptr != NULL) free_file_line(ptr, file, line, true); } +void operator delete(void *ptr, const char *file, int line, const zeromem_t &) { if (ptr != nullptr) free_file_line(ptr, file, line, false); } +void operator delete[](void *ptr, const char *file, int line, const zeromem_t &) { if (ptr != nullptr) free_file_line(ptr, file, line, true); } @@ -146,13 +146,13 @@ void *malloc_file_line(size_t size, const char *file, int line, bool array, bool { // allocate the memory and fail if we can't void *result = array ? osd_malloc_array(size) : osd_malloc(size); - if (result == NULL) + if (result == nullptr) { fprintf(stderr, "Failed to allocate %d bytes (%s:%d)\n", UINT32(size), file, line); osd_break_into_debugger("Failed to allocate RAM"); if (throw_on_fail) throw std::bad_alloc(); - return NULL; + return nullptr; } // zap the memory if requested @@ -183,7 +183,7 @@ void free_file_line(void *memory, const char *file, int line, bool array) memory_entry *entry = memory_entry::find(memory); // warn about untracked frees - if (entry == NULL) + if (entry == nullptr) { fprintf(stderr, "Error: attempt to free untracked memory %p in %s(%d)!\n", memory, file, line); osd_break_into_debugger("Error: attempt to free untracked memory"); @@ -267,7 +267,7 @@ void memory_entry::acquire_lock() { // allocate a lock on first usage // note that osd_lock_alloc() may re-enter this path, so protect against recursion! - if (s_lock == NULL) + if (s_lock == nullptr) { if (s_lock_alloc) return; @@ -298,14 +298,14 @@ memory_entry *memory_entry::allocate(size_t size, void *base, const char *file, acquire_lock(); // if we're out of free entries, allocate a new chunk - if (s_freehead == NULL) + if (s_freehead == nullptr) { // create a new chunk, and fail if we can't memory_entry *entry = reinterpret_cast(osd_malloc_array(memory_block_alloc_chunk * sizeof(memory_entry))); - if (entry == NULL) + if (entry == nullptr) { release_lock(); - return NULL; + return nullptr; } // add all the entries to the list @@ -323,7 +323,7 @@ memory_entry *memory_entry::allocate(size_t size, void *base, const char *file, // populate it entry->m_size = size; entry->m_base = base; - entry->m_file = s_tracking ? file : NULL; + entry->m_file = s_tracking ? file : nullptr; entry->m_line = s_tracking ? line : 0; entry->m_id = s_curid++; entry->m_array = array; @@ -333,9 +333,9 @@ memory_entry *memory_entry::allocate(size_t size, void *base, const char *file, // add it to the alloc list int hashval = reinterpret_cast(base) % k_hash_prime; entry->m_next = s_hash[hashval]; - if (entry->m_next != NULL) + if (entry->m_next != nullptr) entry->m_next->m_prev = entry; - entry->m_prev = NULL; + entry->m_prev = nullptr; s_hash[hashval] = entry; release_lock(); @@ -350,15 +350,15 @@ memory_entry *memory_entry::allocate(size_t size, void *base, const char *file, memory_entry *memory_entry::find(void *ptr) { // NULL maps to nothing - if (ptr == NULL) - return NULL; + if (ptr == nullptr) + return nullptr; // scan the list under the lock acquire_lock(); int hashval = reinterpret_cast(ptr) % k_hash_prime; memory_entry *entry; - for (entry = s_hash[hashval]; entry != NULL; entry = entry->m_next) + for (entry = s_hash[hashval]; entry != nullptr; entry = entry->m_next) if (entry->m_base == ptr) break; @@ -380,11 +380,11 @@ void memory_entry::release(memory_entry *entry, const char *file, int line) // remove ourselves from the alloc list int hashval = reinterpret_cast(entry->m_base) % k_hash_prime; - if (entry->m_prev != NULL) + if (entry->m_prev != nullptr) entry->m_prev->m_next = entry->m_next; else s_hash[hashval] = entry->m_next; - if (entry->m_next != NULL) + if (entry->m_next != nullptr) entry->m_next->m_prev = entry->m_prev; // add ourself to the free list @@ -411,9 +411,9 @@ void memory_entry::report_unfreed(UINT64 start) // check for leaked memory UINT32 total = 0; - for (int hashnum = 0; hashnum < k_hash_prime; hashnum++) - for (memory_entry *entry = s_hash[hashnum]; entry != NULL; entry = entry->m_next) - if (entry->m_file != NULL && entry->m_id >= start) + for (auto entry : s_hash) + for (; entry != nullptr; entry = entry->m_next) + if (entry->m_file != nullptr && entry->m_id >= start) { if (total == 0) fprintf(stderr, "--- memory leak warning ---\n"); -- cgit v1.2.3 From 1d40aecb585e8dd1fedefdd35a833c66fc2a1b96 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Wed, 9 Dec 2015 10:50:20 +0100 Subject: Cleanup of osdcomm.h (nw) --- src/lib/util/corealloc.cpp | 5 +++- src/osd/osdcomm.h | 62 ++++++++++------------------------------------ 2 files changed, 17 insertions(+), 50 deletions(-) (limited to 'src/lib/util/corealloc.cpp') diff --git a/src/lib/util/corealloc.cpp b/src/lib/util/corealloc.cpp index 9ca7af380d3..9e25af63b10 100644 --- a/src/lib/util/corealloc.cpp +++ b/src/lib/util/corealloc.cpp @@ -27,7 +27,10 @@ // define this to zap memory to a fixed non-0 value before freeing //#define OVERWRITE_FREED_MEMORY - +// compatibility with non-clang compilers +#ifndef __has_feature + #define __has_feature(x) 0 +#endif //************************************************************************** // CONSTANTS diff --git a/src/osd/osdcomm.h b/src/osd/osdcomm.h index 9465be7477c..b00c74869f7 100644 --- a/src/osd/osdcomm.h +++ b/src/osd/osdcomm.h @@ -16,7 +16,7 @@ #include #include - +#include /*************************************************************************** COMPILER-SPECIFIC NASTINESS @@ -29,38 +29,23 @@ /* Some optimizations/warnings cleanups for GCC */ -#if defined(__GNUC__) && (__GNUC__ >= 3) +#if defined(__GNUC__) #define ATTR_UNUSED __attribute__((__unused__)) #define ATTR_NORETURN __attribute__((noreturn)) #define ATTR_PRINTF(x,y) __attribute__((format(printf, x, y))) -#define ATTR_MALLOC __attribute__((malloc)) -#define ATTR_PURE __attribute__((pure)) #define ATTR_CONST __attribute__((const)) #define ATTR_FORCE_INLINE __attribute__((always_inline)) #define ATTR_NONNULL(...) __attribute__((nonnull(__VA_ARGS__))) #define ATTR_DEPRECATED __attribute__((deprecated)) -/* not supported in GCC prior to 4.4.x */ -#if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4) #define ATTR_HOT __attribute__((hot)) #define ATTR_COLD __attribute__((cold)) -#else -#define ATTR_HOT -#define ATTR_COLD -#endif #define UNEXPECTED(exp) __builtin_expect(!!(exp), 0) #define EXPECTED(exp) __builtin_expect(!!(exp), 1) #define RESTRICT __restrict__ -#define SETJMP_GNUC_PROTECT() (void)__builtin_return_address(1) #else #define ATTR_UNUSED -#if defined(_MSC_VER) && (_MSC_VER >= 1200) #define ATTR_NORETURN __declspec(noreturn) -#else -#define ATTR_NORETURN -#endif #define ATTR_PRINTF(x,y) -#define ATTR_MALLOC -#define ATTR_PURE #define ATTR_CONST #define ATTR_FORCE_INLINE __forceinline #define ATTR_NONNULL(...) @@ -70,7 +55,6 @@ #define UNEXPECTED(exp) (exp) #define EXPECTED(exp) (exp) #define RESTRICT -#define SETJMP_GNUC_PROTECT() do {} while (0) #endif @@ -79,43 +63,28 @@ FUNDAMENTAL TYPES ***************************************************************************/ -/* These types work on most modern compilers; however, OSD code can - define their own by setting OSD_TYPES_DEFINED */ - -#ifndef OSD_TYPES_DEFINED /* 8-bit values */ -typedef unsigned char UINT8; -typedef signed char INT8; +using UINT8 = uint8_t; +using INT8 = int8_t; /* 16-bit values */ -typedef unsigned short UINT16; -typedef signed short INT16; +using UINT16 = uint16_t; +using INT16 = int16_t; /* 32-bit values */ -#ifndef _WINDOWS_H -typedef unsigned int UINT32; -typedef signed int INT32; -#endif +using UINT32 = uint32_t; +using INT32 = int32_t; /* 64-bit values */ -#ifndef _WINDOWS_H -#ifdef _MSC_VER -typedef signed __int64 INT64; -typedef unsigned __int64 UINT64; -#else -__extension__ typedef unsigned long long UINT64; -__extension__ typedef signed long long INT64; -#endif -#endif - -#endif +using UINT64 = uint64_t; +using INT64 = int64_t; /* pointer-sized values */ #ifdef PTR64 -typedef UINT64 FPTR; +using FPTR = uint64_t; #else -typedef UINT32 FPTR; +using FPTR = uint32_t; #endif @@ -165,7 +134,7 @@ typedef UINT32 FPTR; /* MINGW has adopted the MSVC formatting for 64-bit ints as of gcc 4.4 */ -#if (defined(__MINGW32__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))) || defined(_MSC_VER) +#if defined(__MINGW32__) || defined(_MSC_VER) #define I64FMT "I64" #else #define I64FMT "ll" @@ -218,11 +187,6 @@ typedef UINT32 FPTR; #define LITTLE_ENDIANIZE_INT64(x) (FLIPENDIAN_INT64(x)) #endif /* LSB_FIRST */ -// compatibility with non-clang compilers -#ifndef __has_feature - #define __has_feature(x) 0 -#endif - #ifdef _MSC_VER #include typedef ptrdiff_t ssize_t; -- cgit v1.2.3 From 791743976e3366e9d3bf8f3b247280bf04c12baf Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Wed, 9 Dec 2015 11:37:33 +0100 Subject: Revert "Cleanup of osdcomm.h (nw)" This reverts commit 1d40aecb585e8dd1fedefdd35a833c66fc2a1b96. --- src/lib/util/corealloc.cpp | 5 +--- src/osd/osdcomm.h | 62 ++++++++++++++++++++++++++++++++++++---------- 2 files changed, 50 insertions(+), 17 deletions(-) (limited to 'src/lib/util/corealloc.cpp') diff --git a/src/lib/util/corealloc.cpp b/src/lib/util/corealloc.cpp index 9e25af63b10..9ca7af380d3 100644 --- a/src/lib/util/corealloc.cpp +++ b/src/lib/util/corealloc.cpp @@ -27,10 +27,7 @@ // define this to zap memory to a fixed non-0 value before freeing //#define OVERWRITE_FREED_MEMORY -// compatibility with non-clang compilers -#ifndef __has_feature - #define __has_feature(x) 0 -#endif + //************************************************************************** // CONSTANTS diff --git a/src/osd/osdcomm.h b/src/osd/osdcomm.h index b00c74869f7..9465be7477c 100644 --- a/src/osd/osdcomm.h +++ b/src/osd/osdcomm.h @@ -16,7 +16,7 @@ #include #include -#include + /*************************************************************************** COMPILER-SPECIFIC NASTINESS @@ -29,23 +29,38 @@ /* Some optimizations/warnings cleanups for GCC */ -#if defined(__GNUC__) +#if defined(__GNUC__) && (__GNUC__ >= 3) #define ATTR_UNUSED __attribute__((__unused__)) #define ATTR_NORETURN __attribute__((noreturn)) #define ATTR_PRINTF(x,y) __attribute__((format(printf, x, y))) +#define ATTR_MALLOC __attribute__((malloc)) +#define ATTR_PURE __attribute__((pure)) #define ATTR_CONST __attribute__((const)) #define ATTR_FORCE_INLINE __attribute__((always_inline)) #define ATTR_NONNULL(...) __attribute__((nonnull(__VA_ARGS__))) #define ATTR_DEPRECATED __attribute__((deprecated)) +/* not supported in GCC prior to 4.4.x */ +#if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4) #define ATTR_HOT __attribute__((hot)) #define ATTR_COLD __attribute__((cold)) +#else +#define ATTR_HOT +#define ATTR_COLD +#endif #define UNEXPECTED(exp) __builtin_expect(!!(exp), 0) #define EXPECTED(exp) __builtin_expect(!!(exp), 1) #define RESTRICT __restrict__ +#define SETJMP_GNUC_PROTECT() (void)__builtin_return_address(1) #else #define ATTR_UNUSED +#if defined(_MSC_VER) && (_MSC_VER >= 1200) #define ATTR_NORETURN __declspec(noreturn) +#else +#define ATTR_NORETURN +#endif #define ATTR_PRINTF(x,y) +#define ATTR_MALLOC +#define ATTR_PURE #define ATTR_CONST #define ATTR_FORCE_INLINE __forceinline #define ATTR_NONNULL(...) @@ -55,6 +70,7 @@ #define UNEXPECTED(exp) (exp) #define EXPECTED(exp) (exp) #define RESTRICT +#define SETJMP_GNUC_PROTECT() do {} while (0) #endif @@ -63,28 +79,43 @@ FUNDAMENTAL TYPES ***************************************************************************/ +/* These types work on most modern compilers; however, OSD code can + define their own by setting OSD_TYPES_DEFINED */ + +#ifndef OSD_TYPES_DEFINED /* 8-bit values */ -using UINT8 = uint8_t; -using INT8 = int8_t; +typedef unsigned char UINT8; +typedef signed char INT8; /* 16-bit values */ -using UINT16 = uint16_t; -using INT16 = int16_t; +typedef unsigned short UINT16; +typedef signed short INT16; /* 32-bit values */ -using UINT32 = uint32_t; -using INT32 = int32_t; +#ifndef _WINDOWS_H +typedef unsigned int UINT32; +typedef signed int INT32; +#endif /* 64-bit values */ -using UINT64 = uint64_t; -using INT64 = int64_t; +#ifndef _WINDOWS_H +#ifdef _MSC_VER +typedef signed __int64 INT64; +typedef unsigned __int64 UINT64; +#else +__extension__ typedef unsigned long long UINT64; +__extension__ typedef signed long long INT64; +#endif +#endif + +#endif /* pointer-sized values */ #ifdef PTR64 -using FPTR = uint64_t; +typedef UINT64 FPTR; #else -using FPTR = uint32_t; +typedef UINT32 FPTR; #endif @@ -134,7 +165,7 @@ using FPTR = uint32_t; /* MINGW has adopted the MSVC formatting for 64-bit ints as of gcc 4.4 */ -#if defined(__MINGW32__) || defined(_MSC_VER) +#if (defined(__MINGW32__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))) || defined(_MSC_VER) #define I64FMT "I64" #else #define I64FMT "ll" @@ -187,6 +218,11 @@ using FPTR = uint32_t; #define LITTLE_ENDIANIZE_INT64(x) (FLIPENDIAN_INT64(x)) #endif /* LSB_FIRST */ +// compatibility with non-clang compilers +#ifndef __has_feature + #define __has_feature(x) 0 +#endif + #ifdef _MSC_VER #include typedef ptrdiff_t ssize_t; -- cgit v1.2.3 From 52612a9fddb0921e5e26bc039f9b6d454952e6f8 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Wed, 9 Dec 2015 15:20:48 +0100 Subject: cleanup of osdcomm.h (nw) --- src/lib/util/corealloc.cpp | 4 ++++ src/osd/osdcomm.h | 59 ++++++++++++---------------------------------- 2 files changed, 19 insertions(+), 44 deletions(-) (limited to 'src/lib/util/corealloc.cpp') diff --git a/src/lib/util/corealloc.cpp b/src/lib/util/corealloc.cpp index 9ca7af380d3..38f21846f96 100644 --- a/src/lib/util/corealloc.cpp +++ b/src/lib/util/corealloc.cpp @@ -27,6 +27,10 @@ // define this to zap memory to a fixed non-0 value before freeing //#define OVERWRITE_FREED_MEMORY +// compatibility with non-clang compilers +#ifndef __has_feature + #define __has_feature(x) 0 +#endif //************************************************************************** diff --git a/src/osd/osdcomm.h b/src/osd/osdcomm.h index 9465be7477c..c4c5501f2e0 100644 --- a/src/osd/osdcomm.h +++ b/src/osd/osdcomm.h @@ -16,7 +16,7 @@ #include #include - +#include /*************************************************************************** COMPILER-SPECIFIC NASTINESS @@ -29,38 +29,23 @@ /* Some optimizations/warnings cleanups for GCC */ -#if defined(__GNUC__) && (__GNUC__ >= 3) +#if defined(__GNUC__) #define ATTR_UNUSED __attribute__((__unused__)) #define ATTR_NORETURN __attribute__((noreturn)) #define ATTR_PRINTF(x,y) __attribute__((format(printf, x, y))) -#define ATTR_MALLOC __attribute__((malloc)) -#define ATTR_PURE __attribute__((pure)) #define ATTR_CONST __attribute__((const)) #define ATTR_FORCE_INLINE __attribute__((always_inline)) #define ATTR_NONNULL(...) __attribute__((nonnull(__VA_ARGS__))) #define ATTR_DEPRECATED __attribute__((deprecated)) -/* not supported in GCC prior to 4.4.x */ -#if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4) #define ATTR_HOT __attribute__((hot)) #define ATTR_COLD __attribute__((cold)) -#else -#define ATTR_HOT -#define ATTR_COLD -#endif #define UNEXPECTED(exp) __builtin_expect(!!(exp), 0) #define EXPECTED(exp) __builtin_expect(!!(exp), 1) #define RESTRICT __restrict__ -#define SETJMP_GNUC_PROTECT() (void)__builtin_return_address(1) #else #define ATTR_UNUSED -#if defined(_MSC_VER) && (_MSC_VER >= 1200) #define ATTR_NORETURN __declspec(noreturn) -#else -#define ATTR_NORETURN -#endif #define ATTR_PRINTF(x,y) -#define ATTR_MALLOC -#define ATTR_PURE #define ATTR_CONST #define ATTR_FORCE_INLINE __forceinline #define ATTR_NONNULL(...) @@ -70,7 +55,6 @@ #define UNEXPECTED(exp) (exp) #define EXPECTED(exp) (exp) #define RESTRICT -#define SETJMP_GNUC_PROTECT() do {} while (0) #endif @@ -79,43 +63,35 @@ FUNDAMENTAL TYPES ***************************************************************************/ -/* These types work on most modern compilers; however, OSD code can - define their own by setting OSD_TYPES_DEFINED */ - -#ifndef OSD_TYPES_DEFINED /* 8-bit values */ -typedef unsigned char UINT8; -typedef signed char INT8; +using UINT8 = uint8_t; +using INT8 = int8_t; /* 16-bit values */ -typedef unsigned short UINT16; -typedef signed short INT16; +using UINT16 = uint16_t; +using INT16 = int16_t; /* 32-bit values */ -#ifndef _WINDOWS_H -typedef unsigned int UINT32; -typedef signed int INT32; -#endif +using UINT32 = uint32_t; +using INT32 = int32_t; /* 64-bit values */ #ifndef _WINDOWS_H #ifdef _MSC_VER -typedef signed __int64 INT64; -typedef unsigned __int64 UINT64; +using UINT64 = unsigned __int64; +using INT64 = signed __int64; #else -__extension__ typedef unsigned long long UINT64; -__extension__ typedef signed long long INT64; +using UINT64 = unsigned long long; +using INT64 = signed long long; #endif #endif -#endif - /* pointer-sized values */ #ifdef PTR64 -typedef UINT64 FPTR; +using FPTR = UINT64; #else -typedef UINT32 FPTR; +using FPTR = UINT32; #endif @@ -165,7 +141,7 @@ typedef UINT32 FPTR; /* MINGW has adopted the MSVC formatting for 64-bit ints as of gcc 4.4 */ -#if (defined(__MINGW32__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))) || defined(_MSC_VER) +#if defined(__MINGW32__) || defined(_MSC_VER) #define I64FMT "I64" #else #define I64FMT "ll" @@ -218,11 +194,6 @@ typedef UINT32 FPTR; #define LITTLE_ENDIANIZE_INT64(x) (FLIPENDIAN_INT64(x)) #endif /* LSB_FIRST */ -// compatibility with non-clang compilers -#ifndef __has_feature - #define __has_feature(x) 0 -#endif - #ifdef _MSC_VER #include typedef ptrdiff_t ssize_t; -- cgit v1.2.3