/* Inline all 5 ANSI C mem* functions. ISO C Runtime Library Copyright (C) 2002-2014 Green Hills Software, Inc. This program is the property of Green Hills Software, Inc, its contents are proprietary information and no part of it is to be disclosed to anyone except employees of Green Hills Software, Inc., or as agreed in writing signed by the President of Green Hills Software, Inc. */ #if !defined(__GHS_MEM_H) #ifdef __ghs__ #pragma ghs startnomisra #endif #define __GHS_MEM_H #ifndef _STRING_H # error Please include instead of ghs_mem.h #endif /************************************************************************/ /* #define __GHS_EXTERN_INLINE for C/C++ extern inline functions */ /************************************************************************/ #if defined(__cplusplus) # define __GHS_EXTERN_INLINE extern "C" inline /* ANSI/ISO C++ */ #elif defined(__KCC) || (defined(__GNUC__) && !defined(__GNUC_STDC_INLINE__)) # define __GHS_EXTERN_INLINE extern __inline__ /* KAI C/GNU C */ #elif defined(__STDC_VERSION__) && (__STDC_VERSION__>=199901L) # define __GHS_EXTERN_INLINE inline /* ANSI/ISO C99 */ # define __GHS_RENAME_MEMFUNCS #else # define __GHS_EXTERN_INLINE __inline /* GHS C */ # define __GHS_RENAME_MEMFUNCS #endif /************************************************************************/ /* #define __GHS_CONST */ /************************************************************************/ #if !defined(__GHS_CONST) #if defined(__cplusplus) /* C++? */ #define __GHS_CONST const /* yes */ #else #define __GHS_CONST /* no */ #endif #endif /************************************************************************/ /* #define __GHS_CPU_WHILE0 */ /************************************************************************/ #if !defined(__GHS_CPU_WHILE0) && 0 /* previously used for ST100 */ #define __GHS_CPU_WHILE0/* use: while (N--) { loop_body } */ #endif /* else use: if(N) { loop_body } while (--N); */ /************************************************************************/ /* #define __GHS_LOOPS(N) (Loop Start) and __GHS_LOOPE(N) (Loop End) */ /************************************************************************/ #if defined(__GHS_CPU_WHILE0) /* canonic form */ # define __GHS_LOOPS(__GHS_N) while(__GHS_N--) { /* H/W loop top */ # define __GHS_LOOPE(__GHS_N) } /* H/W loop end */ #else # define __GHS_LOOPS(__GHS_N) if (__GHS_N) do { /* 0 trip loop? */ # define __GHS_LOOPE(__GHS_N) } while(--__GHS_N) /* count trips */ #endif /************************************************************************/ /* #define __GHS_CPU_PREINC */ /************************************************************************/ #if defined(__ppc) # if !defined(__GHS_CPU_PREINC) /*--------------*/ # define __GHS_CPU_PREINC /* *p++ -> *++p */ # endif /*--------------*/ #endif #if !defined(__GHS_CPU_PREINC) /*--------------*/ #define __GHS_INCR(__GHS_P) (__GHS_P-1) /* preincrement */ #define __GHS_DECR(__GHS_P) __GHS_P /* predecrement */ #define __GHS_NEXT(__GHS_P) __GHS_P++ /* next address */ #define __GHS_PREV(__GHS_P) __GHS_P-- /* prev address */ #define __GHS_LAST(__GHS_P) (__GHS_P-1) /* last address */ #else /*--------------*/ #define __GHS_INCR(__GHS_P) __GHS_P /* preincrement */ #define __GHS_DECR(__GHS_P) (__GHS_P-1) /* predecrement */ #define __GHS_NEXT(__GHS_P) ++__GHS_P /* next address */ #define __GHS_PREV(__GHS_P) --__GHS_P /* prev address */ #define __GHS_LAST(__GHS_P) __GHS_P /* last address */ #endif /*--------------*/ /************************************************************************/ /* memchr: find a character in an N byte string */ /************************************************************************/ #ifdef __GHS_RENAME_MEMFUNCS #pragma ghs do_not_expand_empty_macro #define memchr(__GHS_CV, __GHS_M, __GHS_n) __ghs_memchr(__GHS_CV, __GHS_M, __GHS_n) #endif __GHS_EXTERN_INLINE __GHS_CONST void * memchr (const void *__GHS_CV, int __GHS_M, size_t __GHS_n) { size_t __GHS_N = __GHS_n; const char *__GHS_T = __GHS_DECR((const char *) __GHS_CV); __GHS_M = (char) __GHS_M; __GHS_LOOPS(__GHS_N) { const char __GHS_C = *__GHS_NEXT(__GHS_T); #pragma ghs nowarning 1836 if (__GHS_C==__GHS_M) return (void *) __GHS_LAST(__GHS_T); #pragma ghs endnowarning 1836 } __GHS_LOOPE(__GHS_N); return (void *) 0; } #undef __GHS_EXTERN_INLINE #undef __GHS_LOOPS #undef __GHS_LOOPE #undef __GHS_INCR #undef __GHS_DECR #undef __GHS_NEXT #undef __GHS_PREV #undef __GHS_LAST #ifdef __ghs__ #pragma ghs endnomisra #endif #endif /* !defined(__GHS_MEM_H) */