mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
Remove obsolete tests which:
A. do not just test LLC, or even the sparc backend B. are cut down versions of tests that exist in other places git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8821 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
44ae86aaf9
commit
4f8ede9e10
@ -1,74 +0,0 @@
|
||||
/*
|
||||
* Program: llc
|
||||
*
|
||||
* Test Name: badfuncptr.c
|
||||
*
|
||||
* Test Problem:
|
||||
* Indirect call via function pointer is mishandled in reg. alloc.
|
||||
* The indirect call address was allocated the same register as the
|
||||
* first outgoing argument, so it was overwritten before the call.
|
||||
*
|
||||
* Test Resolution:
|
||||
* In PhyRegAlloc.cpp, mark the live range for the indirect call
|
||||
* address as having a Call Interference. This has to be done
|
||||
* as a special case since it may not be live after the call.
|
||||
*
|
||||
* Resolution Status:
|
||||
* Fixed on 3/29/02 -- Adve.
|
||||
*/
|
||||
/* For copyright information, see olden_v1.0/COPYRIGHT */
|
||||
|
||||
#include <stdlib.h>
|
||||
/* #include "hash.h" */
|
||||
/*--------*/
|
||||
/* hash.h */
|
||||
/*--------*/
|
||||
/* For copyright information, see olden_v1.0/COPYRIGHT */
|
||||
|
||||
#include "stdio.h"
|
||||
|
||||
typedef struct hash_entry {
|
||||
unsigned int key;
|
||||
void *entry;
|
||||
struct hash_entry *next;
|
||||
} *HashEntry;
|
||||
|
||||
typedef struct hash {
|
||||
HashEntry *array;
|
||||
int (*mapfunc)(unsigned int);
|
||||
int size;
|
||||
} *Hash;
|
||||
|
||||
Hash MakeHash(int size, int (*map)(unsigned int));
|
||||
void *HashLookup(unsigned int key, Hash hash);
|
||||
void HashInsert(void *entry,unsigned int key, Hash hash);
|
||||
void HashDelete(unsigned int key, Hash hash);
|
||||
/*--------*/
|
||||
/* END hash.h */
|
||||
/*--------*/
|
||||
|
||||
#define assert(num,a) if (!(a)) {printf("Assertion failure:%d in hash\n",num); exit(-1);}
|
||||
|
||||
void *HashLookup(unsigned int key, Hash hash)
|
||||
{
|
||||
int j;
|
||||
HashEntry ent;
|
||||
|
||||
j = (hash->mapfunc)(key); /* 14% miss in hash->mapfunc */
|
||||
assert(1,j>=0);
|
||||
assert(2,j<hash->size);
|
||||
for (ent = hash->array[j]; /* 17% miss in hash->array[j] */ /* adt_pf can't detect :( */
|
||||
ent && /* 47% miss in ent->key */ /* adt_pf can detect :) */
|
||||
ent->key!=key;
|
||||
ent=ent->next); /* 8% miss in ent->next */ /* adt_pf can detect :) */
|
||||
if (ent) return ent->entry;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* essentially dummy main so testing does not fail */
|
||||
int
|
||||
main()
|
||||
{
|
||||
printf("&HashLookup = %d\n", !!HashLookup);
|
||||
return 0;
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
/* -*- mode: c -*-
|
||||
* $Id$
|
||||
* http://www.bagley.org/~doug/shootout/
|
||||
*
|
||||
* this program is modified from:
|
||||
* http://cm.bell-labs.com/cm/cs/who/bwk/interps/pap.html
|
||||
* Timing Trials, or, the Trials of Timing: Experiments with Scripting
|
||||
* and User-Interface Languages</a> by Brian W. Kernighan and
|
||||
* Christopher J. Van Wyk.
|
||||
*
|
||||
* I added free() to deallocate memory.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
int i, n = ((argc == 2) ? atoi(argv[1]) : 1);
|
||||
int *y = (int *) calloc(n, sizeof(int));
|
||||
for (i=0; i < n; i++)
|
||||
y[i] = i*i;
|
||||
printf("%d\n", y[n-1]);
|
||||
return(0);
|
||||
}
|
||||
|
@ -1,79 +0,0 @@
|
||||
/*===- test/Regression/Transforms/Scalar/DecomposeMultiDimRefs.cpp -----=*
|
||||
*
|
||||
* This is a feature test that checks for correct code generation
|
||||
* of the SAVE instruction when the stack size does not fit in the
|
||||
* immediate field of the SAVE instruction. This happens in main().
|
||||
*===---------------------------------------------------------------------===*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
typedef struct Flat_struct {
|
||||
char c;
|
||||
float x;
|
||||
} Flat_t;
|
||||
|
||||
typedef struct Mixed_struct {
|
||||
int N;
|
||||
double A[10];
|
||||
double B[10][10];
|
||||
Flat_t F[10];
|
||||
} Mixed_t;
|
||||
|
||||
|
||||
double
|
||||
AddMixed(Mixed_t* M)
|
||||
{
|
||||
double sum = 0;
|
||||
int i, j;
|
||||
|
||||
for (i=0; i < 10; ++i)
|
||||
sum += M->A[i];
|
||||
|
||||
for (i=0; i < 10; ++i)
|
||||
for (j=0; j < 10; ++j)
|
||||
sum += M->B[i][j];
|
||||
|
||||
for (i=0; i < 10; ++i) {
|
||||
sum += (double) M->F[i].c;
|
||||
sum += M->F[i].x;
|
||||
}
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
void
|
||||
InitializeMixed(Mixed_t* M, int base)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
for (i=0; i < 10; ++i)
|
||||
M->A[i] = i + base;
|
||||
|
||||
for (i=0; i < 10; ++i)
|
||||
for (j=0; j < 10; ++j)
|
||||
M->B[i][j] = i*10 + j + base;
|
||||
|
||||
for (i=0; i < 10; ++i) {
|
||||
M->F[i].c = 'Q';
|
||||
M->F[i].x = i / 10 + base;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
Mixed_t M;
|
||||
Mixed_t MA[4];
|
||||
int i;
|
||||
|
||||
InitializeMixed(&M, 100);
|
||||
printf("Sum(M) = %.2f\n", AddMixed(&M));
|
||||
|
||||
for (i=0; i < 4; i++) {
|
||||
InitializeMixed(&MA[i], 100 * (i+2));
|
||||
printf("Sum(MA[%d]) = %.2f\n", i, AddMixed(&MA[i]));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,156 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
|
||||
#undef LLVM_CAN_PASS_STRUCTS_BY_VALUE
|
||||
#ifdef LLVM_CAN_PASS_STRUCTS_BY_VALUE
|
||||
typedef struct SmallStruct_struct {
|
||||
char c1, c2, c3, c4;
|
||||
int n;
|
||||
} SmallStruct;
|
||||
|
||||
|
||||
typedef struct BigStruct_struct {
|
||||
char c1, c2, c3, c4;
|
||||
double d1, d2; /* Note: d1 will need padding */
|
||||
int n;
|
||||
struct BigStruct_struct* next; /* Note: next will need padding */
|
||||
} BigStruct;
|
||||
|
||||
|
||||
SmallStruct
|
||||
printStructArgs(SmallStruct s1, /* Could fit in reg */
|
||||
int a1, float a2, char a3, double a4, char* a5,
|
||||
BigStruct s2, /* Must go on stack */
|
||||
int a6, float a7, char a8, double a9, char* a10,
|
||||
SmallStruct s3, /* Probably no available regs */
|
||||
int a11, float a12, char a13, double a14, char* a15)
|
||||
{
|
||||
SmallStruct result;
|
||||
|
||||
printf("\nprintStructArgs with 13 arguments:\n");
|
||||
printf("\tArg 1 : %c %c %c %c %d\n", s1.c1, s1.c2, s1.c3, s1.c4, s1.n);
|
||||
printf("\tArgs 2-6 : %d %f %c %lf %c\n", a1, a2, a3, a4, *a5);
|
||||
printf("\tArg 7 : %c %c %c %c %lf %lf %d %p\n",
|
||||
s2.c1, s2.c2, s2.c3, s2.c4, s2.d1, s2.d2, s2.n,s2.next);
|
||||
printf("\tArg 8 : %c %c %c %c %d\n", s3.c1, s3.c2, s3.c3, s3.c4, s3.n);
|
||||
printf("\tArgs 9-13 : %d %f %c %lf %c\n", a6, a7, a8, a9, *a10);
|
||||
printf("\tArgs 14-18: %d %f %c %lf %c\n", a11, a12, a13, a14, *a15);
|
||||
printf("\n");
|
||||
|
||||
result.c1 = s2.c1;
|
||||
result.c2 = s2.c2;
|
||||
result.c3 = s2.c3;
|
||||
result.c4 = s2.c4;
|
||||
result.n = s2.n;
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif /* LLVM_CAN_PASS_STRUCTS_BY_VALUE */
|
||||
|
||||
#undef LLC_SUPPORTS_VARARGS_FUNCTIONS
|
||||
#ifdef LLC_SUPPORTS_VARARGS_FUNCTIONS
|
||||
void
|
||||
printVarArgs(int a1, ...)
|
||||
{
|
||||
double a2, a7, a12; /* float is promoted to double! */
|
||||
int a3, a8, a13; /* char is promoted to int! */
|
||||
double a4, a9, a14;
|
||||
char *a5, *a10, *a15;
|
||||
int a6, a11;
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, a1);
|
||||
a2 = va_arg(ap, double);
|
||||
a3 = va_arg(ap, int);
|
||||
a4 = va_arg(ap, double);
|
||||
a5 = va_arg(ap, char*);
|
||||
|
||||
a6 = va_arg(ap, int);
|
||||
a7 = va_arg(ap, double);
|
||||
a8 = va_arg(ap, int);
|
||||
a9 = va_arg(ap, double);
|
||||
a10 = va_arg(ap, char*);
|
||||
|
||||
a11 = va_arg(ap, int);
|
||||
a12 = va_arg(ap, double);
|
||||
a13 = va_arg(ap, int);
|
||||
a14 = va_arg(ap, double);
|
||||
a15 = va_arg(ap, char*);
|
||||
|
||||
printf("\nprintVarArgs with 15 arguments:\n");
|
||||
printf("\tArgs 1-5 : %d %f %c %lf %c\n", a1, a2, a3, a4, *a5);
|
||||
printf("\tArgs 6-10 : %d %f %c %lf %c\n", a6, a7, a8, a9, *a10);
|
||||
printf("\tArgs 11-14: %d %f %c %lf %c\n", a11, a12, a13, a14, *a15);
|
||||
printf("\n");
|
||||
return;
|
||||
}
|
||||
#endif /* LLC_SUPPORTS_VARARGS_FUNCTIONS */
|
||||
|
||||
|
||||
void
|
||||
printArgsNoRet(int a1, float a2, char a3, double a4, char* a5,
|
||||
int a6, float a7, char a8, double a9, char* a10,
|
||||
int a11, float a12, char a13, double a14, char* a15)
|
||||
{
|
||||
printf("\nprintArgsNoRet with 15 arguments:\n");
|
||||
printf("\tArgs 1-5 : %d %f %c %lf %c\n", a1, a2, a3, a4, *a5);
|
||||
printf("\tArgs 6-10 : %d %f %c %lf %c\n", a6, a7, a8, a9, *a10);
|
||||
printf("\tArgs 11-14: %d %f %c %lf %c\n", a11, a12, a13, a14, *a15);
|
||||
printf("\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
#ifdef LLVM_CAN_PASS_STRUCTS_BY_VALUE
|
||||
SmallStruct s1, s3, result;
|
||||
BigStruct s2;
|
||||
#endif /* LLVM_CAN_PASS_STRUCTS_BY_VALUE */
|
||||
|
||||
printArgsNoRet(1, 2.1, 'c', 4.1, "e",
|
||||
6, 7.1, 'h', 9.1, "j",
|
||||
11, 12.1, 'm', 14.1, "o");
|
||||
|
||||
#ifdef LLC_SUPPORTS_VARARGS_FUNCTIONS
|
||||
printVarArgs(1, 2.2, 'c', 4.2, "e",
|
||||
6, 7.2, 'h', 9.2, "j",
|
||||
11, 12.2, 'm', 14.2, "o");
|
||||
#endif /* LLC_SUPPORTS_VARARGS_FUNCTIONS */
|
||||
|
||||
#ifdef LLVM_CAN_PASS_STRUCTS_BY_VALUE
|
||||
s1.c1 = 'a';
|
||||
s1.c2 = 'b';
|
||||
s1.c3 = 'c';
|
||||
s1.c4 = 'd';
|
||||
s1.n = 111;
|
||||
|
||||
s2.c1 = 'h';
|
||||
s2.c2 = 'i';
|
||||
s2.c3 = 'j';
|
||||
s2.c4 = 'k';
|
||||
s2.d1 = 1.1;
|
||||
s2.d2 = 2.2;
|
||||
s2.n = 222;
|
||||
s2.next = &s2;
|
||||
|
||||
s3.c1 = 'w';
|
||||
s3.c2 = 'x';
|
||||
s3.c3 = 'y';
|
||||
s3.c4 = 'z';
|
||||
s3.n = 333;
|
||||
|
||||
result = printStructArgs(s1,
|
||||
1, 2.0, 'c', 4.0, "e",
|
||||
s2,
|
||||
6, 7.0, 'h', 9.0, "j",
|
||||
s3);
|
||||
|
||||
printf("\nprintStructArgs returns:\n\t%c %c %c %c %d\n\n",
|
||||
result.c1, result.c2, result.c3, result.c4, result.n);
|
||||
#endif /* LLVM_CAN_PASS_STRUCTS_BY_VALUE */
|
||||
|
||||
return 0;
|
||||
}
|
126
test/LLC/casts.c
126
test/LLC/casts.c
@ -1,126 +0,0 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define __STDC_LIMIT_MACROS 1
|
||||
#include <inttypes.h>
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
int8_t C, c1;
|
||||
uint8_t uc1;
|
||||
|
||||
short S, s1;
|
||||
unsigned short us1;
|
||||
|
||||
int i1;
|
||||
unsigned ui1;
|
||||
|
||||
int64_t L, l1;
|
||||
uint64_t ul1;
|
||||
|
||||
float F;
|
||||
double D;
|
||||
|
||||
/* input values */
|
||||
C = (char) (argc >= 2)? atoi(argv[1]) : 0x64; /* 100 = 'd' */
|
||||
S = (short) (argc >= 3)? atoi(argv[2]) : -769; /* 0xfcff = -769 */
|
||||
L = (long) (argc >= 4)? atoi(argv[3]) : 0xa3a3a3a3a3a3; /*179923220407203*/
|
||||
|
||||
/* Test integer to integer conversions */
|
||||
uc1 = (uint8_t) C; /* 100 = 'd' */
|
||||
us1 = (unsigned short) C; /* 100 = 'd' */
|
||||
ui1 = (unsigned int) C; /* 100 = 'd' */
|
||||
ul1 = (unsigned long) C; /* 100 = 'd' */
|
||||
|
||||
s1 = (short) C; /* 100 = 'd' */
|
||||
i1 = (int) C; /* 100 = 'd' */
|
||||
l1 = (long) C; /* 100 = 'd' */
|
||||
|
||||
printf("\nCHAR C = '%c' (%d)\t\t(0x%x)\n", C, C, C);
|
||||
printf("char to short s1 = %d\t\t(0x%x)\n", s1, s1);
|
||||
printf("char to int i1 = %d\t\t(0x%x)\n", i1, i1);
|
||||
printf("char to long l1 = %ld\t\t(0x%lx)\n", l1, l1);
|
||||
|
||||
printf("\nchar to ubyte uc1 = %u\t\t(0x%x)\n", uc1, uc1);
|
||||
printf("char to ushort us1 = %u\t\t(0x%x)\n", us1, us1);
|
||||
printf("char to uint ui1 = %u\t\t(0x%x)\n", ui1, ui1);
|
||||
printf("char to ulong ul1 = %lu\t\t(0x%lx)\n", ul1, ul1);
|
||||
|
||||
uc1 = (uint8_t) S; /* 0xff = 255 */
|
||||
us1 = (unsigned short) S; /* 0xfcff = 64767 */
|
||||
ui1 = (unsigned int) S; /* 0xfffffcff = 4294966527 */
|
||||
ul1 = (unsigned long) S; /* */
|
||||
|
||||
c1 = (int8_t) S; /* 0xff = -1 */
|
||||
i1 = (int) S; /* 0xfffffcff = -769 */
|
||||
l1 = (long) S; /* */
|
||||
|
||||
printf("\n\nSHORT S = %d\t\t(0x%x)\n", S, S);
|
||||
printf("short to byte c1 = %d\t\t(0x%x)\n", c1, c1);
|
||||
printf("short to int i1 = %d\t\t(0x%x)\n", i1, i1);
|
||||
printf("short to long l1 = %ld\t\t(0x%lx)\n", l1, l1);
|
||||
|
||||
printf("\nshort to ubyte uc1 = %u\t\t(0x%x)\n", uc1, uc1);
|
||||
printf("short to ushort us1 = %u\t\t(0x%x)\n", us1, us1);
|
||||
printf("short to uint ui1 = %u\t\t(0x%x)\n", ui1, ui1);
|
||||
printf("short to ulong ul1 = %lu\t\t(0x%lx)\n", ul1, ul1);
|
||||
|
||||
uc1 = (unsigned char) L; /* */
|
||||
c1 = (int8_t) L; /* */
|
||||
s1 = (short) L; /* */
|
||||
us1 = (unsigned short) L; /* */
|
||||
i1 = (int) L; /* */
|
||||
ui1 = (unsigned int) L; /* */
|
||||
ul1 = (unsigned long) L; /* */
|
||||
|
||||
printf("\n\nLONG L = %ld\t\t(0x%lx)\n", L, L);
|
||||
printf("long to byte c1 = %d\t\t(0x%x)\n", c1, c1);
|
||||
printf("long to short s1 = %d\t\t(0x%x)\n", s1, s1);
|
||||
printf("long to int i1 = %d\t\t(0x%x)\n", i1, i1);
|
||||
|
||||
printf("\nlong to ubyte uc1 = %u\t\t(0x%x)\n", uc1, uc1);
|
||||
printf("long to ushort us1 = %u\t\t(0x%x)\n", us1, us1);
|
||||
printf("long to uint ui1 = %u\t\t(0x%x)\n", ui1, ui1);
|
||||
printf("long to ulong ul1 = %lu\t\t(0x%lx)\n", ul1, ul1);
|
||||
|
||||
/* Test floating-point to integer conversions */
|
||||
F = (float) (argc >= 4)? atof(argv[3]) : 1.0;
|
||||
D = (argc >= 5)? atof(argv[4]) : 2.0;
|
||||
|
||||
us1 = (unsigned short) F;
|
||||
ui1 = (unsigned int) F;
|
||||
ul1 = (unsigned long) F;
|
||||
|
||||
s1 = (short) F;
|
||||
i1 = (int) F;
|
||||
l1 = (long) F;
|
||||
|
||||
printf("\n\nFLOAT F = %f\n", F);
|
||||
printf("float to short s1 = %d\t\t(0x%x)\n", s1, s1);
|
||||
printf("float to int i1 = %d\t\t(0x%x)\n", i1, i1);
|
||||
|
||||
printf("float to ushort us1 = %u\t\t(0x%x)\n", us1, us1);
|
||||
printf("float to uint ui1 = %u\t\t(0x%x)\n", ui1, ui1);
|
||||
printf("float to ulong ul1 = %lu\t\t(0x%lx)\n", ul1, ul1);
|
||||
|
||||
us1 = (unsigned short) D;
|
||||
ui1 = (unsigned int) D;
|
||||
ul1 = (unsigned long) D;
|
||||
|
||||
s1 = (short) D;
|
||||
i1 = (int) D;
|
||||
l1 = (long) D;
|
||||
|
||||
printf("\n\nDOUBLE D = %f\n", D);
|
||||
printf("double to short s1 = %d\t\t(0x%x)\n", s1, s1);
|
||||
printf("double to int i1 = %d\t\t(0x%x)\n", i1, i1);
|
||||
printf("double to long l1 = %ld\t\t(0x%lx)\n", l1, l1);
|
||||
|
||||
printf("double to ushort us1 = %u\t\t(0x%x)\n", us1, us1);
|
||||
printf("double to uint ui1 = %u\t\t(0x%x)\n", ui1, ui1);
|
||||
printf("double to ulong ul1 = %lu\t\t(0x%lx)\n", ul1, ul1);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
/* globalrefs.c - Test symbolic constant expressions constructed from
|
||||
* global addresses and index expressions into global addresses.
|
||||
* Do this both with global constants and with inline constant.
|
||||
* Instead of printing absolute addresses, print out the differences in
|
||||
* memory addresses to get output that matches that of the native compiler.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define __STDC_LIMIT_MACROS 1
|
||||
#include <inttypes.h>
|
||||
|
||||
struct test {
|
||||
long A;
|
||||
struct { unsigned X; unsigned Y; } S;
|
||||
struct test* next;
|
||||
};
|
||||
|
||||
struct test TestArray[10];
|
||||
struct test Test1;
|
||||
|
||||
/* Create global symbolic constants from the addresses of the above globals */
|
||||
|
||||
struct test* TestArrayPtr = &TestArray[3];
|
||||
long* Aptr = &Test1.A;
|
||||
unsigned* Yptr = &Test1.S.Y;
|
||||
struct test** NextPtr = &Test1.next;
|
||||
|
||||
void
|
||||
printdiff(void* p1, void* p2)
|
||||
{
|
||||
printf(" 0x%lx", (unsigned long) p1 - (unsigned long) p2);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
unsigned long diff1, diff2, diff3, diff4;
|
||||
|
||||
printf("sizeof(struct Test) = %llu\n\n", sizeof(struct test));
|
||||
|
||||
printdiff(&TestArray[3], TestArray);
|
||||
printdiff(&Test1.A, &TestArray[3]);
|
||||
printdiff(&Test1.S.Y, &Test1.A);
|
||||
printdiff(&Test1.next, &Test1.S.Y);
|
||||
printf("\n");
|
||||
|
||||
diff1 = (unsigned long) &TestArray[3] - (unsigned long) TestArray;
|
||||
diff2 = (unsigned long) &Test1.A - (unsigned long) &TestArray[3];
|
||||
diff3 = (unsigned long) &Test1.S.Y - (unsigned long) &Test1.A;
|
||||
diff4 = (unsigned long) &Test1.next - (unsigned long) &Test1.S.Y;
|
||||
|
||||
printf("&TestArray[3] - TestArray = 0x%lx\n", diff1);
|
||||
printf("Aptr - &TestArray[3] = 0x%lx\n", diff2);
|
||||
printf("Xptr - Aptr = 0x%lx\n", diff3);
|
||||
printf("NextPtr - Xptr = 0x%lx\n\n", diff4);
|
||||
|
||||
diff1 = (unsigned long) TestArrayPtr - (unsigned long) TestArray;
|
||||
diff2 = (unsigned long) Aptr - (unsigned long) TestArrayPtr;
|
||||
diff3 = (unsigned long) Yptr - (unsigned long) Aptr;
|
||||
diff4 = (unsigned long) NextPtr - (unsigned long) Yptr;
|
||||
|
||||
printf("&TestArray[3] - TestArray = 0x%lx\n", diff1);
|
||||
printf("Aptr - &TestArray[3] = 0x%lx\n", diff2);
|
||||
printf("Xptr - Aptr = 0x%lx\n", diff3);
|
||||
printf("NextPtr - Xptr = 0x%lx\n\n", diff4);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
/* For copyright information, see olden_v1.0/COPYRIGHT */
|
||||
|
||||
/**********************************************************
|
||||
* poisson.c: handles math routines for health.c *
|
||||
**********************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
/* From health.h */
|
||||
#define IA 16807
|
||||
#define IM 2147483647
|
||||
#define AM (1.0 / IM)
|
||||
#define IQ 127773
|
||||
#define IR 2836
|
||||
#define MASK 123459876
|
||||
|
||||
float my_rand(long idum)
|
||||
{
|
||||
long k;
|
||||
float answer;
|
||||
|
||||
idum ^= MASK;
|
||||
k = idum / IQ;
|
||||
idum = IA * (idum - k * IQ) - IR * k;
|
||||
idum ^= MASK;
|
||||
if (idum < 0)
|
||||
idum += IM;
|
||||
answer = AM * idum;
|
||||
return answer;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
printf("my_rand(%d) = %g\n", 2555540, my_rand(2555540));
|
||||
printf("my_rand(%d) = %g\n", 2427763, my_rand(2427763));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1,44 +0,0 @@
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
* Test routines for testing the tracing code.
|
||||
*/
|
||||
|
||||
struct DummyStruct {
|
||||
struct DummyStruct* next;
|
||||
int seqnum;
|
||||
};
|
||||
|
||||
int
|
||||
AddCounts(struct DummyStruct* S1,
|
||||
struct DummyStruct* S2,
|
||||
struct DummyStruct* S3, int noPrint)
|
||||
{
|
||||
if (!noPrint)
|
||||
printf("&S1 = %p\t&S2 = %p\t&S3 = %p\n", S1, S2, S3);
|
||||
return S1->seqnum + S2->seqnum + S3->seqnum;
|
||||
}
|
||||
|
||||
void
|
||||
testAllocaOrder(int noPrint)
|
||||
{
|
||||
static int count = 0;
|
||||
struct DummyStruct S1, S2, S3;
|
||||
|
||||
S1.seqnum = ++count;
|
||||
S2.seqnum = ++count;
|
||||
S3.seqnum = ++count;
|
||||
|
||||
printf("sum = %d\n", AddCounts(&S1, &S2, &S3, noPrint));
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
unsigned int i, noPrint = 1;
|
||||
if (argc > 1 && ! strcmp(argv[1], "-d"))
|
||||
noPrint = 0;
|
||||
for (i=0; i < 10; ++i)
|
||||
testAllocaOrder(noPrint);
|
||||
return 0;
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define A 16807.0
|
||||
#define M 2147483647.0
|
||||
|
||||
/*
|
||||
* This function calls floor() which does not have a prototype.
|
||||
* Test that the argument to floor is passed correctly.
|
||||
*/
|
||||
double
|
||||
my_rand(double seed)
|
||||
{
|
||||
double t = A*seed + 1;
|
||||
double floor();
|
||||
|
||||
seed = t - (M * floor(t / M)); /* t%M if t > M; t otherwise */
|
||||
return seed;
|
||||
|
||||
} /* end of random */
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
double seed = 123 * ((argc > 1)? atof(argv[1]) : 3.1415926);
|
||||
printf("my_rand(%lf) = %lf\n", seed, my_rand(seed));
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user