Changed LICENSE. Now referenced to web site and file on project root directory
[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
14 #ifdef ANNA_FILE_LOCATION
15 #undef ANNA_FILE_LOCATION
16 #endif
17 #define ANNA_FILE_LOCATION (const char *)__FILE__,(const int)__LINE__
18 //#define ANNA_FILE_LOCATION __PRETTY_FUNCTION__,(const char *)__FILE__,(const int)__LINE__
19
20
21 #define ANNA_VERSION 0x000d03
22
23 #if defined(__linux__) && !defined (_NO_BUILTIN)
24 #define anna_memcpy(a,b,c) __builtin_memcpy((a),(b),(c))
25 #define anna_memset(a,b,c) __builtin_memset((a),(b),(c))
26 #define anna_memmove(a,b,c) __builtin_memmove((a),(b),(c))
27 #define anna_strcpy(a,b) __builtin_strcpy((a),(b))
28 #define anna_strncpy(a,b,c) __builtin_strncpy((a),(b),(c))
29 #define anna_strcmp(a,b) __builtin_strcmp((a),(b))
30 #define anna_strncmp(a,b,n) __builtin_strncmp((a),(b),(n))
31 #define anna_strcat(a,b) __builtin_strcat((a),(b))
32 #define anna_strlen(a) __builtin_strlen((a))
33 #define anna_strstr(a,b) __builtin_strstr((a),(b))
34 #define anna_strchr(a,b) __builtin_strchr((a),(b))
35 #else
36 #define anna_memcpy(a,b,c) memcpy((a),(b),(c))
37 #define anna_memset(a,b,c) memset((a),(b),(c))
38 #define anna_memmove(a,b,c) memmove((a),(b),(c))
39 #define anna_strcpy(a,b) strcpy((a),(b))
40 #define anna_strncpy(a,b,c) strncpy((a),(b),(c))
41 #define anna_strcmp(a,b) strcmp((a),(b))
42 #define anna_strncmp(a,b,n) strncmp((a),(b),(n))
43 #define anna_strcat(a,b) strcat((a),(b))
44 #define anna_strlen(a) strlen((a))
45 #define anna_strstr(a,b) strstr((a),(b))
46 #define anna_strchr(a,b) strchr((a),(b))
47 #endif
48
49 #define anna_signal_shield(r,a) { int cx (0); do { if ((r = (a)) < 0) cx ++; } while (r < 0 && errno == EINTR && cx < 5); }
50
51 //#define anna_append_string(str,str1,str2) (str).append (str1).append (str2)
52
53 #ifndef _NOTRACE
54 #define LOGWARNING(a) if (anna::Logger::isActive (anna::Logger::Warning) == true) {a;}
55 #define LOGNOTICE(a) if (anna::Logger::isActive (anna::Logger::Notice) == true) {a;}
56 #define LOGINFORMATION(a) if (anna::Logger::isActive (anna::Logger::Information) == true) {a;}
57 #define LOG_EXCL_INFORMATION(a) if (anna::Logger::isActive (anna::Logger::Debug) == false && anna::Logger::isActive (anna::Logger::Information) == true) {a;}
58 #define LOGDEBUG(a) if (anna::Logger::isActive (anna::Logger::Debug) == true) {a;}
59 #define LOGLOCAL0(a) if (anna::Logger::isActive (anna::Logger::Local0) == true) {a;}
60 #define LOGLOCAL1(a) if (anna::Logger::isActive (anna::Logger::Local1) == true) {a;}
61 #define LOGLOCAL2(a) if (anna::Logger::isActive (anna::Logger::Local2) == true) {a;}
62 #define LOGLOCAL3(a) if (anna::Logger::isActive (anna::Logger::Local3) == true) {a;}
63 #define LOGLOCAL4(a) if (anna::Logger::isActive (anna::Logger::Local4) == true) {a;}
64 #define LOGLOCAL5(a) if (anna::Logger::isActive (anna::Logger::Local5) == true) {a;}
65 #define LOGLOCAL6(a) if (anna::Logger::isActive (anna::Logger::Local6) == true) {a;}
66 #define LOGLOCAL7(a) if (anna::Logger::isActive (anna::Logger::Local7) == true) {a;}
67 #define LOGMETHOD(a) a;
68 #define LOGFUNCTION(a) a;
69 #else
70 #define LOGWARNING(a)
71 #define LOGNOTICE(a)
72 #define LOGINFORMATION(a)
73 #define LOGDEBUG(a)
74 #define LOGLOCAL0(a)
75 #define LOGLOCAL1(a)
76 #define LOGLOCAL2(a)
77 #define LOGLOCAL3(a)
78 #define LOGLOCAL4(a)
79 #define LOGLOCAL5(a)
80 #define LOGLOCAL6(a)
81 #define LOGLOCAL7(a)
82 #define LOGMETHOD(a)
83 #define LOGFUNCTION(a)
84 #endif
85
86 #ifdef _MT
87 #define WHEN_MULTITHREAD(a) a
88 #define WHEN_SINGLETHREAD(a)
89 #else
90 #define WHEN_MULTITHREAD(a)
91 #define WHEN_SINGLETHREAD(a) a
92 #endif
93
94 namespace anna {
95 #ifndef __x86_64__
96 #undef  __anna64__
97 /** Defines required data type to conversion from pointer to integer */
98 typedef int ptrnumber;
99 #else
100 #define __anna64__
101 /** Defines required data type to conversion from pointer to integer */
102 typedef long ptrnumber;
103 #endif
104 }
105
106 /**
107  * Make conversion from pointer to integer, it will work both 64 bits and 32 bits architecture.
108  */
109 #define anna_ptrnumber_cast(pointer) (anna::ptrnumber)((void*)(pointer))
110
111 #endif
112