misc.c 5.94 KB
Newer Older
1 2
/*
 * Helper functions for ntdll
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
 *
 * Copyright 2000 Juergen Schmied
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * 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 22
 */

#include "config.h"

23 24 25
#include <time.h>
#include <math.h>

26
#include "wine/library.h"
27
#include "wine/debug.h"
28 29
#include "ntdll_misc.h"

30
WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
31

32 33 34 35 36
#if defined(__GNUC__) && defined(__i386__)
#define DO_FPU(x,y) __asm__ __volatile__( x " %0;fwait" : "=m" (y) : )
#define POP_FPU(x) DO_FPU("fstpl",x)
#endif

37
void dump_ObjectAttributes (const OBJECT_ATTRIBUTES *oa)
38 39
{
	if (oa)
40
	  TRACE("%p:(name=%s, attr=0x%08x, hRoot=%p, sd=%p)\n",
41 42 43 44
	    oa, debugstr_us(oa->ObjectName),
	    oa->Attributes, oa->RootDirectory, oa->SecurityDescriptor);
}

45
LPCSTR debugstr_us( const UNICODE_STRING *us )
46
{
47
    if (!us) return "<null>";
48
    return debugstr_wn(us->Buffer, us->Length / sizeof(WCHAR));
49 50
}

51
/*********************************************************************
52
 *                  _ftol   (NTDLL.@)
53 54 55
 *
 * VERSION
 *	[GNUC && i386]
56
 */
57
#if defined(__GNUC__) && defined(__i386__)
58
LONGLONG CDECL NTDLL__ftol(void)
59 60 61 62 63
{
	/* don't just do DO_FPU("fistp",retval), because the rounding
	 * mode must also be set to "round towards zero"... */
	double fl;
	POP_FPU(fl);
64
	return (LONGLONG)fl;
65
}
66 67 68
#endif /* defined(__GNUC__) && defined(__i386__) */

/*********************************************************************
69
 *                  _ftol   (NTDLL.@)
70 71 72 73 74 75
 *
 * FIXME
 *	Should be register function
 * VERSION
 *	[!GNUC && i386]
 */
Dmitry Timoshkov's avatar
Dmitry Timoshkov committed
76
#if !defined(__GNUC__) && defined(__i386__)
77
LONGLONG CDECL NTDLL__ftol(double fl)
78 79
{
	FIXME("should be register function\n");
80
	return (LONGLONG)fl;
81
}
82 83 84
#endif /* !defined(__GNUC__) && defined(__i386__) */

/*********************************************************************
85
 *                  _ftol   (NTDLL.@)
86 87 88 89
 * VERSION
 *	[!i386]
 */
#ifndef __i386__
90
LONG CDECL NTDLL__ftol(double fl)
91 92 93 94
{
	return (LONG) fl;
}
#endif /* !defined(__i386__) */
95 96

/*********************************************************************
97
 *                  _CIpow   (NTDLL.@)
98 99
 * VERSION
 *	[GNUC && i386]
100
 */
101
#if defined(__GNUC__) && defined(__i386__)
102
double CDECL NTDLL__CIpow(void)
103 104 105 106 107 108
{
	double x,y;
	POP_FPU(y);
	POP_FPU(x);
	return pow(x,y);
}
109 110 111 112
#endif /* defined(__GNUC__) && defined(__i386__) */


/*********************************************************************
113
 *                  _CIpow   (NTDLL.@)
114 115 116 117 118 119 120 121
 *
 * FIXME
 *	Should be register function
 *
 * VERSION
 *	[!GNUC && i386]
 */
#if !defined(__GNUC__) && defined(__i386__)
122
double CDECL NTDLL__CIpow(double x,double y)
123 124 125 126
{
	FIXME("should be register function\n");
	return pow(x,y);
}
127 128 129
#endif /* !defined(__GNUC__) && defined(__i386__) */

/*********************************************************************
130
 *                  _CIpow   (NTDLL.@)
131 132 133 134
 * VERSION
 *	[!i386]
 */
#ifndef __i386__
135
double CDECL NTDLL__CIpow(double x,double y)
136 137 138 139
{
	return pow(x,y);
}
#endif /* !defined(__i386__) */
140 141


142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
/*********************************************************************
 *                  wine_get_version   (NTDLL.@)
 */
const char * CDECL NTDLL_wine_get_version(void)
{
    return wine_get_version();
}

/*********************************************************************
 *                  wine_get_build_id   (NTDLL.@)
 */
const char * CDECL NTDLL_wine_get_build_id(void)
{
    return wine_get_build_id();
}

158 159 160
/*********************************************************************
 *                  abs   (NTDLL.@)
 */
161
int CDECL NTDLL_abs( int i )
162 163 164 165 166 167 168
{
    return abs( i );
}

/*********************************************************************
 *                  labs   (NTDLL.@)
 */
169
LONG CDECL NTDLL_labs( LONG i )
170 171 172 173 174 175 176
{
    return labs( i );
}

/*********************************************************************
 *                  atan   (NTDLL.@)
 */
177
double CDECL NTDLL_atan( double d )
178 179 180 181 182 183 184
{
    return atan( d );
}

/*********************************************************************
 *                  ceil   (NTDLL.@)
 */
185
double CDECL NTDLL_ceil( double d )
186 187 188 189 190 191 192
{
    return ceil( d );
}

/*********************************************************************
 *                  cos   (NTDLL.@)
 */
193
double CDECL NTDLL_cos( double d )
194 195 196 197 198 199 200
{
    return cos( d );
}

/*********************************************************************
 *                  fabs   (NTDLL.@)
 */
201
double CDECL NTDLL_fabs( double d )
202 203 204 205 206 207 208
{
    return fabs( d );
}

/*********************************************************************
 *                  floor   (NTDLL.@)
 */
209
double CDECL NTDLL_floor( double d )
210 211 212 213 214 215 216
{
    return floor( d );
}

/*********************************************************************
 *                  log   (NTDLL.@)
 */
217
double CDECL NTDLL_log( double d )
218 219 220 221 222 223 224
{
    return log( d );
}

/*********************************************************************
 *                  pow   (NTDLL.@)
 */
225
double CDECL NTDLL_pow( double x, double y )
226 227 228 229 230 231 232
{
    return pow( x, y );
}

/*********************************************************************
 *                  sin   (NTDLL.@)
 */
233
double CDECL NTDLL_sin( double d )
234 235 236 237 238 239 240
{
    return sin( d );
}

/*********************************************************************
 *                  sqrt   (NTDLL.@)
 */
241
double CDECL NTDLL_sqrt( double d )
242 243 244 245 246 247 248
{
    return sqrt( d );
}

/*********************************************************************
 *                  tan   (NTDLL.@)
 */
249
double CDECL NTDLL_tan( double d )
250 251 252
{
    return tan( d );
}