00001
00006
00007
00008
00009
00010
00011
00012
00231 #include "generic.h"
00232
00233 #include <assert.h>
00234 #include <stdlib.h>
00235 #include <stdio.h>
00236 #include <math.h>
00237
00238 #ifdef VL_OS_WIN
00239 #include <Windows.h>
00240 #endif
00241
00242 VL_EXPORT int vl_err_no = 0 ;
00243 VL_EXPORT char vl_err_msg [VL_ERR_MSG_LEN + 1] = "" ;
00244
00250 VL_EXPORT
00251 char const * vl_get_version_string ()
00252 {
00253 return VL_VERSION_STRING ;
00254 }
00255
00261 VL_EXPORT
00262 void vl_print_info ()
00263 {
00264 VL_PRINTF ("VLFeat version %s\n", vl_get_version_string()) ;
00265 vl_print_host_info () ;
00266 }
00267
00269 static int
00270 do_nothing_printf (char const* format, ...)
00271 {
00272 return 0 ;
00273 }
00274
00276 void *(*vl_malloc_func) (size_t) = &malloc ;
00277
00279 void *(*vl_realloc_func) (void*,size_t) = &realloc ;
00280
00282 void *(*vl_calloc_func) (size_t, size_t) = &calloc ;
00283
00285 void (*vl_free_func) (void*) = &free ;
00286
00288 int (*vl_printf_func) (char const *, ...)= printf ;
00289
00339 VL_EXPORT
00340 void vl_set_alloc_func (void *(*malloc_func) (size_t),
00341 void *(*realloc_func) (void*, size_t),
00342 void *(*calloc_func) (size_t, size_t),
00343 void (*free_func) (void*))
00344 {
00345 vl_malloc_func = malloc_func ;
00346 vl_realloc_func = realloc_func ;
00347 vl_calloc_func = calloc_func ;
00348 vl_free_func = free_func ;
00349 }
00350
00351 VL_EXPORT
00352 void
00353 vl_set_printf_func (printf_func_t printf_func)
00354 {
00355 vl_printf_func = printf_func ? printf_func : do_nothing_printf ;
00356 }
00357
00358 #ifdef VL_OS_WIN
00359 LARGE_INTEGER tic_freq ;
00360 LARGE_INTEGER tic_mark ;
00361 #else
00362 clock_t tic_mark ;
00363 #endif
00364
00369 void vl_tic()
00370 {
00371 #ifdef VL_OS_WIN
00372 QueryPerformanceFrequency(&tic_freq) ;
00373 QueryPerformanceCounter(&tic_mark) ;
00374 #else
00375 tic_mark = clock() ;
00376 #endif
00377 }
00378
00391 double vl_toc()
00392 {
00393 #ifdef VL_OS_WIN
00394 LARGE_INTEGER toc_mark ;
00395 QueryPerformanceCounter(&toc_mark) ;
00396 return (double) (toc_mark.QuadPart - tic_mark.QuadPart) / tic_freq.QuadPart ;
00397 #else
00398 return (double) (clock() - tic_mark) / CLOCKS_PER_SEC ;
00399 #endif
00400 }