longlong.c 1.21 KB
#include <rmon.h>
#include "corefunc.h"

longlong()
{
	int numFailures = 0;
	long long a, b;
	unsigned long long c, d;
	int i, j;
	long long arr[4];
	long long arri[2] = {0x100001000LL, 3};
	struct rec {
		int one;
		long long two;
	} vrec;

	numFailures += check_equal(sizeof(long long), 8);
	numFailures += check_equal(__builtin_alignof(long long), 8);
	a = 0x10000000aLL;
	b = a;
	b++;
	d = b - 1;
	numFailures += check_equal(a, d);
	c = a + b;
	numFailures += check_equal(c, 0x200000015LLU);
	i = 5;
	b = i * 2;
	b = -b;
	numFailures += check_equal(b, -10);
	a >>= 30;
	numFailures += check_equal(a, 4);
	a = a << 1;
	numFailures += check_equal(a, 8);
	b = a % 5;
	numFailures += check_equal(b, 3);
	arr[0] = arri[1];
	arr[3] = arr[0];
	a = arr[3];
	numFailures += check_equal(a, 3);
	vrec.one = 1;
	a--;
	vrec.two = a;
	numFailures += check_equal(vrec.two, 2LL);
	c = 1 << ((a < 3 ? 1 : 3)*4%3+1); 
	numFailures += check_equal(c, 4LLU);
	c ^= 1;
	/* c == 5 */
	c = ~c & (c | 2);
	numFailures += check_equal(c, 2);
	switch (b) {
	case 0:
		osSyncPrintf("longlong switch 0 fail\n");
		numFailures++;
		break;

	case 3LL:
		break;
	default:
		osSyncPrintf("longlong switch fail\n");
		numFailures++;
		break;
	}
	return(numFailures);
}