- Added Blzut3's Solaris patch.

SVN r2070 (trunk)
This commit is contained in:
Christoph Oelckers 2010-01-01 09:21:04 +00:00
parent 3f4f0a8ae4
commit 9aa1e20c77
10 changed files with 165 additions and 6 deletions

View file

@ -7,6 +7,7 @@ January 1, 2010 (SBARINFO update)
inventory items and armortype in drawswitchableimage.
January 1, 2010 (Changes by Graf Zahl)
- Added Blzut3's Solaris patch.
- Fixed: Heretic's Weredragon (Beast) should not have a melee state.
December 31, 2009 (Changes by Graf Zahl)

View file

@ -774,6 +774,11 @@ add_executable( zdoom WIN32
set_source_files_properties( xlat/parse_xlat.cpp PROPERTIES OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/xlat_parser.c" )
set_source_files_properties( sc_man.cpp PROPERTIES OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/sc_man_scanner.h" )
if(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS")
# [BL] Solaris requires these to be explicitly linked.
set( ZDOOM_LIBS ${ZDOOM_LIBS} nsl socket)
endif(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS")
target_link_libraries( zdoom ${ZDOOM_LIBS} gme gdtoa dumb lzma )
include_directories( .
g_doom

View file

@ -46,6 +46,9 @@
# include <unistd.h>
# include <netdb.h>
# include <sys/ioctl.h>
# ifdef __sun
# include <fcntl.h>
# endif
#endif
#include "doomtype.h"
@ -422,7 +425,11 @@ void StartNetwork (bool autoPort)
// create communication socket
mysocket = UDPsocket ();
BindToLocalPort (mysocket, autoPort ? 0 : DOOMPORT);
#ifndef __sun
ioctlsocket (mysocket, FIONBIO, &trueval);
#else
fcntl(mysocket, F_SETFL, trueval | O_NONBLOCK);
#endif
}
void SendAbort (void)

View file

@ -52,11 +52,14 @@
#endif
#if defined(__APPLE__)
#define _msize(p) malloc_size(p)
#elif defined(__sun)
#define _msize(p) (*((size_t*)(p)-1))
#elif !defined(_WIN32)
#define _msize(p) malloc_usable_size(p) // from glibc/FreeBSD
#endif
#ifndef _DEBUG
#if !defined(__sun)
void *M_Malloc(size_t size)
{
void *block = malloc(size);
@ -83,10 +86,50 @@ void *M_Realloc(void *memblock, size_t size)
return block;
}
#else
void *M_Malloc(size_t size)
{
void *block = malloc(size+sizeof(size_t));
if (block == NULL)
I_FatalError("Could not malloc %zu bytes", size);
size_t *sizeStore = (size_t *) block;
*sizeStore = size;
block = sizeStore+1;
GC::AllocBytes += _msize(block);
return block;
}
void *M_Realloc(void *memblock, size_t size)
{
if(memblock == NULL)
return M_Malloc(size);
if (memblock != NULL)
{
GC::AllocBytes -= _msize(memblock);
}
void *block = realloc(((size_t*) memblock)-1, size+sizeof(size_t));
if (block == NULL)
{
I_FatalError("Could not realloc %zu bytes", size);
}
size_t *sizeStore = (size_t *) block;
*sizeStore = size;
block = sizeStore+1;
GC::AllocBytes += _msize(block);
return block;
}
#endif
#else
#ifdef _MSC_VER
#include <crtdbg.h>
#endif
#if !defined(__sun)
void *M_Malloc_Dbg(size_t size, const char *file, int lineno)
{
void *block = _malloc_dbg(size, _NORMAL_BLOCK, file, lineno);
@ -112,8 +155,49 @@ void *M_Realloc_Dbg(void *memblock, size_t size, const char *file, int lineno)
GC::AllocBytes += _msize(block);
return block;
}
#else
void *M_Malloc_Dbg(size_t size, const char *file, int lineno)
{
void *block = _malloc_dbg(size+sizeof(size_t), _NORMAL_BLOCK, file, lineno);
if (block == NULL)
I_FatalError("Could not malloc %zu bytes", size);
size_t *sizeStore = (size_t *) block;
*sizeStore = size;
block = sizeStore+1;
GC::AllocBytes += _msize(block);
return block;
}
void *M_Realloc_Dbg(void *memblock, size_t size, const char *file, int lineno)
{
if(memblock == NULL)
return M_Malloc_Dbg(size, file, lineno);
if (memblock != NULL)
{
GC::AllocBytes -= _msize(memblock);
}
void *block = _realloc_dbg(((size_t*) memblock)-1, size+sizeof(size_t), _NORMAL_BLOCK, file, lineno);
if (block == NULL)
{
I_FatalError("Could not realloc %zu bytes", size);
}
size_t *sizeStore = (size_t *) block;
*sizeStore = size;
block = sizeStore+1;
GC::AllocBytes += _msize(block);
return block;
}
#endif
#endif
#if !defined(__sun)
void M_Free (void *block)
{
if (block != NULL)
@ -122,3 +206,14 @@ void M_Free (void *block)
free(block);
}
}
#else
void M_Free (void *block)
{
if(block != NULL)
{
GC::AllocBytes -= _msize(block);
free(((size_t*) block)-1);
}
}
#endif

View file

@ -274,11 +274,11 @@ void P_ProcessSwitchDef (FScanner &sc)
{
if (def2 != NULL)
{
free (def2);
M_Free (def2);
}
if (def1 != NULL)
{
free (def1);
M_Free (def1);
}
return;
}

View file

@ -41,8 +41,10 @@
#define stat _stat
#else
#include <dirent.h>
#ifndef __sun
#include <fts.h>
#endif
#endif
#include <stdio.h>
#include <string.h>
#include <ctype.h>
@ -197,6 +199,46 @@ int FDirectory::AddDirectory(const char *dirpath)
return count;
}
#elif defined(__sun)
int FDirectory::AddDirectory(const char *dirpath)
{
int count = 0;
TArray<FString> scanDirectories;
scanDirectories.Push(dirpath);
for(unsigned int i = 0;i < scanDirectories.Size();i++)
{
DIR* directory = opendir(scanDirectories[i].GetChars());
if (directory == NULL)
{
Printf("Could not ready directory: %s\n", strerror(errno));
return NULL;
}
struct dirent *file;
while((file = readdir(directory)) != NULL)
{
if(file->d_name[0] == '.') //File is hidden or ./.. directory so ignore it.
continue;
FString fullFileName = scanDirectories[i] + file->d_name;
struct stat fileStat;
stat(fullFileName.GetChars(), &fileStat);
if(S_ISDIR(fileStat.st_mode))
{
scanDirectories.Push(scanDirectories[i] + file->d_name + "/");
continue;
}
AddEntry(scanDirectories[i] + file->d_name, fileStat.st_size);
count++;
}
closedir(directory);
}
return count;
}
#else
//==========================================================================
@ -294,6 +336,7 @@ FileReader *FDirectoryLump::NewReader()
{
FString fullpath = Owner->Filename;
fullpath += FullName;
printf("%s\n", fullpath.GetChars());
return new FileReader(fullpath);
}
catch (CRecoverableError &)

View file

@ -8,6 +8,12 @@
#include <errno.h>
#include <sys/ucontext.h>
// Solaris doesn't have SA_ONESHOT
// According to the Linux header this is the same.
#ifndef SA_ONESHOT
#define SA_ONESHOT SA_RESETHAND
#endif
static const char *cc_logfile = NULL;
static char respfile[256];

View file

@ -46,6 +46,8 @@ extern HWND Window;
#endif
#ifdef __APPLE__
#include <stdlib.h>
#elif __sun
#include <alloca.h>
#else
#include <malloc.h>
#endif

View file

@ -73,7 +73,7 @@ protected:
static bool read(SoundStream *stream, void *buff, int len, void *userdata);
};
#pragma pack(push, 1)
#pragma pack(1)
typedef struct tagITFILEHEADER
{
@ -108,7 +108,7 @@ typedef struct MODMIDICFG
char szMidiZXXExt[128*32]; // changed from CHAR
} MODMIDICFG, *LPMODMIDICFG;
#pragma pack(pop)
#pragma pack()
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------

View file

@ -1,7 +1,7 @@
#ifndef __W_ZIP
#define __W_ZIP
#pragma pack(push, 1)
#pragma pack(1)
// FZipCentralInfo
struct FZipEndOfCentralDirectory
{
@ -56,7 +56,7 @@ struct FZipLocalFileHeader
};
#pragma pack(pop)
#pragma pack()
#define ZIP_LOCALFILE MAKE_ID('P','K',3,4)
#define ZIP_CENTRALFILE MAKE_ID('P','K',1,2)