Changeset 228 for soft/giet_vm/libs/common.h
- Timestamp:
- Feb 12, 2013, 6:33:31 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/libs/common.h
r178 r228 16 16 */ 17 17 ////////////////////////////////////////////////////////////////////////// 18 static inline void *memcpy(void *_dst, const void *_src, unsigned int size) 19 { 20 unsigned int *dst = _dst; 21 const unsigned int *src = _src; 18 static inline void * memcpy(void * _dst, const void * _src, unsigned int size) { 19 unsigned int * dst = _dst; 20 const unsigned int * src = _src; 22 21 23 22 /* if source and destination buffer are word-aligned, 24 23 * then copy word-by-word */ 25 if (!((unsigned int)dst & 3) && !((unsigned int)src & 3)) 24 if (!((unsigned int)dst & 3) && !((unsigned int)src & 3)) { 26 25 while (size > 3) { 27 26 *dst++ = *src++; 28 27 size -= 4; 29 28 } 29 } 30 30 31 unsigned char * cdst = (unsigned char*)dst;32 unsigned char * csrc = (unsigned char*)src;31 unsigned char * cdst = (unsigned char *) dst; 32 unsigned char * csrc = (unsigned char *) src; 33 33 34 34 /* byte-by-byte copy */ … … 39 39 } 40 40 41 41 42 ////////////////////////////////////////////////////////// 42 static inline void * memset(void * dst, int s, unsigned int count)43 { 44 char *a = (char *) dst; 45 while (count--) 46 *a++ = (char)s; 47 43 static inline void * memset(void * dst, int s, unsigned int count) { 44 char * a = (char *) dst; 45 while (count--) { 46 *a++ = (char) s; 47 } 48 return dst; 48 49 } 49 50 51 50 52 /** 51 52 53 */54 #define assert(expr) 55 do { 56 if ( ! (expr) ) { 53 the same as the C assert. 54 Taken from Mutekh(SRL API) 55 */ 56 #define assert(expr) \ 57 do { \ 58 if ( ! (expr) ) { \ 57 59 giet_tty_printf("assertion (%s) failed on %s:%d !\n", \ 58 #expr, __FILE__, __LINE__ );\59 __abort(); 60 } 60 #expr, __FILE__, __LINE__ ); \ 61 __abort(); \ 62 } \ 61 63 } while(0) 62 64 63 65 /** 64 @this aborts the current execution. 65 Taken from Mutekh(SRL API) 66 */ 67 static inline void __abort() 68 { 69 asm volatile ("break 0"); 70 while(1); 66 @this aborts the current execution. 67 Taken from Mutekh(SRL API) 68 */ 69 static inline void __abort() { 70 asm volatile ("break 0"); 71 while (1); 71 72 } 72 73 73 74 #endif /* _COMMON_H_ */ 75 76 77 // Local Variables: 78 // tab-width: 4 79 // c-basic-offset: 4 80 // c-file-offsets:((innamespace . 0)(inline-open . 0)) 81 // indent-tabs-mode: nil 82 // End: 83 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 84
Note: See TracChangeset
for help on using the changeset viewer.