CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

cssysdef.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 1998-2001 by Jorrit Tyberghein
00003     Written by Andrew Zabolotny <bit@eltech.ru>
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public
00016     License along with this library; if not, write to the Free
00017     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 */
00019 
00020 #ifdef __CS_CSSYSDEFS_H__
00021 #error Do not include cssysdef.h from header files please!
00022 #else
00023 #define __CS_CSSYSDEFS_H__
00024 
00025 #define CSDEF_FRIEND
00026 #include "csdef.h"
00027 #undef CSDEF_FRIEND
00028 
00070 /*
00071  * Pull in platform-specific overrides of the requested functionality.
00072  */
00073 #include "csutil/csosdefs.h"
00074 
00075 #include "csextern.h"
00076 
00077 /*
00078  * Default definitions for requested functionality.  Platform-specific
00079  * configuration files may override these.
00080  */
00081 
00088 #ifdef COMP_GCC
00089 // In GCC we are able to declare stack vars of dynamic size directly
00090 #  define CS_ALLOC_STACK_ARRAY(type, var, size) \
00091       type var [size]
00092 #else
00093 #  include <malloc.h>
00094 #  define CS_ALLOC_STACK_ARRAY(type, var, size) \
00095       type *var = (type *)alloca ((size) * sizeof (type))
00096 #endif
00097 
00101 #ifdef CS_SYSDEF_PROVIDE_TEMP
00102 #  ifndef TEMP_DIR
00103 #    if defined(OS_UNIX)
00104 #      define TEMP_DIR "/tmp/"
00105 #    else
00106 #      define TEMP_DIR ""
00107 #    endif
00108 #  endif
00109 #  ifndef TEMP_FILE
00110 #    if defined(OS_UNIX)
00111 #      include <unistd.h>
00113 #      define TEMP_FILE "cs%lud.tmp", (unsigned long)getpid()
00114 #    else
00115 
00116 #      define TEMP_FILE "$cs$.tmp"
00117 #    endif
00118 #  endif
00119 #endif // CS_SYSDEF_PROVIDE_TEMP
00120 
00124 #ifdef CS_SYSDEF_PROVIDE_MKDIR
00125 #  ifndef MKDIR
00126 #    if defined(OS_WIN32) || (defined(OS_DOS) && !defined(COMP_GCC))
00127 #      define MKDIR(path) _mkdir (path)
00128 #    else
00129 #      define MKDIR(path) mkdir (path, 0755)
00130 #    endif
00131 #  endif
00132 #endif // CS_SYSDEF_PROVIDE_MKDIR
00133 
00134 #ifdef CS_SYSDEF_PROVIDE_GETCWD
00135 #  if !defined(COMP_VC) && !defined(COMP_BC)
00136 #    include <unistd.h>
00137 #  endif
00138 #endif // CS_SYSDEF_PROVIDE_GETCWD
00139 
00140 #ifdef CS_SYSDEF_PROVIDE_DIR
00141 // For systems without opendir()
00142 // Although COMP_GCC has opendir, readdir, CS' versions are preferred.
00143 # if defined(__NEED_OPENDIR_PROTOTYPE)
00144      struct DIR;
00145      struct dirent;
00146      extern "C" CS_CSUTIL_EXPORT DIR *opendir (const char *name);
00147      extern "C" CS_CSUTIL_EXPORT dirent *readdir (DIR *dirp);
00148      extern "C" CS_CSUTIL_EXPORT int closedir (DIR *dirp);
00149      //extern "C" void seekdir (DIR *dirp, long off);
00150      //extern "C" long telldir (DIR *dirp);
00151      //extern "C" void rewinddir (DIR *dirp);
00152 # endif
00153 // Generic ISDIR where needed
00154 #  ifdef __NEED_GENERIC_ISDIR
00155 #    if defined (OS_WIN32) || defined (OS_DOS)
00156 #      include <io.h>
00157 #    endif
00158 #    include <sys/types.h>
00159 #    if !defined(OS_WIN32)
00160 #      include <dirent.h>
00161 #    endif
00162 #    include <sys/stat.h>
00163      static inline bool isdir (const char *path, struct dirent *de)
00164      {
00165        int pathlen = strlen (path);
00166        CS_ALLOC_STACK_ARRAY(char, fullname, pathlen + 2 + strlen (de->d_name));
00167        memcpy (fullname, path, pathlen + 1);
00168        
00169        if ((pathlen) && (fullname[pathlen-1] != PATH_SEPARATOR))
00170        {
00171          fullname[pathlen++] = PATH_SEPARATOR;
00172          fullname[pathlen] = 0;
00173        }
00174               
00175        strcat (&fullname [pathlen], de->d_name);
00176        struct stat st;
00177        stat (fullname, &st);
00178        return ((st.st_mode & S_IFMT) == S_IFDIR);
00179      }
00180 #  endif
00181 #endif // CS_SYSDEF_PROVIDE_DIR
00182 
00183 #ifdef CS_SYSDEF_PROVIDE_UNLINK
00184 #  if !defined(COMP_VC) && !defined(COMP_BC)
00185 #    include <unistd.h>
00186 #  endif
00187 #endif
00188 
00189 #ifdef CS_SYSDEF_PROVIDE_ACCESS
00190 #  if !defined(COMP_VC) && !defined(COMP_BC)
00191 #    include <unistd.h>
00192 #  endif
00193 #  ifndef F_OK
00194 #    define F_OK 0
00195 #  endif
00196 #  ifndef R_OK
00197 #    define R_OK 2
00198 #  endif
00199 #  ifndef W_OK
00200 #    define W_OK 4
00201 #  endif
00202 #endif
00203 
00204 #ifdef CS_SYSDEF_PROVIDE_GETOPT
00205 #  ifndef __STDC__
00206 #    define __STDC__ 1
00207 #  endif
00208 #  include "csutil/getopt.h"
00209 #endif
00210 
00211 #ifdef CS_SYSDEF_PROVIDE_SOCKETS
00212 # ifdef __GNUC__
00213 #  warning CS_SYSDEF_PROVIDE_SOCKETS is deprecated, include cssys/sockets.h instead
00214 # endif
00215 #include "csutil/sockets.h"
00216 #endif
00217 
00218 #ifdef CS_SYSDEF_PROVIDE_SELECT
00219 #  include <sys/select.h>
00220 #endif
00221 
00237 #define CS_HEADER_GLOBAL(X,Y) CS_HEADER_GLOBAL_COMPOSE(X,Y)
00238 #define CS_HEADER_GLOBAL_COMPOSE(X,Y) <X/Y>
00239 
00252 #define CS_HEADER_LOCAL(X,Y) CS_HEADER_LOCAL_COMPOSE1(X,Y)
00253 #define CS_HEADER_LOCAL_COMPOSE1(X,Y) CS_HEADER_LOCAL_COMPOSE2(X/Y)
00254 #define CS_HEADER_LOCAL_COMPOSE2(X) #X
00255 
00256 
00262 #if !defined(CS_EXPORTED_FUNCTION)
00263 #  define CS_EXPORTED_FUNCTION extern "C"
00264 #endif
00265 
00277 #if !defined(CS_EXPORTED_NAME)
00278 #  define CS_EXPORTED_NAME(Prefix, Suffix) Prefix ## Suffix
00279 #endif
00280 
00281 #ifndef CS_IMPLEMENT_PLATFORM_PLUGIN
00282 #  define CS_IMPLEMENT_PLATFORM_PLUGIN
00283 #endif
00284 
00285 #ifndef CS_IMPLEMENT_PLATFORM_APPLICATION
00286 #  define CS_IMPLEMENT_PLATFORM_APPLICATION
00287 #endif
00288 
00295 #ifndef CS_INITIALIZE_PLATFORM_APPLICATION
00296 #  define CS_INITIALIZE_PLATFORM_APPLICATION    /* */
00297 /*
00298   This definition may seem odd, but it's here for doxygen's sake, which
00299   apparently fails to document empty macro definitions.
00300  */
00301 #endif
00302 
00303 #if !defined(CS_BUILD_SHARED_LIBS)
00304 # define CS_STATIC_VAR_EXTERN
00305 #else
00306 # define CS_STATIC_VAR_EXTERN   CS_CSUTIL_EXPORT
00307 #endif
00308 
00309 #ifndef CS_STATIC_VAR_DESTRUCTION_REGISTRAR_FUNCTION
00310 #  define CS_STATIC_VAR_DESTRUCTION_REGISTRAR_FUNCTION cs_static_var_cleanup
00311 #endif
00312 
00313 #ifndef CS_DECLARE_STATIC_VARIABLE_REGISTRATION
00314 #  define CS_DECLARE_STATIC_VARIABLE_REGISTRATION \
00315     CS_STATIC_VAR_EXTERN void \
00316     CS_STATIC_VAR_DESTRUCTION_REGISTRAR_FUNCTION (void (*p)());
00317 #endif
00318 
00319 #ifndef CS_DECLARE_STATIC_VARIABLE_CLEANUP
00320 #  define CS_DECLARE_STATIC_VARIABLE_CLEANUP \
00321    CS_DECLARE_STATIC_VARIABLE_REGISTRATION
00322 #endif
00323 
00324 #ifndef CS_IMPLEMENT_STATIC_VARIABLE_REGISTRATION
00325 #  define CS_IMPLEMENT_STATIC_VARIABLE_REGISTRATION                    \
00326 CS_STATIC_VAR_EXTERN void                                              \
00327 CS_STATIC_VAR_DESTRUCTION_REGISTRAR_FUNCTION (void (*p)())             \
00328 {                                                                      \
00329   static void (**a)() = 0;                                             \
00330   static int lastEntry = 0;                                            \
00331   static int maxEntries = 0;                                           \
00332                                                                        \
00333   if (p != 0)                                                          \
00334   {                                                                    \
00335     if (lastEntry >= maxEntries)                                       \
00336     {                                                                  \
00337       maxEntries += 10;                                                \
00338       if (a == 0)                                                      \
00339         a = (void (**)())malloc(maxEntries * sizeof(void*));           \
00340       else                                                             \
00341         a = (void (**)())realloc(a, maxEntries * sizeof(void*));       \
00342     }                                                                  \
00343     a[lastEntry++] = p;                                                \
00344   }                                                                    \
00345   else if (a != 0)                                                     \
00346   {                                                                    \
00347     for (int i = lastEntry - 1; i >= 0; i--)                           \
00348       a[i] ();                                                         \
00349     free (a);                                                          \
00350     a = 0;                                                             \
00351     lastEntry = 0;                                                     \
00352     maxEntries = 0;                                                    \
00353   }                                                                    \
00354 }
00355 #endif
00356 
00357 #ifndef CS_IMPLEMENT_STATIC_VARIABLE_CLEANUP
00358 #  define CS_IMPLEMENT_STATIC_VARIABLE_CLEANUP \
00359    CS_IMPLEMENT_STATIC_VARIABLE_REGISTRATION   
00360 #endif
00361 
00370 #if defined(CS_STATIC_LINKED) || defined(CS_BUILD_SHARED_LIBS)
00371 
00372 #  ifndef CS_IMPLEMENT_PLUGIN
00373 #  define CS_IMPLEMENT_PLUGIN        \
00374           CS_IMPLEMENT_PLATFORM_PLUGIN 
00375 #  endif
00376 
00377 #else
00378 
00379 #  ifndef CS_IMPLEMENT_PLUGIN
00380 #  define CS_IMPLEMENT_PLUGIN              \
00381    CS_IMPLEMENT_STATIC_VARIABLE_CLEANUP    \
00382    CS_IMPLEMENT_PLATFORM_PLUGIN 
00383 #  endif
00384 
00385 #endif
00386 
00395 #ifndef CS_IMPLEMENT_APPLICATION
00396 # if !defined(CS_BUILD_SHARED_LIBS)
00397 #  define CS_IMPLEMENT_APPLICATION       \
00398    CS_IMPLEMENT_STATIC_VARIABLE_CLEANUP  \
00399    CS_IMPLEMENT_PLATFORM_APPLICATION 
00400 # else
00401 #  define CS_IMPLEMENT_APPLICATION       \
00402    CS_IMPLEMENT_PLATFORM_APPLICATION 
00403 # endif
00404 #endif
00405 
00409 #ifndef CS_REGISTER_STATIC_FOR_DESTRUCTION
00410 #define CS_REGISTER_STATIC_FOR_DESTRUCTION(getterFunc)\
00411         CS_STATIC_VAR_DESTRUCTION_REGISTRAR_FUNCTION (getterFunc);
00412 #endif
00413 
00417 #ifndef CS_STATIC_VARIABLE_CLEANUP
00418 #define CS_STATIC_VARIABLE_CLEANUP  \
00419         CS_STATIC_VAR_DESTRUCTION_REGISTRAR_FUNCTION (0);
00420 #endif
00421 
00432 #ifndef CS_IMPLEMENT_STATIC_VAR_EXT
00433 #define CS_IMPLEMENT_STATIC_VAR_EXT(getterFunc,Type,initParam,kill_how) \
00434 CS_DECLARE_STATIC_VARIABLE_REGISTRATION                                 \
00435 extern "C" {                                                            \
00436 static Type* getterFunc ();                                             \
00437 static void getterFunc ## _kill ();                                     \
00438 static void getterFunc ## _kill_array ();                               \
00439 void getterFunc ## _kill ()                                             \
00440 {                                                                       \
00441   (void)getterFunc ## _kill_array;                                      \
00442   delete getterFunc ();                                                 \
00443 }                                                                       \
00444 void getterFunc ## _kill_array ()                                       \
00445 {                                                                       \
00446   (void)getterFunc ## _kill;                                            \
00447   delete [] getterFunc ();                                              \
00448 }                                                                       \
00449 Type* getterFunc ()                                                     \
00450 {                                                                       \
00451   static Type *v=0;                                                     \
00452   if (!v)                                                               \
00453   {                                                                     \
00454     v = new Type initParam;                                             \
00455     CS_REGISTER_STATIC_FOR_DESTRUCTION (getterFunc ## kill_how);        \
00456   }                                                                     \
00457   return v;                                                             \
00458 }                                                                       \
00459 }
00460 #endif
00461 
00462 #ifndef CS_IMPLEMENT_STATIC_VAR
00463 #define CS_IMPLEMENT_STATIC_VAR(getterFunc,Type,initParam)    \
00464  CS_IMPLEMENT_STATIC_VAR_EXT(getterFunc,Type,initParam,_kill)    
00465 #endif
00466 
00467 #ifndef CS_IMPLEMENT_STATIC_VAR_ARRAY
00468 #define CS_IMPLEMENT_STATIC_VAR_ARRAY(getterFunc,Type,initParam)    \
00469  CS_IMPLEMENT_STATIC_VAR_EXT(getterFunc,Type,initParam,_kill_array)    
00470 #endif
00471 
00477 #ifndef CS_DECLARE_STATIC_CLASSVAR
00478 #define CS_DECLARE_STATIC_CLASSVAR(var,getterFunc,Type)       \
00479 static Type *var;                                             \
00480 static Type *getterFunc ();                                   
00481 #endif
00482 
00483 #ifndef CS_DECLARE_STATIC_CLASSVAR_REF
00484 #define CS_DECLARE_STATIC_CLASSVAR_REF(var,getterFunc,Type)   \
00485 static Type *var;                                             \
00486 static Type &getterFunc ();                                   
00487 #endif
00488 
00498 #ifndef CS_IMPLEMENT_STATIC_CLASSVAR_EXT
00499 #define CS_IMPLEMENT_STATIC_CLASSVAR_EXT(Class,var,getterFunc,Type,initParam,kill_how)   \
00500 Type *Class::var = 0;                                                                    \
00501 extern "C" {                                                                             \
00502 static void Class ## _ ## getterFunc ## _kill ();                                        \
00503 static void Class ## _ ## getterFunc ## _kill_array ();                                  \
00504 void Class ## _ ## getterFunc ## _kill ()                                                \
00505 {                                                                                        \
00506   (void) Class ## _ ## getterFunc ## _kill_array;                                        \
00507   delete Class::getterFunc ();                                                           \
00508 }                                                                                        \
00509 void Class ## _ ## getterFunc ## _kill_array ()                                          \
00510 {                                                                                        \
00511   (void) Class ## _ ## getterFunc ## _kill;                                              \
00512   delete [] Class::getterFunc ();                                                        \
00513 }                                                                                        \
00514 }                                                                                        \
00515 Type* Class::getterFunc ()                                                               \
00516 {                                                                                        \
00517   if (!var)                                                                              \
00518   {                                                                                      \
00519     var = new Type initParam;                                                            \
00520     CS_DECLARE_STATIC_VARIABLE_REGISTRATION                                              \
00521     CS_REGISTER_STATIC_FOR_DESTRUCTION (Class ## _ ## getterFunc ## kill_how);           \
00522   }                                                                                      \
00523   return var;                                                                            \
00524 }
00525 #endif
00526 
00527 #ifndef CS_IMPLEMENT_STATIC_CLASSVAR
00528 #define CS_IMPLEMENT_STATIC_CLASSVAR(Class,var,getterFunc,Type,initParam) \
00529         CS_IMPLEMENT_STATIC_CLASSVAR_EXT(Class,var,getterFunc,Type,initParam,_kill)
00530 #endif
00531 
00532 #ifndef CS_IMPLEMENT_STATIC_CLASSVAR_ARRAY
00533 #define CS_IMPLEMENT_STATIC_CLASSVAR_ARRAY(Class,var,getterFunc,Type,initParam) \
00534         CS_IMPLEMENT_STATIC_CLASSVAR_EXT(Class,var,getterFunc,Type,initParam,_kill_array)
00535 #endif
00536 
00537 #ifndef CS_IMPLEMENT_STATIC_CLASSVAR_REF_EXT
00538 #define CS_IMPLEMENT_STATIC_CLASSVAR_REF_EXT(Class,var,getterFunc,Type,initParam,kill_how)   \
00539 Type *Class::var = 0;                                                                        \
00540 extern "C" {                                                                                 \
00541 static void Class ## _ ## getterFunc ## _kill ();                                            \
00542 static void Class ## _ ## getterFunc ## _kill_array ();                                      \
00543 void Class ## _ ## getterFunc ## _kill ()                                                    \
00544 {                                                                                            \
00545   (void) Class ## _ ## getterFunc ## _kill_array;                                            \
00546   delete &Class::getterFunc ();                                                              \
00547 }                                                                                            \
00548 void Class ## _ ## getterFunc ## _kill_array ()                                              \
00549 {                                                                                            \
00550   (void) Class ## _ ## getterFunc ## _kill;                                                  \
00551   delete [] &Class::getterFunc ();                                                           \
00552 }                                                                                            \
00553 }                                                                                            \
00554 Type &Class::getterFunc ()                                                                   \
00555 {                                                                                            \
00556   if (!var)                                                                                  \
00557   {                                                                                          \
00558     var = new Type initParam;                                                                \
00559     CS_DECLARE_STATIC_VARIABLE_REGISTRATION                                                  \
00560     CS_REGISTER_STATIC_FOR_DESTRUCTION (Class ## _ ## getterFunc ## kill_how);               \
00561   }                                                                                          \
00562   return *var;                                                                               \
00563 }
00564 #endif
00565 
00566 #ifndef CS_IMPLEMENT_STATIC_CLASSVAR_REF
00567 #define CS_IMPLEMENT_STATIC_CLASSVAR_REF(Class,var,getterFunc,Type,initParam)   \
00568         CS_IMPLEMENT_STATIC_CLASSVAR_REF_EXT(Class,var,getterFunc,Type,initParam,_kill)
00569 #endif
00570 
00571 #ifndef CS_IMPLEMENT_STATIC_CLASSVAR_REF_ARRAY
00572 #define CS_IMPLEMENT_STATIC_CLASSVAR_REF_ARRAY(Class,var,getterFunc,Type,initParam)   \
00573         CS_IMPLEMENT_STATIC_CLASSVAR_REF_EXT(Class,var,getterFunc,Type,initParam,_kill_array)
00574 #endif
00575 
00576 // The following define should only be enabled if you have defined
00577 // a special version of overloaded new that accepts two additional
00578 // parameters: a (void*) pointing to the filename and an int with the
00579 // line number. This is typically used for memory debugging.
00580 // In csutil/memdebug.cpp there is a memory debugger which can (optionally)
00581 // use this feature. Note that if CS_EXTENSIVE_MEMDEBUG is enabled while
00582 // the memory debugger is not the memory debugger will still provide the
00583 // needed overloaded operators so you can leave CS_EXTENSIVE_MEMDEBUG on in
00584 // that case and the only overhead will be a little more arguments to 'new'.
00585 // Do not enable CS_EXTENSIVE_MEMDEBUG if your platform or your own code
00586 // defines its own 'new' operator, since this version will interfere with your
00587 // own.
00588 // CS_MEMORY_TRACKER is treated like CS_EXTENSIVE_MEMDEBUG here.
00589 // Same for CS_REF_TRACKER.
00590 #ifndef CS_DEBUG
00591 #  undef CS_EXTENSIVE_MEMDEBUG
00592 #  undef CS_MEMORY_TRACKER
00593 #  undef CS_REF_TRACKER
00594 #else
00595 #  if defined(CS_EXTENSIVE_MEMDEBUG) && defined(CS_MEMORY_TRACKER)
00596 #    error Do not use CS_EXTENSIVE_MEMDEBUG and CS_MEMORY_TRACKER at the same time!
00597 #  endif
00598 #endif
00599 #if defined(CS_EXTENSIVE_MEMDEBUG) || defined(CS_MEMORY_TRACKER)
00600 extern void* operator new (size_t s, void* filename, int line);
00601 extern void* operator new[] (size_t s, void* filename, int line);
00602 #define CS_EXTENSIVE_MEMDEBUG_NEW new ((void*)__FILE__, __LINE__)
00603 #define new CS_EXTENSIVE_MEMDEBUG_NEW
00604 #endif
00605 
00606 #ifdef CS_DEBUG
00607 #  if !defined (DEBUG_BREAK)
00608 #    if defined (PROC_X86)
00609 #      if defined (COMP_GCC)
00610 #        define DEBUG_BREAK asm ("int $3")
00611 #      else
00612 #        define DEBUG_BREAK _asm int 3
00613 #      endif
00614 #    else
00615 #      define DEBUG_BREAK { static int x = 0; x /= x; }
00616 #    endif
00617 #  endif
00618 #  if !defined (CS_ASSERT)
00619 #    if defined (COMP_VC)
00620 #      define  CS_ASSERT(x) assert(x)
00621 #    else
00622 #      include <stdio.h>
00623 #      define CS_ASSERT(x)            \
00624          if (!(x))              \
00625          {                \
00626            fprintf (stderr, __FILE__ ":%d: failed assertion '%s'\n",\
00627              int(__LINE__), #x );         \
00628            DEBUG_BREAK;             \
00629          }
00630 #    endif
00631 #  endif
00632 #  if !defined (CS_ASSERT_MSG)
00633 #      define  CS_ASSERT_MSG(msg, x) CS_ASSERT(((msg) && (x)))
00634 #  endif
00635 #else
00636 #  undef DEBUG_BREAK
00637 #  define DEBUG_BREAK
00638 #  undef CS_ASSERT
00639 #  define CS_ASSERT(x)
00640 #  undef CS_ASSERT_MSG
00641 #  define CS_ASSERT_MSG(m, x)
00642 #endif
00643 
00644 // Check if the csosdefs.h defined either CS_LITTLE_ENDIAN or CS_BIG_ENDIAN
00645 #if !defined (CS_LITTLE_ENDIAN) && !defined (CS_BIG_ENDIAN)
00646 #  error No CS_XXX_ENDIAN macro defined in your OS-specific csosdefs.h!
00647 #endif
00648 
00649 /*
00650  * This is a bit of overkill but if you're sure your CPU doesn't require
00651  * strict alignment add your CPU to the !defined below to get slightly
00652  * smaller and faster code in some cases.
00653  *
00654  * @@@ In the future, this should be moved to volatile.h and determined as
00655  * part of the configuration process.
00656  */
00657 #if !defined (PROC_X86)
00658 #  define CS_STRICT_ALIGNMENT
00659 #endif
00660 
00661 // Adjust some definitions contained in volatile.h
00662 #if defined (PROC_X86) && !defined (DO_NASM)
00663 #  undef NO_ASSEMBLER
00664 #  define NO_ASSEMBLER
00665 #endif
00666 
00667 #if !defined (PROC_X86) || defined (NO_ASSEMBLER)
00668 #  undef DO_MMX
00669 #  undef DO_NASM
00670 #endif
00671 
00672 // Use fast QInt and QRound on CPUs that are known to support it
00673 #if !defined (CS_NO_IEEE_OPTIMIZATIONS)
00674 #  if !defined (CS_IEEE_DOUBLE_FORMAT)
00675 #    if defined (PROC_X86) || defined (PROC_M68K)
00676 #      define CS_IEEE_DOUBLE_FORMAT
00677 #    endif
00678 #  endif
00679 #endif
00680 
00681 // gcc can perform usefull checking for printf/scanf format strings, just add
00682 // this define at the end of the function declaration
00683 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
00684 #  define CS_GNUC_PRINTF( format_idx, arg_idx)    \
00685      __attribute__((format (__printf__, format_idx, arg_idx)))
00686 #  define CS_GNUC_SCANF( format_idx, arg_idx )        \
00687      __attribute__((format (__scanf__, format_idx, arg_idx)))
00688 #else
00689 #  define CS_GNUC_PRINTF( format_idx, arg_idx )
00690 #  define CS_GNUC_SCANF( format_idx, arg_idx )
00691 #endif
00692 
00693 // remove __attribute__ on non GNUC compilers
00694 #ifndef __GNUC__
00695 #define __attribute__(x)
00696 #endif
00697 
00698 // Support for alignment and packing of structures.
00699 #if !defined(CS_STRUCT_ALIGN_4BYTE_BEGIN)
00700 #  if defined(__GNUC__) && defined(CS_STRICT_ALIGNMENT)
00701 #    define CS_STRUCT_ALIGN_4BYTE_BEGIN
00702 #    define CS_STRUCT_ALIGN_4BYTE_END __attribute__ ((aligned(4)))
00703 #  else
00704 #    define CS_STRUCT_ALIGN_4BYTE_BEGIN
00705 #    define CS_STRUCT_ALIGN_4BYTE_END
00706 #  endif
00707 #endif
00708 
00709 // Macro used to define static implicit pointer conversion function.
00710 // Only use within a class declaration.
00711 #ifndef _CS_IMPLICITPTRCAST_NAME
00712 #  define _CS_IMPLICITPTRCAST_NAME __ImplicitPtrCast
00713 #endif
00714 
00736 #define CS_IMPLEMENT_IMPLICIT_PTR_CAST(classname) \
00737   inline static classname* _CS_IMPLICITPTRCAST_NAME (classname* ptr) \
00738   { \
00739     return ptr;\
00740   }
00741 
00750 #define CS_IMPLICIT_PTR_CAST(classname, ptr) \
00751   (classname::_CS_IMPLICITPTRCAST_NAME(ptr))
00752 
00754 extern void (*fatal_exit) (int errorcode, bool canreturn);
00755 
00756 #endif // __CS_CSSYSDEFS_H__

Generated for Crystal Space by doxygen 1.2.18