//////////////////////////////////////////////////////////////////////////////
//
// PS2_in_VC.h
//
// Copyright (c) 2002-2003 Rebellion. All rights reserved.
// Based on small SN Systems example file.
//
// This file allows PS2 code to compile under MSVC, once you made the
// following changes to the PS2 stdlib headers as well:
//
//     \usr\local\sce\ee\include\eestruct.h:
//          Change all structs to use paddings of <= 32 bits.
//
//     \usr\local\sce\ee\gcc\lib\gcc-lib\ee\2.95.3\include\stddef.h:
//          Replace the section under "/* A null pointer constant.  */" with
//          the following:
//              #if defined (_STDDEF_H) || defined (__need_NULL)
//                  #undef NULL /* in case <stdio.h> has defined it. */
//                  #ifdef _MSC_VER
//                      #define NULL (0)
//                  #elif defined(__GNUG__)
//                      #define NULL __null
//                  #else /* G++ */
//                      #define NULL ((void *)0)
//                  #endif /* G++ */
//              #endif /* NULL not defined and <stddef.h> or need NULL.  */
//              #undef __need_NULL
//
// Pre-modified files are available on Sourcesafe.
//
//////////////////////////////////////////////////////////////////////////////

// B E G I N   F I L E   W R A P P E R ///////////////////////////////////////

#pragma once

#ifndef ___PS2_IN_VC_H___
#define ___PS2_IN_VC_H___ 1

// M A C R O S   A N D   T Y P E S ///////////////////////////////////////////

#define ASURA_PS2_IN_VC 1

// (MH - 27.10.2003) fool the VC pass into thinking it's the GCC compiler.
// full list in sn newsgroup on 24th Jan 2003, RE: stl_msvc.h
//#undef _MSC_VER
// problems with NULL in stddef unless _MSC_VER is defined...
#undef _WIN32
#undef WIN32
#define __mips 3
#define __mips64


// (MP - 13.04.2002) We want to #define ASURA_USE_PRAGMA_ONCE here to speed
// up the PC side of the build. Note that we don't want to #define it in the
// project (as we would on the PC, etc.) because the PS2 compiler complains
// about it.
#ifdef ASURA_USE_PRAGMA_ONCE
    #error ASURA_USE_PRAGMA_ONCE shouldn't be defined already!
#endif
#define ASURA_USE_PRAGMA_ONCE

//
// This will nullify all of the GNU compiler's __attribute__ things.
//
#define __attribute__(a)

//
// This will prevent an Endian not defined error.
//
#define __IEEE_LITTLE_ENDIAN

//
// This will prevent a size_t redefinition error.
//
// (MP - 08.05.2003) IOP builds seem to need to have this defined by the
// PS2 headers.
//
#ifdef __cplusplus
#define __size_t__
#endif

//
// This will prevent errors by headers which use u_long128.  Obviously
// the type defined below is only 32 bits, but (1) this is what the real
// headers seem to do in the GNU compiler and more importantly (2) it works!
//
typedef unsigned int u_long128;

// (MP - 17.12.2001) And the same for long128.
typedef int long128;

// (MP - 17.12.2001) Hmm. This seems to be necessary to get the PS2's _ansi.h
// header to allow proper function declarations.
#define __STDC__

// (MP - 17.12.2001) But then it also wants a wchar_t type...
//typedef char wchar_t;
#ifdef __cplusplus
typedef unsigned short wchar_t;
#endif

// (MP - 17.12.2001) A fix for problems in libdma.h and possibly elsewhere.
#ifdef __cplusplus
#define INLINE static inline
#else
#define INLINE 
#endif

// (MP - 17.12.2001) To prevent VC complaining about usage of asm("") or
// asm __volatile__("")...
// (MP - 03.01.2002) My previous attempt was to attempt a replacement function
// with variable args. This wasn't sufficient. Here's Matthew Clemson's 
// suggestion.
#define asm /##/
#define __asm__ /##/

// (MP - 17.12.2001) VC supports outdated scoping on for loops, hence the
// following.
// (MP - 01.10.2002) Don't do this when Lint is present because it confuses
// it - it fails to deduce the loop will always be executed and you end up
// with warnings about things possibly being used when uninitialised.
#ifndef _lint
#define for if( 0 ) { } else for
#endif

// (MP - 03.01.2002) Some fixes for variable argument stuff.
#define __builtin_next_arg
typedef char* va_list;
#define _VA_LIST_
typedef char* __gnuc_va_list;
#define __GNUC_VA_LIST

#ifdef _lint
// (MP - 18.09.2002) Fix a bunch of Lint warnings for standard headers, etc.
#include "PS2_in_Lint.h"
#endif

#ifndef __cplusplus
#define __const 
#endif

// (MP - 27.03.2003) SN's version of GCC provides these cut-down versions of
// the usual __FILE__ preprocessor macro. We use them to reduce amount of
// text added to executables in assert builds.
#define __SN_FILE__      ""
#define __SN_BASE_FILE__ ""

#define __builtin_return_address(level) (reinterpret_cast<void*>(NULL))

// (MP - 23.10.2003) Latest libc from SN requires this.
#define __restrict

// E N D   F I L E   W R A P P E R ///////////////////////////////////////////

#endif // #ifndef ___PS2_IN_VC_H___

