Various fixes for win32, mostly as a result of the splits.

This commit is contained in:
John Popplewell 2006-02-20 04:12:27 +00:00
parent 7ce606ea61
commit 2982961f38
7 changed files with 41 additions and 38 deletions

View file

@ -29,30 +29,24 @@
*/ */
#ifdef WIN32 #ifdef WIN32
/* Horrible, dangerous macros. */
/* /*
The SDL stderr redirection trick doesn't seem to work for perror(). The SDL stderr redirection trick doesn't seem to work for perror().
This does pretty much the same thing. This does pretty much the same thing.
*/ */
static void win32_perror(const char * const str) #define perror(str) ({ \
{ if ( (str) && *(str) ) \
if ( str && *str ) fprintf(stderr,"%s : ",(str)); \
fprintf(stderr,"%s : ",str); fprintf(stderr, \
fprintf(stderr, "%s [%d]\n", \
"%s [%d]\n", (errno<_sys_nerr)?_sys_errlist[errno]:"unknown",errno ); \
(errno<_sys_nerr)?_sys_errlist[errno]:"unknown",errno ); })
}
#define perror win32_perror
/* /*
MinGW implementation of isspace() crashes on some Win98 boxes MinGW implementation of isspace() crashes on some Win98 boxes
if c is 'out-of-range'. if c is 'out-of-range'.
*/ */
#define isspace(c) (((c) == 0x20) || ((c) >= 0x09 && (c) <= 0x0D))
static int win32_isspace(int c)
{
return (c == 0x20) || (c >= 0x09 && c <= 0x0D);
}
#define isspace win32_isspace
/* /*
WIN32 and MINGW don't have strcasestr(). WIN32 and MINGW don't have strcasestr().
@ -109,7 +103,9 @@ static int win32_isspace(int c)
// won't alias anything, and aligned enough for anything // won't alias anything, and aligned enough for anything
#define MALLOC __attribute__ ((__malloc__)) #define MALLOC __attribute__ ((__malloc__))
// no side effect, may read globals // no side effect, may read globals
#ifndef WIN32
#define PURE __attribute__ ((__pure__)) #define PURE __attribute__ ((__pure__))
#endif
// tell gcc what to expect: if(unlikely(err)) die(err); // tell gcc what to expect: if(unlikely(err)) die(err);
#define likely(x) __builtin_expect(!!(x),1) #define likely(x) __builtin_expect(!!(x),1)
#define unlikely(x) __builtin_expect(!!(x),0) #define unlikely(x) __builtin_expect(!!(x),0)

View file

@ -11,12 +11,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#ifndef WIN32
#include <unistd.h>
#include <dirent.h> #include <dirent.h>
#endif
#include "SDL_ttf.h" #include "SDL_ttf.h"

View file

@ -22,6 +22,9 @@
#include "get_fname.h" #include "get_fname.h"
#include "debug.h" #include "debug.h"
#ifdef WIN32
#include "win32_print.h"
#endif
#ifdef FORKED_FONTS #ifdef FORKED_FONTS
@ -446,7 +449,7 @@ int load_user_fonts(SDL_Surface * screen, void *vp)
{ {
#ifdef WIN32 #ifdef WIN32
homedirdir = GetSystemFontDir(); homedirdir = GetSystemFontDir();
loadfonts(homedirdir); loadfonts(screen, homedirdir);
free(homedirdir); free(homedirdir);
#elif defined(__BEOS__) #elif defined(__BEOS__)
loadfonts(screen, "/boot/home/config/font/ttffonts"); loadfonts(screen, "/boot/home/config/font/ttffonts");

View file

@ -22,9 +22,22 @@
#ifndef FORKED_FONTS #ifndef FORKED_FONTS
#include "SDL_thread.h" #include "SDL_thread.h"
#include "SDL_mutex.h" #include "SDL_mutex.h"
#else
/* This shouldn't really be here :-)
* Move into 'fonts.c' and the code in 'tuxpaint.c'
* that uses this lot should be put into 'fonts.c' as well.
*/
#define SDL_CreateThread(fn,vp) (void*)(long)(fn(vp))
#define SDL_WaitThread(tid,rcp) do{(void)tid;(void)rcp;}while(0)
#define SDL_Thread int
#define SDL_mutex int
#define SDL_CreateMutex() 0 // creates in released state
#define SDL_DestroyMutex(lock)
#define SDL_mutexP(lock) // take lock
#define SDL_mutexV(lock) // release lock
#endif
extern SDL_Thread *font_thread; extern SDL_Thread *font_thread;
#endif
extern volatile long font_thread_done, font_thread_aborted; extern volatile long font_thread_done, font_thread_aborted;
extern volatile long waiting_for_fonts; extern volatile long waiting_for_fonts;

View file

@ -34,6 +34,9 @@
#include "i18n.h" #include "i18n.h"
#include "debug.h" #include "debug.h"
#ifdef WIN32
#include <sys/types.h>
#endif
/* Globals: */ /* Globals: */

View file

@ -309,20 +309,6 @@ extern WrapperData macosx;
#define FNAME_EXTENSION ".bmp" #define FNAME_EXTENSION ".bmp"
#endif #endif
#if defined(THREADED_FONTS) || defined(THREADED_STAMPS)
#include "SDL_thread.h"
#include "SDL_mutex.h"
#else
#define SDL_CreateThread(fn,vp) (void*)(long)(fn(vp))
#define SDL_WaitThread(tid,rcp) do{(void)tid;(void)rcp;}while(0)
#define SDL_Thread int
#define SDL_mutex int
#define SDL_CreateMutex() 0 // creates in released state
#define SDL_DestroyMutex(lock)
#define SDL_mutexP(lock) // take lock
#define SDL_mutexV(lock) // release lock
#endif
#include "SDL_getenv.h" #include "SDL_getenv.h"
#include "i18n.h" #include "i18n.h"
@ -5307,6 +5293,11 @@ static void load_stamps(SDL_Surface * screen)
} }
static int load_user_fonts_stub(void *vp)
{
return load_user_fonts(screen, vp);
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/* Setup: */ /* Setup: */
@ -6189,7 +6180,7 @@ static void setup(int argc, char * argv[])
#ifdef FORKED_FONTS #ifdef FORKED_FONTS
reliable_write(font_socket_fd, &no_system_fonts, sizeof no_system_fonts); reliable_write(font_socket_fd, &no_system_fonts, sizeof no_system_fonts);
#else #else
font_thread = SDL_CreateThread(load_user_fonts, NULL); font_thread = SDL_CreateThread(load_user_fonts_stub, NULL);
#endif #endif
// continuing on with the rest of the cursors... // continuing on with the rest of the cursors...
@ -6711,8 +6702,10 @@ static void create_button_labels(void)
static void seticon(void) static void seticon(void)
{ {
#ifndef WIN32
int masklen; int masklen;
Uint8 * mask; Uint8 * mask;
#endif
SDL_Surface * icon; SDL_Surface * icon;
/* Load icon into a surface: */ /* Load icon into a surface: */

View file

@ -538,7 +538,7 @@ char *GetDefaultSaveDir(const char *suffix)
Returns heap string containing system font directory. Returns heap string containing system font directory.
E.g. 'C:\Windows\Fonts' E.g. 'C:\Windows\Fonts'
*/ */
char *GetSystemFontDir() char *GetSystemFontDir(void)
{ {
char path[MAX_PATH]; char path[MAX_PATH];
const char *key = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"; const char *key = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders";