Fix pre-commit bug regarding astyle detection. If not installed, all commited files...
[anna.git] / include / anna / config / defines.hpp
index e69de29..4bae089 100644 (file)
@@ -0,0 +1,121 @@
+// ANNA - Anna is Not Nothingness Anymore                                                         //
+//                                                                                                //
+// (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
+//                                                                                                //
+// See project site at http://redmine.teslayout.com/projects/anna-suite                           //
+// See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
+
+
+#ifndef anna_config_defines_hpp
+#define anna_config_defines_hpp
+
+//#include <sys/types.h>
+#include <stdint.h>
+// For cstd0x compatibility we will use stdint.h types instead of std:: ones on cstdint:
+//#include <cstdint>  when C++11 available
+
+#include <anna/core/tracing/Logger.hpp>
+
+
+#ifdef ANNA_FILE_LOCATION
+#undef ANNA_FILE_LOCATION
+#endif
+#define ANNA_FILE_LOCATION (const char *)__FILE__,(const int)__LINE__
+//#define ANNA_FILE_LOCATION __PRETTY_FUNCTION__,(const char *)__FILE__,(const int)__LINE__
+
+
+#define ANNA_VERSION 0x000d03
+
+#if defined(__linux__) && !defined (_NO_BUILTIN)
+#define anna_memcpy(a,b,c) __builtin_memcpy((a),(b),(c))
+#define anna_memset(a,b,c) __builtin_memset((a),(b),(c))
+#define anna_memmove(a,b,c) __builtin_memmove((a),(b),(c))
+#define anna_strcpy(a,b) __builtin_strcpy((a),(b))
+#define anna_strncpy(a,b,c) __builtin_strncpy((a),(b),(c))
+#define anna_strcmp(a,b) __builtin_strcmp((a),(b))
+#define anna_strncmp(a,b,n) __builtin_strncmp((a),(b),(n))
+#define anna_strcat(a,b) __builtin_strcat((a),(b))
+#define anna_strlen(a) __builtin_strlen((a))
+#define anna_strstr(a,b) __builtin_strstr((a),(b))
+#define anna_strchr(a,b) __builtin_strchr((a),(b))
+#else
+#define anna_memcpy(a,b,c) memcpy((a),(b),(c))
+#define anna_memset(a,b,c) memset((a),(b),(c))
+#define anna_memmove(a,b,c) memmove((a),(b),(c))
+#define anna_strcpy(a,b) strcpy((a),(b))
+#define anna_strncpy(a,b,c) strncpy((a),(b),(c))
+#define anna_strcmp(a,b) strcmp((a),(b))
+#define anna_strncmp(a,b,n) strncmp((a),(b),(n))
+#define anna_strcat(a,b) strcat((a),(b))
+#define anna_strlen(a) strlen((a))
+#define anna_strstr(a,b) strstr((a),(b))
+#define anna_strchr(a,b) strchr((a),(b))
+#endif
+
+#define anna_signal_shield(r,a) { int cx (0); do { if ((r = (a)) < 0) cx ++; } while (r < 0 && errno == EINTR && cx < 5); }
+
+//#define anna_append_string(str,str1,str2) (str).append (str1).append (str2)
+
+#ifndef _NOTRACE
+#define LOGWARNING(a) if (anna::Logger::isActive (anna::Logger::Warning) == true) {a;}
+#define LOGNOTICE(a) if (anna::Logger::isActive (anna::Logger::Notice) == true) {a;}
+#define LOGINFORMATION(a) if (anna::Logger::isActive (anna::Logger::Information) == true) {a;}
+#define LOG_EXCL_INFORMATION(a) if (anna::Logger::isActive (anna::Logger::Debug) == false && anna::Logger::isActive (anna::Logger::Information) == true) {a;}
+#define LOGDEBUG(a) if (anna::Logger::isActive (anna::Logger::Debug) == true) {a;}
+#define LOGLOCAL0(a) if (anna::Logger::isActive (anna::Logger::Local0) == true) {a;}
+#define LOGLOCAL1(a) if (anna::Logger::isActive (anna::Logger::Local1) == true) {a;}
+#define LOGLOCAL2(a) if (anna::Logger::isActive (anna::Logger::Local2) == true) {a;}
+#define LOGLOCAL3(a) if (anna::Logger::isActive (anna::Logger::Local3) == true) {a;}
+#define LOGLOCAL4(a) if (anna::Logger::isActive (anna::Logger::Local4) == true) {a;}
+#define LOGLOCAL5(a) if (anna::Logger::isActive (anna::Logger::Local5) == true) {a;}
+#define LOGLOCAL6(a) if (anna::Logger::isActive (anna::Logger::Local6) == true) {a;}
+#define LOGLOCAL7(a) if (anna::Logger::isActive (anna::Logger::Local7) == true) {a;}
+#define LOGMETHOD(a) a;
+#define LOGFUNCTION(a) a;
+#else
+#define LOGWARNING(a)
+#define LOGNOTICE(a)
+#define LOGINFORMATION(a)
+#define LOGDEBUG(a)
+#define LOGLOCAL0(a)
+#define LOGLOCAL1(a)
+#define LOGLOCAL2(a)
+#define LOGLOCAL3(a)
+#define LOGLOCAL4(a)
+#define LOGLOCAL5(a)
+#define LOGLOCAL6(a)
+#define LOGLOCAL7(a)
+#define LOGMETHOD(a)
+#define LOGFUNCTION(a)
+#endif
+
+#ifdef _MT
+#define WHEN_MULTITHREAD(a) a
+#define WHEN_SINGLETHREAD(a)
+#else
+#define WHEN_MULTITHREAD(a)
+#define WHEN_SINGLETHREAD(a) a
+#endif
+
+namespace anna {
+#ifndef __x86_64__
+#undef  __anna64__
+///** Defines required data type to conversion from pointer to integer */
+//typedef int ptrnumber;
+#else
+#define __anna64__
+///** Defines required data type to conversion from pointer to integer */
+//typedef long ptrnumber;
+#endif
+
+typedef intptr_t ptrnumber;
+
+}
+
+/**
+ * Make conversion from pointer to integer, it will work both 64 bits and 32 bits architecture.
+ */
+#define anna_ptrnumber_cast(pointer) (anna::ptrnumber)((void*)(pointer))
+
+#endif
+