[LTP] LTP release

Cyril Hrubis chrubis@suse.cz
Wed Sep 9 15:27:03 CEST 2020


Hi!
> Also I would like to get rid of the -fno-optimize-sibling-calls in the
> Makefile, this makes the test a bit fragile and less portable.

What about this code:

#include <stdint.h>
#include <stdio.h>

static intptr_t addr_func(void) __attribute__((noinline));

static intptr_t addr_func(void)
{
	int a;

	return (intptr_t)&a;
}

/*
 * Returns negative number if stack grows down, possitive if stack grows up
 */
static int stack_dir(void)
{
	intptr_t addr = addr_func();

	printf("%p %p\n", &addr, (void*)addr);

	return addr - (intptr_t)&addr;
}

int main(void)
{
	printf("%i\n", stack_dir());

	return 0;
}

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list