Runtime routines implementing print<TYPE> for all basic types.
[oota-llvm.git] / test / runtime.c
1 #include <stdio.h>
2 #include <sys/types.h>
3
4 void
5 printSByte(char c)
6 {
7   putchar(c);
8 }
9
10 void
11 printUByte(unsigned char c)
12 {
13   putchar(c);
14 }
15
16 void
17 printShort(short i)
18 {
19   printf("%d", i);
20 }
21
22 void
23 printUShort(unsigned short i)
24 {
25   printf("%d", i);
26 }
27
28 void
29 printInt(int i)
30 {
31   printf("%d", i);
32 }
33
34 void
35 printUInt(unsigned int i)
36 {
37   printf("%d", i);
38 }
39
40 void
41 printLong(int64_t l)
42 {
43   printf("%d", l);
44 }
45
46 void
47 printULong(uint64_t l)
48 {
49   printf("%d", l);
50 }
51
52 void
53 printString(const char* str)
54 {
55   printf("%s", str);
56 }
57
58 void
59 printFloat(float f)
60 {
61   printf("%g", f);
62 }
63
64 void
65 printDouble(double d)
66 {
67   printf("%g", d);
68 }
69
70 #undef  TEST_RUNTIME
71 #ifdef  TEST_RUNTIME
72 int
73 main(int argc, char** argv)
74 {
75   int i;
76   printString("argc = ");
77   printLong(argc);
78   printString(" = (as float) ");
79   printFloat(argc);
80   printString(" = (as double) ");
81   printDouble(argc);
82   for (i=0; i < argc; i++)
83     {
84       printString("\nargv[");
85       printLong(i);
86       printString("] = ");
87       printString(argv[i]);
88     }
89   printString("\n");
90 }
91 #endif