Fix pre-commit bug regarding astyle detection. If not installed, all commited files...
[anna.git] / include / anna / config / defines.hpp
1 // ANNA - Anna is Not Nothingness Anymore                                                         //
2 //                                                                                                //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
4 //                                                                                                //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite                           //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
7
8
9 #ifndef anna_config_defines_hpp
10 #define anna_config_defines_hpp
11
12 //#include <sys/types.h>
13 #include <stdint.h>
14 // For cstd0x compatibility we will use stdint.h types instead of std:: ones on cstdint:
15 //#include <cstdint>  when C++11 available
16
17 #include <anna/core/tracing/Logger.hpp>
18
19
20 #ifdef ANNA_FILE_LOCATION
21 #undef ANNA_FILE_LOCATION
22 #endif
23 #define ANNA_FILE_LOCATION (const char *)__FILE__,(const int)__LINE__
24 //#define ANNA_FILE_LOCATION __PRETTY_FUNCTION__,(const char *)__FILE__,(const int)__LINE__
25
26
27 #define ANNA_VERSION 0x000d03
28
29 #if defined(__linux__) && !defined (_NO_BUILTIN)
30 #define anna_memcpy(a,b,c) __builtin_memcpy((a),(b),(c))
31 #define anna_memset(a,b,c) __builtin_memset((a),(b),(c))
32 #define anna_memmove(a,b,c) __builtin_memmove((a),(b),(c))
33 #define anna_strcpy(a,b) __builtin_strcpy((a),(b))
34 #define anna_strncpy(a,b,c) __builtin_strncpy((a),(b),(c))
35 #define anna_strcmp(a,b) __builtin_strcmp((a),(b))
36 #define anna_strncmp(a,b,n) __builtin_strncmp((a),(b),(n))
37 #define anna_strcat(a,b) __builtin_strcat((a),(b))
38 #define anna_strlen(a) __builtin_strlen((a))
39 #define anna_strstr(a,b) __builtin_strstr((a),(b))
40 #define anna_strchr(a,b) __builtin_strchr((a),(b))
41 #else
42 #define anna_memcpy(a,b,c) memcpy((a),(b),(c))
43 #define anna_memset(a,b,c) memset((a),(b),(c))
44 #define anna_memmove(a,b,c) memmove((a),(b),(c))
45 #define anna_strcpy(a,b) strcpy((a),(b))
46 #define anna_strncpy(a,b,c) strncpy((a),(b),(c))
47 #define anna_strcmp(a,b) strcmp((a),(b))
48 #define anna_strncmp(a,b,n) strncmp((a),(b),(n))
49 #define anna_strcat(a,b) strcat((a),(b))
50 #define anna_strlen(a) strlen((a))
51 #define anna_strstr(a,b) strstr((a),(b))
52 #define anna_strchr(a,b) strchr((a),(b))
53 #endif
54
55 #define anna_signal_shield(r,a) { int cx (0); do { if ((r = (a)) < 0) cx ++; } while (r < 0 && errno == EINTR && cx < 5); }
56
57 //#define anna_append_string(str,str1,str2) (str).append (str1).append (str2)
58
59 #ifndef _NOTRACE
60 #define LOGWARNING(a) if (anna::Logger::isActive (anna::Logger::Warning) == true) {a;}
61 #define LOGNOTICE(a) if (anna::Logger::isActive (anna::Logger::Notice) == true) {a;}
62 #define LOGINFORMATION(a) if (anna::Logger::isActive (anna::Logger::Information) == true) {a;}
63 #define LOG_EXCL_INFORMATION(a) if (anna::Logger::isActive (anna::Logger::Debug) == false && anna::Logger::isActive (anna::Logger::Information) == true) {a;}
64 #define LOGDEBUG(a) if (anna::Logger::isActive (anna::Logger::Debug) == true) {a;}
65 #define LOGLOCAL0(a) if (anna::Logger::isActive (anna::Logger::Local0) == true) {a;}
66 #define LOGLOCAL1(a) if (anna::Logger::isActive (anna::Logger::Local1) == true) {a;}
67 #define LOGLOCAL2(a) if (anna::Logger::isActive (anna::Logger::Local2) == true) {a;}
68 #define LOGLOCAL3(a) if (anna::Logger::isActive (anna::Logger::Local3) == true) {a;}
69 #define LOGLOCAL4(a) if (anna::Logger::isActive (anna::Logger::Local4) == true) {a;}
70 #define LOGLOCAL5(a) if (anna::Logger::isActive (anna::Logger::Local5) == true) {a;}
71 #define LOGLOCAL6(a) if (anna::Logger::isActive (anna::Logger::Local6) == true) {a;}
72 #define LOGLOCAL7(a) if (anna::Logger::isActive (anna::Logger::Local7) == true) {a;}
73 #define LOGMETHOD(a) a;
74 #define LOGFUNCTION(a) a;
75 #else
76 #define LOGWARNING(a)
77 #define LOGNOTICE(a)
78 #define LOGINFORMATION(a)
79 #define LOGDEBUG(a)
80 #define LOGLOCAL0(a)
81 #define LOGLOCAL1(a)
82 #define LOGLOCAL2(a)
83 #define LOGLOCAL3(a)
84 #define LOGLOCAL4(a)
85 #define LOGLOCAL5(a)
86 #define LOGLOCAL6(a)
87 #define LOGLOCAL7(a)
88 #define LOGMETHOD(a)
89 #define LOGFUNCTION(a)
90 #endif
91
92 #ifdef _MT
93 #define WHEN_MULTITHREAD(a) a
94 #define WHEN_SINGLETHREAD(a)
95 #else
96 #define WHEN_MULTITHREAD(a)
97 #define WHEN_SINGLETHREAD(a) a
98 #endif
99
100 namespace anna {
101 #ifndef __x86_64__
102 #undef  __anna64__
103 ///** Defines required data type to conversion from pointer to integer */
104 //typedef int ptrnumber;
105 #else
106 #define __anna64__
107 ///** Defines required data type to conversion from pointer to integer */
108 //typedef long ptrnumber;
109 #endif
110
111 typedef intptr_t ptrnumber;
112
113 }
114
115 /**
116  * Make conversion from pointer to integer, it will work both 64 bits and 32 bits architecture.
117  */
118 #define anna_ptrnumber_cast(pointer) (anna::ptrnumber)((void*)(pointer))
119
120 #endif
121