os/ossrv/genericopenlibs/liboil/src/copy_s.c
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericopenlibs/liboil/src/copy_s.c	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,194 @@
     1.4 +/*
     1.5 + * LIBOIL - Library of Optimized Inner Loops
     1.6 + * Copyright (c) 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 +//Portions Copyright (c)  2008-2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. 
    1.31 +
    1.32 +#ifdef HAVE_CONFIG_H
    1.33 +#include "config.h"
    1.34 +#endif
    1.35 +
    1.36 +#include <string.h>
    1.37 +
    1.38 +#include <liboilfunction.h>
    1.39 +
    1.40 +/**
    1.41 + * SECTION:liboilfuncs-copy:
    1.42 + * @title: Copying
    1.43 + * @short_description: Functions for copying data
    1.44 + *
    1.45 + */
    1.46 +
    1.47 +/**
    1.48 + * oil_copy_u8:
    1.49 + * @dest: destination array
    1.50 + * @src: source array
    1.51 + * @n: number of elements
    1.52 + *
    1.53 + * Copies from source to destination.
    1.54 + */
    1.55 +OIL_DEFINE_CLASS (copy_u8, "uint8_t *dest, uint8_t *src, int n");
    1.56 +
    1.57 +static void
    1.58 +copy_u8_ref (uint8_t *dest, uint8_t *src, int n)
    1.59 +{
    1.60 +  int i;
    1.61 +  for(i=0;i<n;i++){
    1.62 +    dest[i] = src[i];
    1.63 +  }
    1.64 +}
    1.65 +OIL_DEFINE_IMPL_REF (copy_u8_ref, copy_u8);
    1.66 +
    1.67 +/**
    1.68 + * oil_compare_u8:
    1.69 + * @d_1: destination array
    1.70 + * @s1: source array
    1.71 + * @s2: source array
    1.72 + * @n: number of elements
    1.73 + *
    1.74 + * Compares two arrays.  The index of the first two elements that are
    1.75 + * unequal is written into dest.  If all elements are equal, @n is
    1.76 + * written into dest.
    1.77 + */
    1.78 +OIL_DEFINE_CLASS (compare_u8, "uint32_t *d_1, uint8_t *s1, uint8_t *s2, int n");
    1.79 +
    1.80 +static void
    1.81 +compare_u8_ref (uint32_t *dest, uint8_t *src1, uint8_t *src2, int n)
    1.82 +{
    1.83 +  int i;
    1.84 +
    1.85 +  for(i=0;i<n;i++){
    1.86 +    if (src1[i] != src2[i]) {
    1.87 +      dest[0] = i;
    1.88 +      return;
    1.89 +    }
    1.90 +  }
    1.91 +  dest[0] = n;
    1.92 +}
    1.93 +OIL_DEFINE_IMPL_REF (compare_u8_ref, compare_u8);
    1.94 +
    1.95 +/**
    1.96 + * oil_testzero_u8:
    1.97 + * @d_1: destination array
    1.98 + * @s: source array
    1.99 + * @n: number of elements
   1.100 + *
   1.101 + * Tests each element in the source array for equality with 0.  The
   1.102 + * index of the first zero element is written into dest.  If all
   1.103 + * elements are non-zero, @n is written into dest.
   1.104 + *
   1.105 + * This function is roughly equivalent to strnlen().  One notable
   1.106 + * difference is that implementations of this function may legally
   1.107 + * read past the zero byte.
   1.108 + */
   1.109 +OIL_DEFINE_CLASS (testzero_u8, "uint32_t *d_1, uint8_t *s, int n");
   1.110 +
   1.111 +static void
   1.112 +testzero_u8_ref (uint32_t *dest, uint8_t *src1, int n)
   1.113 +{
   1.114 +  int i;
   1.115 +
   1.116 +  for(i=0;i<n;i++){
   1.117 +    if (src1[i] == 0) {
   1.118 +      dest[0] = i;
   1.119 +      return;
   1.120 +    }
   1.121 +  }
   1.122 +  dest[0] = n;
   1.123 +}
   1.124 +OIL_DEFINE_IMPL_REF (testzero_u8_ref, testzero_u8);
   1.125 +
   1.126 +
   1.127 +
   1.128 +#ifdef	__SYMBIAN32__
   1.129 + 
   1.130 +OilFunctionClass* __oil_function_class_copy_u8() {
   1.131 +		return &_oil_function_class_copy_u8;
   1.132 +}
   1.133 +#endif
   1.134 +
   1.135 +#ifdef	__SYMBIAN32__
   1.136 + 
   1.137 +OilFunctionClass* __oil_function_class_compare_u8() {
   1.138 +		return &_oil_function_class_compare_u8;
   1.139 +}
   1.140 +#endif
   1.141 +
   1.142 +#ifdef	__SYMBIAN32__
   1.143 + 
   1.144 +OilFunctionClass* __oil_function_class_testzero_u8() {
   1.145 +		return &_oil_function_class_testzero_u8;
   1.146 +}
   1.147 +#endif
   1.148 +
   1.149 +
   1.150 +
   1.151 +#ifdef	__SYMBIAN32__
   1.152 + 
   1.153 +OilFunctionImpl* __oil_function_impl_copy_u8_ref() {
   1.154 +		return &_oil_function_impl_copy_u8_ref;
   1.155 +}
   1.156 +#endif
   1.157 +
   1.158 +#ifdef	__SYMBIAN32__
   1.159 + 
   1.160 +OilFunctionImpl* __oil_function_impl_compare_u8_ref() {
   1.161 +		return &_oil_function_impl_compare_u8_ref;
   1.162 +}
   1.163 +#endif
   1.164 +
   1.165 +#ifdef	__SYMBIAN32__
   1.166 + 
   1.167 +OilFunctionImpl* __oil_function_impl_testzero_u8_ref() {
   1.168 +		return &_oil_function_impl_testzero_u8_ref;
   1.169 +}
   1.170 +#endif
   1.171 +
   1.172 +
   1.173 +
   1.174 +#ifdef	__SYMBIAN32__
   1.175 + 
   1.176 +EXPORT_C void** _oil_function_class_ptr_copy_u8 ()	{
   1.177 +	oil_function_class_ptr_copy_u8 = __oil_function_class_copy_u8();
   1.178 +	return &oil_function_class_ptr_copy_u8->func;
   1.179 +	}
   1.180 +#endif
   1.181 +
   1.182 +#ifdef	__SYMBIAN32__
   1.183 + 
   1.184 +EXPORT_C void** _oil_function_class_ptr_compare_u8 ()	{
   1.185 +	oil_function_class_ptr_compare_u8 = __oil_function_class_compare_u8();
   1.186 +	return &oil_function_class_ptr_compare_u8->func;
   1.187 +	}
   1.188 +#endif
   1.189 +
   1.190 +#ifdef	__SYMBIAN32__
   1.191 + 
   1.192 +EXPORT_C void** _oil_function_class_ptr_testzero_u8 ()	{
   1.193 +	oil_function_class_ptr_testzero_u8 = __oil_function_class_testzero_u8();
   1.194 +	return &oil_function_class_ptr_testzero_u8->func;
   1.195 +	}
   1.196 +#endif
   1.197 +