ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/trunk/xvidcore/src/portab.h
Revision: 37
Committed: Sat Mar 16 22:28:37 2002 UTC (22 years, 6 months ago) by chl
Content type: text/plain
File size: 2950 byte(s)
Error occurred while calculating annotation data.
Log Message:
Disabled DEBUG-messages in Linux, if _DEBUG not set

File Contents

# Content
1 #ifndef _PORTAB_H_
2 #define _PORTAB_H_
3
4 #if defined(WIN32)
5
6 #include <windows.h>
7
8 #ifdef _DEBUG
9 #define DEBUG(S) OutputDebugString((S));
10 #define DEBUG1(S,I) { char tmp[100]; wsprintf(tmp, "%s %i\n", (S), (I)); OutputDebugString(tmp); }
11 #define DEBUG2(X,A,B) { char tmp[100]; wsprintf(tmp, "%s %i %i\n", (X), (A), (B)); OutputDebugString(tmp); }
12 #define DEBUG3(X,A,B,C){ char tmp[1000]; wsprintf(tmp,"%s %i %i %i",(X),(A), (B), (C)); OutputDebugString(tmp); }
13 #define DEBUG8(X,A,B,C,D,E,F,G,H){ char tmp[1000]; wsprintf(tmp,"%s %i %i %i %i %i %i %i %i",(X),(A),(B),(C),(D),(E),(F),(G),(H)); OutputDebugString(tmp); }
14 #else
15 #define DEBUG(S)
16 #define DEBUG1(S,I)
17 #define DEBUG2(X,A,B)
18 #define DEBUG3(X,A,B,C)
19 #define DEBUG8(X,A,B,C,D,E,F,G,H)
20 #endif
21
22
23 #define int8_t char
24 #define uint8_t unsigned char
25 #define int16_t short
26 #define uint16_t unsigned short
27 #define int32_t int
28 #define uint32_t unsigned int
29 #define int64_t __int64
30 #define uint64_t unsigned __int64
31
32 #define EMMS() __asm {emms}
33
34 // needed for bitstream.h
35 #define BSWAP(a) __asm mov eax,a __asm bswap eax __asm mov a, eax
36
37 // needed for timer.c
38 static __inline int64_t read_counter() {
39 int64_t ts;
40 uint32_t ts1, ts2;
41
42 __asm {
43 rdtsc
44 mov ts1, eax
45 mov ts2, edx
46 }
47
48 ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1);
49
50 return ts;
51 }
52
53 #elif defined(LINUX) || defined(DJGPP)
54
55
56 #ifdef _DEBUG
57
58 #include <stdio.h>
59 #define DEBUG_WHERE stdout
60 #define DEBUG(S) fprintf(DEBUG_WHERE, "%s\n", (S));
61 #define DEBUG1(S,I) fprintf(DEBUG_WHERE, "%s %i\n", (S), (I))
62 #define DEBUG2(S,A,B) fprintf(DEBUG_WHERE, "%s%i=%i\n", (S), (A), (B))
63 #define DEBUG3(S,A,B,C) fprintf(DEBUG_WHERE, "%s %i %x %x\n", (S), (A), (B), (C))
64 #define DEBUG8(S,A,B,C,D,E,F,G,H)
65 #else
66 #define DEBUG(S)
67 #define DEBUG1(S,I)
68 #define DEBUG2(X,A,B)
69 #define DEBUG3(X,A,B,C)
70 #define DEBUG8(X,A,B,C,D,E,F,G,H)
71 #endif
72
73 #if defined(LINUX)
74
75 #include <stdint.h>
76
77 #else
78
79 #define int8_t char
80 #define uint8_t unsigned char
81 #define int16_t short
82 #define uint16_t unsigned short
83 #define int32_t int
84 #define uint32_t unsigned int
85 #define int64_t long long
86 #define uint64_t unsigned long long
87
88 #endif
89
90 #define EMMS() __asm__("emms\n\t")
91
92 // needed for bitstream.h
93 #define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) )
94
95 // needed for timer.c
96 static __inline int64_t read_counter() {
97 int64_t ts;
98 uint32_t ts1, ts2;
99
100 __asm__ __volatile__("rdtsc\n\t":"=a"(ts1), "=d"(ts2));
101
102 ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1);
103
104 return ts;
105 }
106
107 #else // OTHER OS
108
109 #define DEBUG(S)
110 #define DEBUG1(S,I)
111 #define DEBUG2(X,A,B)
112 #define DEBUG3(X,A,B,C)
113 #define DEBUG8(X,A,B,C,D,E,F,G,H)
114
115 #include <inttypes.h>
116
117 #define EMMS()
118
119 // needed for bitstream.h
120 #define BSWAP(a) \
121 ((a) = ( ((a)&0xff)<<24) | (((a)&0xff00)<<8) | (((a)>>8)&0xff00) | (((a)>>24)&0xff))
122
123 // rdtsc command most likely not supported,
124 // so just dummy code here
125 static __inline int64_t read_counter() {
126 return 0;
127 }
128
129 #endif
130
131 #endif // _PORTAB_H_
132