Legacy:UnGnuG.H

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to navigation Jump to search

See Native Coding On Linux for information on how to use this headerfile.

<uscript> /*============================================================================= UnGnuG.h: Unreal definitions for Gnu G++. Unfinished. Unsupported. Copyright 1997-1999 Epic Games, Inc. All Rights Reserved. =============================================================================*/

/*---------------------------------------------------------------------------- Platform compiler definitions.


*/

  1. ifdef __LINUX_X86__

#define __UNIX__ 1 #define __LINUX__ 1 #define __INTEL__ 1 #define __INTEL_BYTE_ORDER__ 1 #undef ASM #undef ASM3DNOW #undef ASMKNI #define ASMLINUX 1

  1. else

#error Unsupported platform.

  1. endif

// Stack control.

  1. include <sys/wait.h>
  2. include <signal.h>
  3. include <setjmp.h>

class __Context { public: __Context() { Last = Env; } ~__Context() { Env = Last; } static void StaticInit(); static jmp_buf Env;

protected: static void HandleSignal( int Sig ); static struct sigaction Act_SIGHUP; static struct sigaction Act_SIGQUIT; static struct sigaction Act_SIGILL; static struct sigaction Act_SIGTRAP; static struct sigaction Act_SIGIOT; static struct sigaction Act_SIGBUS; static struct sigaction Act_SIGFPE; static struct sigaction Act_SIGSEGV; static struct sigaction Act_SIGTERM; jmp_buf Last; };

/*---------------------------------------------------------------------------- Platform specifics types and defines.


*/

// Undo any Windows defines.

  1. undef BYTE
  2. undef WORD
  3. undef DWORD
  4. undef INT
  5. undef FLOAT
  6. undef MAXBYTE
  7. undef MAXWORD
  8. undef MAXDWORD
  9. undef MAXINT
  10. undef VOID
  11. undef CDECL

// Make sure HANDLE is defined.

  1. define HANDLE DWORD
  2. define HINSTANCE DWORD

// Sizes. enum {DEFAULT_ALIGNMENT = 8 }; // Default boundary to align memory allocations on. enum {CACHE_LINE_SIZE = 32}; // Cache line size.

  1. define GCC_PACK(n) __attribute__((packed,aligned(n)))

// Optimization macros

  1. define DISABLE_OPTIMIZATION
  2. define ENABLE_OPTIMIZATION

// Function type macros.

  1. define DLL_IMPORT
  2. define DLL_EXPORT extern "C"
  3. define DLL_EXPORT_CLASS
  4. define VARARGS
  5. define CDECL
  6. define STDCALL
  7. define FORCEINLINE /* Force code to be inline */
  8. define ZEROARRAY 0 /* Zero-length arrays in structs */
  9. define __cdecl

// Variable arguments.

  1. define GET_VARARGS(msg,len,fmt) \

{ \ va_list ArgPtr; \ va_start( ArgPtr, fmt ); \ vsprintf( msg, fmt, ArgPtr ); \ va_end( ArgPtr ); \ }

  1. define GET_VARARGS_RESULT(msg,len,fmt,result) \

{ \ va_list ArgPtr; \ va_start( ArgPtr, fmt ); \ result = vsprintf( msg, fmt, ArgPtr ); \ va_end( ArgPtr ); \ }

// Compiler name.

  1. define COMPILER "Compiled with GNU g++ ("__VERSION__")"

// Unsigned base types. typedef unsigned char BYTE; // 8-bit unsigned. typedef unsigned short _WORD; // 16-bit unsigned. typedef unsigned int DWORD; // 32-bit unsigned. typedef unsigned long long QWORD; // 64-bit unsigned.

// Signed base types. typedef signed char SBYTE; // 8-bit signed. typedef signed short SWORD; // 16-bit signed. typedef signed int INT; // 32-bit signed. typedef signed long long SQWORD; // 64-bit signed.

// Character types. typedef char ANSICHAR; // An ANSI character. typedef unsigned short UNICHAR; // A unicode character. typedef unsigned char ANSICHARU; // An ANSI character. typedef unsigned short UNICHARU; // A unicode character.

