itom 1.3.0
D:/git-itom/sources/itom/common/commonGlobal.h
00001 /* ********************************************************************
00002     itom software
00003     URL: http://www.uni-stuttgart.de/ito
00004     Copyright (C) 2013, Institut für Technische Optik (ITO),
00005     Universität Stuttgart, Germany
00006 
00007     This file is part of itom and its software development toolkit (SDK).
00008 
00009     itom is free software; you can redistribute it and/or modify it
00010     under the terms of the GNU Library General Public Licence as published by
00011     the Free Software Foundation; either version 2 of the Licence, or (at
00012     your option) any later version.
00013    
00014     In addition, as a special exception, the Institut für Technische
00015     Optik (ITO) gives you certain additional rights.
00016     These rights are described in the ITO LGPL Exception version 1.0,
00017     which can be found in the file LGPL_EXCEPTION.txt in this package.
00018 
00019     itom is distributed in the hope that it will be useful, but
00020     WITHOUT ANY WARRANTY; without even the implied warranty of
00021     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library
00022     General Public Licence for more details.
00023 
00024     You should have received a copy of the GNU Library General Public License
00025     along with itom. If not, see <http://www.gnu.org/licenses/>.
00026 *********************************************************************** */
00027 
00028 #ifndef COMMONGLOBAL_H
00029 #define COMMONGLOBAL_H
00030 
00031 #if (defined ITOMLIBS_SHARED && ( defined(_Windows) || defined(_WINDOWS) || defined(WIN32) || defined(_WIN32) || defined(__WIN32__) )) 
00032     
00033     #ifndef ITOMCOMMON_EXPORT
00034         
00035         /* Borland/Microsoft */
00036         #if defined(_MSC_VER) || defined(__BORLANDC__)
00037             #if (_MSC_VER >= 800) || (__BORLANDC__ >= 0x500)
00038             #else
00039                 #ifdef ITOMCOMMON_DLL
00040                     #define ITOMCOMMON_EXPORT __export
00041                 #else
00042                     #define ITOMCOMMON_EXPORT /*__import */ /* doesn't exist AFAIK in VC++ */
00043                 #endif                              /* Exists in Borland C++ for
00044                                                                 C++ classes (== huge) */
00045             #endif
00046         #endif
00047 
00048         #ifndef ITOMCOMMON_EXPORT //ITOMCOMMON_EXPORT has not be defined yet
00049             #ifdef ITOMCOMMON_DLL
00050                 #define ITOMCOMMON_EXPORT __declspec(dllexport)
00051             #else
00052                 #define ITOMCOMMON_EXPORT __declspec(dllimport)
00053             #endif
00054         #endif
00055         
00056     #endif //ITOMCOMMON_EXPORT
00057     
00058 #endif //windows
00059 
00060 #ifndef ITOMCOMMON_EXPORT
00061     #define ITOMCOMMON_EXPORT
00062 #endif
00063 
00064 
00065 #if (defined ITOMLIBS_SHARED && ( defined(_Windows) || defined(_WINDOWS) || defined(WIN32) || defined(_WIN32) || defined(__WIN32__) )) 
00066     
00067     #ifndef ITOMCOMMONQT_EXPORT
00068         
00069         /* Borland/Microsoft */
00070         #if defined(_MSC_VER) || defined(__BORLANDC__)
00071             #if (_MSC_VER >= 800) || (__BORLANDC__ >= 0x500)
00072             #else
00073                 #ifdef ITOMCOMMONQT_DLL
00074                     #define ITOMCOMMONQT_EXPORT __export
00075                 #else
00076                     #define ITOMCOMMONQT_EXPORT /*__import */ /* doesn't exist AFAIK in VC++ */
00077                 #endif                              /* Exists in Borland C++ for
00078                                                                 C++ classes (== huge) */
00079             #endif
00080         #endif
00081 
00082         #ifndef ITOMCOMMONQT_EXPORT //ITOMCOMMONQT_EXPORT has not be defined yet
00083             #ifdef ITOMCOMMONQT_DLL
00084                 #define ITOMCOMMONQT_EXPORT __declspec(dllexport)
00085             #else
00086                 #define ITOMCOMMONQT_EXPORT __declspec(dllimport)
00087             #endif
00088         #endif
00089         
00090     #endif //ITOMCOMMONQT_EXPORT
00091     
00092 #endif //windows
00093 
00094 #ifndef ITOMCOMMONQT_EXPORT
00095     #define ITOMCOMMONQT_EXPORT
00096 #endif
00097 
00098 
00100     #ifdef __GNUC__
00101     
00102       #if __GNUC__*10 + __GNUC_MINOR__ >= 42
00103 
00104         #if !defined WIN32 && (defined __i486__ || defined __i586__ || \
00105             defined __i686__ || defined __MMX__ || defined __SSE__  || defined __ppc__)
00106           #define ITOM_XADD __sync_fetch_and_add
00107         #else
00108           #include <ext/atomicity.h>
00109           #define ITOM_XADD __gnu_cxx::__exchange_and_add
00110         #endif
00111 
00112       #else
00113         #include <bits/atomicity.h>
00114         #if __GNUC__*10 + __GNUC_MINOR__ >= 34
00115           #define ITOM_XADD __gnu_cxx::__exchange_and_add
00116         #else
00117           #define ITOM_XADD __exchange_and_add
00118         #endif
00119       #endif
00120     
00121     #elif (defined WIN32 || defined _WIN32)
00122       #include <intrin.h>
00123       #define ITOM_XADD(addr,delta) _InterlockedExchangeAdd((long volatile*)(addr), (delta))
00124     #else
00125       template<typename _Tp> static inline _Tp ITOM_XADD(_Tp* addr, _Tp delta)
00126       { int tmp = *addr; *addr += delta; return tmp; } 
00127     #endif
00128 
00129     #define ITOM_INCREF(intvar) ITOM_XADD(intvar,1)
00130     #define ITOM_DECREF(intvar) ITOM_XADD(intvar,-1)
00131 
00132 #endif
00133 
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends