Skip to content

Commit

Permalink
api: Added mmk_no_optimize function attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
Snaipe committed Mar 29, 2016
1 parent bc422d2 commit a090921
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions include/mimick.h
Expand Up @@ -70,6 +70,14 @@ void mmk_stub_destroy(mmk_stub stub);
# endif
# endif

# if defined __clang__
# define mmk_no_optimize __attribute__((optnone))
# elif __GNUC__ >= 4 && __GNUC_MINOR__ >= 4
# define mmk_no_optimize __attribute__((optimize(0)))
# else
# define mmk_no_optimize
# endif

# ifndef MMK_DO_NOT_DISABLE_WARNINGS
# if defined __GNUC__
# pragma GCC diagnostic ignored "-Wunused-result"
Expand Down
4 changes: 2 additions & 2 deletions sample/strdup/test.c
Expand Up @@ -6,7 +6,7 @@

mmk_mock_define(malloc_mock, void *, size_t, size);

void test_simple_case(void)
void mmk_no_optimize test_simple_case(void)
{
static char ref[] = "hello";
char buf[sizeof (ref)];
Expand All @@ -26,7 +26,7 @@ void test_simple_case(void)
mmk_reset(malloc);
}

void test_error_case(void)
void mmk_no_optimize test_error_case(void)
{
mmk_mock("malloc@lib:strdup", malloc_mock);

Expand Down

0 comments on commit a090921

Please sign in to comment.