mirror of https://github.com/PCSX2/pcsx2.git
Redid the structure packing macros a bit: added __packed, a bunch of comments, and removed a few ugly #ifdefs.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2146 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
f716232ea8
commit
5f26a90b36
|
@ -179,12 +179,46 @@
|
|||
|
||||
// Defines the memory page size for the target platform at compilation. All supported platforms
|
||||
// (which means Intel only right now) have a 4k granularity.
|
||||
|
||||
#define PCSX2_PAGESIZE 0x1000
|
||||
static const int __pagesize = PCSX2_PAGESIZE;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Structure Packing (__packed)
|
||||
//
|
||||
// Current Method:
|
||||
// Use a combination of embedded compiler-specific #pragma mess in conjunction with a
|
||||
// __packed macro. The former appeases the MSVC gods, the latter appeases the GCC gods.
|
||||
// The end result looks something like this:
|
||||
//
|
||||
// #ifdef _MSC_VER
|
||||
// # pragma pack(1)
|
||||
// #endif
|
||||
//
|
||||
// struct SomeKindaFail {
|
||||
// u8 neat;
|
||||
// u32 unaligned32;
|
||||
// } __packed;
|
||||
//
|
||||
// MSVC 2008 and better support __pragma, however there's no way to support that in
|
||||
// a way that's backwards compatible to VS 2005, without still including the old-style
|
||||
// #pragma mess. So there's really not much point (yet) in using it. I've included macros
|
||||
// that utilize __pragma (commented out below) which can be deployed at a time when we
|
||||
// are ok with the idea of completely breaking backwards compat with VC2005/prior.
|
||||
//
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// Microsoft Visual Studio
|
||||
// --------------------------------------------------------------------------------------
|
||||
#ifdef _MSC_VER
|
||||
|
||||
// Using these breaks compat with VC2005; so we're not using it yet.
|
||||
//# define __pack_begin __pragma(pack(1))
|
||||
//# define __pack_end __pragma(pack())
|
||||
|
||||
// This is the 2005/earlier compatible packing define, which must be used in conjunction
|
||||
// with #ifdef _MSC_VER/#pragma pack() directives (ugly).
|
||||
# define __packed
|
||||
|
||||
# define __aligned(alig) __declspec(align(alig))
|
||||
# define __aligned16 __declspec(align(16))
|
||||
# define __pagealigned __declspec(align(PCSX2_PAGESIZE))
|
||||
|
@ -205,32 +239,15 @@ static const int __pagesize = PCSX2_PAGESIZE;
|
|||
# define likely(x) x
|
||||
# define unlikely(x) x
|
||||
|
||||
# define CALLBACK __stdcall
|
||||
# define CALLBACK __stdcall
|
||||
|
||||
#else
|
||||
|
||||
// GCC 4.4.0 is a bit nutty, as compilers go. it gets a define to itself.
|
||||
# define GCC_VERSION (__GNUC__ * 10000 \
|
||||
+ __GNUC_MINOR__ * 100 \
|
||||
+ __GNUC_PATCHLEVEL__)
|
||||
// --------------------------------------------------------------------------------------
|
||||
// GCC / Intel Compilers Section
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
/* Test for GCC > 4.4.0; Should be adjusted when new versions come out */
|
||||
# if GCC_VERSION >= 40400
|
||||
# define THE_UNBEARABLE_LIGHTNESS_OF_BEING_GCC_4_4_0
|
||||
# define __nooptimization __attribute__((optimize("O0")))
|
||||
# endif
|
||||
|
||||
/*
|
||||
This theoretically unoptimizes. Not having much luck so far.
|
||||
# ifdef THE_UNBEARABLE_LIGHTNESS_OF_BEING_GCC_4_4_0
|
||||
# pragma GCC optimize ("O0")
|
||||
# endif
|
||||
|
||||
# ifdef THE_UNBEARABLE_LIGHTNESS_OF_BEING_GCC_4_4_0
|
||||
# pragma GCC reset_options
|
||||
# endif
|
||||
|
||||
*/
|
||||
# define __packed __attribute__((packed))
|
||||
|
||||
# define __aligned(alig) __attribute__((aligned(alig)))
|
||||
# define __aligned16 __attribute__((aligned(16)))
|
||||
|
|
|
@ -23,29 +23,25 @@
|
|||
|
||||
#include "Common.h"
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma pack(1)
|
||||
#ifdef _MSC_VER
|
||||
# pragma pack(1)
|
||||
#endif
|
||||
|
||||
struct TocEntry
|
||||
{
|
||||
u32 fileLBA;
|
||||
u32 fileSize;
|
||||
u8 fileProperties;
|
||||
u8 padding1[3];
|
||||
u32 fileLBA;
|
||||
u32 fileSize;
|
||||
u8 fileProperties;
|
||||
u8 padding1[3];
|
||||
char filename[128+1];
|
||||
u8 date[7];
|
||||
#if defined(_MSC_VER)
|
||||
};
|
||||
#else
|
||||
} __attribute__((packed));
|
||||
u8 date[7];
|
||||
} __packed;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma pack()
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
int IsoFS_findFile(const char* fname, struct TocEntry* tocEntry);
|
||||
int IsoFS_readSectors(u32 lsn, u32 sectors, void *buf);
|
||||
extern int IsoFS_findFile(const char* fname, struct TocEntry* tocEntry);
|
||||
extern int IsoFS_readSectors(u32 lsn, u32 sectors, void *buf);
|
||||
|
||||
#endif // _ISOFSCDVD_H
|
||||
|
|
|
@ -17,16 +17,14 @@
|
|||
* Modified by Florin for PCSX2 emu
|
||||
*/
|
||||
|
||||
#ifndef __ISOFSDRV_H__
|
||||
#define __ISOFSDRV_H__
|
||||
#pragma once
|
||||
|
||||
#include "IsoFScdvd.h"
|
||||
|
||||
/* Filing-system exported functions */
|
||||
void IsoFS_init();
|
||||
int IsoFS_open(const char *name, int mode);
|
||||
int IsoFS_lseek(int fd, int offset, int whence);
|
||||
int IsoFS_read( int fd, char * buffer, int size );
|
||||
int IsoFS_close( int fd);
|
||||
extern void IsoFS_init();
|
||||
extern int IsoFS_open(const char *name, int mode);
|
||||
extern int IsoFS_lseek(int fd, int offset, int whence);
|
||||
extern int IsoFS_read( int fd, char * buffer, int size );
|
||||
extern int IsoFS_close(int fd);
|
||||
|
||||
#endif//__ISOFSDRV_H__
|
||||
|
|
|
@ -17,19 +17,18 @@
|
|||
* Modified by Florin for PCSX2 emu
|
||||
*/
|
||||
|
||||
#ifndef __ISOFSTOOLS_H__
|
||||
#define __ISOFSTOOLS_H__
|
||||
#pragma once
|
||||
|
||||
#include "IsoFScdvd.h"
|
||||
|
||||
int IsoFS_initDirectoryList(char* pathname, char* extensions, unsigned int inc_dirs);
|
||||
int IsoFS_getDirectories(TocEntry tocEntry[], int req_entries);
|
||||
|
||||
#define CD_SECS 60 /* seconds per minute */
|
||||
#define CD_FRAMES 75 /* frames per second */
|
||||
#define CD_MSF_OFFSET 150 /* MSF numbering offset of first frame */
|
||||
static const int CD_SECS = 60; // seconds per minute
|
||||
static const int CD_FRAMES = 75; // frames per second
|
||||
static const int CD_MSF_OFFSET = 150; // MSF numbering offset of first frame
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#ifdef _MSC_VER
|
||||
# pragma pack(1)
|
||||
#endif
|
||||
|
||||
|
@ -44,11 +43,8 @@ struct rootDirTocHeader
|
|||
u8 reserved[6]; //+1A
|
||||
u8 reserved2; //+20
|
||||
u8 reserved3; //+21
|
||||
#if defined(_MSC_VER)
|
||||
}; //+22
|
||||
#else
|
||||
} __attribute__((packed));
|
||||
#endif
|
||||
|
||||
} __packed; //+22
|
||||
|
||||
struct asciiDate
|
||||
{
|
||||
|
@ -60,11 +56,7 @@ struct asciiDate
|
|||
char seconds[2];
|
||||
char hundreths[2];
|
||||
char terminator[1];
|
||||
#if defined(_MSC_VER)
|
||||
};
|
||||
#else
|
||||
} __attribute__((packed));
|
||||
#endif
|
||||
} __packed;
|
||||
|
||||
struct cdVolDesc
|
||||
{
|
||||
|
@ -80,6 +72,7 @@ struct cdVolDesc
|
|||
u8 reserved6[32];
|
||||
u32 unknown1;
|
||||
u32 unknown1_bigend;
|
||||
|
||||
u16 volDescSize; //+80
|
||||
u16 volDescSize_bigend; //+82
|
||||
u32 unknown3; //+84
|
||||
|
@ -88,7 +81,9 @@ struct cdVolDesc
|
|||
u32 reserved7; //+90
|
||||
u32 secDirTableLBA; // LBA of Secondary Dir Table //+94
|
||||
u32 reserved8; //+98
|
||||
struct rootDirTocHeader rootToc;
|
||||
|
||||
rootDirTocHeader rootToc;
|
||||
|
||||
s8 volSetName[128];
|
||||
s8 publisherName[128];
|
||||
s8 preparerName[128];
|
||||
|
@ -96,17 +91,15 @@ struct cdVolDesc
|
|||
s8 copyrightFileName[37];
|
||||
s8 abstractFileName[37];
|
||||
s8 bibliographyFileName[37];
|
||||
struct asciiDate creationDate;
|
||||
struct asciiDate modificationDate;
|
||||
struct asciiDate effectiveDate;
|
||||
struct asciiDate expirationDate;
|
||||
|
||||
asciiDate creationDate;
|
||||
asciiDate modificationDate;
|
||||
asciiDate effectiveDate;
|
||||
asciiDate expirationDate;
|
||||
|
||||
u8 reserved10;
|
||||
u8 reserved11[1166];
|
||||
#if defined(_MSC_VER)
|
||||
};
|
||||
#else
|
||||
} __attribute__((packed));
|
||||
#endif
|
||||
} __packed;
|
||||
|
||||
struct dirTableEntry
|
||||
{
|
||||
|
@ -115,34 +108,30 @@ struct dirTableEntry
|
|||
u32 dirTOCLBA;
|
||||
u16 dirDepth;
|
||||
u8 dirName[32];
|
||||
#if defined(_MSC_VER)
|
||||
};
|
||||
#else
|
||||
} __attribute__((packed));
|
||||
#endif
|
||||
} __packed;
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// dirTocEntry
|
||||
// --------------------------------------------------------------------------------------
|
||||
// This is the internal Table of Contents, as found on the CD
|
||||
// TocEntry structure contains only the important stuff needed for export.
|
||||
|
||||
struct dirTocEntry
|
||||
{
|
||||
short length;
|
||||
u32 fileLBA;
|
||||
u32 fileLBA_bigend;
|
||||
u32 fileSize;
|
||||
u32 fileSize_bigend;
|
||||
u8 dateStamp[6];
|
||||
u8 reserved1;
|
||||
u8 fileProperties;
|
||||
u8 reserved2[6];
|
||||
u8 filenameLength;
|
||||
char filename[128];
|
||||
#if defined(_MSC_VER)
|
||||
};
|
||||
#else
|
||||
} __attribute__((packed));
|
||||
#endif // This is the internal format on the CD
|
||||
// TocEntry structure contains only the important stuff needed for export
|
||||
s16 length;
|
||||
u32 fileLBA;
|
||||
u32 fileLBA_bigend;
|
||||
u32 fileSize;
|
||||
u32 fileSize_bigend;
|
||||
u8 dateStamp[6];
|
||||
u8 reserved1;
|
||||
u8 fileProperties;
|
||||
u8 reserved2[6];
|
||||
u8 filenameLength;
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma pack()
|
||||
char filename[128];
|
||||
} __packed;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma pack()
|
||||
#endif
|
||||
|
||||
#endif//__ISOFSTOOLS_H__
|
||||
|
|
|
@ -1016,13 +1016,10 @@ struct TGA_HEADER
|
|||
u8 descriptor; // image descriptor bits (vh flip bits)
|
||||
|
||||
// pixel data follows header
|
||||
} __packed;
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
};
|
||||
|
||||
#pragma pack()
|
||||
#else
|
||||
} __attribute__((packed));
|
||||
|
||||
# pragma pack()
|
||||
#endif
|
||||
|
||||
void SaveTGA(const char* filename, int width, int height, void* pdata)
|
||||
|
|
|
@ -26,18 +26,18 @@
|
|||
// romdir structure (packing required!)
|
||||
//
|
||||
#if defined(_MSC_VER)
|
||||
#pragma pack(1)
|
||||
# pragma pack(1)
|
||||
#endif
|
||||
|
||||
struct romdir
|
||||
{
|
||||
char fileName[10];
|
||||
u16 extInfoSize;
|
||||
u32 fileSize;
|
||||
#if defined(_MSC_VER)
|
||||
};
|
||||
#pragma pack() //+22
|
||||
#else
|
||||
} __attribute__((packed));
|
||||
} __packed; // +22
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma pack()
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -25,12 +25,12 @@ union regInfo {
|
|||
};
|
||||
};
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma pack(1)
|
||||
#pragma warning(disable:4996)
|
||||
#ifdef _MSC_VER
|
||||
# pragma pack(1)
|
||||
# pragma warning(disable:4996) // 'function': was declared deprecated
|
||||
#endif
|
||||
|
||||
__declspec(align(16)) struct microRegInfo { // Ordered for Faster Compares
|
||||
__aligned16 struct microRegInfo { // Ordered for Faster Compares
|
||||
u32 vi15; // Constant Prop Info for vi15 (only valid if sign-bit set)
|
||||
u8 needExactMatch; // If set, block needs an exact match of pipeline state
|
||||
u8 q;
|
||||
|
@ -43,21 +43,16 @@ __declspec(align(16)) struct microRegInfo { // Ordered for Faster Compares
|
|||
u8 flags; // clip x2 :: status x2
|
||||
u8 blockType; // 0 = Normal; 1,2 = Compile one instruction (E-bit/Branch Ending)
|
||||
u8 padding[5]; // 160 bytes
|
||||
#if defined(_MSC_VER)
|
||||
};
|
||||
#else
|
||||
} __attribute__((packed));
|
||||
#endif
|
||||
} __packed;
|
||||
|
||||
__declspec(align(16)) struct microBlock {
|
||||
__aligned16 struct microBlock {
|
||||
microRegInfo pState; // Detailed State of Pipeline
|
||||
microRegInfo pStateEnd; // Detailed State of Pipeline at End of Block (needed by JR/JALR opcodes)
|
||||
u8* x86ptrStart; // Start of code
|
||||
#if defined(_MSC_VER)
|
||||
};
|
||||
#pragma pack()
|
||||
#else
|
||||
} __attribute__((packed));
|
||||
} __packed;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma pack()
|
||||
#endif
|
||||
|
||||
struct microTempRegInfo {
|
||||
|
|
Loading…
Reference in New Issue