CrystalSpace

Public API Reference

Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class 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 #ifndef __CS_CSSYSDEF_H__
00021 #define __CS_CSSYSDEF_H__
00022 
00023 #define CSDEF_FRIEND
00024 #include "csdef.h"
00025 #undef CSDEF_FRIEND
00026 
00036 /*
00037  * Pull in platform-specific overrides of the requested functionality.
00038  */
00039 #include "csutil/csosdefs.h"
00040 
00041 // Defaults for platforms that do not define their own.
00042 #ifndef CS_EXPORT_SYM_DLL
00043 #  define CS_EXPORT_SYM_DLL
00044 #endif
00045 #ifndef CS_IMPORT_SYM_DLL
00046 #  define CS_IMPORT_SYM_DLL extern
00047 #endif
00048 #ifndef CS_EXPORT_SYM
00049 #  define CS_EXPORT_SYM
00050 #endif
00051 #ifndef CS_IMPORT_SYM
00052 #  define CS_IMPORT_SYM
00053 #endif
00054 
00055 #include "csextern.h"
00056 
00057 /*
00058  * Default definitions for requested functionality.  Platform-specific
00059  * configuration files may override these.
00060  */
00061 
00062 #ifndef CS_FORCEINLINE
00063 #define CS_FORCEINLINE inline
00064 #endif
00065 
00070 #ifndef CS_MAXPATHLEN
00071 #define CS_MAXPATHLEN 1024
00072 #endif
00073 #include <stdio.h>
00074 #ifdef CS_HAS_SYS_PARAM_H
00075 #include <sys/param.h>
00076 #endif
00077 
00084 #ifdef CS_COMPILER_GCC
00085 // In GCC we are able to declare stack vars of dynamic size directly
00086 #  define CS_ALLOC_STACK_ARRAY(type, var, size) \
00087      type var [size]
00088 #else
00089 #  include <malloc.h>
00090 #  define CS_ALLOC_STACK_ARRAY(type, var, size) \
00091      type *var = (type *)alloca ((size) * sizeof (type))
00092 #endif
00093 
00097 #ifndef CS_TEMP_DIR
00098 #  if defined(CS_PLATFORM_UNIX)
00099 #    define CS_TEMP_DIR "/tmp/"
00100 #  else
00101 #    define CS_TEMP_DIR ""
00102 #  endif
00103 #endif
00104 
00108 #ifndef CS_TEMP_FILE
00109 #  if defined(CS_PLATFORM_UNIX)
00110 #    define CS_TEMP_FILE "cs%lud.tmp", (unsigned long)getpid()
00111 #  else
00112 #    define CS_TEMP_FILE "$cs$.tmp"
00113 #  endif
00114 #endif
00115 
00116 #ifdef CS_USE_CUSTOM_ISDIR
00117 static inline bool isdir (const char *path, struct dirent *de)
00118 {
00119   int pathlen = strlen (path);
00120   char* fullname = new char[pathlen + 2 + strlen (de->d_name)];
00121   memcpy (fullname, path, pathlen + 1);
00122   if ((pathlen) && (fullname[pathlen-1] != CS_PATH_SEPARATOR))
00123   {
00124     fullname[pathlen++] = CS_PATH_SEPARATOR;
00125     fullname[pathlen] = 0;
00126   }
00127   strcat (&fullname [pathlen], de->d_name);
00128   struct stat st;
00129   stat (fullname, &st);
00130   delete[] fullname;
00131   return ((st.st_mode & S_IFMT) == S_IFDIR);
00132 }
00133 #endif
00134 
00142 #ifdef CS_HAS_POSIX_MMAP
00143 
00144 #ifndef CS_HAS_MEMORY_MAPPED_IO
00145 #define CS_HAS_MEMORY_MAPPED_IO
00146 #endif
00147 
00149 struct csMemMapInfo
00150 {          
00152   int hMappedFile;
00154   unsigned char *data;
00156   unsigned int file_size;
00158   bool close;
00159 };
00160 
00161 #endif // CS_HAS_POSIX_MMAP
00162 
00178 #define CS_HEADER_GLOBAL(X,Y) CS_HEADER_GLOBAL_COMPOSE(X,Y)
00179 #define CS_HEADER_GLOBAL_COMPOSE(X,Y) <X/Y>
00180 
00193 #define CS_HEADER_LOCAL(X,Y) CS_HEADER_LOCAL_COMPOSE1(X,Y)
00194 #define CS_HEADER_LOCAL_COMPOSE1(X,Y) CS_HEADER_LOCAL_COMPOSE2(X/Y)
00195 #define CS_HEADER_LOCAL_COMPOSE2(X) #X
00196 
00197 
00203 #if !defined(CS_EXPORTED_FUNCTION)
00204 #  define CS_EXPORTED_FUNCTION extern "C"
00205 #endif
00206 
00218 #if !defined(CS_EXPORTED_NAME)
00219 #  define CS_EXPORTED_NAME(Prefix, Suffix) Prefix ## Suffix
00220 #endif
00221 
00222 #ifndef CS_IMPLEMENT_PLATFORM_PLUGIN
00223 #  define CS_IMPLEMENT_PLATFORM_PLUGIN
00224 #endif
00225 
00226 #ifndef CS_IMPLEMENT_PLATFORM_APPLICATION
00227 #  define CS_IMPLEMENT_PLATFORM_APPLICATION
00228 #endif
00229 
00236 #ifndef CS_INITIALIZE_PLATFORM_APPLICATION
00237 #  define CS_INITIALIZE_PLATFORM_APPLICATION /* */
00238 /*
00239   This definition may seem odd, but it's here for doxygen's sake, which
00240   apparently fails to document empty macro definitions.
00241  */
00242 #endif
00243 
00244 typedef void (*csStaticVarCleanupFN) (void (*p)());
00245 extern csStaticVarCleanupFN csStaticVarCleanup;
00246 
00247 #ifndef CS_IMPLEMENT_STATIC_VARIABLE_REGISTRATION
00248 #  define CS_IMPLEMENT_STATIC_VARIABLE_REGISTRATION(Name)              \
00249 void Name (void (*p)())                                                \
00250 {                                                                      \
00251   static void (**a)() = 0;                                             \
00252   static int lastEntry = 0;                                            \
00253   static int maxEntries = 0;                                           \
00254                                                                        \
00255   if (p != 0)                                                          \
00256   {                                                                    \
00257     if (lastEntry >= maxEntries)                                       \
00258     {                                                                  \
00259       maxEntries += 10;                                                \
00260       if (a == 0)                                                      \
00261         a = (void (**)())malloc(maxEntries * sizeof(void*));           \
00262       else                                                             \
00263         a = (void (**)())realloc(a, maxEntries * sizeof(void*));       \
00264     }                                                                  \
00265     a[lastEntry++] = p;                                                \
00266   }                                                                    \
00267   else if (a != 0)                                                     \
00268   {                                                                    \
00269     for (int i = lastEntry - 1; i >= 0; i--)                           \
00270       a[i] ();                                                         \
00271     free (a);                                                          \
00272     a = 0;                                                             \
00273     lastEntry = 0;                                                     \
00274     maxEntries = 0;                                                    \
00275   }                                                                    \
00276 }
00277 #endif
00278 
00279 #ifndef CS_DEFINE_STATIC_VARIABLE_REGISTRATION
00280 #  define CS_DEFINE_STATIC_VARIABLE_REGISTRATION(func) \
00281     csStaticVarCleanupFN csStaticVarCleanup = &func
00282 #endif
00283 
00284 #ifndef CS_DECLARE_STATIC_VARIABLE_REGISTRATION
00285 #  define CS_DECLARE_STATIC_VARIABLE_REGISTRATION(func) \
00286     void func (void (*p)())
00287 #endif
00288 
00289 #ifndef CS_DECLARE_DEFAULT_STATIC_VARIABLE_REGISTRATION
00290 #  define CS_DECLARE_DEFAULT_STATIC_VARIABLE_REGISTRATION               \
00291     CS_CSUTIL_EXPORT                                                    \
00292     CS_DECLARE_STATIC_VARIABLE_REGISTRATION (csStaticVarCleanup_csutil);
00293 #endif
00294 
00295 /* scfStaticallyLinked - Flag indicating whether external linkage was used when 
00296  * building the application. Determines whether SCF scans for plugins at 
00297  * startup.
00298  */
00302 #if defined(CS_BUILD_SHARED_LIBS)
00303 #  define CS_DEFINE_STATICALLY_LINKED_FLAG
00304 #elif defined(CS_STATIC_LINKED)
00305 #  define CS_DEFINE_STATICALLY_LINKED_FLAG  bool scfStaticallyLinked = true;
00306 #else
00307 #  define CS_DEFINE_STATICALLY_LINKED_FLAG  bool scfStaticallyLinked = false;
00308 #endif
00309 
00310 
00322 #ifndef CS_IMPLEMENT_FOREIGN_DLL
00323 #  if defined(CS_BUILD_SHARED_LIBS)
00324 #    define CS_IMPLEMENT_FOREIGN_DLL                                        \
00325        CS_IMPLEMENT_STATIC_VARIABLE_REGISTRATION(csStaticVarCleanup_local); \
00326        CS_DEFINE_STATICALLY_LINKED_FLAG                                     \
00327        CS_DEFINE_STATIC_VARIABLE_REGISTRATION (csStaticVarCleanup_local);
00328 #  else
00329 #    define CS_IMPLEMENT_FOREIGN_DLL                                        \
00330        CS_DECLARE_DEFAULT_STATIC_VARIABLE_REGISTRATION                      \
00331        CS_DEFINE_STATICALLY_LINKED_FLAG                                     \
00332        CS_DEFINE_STATIC_VARIABLE_REGISTRATION (csStaticVarCleanup_csutil);
00333 #  endif
00334 #endif
00335 
00344 #if defined(CS_STATIC_LINKED)
00345 
00346 #  ifndef CS_IMPLEMENT_PLUGIN
00347 #  define CS_IMPLEMENT_PLUGIN                                           \
00348           CS_IMPLEMENT_PLATFORM_PLUGIN 
00349 #  endif
00350 
00351 #elif !defined(CS_BUILD_SHARED_LIBS)
00352 
00353 #  ifndef CS_IMPLEMENT_PLUGIN
00354 #  define CS_IMPLEMENT_PLUGIN                                           \
00355           CS_IMPLEMENT_PLATFORM_PLUGIN                                  \
00356           CS_DEFINE_STATICALLY_LINKED_FLAG                              \
00357           CS_DECLARE_DEFAULT_STATIC_VARIABLE_REGISTRATION               \
00358           CS_DEFINE_STATIC_VARIABLE_REGISTRATION (csStaticVarCleanup_csutil);
00359 #  endif
00360 
00361 #else
00362 
00363 #  ifndef CS_IMPLEMENT_PLUGIN
00364 #  define CS_IMPLEMENT_PLUGIN                                           \
00365    CS_DEFINE_STATICALLY_LINKED_FLAG                                     \
00366    CS_IMPLEMENT_STATIC_VARIABLE_REGISTRATION(csStaticVarCleanup_local)  \
00367    CS_DEFINE_STATIC_VARIABLE_REGISTRATION (csStaticVarCleanup_local);   \
00368    CS_IMPLEMENT_PLATFORM_PLUGIN 
00369 #  endif
00370 
00371 #endif
00372 
00381 #ifndef CS_IMPLEMENT_APPLICATION
00382 #  define CS_IMPLEMENT_APPLICATION                                      \
00383   CS_DECLARE_DEFAULT_STATIC_VARIABLE_REGISTRATION                       \
00384   CS_DEFINE_STATICALLY_LINKED_FLAG                                      \
00385   CS_DEFINE_STATIC_VARIABLE_REGISTRATION (csStaticVarCleanup_csutil);   \
00386   CS_IMPLEMENT_PLATFORM_APPLICATION 
00387 #endif
00388 
00392 #ifndef CS_REGISTER_STATIC_FOR_DESTRUCTION
00393 #define CS_REGISTER_STATIC_FOR_DESTRUCTION(getterFunc)\
00394         csStaticVarCleanup (getterFunc);
00395 #endif
00396 
00400 #ifndef CS_STATIC_VARIABLE_CLEANUP
00401 #define CS_STATIC_VARIABLE_CLEANUP  \
00402         csStaticVarCleanup (0);
00403 #endif
00404 
00416 #ifndef CS_IMPLEMENT_STATIC_VAR_EXT
00417 #define CS_IMPLEMENT_STATIC_VAR_EXT(getterFunc,Type,initParam,kill_how) \
00418 extern "C" {                                                            \
00419 static Type* getterFunc ();                                             \
00420 static void getterFunc ## _kill ();                                     \
00421 static void getterFunc ## _kill_array ();                               \
00422 void getterFunc ## _kill ()                                             \
00423 {                                                                       \
00424   (void)(&getterFunc ## _kill_array);                                   \
00425   delete getterFunc ();                                                 \
00426 }                                                                       \
00427 void getterFunc ## _kill_array ()                                       \
00428 {                                                                       \
00429   (void)(&getterFunc ## _kill);                                         \
00430   delete [] getterFunc ();                                              \
00431 }                                                                       \
00432 Type* getterFunc ()                                                     \
00433 {                                                                       \
00434   static Type *v=0;                                                     \
00435   if (!v)                                                               \
00436   {                                                                     \
00437     v = new Type initParam;                                             \
00438     csStaticVarCleanup (getterFunc ## kill_how);                        \
00439   }                                                                     \
00440   return v;                                                             \
00441 }                                                                       \
00442 }
00443 #endif
00444 
00445 #ifndef CS_IMPLEMENT_STATIC_VAR
00446 #define CS_IMPLEMENT_STATIC_VAR(getterFunc,Type,initParam) \
00447  CS_IMPLEMENT_STATIC_VAR_EXT(getterFunc,Type,initParam,_kill)    
00448 #endif
00449 
00450 #ifndef CS_IMPLEMENT_STATIC_VAR_ARRAY
00451 #define CS_IMPLEMENT_STATIC_VAR_ARRAY(getterFunc,Type,initParam) \
00452  CS_IMPLEMENT_STATIC_VAR_EXT(getterFunc,Type,initParam,_kill_array)    
00453 #endif
00454 
00462 #ifndef CS_DECLARE_STATIC_CLASSVAR
00463 #define CS_DECLARE_STATIC_CLASSVAR(var,getterFunc,Type)       \
00464 static Type *var;                                             \
00465 static Type *getterFunc ();                                   
00466 #endif
00467 
00468 #ifndef CS_DECLARE_STATIC_CLASSVAR_REF
00469 #define CS_DECLARE_STATIC_CLASSVAR_REF(var,getterFunc,Type)   \
00470 static Type *var;                                             \
00471 static Type &getterFunc ();                                   
00472 #endif
00473 
00484 #ifndef CS_IMPLEMENT_STATIC_CLASSVAR_EXT
00485 #define CS_IMPLEMENT_STATIC_CLASSVAR_EXT(Class,var,getterFunc,Type,initParam,\
00486   kill_how)                                                     \
00487 Type *Class::var = 0;                                           \
00488 extern "C" {                                                    \
00489 static void Class ## _ ## getterFunc ## _kill ();               \
00490 static void Class ## _ ## getterFunc ## _kill_array ();         \
00491 void Class ## _ ## getterFunc ## _kill ()                       \
00492 {                                                               \
00493   delete Class::getterFunc ();                                  \
00494   (void)(&Class ## _ ## getterFunc ## _kill_array);             \
00495 }                                                               \
00496 void Class ## _ ## getterFunc ## _kill_array ()                 \
00497 {                                                               \
00498   delete [] Class::getterFunc ();                               \
00499   (void)(&Class ## _ ## getterFunc ## _kill);                   \
00500 }                                                               \
00501 }                                                               \
00502 Type* Class::getterFunc ()                                      \
00503 {                                                               \
00504   if (!var)                                                     \
00505   {                                                             \
00506     var = new Type initParam;                                   \
00507     csStaticVarCleanup (Class ## _ ## getterFunc ## kill_how);  \
00508   }                                                             \
00509   return var;                                                   \
00510 }
00511 #endif
00512 
00513 #ifndef CS_IMPLEMENT_STATIC_CLASSVAR
00514 #define CS_IMPLEMENT_STATIC_CLASSVAR(Class,var,getterFunc,Type,initParam) \
00515   CS_IMPLEMENT_STATIC_CLASSVAR_EXT(Class,var,getterFunc,Type,initParam,_kill)
00516 #endif
00517 
00518 #ifndef CS_IMPLEMENT_STATIC_CLASSVAR_ARRAY
00519 #define CS_IMPLEMENT_STATIC_CLASSVAR_ARRAY(Class,var,getterFunc,Type,\
00520   initParam) \
00521   CS_IMPLEMENT_STATIC_CLASSVAR_EXT(Class,var,getterFunc,Type,initParam,\
00522     _kill_array)
00523 #endif
00524 
00525 #ifndef CS_IMPLEMENT_STATIC_CLASSVAR_REF_EXT
00526 #define CS_IMPLEMENT_STATIC_CLASSVAR_REF_EXT(Class,var,getterFunc,Type,\
00527   initParam,kill_how) \
00528 Type *Class::var = 0;                                          \
00529 extern "C" {                                                   \
00530 static void Class ## _ ## getterFunc ## _kill ();              \
00531 static void Class ## _ ## getterFunc ## _kill_array ();        \
00532 void Class ## _ ## getterFunc ## _kill ()                      \
00533 {                                                              \
00534   (void) Class ## _ ## getterFunc ## _kill_array;              \
00535   delete &Class::getterFunc ();                                \
00536 }                                                              \
00537 void Class ## _ ## getterFunc ## _kill_array ()                \
00538 {                                                              \
00539   (void) Class ## _ ## getterFunc ## _kill;                    \
00540   delete [] &Class::getterFunc ();                             \
00541 }                                                              \
00542 }                                                              \
00543 Type &Class::getterFunc ()                                     \
00544 {                                                              \
00545   if (!var)                                                    \
00546   {                                                            \
00547     var = new Type initParam;                                  \
00548     csStaticVarCleanup (Class ## _ ## getterFunc ## kill_how); \
00549   }                                                            \
00550   return *var;                                                 \
00551 }
00552 #endif
00553 
00554 #ifndef CS_IMPLEMENT_STATIC_CLASSVAR_REF
00555 #define CS_IMPLEMENT_STATIC_CLASSVAR_REF(Class,var,getterFunc,Type,initParam)\
00556   CS_IMPLEMENT_STATIC_CLASSVAR_REF_EXT(Class,var,getterFunc,Type,\
00557     initParam,_kill)
00558 #endif
00559 
00560 #ifndef CS_IMPLEMENT_STATIC_CLASSVAR_REF_ARRAY
00561 #define CS_IMPLEMENT_STATIC_CLASSVAR_REF_ARRAY(Class,var,getterFunc,Type,\
00562   initParam) \
00563   CS_IMPLEMENT_STATIC_CLASSVAR_REF_EXT(Class,var,getterFunc,Type,initParam,\
00564     _kill_array)
00565 #endif
00566 
00567 // The following define should only be enabled if you have defined
00568 // a special version of overloaded new that accepts two additional
00569 // parameters: a (void*) pointing to the filename and an int with the
00570 // line number. This is typically used for memory debugging.
00571 // In csutil/memdebug.cpp there is a memory debugger which can (optionally)
00572 // use this feature. Note that if CS_EXTENSIVE_MEMDEBUG is enabled while
00573 // the memory debugger is not the memory debugger will still provide the
00574 // needed overloaded operators so you can leave CS_EXTENSIVE_MEMDEBUG on in
00575 // that case and the only overhead will be a little more arguments to 'new'.
00576 // Do not enable CS_EXTENSIVE_MEMDEBUG if your platform or your own code
00577 // defines its own 'new' operator, since this version will interfere with your
00578 // own.
00579 // CS_MEMORY_TRACKER is treated like CS_EXTENSIVE_MEMDEBUG here.
00580 // Same for CS_REF_TRACKER.
00581 #ifndef CS_DEBUG
00582 #  undef CS_EXTENSIVE_MEMDEBUG
00583 #  undef CS_REF_TRACKER
00584 #else
00585 #  if defined(CS_EXTENSIVE_MEMDEBUG) && defined(CS_MEMORY_TRACKER)
00586 #    error Do not use CS_EXTENSIVE_MEMDEBUG and CS_MEMORY_TRACKER together!
00587 #  endif
00588 #endif
00589 #if defined(CS_EXTENSIVE_MEMDEBUG) || defined(CS_MEMORY_TRACKER)
00590 extern void* operator new (size_t s, void* filename, int line);
00591 extern void* operator new[] (size_t s, void* filename, int line);
00592 #define CS_EXTENSIVE_MEMDEBUG_NEW new ((void*)__FILE__, __LINE__)
00593 #define new CS_EXTENSIVE_MEMDEBUG_NEW
00594 #endif
00595 
00596 #ifdef CS_DEBUG
00597 #  if !defined (DEBUG_BREAK)
00598 #    if defined (CS_PROCESSOR_X86)
00599 #      if defined (CS_COMPILER_GCC)
00600 #        define DEBUG_BREAK asm ("int $3")
00601 #      else
00602 #        define DEBUG_BREAK _asm int 3
00603 #      endif
00604 #    else
00605 #      define DEBUG_BREAK { static int x = 0; x /= x; }
00606 #    endif
00607 #  endif
00608 #  if !defined (CS_ASSERT)
00609 #    if defined (CS_COMPILER_MSVC)
00610 #      define CS_ASSERT(x) assert(x)
00611 #    else
00612 #      include <stdio.h>
00613 #      define CS_ASSERT(x) \
00614          if (!(x)) \
00615          { \
00616            fprintf (stderr, __FILE__ ":%d: failed assertion '%s'\n", \
00617              int(__LINE__), #x); \
00618            DEBUG_BREAK; \
00619          }
00620 #    endif
00621 #  endif
00622 #  if !defined (CS_ASSERT_MSG)
00623 #      define CS_ASSERT_MSG(msg,x) CS_ASSERT(((msg) && (x)))
00624 #  endif
00625 #else
00626 #  undef  DEBUG_BREAK
00627 #  define DEBUG_BREAK
00628 #  undef  CS_ASSERT
00629 #  define CS_ASSERT(x)
00630 #  undef  CS_ASSERT_MSG
00631 #  define CS_ASSERT_MSG(m,x)
00632 #endif
00633 
00645 #ifndef CS_DEPRECATED_METHOD
00646 #  if defined(CS_COMPILER_GCC)
00647 #    define CS_DEPRECATED_METHOD                __attribute__ ((deprecated))
00648 #  elif defined(CS_COMPILER_MSVC)
00649 #    define CS_DEPRECATED_METHOD                /*__declspec(deprecated)*/
00650       /* Disabled: Unfortunately, MSVC is overzealous with warnings; 
00651          it even emits one when a deprecated method is overridden, e.g. when 
00652          implementing an interface method. */
00653 #  else
00654 #    define CS_DEPRECATED_METHOD
00655 #  endif
00656 #endif
00657 
00667 #ifndef CS_DEPRECATED_TYPE
00668 #  if defined(CS_COMPILER_GCC)
00669 #    define CS_DEPRECATED_TYPE          __attribute__ ((deprecated))
00670 #  elif defined(CS_COMPILER_MSVC)
00671 #    define CS_DEPRECATED_TYPE
00672 #  else
00673 #    define CS_DEPRECATED_TYPE
00674 #  endif
00675 #endif
00676 
00677 // Check if the csosdefs.h defined either CS_LITTLE_ENDIAN or CS_BIG_ENDIAN
00678 #if !defined (CS_LITTLE_ENDIAN) && !defined (CS_BIG_ENDIAN)
00679 #  error No CS_XXX_ENDIAN macro defined in your OS-specific csosdefs.h!
00680 #endif
00681 
00682 /*
00683  * This is a bit of overkill but if you're sure your CPU doesn't require
00684  * strict alignment add your CPU to the !defined below to get slightly
00685  * smaller and faster code in some cases.
00686  *
00687  * @@@ In the future, this should be moved to csconfig.h and determined as
00688  * part of the configuration process.
00689  */
00690 #if !defined (CS_PROCESSOR_X86)
00691 #  define CS_STRICT_ALIGNMENT
00692 #endif
00693 
00694 // Adjust some definitions contained in csconfig.h
00695 #if defined (CS_PROCESSOR_X86) && !defined (CS_USE_NASM)
00696 #  undef NO_ASSEMBLER
00697 #  define NO_ASSEMBLER
00698 #endif
00699 
00700 #if !defined (CS_PROCESSOR_X86) || defined (NO_ASSEMBLER)
00701 #  undef CS_USE_MMX
00702 #  undef CS_USE_NASM
00703 #endif
00704 
00705 // Use fast csQint and csQround on CPUs that are known to support it
00706 #if !defined (CS_NO_IEEE_OPTIMIZATIONS)
00707 #  if !defined (CS_IEEE_DOUBLE_FORMAT)
00708 #    if (CS_PROCESSOR_SIZE == 32) && \
00709         (defined (CS_PROCESSOR_X86) || defined (CS_PROCESSOR_M68K))
00710 #      define CS_IEEE_DOUBLE_FORMAT
00711 #    endif
00712 #  endif
00713 #endif
00714 
00715 // gcc can perform usefull checking for printf/scanf format strings, just add
00716 // this define at the end of the function declaration
00717 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
00718 #  define CS_GNUC_PRINTF(format_idx, arg_idx) \
00719      __attribute__((format (__printf__, format_idx, arg_idx)))
00720 #  define CS_GNUC_SCANF(format_idx, arg_idx) \
00721      __attribute__((format (__scanf__, format_idx, arg_idx)))
00722 #else
00723 #  define CS_GNUC_PRINTF(format_idx, arg_idx)
00724 #  define CS_GNUC_SCANF(format_idx, arg_idx)
00725 #endif
00726 
00727 // Remove __attribute__ on non GNUC compilers.
00728 #ifndef __GNUC__
00729 #define __attribute__(x)
00730 #endif
00731 
00732 // Support for alignment and packing of structures.
00733 #if !defined(CS_STRUCT_ALIGN_4BYTE_BEGIN)
00734 #  if defined(__GNUC__) && defined(CS_STRICT_ALIGNMENT)
00735 #    define CS_STRUCT_ALIGN_4BYTE_BEGIN
00736 #    define CS_STRUCT_ALIGN_4BYTE_END __attribute__ ((aligned(4)))
00737 #  else
00738 #    define CS_STRUCT_ALIGN_4BYTE_BEGIN
00739 #    define CS_STRUCT_ALIGN_4BYTE_END
00740 #  endif
00741 #endif
00742 
00743 // Macro used to define static implicit pointer conversion function.
00744 // Only use within a class declaration.
00745 #ifndef _CS_IMPLICITPTRCAST_NAME
00746 #  define _CS_IMPLICITPTRCAST_NAME __ImplicitPtrCast
00747 #endif
00748 
00770 #define CS_IMPLEMENT_IMPLICIT_PTR_CAST(classname) \
00771   inline static classname* _CS_IMPLICITPTRCAST_NAME (classname* ptr) \
00772   { \
00773     return ptr;\
00774   }
00775 
00784 #define CS_IMPLICIT_PTR_CAST(classname, ptr) \
00785   (classname::_CS_IMPLICITPTRCAST_NAME(ptr))
00786 
00788 extern void (*fatal_exit) (int errorcode, bool canreturn);
00789 
00793 #ifdef CS_HAVE_VA_COPY
00794 #  define CS_VA_COPY(dest, src)         va_copy(dest, src)
00795 #else
00796 #  ifdef CS_HAVE___VA_COPY
00797 #    define CS_VA_COPY(dest, src)       __va_copy(dest, src)
00798 #  else
00799 #    define CS_VA_COPY(dest, src)       dest = src;
00800 #  endif
00801 #endif
00802 
00803 #endif // __CS_CSSYSDEF_H__

Generated for Crystal Space by doxygen 1.3.9.1