Mercurial > hg > audiodb
comparison audioDB.h @ 370:2d5c3f8e8c22
Merge gcc-4.3-cleanups branch (-r629:642, but I consider that branch as
having served its purpose) onto the trunk.
Now compiles cleanly even with a fairly picky gcc. I await version 4.4
with bated breath.
author | mas01cr |
---|---|
date | Wed, 12 Nov 2008 15:40:40 +0000 |
parents | 94c18f128ce8 |
children | 78fed0d4c108 dc099cd34b5b |
comparison
equal
deleted
inserted
replaced
355:94c18f128ce8 | 370:2d5c3f8e8c22 |
---|---|
131 #define O2_ERR_KEYNOTFOUND (0xFFFFFF00) | 131 #define O2_ERR_KEYNOTFOUND (0xFFFFFF00) |
132 | 132 |
133 // Macros | 133 // Macros |
134 #define O2_ACTION(a) (strcmp(command,a)==0) | 134 #define O2_ACTION(a) (strcmp(command,a)==0) |
135 | 135 |
136 #define ALIGN_UP(x,w) ((x) + ((1<<w)-1) & ~((1<<w)-1)) | 136 #define ALIGN_UP(x,w) (((x) + ((1<<w)-1)) & ~((1<<w)-1)) |
137 #define ALIGN_DOWN(x,w) ((x) & ~((1<<w)-1)) | 137 #define ALIGN_DOWN(x,w) ((x) & ~((1<<w)-1)) |
138 | 138 |
139 #define ALIGN_PAGE_UP(x) ((x) + (getpagesize()-1) & ~(getpagesize()-1)) | 139 #define ALIGN_PAGE_UP(x) (((x) + (getpagesize()-1)) & ~(getpagesize()-1)) |
140 #define ALIGN_PAGE_DOWN(x) ((x) & ~(getpagesize()-1)) | 140 #define ALIGN_PAGE_DOWN(x) ((x) & ~(getpagesize()-1)) |
141 | 141 |
142 #define ENSURE_STRING(x) ((x) ? (x) : "") | 142 #define ENSURE_STRING(x) ((x) ? (x) : "") |
143 | 143 |
144 #define CHECKED_MMAP(type, var, start, length) \ | 144 #define CHECKED_MMAP(type, var, start, length) \ |
145 { void *tmp = mmap(0, length, (PROT_READ | (forWrite ? PROT_WRITE : 0)), MAP_SHARED, dbfid, (start)); \ | 145 { void *tmp = mmap(0, length, (PROT_READ | (forWrite ? PROT_WRITE : 0)), MAP_SHARED, dbfid, (start)); \ |
146 if(tmp == (void *) -1) { \ | 146 if(tmp == (void *) -1) { \ |
147 error("mmap error for db table", #var, "mmap"); \ | 147 error("mmap error for db table", #var, "mmap"); \ |
148 } \ | 148 } \ |
149 var = (type) tmp; \ | 149 var = (type) tmp; \ |
150 } | |
151 | |
152 #define CHECKED_READ(fd, buf, count) \ | |
153 { size_t tmpcount = count; \ | |
154 ssize_t tmp = read(fd, buf, tmpcount); \ | |
155 if(tmp == -1) { \ | |
156 error("read error", "", "read"); \ | |
157 } else if((size_t) tmp != tmpcount) { \ | |
158 error("short read", ""); \ | |
159 } \ | |
160 } | |
161 | |
162 #define CHECKED_WRITE(fd, buf, count) \ | |
163 { size_t tmpcount = count; \ | |
164 ssize_t tmp = write(fd, buf, tmpcount); \ | |
165 if(tmp == -1) { \ | |
166 error("write error", "", "write"); \ | |
167 } else if((size_t) tmp != tmpcount) { \ | |
168 error("short write", ""); \ | |
169 } \ | |
150 } | 170 } |
151 | 171 |
152 #define VERB_LOG(vv, ...) \ | 172 #define VERB_LOG(vv, ...) \ |
153 if(verbosity > vv) { \ | 173 if(verbosity > vv) { \ |
154 fprintf(stderr, __VA_ARGS__); \ | 174 fprintf(stderr, __VA_ARGS__); \ |
300 // LISZT parameters | 320 // LISZT parameters |
301 unsigned lisztOffset; | 321 unsigned lisztOffset; |
302 unsigned lisztLength; | 322 unsigned lisztLength; |
303 | 323 |
304 //for lib / API | 324 //for lib / API |
325 int apierrortemp; | |
305 unsigned UseApiError; | 326 unsigned UseApiError; |
306 | 327 |
307 // private methods | 328 // private methods |
308 void error(const char* a, const char* b = "", const char *sysFunc = 0); | 329 void error(const char* a, const char* b = "", const char *sysFunc = 0); |
309 void sequence_sum(double *buffer, int length, int seqlen); | 330 void sequence_sum(double *buffer, int length, int seqlen); |
331 void insertPowerData(unsigned n, int powerfd, double *powerdata); | 352 void insertPowerData(unsigned n, int powerfd, double *powerdata); |
332 unsigned getKeyPos(char* key); | 353 unsigned getKeyPos(char* key); |
333 void prefix_name(char** const name, const char* prefix); | 354 void prefix_name(char** const name, const char* prefix); |
334 | 355 |
335 public: | 356 public: |
336 audioDB(const unsigned argc, const char *const argv[]); | 357 audioDB(const unsigned argc, const char *argv[]); |
337 audioDB(const unsigned argc, const char *const argv[], adb__queryResponse *adbQueryResponse); | 358 audioDB(const unsigned argc, const char *argv[], adb__queryResponse *adbQueryResponse); |
338 audioDB(const unsigned argc, const char *const argv[], adb__statusResponse *adbStatusResponse); | 359 audioDB(const unsigned argc, const char *argv[], adb__statusResponse *adbStatusResponse); |
339 audioDB(const unsigned argc, const char *const argv[], adb__lisztResponse *adbLisztResponse); | 360 audioDB(const unsigned argc, const char *argv[], adb__lisztResponse *adbLisztResponse); |
340 audioDB(const unsigned argc, char* const argv[], int * apierror); | 361 audioDB(const unsigned argc, const char *argv[], int * apierror); |
341 audioDB(const unsigned argc, char* const argv[], cppstatusptr stat, int * apierror); | 362 audioDB(const unsigned argc, const char *argv[], cppstatusptr stat, int * apierror); |
342 audioDB(const unsigned argc, char* const argv[],adb__queryResponse *adbQueryResponse, int * apierror); | 363 audioDB(const unsigned argc, const char *argv[],adb__queryResponse *adbQueryResponse, int * apierror); |
343 | 364 |
344 | 365 |
345 void cleanup(); | 366 void cleanup(); |
346 ~audioDB(); | 367 ~audioDB(); |
347 int processArgs(const unsigned argc, const char* const argv[]); | 368 int processArgs(const unsigned argc, const char* argv[]); |
348 void get_lock(int fd, bool exclusive); | 369 void get_lock(int fd, bool exclusive); |
349 void release_lock(int fd); | 370 void release_lock(int fd); |
350 void create(const char* dbName); | 371 void create(const char* dbName); |
351 bool enough_per_file_space_free(); | 372 bool enough_per_file_space_free(); |
352 bool enough_data_space_free(off_t size); | 373 bool enough_data_space_free(off_t size); |
408 LSH* index_allocate(char* indexName, bool load_hashTables); | 429 LSH* index_allocate(char* indexName, bool load_hashTables); |
409 void init_track_aux_data(Uns32T trackID, double* fvp, double** sNormpp,double** snPtrp, double** sPowerp, double** spPtrp); | 430 void init_track_aux_data(Uns32T trackID, double* fvp, double** sNormpp,double** snPtrp, double** sPowerp, double** spPtrp); |
410 | 431 |
411 // Web Services | 432 // Web Services |
412 void startServer(); | 433 void startServer(); |
413 | |
414 int apierrortemp; | |
415 | 434 |
416 void ws_status(const char*dbName, char* hostport); | 435 void ws_status(const char*dbName, char* hostport); |
417 void ws_query(const char*dbName, const char *featureFileName, const char* hostport); | 436 void ws_query(const char*dbName, const char *featureFileName, const char* hostport); |
418 void ws_query_by_key(const char*dbName, const char *trackKey, const char* featureFileName, const char* hostport); | 437 void ws_query_by_key(const char*dbName, const char *trackKey, const char* featureFileName, const char* hostport); |
419 void ws_liszt(const char* dbName, char* hostport); | 438 void ws_liszt(const char* dbName, char* hostport); |
489 relative_threshold(0.0), \ | 508 relative_threshold(0.0), \ |
490 reporter(0), \ | 509 reporter(0), \ |
491 exact_evaluation_queue(0), \ | 510 exact_evaluation_queue(0), \ |
492 lisztOffset(0), \ | 511 lisztOffset(0), \ |
493 lisztLength(0), \ | 512 lisztLength(0), \ |
513 apierrortemp(0), \ | |
514 UseApiError(0), \ | |
494 lsh(0), \ | 515 lsh(0), \ |
495 lsh_in_core(false), \ | 516 lsh_in_core(false), \ |
496 lsh_use_u_functions(false), \ | 517 lsh_use_u_functions(false), \ |
497 lsh_exact(false), \ | 518 lsh_exact(false), \ |
498 WS_load_index(false), \ | 519 WS_load_index(false), \ |
500 lsh_param_m(0), \ | 521 lsh_param_m(0), \ |
501 lsh_param_N(0), \ | 522 lsh_param_N(0), \ |
502 lsh_param_b(0), \ | 523 lsh_param_b(0), \ |
503 lsh_param_ncols(0), \ | 524 lsh_param_ncols(0), \ |
504 lsh_n_point_bits(0), \ | 525 lsh_n_point_bits(0), \ |
505 vv(0), \ | 526 vv(0) |
506 apierrortemp(0) | |
507 #endif | 527 #endif |