| 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 | #ifdef DEBUG | 
|---|
| 37 | void dump_ObjectAttributes (const OBJECT_ATTRIBUTES *oa) | 
|---|
| 38 | { | 
|---|
| 39 | if (oa) | 
|---|
| 40 | TRACE("%p:(name=%s, attr=0x%08lx, hRoot=0x%08x, sd=%p) \n", | 
|---|
| 41 | oa, debugstr_us(oa->ObjectName), | 
|---|
| 42 | oa->Attributes, oa->RootDirectory, oa->SecurityDescriptor); | 
|---|
| 43 | } | 
|---|
| 44 |  | 
|---|
| 45 | LPCSTR debugstr_us( const UNICODE_STRING *us ) | 
|---|
| 46 | { | 
|---|
| 47 | if (!us) return "<null>"; | 
|---|
| 48 | return debugstr_wn(us->Buffer, us->Length); | 
|---|
| 49 | } | 
|---|
| 50 | #endif | 
|---|
| 51 |  | 
|---|
| 52 | /********************************************************************* | 
|---|
| 53 | *                  _ftol   (NTDLL.@) | 
|---|
| 54 | * | 
|---|
| 55 | * VERSION | 
|---|
| 56 | *      [GNUC && i386] | 
|---|
| 57 | */ | 
|---|
| 58 | #if defined(__GNUC__) && defined(__i386__) | 
|---|
| 59 | LONG __cdecl NTDLL__ftol(void) | 
|---|
| 60 | { | 
|---|
| 61 | /* don't just do DO_FPU("fistp",retval), because the rounding | 
|---|
| 62 | * mode must also be set to "round towards zero"... */ | 
|---|
| 63 | double fl; | 
|---|
| 64 | POP_FPU(fl); | 
|---|
| 65 | return (LONG)fl; | 
|---|
| 66 | } | 
|---|
| 67 | #endif /* defined(__GNUC__) && defined(__i386__) */ | 
|---|
| 68 |  | 
|---|
| 69 | /********************************************************************* | 
|---|
| 70 | *                  _ftol   (NTDLL.@) | 
|---|
| 71 | * | 
|---|
| 72 | * FIXME | 
|---|
| 73 | *      Should be register function | 
|---|
| 74 | * VERSION | 
|---|
| 75 | *      [!GNUC && i386] | 
|---|
| 76 | */ | 
|---|
| 77 | #if !defined(__GNUC__) && defined(__i386__) | 
|---|
| 78 | LONG __cdecl NTDLL__ftol(double fl) | 
|---|
| 79 | { | 
|---|
| 80 | FIXME("should be register function\n"); | 
|---|
| 81 | return (LONG)fl; | 
|---|
| 82 | } | 
|---|
| 83 | #endif /* !defined(__GNUC__) && defined(__i386__) */ | 
|---|
| 84 |  | 
|---|
| 85 | /********************************************************************* | 
|---|
| 86 | *                  _ftol   (NTDLL.@) | 
|---|
| 87 | * VERSION | 
|---|
| 88 | *      [!i386] | 
|---|
| 89 | */ | 
|---|
| 90 | #ifndef __i386__ | 
|---|
| 91 | LONG __cdecl NTDLL__ftol(double fl) | 
|---|
| 92 | { | 
|---|
| 93 | return (LONG) fl; | 
|---|
| 94 | } | 
|---|
| 95 | #endif /* !defined(__i386__) */ | 
|---|
| 96 |  | 
|---|
| 97 | /********************************************************************* | 
|---|
| 98 | *                  _CIpow   (NTDLL.@) | 
|---|
| 99 | * VERSION | 
|---|
| 100 | *      [GNUC && i386] | 
|---|
| 101 | */ | 
|---|
| 102 | #if defined(__GNUC__) && defined(__i386__) | 
|---|
| 103 | double __cdecl NTDLL__CIpow(void) | 
|---|
| 104 | { | 
|---|
| 105 | double x,y; | 
|---|
| 106 | POP_FPU(y); | 
|---|
| 107 | POP_FPU(x); | 
|---|
| 108 | return pow(x,y); | 
|---|
| 109 | } | 
|---|
| 110 | #endif /* defined(__GNUC__) && defined(__i386__) */ | 
|---|
| 111 |  | 
|---|
| 112 |  | 
|---|
| 113 | /********************************************************************* | 
|---|
| 114 | *                  _CIpow   (NTDLL.@) | 
|---|
| 115 | * | 
|---|
| 116 | * FIXME | 
|---|
| 117 | *      Should be register function | 
|---|
| 118 | * | 
|---|
| 119 | * VERSION | 
|---|
| 120 | *      [!GNUC && i386] | 
|---|
| 121 | */ | 
|---|
| 122 | #if !defined(__GNUC__) && defined(__i386__) | 
|---|
| 123 | double __cdecl NTDLL__CIpow(double x,double y) | 
|---|
| 124 | { | 
|---|
| 125 | FIXME("should be register function\n"); | 
|---|
| 126 | return pow(x,y); | 
|---|
| 127 | } | 
|---|
| 128 | #endif /* !defined(__GNUC__) && defined(__i386__) */ | 
|---|
| 129 |  | 
|---|
| 130 | /********************************************************************* | 
|---|
| 131 | *                  _CIpow   (NTDLL.@) | 
|---|
| 132 | * VERSION | 
|---|
| 133 | *      [!i386] | 
|---|
| 134 | */ | 
|---|
| 135 | #ifndef __i386__ | 
|---|
| 136 | double __cdecl NTDLL__CIpow(double x,double y) | 
|---|
| 137 | { | 
|---|
| 138 | return pow(x,y); | 
|---|
| 139 | } | 
|---|
| 140 | #endif /* !defined(__i386__) */ | 
|---|
| 141 |  | 
|---|
| 142 |  | 
|---|