00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef CORE_PORTME_H
00011 #define CORE_PORTME_H
00012
00013
00014
00015
00016
00017
00018 #ifndef HAS_FLOAT
00019 #define HAS_FLOAT 1
00020 #endif
00021
00022
00023
00024
00025 #ifndef HAS_TIME_H
00026 #define HAS_TIME_H 1
00027 #endif
00028
00029
00030
00031
00032 #ifndef USE_CLOCK
00033 #define USE_CLOCK 0
00034 #endif
00035
00036
00037
00038 #ifndef HAS_STDIO
00039 #define HAS_STDIO 1
00040 #endif
00041
00042
00043
00044 #ifndef HAS_PRINTF
00045 #define HAS_PRINTF 1
00046 #endif
00047
00048
00049
00050
00051 #if defined(_MSC_VER)
00052 #include <windows.h>
00053 typedef size_t CORE_TICKS;
00054 #elif HAS_TIME_H
00055 #include <time.h>
00056 typedef clock_t CORE_TICKS;
00057 #else
00058 #error "Please define type of CORE_TICKS and implement start_time, end_time get_time and time_in_secs functions!"
00059 #endif
00060
00061
00062
00063
00064 #ifndef COMPILER_VERSION
00065 #ifdef __GNUC__
00066 #define COMPILER_VERSION "GCC"__VERSION__
00067 #else
00068 #define COMPILER_VERSION "Please put compiler version here (e.g. gcc 4.1)"
00069 #endif
00070 #endif
00071 #ifndef COMPILER_FLAGS
00072 #define COMPILER_FLAGS FLAGS_STR
00073 #endif
00074 #ifndef MEM_LOCATION
00075 #define MEM_LOCATION "Please put data memory location here\n\t\t\t(e.g. code in flash, data on heap etc)"
00076 #define MEM_LOCATION_UNSPEC 1
00077 #endif
00078
00079
00080
00081
00082
00083
00084
00085 typedef signed short ee_s16;
00086 typedef unsigned short ee_u16;
00087 typedef signed int ee_s32;
00088 typedef double ee_f32;
00089 typedef unsigned char ee_u8;
00090 typedef unsigned int ee_u32;
00091 typedef unsigned long long ee_ptr_int;
00092
00093 #define align_mem(x) (void *)(4 + (((ee_ptr_int)(x) - 1) & ~3))
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103 #ifndef SEED_METHOD
00104 #define SEED_METHOD SEED_ARG
00105 #endif
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115 #ifndef MEM_METHOD
00116 #define MEM_METHOD MEM_MALLOC
00117 #endif
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134 #ifndef MULTITHREAD
00135 #define MULTITHREAD 1
00136 #endif
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149 #ifndef USE_PTHREAD
00150 #define USE_PTHREAD 0
00151 #endif
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164 #ifndef USE_FORK
00165 #define USE_FORK 0
00166 #endif
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179 #ifndef USE_SOCKET
00180 #define USE_SOCKET 0
00181 #endif
00182
00183
00184
00185
00186
00187
00188
00189
00190 #ifndef MAIN_HAS_NOARGC
00191 #define MAIN_HAS_NOARGC 0
00192 #endif
00193
00194
00195
00196
00197
00198
00199
00200
00201 #ifndef MAIN_HAS_NORETURN
00202 #define MAIN_HAS_NORETURN 0
00203 #endif
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214 extern ee_u32 default_num_contexts;
00215
00216 #if (MULTITHREAD>1)
00217 #if USE_PTHREAD
00218 #include <pthread.h>
00219 #define PARALLEL_METHOD "PThreads"
00220 #elif USE_FORK
00221 #include <unistd.h>
00222 #include <errno.h>
00223 #include <sys/wait.h>
00224 #include <sys/shm.h>
00225 #include <string.h>
00226 #define PARALLEL_METHOD "Fork"
00227 #elif USE_SOCKET
00228 #include <sys/types.h>
00229 #include <sys/socket.h>
00230 #include <netinet/in.h>
00231 #include <arpa/inet.h>
00232 #include <sys/wait.h>
00233 #include <stdio.h>
00234 #include <stdlib.h>
00235 #include <string.h>
00236 #include <unistd.h>
00237 #include <errno.h>
00238 #define PARALLEL_METHOD "Sockets"
00239 #else
00240 #define PARALLEL_METHOD "Proprietary"
00241 #error "Please implement multicore functionality in core_portme.c to use multiple contexts."
00242 #endif
00243 #endif
00244
00245 typedef struct CORE_PORTABLE_S {
00246 #if (MULTITHREAD>1)
00247 #if USE_PTHREAD
00248 pthread_t thread;
00249 #elif USE_FORK
00250 pid_t pid;
00251 int shmid;
00252 void *shm;
00253 #elif USE_SOCKET
00254 pid_t pid;
00255 int sock;
00256 struct sockaddr_in sa;
00257 #endif
00258 #endif
00259 ee_u8 portable_id;
00260 } core_portable;
00261
00262
00263 void portable_init(core_portable *p, int *argc, char *argv[]);
00264 void portable_fini(core_portable *p);
00265
00266 #if (SEED_METHOD==SEED_VOLATILE)
00267 #if (VALIDATION_RUN || PERFORMANCE_RUN || PROFILE_RUN)
00268 #define RUN_TYPE_FLAG 1
00269 #else
00270 #if (TOTAL_DATA_SIZE==1200)
00271 #define PROFILE_RUN 1
00272 #else
00273 #define PERFORMANCE_RUN 1
00274 #endif
00275 #endif
00276 #endif
00277
00278 #endif