Date: Fri, 31 Dec 2004 04:14:09 +0900
authorSam Lantinga <slouken@libsdl.org>
Sun, 02 Jan 2005 05:05:21 +0000
changeset 1019e3b3130f3af8
parent 1018 012af0b7e8e6
child 1020 5b1cb1e9140d
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
include/begin_code.h
src/audio/SDL_mixer_MMX.c
src/audio/SDL_mixer_MMX.h
src/cdrom/osf/SDL_syscdrom.c
     1.1 --- a/configure.in	Mon Dec 27 20:03:53 2004 +0000
     1.2 +++ b/configure.in	Sun Jan 02 05:05:21 2005 +0000
     1.3 @@ -1280,12 +1280,11 @@
     1.4              pthread_lib=""
     1.5              ;;
     1.6          *-*-osf*)
     1.7 +            pthread_cflags="-D_REENTRANT"
     1.8              if test x$ac_cv_prog_gcc = xyes; then
     1.9 -                pthread_cflags="-D_REENTRANT"
    1.10                  pthread_lib="-lpthread -lrt"
    1.11              else
    1.12 -                pthread_cflags="-pthread"
    1.13 -                pthread_lib="-lpthread -lrt"
    1.14 +                pthread_lib="-lpthread -lexc -lrt"
    1.15              fi
    1.16              ;;
    1.17          *)
     2.1 --- a/include/begin_code.h	Mon Dec 27 20:03:53 2004 +0000
     2.2 +++ b/include/begin_code.h	Sun Jan 02 05:05:21 2005 +0000
     2.3 @@ -102,7 +102,8 @@
     2.4  /* Add any special compiler-specific cases here */
     2.5  #if defined(_MSC_VER) || defined(__BORLANDC__) || \
     2.6      defined(__DMC__) || defined(__SC__) || \
     2.7 -    defined(__WATCOMC__) || defined(__LCC__)
     2.8 +    defined(__WATCOMC__) || defined(__LCC__) || \
     2.9 +    defined(__DECC)
    2.10  #ifndef __inline__
    2.11  #define __inline__	__inline
    2.12  #endif
     3.1 --- a/src/audio/SDL_mixer_MMX.c	Mon Dec 27 20:03:53 2004 +0000
     3.2 +++ b/src/audio/SDL_mixer_MMX.c	Sun Jan 02 05:05:21 2005 +0000
     3.3 @@ -1,14 +1,16 @@
     3.4 -// MMX assembler version of SDL_MixAudio for signed little endian 16 bit samples and signed 8 bit samples
     3.5 -// Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr)
     3.6 -// This code is licensed under the LGPL (see COPYING for details)
     3.7 -// 
     3.8 -// Assumes buffer size in bytes is a multiple of 16
     3.9 -// Assumes SDL_MIX_MAXVOLUME = 128
    3.10 +/*
    3.11 +    MMX assembler version of SDL_MixAudio for signed little endian 16 bit samples and signed 8 bit samples
    3.12 +    Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr)
    3.13 +    This code is licensed under the LGPL (see COPYING for details)
    3.14 + 
    3.15 +    Assumes buffer size in bytes is a multiple of 16
    3.16 +    Assumes SDL_MIX_MAXVOLUME = 128
    3.17 +*/
    3.18  
    3.19  
    3.20 -////////////////////////////////////////////////
    3.21 -// Mixing for 16 bit signed buffers
    3.22 -////////////////////////////////////////////////
    3.23 +/***********************************************
    3.24 +*   Mixing for 16 bit signed buffers
    3.25 +***********************************************/
    3.26  
    3.27  #if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT)
    3.28  void SDL_MixAudio_MMX_S16(char* dst,char* src,unsigned int size,int volume)
     4.1 --- a/src/audio/SDL_mixer_MMX.h	Mon Dec 27 20:03:53 2004 +0000
     4.2 +++ b/src/audio/SDL_mixer_MMX.h	Sun Jan 02 05:05:21 2005 +0000
     4.3 @@ -1,9 +1,11 @@
     4.4 -// headers for MMX assembler version of SDL_MixAudio
     4.5 -// Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr)
     4.6 -// This code is licensed under the LGPL (see COPYING for details)
     4.7 -// 
     4.8 -// Assumes buffer size in bytes is a multiple of 16
     4.9 -// Assumes SDL_MIX_MAXVOLUME = 128
    4.10 +/*
    4.11 +    headers for MMX assembler version of SDL_MixAudio
    4.12 +    Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr)
    4.13 +    This code is licensed under the LGPL (see COPYING for details)
    4.14 +
    4.15 +    Assumes buffer size in bytes is a multiple of 16
    4.16 +    Assumes SDL_MIX_MAXVOLUME = 128
    4.17 +*/
    4.18  
    4.19  
    4.20  #if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT)
     5.1 --- a/src/cdrom/osf/SDL_syscdrom.c	Mon Dec 27 20:03:53 2004 +0000
     5.2 +++ b/src/cdrom/osf/SDL_syscdrom.c	Sun Jan 02 05:05:21 2005 +0000
     5.3 @@ -22,9 +22,10 @@
     5.4  
     5.5  /* Functions for system-level CD-ROM audio control */
     5.6  
     5.7 -//#define DEBUG_CDROM 1
     5.8 +/* #define DEBUG_CDROM 1 */
     5.9  
    5.10  #include <sys/types.h>
    5.11 +#include <dirent.h>
    5.12  #include <sys/stat.h>
    5.13  #include <fcntl.h>
    5.14  #include <io/cam/cdrom.h>
    5.15 @@ -141,11 +142,22 @@
    5.16  
    5.17  int  SDL_SYS_CDInit(void)
    5.18  {
    5.19 -    /* checklist: /dev/rdisk/cdrom?c
    5.20 +    /* checklist:
    5.21 +     *
    5.22 +     * Tru64 5.X (/dev/rdisk/cdrom?c)
    5.23 +     * dir: /dev/rdisk, name: cdrom
    5.24 +     *
    5.25 +     * Digital UNIX 4.0X (/dev/rrz?c)
    5.26 +     * dir: /dev, name: rrz
    5.27       *
    5.28       */
    5.29 -    static char *checklist[] = {
    5.30 -	"?0 rdisk/cdrom?",NULL};
    5.31 +    struct {
    5.32 +	char *dir;
    5.33 +	char *name;
    5.34 +    } checklist[] = {
    5.35 +	{"/dev/rdisk", "cdrom"},
    5.36 +	{"/dev", "rrz"},
    5.37 +	{NULL, NULL}};
    5.38      char drive[32];
    5.39      char *SDLcdrom;
    5.40      int i, j, exists;
    5.41 @@ -195,37 +207,32 @@
    5.42  	}
    5.43      }
    5.44      /* Scan the system for CD-ROM drives */
    5.45 -    for ( i=0; checklist[i]; ++i ) {
    5.46 -	if ( checklist[i][0] == '?' ) {
    5.47 -	    char *insert;
    5.48 -	    exists = 1;
    5.49 -	    for ( j=checklist[i][1]; exists; ++j ) {
    5.50 -		sprintf(drive, "/dev/%sc", &checklist[i][3]);
    5.51 -		insert = strchr(drive, '?');
    5.52 -		if ( insert != NULL ) {
    5.53 -		    *insert = j;
    5.54 -		}
    5.55 -		switch (CheckDrive(drive, &stbuf)) {
    5.56 -		    /* Drive exists and is a CD-ROM */
    5.57 -		    case 1:
    5.58 -			AddDrive(drive, &stbuf);
    5.59 -			break;
    5.60 -			/* Drive exists, but isn't a CD-ROM */
    5.61 -		    case 0:
    5.62 -			break;
    5.63 -			/* Drive doesn't exist */
    5.64 -		    case -1:
    5.65 -			exists = 0;
    5.66 -			break;
    5.67 -		}
    5.68 -	    }
    5.69 +    for ( i = 0; checklist[i].dir; ++i) {
    5.70 +	DIR *devdir;
    5.71 +	struct dirent *devent;
    5.72 +	int name_len;
    5.73 +
    5.74 +	devdir = opendir(checklist[i].dir);
    5.75 +	if (devdir) {
    5.76 +	    name_len = strlen(checklist[i].name);
    5.77 +	    while (devent = readdir(devdir))
    5.78 +		if (memcmp(checklist[i].name, devent->d_name, name_len) == 0)
    5.79 +		    if (devent->d_name[devent->d_namlen-1] == 'c') {
    5.80 +			sprintf(drive, "%s/%s", checklist[i].dir, devent->d_name);
    5.81 +#ifdef DEBUG_CDROM
    5.82 +			fprintf(stderr, "Try to add drive: %s\n", drive);
    5.83 +#endif
    5.84 +			if ( CheckDrive(drive, &stbuf) > 0 )
    5.85 +			    AddDrive(drive, &stbuf);
    5.86 +		    }
    5.87 +	    closedir(devdir);
    5.88  	} else {
    5.89 -	    sprintf(drive, "/dev/%s", checklist[i]);
    5.90 -	    if ( CheckDrive(drive, &stbuf) > 0 ) {
    5.91 -		AddDrive(drive, &stbuf);
    5.92 -	    }
    5.93 +#ifdef DEBUG_CDROM
    5.94 +	    fprintf(stderr, "cannot open dir: %s\n", checklist[i].dir);
    5.95 +#endif
    5.96  	}
    5.97      }
    5.98 +
    5.99  /*
   5.100      SDLcdrom=malloc(sizeof(char) * 32);
   5.101      strcpy(SDLcdrom,"/dev/rdisk/cdrom0c");