os/ossrv/genericopenlibs/liboil/src/deprecated/abs_c_dep.c
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
/*
sl@0
     2
 * LIBOIL - Library of Optimized Inner Loops
sl@0
     3
 * Copyright (c) 2003 David A. Schleef <ds@schleef.org>
sl@0
     4
 * All rights reserved.
sl@0
     5
 *
sl@0
     6
 * Redistribution and use in source and binary forms, with or without
sl@0
     7
 * modification, are permitted provided that the following conditions
sl@0
     8
 * are met:
sl@0
     9
 * 1. Redistributions of source code must retain the above copyright
sl@0
    10
 *    notice, this list of conditions and the following disclaimer.
sl@0
    11
 * 2. Redistributions in binary form must reproduce the above copyright
sl@0
    12
 *    notice, this list of conditions and the following disclaimer in the
sl@0
    13
 *    documentation and/or other materials provided with the distribution.
sl@0
    14
 * 
sl@0
    15
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
sl@0
    16
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
sl@0
    17
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
sl@0
    18
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
sl@0
    19
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
sl@0
    20
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
sl@0
    21
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
sl@0
    22
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
sl@0
    23
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
sl@0
    24
 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
sl@0
    25
 * POSSIBILITY OF SUCH DAMAGE.
sl@0
    26
 */
sl@0
    27
//Portions Copyright (c)  2008-2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. 
sl@0
    28
sl@0
    29
#ifdef HAVE_CONFIG_H
sl@0
    30
#include "config.h"
sl@0
    31
#endif
sl@0
    32
sl@0
    33
//#include "liboil_wsd_solutions.h"
sl@0
    34
#include "liboil/liboilfunction.h"
sl@0
    35
#include "liboil/simdpack/simdpack.h"
sl@0
    36
#include <math.h>
sl@0
    37
sl@0
    38
/*
sl@0
    39
#if EMULATOR       
sl@0
    40
GET_GLOBAL_VAR_FROM_TLS(_class,abs_f32_f32,OilFunctionClass)
sl@0
    41
#define _oil_function_class_abs_f32_f32 (*GET_OIL_WSD_VAR_NAME(_class,abs_f32_f32,g)())
sl@0
    42
#else
sl@0
    43
OIL_DEFINE_CLASS (abs_f32_f32, "float *dest, int dstr, float *src, int sstr, int n");
sl@0
    44
#endif
sl@0
    45
*/
sl@0
    46
sl@0
    47
OIL_DEFINE_CLASS (abs_u8_s8, "uint8_t *dest, int dstr, int8_t *src, int sstr, int n");
sl@0
    48
OIL_DEFINE_CLASS (abs_u16_s16, "uint16_t *dest, int dstr, int16_t *src, int sstr, int n");
sl@0
    49
OIL_DEFINE_CLASS (abs_u32_s32, "uint32_t *dest, int dstr, int32_t *src, int sstr, int n");
sl@0
    50
OIL_DEFINE_CLASS (abs_f32_f32, "float *dest, int dstr, float *src, int sstr, int n");
sl@0
    51
OIL_DEFINE_CLASS (abs_f64_f64, "double *dest, int dstr, double *src, int sstr, int n");
sl@0
    52
sl@0
    53
sl@0
    54
//static void abs_test (OilFunctionClass *klass, OilFunctionImpl *impl);
sl@0
    55
sl@0
    56
#define ABS(x) ((x)>0 ? (x) : -(x))
sl@0
    57
sl@0
    58
sl@0
    59
/**
sl@0
    60
 * oil_abs_u8_s8:
sl@0
    61
 * @dest: destination array
sl@0
    62
 * @dstr: stride of destination elements
sl@0
    63
 * @src: source array
sl@0
    64
 * @sstr: stride of source elements
sl@0
    65
 * @n: number of elements in arrays
sl@0
    66
 *
sl@0
    67
 * Calculates the absolute value of each element in the source array
sl@0
    68
 * and writes it into the destination array.
sl@0
    69
 */
sl@0
    70
static void
sl@0
    71
abs_u8_s8_ref (uint8_t *dest, int dstr, int8_t *src, int sstr, int n)
sl@0
    72
{
sl@0
    73
  int i;
sl@0
    74
  int x;
sl@0
    75
sl@0
    76
  for (i=0; i<n; i++) {
sl@0
    77
    x = OIL_GET(src, i*sstr, int8_t);
sl@0
    78
    x = ABS(x);
sl@0
    79
    OIL_GET(dest, i*dstr, uint8_t) = x;
sl@0
    80
  }
sl@0
    81
}
sl@0
    82
OIL_DEFINE_IMPL_REF (abs_u8_s8_ref, abs_u8_s8);
sl@0
    83
sl@0
    84
#ifdef	__SYMBIAN32__
sl@0
    85
 
sl@0
    86
OilFunctionImpl* __oil_function_impl_abs_u8_s8_ref()
sl@0
    87
    {
sl@0
    88
    return &_oil_function_impl_abs_u8_s8_ref;
sl@0
    89
    }
sl@0
    90
#endif
sl@0
    91
