1 /* small utility functions for winebuild */
12 void *xmalloc (size_t size)
16 res = malloc (size ? size : 1);
19 fprintf (stderr, "Virtual memory exhausted.\n");
25 void *xrealloc (void *ptr, size_t size)
27 void *res = realloc (ptr, size);
30 fprintf (stderr, "Virtual memory exhausted.\n");
36 char *xstrdup( const char *str )
38 char *res = strdup( str );
41 fprintf (stderr, "Virtual memory exhausted.\n");
47 char *strupper(char *s)
50 for (p = s; *p; p++) *p = toupper(*p);
54 void fatal_error( const char *msg, ... )
57 va_start( valist, msg );
60 fprintf( stderr, "%s:", input_file_name );
62 fprintf( stderr, "%d:", current_line );
65 vfprintf( stderr, msg, valist );
70 void fatal_perror( const char *msg, ... )
73 va_start( valist, msg );
76 fprintf( stderr, "%s:", input_file_name );
78 fprintf( stderr, "%d:", current_line );
81 vfprintf( stderr, msg, valist );
87 void warning( const char *msg, ... )
90 va_start( valist, msg );
93 fprintf( stderr, "%s:", input_file_name );
95 fprintf( stderr, "%d:", current_line );
98 fprintf( stderr, "warning: " );
99 vfprintf( stderr, msg, valist );
103 /* dump a byte stream into the assembly code */
104 void dump_bytes( FILE *outfile, const unsigned char *data, int len,
105 const char *label, int constant )
109 fprintf( outfile, "\nstatic %sunsigned char %s[%d] = {",
110 constant ? "const " : "", label, len );
111 for (i = 0; i < len; i++)
113 if (!(i & 7)) fprintf( outfile, "\n " );
114 fprintf( outfile, "0x%02x", *data++ );
115 if (i < len - 1) fprintf( outfile, "," );
117 fprintf( outfile, "\n};\n" );