ntdll/tests: Skip a couple of exception tests that crash on Wow64.
[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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #include "config.h"
22
23 #include <time.h>
24 #include <math.h>
25 #ifdef HAVE_SYS_UTSNAME_H
26 #include <sys/utsname.h>
27 #endif
28
29 #include "wine/library.h"
30 #include "wine/debug.h"
31 #include "ntdll_misc.h"
32
33 WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
34
35 #if defined(__GNUC__) && defined(__i386__)
36 #define DO_FPU(x,y) __asm__ __volatile__( x " %0;fwait" : "=m" (y) : )
37 #define POP_FPU(x) DO_FPU("fstpl",x)
38 #endif
39
40 LPCSTR debugstr_ObjectAttributes(const OBJECT_ATTRIBUTES *oa)
41 {
42     if (!oa) return "<null>";
43     return wine_dbg_sprintf( "{name=%s, attr=0x%08x, hRoot=%p, sd=%p}\n",
44                              debugstr_us(oa->ObjectName), oa->Attributes,
45                              oa->RootDirectory, oa->SecurityDescriptor );
46 }
47
48 LPCSTR debugstr_us( const UNICODE_STRING *us )
49 {
50     if (!us) return "<null>";
51     return debugstr_wn(us->Buffer, us->Length / sizeof(WCHAR));
52 }
53
54 /*********************************************************************
55  *                  _ftol   (NTDLL.@)
56  *
57  * VERSION
58  *      [GNUC && i386]
59  */
60 #if defined(__GNUC__) && defined(__i386__)
61 LONGLONG CDECL NTDLL__ftol(void)
62 {
63         /* don't just do DO_FPU("fistp",retval), because the rounding
64          * mode must also be set to "round towards zero"... */
65         double fl;
66         POP_FPU(fl);
67         return (LONGLONG)fl;
68 }
69 #endif /* defined(__GNUC__) && defined(__i386__) */
70
71 /*********************************************************************
72  *                  _ftol   (NTDLL.@)
73  *
74  * FIXME
75  *      Should be register function
76  * VERSION
77  *      [!GNUC && i386]
78  */
79 #if !defined(__GNUC__) && defined(__i386__)
80 LONGLONG CDECL NTDLL__ftol(double fl)
81 {
82         FIXME("should be register function\n");
83         return (LONGLONG)fl;
84 }
85 #endif /* !defined(__GNUC__) && defined(__i386__) */
86
87 /*********************************************************************
88  *                  _CIpow   (NTDLL.@)
89  * VERSION
90  *      [GNUC && i386]
91  */
92 #if defined(__GNUC__) && defined(__i386__)
93 double CDECL NTDLL__CIpow(void)
94 {
95         double x,y;
96         POP_FPU(y);
97         POP_FPU(x);
98         return pow(x,y);
99 }
100 #endif /* defined(__GNUC__) && defined(__i386__) */
101
102
103 /*********************************************************************
104  *                  _CIpow   (NTDLL.@)
105  *
106  * FIXME
107  *      Should be register function
108  *
109  * VERSION
110  *      [!GNUC && i386]
111  */
112 #if !defined(__GNUC__) && defined(__i386__)
113 double CDECL NTDLL__CIpow(double x,double y)
114 {
115         FIXME("should be register function\n");
116         return pow(x,y);
117 }
118 #endif /* !defined(__GNUC__) && defined(__i386__) */
119
120 /*********************************************************************
121  *                  wine_get_version   (NTDLL.@)
122  */
123 const char * CDECL NTDLL_wine_get_version(void)
124 {
125     return wine_get_version();
126 }
127
128 /*********************************************************************
129  *                  wine_get_build_id   (NTDLL.@)
130  */
131 const char * CDECL NTDLL_wine_get_build_id(void)
132 {
133     return wine_get_build_id();
134 }
135
136 /*********************************************************************
137  *                  wine_get_host_version   (NTDLL.@)
138  */
139 void CDECL NTDLL_wine_get_host_version( const char **sysname, const char **release )
140 {
141 #ifdef HAVE_SYS_UTSNAME_H
142     static struct utsname buf;
143     static int init_done;
144
145     if (!init_done)
146     {
147         uname( &buf );
148         init_done = 1;
149     }
150     if (sysname) *sysname = buf.sysname;
151     if (release) *release = buf.release;
152 #else
153     if (sysname) *sysname = "";
154     if (release) *release = "";
155 #endif
156 }
157
158 /*********************************************************************
159  *                  abs   (NTDLL.@)
160  */
161 int CDECL NTDLL_abs( int i )
162 {
163     return abs( i );
164 }
165
166 /*********************************************************************
167  *                  labs   (NTDLL.@)
168  */
169 LONG CDECL NTDLL_labs( LONG i )
170 {
171     return labs( i );
172 }
173
174 /*********************************************************************
175  *                  atan   (NTDLL.@)
176  */
177 double CDECL NTDLL_atan( double d )
178 {
179     return atan( d );
180 }
181
182 /*********************************************************************
183  *                  ceil   (NTDLL.@)
184  */
185 double CDECL NTDLL_ceil( double d )
186 {
187     return ceil( d );
188 }
189
190 /*********************************************************************
191  *                  cos   (NTDLL.@)
192  */
193 double CDECL NTDLL_cos( double d )
194 {
195     return cos( d );
196 }
197
198 /*********************************************************************
199  *                  fabs   (NTDLL.@)
200  */
201 double CDECL NTDLL_fabs( double d )
202 {
203     return fabs( d );
204 }
205
206 /*********************************************************************
207  *                  floor   (NTDLL.@)
208  */
209 double CDECL NTDLL_floor( double d )
210 {
211     return floor( d );
212 }
213
214 /*********************************************************************
215  *                  log   (NTDLL.@)
216  */
217 double CDECL NTDLL_log( double d )
218 {
219     return log( d );
220 }
221
222 /*********************************************************************
223  *                  pow   (NTDLL.@)
224  */
225 double CDECL NTDLL_pow( double x, double y )
226 {
227     return pow( x, y );
228 }
229
230 /*********************************************************************
231  *                  sin   (NTDLL.@)
232  */
233 double CDECL NTDLL_sin( double d )
234 {
235     return sin( d );
236 }
237
238 /*********************************************************************
239  *                  sqrt   (NTDLL.@)
240  */
241 double CDECL NTDLL_sqrt( double d )
242 {
243     return sqrt( d );
244 }
245
246 /*********************************************************************
247  *                  tan   (NTDLL.@)
248  */
249 double CDECL NTDLL_tan( double d )
250 {
251     return tan( d );
252 }