FreeBASIC  0.91.0
hinit.c
Go to the documentation of this file.
1 /* libfb initialization for xbox */
2 
3 #include "../fb.h"
4 
5 #ifdef ENABLE_MT
6 static CRITICAL_SECTION __fb_global_mutex;
7 static CRITICAL_SECTION __fb_string_mutex;
8 FBCALL void fb_Lock( void ) { EnterCriticalSection( &__fb_global_mutex ); }
9 FBCALL void fb_Unlock( void ) { LeaveCriticalSection( &__fb_global_mutex ); }
10 FBCALL void fb_StrLock( void ) { EnterCriticalSection( &__fb_string_mutex ); }
11 FBCALL void fb_StrUnlock( void ) { LeaveCriticalSection( &__fb_string_mutex ); }
12 #endif
13 
14 void fb_hInit( void )
15 {
16  unsigned int control_word;
17 
18  /* Get FPU control word */
19  __asm__ __volatile__( "fstcw %0" : "=m" (control_word) : );
20  /* Set 64-bit and round to nearest */
21  control_word = (control_word & 0xF0FF) | 0x300;
22  /* Write back FPU control word */
23  __asm__ __volatile__( "fldcw %0" : : "m" (control_word) );
24 
25 
26 #ifdef ENABLE_MT
27  /* !!!FIXME!!! replace with xbox/openxdk equivalents */
28  InitializeCriticalSection(&__fb_global_mutex);
29  InitializeCriticalSection(&__fb_string_mutex);
30 #endif
31 }
32 
33 void fb_hEnd( int unused )
34 {
35 #ifdef ENABLE_MT
36  DeleteCriticalSection(&__fb_global_mutex);
37  DeleteCriticalSection(&__fb_string_mutex);
38 #endif
39 }