Using Inline Function Expansion
2-33
C Compiler Description
Example 2
−
1. How the Run-Time-Support Library Uses the _INLINE Preprocessor
Symbol
(a) string.h
/****************************************************************************/
/* STRING.H HEADER FILE */
/****************************************************************************/
typdef unsigned size_t
#if _INLINE
#define _ _INLINE static inline
/* Declaration when inlining
*/
#else
#define _ _INLINE
/*No declaration when not inlining
*/
#endif
_ _INLINE
void *memcpy (void *_s1, const void *_s2, size_t _n);
#if _INLINE
/* Declare the inlined function
*/
static inline void *memcpy (void *to, const void *from, size_t n)
{
register char *rto
= (char *) to;
register char *rfrom = (char *) from;
register size_t rn;
for (rn = 0; rn < n; rn++) *rto++ =rfrom++;
return (to);
}
#endif
/* _INLINE
*/
#undef _ _INLINE
(b) strlen.c
/****************************************************************************/
/* MEMCPY.C (rts2
xx
.lib) */
/****************************************************************************/
#undef _INLINE /* Turn off so code will be generated */
#include <string.h>
void *memcpy (void *to, const void *from, size_t n)
{
register char *rto
= (char *) to;
register char *rfrom = (char *) from;
register size_t rn;
for (rn = 0; rn < n; rn++) *rto++ =rfrom++;
return (to);
}
Summary of Contents for TMS320C2x
Page 8: ...viii...
Page 69: ...2 47 C Compiler Description...
Page 159: ...6 36...
Page 226: ...8 6...