2010-10-01 04:46:47 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2010-10-01 06:11:33 +08:00
|
|
|
#define INLINE inline __attribute__((always_inline))
|
2010-10-01 04:46:47 +08:00
|
|
|
|
|
|
|
int
|
|
|
|
func_not_inlined (void)
|
|
|
|
{
|
|
|
|
printf ("Called func_not_inlined.\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-10-01 06:11:33 +08:00
|
|
|
INLINE int
|
2010-10-01 04:46:47 +08:00
|
|
|
func_inlined (void)
|
|
|
|
{
|
|
|
|
static int func_inline_call_count = 0;
|
|
|
|
printf ("Called func_inlined.\n");
|
|
|
|
++func_inline_call_count;
|
|
|
|
printf ("Returning func_inlined call count: %d.\n", func_inline_call_count);
|
2010-10-13 05:57:42 +08:00
|
|
|
return func_inline_call_count; // Set break point at this line.
|
2010-10-01 04:46:47 +08:00
|
|
|
}
|
|
|
|
|
2010-10-01 06:11:33 +08:00
|
|
|
extern int func_inlined (void);
|
|
|
|
|
2010-10-01 04:46:47 +08:00
|
|
|
int
|
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
|
|
|
printf ("Starting...\n");
|
|
|
|
|
|
|
|
int (*func_ptr) (void);
|
|
|
|
func_ptr = func_inlined;
|
|
|
|
|
|
|
|
int a = func_inlined();
|
|
|
|
printf("First call to func_inlined() returns: %d.\n", a);
|
|
|
|
|
|
|
|
func_not_inlined ();
|
|
|
|
|
|
|
|
func_ptr ();
|
|
|
|
|
|
|
|
printf("Last call to func_inlined() returns: %d.\n", func_inlined ());
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|