misc.c 6.13 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
#include <time.h>
#include <math.h>
25 26 27
#ifdef HAVE_SYS_UTSNAME_H
#include <sys/utsname.h>
#endif
28

29
#include "wine/library.h"
30
#include "wine/debug.h"
31 32
#include "ntdll_misc.h"

33
WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
34

35 36 37 38 39
#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

40
LPCSTR debugstr_ObjectAttributes(const OBJECT_ATTRIBUTES *oa)
41
{
42 43 44 45
    if (!oa) return "<null>";
    return wine_dbg_sprintf( "{name=%s, attr=0x%08x, hRoot=%p, sd=%p}\n",
                             debugstr_us(oa->ObjectName), oa->Attributes,
                             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 58
 *
 * VERSION
 *	[GNUC && i386]
59
 */
60
#if defined(__GNUC__) && defined(__i386__)
61
LONGLONG CDECL NTDLL__ftol(void)
62 63 64 65 66
{
	/* 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);
67
	return (LONGLONG)fl;
68
}
69 70 71
#endif /* defined(__GNUC__) && defined(__i386__) */

/*********************************************************************
72
 *                  _ftol   (NTDLL.@)
73 74 75 76 77 78
 *
 * FIXME
 *	Should be register function
 * VERSION
 *	[!GNUC && i386]
 */
Dmitry Timoshkov's avatar
Dmitry Timoshkov committed
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 86
#endif /* !defined(__GNUC__) && defined(__i386__) */

87
/*********************************************************************
88
 *                  _CIpow   (NTDLL.@)
89 90
 * VERSION
 *	[GNUC && i386]
91
 */
92
#if defined(__GNUC__) && defined(__i386__)
93
double CDECL NTDLL__CIpow(void)
94 95 96 97 98 99
{
	double x,y;
	POP_FPU(y);
	POP_FPU(x);
	return pow(x,y);
}
100 101 102 103
#endif /* defined(__GNUC__) && defined(__i386__) */


/*********************************************************************
104
 *                  _CIpow   (NTDLL.@)
105 106 107 108 109 110 111 112
 *
 * FIXME
 *	Should be register function
 *
 * VERSION
 *	[!GNUC && i386]
 */
#if !defined(__GNUC__) && defined(__i386__)
113
double CDECL NTDLL__CIpow(double x,double y)
114 115 116 117
{
	FIXME("should be register function\n");
	return pow(x,y);
}
118 119
#endif /* !defined(__GNUC__) && defined(__i386__) */

120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
/*********************************************************************
 *                  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();
}

136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
/*********************************************************************
 *                  wine_get_host_version   (NTDLL.@)
 */
void CDECL NTDLL_wine_get_host_version( const char **sysname, const char **release )
{
#ifdef HAVE_SYS_UTSNAME_H
    static struct utsname buf;
    static int init_done;

    if (!init_done)
    {
        uname( &buf );
        init_done = 1;
    }
    if (sysname) *sysname = buf.sysname;
    if (release) *release = buf.release;
#else
    if (sysname) *sysname = "";
    if (release) *release = "";
#endif
}

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 );
}