/**
sl@0
    92
 * oil_abs_u16_s16:
sl@0
    93
 * @dest: destination array
sl@0
    94
 * @dstr: stride of destination elements
sl@0
    95
 * @src: source array
sl@0
    96
 * @sstr: stride of source elements
sl@0
    97
 * @n: number of elements in arrays
sl@0
    98
 *
sl@0
    99
 * Calculates the absolute value of each element in the source array
sl@0
   100
 * and writes it into the destination array.
sl@0
   101
 */
sl@0
   102
static void
sl@0
   103
abs_u16_s16_ref (uint16_t *dest, int dstr, int16_t *src, int sstr, int n)
sl@0
   104
{
sl@0
   105
  int i;
sl@0
   106
  int x;
sl@0
   107
sl@0
   108
  for (i=0; i<n; i++) {
sl@0
   109
    x = OIL_GET(src, i*sstr, int16_t);
sl@0
   110
    x = ABS(x);
sl@0
   111
    OIL_GET(dest, i*dstr, uint16_t) = x;
sl@0
   112
  }
sl@0
   113
}
sl@0
   114
OIL_DEFINE_IMPL_REF (abs_u16_s16_ref, abs_u16_s16);
sl@0
   115
sl@0
   116
/**
sl@0
   117
 * oil_abs_u32_s32:
sl@0
   118
 * @dest: destination array
sl@0
   119
 * @dstr: stride of destination elements
sl@0
   120
 * @src: source array
sl@0
   121
 * @sstr: stride of source elements
sl@0
   122
 * @n: number of elements in arrays
sl@0
   123
 *
sl@0
   124
 * Calculates the absolute value of each element in the source array
sl@0
   125
 * and writes it into the destination array.
sl@0
   126
 */
sl@0
   127
static void
sl@0
   128
abs_u32_s32_ref (uint32_t *dest, int dstr, int32_t *src, int sstr, int n)
sl@0
   129
{
sl@0
   130
  int i;
sl@0
   131
  int x;
sl@0
   132
sl@0
   133
  for (i=0; i<n; i++) {
sl@0
   134
    x = OIL_GET(src, i*sstr, int32_t);
sl@0
   135
    x = ABS(x);
sl@0
   136
    OIL_GET(dest, i*dstr, uint32_t) = x;
sl@0
   137
  }
sl@0
   138
}
sl@0
   139
OIL_DEFINE_IMPL_REF (abs_u32_s32_ref, abs_u32_s32);
sl@0
   140
sl@0
   141
/**
sl@0
   142
 * oil_abs_f32_f32:
sl@0
   143
 * @dest: destination array
sl@0
   144
 * @dstr: stride of destination elements
sl@0
   145
 * @src: source array
sl@0
   146
 * @sstr: stride of source elements
sl@0
   147
 * @n: number of elements in arrays
sl@0
   148
 *
sl@0
   149
 * Calculates the absolute value of each element in the source array
sl@0
   150
 * and writes it into the destination array.
sl@0
   151
 */
sl@0
   152
static void
sl@0
   153
abs_f32_f32_ref (float *dest, int dstr, float *src, int sstr, int n)
sl@0
   154
{
sl@0
   155
  int i;
sl@0
   156
sl@0
   157
  for (i=0; i<n; i++) {
sl@0
   158
    OIL_GET(dest, i*dstr, float) = fabs(OIL_GET(src, i*sstr, float));
sl@0
   159
  }
sl@0
   160
}
sl@0
   161
sl@0
   162
OIL_DEFINE_IMPL_REF (abs_f32_f32_ref, abs_f32_f32);
sl@0
   163
sl@0
   164
sl@0
   165
#ifdef	__SYMBIAN32__
sl@0
   166
 
sl@0
   167
OilFunctionImpl* __oil_function_impl_abs_f32_f32_ref() {
sl@0
   168
        return &_oil_function_impl_abs_f32_f32_ref;
sl@0
   169
}
sl@0
   170
#endif
sl@0
   171
sl@0
   172
sl@0
   173
/**
sl@0
   174
 * oil_abs_f64_f64:
sl@0
   175
 * @dest: destination array
sl@0
   176
 * @dstr: stride of destination elements
sl@0
   177
 * @src: source array
sl@0
   178
 * @sstr: stride of source elements
sl@0
   179
 * @n: number of elements in arrays
sl@0
   180
 *
sl@0
   181
 * Calculates the absolute value of each element in the source array
sl@0
   182
 * and writes it into the destination array.
sl@0
   183
 */
sl@0
   184
static void
sl@0
   185
abs_f64_f64_ref (double *dest, int dstr, double *src, int sstr, int n)
sl@0
   186
{
sl@0
   187
  int i;
sl@0
   188
sl@0
   189
  for (i=0; i<n; i++) {
sl@0
   190
    OIL_GET(dest, i*dstr, double) = fabs(OIL_GET(src, i*sstr, double));
sl@0
   191
  }
sl@0
   192
}
sl@0
   193
sl@0
   194
OIL_DEFINE_IMPL_REF (abs_f64_f64_ref, abs_f64_f64);
sl@0
   195
sl@0
   196
