/usr/include/vl/generic.h is in libvlfeat-dev 0.9.17+dfsg0-6build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | /** @file generic.h
** @brief Generic (@ref generic)
** @author Andrea Vedaldi
**/
/*
Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson.
Copyright (C) 2013 Andrea Vedaldi.
All rights reserved.
This file is part of the VLFeat library and is made available under
the terms of the BSD license (see the COPYING file).
*/
#ifndef VL_GENERIC_H
#define VL_GENERIC_H
#include "host.h"
#include "random.h"
#include <stdlib.h>
#include <stddef.h>
#include <time.h>
#include <assert.h>
/** @brief Library version string */
#define VL_VERSION_STRING "0.9.17"
/** @brief Maximum length (in characters) of an error message */
#define VL_ERR_MSG_LEN 1024
/** @name Type identifiers for atomic data types
** @{ */
#define VL_TYPE_FLOAT 1 /**< @c float type */
#define VL_TYPE_DOUBLE 2 /**< @c double type */
#define VL_TYPE_INT8 3 /**< @c ::vl_int8 type */
#define VL_TYPE_UINT8 4 /**< @c ::vl_uint8 type */
#define VL_TYPE_INT16 5 /**< @c ::vl_int16 type */
#define VL_TYPE_UINT16 6 /**< @c ::vl_uint16 type */
#define VL_TYPE_INT32 7 /**< @c ::vl_int32 type */
#define VL_TYPE_UINT32 8 /**< @c ::vl_uint32 type */
#define VL_TYPE_INT64 9 /**< @c ::vl_int64 type */
#define VL_TYPE_UINT64 10 /**< @c ::vl_uint64 type */
typedef vl_uint32 vl_type ;
/** @brief Get the name of a data type.
** @param type data type.
** @return data name of the data type.
**
** @c type is one of ::VL_TYPE_FLOAT, ::VL_TYPE_DOUBLE,
** ::VL_TYPE_INT8, ::VL_TYPE_INT16, ::VL_TYPE_INT32, ::VL_TYPE_INT64,
** ::VL_TYPE_UINT8, ::VL_TYPE_UINT16, ::VL_TYPE_UINT32, ::VL_TYPE_UINT64.
**/
VL_INLINE char const *
vl_get_type_name (vl_type type)
{
switch (type) {
case VL_TYPE_FLOAT : return "float" ;
case VL_TYPE_DOUBLE : return "double" ;
case VL_TYPE_INT8 : return "int8" ;
case VL_TYPE_INT16 : return "int16" ;
case VL_TYPE_INT32 : return "int32" ;
case VL_TYPE_INT64 : return "int64" ;
case VL_TYPE_UINT8 : return "int8" ;
case VL_TYPE_UINT16 : return "int16" ;
case VL_TYPE_UINT32 : return "int32" ;
case VL_TYPE_UINT64 : return "int64" ;
default: return NULL ;
}
}
/** @brief Get data type size.
** @param type data type.
** @return size (in byte)
**
** @c type is one of ::VL_TYPE_FLOAT, ::VL_TYPE_DOUBLE,
** ::VL_TYPE_INT8, ::VL_TYPE_INT16, ::VL_TYPE_INT32, ::VL_TYPE_INT64,
** ::VL_TYPE_UINT8, ::VL_TYPE_UINT16, ::VL_TYPE_UINT32, ::VL_TYPE_UINT64.
**/
VL_INLINE vl_size
vl_get_type_size (vl_type type)
{
vl_size dataSize = 0 ;
switch (type) {
case VL_TYPE_DOUBLE : dataSize = sizeof(double) ; break ;
case VL_TYPE_FLOAT : dataSize = sizeof(float) ; break ;
case VL_TYPE_INT64 : case VL_TYPE_UINT64 : dataSize = sizeof(vl_int64) ; break ;
case VL_TYPE_INT32 : case VL_TYPE_UINT32 : dataSize = sizeof(vl_int32) ; break ;
case VL_TYPE_INT16 : case VL_TYPE_UINT16 : dataSize = sizeof(vl_int16) ; break ;
case VL_TYPE_INT8 : case VL_TYPE_UINT8 : dataSize = sizeof(vl_int8) ; break ;
default:
abort() ;
}
return dataSize ;
}
/** @} */
VL_EXPORT char const * vl_get_version_string (void) ;
VL_EXPORT char * vl_configuration_to_string_copy (void) ;
VL_EXPORT void vl_set_simd_enabled (vl_bool x) ;
VL_EXPORT vl_bool vl_get_simd_enabled (void) ;
VL_EXPORT vl_bool vl_cpu_has_avx (void) ;
VL_EXPORT vl_bool vl_cpu_has_sse3 (void) ;
VL_EXPORT vl_bool vl_cpu_has_sse2 (void) ;
VL_EXPORT vl_size vl_get_num_cpus (void) ;
VL_EXPORT vl_size vl_get_max_threads (void) ;
VL_EXPORT void vl_set_num_threads (vl_size n) ;
VL_EXPORT VlRand * vl_get_rand (void) ;
#if 0
VL_EXPORT vl_size vl_get_thread_limit (void) ;
#endif
/** ------------------------------------------------------------------
** @name Error handling
** @{ */
#define VL_ERR_OK 0 /**< No error */
#define VL_ERR_OVERFLOW 1 /**< Buffer overflow error */
#define VL_ERR_ALLOC 2 /**< Resource allocation error */
#define VL_ERR_BAD_ARG 3 /**< Bad argument or illegal data error */
#define VL_ERR_IO 4 /**< Input/output error */
#define VL_ERR_EOF 5 /**< End-of-file or end-of-sequence error */
#define VL_ERR_NO_MORE 5 /**< End-of-sequence @deprecated */
VL_EXPORT int vl_get_last_error (void) ;
VL_EXPORT char const * vl_get_last_error_message (void) ;
VL_EXPORT int vl_set_last_error (int error, char const * errorMessage, ...) ;
/** @} */
/** ------------------------------------------------------------------
** @name Memory allocation
** @{ */
VL_EXPORT void
vl_set_alloc_func (void *(*malloc_func) (size_t),
void *(*realloc_func) (void*,size_t),
void *(*calloc_func) (size_t, size_t),
void (*free_func) (void*)) ;
VL_EXPORT void *vl_malloc (size_t n) ;
VL_EXPORT void *vl_realloc (void *ptr, size_t n) ;
VL_EXPORT void *vl_calloc (size_t n, size_t size) ;
VL_EXPORT void *vl_memalign (size_t n, size_t size) ;
VL_EXPORT void vl_free (void* ptr) ;
/** @} */
/** ------------------------------------------------------------------
** @name Logging
** @{ */
/** @brief Customizable printf function pointer type */
typedef int(*printf_func_t) (char const *format, ...) ;
VL_EXPORT void vl_set_printf_func (printf_func_t printf_func) ;
VL_EXPORT printf_func_t vl_get_printf_func (void) ;
/** @def VL_PRINTF
** @brief Call user-customizable @c printf function
**
** The function calls the user customizable @c printf.
**/
/** @def VL_PRINT
** @brief Same as ::VL_PRINTF (legacy code)
**/
#define VL_PRINTF (*vl_get_printf_func())
#define VL_PRINT (*vl_get_printf_func())
/** @} */
/** ------------------------------------------------------------------
** @name Common operations
** @{ */
/** @brief Compute the minimum between two values
** @param x value
** @param y value
** @return the minimum of @a x and @a y.
**/
#define VL_MIN(x,y) (((x)<(y))?(x):(y))
/** @brief Compute the maximum between two values
** @param x value.
** @param y value.
** @return the maximum of @a x and @a y.
**/
#define VL_MAX(x,y) (((x)>(y))?(x):(y))
/** @brief Signed left shift operation
** @param x value.
** @param n number of shift positions.
** @return @c x << n .
** The macro is equivalent to the builtin @c << operator, but it
** supports negative shifts too.
**/
#define VL_SHIFT_LEFT(x,n) (((n)>=0)?((x)<<(n)):((x)>>-(n)))
/* @} */
/** ------------------------------------------------------------------
** @name Measuring time
** @{
**/
VL_EXPORT void vl_tic (void) ;
VL_EXPORT double vl_toc (void) ;
VL_EXPORT double vl_get_cpu_time (void) ;
/** @} */
/* VL_GENERIC_H */
#endif
|