Fixed debugstr_as/us prototypes.
[wine] / dlls / ntdll / misc.c
1 /*
2  * Helper functions for ntdll
3  */
4 #include <time.h>
5 #include <math.h>
6
7 #include "config.h"
8
9 #include "debugtools.h"
10 #include "ntdll_misc.h"
11
12 DEFAULT_DEBUG_CHANNEL(ntdll);
13
14 #if defined(__GNUC__) && defined(__i386__)
15 #define USING_REAL_FPU
16 #define DO_FPU(x,y) __asm__ __volatile__( x " %0;fwait" : "=m" (y) : )
17 #define POP_FPU(x) DO_FPU("fstpl",x)
18 #endif
19
20 void dump_ObjectAttributes (POBJECT_ATTRIBUTES oa)
21 {
22         if (oa)
23           TRACE("%p:(name=%s, attr=0x%08lx, hRoot=0x%08x, sd=%p) \n",
24             oa, debugstr_us(oa->ObjectName),
25             oa->Attributes, oa->RootDirectory, oa->SecurityDescriptor);
26 }
27
28 void dump_AnsiString(PANSI_STRING as, BOOLEAN showstring)
29 {
30         if (as)
31         {
32           if (showstring)
33             TRACE("%p %p(%s) (%u %u)\n", as, as->Buffer, debugstr_as(as), as->Length, as->MaximumLength);
34           else
35             TRACE("%p %p(<OUT>) (%u %u)\n", as, as->Buffer, as->Length, as->MaximumLength);
36         }
37 }
38
39 void dump_UnicodeString(PUNICODE_STRING us, BOOLEAN showstring)
40 {
41         if (us)
42         {
43           if (showstring)
44             TRACE("%p %p(%s) (%u %u)\n", us, us->Buffer, debugstr_us(us), us->Length, us->MaximumLength);
45           else
46             TRACE("%p %p(<OUT>) (%u %u)\n", us, us->Buffer, us->Length, us->MaximumLength);
47         }
48 }
49
50 LPCSTR debugstr_as( const STRING *str )
51 {
52     if (!str) return "<null>";
53     return debugstr_an(str->Buffer, str->Length);
54 }
55
56 LPCSTR debugstr_us( const UNICODE_STRING *us )
57 {
58     if (!us) return "<null>";
59     return debugstr_wn(us->Buffer, us->Length);
60 }
61
62 /*********************************************************************
63  *                  _ftol   (NTDLL)
64  */
65 #ifdef USING_REAL_FPU
66 LONG __cdecl NTDLL__ftol(void)
67 {
68         /* don't just do DO_FPU("fistp",retval), because the rounding
69          * mode must also be set to "round towards zero"... */
70         double fl;
71         POP_FPU(fl);
72         return (LONG)fl;
73 }
74 #else
75 LONG __cdecl NTDLL__ftol(double fl)
76 {
77         FIXME("should be register function\n");
78         return (LONG)fl;
79 }
80 #endif
81
82 /*********************************************************************
83  *                  _CIpow   (NTDLL)
84  */
85 #ifdef USING_REAL_FPU
86 LONG __cdecl NTDLL__CIpow(void)
87 {
88         double x,y;
89         POP_FPU(y);
90         POP_FPU(x);
91         return pow(x,y);
92 }
93 #else
94 LONG __cdecl NTDLL__CIpow(double x,double y)
95 {
96         FIXME("should be register function\n");
97         return pow(x,y);
98 }
99 #endif