os/ossrv/genericopenlibs/liboil/src/copy_s.c
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2  * LIBOIL - Library of Optimized Inner Loops
     3  * Copyright (c) 2004 David A. Schleef <ds@schleef.org>
     4  * All rights reserved.
     5  *
     6  * Redistribution and use in source and binary forms, with or without
     7  * modification, are permitted provided that the following conditions
     8  * are met:
     9  * 1. Redistributions of source code must retain the above copyright
    10  *    notice, this list of conditions and the following disclaimer.
    11  * 2. Redistributions in binary form must reproduce the above copyright
    12  *    notice, this list of conditions and the following disclaimer in the
    13  *    documentation and/or other materials provided with the distribution.
    14  * 
    15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
    16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    17  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
    19  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    20  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    21  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
    23  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
    24  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    25  * POSSIBILITY OF SUCH DAMAGE.
    26  */
    27 //Portions Copyright (c)  2008-2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. 
    28 
    29 #ifdef HAVE_CONFIG_H
    30 #include "config.h"
    31 #endif
    32 
    33 #include <string.h>
    34 
    35 #include <liboilfunction.h>
    36 
    37 /**
    38  * SECTION:liboilfuncs-copy:
    39  * @title: Copying
    40  * @short_description: Functions for copying data
    41  *
    42  */
    43 
    44 /**
    45  * oil_copy_u8:
    46  * @dest: destination array
    47  * @src: source array
    48  * @n: number of elements
    49  *
    50  * Copies from source to destination.
    51  */
    52 OIL_DEFINE_CLASS (copy_u8, "uint8_t *dest, uint8_t *src, int n");
    53 
    54 static void
    55 copy_u8_ref (uint8_t *dest, uint8_t *src, int n)
    56 {
    57   int i;
    58   for(i=0;i<n;i++){
    59     dest[i] = src[i];
    60   }
    61 }
    62 OIL_DEFINE_IMPL_REF (copy_u8_ref, copy_u8);
    63 
    64 /**
    65  * oil_compare_u8:
    66  * @d_1: destination array
    67  * @s1: source array
    68  * @s2: source array
    69  * @n: number of elements
    70  *
    71  * Compares two arrays.  The index of the first two elements that are
    72  * unequal is written into dest.  If all elements are equal, @n is
    73  * written into dest.
    74  */
    75 OIL_DEFINE_CLASS (compare_u8, "uint32_t *d_1, uint8_t *s1, uint8_t *s2, int n");
    76 
    77 static void
    78 compare_u8_ref (uint32_t *dest, uint8_t *src1, uint8_t *src2, int n)
    79 {
    80   int i;
    81 
    82   for(i=0;i<n;i++){
    83     if (src1[i] != src2[i]) {
    84       dest[0] = i;
    85       return;
    86     }
    87   }
    88   dest[0] = n;
    89 }
    90 OIL_DEFINE_IMPL_REF (compare_u8_ref, compare_u8);
    91 
    92 /**
    93  * oil_testzero_u8:
    94  * @d_1: destination array
    95  * @s: source array
    96  * @n: number of elements
    97  *
    98  * Tests each element in the source array for equality with 0.  The
    99  * index of the first zero element is written into dest.  If all
   100  * elements are non-zero, @n is written into dest.
   101  *
   102  * This function is roughly equivalent to strnlen().  One notable
   103  * difference is that implementations of this function may legally
   104  * read past the zero byte.
   105  */
   106 OIL_DEFINE_CLASS (testzero_u8, "uint32_t *d_1, uint8_t *s, int n");
   107 
   108 static void
   109 testzero_u8_ref (uint32_t *dest, uint8_t *src1, int n)
   110 {
   111   int i;
   112 
   113   for(i=0;i<n;i++){
   114     if (src1[i] == 0) {
   115       dest[0] = i;
   116       return;
   117     }
   118   }
   119   dest[0] = n;
   120 }
   121 OIL_DEFINE_IMPL_REF (testzero_u8_ref, testzero_u8);
   122 
   123 
   124 
   125 #ifdef	__SYMBIAN32__
   126  
   127 OilFunctionClass* __oil_function_class_copy_u8() {
   128 		return &_oil_function_class_copy_u8;
   129 }
   130 #endif
   131 
   132 #ifdef	__SYMBIAN32__
   133  
   134 OilFunctionClass* __oil_function_class_compare_u8() {
   135 		return &_oil_function_class_compare_u8;
   136 }
   137 #endif
   138 
   139 #ifdef	__SYMBIAN32__
   140  
   141 OilFunctionClass* __oil_function_class_testzero_u8() {
   142 		return &_oil_function_class_testzero_u8;
   143 }
   144 #endif
   145 
   146 
   147 
   148 #ifdef	__SYMBIAN32__
   149  
   150 OilFunctionImpl* __oil_function_impl_copy_u8_ref() {
   151 		return &_oil_function_impl_copy_u8_ref;
   152 }
   153 #endif
   154 
   155 #ifdef	__SYMBIAN32__
   156  
   157 OilFunctionImpl* __oil_function_impl_compare_u8_ref() {
   158 		return &_oil_function_impl_compare_u8_ref;
   159 }
   160 #endif
   161 
   162 #ifdef	__SYMBIAN32__
   163  
   164 OilFunctionImpl* __oil_function_impl_testzero_u8_ref() {
   165 		return &_oil_function_impl_testzero_u8_ref;
   166 }
   167 #endif
   168 
   169 
   170 
   171 #ifdef	__SYMBIAN32__
   172  
   173 EXPORT_C void** _oil_function_class_ptr_copy_u8 ()	{
   174 	oil_function_class_ptr_copy_u8 = __oil_function_class_copy_u8();
   175 	return &oil_function_class_ptr_copy_u8->func;
   176 	}
   177 #endif
   178 
   179 #ifdef	__SYMBIAN32__
   180  
   181 EXPORT_C void** _oil_function_class_ptr_compare_u8 ()	{
   182 	oil_function_class_ptr_compare_u8 = __oil_function_class_compare_u8();
   183 	return &oil_function_class_ptr_compare_u8->func;
   184 	}
   185 #endif
   186 
   187 #ifdef	__SYMBIAN32__
   188  
   189 EXPORT_C void** _oil_function_class_ptr_testzero_u8 ()	{
   190 	oil_function_class_ptr_testzero_u8 = __oil_function_class_testzero_u8();
   191 	return &oil_function_class_ptr_testzero_u8->func;
   192 	}
   193 #endif
   194