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