#include <sys/cdefs.h>

#include <stdio.h>

#include <test.h>
#include "internal.h"

#define	VERSION	"5.0"

//PRIVATESYM(one,TEST_5_PRIVATE)
__asm(".symver one,one@TEST_5_PRIVATE");
__attribute__((visibility("default")))
int one = 1;

__asm(".symver __thyme00,__thyme00@TEST_BASE");
__typeof(thyme) __thyme00 __attribute__((alias("thyme")));

//EXPORT
__attribute__((visibility("default")))
thyme_t
thyme(thyme_t *p)
{
	thyme_t t = (thyme_t)0x0123456789abcdefULL;

	if (p)
		*p = t;
	return t;
}

//HIDDEN
__attribute__((visibility("hidden")))
long
i(long y, long d)
{
	printf("%s %s:%d i_long(%lx, %ld)\n", VERSION, __FILE__, __LINE__, y, d);
	return y + d;
}

//EXPORT
__attribute__((visibility("default")))
long
f(long x)
{
	printf("%s %s:%d f_long(%lx)\n", VERSION, __FILE__, __LINE__, x);
	return i(x << 8, one);
}

//HIDDEN
__attribute__((visibility("hidden")))
long
h(long x)
{
	printf("%s %s:%d h_long(%lx)\n", VERSION, __FILE__, __LINE__, x);
	return x >> 8;
}

//EXPORT
__attribute__((visibility("default")))
int
g(int x)
{
	printf("%s %s:%d g(%x)\n", VERSION, __FILE__, __LINE__, x);
	return h(f(x));
}