sl@0
   197
#ifdef	__SYMBIAN32__
sl@0
   198
 
sl@0
   199
OilFunctionClass* __oil_function_class_abs_f32_f32() {
sl@0
   200
		return &_oil_function_class_abs_f32_f32;
sl@0
   201
}
sl@0
   202
#endif
sl@0
   203
sl@0
   204
#ifdef	__SYMBIAN32__
sl@0
   205
 
sl@0
   206
OilFunctionClass* __oil_function_class_abs_u8_s8() {
sl@0
   207
		return &_oil_function_class_abs_u8_s8;
sl@0
   208
}
sl@0
   209
#endif
sl@0
   210
sl@0
   211
#ifdef	__SYMBIAN32__
sl@0
   212
 
sl@0
   213
OilFunctionClass* __oil_function_class_abs_u16_s16() {
sl@0
   214
		return &_oil_function_class_abs_u16_s16;
sl@0
   215
}
sl@0
   216
#endif
sl@0
   217
sl@0
   218
#ifdef	__SYMBIAN32__
sl@0
   219
 
sl@0
   220
OilFunctionClass* __oil_function_class_abs_u32_s32() {
sl@0
   221
		return &_oil_function_class_abs_u32_s32;
sl@0
   222
}
sl@0
   223
#endif
sl@0
   224
sl@0
   225
#ifdef	__SYMBIAN32__
sl@0
   226
 
sl@0
   227
OilFunctionClass* __oil_function_class_abs_f64_f64() {
sl@0
   228
		return &_oil_function_class_abs_f64_f64;
sl@0
   229
}
sl@0
   230
#endif
sl@0
   231
sl@0
   232
#ifdef	__SYMBIAN32__
sl@0
   233
 
sl@0
   234
OilFunctionImpl* __oil_function_impl_abs_u16_s16_ref() {
sl@0
   235
		return &_oil_function_impl_abs_u16_s16_ref;
sl@0
   236
}
sl@0
   237
#endif
sl@0
   238
sl@0
   239
#ifdef	__SYMBIAN32__
sl@0
   240
 
sl@0
   241
OilFunctionImpl* __oil_function_impl_abs_u32_s32_ref() {
sl@0
   242
		return &_oil_function_impl_abs_u32_s32_ref;
sl@0
   243
}
sl@0
   244
#endif
sl@0
   245
sl@0
   246
#ifdef	__SYMBIAN32__
sl@0
   247
 
sl@0
   248
OilFunctionImpl* __oil_function_impl_abs_f64_f64_ref() {
sl@0
   249
		return &_oil_function_impl_abs_f64_f64_ref;
sl@0
   250
}
sl@0
   251
#endif
sl@0
   252
sl@0
   253
sl@0
   254
sl@0
   255
#ifdef	__SYMBIAN32__
sl@0
   256
 
sl@0
   257
EXPORT_C void** _oil_function_class_ptr_abs_f32_f32 ()	{
sl@0
   258
	oil_function_class_ptr_abs_f32_f32 = __oil_function_class_abs_f32_f32();
sl@0
   259
	return &oil_function_class_ptr_abs_f32_f32->func;
sl@0
   260
	}
sl@0
   261
#endif
sl@0
   262
sl@0
   263
#ifdef	__SYMBIAN32__
sl@0
   264
 
sl@0
   265
EXPORT_C void** _oil_function_class_ptr_abs_u8_s8 ()	{
sl@0
   266
	oil_function_class_ptr_abs_u8_s8 = __oil_function_class_abs_u8_s8();
sl@0
   267
	return &oil_function_class_ptr_abs_u8_s8->func;
sl@0
   268
	}
sl@0
   269
#endif
sl@0
   270
sl@0
   271
#ifdef	__SYMBIAN32__
sl@0
   272
 
sl@0
   273
EXPORT_C void** _oil_function_class_ptr_abs_u16_s16 ()	{
sl@0
   274
	oil_function_class_ptr_abs_u16_s16 = __oil_function_class_abs_u16_s16();
sl@0
   275
	return &oil_function_class_ptr_abs_u16_s16->func;
sl@0
   276
	}
sl@0
   277
#endif
sl@0
   278
sl@0
   279
#ifdef	__SYMBIAN32__
sl@0
   280
 
sl@0
   281
EXPORT_C void** _oil_function_class_ptr_abs_u32_s32 ()	{
sl@0
   282
	oil_function_class_ptr_abs_u32_s32 = __oil_function_class_abs_u32_s32();
sl@0
   283
	return &oil_function_class_ptr_abs_u32_s32->func;
sl@0
   284
	}
sl@0
   285
#endif
sl@0
   286
sl@0
   287
#ifdef	__SYMBIAN32__
sl@0
   288
 
sl@0
   289
EXPORT_C void** _oil_function_class_ptr_abs_f64_f64 ()	{
sl@0
   290
	oil_function_class_ptr_abs_f64_f64 = __oil_function_class_abs_f64_f64();
sl@0
   291
	return &oil_function_class_ptr_abs_f64_f64->func;
sl@0
   292
	}
sl@0
   293
#endif
sl@0
   294