// Other base types. typedef signed int UBOOL; // Boolean 0 (false) or 1 (true). typedef float FLOAT; // 32-bit IEEE floating point. typedef double DOUBLE; // 64-bit IEEE double. typedef unsigned int SIZE_T; // Corresponds to C SIZE_T.

// Bitfield type. typedef unsigned int BITFIELD; // For bitfields.

typedef unsigned int size_t;

// Make sure characters are unsigned.

  1. ifdef __CHAR_UNSIGNED__

#error "Bad compiler option: Characters must be signed"

  1. endif

// Strings.

  1. if __UNIX__
  2. define LINE_TERMINATOR TEXT("\n")
  3. define PATH_SEPARATOR TEXT("/")
  4. define DLLEXT TEXT(".so")
  5. else
  6. define LINE_TERMINATOR TEXT("\r\n")
  7. define PATH_SEPARATOR TEXT("\\")
  8. define DLLEXT TEXT(".dll")
  9. endif

// NULL.

  1. undef NULL
  2. define NULL 0

// Package implementation.

  1. define IMPLEMENT_PACKAGE_PLATFORM(pkgname) \

extern "C" {HINSTANCE hInstance;} \ BYTE GLoaded##pkgname;

// Platform support options.

  1. define PLATFORM_NEEDS_ARRAY_NEW 1
  2. define FORCE_ANSI_LOG 0

// OS unicode function calling.

  1. define TCHAR_CALL_OS(funcW,funcA) (funcA)
  2. define TCHAR_TO_ANSI(str) str
  3. define ANSI_TO_TCHAR(str) str

// !! Fixme: This is a workaround.

  1. define GCC_OPT_INLINE

// Memory

  1. define appAlloca(size) alloca((size+7)&~7)

extern CORE_API UBOOL GTimestamp; CORE_API extern FLOAT GSecondsPerCycle;

// // Round a floating point number to an integer. // Note that (int+.5) is rounded to (int+1). //

  1. define DEFINED_appRound 1

inline INT appRound( FLOAT F ) { return (INT)(F); }

// // Converts to integer equal to or less than. //

  1. define DEFINED_appFloor 1

inline INT appFloor( FLOAT F ) { static FLOAT Half=0.5; return (INT)(F - Half); }

// // CPU cycles, related to GSecondsPerCycle. //

  1. define DEFINED_appCycles 1

inline DWORD appCycles() { if( GTimestamp ) { DWORD r; asm("rdtsc" : "=a" (r) : "d" (r)); return r; } }

// // Memory copy. //

  1. define DEFINED_appMemcpy 1

inline void appMemcpy( void* Dest, const void* Src, INT Count ) { asm volatile(" pushl %%ebx; pushl %%ecx; pushl %%esi; pushl %%edi; mov %%ecx, %%ebx; shr $2, %%ecx; and $3, %%ebx; rep; movsl; mov %%ebx, %%ecx; rep; movsb; popl %%edi; popl %%esi; popl %%ecx; popl %%ebx; " : : "S" (Src), "D" (Dest), "c" (Count) ); }

// // Memory zero. //

  1. define DEFINED_appMemzero 1

inline void appMemzero( void* Dest, INT Count ) { memset( Dest, 0, Count ); }

/*---------------------------------------------------------------------------- Globals.


*/

// System identification. extern "C" { extern HINSTANCE hInstance; extern CORE_API UBOOL GIsMMX; extern CORE_API UBOOL GIsPentiumPro; extern CORE_API UBOOL GIsKatmai; extern CORE_API UBOOL GIsK6; extern CORE_API UBOOL GIs3DNow; extern CORE_API UBOOL GTimestamp; }

// Module name extern ANSICHAR GModule[32];

/*----------------------------------------------------------------------------

The End.


*/

</uscript>


El Muerte TDS: Intresting header, but why here ?

Mr.Mitchell: It is related to Native Coding On Linux, as far as I understand you need it to compile UT native mods on Linux