* gcc.dg/lto/20080924_0.c: Fix defaulting to int.
[official-gcc.git] / gcc / testsuite / gcc.dg / lto / 20091013-1_1.c
blobb75d0959cc37f171ddf685806d75f2ec5ae4b375
1 /* { dg-xfail-if "cast to pointer of different size" { "avr-*-*" x86_64-*-mingw* } { "*" } { "" } } */
2 typedef struct HDC__ { int unused; } *HDC;
3 typedef struct HFONT__ { int unused; } *HFONT;
5 typedef struct
7 unsigned int ciACP;
8 } CHARSETINFO, *PCHARSETINFO, *LPCHARSETINFO;
10 typedef struct tagTEXTMETRICW
12 int tmCharSet;
13 } TEXTMETRICW, *LPTEXTMETRICW, *PTEXTMETRICW;
15 struct gdi_obj_funcs
17 void* (*pSelectObject)( void* handle, void* hdc );
20 typedef struct tagGdiFont GdiFont;
22 typedef struct tagDC
24 int xunused;
25 GdiFont *gdiFont;
26 unsigned int font_code_page;
27 } DC;
29 extern GdiFont* WineEngCreateFontInstance(DC*, HFONT);
30 extern unsigned int WineEngGetTextCharsetInfo(GdiFont *font, void* fs, unsigned int flags);
31 extern int WineEngGetTextMetrics(GdiFont*, LPTEXTMETRICW);
32 extern void* alloc_gdi_handle( void *obj, unsigned short type, const struct gdi_obj_funcs *funcs );
34 enum __wine_debug_class
36 __WINE_DBCL_FIXME,
37 __WINE_DBCL_ERR,
38 __WINE_DBCL_WARN,
39 __WINE_DBCL_TRACE,
41 __WINE_DBCL_INIT = 7
44 struct __wine_debug_channel
46 unsigned char flags;
47 char name[15];
50 extern int wine_dbg_log( enum __wine_debug_class cls, struct __wine_debug_channel *ch, const char *func,
51 const char *format, ... ) __attribute__((format (printf,4,5)));
53 static struct __wine_debug_channel __wine_dbch_font = { ~0, "font" };
54 static struct __wine_debug_channel * const __wine_dbch___default = &__wine_dbch_font;
56 static void* FONT_SelectObject( void* handle, void* hdc );
57 int TranslateCharsetInfo( void *, CHARSETINFO *, int );
58 unsigned int GetACP (void);
60 static const struct gdi_obj_funcs font_funcs =
62 FONT_SelectObject,
65 HFONT CreateFontIndirectW( const void *plf )
67 return alloc_gdi_handle( 0, 6, &font_funcs );
70 static void update_font_code_page( DC *dc )
72 CHARSETINFO csi;
73 int charset = (unsigned char)1;
75 if (dc->gdiFont)
76 charset = WineEngGetTextCharsetInfo( dc->gdiFont, ((void *)0), 0 );
78 if (TranslateCharsetInfo( ((void *)(unsigned long)((unsigned long)charset)), &csi, 1) )
79 dc->font_code_page = csi.ciACP;
80 else {
81 switch(charset) {
82 case (unsigned char)1:
83 dc->font_code_page = GetACP();
84 break;
86 case (unsigned char)246:
87 dc->font_code_page = 0;
88 break;
90 default:
91 do { if((((__wine_dbch___default))->flags & (1 << __WINE_DBCL_FIXME))) { struct __wine_debug_channel * const __dbch = (__wine_dbch___default); const enum __wine_debug_class __dbcl = __WINE_DBCL_FIXME; wine_dbg_log( __dbcl, __dbch, __FUNCTION__, "Can't find codepage for charset %d\n", charset); } } while(0);
92 dc->font_code_page = 0;
93 break;
97 do { if((((__wine_dbch___default))->flags & (1 << __WINE_DBCL_TRACE))) { struct __wine_debug_channel * const __dbch = (__wine_dbch___default); const enum __wine_debug_class __dbcl = __WINE_DBCL_TRACE; wine_dbg_log( __dbcl, __dbch, __FUNCTION__, "charset %d => cp %d\n", charset, dc->font_code_page); } } while(0);
100 static void* FONT_SelectObject( void* handle, void* hdc )
102 DC *dc;
104 dc->gdiFont = WineEngCreateFontInstance( dc, handle );
105 update_font_code_page( dc );
106 return 0;
109 int GetTextMetricsW( HDC hdc, TEXTMETRICW *metrics )
111 DC * dc;
112 return WineEngGetTextMetrics(dc->gdiFont, metrics);