From 3b186dc9c57cb38049237e8aa87ffd679a5dd3df Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 2 Jan 2005 05:05:21 +0000 Subject: [PATCH] Date: Fri, 31 Dec 2004 04:14:09 +0900 From: Hayashi Naoyuki Subject: SDL patch for Tru64 UNIX 4.0X SDL-1.2.8 support only Tru64 5.X. This patch is for Tru64 UNIX 4.X.(tested on Tru64 UNIX 4.0G and 5.1B) SDL-1.2.8/configure.in: ld doesn't accept -pthread option. cc -pthread has same effect as -D_REENTRANT when compiling, and has same effect as -lpthread -lexc when linking. SDL-1.2.8/include/begin_code.h: Old Compaq C Compiler accept not inline but __inline. SDL-1.2.8/src/audio/SDL_mixer_MMX.c: SDL-1.2.8/src/audio/SDL_mixer_MMX.h: Old Compaq C Compiler doesn't accept //. SDL-1.2.8/src/cdrom/osf/SDL_syscdrom.c: When becoming Tru64 v5.0 from Tru64 v4.0, the arrangement of the cd-rom device was changed. --- configure.in | 5 +-- include/begin_code.h | 3 +- src/audio/SDL_mixer_MMX.c | 24 ++++++------ src/audio/SDL_mixer_MMX.h | 14 ++++--- src/cdrom/osf/SDL_syscdrom.c | 71 ++++++++++++++++++++---------------- 5 files changed, 64 insertions(+), 53 deletions(-) diff --git a/configure.in b/configure.in index 040fa8eec..27d8ab2c6 100644 --- a/configure.in +++ b/configure.in @@ -1280,12 +1280,11 @@ CheckPTHREAD() pthread_lib="" ;; *-*-osf*) + pthread_cflags="-D_REENTRANT" if test x$ac_cv_prog_gcc = xyes; then - pthread_cflags="-D_REENTRANT" pthread_lib="-lpthread -lrt" else - pthread_cflags="-pthread" - pthread_lib="-lpthread -lrt" + pthread_lib="-lpthread -lexc -lrt" fi ;; *) diff --git a/include/begin_code.h b/include/begin_code.h index 1b43406ad..664354c30 100644 --- a/include/begin_code.h +++ b/include/begin_code.h @@ -102,7 +102,8 @@ /* Add any special compiler-specific cases here */ #if defined(_MSC_VER) || defined(__BORLANDC__) || \ defined(__DMC__) || defined(__SC__) || \ - defined(__WATCOMC__) || defined(__LCC__) + defined(__WATCOMC__) || defined(__LCC__) || \ + defined(__DECC) #ifndef __inline__ #define __inline__ __inline #endif diff --git a/src/audio/SDL_mixer_MMX.c b/src/audio/SDL_mixer_MMX.c index 51a3b9d4e..9a33f4f8b 100644 --- a/src/audio/SDL_mixer_MMX.c +++ b/src/audio/SDL_mixer_MMX.c @@ -1,14 +1,16 @@ -// MMX assembler version of SDL_MixAudio for signed little endian 16 bit samples and signed 8 bit samples -// Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr) -// This code is licensed under the LGPL (see COPYING for details) -// -// Assumes buffer size in bytes is a multiple of 16 -// Assumes SDL_MIX_MAXVOLUME = 128 - - -//////////////////////////////////////////////// -// Mixing for 16 bit signed buffers -//////////////////////////////////////////////// +/* + MMX assembler version of SDL_MixAudio for signed little endian 16 bit samples and signed 8 bit samples + Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr) + This code is licensed under the LGPL (see COPYING for details) + + Assumes buffer size in bytes is a multiple of 16 + Assumes SDL_MIX_MAXVOLUME = 128 +*/ + + +/*********************************************** +* Mixing for 16 bit signed buffers +***********************************************/ #if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT) void SDL_MixAudio_MMX_S16(char* dst,char* src,unsigned int size,int volume) diff --git a/src/audio/SDL_mixer_MMX.h b/src/audio/SDL_mixer_MMX.h index 8cd29235b..f95f6a334 100644 --- a/src/audio/SDL_mixer_MMX.h +++ b/src/audio/SDL_mixer_MMX.h @@ -1,9 +1,11 @@ -// headers for MMX assembler version of SDL_MixAudio -// Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr) -// This code is licensed under the LGPL (see COPYING for details) -// -// Assumes buffer size in bytes is a multiple of 16 -// Assumes SDL_MIX_MAXVOLUME = 128 +/* + headers for MMX assembler version of SDL_MixAudio + Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr) + This code is licensed under the LGPL (see COPYING for details) + + Assumes buffer size in bytes is a multiple of 16 + Assumes SDL_MIX_MAXVOLUME = 128 +*/ #if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT) diff --git a/src/cdrom/osf/SDL_syscdrom.c b/src/cdrom/osf/SDL_syscdrom.c index fad398ae1..deb12daf4 100644 --- a/src/cdrom/osf/SDL_syscdrom.c +++ b/src/cdrom/osf/SDL_syscdrom.c @@ -22,9 +22,10 @@ /* Functions for system-level CD-ROM audio control */ -//#define DEBUG_CDROM 1 +/* #define DEBUG_CDROM 1 */ #include +#include #include #include #include @@ -141,11 +142,22 @@ static void AddDrive(char *drive, struct stat *stbuf) int SDL_SYS_CDInit(void) { - /* checklist: /dev/rdisk/cdrom?c + /* checklist: + * + * Tru64 5.X (/dev/rdisk/cdrom?c) + * dir: /dev/rdisk, name: cdrom + * + * Digital UNIX 4.0X (/dev/rrz?c) + * dir: /dev, name: rrz * */ - static char *checklist[] = { - "?0 rdisk/cdrom?",NULL}; + struct { + char *dir; + char *name; + } checklist[] = { + {"/dev/rdisk", "cdrom"}, + {"/dev", "rrz"}, + {NULL, NULL}}; char drive[32]; char *SDLcdrom; int i, j, exists; @@ -195,37 +207,32 @@ int SDL_SYS_CDInit(void) } } /* Scan the system for CD-ROM drives */ - for ( i=0; checklist[i]; ++i ) { - if ( checklist[i][0] == '?' ) { - char *insert; - exists = 1; - for ( j=checklist[i][1]; exists; ++j ) { - sprintf(drive, "/dev/%sc", &checklist[i][3]); - insert = strchr(drive, '?'); - if ( insert != NULL ) { - *insert = j; - } - switch (CheckDrive(drive, &stbuf)) { - /* Drive exists and is a CD-ROM */ - case 1: - AddDrive(drive, &stbuf); - break; - /* Drive exists, but isn't a CD-ROM */ - case 0: - break; - /* Drive doesn't exist */ - case -1: - exists = 0; - break; - } - } + for ( i = 0; checklist[i].dir; ++i) { + DIR *devdir; + struct dirent *devent; + int name_len; + + devdir = opendir(checklist[i].dir); + if (devdir) { + name_len = strlen(checklist[i].name); + while (devent = readdir(devdir)) + if (memcmp(checklist[i].name, devent->d_name, name_len) == 0) + if (devent->d_name[devent->d_namlen-1] == 'c') { + sprintf(drive, "%s/%s", checklist[i].dir, devent->d_name); +#ifdef DEBUG_CDROM + fprintf(stderr, "Try to add drive: %s\n", drive); +#endif + if ( CheckDrive(drive, &stbuf) > 0 ) + AddDrive(drive, &stbuf); + } + closedir(devdir); } else { - sprintf(drive, "/dev/%s", checklist[i]); - if ( CheckDrive(drive, &stbuf) > 0 ) { - AddDrive(drive, &stbuf); - } +#ifdef DEBUG_CDROM + fprintf(stderr, "cannot open dir: %s\n", checklist[i].dir); +#endif } } + /* SDLcdrom=malloc(sizeof(char) * 32); strcpy(SDLcdrom,"/dev/rdisk/cdrom0c");