platform.h

Go to the documentation of this file.
00001 /*
00002  * opencog/util/platform.h
00003  *
00004  * Copyright (C) 2002-2007 Novamente LLC
00005  * All Rights Reserved
00006  *
00007  * Written by Moshe Looks <moshe@metacog.org>
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU Affero General Public License v3 as
00011  * published by the Free Software Foundation and including the exceptions
00012  * at http://opencog.org/wiki/Licenses
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU Affero General Public License
00020  * along with this program; if not, write to:
00021  * Free Software Foundation, Inc.,
00022  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
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 //#include <assert.h>
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 } // namespace opencog
00104 
00105 #endif // _OPENCOG_PLATFORM_H

Generated on Fri Dec 4 23:23:31 2009 for OpenCog Framework by  doxygen 1.5.6