1 /* ----> DO NOT REMOVE THE FOLLOWING NOTICE <---- 2 * 3 * Copyright (c) 2014-2015 Datalight, Inc. 4 * All Rights Reserved Worldwide. 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; use version 2 of the License. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but "AS-IS," WITHOUT ANY WARRANTY; without even the implied warranty 12 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License along 16 * with this program; if not, write to the Free Software Foundation, Inc., 17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 */ 19 20 /* Businesses and individuals that for commercial or other reasons cannot 21 * comply with the terms of the GPLv2 license may obtain a commercial license 22 * before incorporating Reliance Edge into proprietary software for 23 * distribution in any form. Visit http://www.datalight.com/reliance-edge for 24 * more information. 25 */ 26 27 /** @file 28 */ 29 #ifndef REDUTILS_H 30 #define REDUTILS_H 31 32 33 #if REDCONF_ASSERTS == 1 34 #define REDERROR() RedOsAssertFail( __FILE__, __LINE__ ) 35 #define REDASSERT( EXP ) ( ( EXP ) ? ( void ) 0 : REDERROR() ) 36 #else 37 #define REDERROR() ( ( void ) 0 ) 38 #define REDASSERT( EXP ) ( ( void ) 0 ) 39 #endif 40 41 42 void RedMemCpy( void * pDest, 43 const void * pSrc, 44 uint32_t ulLen ); 45 void RedMemMove( void * pDest, 46 const void * pSrc, 47 uint32_t ulLen ); 48 void RedMemSet( void * pDest, 49 uint8_t bVal, 50 uint32_t ulLen ); 51 int32_t RedMemCmp( const void * pMem1, 52 const void * pMem2, 53 uint32_t ulLen ); 54 55 uint32_t RedStrLen( const char * pszStr ); 56 int32_t RedStrCmp( const char * pszStr1, 57 const char * pszStr2 ); 58 int32_t RedStrNCmp( const char * pszStr1, 59 const char * pszStr2, 60 uint32_t ulLen ); 61 void RedStrNCpy( char * pszDst, 62 const char * pszSrc, 63 uint32_t ulLen ); 64 65 uint32_t RedCrc32Update( uint32_t ulInitCrc32, 66 const void * pBuffer, 67 uint32_t ulLength ); 68 uint32_t RedCrcNode( const void * pBuffer ); 69 70 #if REDCONF_API_POSIX == 1 71 uint32_t RedNameLen( const char * pszName ); 72 #endif 73 74 bool RedBitGet( const uint8_t * pbBitmap, 75 uint32_t ulBit ); 76 void RedBitSet( uint8_t * pbBitmap, 77 uint32_t ulBit ); 78 void RedBitClear( uint8_t * pbBitmap, 79 uint32_t ulBit ); 80 81 #ifdef REDCONF_ENDIAN_SWAP 82 uint64_t RedRev64( uint64_t ullToRev ); 83 uint32_t RedRev32( uint32_t ulToRev ); 84 uint16_t RedRev16( uint16_t uToRev ); 85 #endif 86 87 void RedSignOn( void ); 88 89 90 #endif /* ifndef REDUTILS_H */ 91