#include <stdio.h>

/* from /include/linux/compiler.h */
#define likely_notrace(x)       __builtin_expect(!!(x), 1)
#define unlikely_notrace(x)     __builtin_expect(!!(x), 0)

#define likely(x)   likely_notrace(x)
#define unlikely(x) unlikely_notrace(x)

/* from include/linux/compiler-gcc4.h */
#define __must_check            __attribute__((warn_unused_result))

/* From include/linux/err.h */
#define MAX_ERRNO       4095

#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)

static inline long __must_check IS_ERR(const void *ptr)
{

	return IS_ERR_VALUE((unsigned long)ptr);
}

static inline long __must_check IS_ERR_OR_NULL(const void *ptr)
{
	return !ptr || IS_ERR_VALUE((unsigned long)ptr);
}


/* Mimic regulator_get() when CONFIG_REGULATOR is defined */
unsigned long *regulator_get_full()
{
	unsigned long *ptr;

	return ptr;
}

/* Mimic regulator_get() when CONFIG_REGULATOR is NOT defined */
unsigned long *regulator_get_stub()
{
	return NULL; /* or maybe return -ENOSYS; ? */
}

int main(void)
{
	unsigned long *vcc = NULL;

	vcc = regulator_get_full();
	if (IS_ERR(vcc))
		printf("full: IS_ERR         = true\n");
	else
		printf("full: IS_ERR         = false\n");

	if (IS_ERR_OR_NULL(vcc))
		printf("full: IS_ERR_OR_NULL = true\n");
	else
		printf("full: IS_ERR_OR_NULL = false\n");


	vcc = regulator_get_stub();
	if (IS_ERR(vcc))
		printf("stub: IS_ERR         = true\n");
	else
		printf("stub: IS_ERR         = false\n");

	if (IS_ERR_OR_NULL(vcc))
		printf("stub: IS_ERR_OR_NULL = true\n");
	else
		printf("stub: IS_ERR_OR_NULL = false\n");

	return 0;
}
