os/ossrv/genericopenlibs/liboil/src/liboilfunction.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericopenlibs/liboil/src/liboilfunction.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,432 @@
     1.4 +/*
     1.5 + * LIBOIL - Library of Optimized Inner Loops
     1.6 + * Copyright (c) 2003,2004 David A. Schleef <ds@schleef.org>
     1.7 + * All rights reserved.
     1.8 + *
     1.9 + * Redistribution and use in source and binary forms, with or without
    1.10 + * modification, are permitted provided that the following conditions
    1.11 + * are met:
    1.12 + * 1. Redistributions of source code must retain the above copyright
    1.13 + *    notice, this list of conditions and the following disclaimer.
    1.14 + * 2. Redistributions in binary form must reproduce the above copyright
    1.15 + *    notice, this list of conditions and the following disclaimer in the
    1.16 + *    documentation and/or other materials provided with the distribution.
    1.17 + * 
    1.18 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
    1.19 + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    1.20 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    1.21 + * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
    1.22 + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    1.23 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    1.24 + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    1.25 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
    1.26 + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
    1.27 + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    1.28 + * POSSIBILITY OF SUCH DAMAGE.
    1.29 + */
    1.30 +
    1.31 +//Portions Copyright (c)  2008-2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. 
    1.32 +
    1.33 +#ifndef _LIBOIL_FUNCTION_H_
    1.34 +#define _LIBOIL_FUNCTION_H_
    1.35 +
    1.36 +#include "liboil/liboilutils.h"
    1.37 +#include "liboil/liboiltypes.h"
    1.38 +
    1.39 +/**
    1.40 + * OIL_CHECK_PROTOTYPE:
    1.41 + * @a:
    1.42 + *
    1.43 + * Macro used internally to implement the --enable-prototype-checking
    1.44 + * configure option.
    1.45 + */
    1.46 +#ifdef LIBOIL_STRICT_PROTOTYPES
    1.47 +#include <liboil/liboilfuncs.h>
    1.48 +#define OIL_CHECK_PROTOTYPE(a) a
    1.49 +#else
    1.50 +#define OIL_CHECK_PROTOTYPE(a)
    1.51 +#endif
    1.52 +
    1.53 +OIL_BEGIN_DECLS
    1.54 +
    1.55 +/**
    1.56 + * OilImplFlag:
    1.57 + *
    1.58 + * Implementation flags.
    1.59 + *
    1.60 + * @OIL_IMPL_FLAG_REF: is the reference implementation for the class.
    1.61 + *
    1.62 + * @OIL_IMPL_FLAG_OPT: was compiled with alternate CFLAGS as specified
    1.63 + * by --enable-alternate-optimization.
    1.64 + *
    1.65 + * @OIL_IMPL_FLAG_ASM: is written in assembly code.
    1.66 + *
    1.67 + * @OIL_IMPL_FLAG_DISABLED: is disabled.  This can be set either in the
    1.68 + * source code or during library initialization.
    1.69 + *
    1.70 + * @OIL_IMPL_FLAG_CMOV: uses the i386 instruction cmov or its variants.
    1.71 + *
    1.72 + * @OIL_IMPL_FLAG_MMX: uses MMX instructions.
    1.73 + *
    1.74 + * @OIL_IMPL_FLAG_SSE: uses SSE instructions.
    1.75 + *
    1.76 + * @OIL_IMPL_FLAG_MMXEXT: uses AMD's extended MMX instructions.  These
    1.77 + * are a subset of what Intel calls SSE2.  If an implementation uses
    1.78 + * only AMD's extended MMX instructions, it should set this flag, and
    1.79 + * not @OIL_IMPL_FLAG_SSE2.
    1.80 + *
    1.81 + * @OIL_IMPL_FLAG_SSE2: uses SSE2 instructions.  This flag implies
    1.82 + * @OIL_IMPL_FLAG_SSE and @OIL_IMPL_FLAG_MMXEXT.
    1.83 + *
    1.84 + * @OIL_IMPL_FLAG_3DNOW: uses 3DNow! instructions.
    1.85 + *
    1.86 + * @OIL_IMPL_FLAG_3DNOWEXT: uses extended 3DNow! instructions.
    1.87 + *
    1.88 + * @OIL_IMPL_FLAG_SSE3: uses SSE3 instructions.  This flag implies
    1.89 + * @OIL_IMPL_FLAG_SSE2.
    1.90 + *
    1.91 + * @OIL_IMPL_FLAG_SSSE3: uses SSSE3 instructions.  This flag implies
    1.92 + * @OIL_IMPL_FLAG_SSE3.
    1.93 + *
    1.94 + * @OIL_IMPL_FLAG_ALTIVEC: uses Altivec instructions.
    1.95 + *
    1.96 + */
    1.97 +typedef enum {
    1.98 +  OIL_IMPL_FLAG_REF = (1<<0),
    1.99 +  OIL_IMPL_FLAG_OPT = (1<<1),
   1.100 +  OIL_IMPL_FLAG_ASM = (1<<2),
   1.101 +  OIL_IMPL_FLAG_DISABLED = (1<<3),
   1.102 +  OIL_IMPL_FLAG_CMOV = (1<<16),
   1.103 +  OIL_IMPL_FLAG_MMX = (1<<17),
   1.104 +  OIL_IMPL_FLAG_SSE = (1<<18),
   1.105 +  OIL_IMPL_FLAG_MMXEXT = (1<<19),
   1.106 +  OIL_IMPL_FLAG_SSE2 = (1<<20),
   1.107 +  OIL_IMPL_FLAG_3DNOW = (1<<21),
   1.108 +  OIL_IMPL_FLAG_3DNOWEXT = (1<<22),
   1.109 +  OIL_IMPL_FLAG_SSE3 = (1<<23),
   1.110 +  OIL_IMPL_FLAG_ALTIVEC = (1<<24),
   1.111 +  OIL_IMPL_FLAG_EDSP = (1<<25),
   1.112 +  OIL_IMPL_FLAG_ARM6 = (1<<26),
   1.113 +  OIL_IMPL_FLAG_VFP = (1<<27),
   1.114 +  OIL_IMPL_FLAG_SSSE3 = (1<<28)
   1.115 +} OilImplFlag;
   1.116 +
   1.117 +#ifdef OIL_ENABLE_UNSTABLE_API
   1.118 +
   1.119 +/**
   1.120 + * OIL_OPT_MANGLE:
   1.121 + *
   1.122 + * Used internally to implement the --enable-alternate-optimizations
   1.123 + * configure option.
   1.124 + */
   1.125 +/**
   1.126 + * OIL_OPT_FLAG_MANGLE:
   1.127 + *
   1.128 + * Used internally to implement the --enable-alternate-optimizations
   1.129 + * configure option.
   1.130 + */
   1.131 +/**
   1.132 + * OIL_NO_CLASSES:
   1.133 + *
   1.134 + * Used internally to implement the --enable-alternate-optimizations
   1.135 + * configure option.
   1.136 + */
   1.137 +/**
   1.138 + * OIL_OPT_SUFFIX:
   1.139 + *
   1.140 + * Used internally to implement the --enable-alternate-optimizations
   1.141 + * configure option.
   1.142 + */
   1.143 +#ifndef OIL_OPT_MANGLE
   1.144 +#define OIL_OPT_MANGLE(a) a
   1.145 +#define OIL_OPT_FLAG_MANGLE(a) a
   1.146 +#else
   1.147 +#define OIL_NO_CLASSES
   1.148 +#define OIL_OPT_FLAG_MANGLE(a) (((a)&(~OIL_IMPL_FLAG_REF)) | OIL_IMPL_FLAG_OPT)
   1.149 +#endif
   1.150 +#ifndef OIL_OPT_SUFFIX
   1.151 +#define OIL_OPT_SUFFIX
   1.152 +#endif
   1.153 +
   1.154 +/**
   1.155 + * OilFunctionClass:
   1.156 + *
   1.157 + * An opaque structure representing a function class.
   1.158 + *
   1.159 + */
   1.160 +struct _OilFunctionClass {
   1.161 +  /*< private >*/
   1.162 +    void *func;
   1.163 +    const char *name;
   1.164 +    const char *desc;
   1.165 +    OilTestFunction test_func;
   1.166 +
   1.167 +    OilFunctionImpl *first_impl;
   1.168 +    OilFunctionImpl *reference_impl;
   1.169 +
   1.170 +    OilFunctionImpl *chosen_impl;
   1.171 +
   1.172 +    const char *prototype;
   1.173 +};
   1.174 +
   1.175 +/**
   1.176 + * OilFunctionImpl:
   1.177 + *
   1.178 + * An opaque structure representing a function implementation.
   1.179 + *
   1.180 + */
   1.181 +struct _OilFunctionImpl {
   1.182 +  /*< private >*/
   1.183 +    void *next;
   1.184 +    OilFunctionClass *klass;
   1.185 +    void *func;
   1.186 +    unsigned int flags;
   1.187 +    const char *name;
   1.188 +        double profile_ave;
   1.189 +        double profile_std;
   1.190 +};
   1.191 +
   1.192 +/**
   1.193 + * OIL_GET:
   1.194 + * @ptr:
   1.195 + * @offset:
   1.196 + * @type:
   1.197 + *
   1.198 + * Offsets @ptr by @offset number of bytes, and dereferences it
   1.199 + * as type @type.  Note that the offset is in bytes, and not in
   1.200 + * the size of the pointer type.
   1.201 + */
   1.202 +#define OIL_GET(ptr, offset, type) (*(type *)((uint8_t *)(ptr) + (offset)) )
   1.203 +/**
   1.204 + * OIL_OFFSET:
   1.205 + * @ptr:
   1.206 + * @offset:
   1.207 + *
   1.208 + * Add @offset bytes to the pointer @ptr.
   1.209 + */
   1.210 +#define OIL_OFFSET(ptr, offset) ((void *)((uint8_t *)(ptr) + (offset)) )
   1.211 +/**
   1.212 + * OIL_INCREMENT:
   1.213 + * @ptr:
   1.214 + * @offset:
   1.215 + *
   1.216 + * Increments the pointer @ptr by @offset number of bytes.
   1.217 + */
   1.218 +#define OIL_INCREMENT(ptr, offset) (ptr = (void *)((uint8_t *)ptr + (offset)) )
   1.219 +
   1.220 +/**
   1.221 + * OIL_CPU_FLAG_MASK:
   1.222 + *
   1.223 + * Mask describing which bits in #OilImplFlag depend on the current
   1.224 + * CPU.
   1.225 + */
   1.226 +#define OIL_CPU_FLAG_MASK 0xffff0000
   1.227 +
   1.228 +/**
   1.229 + * OIL_DECLARE_CLASS:
   1.230 + * @klass: the name of a function class (without the oil_ prefix)
   1.231 + *
   1.232 + * Declares the Liboil function class @klass.
   1.233 + */
   1.234 +#define OIL_DECLARE_CLASS(klass) \
   1.235 +    extern OilFunctionClass _oil_function_class_ ## klass
   1.236 +
   1.237 +/**
   1.238 + * SECTION:liboilmacros
   1.239 + * @title: Macros
   1.240 + * @short_description: Macros
   1.241 + */
   1.242 +
   1.243 +#ifndef OIL_NO_CLASSES
   1.244 +/**
   1.245 + * OIL_DEFINE_CLASS_FULL:
   1.246 + * @klass: name of class to declare (without oil_ prefix)
   1.247 + * @string: prototype of class
   1.248 + * @test: test function
   1.249 + *
   1.250 + * Defines a #OilFunctionClass structure for @klass.  Classes
   1.251 + * defined this way will be automatically at Liboil initialization
   1.252 + * time.
   1.253 + */
   1.254 +#define OIL_DEFINE_CLASS_FULL(klass, string, test) \
   1.255 +OilFunctionClass _oil_function_class_ ## klass = { \
   1.256 +    NULL, \
   1.257 +    #klass , \
   1.258 +    NULL, \
   1.259 +        test, \
   1.260 +        NULL, \
   1.261 +        NULL, \
   1.262 +        NULL, \
   1.263 +        string \
   1.264 +}; \
   1.265 +OilFunctionClass *oil_function_class_ptr_ ## klass = \
   1.266 +  &_oil_function_class_ ## klass
   1.267 +#else
   1.268 +#define OIL_DEFINE_CLASS_FULL(klass, string, test) \
   1.269 +  OIL_DECLARE_CLASS(klass)
   1.270 +#endif
   1.271 +
   1.272 +/**
   1.273 + * OIL_DEFINE_CLASS:
   1.274 + * @klass: name of class to declare (without oil_ prefix)
   1.275 + * @string: prototype of class
   1.276 + *
   1.277 + * Defines a #OilFunctionClass structure for @klass.  Classes
   1.278 + * defined this way will be automatically at Liboil initialization
   1.279 + * time.
   1.280 + */
   1.281 +#define OIL_DEFINE_CLASS(klass, string) \
   1.282 +  OIL_DEFINE_CLASS_FULL (klass, string, NULL)
   1.283 +
   1.284 +/**
   1.285 + * OIL_DEFINE_IMPL_FULL:
   1.286 + * @function: name of function
   1.287 + * @klass: name of class to declare (without oil_ prefix)
   1.288 + * @flags: implementation flags and CPU requirements
   1.289 + *
   1.290 + * Defines a #OilFunctionImpl structure for the function @function
   1.291 + * and class @klass.  CPU-dependent flags in @flags will indicate
   1.292 + * that this implementation requires the given CPU flags.
   1.293 + */
   1.294 +
   1.295 +#define OIL_DEFINE_IMPL_FULL(function,klass,flags) \
   1.296 +OilFunctionImpl OIL_OPT_MANGLE(_oil_function_impl_ ## function) = { \
   1.297 +    NULL, \
   1.298 +    &_oil_function_class_ ## klass , \
   1.299 +    (void *)function, \
   1.300 +    OIL_OPT_FLAG_MANGLE(flags), \
   1.301 +        #function OIL_OPT_SUFFIX \
   1.302 +} \
   1.303 +
   1.304 +
   1.305 +
   1.306 +
   1.307 +OIL_CHECK_PROTOTYPE(;_oil_type_ ## klass _ignore_me_ ## function = function)
   1.308 +
   1.309 +/**
   1.310 + * OIL_DEFINE_IMPL:
   1.311 + * @function: name of function
   1.312 + * @klass: name of class to declare (without oil_ prefix)
   1.313 + *
   1.314 + * Shorthand for defining a C implementation.  See OIL_DEFINE_IMPL_FULL().
   1.315 + */
   1.316 +#define OIL_DEFINE_IMPL(function,klass) \
   1.317 +    OIL_DEFINE_IMPL_FULL(function,klass,0)
   1.318 +/**
   1.319 + * OIL_DEFINE_IMPL_REF:
   1.320 + * @function: name of function
   1.321 + * @klass: name of class to declare (without oil_ prefix)
   1.322 + *
   1.323 + * Shorthand for defining a reference implementation.  See OIL_DEFINE_IMPL_FULL().
   1.324 + */
   1.325 +#define OIL_DEFINE_IMPL_REF(function,klass) \
   1.326 +    OIL_DEFINE_IMPL_FULL(function,klass,OIL_IMPL_FLAG_REF)
   1.327 +/**
   1.328 + * OIL_DEFINE_IMPL_ASM:
   1.329 + * @function: name of function
   1.330 + * @klass: name of class to declare (without oil_ prefix)
   1.331 + *
   1.332 + * Shorthand for defining an implementation written in inline
   1.333 + * assembly code.  See OIL_DEFINE_IMPL_FULL().
   1.334 + */
   1.335 +#define OIL_DEFINE_IMPL_ASM(function,klass) \
   1.336 +    OIL_DEFINE_IMPL_FULL(function,klass,OIL_IMPL_FLAG_ASM)
   1.337 +/**
   1.338 + * OIL_DEFINE_IMPL_DEPENDS
   1.339 + * @function: name of function
   1.340 + * @klass: name of class to declare (without oil_ prefix)
   1.341 + * @...: other classes this implementation uses
   1.342 + *
   1.343 + * Shorthand for defining an implementation that uses another Liboil
   1.344 + * function class.  This is not currently used.  See
   1.345 + * OIL_DEFINE_IMPL_FULL().
   1.346 + */
   1.347 +#ifndef __SYMBIAN32__
   1.348 +#define OIL_DEFINE_IMPL_DEPENDS(function,klass,...) \
   1.349 +    OIL_DEFINE_IMPL_FULL(function,klass,0)
   1.350 +#else
   1.351 +#define OIL_DEFINE_IMPL_DEPENDS(function,klass,args...) \
   1.352 +    OIL_DEFINE_IMPL_FULL(function,klass,0)
   1.353 +#endif
   1.354 +
   1.355 +
   1.356 +
   1.357 +#ifdef __SYMBIAN32__
   1.358 +IMPORT_C
   1.359 +#endif
   1.360 +void oil_optimize_all (void);
   1.361 +
   1.362 +#ifdef __SYMBIAN32__
   1.363 +IMPORT_C
   1.364 +#endif
   1.365 +void oil_optimize (const char *class_name);
   1.366 +
   1.367 +#ifdef __SYMBIAN32__
   1.368 +IMPORT_C
   1.369 +#endif
   1.370 +OilFunctionClass * oil_class_get_by_index (int i);
   1.371 +
   1.372 +#ifdef __SYMBIAN32__
   1.373 +IMPORT_C
   1.374 +#endif
   1.375 +OilFunctionClass *oil_class_get (const char *class_name);
   1.376 +
   1.377 +#ifdef __SYMBIAN32__
   1.378 +IMPORT_C
   1.379 +#endif
   1.380 +void oil_class_optimize (OilFunctionClass *klass);
   1.381 +
   1.382 +#ifdef __SYMBIAN32__
   1.383 +IMPORT_C
   1.384 +#endif
   1.385 +int oil_class_get_n_classes (void);
   1.386 +
   1.387 +#ifdef __SYMBIAN32__
   1.388 +IMPORT_C
   1.389 +#endif
   1.390 +OilFunctionImpl * oil_impl_get_by_index (int i);
   1.391 +
   1.392 +#ifdef __SYMBIAN32__
   1.393 +IMPORT_C
   1.394 +#endif
   1.395 +int oil_impl_is_runnable (OilFunctionImpl *impl);
   1.396 +
   1.397 +#ifdef __SYMBIAN32__
   1.398 +IMPORT_C
   1.399 +#endif
   1.400 +int oil_impl_is_usable (OilFunctionImpl *impl);
   1.401 +
   1.402 +#ifdef __SYMBIAN32__
   1.403 +IMPORT_C
   1.404 +#endif
   1.405 +void oil_class_choose_by_name (OilFunctionClass * klass, const char *name);
   1.406 +
   1.407 +#ifdef __SYMBIAN32__
   1.408 +IMPORT_C
   1.409 +#endif
   1.410 +void oil_class_register_impl_full (OilFunctionClass * klass,
   1.411 +void (*func)(void), const char *name, unsigned int flags);
   1.412 +
   1.413 +
   1.414 +#ifdef __SYMBIAN32__
   1.415 +IMPORT_C
   1.416 +#endif
   1.417 +void oil_class_register_impl (OilFunctionClass * klass, OilFunctionImpl *impl);
   1.418 +
   1.419 +#ifdef __SYMBIAN32__
   1.420 +IMPORT_C
   1.421 +#endif
   1.422 +void oil_class_register_impl_by_name (const char *klass_name,
   1.423 +    OilFunctionImpl *impl);
   1.424 +
   1.425 +#ifdef __SYMBIAN32__
   1.426 +IMPORT_C
   1.427 +#endif
   1.428 +void oil_init_no_optimize(void);
   1.429 +
   1.430 +#endif
   1.431 +
   1.432 +OIL_END_DECLS
   1.433 +
   1.434 +#endif
   1.435 +