platform.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _OPENCOG_PLATFORM_H
00026 #define _OPENCOG_PLATFORM_H
00027
00028 #ifdef WIN32
00029
00030 #pragma warning(disable:4290)
00031 #include <unordered_set>
00032 #include <unordered_map>
00033 #include <functional>
00034 #include <algorithm>
00035
00036 #define strcasecmp _stricmp
00037 #define snprintf _snprintf
00038
00039 #else // WIN32
00040
00041 #include <tr1/unordered_set>
00042 #include <tr1/unordered_map>
00043 #include <tr1/functional>
00044
00045 #endif // WIN32
00046
00047 #include <stdio.h>
00048 #include <string.h>
00049
00050 #include <string>
00051
00052 namespace opencog
00053 {
00054
00055 struct eqstr {
00056 bool operator()(char *s1, char *s2) const {
00057 return strcmp(s1, s2) == 0;
00058 }
00059 };
00060
00061 struct eqconststr {
00062 bool operator()(const char *s1, const char *s2) const {
00063 return strcmp(s1, s2) == 0;
00064 }
00065 };
00066
00067 struct eqint {
00068 bool operator()(int s1, int s2) const {
00069 return s1 == s2;
00070 }
00071 };
00072
00073 #ifdef __APPLE__
00074 char* __strtok_r(char *s1, const char *s2, char **lasts);
00075 #endif
00076
00077 #ifdef WIN32
00078
00079 #define M_PI 3.14159265358979323846
00080
00081 struct timezone {};
00082
00083 int round(float x);
00084 char* __strtok_r(char *s1, const char *s2, char **lasts);
00085 int gettimeofday(struct timeval* tp, void* tzp);
00086 void usleep(unsigned int useconds);
00087 int __getpid(void);
00088 double rint(double nr);
00089 int __dup2(int, int);
00090 unsigned long long atoll(const char *str);
00091 unsigned int sleep(unsigned seconds);
00092
00093 using std::hash;
00094
00095 #else // !WIN32
00096
00097 using std::tr1::hash;
00098
00099 #endif // WIN32!
00100
00101 size_t getMemUsage();
00102
00103 }
00104
00105 #endif // _OPENCOG_PLATFORM_H