Merge pull request #23 from usr42/issue21_without_issue13

Fix issue 21: Use function pointer for call_history
This commit is contained in:
Mike Long
2017-02-03 20:54:53 +01:00
committed by GitHub
2 changed files with 6 additions and 4 deletions

View File

@@ -355,8 +355,9 @@ def output_reset_function(arg_count, is_value_function)
end end
def define_fff_globals def define_fff_globals
putd "typedef void (*fff_function_t)(void);"
putd "typedef struct { " putd "typedef struct { "
putd " void * call_history[FFF_CALL_HISTORY_LEN];" putd " fff_function_t call_history[FFF_CALL_HISTORY_LEN];"
putd " unsigned int call_history_idx;" putd " unsigned int call_history_idx;"
putd "} fff_globals_t;" putd "} fff_globals_t;"
putd "" putd ""
@@ -373,7 +374,7 @@ def define_fff_globals
putd "" putd ""
putd "#define REGISTER_CALL(function) \\" putd "#define REGISTER_CALL(function) \\"
putd " if(fff.call_history_idx < FFF_CALL_HISTORY_LEN) \\" putd " if(fff.call_history_idx < FFF_CALL_HISTORY_LEN) \\"
putd " fff.call_history[fff.call_history_idx++] = (void *)function;" putd " fff.call_history[fff.call_history_idx++] = (fff_function_t)function;"
end end
def extern_c def extern_c

5
fff.h
View File

@@ -108,8 +108,9 @@ SOFTWARE.
} }
/* -- END INTERNAL HELPER MACROS -- */ /* -- END INTERNAL HELPER MACROS -- */
typedef void (*fff_function_t)(void);
typedef struct { typedef struct {
void * call_history[FFF_CALL_HISTORY_LEN]; fff_function_t call_history[FFF_CALL_HISTORY_LEN];
unsigned int call_history_idx; unsigned int call_history_idx;
} fff_globals_t; } fff_globals_t;
@@ -126,7 +127,7 @@ FFF_END_EXTERN_C \
#define REGISTER_CALL(function) \ #define REGISTER_CALL(function) \
if(fff.call_history_idx < FFF_CALL_HISTORY_LEN) \ if(fff.call_history_idx < FFF_CALL_HISTORY_LEN) \
fff.call_history[fff.call_history_idx++] = (void *)function; fff.call_history[fff.call_history_idx++] = (fff_function_t)function;
#define DECLARE_FAKE_VOID_FUNC0(FUNCNAME) \ #define DECLARE_FAKE_VOID_FUNC0(FUNCNAME) \
FFF_EXTERN_C \ FFF_EXTERN_C \