Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NOINLINE to a couple of test functions #41

Merged
merged 1 commit into from
Feb 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions test/msgpuck.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@
#define lengthof(array) (sizeof(array) / sizeof((array)[0]))
#endif

#ifndef __has_attribute
# define __has_attribute(x) 0
#endif

#if __has_attribute(noinline) || defined(__GNUC__)
# define NOINLINE __attribute__((noinline))
#else
# define NOINLINE
#endif

static char buf[BUF_MAXLEN + 1];
static char str[STRBIN_MAXLEN];
static char *data = buf + 1; /* use unaligned address to fail early */
Expand Down Expand Up @@ -742,7 +752,11 @@ test_next_on_maps(void)
return check_plan();
}

static bool
/**
* When inlined in Release in clang, this function behaves weird. Looking
* sometimes like if its call had no effect even though it did encoding.
*/
static NOINLINE bool
test_encode_uint_custom_size(char *buf, uint64_t val, int size)
{
char *pos;
Expand Down Expand Up @@ -779,7 +793,12 @@ test_encode_uint_custom_size(char *buf, uint64_t val, int size)
return false;
}

static bool
/**
* Unlike test_encode_uint_custom_size(), this one doesn't seem to behave
* strange when inlined, but perhaps it just wasn't used in all the same ways as
* the former.
*/
static NOINLINE bool
test_encode_int_custom_size(char *buf, int64_t val, int size)
{
char *pos;
Expand Down