From bd4baa277fd921decbc87aab52eb0e0efa92f329 Mon Sep 17 00:00:00 2001 From: Carsten Larsen Date: Thu, 2 Feb 2017 22:56:33 +0100 Subject: [PATCH] Cleanup headers --- app/localize/start.h | 6 +- lib/clib.h | 7 +- lib/complex.h | 16 +---- lib/cplex/prim.h | 6 +- lib/math.h | 8 +-- lib/mem.h | 6 +- lib/platform.h | 152 +++++++++++++++++++++++-------------------- 7 files changed, 100 insertions(+), 101 deletions(-) diff --git a/app/localize/start.h b/app/localize/start.h index 840636a5..a2d373a2 100644 --- a/app/localize/start.h +++ b/app/localize/start.h @@ -51,7 +51,7 @@ # define TXTCPU "PowerPC" #endif /******************************************************************************/ -#if defined(__arm__) || defined(_M_ARM) +#if defined(__arm__) || defined(_M_ARM) || defined(__ARM_ARCH_6__) # define TXTCPU "arm" #endif #if defined(__aarch64__) || defined(_M_ARM64) @@ -91,8 +91,8 @@ #endif /******************************************************************************/ #ifndef TXTCPU -#error what cpu is this ?! -//#define TXTCPU EMPTYSTRING +//#error what cpu is this ?! +# define TXTCPU EMPTYSTRING #endif /******************************************************************************/ #if defined(TXTCPU) && defined(__HAVE_68881__) diff --git a/lib/clib.h b/lib/clib.h index 4691f8e1..b6a14c9d 100644 --- a/lib/clib.h +++ b/lib/clib.h @@ -24,8 +24,8 @@ * */ -#ifndef AMATH_CLIB_H -#define AMATH_CLIB_H +#ifndef AMATH_LIB_CLIB_H +#define AMATH_LIB_CLIB_H /** * @file clib.h @@ -56,5 +56,4 @@ void Untag(char *destination, const char *source, } #endif -#endif - +#endif /* AMATH_LIB_CLIB_H */ diff --git a/lib/complex.h b/lib/complex.h index 0df9f037..b479e77a 100644 --- a/lib/complex.h +++ b/lib/complex.h @@ -24,8 +24,8 @@ * */ -#ifndef LIBAMATH_COMPLEX_H -#define LIBAMATH_COMPLEX_H +#ifndef AMATH_LIB_COMPLEX_H +#define AMATH_LIB_COMPLEX_H /** * @file complex.h @@ -108,14 +108,4 @@ complex cacoth(complex z); } #endif -#endif - - - - - - - - - - +#endif /* AMATH_LIB_COMPLEX_H */ diff --git a/lib/cplex/prim.h b/lib/cplex/prim.h index 5eb91d19..251c8c00 100644 --- a/lib/cplex/prim.h +++ b/lib/cplex/prim.h @@ -24,8 +24,8 @@ * */ -#ifndef LIBAMATH_COMPLEX_PRIM_H -#define LIBAMATH_COMPLEX_PRIM_H +#ifndef AMATH_LIB_COMPLEX_PRIM_H +#define AMATH_LIB_COMPLEX_PRIM_H /** * @file prim.h @@ -52,4 +52,4 @@ double ctans(complex z); } #endif -#endif +#endif /* AMATH_LIB_COMPLEX_PRIM_H */ diff --git a/lib/math.h b/lib/math.h index 0adaabbc..20ecd0da 100644 --- a/lib/math.h +++ b/lib/math.h @@ -24,8 +24,8 @@ * */ -#ifndef LIBAMATH_REAL_H -#define LIBAMATH_REAL_H +#ifndef AMATH_LIB_MATH_H +#define AMATH_LIB_MATH_H /** * @file math.h @@ -45,7 +45,7 @@ #define PI 3.141592653589793238462643383279 #define EULERS 2.718281828459045235360287471352 #define sgn(x) (x > 0.0 ? 1.0 : x < 0.0 ? -1.0 : 0.0) -#define log2p(x,y) log(x)/log(y) +#define log2p(x,y) (log(x)/log(y)) #ifdef AMIGA # define abs(x) (x > 0 ? x : -x) @@ -96,4 +96,4 @@ int rempio2(double x, double *y); } #endif -#endif +#endif /* AMATH_LIB_MATH_H*/ diff --git a/lib/mem.h b/lib/mem.h index a17b2ee3..a141784e 100644 --- a/lib/mem.h +++ b/lib/mem.h @@ -24,8 +24,8 @@ * */ -#ifndef AMIGA_MEM_H -#define AMIGA_MEM_H +#ifndef AMATH_LIB_MEM_H +#define AMATH_LIB_MEM_H #include @@ -40,4 +40,4 @@ void MemUsage(long*,long*,long*); } #endif -#endif +#endif /* AMATH_LIB_MEM_H */ diff --git a/lib/platform.h b/lib/platform.h index a200a78d..c3de92d5 100644 --- a/lib/platform.h +++ b/lib/platform.h @@ -24,8 +24,8 @@ * */ -#ifndef AMATH_LIB_PLATFROM_H -#define AMATH_LIB_PLATFROM_H +#ifndef AMATH_LIB_PLATFORM_H +#define AMATH_LIB_PLATFORM_H #include #include "mem.h" @@ -76,14 +76,37 @@ typedef int bool; # endif #endif -// Check weather an AmigaOS compatible API is available +#ifdef __HAIKU__ +# ifndef HAIKU +# define HAIKU +# endif +#endif + #if defined(AOS3) || defined(AOS4) || defined(AROS) || defined (MORPHOS) # ifndef AMIGA -# define AMIGA +# define AMIGA # endif +#endif + +#if defined(unix) || defined(__unix__) || defined(__unix) +# ifndef UNIX +# define UNIX +# endif +#endif + +#if defined(AMIGA) || defined(HAIKU) || defined(UNIX) # ifndef ANSICONSOLE -# define ANSICONSOLE +# define ANSICONSOLE # endif +#endif + +#if defined(__STDC__) && !defined(AMIGA) +# ifndef STDLIBS +# define STDLIBS +# endif +#endif + +#ifdef AMIGA # include # include # include @@ -97,29 +120,37 @@ typedef int bool; # include #endif -// Check weather an POSIX compatible API is available -#if defined(unix) || defined(__unix__) || defined(__unix) -# ifndef UNIX -# define UNIX -# endif -# ifndef ANSICONSOLE -# define ANSICONSOLE -# endif +#ifdef STDLIBS +# include +# include +# include +#endif + +#ifdef HAIKU +# include +# include +#endif + +#ifdef UNIX # include # include # include #endif -#if !defined(AMIGA) && defined(__STDC__) +#ifdef _WIN32 # include # include -# include +#endif + +#ifdef AOS3 +# include #endif #ifdef AROS # include # include #endif + #ifdef MORPHOS # include # include @@ -129,64 +160,15 @@ typedef int bool; # error Includedes must be defined for Amiga OS 4+ #endif -/* GCC 2.95 */ -#if (__GNUC__ == 2 && __GNUC_MINOR__ == 95) -# include -typedef u_int8_t uint8_t; -typedef u_int16_t uint16_t; -typedef u_int32_t uint32_t; -typedef u_int64_t uint64_t; -# define IPTR LONG* -#ifdef __cplusplus -inline void* operator new (size_t size) { - return AllocMemSafe(size); -} - -inline void* operator new[] (size_t size) { - return AllocMemSafe(size); -} - -inline void operator delete (void* ptr) { - FreeMemSafe(ptr); -} - -inline void operator delete[] (void* ptr) { - FreeMemSafe(ptr); -} -#endif +#ifdef AOS3 +#define IPTR LONG* +typedef u_int8_t uint8_t; +typedef u_int16_t uint16_t; +typedef u_int32_t uint32_t; +typedef u_int64_t uint64_t; #endif -#ifdef _WIN32 -# include -# include -#endif - -#ifdef __cplusplus -#if (__GNUC__ > 2) || defined (_WIN32) -#include -inline void* operator new (size_t size) throw(std::bad_alloc) { - return AllocMemSafe(size); -} - -inline void* operator new[] (size_t size) throw(std::bad_alloc) { - return AllocMemSafe(size); -} - -inline void operator delete (void* ptr) throw() { - FreeMemSafe(ptr); -} - -inline void operator delete[] (void* ptr) throw() { - FreeMemSafe(ptr); -} -#endif -#endif - -/** - * @brief - * https://sourceforge.net/p/predef/wiki/Compilers/ - */ - +/* Compilers*/ #if defined(__clang__) /* Clang */ # if defined(__apple_build_version__) @@ -204,14 +186,17 @@ inline void operator delete[] (void* ptr) throw() { # define COMP_VERS CL_VER_STR(__clang_major__) DOT \ CL_VER_STR(__clang_minor__) # endif + /* Intel ICC/ICPC */ #elif defined(__ECC) || defined(__ICC) || defined(__INTEL_COMPILER) # define COMP_NAME "Intel ICC/ICPC" # define COMP_VERS __VERSION__ + /* IBM XL C/C++ */ #elif defined(__IBMC__) || defined(__IBMCPP__) # define COMP_NAME "IBM XL" # define COMP_VERS __xlc__ + /* Microsoft Visual Studio */ #elif defined(_MSC_VER) # define COMP_NAME "MSVC++" @@ -242,6 +227,7 @@ inline void operator delete[] (void* ptr) throw() { # define MSC_VER_STR(x) str(x) # define COMP_VERS MSC_VER_STR(_MSC_VER) # endif + /* Portland Group PGCC/PGCPP */ #elif defined(__PGI) # define COMP_NAME "PGCC/PGCPP" @@ -255,6 +241,7 @@ inline void operator delete[] (void* ptr) throw() { # define COMP_VERS PGCC_VER_STR(__PGIC__) DOT \ PGCC_VER_STR(__PGIC_MINOR) # endif + /* GNU GCC/G++ */ #elif defined(__GNUC__) || defined(__GNUG__) # define COMP_NAME "GCC" @@ -268,6 +255,7 @@ inline void operator delete[] (void* ptr) throw() { # endif #endif +/* ANSI escape codes */ #if defined(ANSICONSOLE) #define HEADLINE "\x1B[1m" #ifdef UNIX @@ -306,6 +294,28 @@ inline void operator delete[] (void* ptr) throw() { #define DELETE1CHAR EMPTYSTRING #define DELETELINE EMPTYSTRING #define CLEARWINDOW EMPTYSTRING +#endif /* ANSICONSOLE */ + +/* Memory allocation */ +#ifdef __cplusplus + +/* GCC 2.95 */ +#if (__GNUC__ == 2 && __GNUC_MINOR__ == 95) +inline void* operator new (size_t size) { return AllocMemSafe(size); } +inline void* operator new[] (size_t size) { return AllocMemSafe(size); } +inline void operator delete (void* ptr) { FreeMemSafe(ptr); } +inline void operator delete[] (void* ptr) { FreeMemSafe(ptr); } #endif +/* GCC 3+ and Windows */ +#if (__GNUC__ > 2) || defined (_WIN32) +#include +inline void* operator new (size_t size) throw(std::bad_alloc) { return AllocMemSafe(size); } +inline void* operator new[] (size_t size) throw(std::bad_alloc) { return AllocMemSafe(size); } +inline void operator delete (void* ptr) throw() { FreeMemSafe(ptr); } +inline void operator delete[] (void* ptr) throw() { FreeMemSafe(ptr); } #endif + +#endif /* __cplusplus */ + +#endif /* AMATH_LIB_PLATFORM_H */