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
00026
00027 #ifndef BZ_BLITZ_H
00028 #define BZ_BLITZ_H
00029
00030
00031
00032
00033
00034
00035 #ifdef BZ_ENABLE_XOPEN_SOURCE
00036 #ifndef _ALL_SOURCE
00037 #define _ALL_SOURCE
00038 #endif
00039 #ifndef _XOPEN_SOURCE
00040 #define _XOPEN_SOURCE
00041 #endif
00042 #ifndef _XOPEN_SOURCE_EXTENDED
00043 #define _XOPEN_SOURCE_EXTENDED 1
00044 #endif
00045 #endif
00046
00047 #include <blitz/compiler.h>
00048 #include <blitz/tuning.h>
00049 #include <blitz/tau.h>
00050
00051 #ifdef BZ_HAVE_STL
00052 #include <string>
00053 #endif
00054
00055 #ifdef BZ_HAVE_STD
00056 #include <iostream>
00057 #include <iomanip>
00058 #include <cstdio>
00059 #include <cmath>
00060 #else
00061 #include <iostream.h>
00062 #include <iomanip.h>
00063 #include <stdio.h>
00064 #include <math.h>
00065 #endif
00066
00067 #ifdef BZ_HAVE_COMPLEX
00068 #include <complex>
00069 #endif
00070
00071 #define BZ_THROW // Needed in <blitz/numinquire.h>
00072
00073 BZ_NAMESPACE(blitz)
00074
00075 #ifdef BZ_HAVE_STD
00076 BZ_USING_NAMESPACE(std)
00077 #endif
00078
00079 #ifdef BZ_GENERATE_GLOBAL_INSTANCES
00080 #define _bz_global
00081 #define BZ_GLOBAL_INIT(X) =X
00082 #else
00083 #define _bz_global extern
00084 #define BZ_GLOBAL_INIT(X)
00085 #endif
00086
00087 BZ_NAMESPACE_END
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101 #ifdef BZ_THREADSAFE
00102 #if defined(_REENTRANT)
00103 #define BZ_THREADSAFE_USE_PTHREADS
00104 #elif defined (_OPENMP)
00105 #define BZ_THREADSAFE_USE_OPENMP
00106 #elif defined(_WIN32)
00107 #define BZ_THREADSAFE_USE_WINDOWS
00108 #endif
00109 #endif
00110
00111 #ifdef BZ_THREADSAFE_USE_PTHREADS
00112 #include <pthread.h>
00113
00114 #define BZ_MUTEX_DECLARE(name) mutable pthread_mutex_t name;
00115 #define BZ_MUTEX_INIT(name) pthread_mutex_init(&name,NULL);
00116 #define BZ_MUTEX_LOCK(name) pthread_mutex_lock(&name);
00117 #define BZ_MUTEX_UNLOCK(name) pthread_mutex_unlock(&name);
00118 #define BZ_MUTEX_DESTROY(name) pthread_mutex_destroy(&name);
00119 #elif defined (BZ_THREADSAFE_USE_WINDOWS)
00120
00121
00122 #define NOMINMAX
00123 #include <Windows.h>
00124
00125 #define BZ_MUTEX_DECLARE(name) mutable CRITICAL_SECTION name;
00126 #define BZ_MUTEX_INIT(name) ::InitializeCriticalSection(&name);
00127 #define BZ_MUTEX_LOCK(name) ::EnterCriticalSection(&name);
00128 #define BZ_MUTEX_UNLOCK(name) ::LeaveCriticalSection(&name);
00129 #define BZ_MUTEX_DESTROY(name) ::DeleteCriticalSection(&name);
00130 #elif defined (BZ_THREADSAFE_USE_OPENMP)
00131 #include <omp.h>
00132
00133 #define BZ_MUTEX_DECLARE(name) mutable omp_lock_t name;
00134 #define BZ_MUTEX_INIT(name) omp_init_lock(&name);
00135 #define BZ_MUTEX_LOCK(name) omp_set_lock(&name);
00136 #define BZ_MUTEX_UNLOCK(name) omp_unset_lock(&name);
00137 #define BZ_MUTEX_DESTROY(name) omp_destroy_lock(&name);
00138 #else
00139 #define BZ_MUTEX_DECLARE(name)
00140 #define BZ_MUTEX_INIT(name)
00141 #define BZ_MUTEX_LOCK(name)
00142 #define BZ_MUTEX_UNLOCK(name)
00143 #define BZ_MUTEX_DESTROY(name)
00144 #endif
00145
00146 #include <blitz/bzdebug.h>
00147
00148 #endif // BZ_BLITZ_H