Helixis 1.0
Task Programming API
sources/builtins.c
Go to the documentation of this file.
00001 /*
00002 ** Copyright 2009-2011, helixis.org
00003 ** All rights reserved.
00004 **
00005 ** Redistribution and use in source and binary forms, with or without modification, are permitted provided
00006 ** that the following conditions are met:
00007 **
00008 ** Redistributions of source code must retain the above copyright notice, this list of conditions and the
00009 ** following disclaimer.
00010 **
00011 ** Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
00012 ** the following disclaimer in the documentation and/or other materials provided with the distribution.
00013 **
00014 ** Neither the name of the helixis.org nor the names of its contributors may be used to endorse or promote
00015 ** products derived from this software without specific prior written permission.
00016 **
00017 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
00018 ** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
00019 ** PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
00020 ** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
00021 ** TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00022 ** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00023 ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00024 ** POSSIBILITY OF SUCH DAMAGE.
00025 */
00026 
00027 /*
00028 ** INCLUDES
00029 */
00030 
00031 #include "hlx/core.h"
00032 #include "helixis_internal.h"
00033 
00034 #ifdef __cplusplus
00035 extern "C"      {
00036 #endif
00037 
00038 /*
00039 ** FUNCTIONS
00040 */
00041 
00042 /* Daniel J.Bernstein hash algorithm */
00043 unsigned long           hlx_hash(const char* str)
00044 {
00045         unsigned long   hash;
00046         int                             c;
00047 
00048         hash = 5361;
00049         while (*str)
00050         {
00051                 c = *str;
00052                 hash = (hash << 5) + hash + c;
00053                 ++str;
00054         }
00055         return (hash);
00056 }
00057 
00058 void    *hlx_memcpy(void* dest, const void* src, unsigned int num)
00059 {
00060         char* dst8 = (char*)dest;
00061         char* src8 = (char*)src;
00062 
00063         if (num & 1)
00064         {
00065                 dst8[0] = src8[0];
00066                 dst8 += 1;
00067                 src8 += 1;
00068         }
00069         num /= 2;
00070         while (num--)
00071         {
00072                 dst8[0] = src8[0];
00073                 dst8[1] = src8[1];
00074                 dst8 += 2;
00075                 src8 += 2;
00076         }
00077         return (dest);
00078 }
00079 
00080 #ifdef __cplusplus
00081 }
00082 #endif
00083 
00084 /*
00085 ** END OF FILE
00086 */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines