Vikram S. Adve | 0b12f2b | 2001-11-05 00:48:27 +0000 | [diff] [blame^] | 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 | void |
| 71 | printPointer(void* p) |
| 72 | { |
| 73 | printf("0x%x", p); |
| 74 | } |
| 75 | |
| 76 | #undef TEST_RUNTIME |
| 77 | #ifdef TEST_RUNTIME |
| 78 | int |
| 79 | main(int argc, char** argv) |
| 80 | { |
| 81 | int i; |
| 82 | printString("argc = "); |
| 83 | printLong(argc); |
| 84 | printString(" = (as float) "); |
| 85 | printFloat(argc * 1.0); |
| 86 | printString(" = (as double) "); |
| 87 | printDouble(argc * 1.0); |
| 88 | for (i=0; i < argc; i++) |
| 89 | { |
| 90 | printString("\nargv["); |
| 91 | printLong(i); |
| 92 | printString("] = "); |
| 93 | printString(argv[i]); |
| 94 | printString("\t@ "); |
| 95 | printPointer(argv[i]); |
| 96 | } |
| 97 | printString("\n"); |
| 98 | } |
| 99 | #endif |