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 ee_u32 ee_ptr_int;
00092
00093
00094
00095 #define align_mem(x) (void *)(4 + (((ee_ptr_int)(x) - 1) & ~3))
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105 #ifndef SEED_METHOD
00106 #define SEED_METHOD SEED_ARG
00107 #endif
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117 #ifndef MEM_METHOD
00118 #define MEM_METHOD MEM_MALLOC
00119 #endif
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136 #ifndef MULTITHREAD
00137 #define MULTITHREAD 1
00138 #endif
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151 #ifndef USE_PTHREAD
00152 #define USE_PTHREAD 0
00153 #endif
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166 #ifndef USE_FORK
00167 #define USE_FORK 0
00168 #endif
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181 #ifndef USE_SOCKET
00182 #define USE_SOCKET 0
00183 #endif
00184
00185
00186
00187
00188
00189
00190
00191
00192 #ifndef MAIN_HAS_NOARGC
00193 #define MAIN_HAS_NOARGC 0
00194 #endif
00195
00196
00197
00198
00199
00200
00201
00202
00203 #ifndef MAIN_HAS_NORETURN
00204 #define MAIN_HAS_NORETURN 0
00205 #endif
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216 extern ee_u32 default_num_contexts;
00217
00218 #if (MULTITHREAD>1)
00219 #if USE_PTHREAD
00220 #include <pthread.h>
00221 #define PARALLEL_METHOD "PThreads"
00222 #elif USE_FORK
00223 #include <unistd.h>
00224 #include <errno.h>
00225 #include <sys/wait.h>
00226 #include <sys/shm.h>
00227 #include <string.h>
00228 #define PARALLEL_METHOD "Fork"
00229 #elif USE_SOCKET
00230 #include <sys/types.h>
00231 #include <sys/socket.h>
00232 #include <netinet/in.h>
00233 #include <arpa/inet.h>
00234 #include <sys/wait.h>
00235 #include <stdio.h>
00236 #include <stdlib.h>
00237 #include <string.h>
00238 #include <unistd.h>
00239 #include <errno.h>
00240 #define PARALLEL_METHOD "Sockets"
00241 #else
00242 #define PARALLEL_METHOD "Proprietary"
00243 #error "Please implement multicore functionality in core_portme.c to use multiple contexts."
00244 #endif
00245 #endif
00246
00247 typedef struct CORE_PORTABLE_S {
00248 #if (MULTITHREAD>1)
00249 #if USE_PTHREAD
00250 pthread_t thread;
00251 #elif USE_FORK
00252 pid_t pid;
00253 int shmid;
00254 void *shm;
00255 #elif USE_SOCKET
00256 pid_t pid;
00257 int sock;
00258 struct sockaddr_in sa;
00259 #endif
00260 #endif
00261 ee_u8 portable_id;
00262 } core_portable;
00263
00264
00265 void portable_init(core_portable *p, int *argc, char *argv[]);
00266 void portable_fini(core_portable *p);
00267
00268 #if (SEED_METHOD==SEED_VOLATILE)
00269 #if (VALIDATION_RUN || PERFORMANCE_RUN || PROFILE_RUN)
00270 #define RUN_TYPE_FLAG 1
00271 #else
00272 #if (TOTAL_DATA_SIZE==1200)
00273 #define PROFILE_RUN 1
00274 #else
00275 #define PERFORMANCE_RUN 1
00276 #endif
00277 #endif
00278 #endif
00279
00280 #endif