forced inlining of functions that are intended to be called before _and_ after copy. Added compiler warning if that fails (-Winline)

This commit is contained in:
Markus Fröschle
2012-12-11 08:52:29 +00:00
parent f71e377e12
commit f38ca6ad48
3 changed files with 26 additions and 28 deletions

View File

@@ -32,6 +32,7 @@ CFLAGS=-mcpu=5474\
-Wall\ -Wall\
-g\ -g\
-Wno-multichar\ -Wno-multichar\
-Winline\
-Os\ -Os\
-fomit-frame-pointer\ -fomit-frame-pointer\
-fno-strict-aliasing\ -fno-strict-aliasing\

View File

@@ -29,8 +29,31 @@
#include <bas_types.h> #include <bas_types.h>
extern inline void wait(uint32_t us); /*
extern inline uint32_t waitfor(uint32_t us, uint32_t (*condition)(void)); * wait for the specified number of us on slice timer 0. Replaces the original routines that had
* the number of useconds to wait for hardcoded in their name.
*/
extern __inline__ void wait(uint32_t us)
{
uint32_t target = MCF_SLT_SCNT(0) - (us * 132);
while (MCF_SLT_SCNT(0) > target);
}
/*
* the same as above, with a checker function which gets called while
* busy waiting and allows for an early return if it returns true
*/
extern __inline__ uint32_t waitfor(uint32_t us, uint32_t (*condition)(void))
{
uint32_t target = MCF_SLT_SCNT(0) - (us * 132);
uint32_t res;
do
{
if ((res = (*condition)()))
return res;
} while (MCF_SLT_SCNT(0) > target);
return 0;
}
#endif /* _WAIT_H_ */ #endif /* _WAIT_H_ */

View File

@@ -30,30 +30,4 @@
#include <wait.h> #include <wait.h>
/*
* wait for the specified number of us on slice timer 0. Replaces the original routines that had
* the number of useconds to wait for hardcoded in their name.
*/
inline void wait(uint32_t us)
{
uint32_t target = MCF_SLT_SCNT(0) - (us * 132);
while (MCF_SLT_SCNT(0) > target);
}
/*
* the same as above, with a checker function which gets called while
* busy waiting and allows for an early return if it returns true
*/
inline uint32_t waitfor(uint32_t us, uint32_t (*condition)(void))
{
uint32_t target = MCF_SLT_SCNT(0) - (us * 132);
uint32_t res;
do
{
if ((res = (*condition)()))
return res;
} while (MCF_SLT_SCNT(0) > target);
return 0;
}