wined3d: Move PARAM C[] program.env[] into baseshader and out of vertex shaders.
[wine] / dlls / ntdll / misc.c
1 /*
2  * Helper functions for ntdll
3  *
4  * Copyright 2000 Juergen Schmied
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include "config.h"
22
23 #include <time.h>
24 #include <math.h>
25
26 #include "wine/debug.h"
27 #include "ntdll_misc.h"
28
29 WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
30
31 #if defined(__GNUC__) && defined(__i386__)
32 #define DO_FPU(x,y) __asm__ __volatile__( x " %0;fwait" : "=m" (y) : )
33 #define POP_FPU(x) DO_FPU("fstpl",x)
34 #endif
35
36 void dump_ObjectAttributes (const OBJECT_ATTRIBUTES *oa)
37 {
38         if (oa)
39           TRACE("%p:(name=%s, attr=0x%08lx, hRoot=%p, sd=%p)\n",
40             oa, debugstr_us(oa->ObjectName),
41             oa->Attributes, oa->RootDirectory, oa->SecurityDescriptor);
42 }
43
44 LPCSTR debugstr_us( const UNICODE_STRING *us )
45 {
46     if (!us) return "<null>";
47     return debugstr_wn(us->Buffer, us->Length / sizeof(WCHAR));
48 }
49
50 /*********************************************************************
51  *                  _ftol   (NTDLL.@)
52  *
53  * VERSION
54  *      [GNUC && i386]
55  */
56 #if defined(__GNUC__) && defined(__i386__)
57 LONGLONG __cdecl NTDLL__ftol(void)
58 {
59         /* don't just do DO_FPU("fistp",retval), because the rounding
60          * mode must also be set to "round towards zero"... */
61         double fl;
62         POP_FPU(fl);
63         return (LONGLONG)fl;
64 }
65 #endif /* defined(__GNUC__) && defined(__i386__) */
66
67 /*********************************************************************
68  *                  _ftol   (NTDLL.@)
69  *
70  * FIXME
71  *      Should be register function
72  * VERSION
73  *      [!GNUC && i386]
74  */
75 #if !defined(__GNUC__) && defined(__i386__)
76 LONGLONG __cdecl NTDLL__ftol(double fl)
77 {
78         FIXME("should be register function\n");
79         return (LONGLONG)fl;
80 }
81 #endif /* !defined(__GNUC__) && defined(__i386__) */
82
83 /*********************************************************************
84  *                  _ftol   (NTDLL.@)
85  * VERSION
86  *      [!i386]
87  */
88 #ifndef __i386__
89 LONG __cdecl NTDLL__ftol(double fl)
90 {
91         return (LONG) fl;
92 }
93 #endif /* !defined(__i386__) */
94
95 /*********************************************************************
96  *                  _CIpow   (NTDLL.@)
97  * VERSION
98  *      [GNUC && i386]
99  */
100 #if defined(__GNUC__) && defined(__i386__)
101 double __cdecl NTDLL__CIpow(void)
102 {
103         double x,y;
104         POP_FPU(y);
105         POP_FPU(x);
106         return pow(x,y);
107 }
108 #endif /* defined(__GNUC__) && defined(__i386__) */
109
110
111 /*********************************************************************
112  *                  _CIpow   (NTDLL.@)
113  *
114  * FIXME
115  *      Should be register function
116  *
117  * VERSION
118  *      [!GNUC && i386]
119  */
120 #if !defined(__GNUC__) && defined(__i386__)
121 double __cdecl NTDLL__CIpow(double x,double y)
122 {
123         FIXME("should be register function\n");
124         return pow(x,y);
125 }
126 #endif /* !defined(__GNUC__) && defined(__i386__) */
127
128 /*********************************************************************
129  *                  _CIpow   (NTDLL.@)
130  * VERSION
131  *      [!i386]
132  */
133 #ifndef __i386__
134 double __cdecl NTDLL__CIpow(double x,double y)
135 {
136         return pow(x,y);
137 }
138 #endif /* !defined(__i386__) */
139
140
141 /*********************************************************************
142  *                  abs   (NTDLL.@)
143  */
144 int NTDLL_abs( int i )
145 {
146     return abs( i );
147 }
148
149 /*********************************************************************
150  *                  labs   (NTDLL.@)
151  */
152 long int NTDLL_labs( long int i )
153 {
154     return labs( i );
155 }
156
157 /*********************************************************************
158  *                  atan   (NTDLL.@)
159  */
160 double NTDLL_atan( double d )
161 {
162     return atan( d );
163 }
164
165 /*********************************************************************
166  *                  ceil   (NTDLL.@)
167  */
168 double NTDLL_ceil( double d )
169 {
170     return ceil( d );
171 }
172
173 /*********************************************************************
174  *                  cos   (NTDLL.@)
175  */
176 double NTDLL_cos( double d )
177 {
178     return cos( d );
179 }
180
181 /*********************************************************************
182  *                  fabs   (NTDLL.@)
183  */
184 double NTDLL_fabs( double d )
185 {
186     return fabs( d );
187 }
188
189 /*********************************************************************
190  *                  floor   (NTDLL.@)
191  */
192 double NTDLL_floor( double d )
193 {
194     return floor( d );
195 }
196
197 /*********************************************************************
198  *                  log   (NTDLL.@)
199  */
200 double NTDLL_log( double d )
201 {
202     return log( d );
203 }
204
205 /*********************************************************************
206  *                  pow   (NTDLL.@)
207  */
208 double NTDLL_pow( double x, double y )
209 {
210     return pow( x, y );
211 }
212
213 /*********************************************************************
214  *                  sin   (NTDLL.@)
215  */
216 double NTDLL_sin( double d )
217 {
218     return sin( d );
219 }
220
221 /*********************************************************************
222  *                  sqrt   (NTDLL.@)
223  */
224 double NTDLL_sqrt( double d )
225 {
226     return sqrt( d );
227 }
228
229 /*********************************************************************
230  *                  tan   (NTDLL.@)
231  */
232 double NTDLL_tan( double d )
233 {
234     return tan( d );
235 }