CrystalSpace

Public API Reference

Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | 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 #  ifdef CS_VISIBILITY_DEFAULT
00044 #    define CS_EXPORT_SYM_DLL CS_VISIBILITY_DEFAULT
00045 #  else
00046 #    define CS_EXPORT_SYM_DLL
00047 #  endif
00048 #endif
00049 #ifndef CS_IMPORT_SYM_DLL
00050 #  define CS_IMPORT_SYM_DLL extern
00051 #endif
00052 #ifndef CS_EXPORT_SYM
00053 #  if defined(CS_VISIBILITY_DEFAULT) && defined(CS_BUILD_SHARED_LIBS)
00054 #    define CS_EXPORT_SYM CS_VISIBILITY_DEFAULT
00055 #  else
00056 #    define CS_EXPORT_SYM
00057 #  endif
00058 #endif
00059 #ifndef CS_IMPORT_SYM
00060 #  define CS_IMPORT_SYM
00061 #endif
00062 
00063 #include "csextern.h"
00064 
00065 /*
00066  * Default definitions for requested functionality.  Platform-specific
00067  * configuration files may override these.
00068  */
00069 
00070 #ifndef CS_FORCEINLINE
00071 #define CS_FORCEINLINE inline
00072 #endif
00073 
00078 #ifndef CS_MAXPATHLEN
00079 #define CS_MAXPATHLEN 1024
00080 #endif
00081 #include <stdio.h>
00082 #ifdef CS_HAVE_SYS_PARAM_H
00083 #include <sys/param.h>
00084 #endif
00085 
00092 #if defined(CS_COMPILER_GCC) && !defined(__STRICT_ANSI__)
00093 // In GCC we are able to declare stack vars of dynamic size directly
00094 #  define CS_ALLOC_STACK_ARRAY(type, var, size) \
00095      type var [size]
00096 #else
00097 #  include <stdlib.h>
00098 #  define CS_ALLOC_STACK_ARRAY(type, var, size) \
00099      type *var = (type *)alloca ((size) * sizeof (type))
00100 #  if defined(CS_COMPILER_GCC) && defined(__STRICT_ANSI__) && !defined(alloca)
00101 #    define alloca(x) __builtin_alloca(x)
00102 #  endif
00103 #endif
00104 
00108 #ifndef CS_TEMP_DIR
00109 #  if defined(CS_PLATFORM_UNIX)
00110 #    define CS_TEMP_DIR "/tmp/"
00111 #  else
00112 #    define CS_TEMP_DIR ""
00113 #  endif
00114 #endif
00115 
00119 #ifndef CS_TEMP_FILE
00120 #  if defined(CS_PLATFORM_UNIX)
00121 #    define CS_TEMP_FILE "cs%lud.tmp", (unsigned long)getpid()
00122 #  else
00123 #    define CS_TEMP_FILE "$cs$.tmp"
00124 #  endif
00125 #endif
00126 
00127 #ifdef CS_USE_CUSTOM_ISDIR
00128 static inline bool isdir (const char *path, struct dirent *de)
00129 {
00130   int pathlen = strlen (path);
00131   char* fullname = new char[pathlen + 2 + strlen (de->d_name)];
00132   memcpy (fullname, path, pathlen + 1);
00133   if ((pathlen) && (fullname[pathlen-1] != CS_PATH_SEPARATOR))
00134   {
00135     fullname[pathlen++] = CS_PATH_SEPARATOR;
00136     fullname[pathlen] = 0;
00137   }
00138   strcat (&fullname [pathlen], de->d_name);
00139   struct stat st;
00140   stat (fullname, &st);
00141   delete[] fullname;
00142   return ((st.st_mode & S_IFMT) == S_IFDIR);
00143 }
00144 #endif
00145 
00154 // Handle platforms with no native aligned malloc
00155 #ifndef CS_HAVE_CSALIGNED_MALLOC
00156 static inline void* csAlignedMalloc (size_t size, size_t align)
00157 {
00158   void *mallocPtr = malloc(size + align + sizeof(void*));
00159   size_t ptrInt = (size_t)mallocPtr;
00160 
00161   ptrInt = (ptrInt + align + sizeof(void*)) / align * align;
00162   *(((void**)ptrInt) - 1) = mallocPtr;
00163 
00164   return (void*)ptrInt;
00165 }
00166 
00167 static inline void csAlignedFree (void* ptr)
00168 {
00169   free(*(((void**)ptr) - 1));
00170 }
00171 #endif
00172 
00188 #define CS_HEADER_GLOBAL(X,Y) CS_HEADER_GLOBAL_COMPOSE(X,Y)
00189 #define CS_HEADER_GLOBAL_COMPOSE(X,Y) <X/Y>
00190 
00203 #define CS_HEADER_LOCAL(X,Y) CS_HEADER_LOCAL_COMPOSE1(X,Y)
00204 #define CS_HEADER_LOCAL_COMPOSE1(X,Y) CS_HEADER_LOCAL_COMPOSE2(X/Y)
00205 #define CS_HEADER_LOCAL_COMPOSE2(X) #X
00206 
00207 
00213 #if !defined(CS_EXPORTED_FUNCTION)
00214 #  if defined(CS_STATIC_LINKED)
00215 #    define CS_EXPORTED_FUNCTION extern "C"
00216 #  else
00217 #    define CS_EXPORTED_FUNCTION extern "C" CS_EXPORT_SYM_DLL
00218 #  endif
00219 #endif
00220 
00232 #if !defined(CS_EXPORTED_NAME)
00233 #  define CS_EXPORTED_NAME(Prefix, Suffix) Prefix ## Suffix
00234 #endif
00235 
00236 #ifndef CS_IMPLEMENT_PLATFORM_PLUGIN
00237 #  define CS_IMPLEMENT_PLATFORM_PLUGIN
00238 #endif
00239 
00240 #ifndef CS_IMPLEMENT_PLATFORM_APPLICATION
00241 #  define CS_IMPLEMENT_PLATFORM_APPLICATION
00242 #endif
00243 
00250 #ifndef CS_INITIALIZE_PLATFORM_APPLICATION
00251 #  define CS_INITIALIZE_PLATFORM_APPLICATION /* */
00252 /*
00253   This definition may seem odd, but it's here for doxygen's sake, which
00254   apparently fails to document empty macro definitions.
00255  */
00256 #endif
00257 
00258 typedef void (*csStaticVarCleanupFN) (void (*p)());
00259 extern csStaticVarCleanupFN csStaticVarCleanup;
00260 
00261 #ifndef CS_IMPLEMENT_STATIC_VARIABLE_REGISTRATION
00262 #  define CS_IMPLEMENT_STATIC_VARIABLE_REGISTRATION(Name)              \
00263 void Name (void (*p)())                                                \
00264 {                                                                      \
00265   static void (**a)() = 0;                                             \
00266   static int lastEntry = 0;                                            \
00267   static int maxEntries = 0;                                           \
00268                                                                        \
00269   if (p != 0)                                                          \
00270   {                                                                    \
00271     if (lastEntry >= maxEntries)                                       \
00272     {                                                                  \
00273       maxEntries += 10;                                                \
00274       if (a == 0)                                                      \
00275         a = (void (**)())malloc(maxEntries * sizeof(void*));           \
00276       else                                                             \
00277         a = (void (**)())realloc(a, maxEntries * sizeof(void*));       \
00278     }                                                                  \
00279     a[lastEntry++] = p;                                                \
00280   }                                                                    \
00281   else if (a != 0)                                                     \
00282   {                                                                    \
00283     for (int i = lastEntry - 1; i >= 0; i--)                           \
00284       a[i] ();                                                         \
00285     free (a);                                                          \
00286     a = 0;                                                             \
00287     lastEntry = 0;                                                     \
00288     maxEntries = 0;                                                    \
00289   }                                                                    \
00290 }
00291 #endif
00292 
00293 #ifndef CS_DEFINE_STATIC_VARIABLE_REGISTRATION
00294 #  define CS_DEFINE_STATIC_VARIABLE_REGISTRATION(func) \
00295     csStaticVarCleanupFN csStaticVarCleanup = &func
00296 #endif
00297 
00298 #ifndef CS_DECLARE_STATIC_VARIABLE_REGISTRATION
00299 #  define CS_DECLARE_STATIC_VARIABLE_REGISTRATION(func) \
00300     void func (void (*p)())
00301 #endif
00302 
00303 #ifndef CS_DECLARE_DEFAULT_STATIC_VARIABLE_REGISTRATION
00304 #  define CS_DECLARE_DEFAULT_STATIC_VARIABLE_REGISTRATION               \
00305     CS_CRYSTALSPACE_EXPORT                                              \
00306     CS_DECLARE_STATIC_VARIABLE_REGISTRATION (csStaticVarCleanup_csutil);
00307 #endif
00308 
00309 /* scfStaticallyLinked - Flag indicating whether external linkage was used when 
00310  * building the application. Determines whether SCF scans for plugins at 
00311  * startup.
00312  */
00316 #if defined(CS_BUILD_SHARED_LIBS)
00317 #  define CS_DEFINE_STATICALLY_LINKED_FLAG
00318 #elif defined(CS_STATIC_LINKED)
00319 #  define CS_DEFINE_STATICALLY_LINKED_FLAG  bool scfStaticallyLinked = true;
00320 #else
00321 #  define CS_DEFINE_STATICALLY_LINKED_FLAG  bool scfStaticallyLinked = false;
00322 #endif
00323 
00324 
00344 #ifndef CS_IMPLEMENT_FOREIGN_DLL
00345 #  if defined(CS_BUILD_SHARED_LIBS)
00346 #    define CS_IMPLEMENT_FOREIGN_DLL                                        \
00347        CS_IMPLEMENT_STATIC_VARIABLE_REGISTRATION(csStaticVarCleanup_local); \
00348        CS_DEFINE_STATICALLY_LINKED_FLAG                                     \
00349        CS_DEFINE_STATIC_VARIABLE_REGISTRATION (csStaticVarCleanup_local);
00350 #  else
00351 #    define CS_IMPLEMENT_FOREIGN_DLL                                        \
00352        CS_DECLARE_DEFAULT_STATIC_VARIABLE_REGISTRATION                      \
00353        CS_DEFINE_STATICALLY_LINKED_FLAG                                     \
00354        CS_DEFINE_STATIC_VARIABLE_REGISTRATION (csStaticVarCleanup_csutil);
00355 #  endif
00356 #endif
00357 
00366 #if defined(CS_STATIC_LINKED)
00367 
00368 #  ifndef CS_IMPLEMENT_PLUGIN
00369 #  define CS_IMPLEMENT_PLUGIN                                           \
00370           CS_IMPLEMENT_PLATFORM_PLUGIN 
00371 #  endif
00372 
00373 #elif !defined(CS_BUILD_SHARED_LIBS)
00374 
00375 #  ifndef CS_IMPLEMENT_PLUGIN
00376 #  define CS_IMPLEMENT_PLUGIN                                           \
00377           CS_IMPLEMENT_PLATFORM_PLUGIN                                  \
00378           CS_DEFINE_STATICALLY_LINKED_FLAG                              \
00379           CS_DECLARE_DEFAULT_STATIC_VARIABLE_REGISTRATION               \
00380           CS_DEFINE_STATIC_VARIABLE_REGISTRATION (csStaticVarCleanup_csutil);
00381 #  endif
00382 
00383 #else
00384 
00385 #  ifndef CS_IMPLEMENT_PLUGIN
00386 #  define CS_IMPLEMENT_PLUGIN                                           \
00387    CS_DEFINE_STATICALLY_LINKED_FLAG                                     \
00388    CS_IMPLEMENT_STATIC_VARIABLE_REGISTRATION(csStaticVarCleanup_local)  \
00389    CS_DEFINE_STATIC_VARIABLE_REGISTRATION (csStaticVarCleanup_local);   \
00390    CS_IMPLEMENT_PLATFORM_PLUGIN 
00391 #  endif
00392 
00393 #endif
00394 
00403 #ifndef CS_IMPLEMENT_APPLICATION
00404 #  define CS_IMPLEMENT_APPLICATION                                      \
00405   CS_DECLARE_DEFAULT_STATIC_VARIABLE_REGISTRATION                       \
00406   CS_DEFINE_STATICALLY_LINKED_FLAG                                      \
00407   CS_DEFINE_STATIC_VARIABLE_REGISTRATION (csStaticVarCleanup_csutil);   \
00408   CS_IMPLEMENT_PLATFORM_APPLICATION 
00409 #endif
00410 
00414 #ifndef CS_REGISTER_STATIC_FOR_DESTRUCTION
00415 #define CS_REGISTER_STATIC_FOR_DESTRUCTION(getterFunc)\
00416         csStaticVarCleanup (getterFunc);
00417 #endif
00418 
00422 #ifndef CS_STATIC_VARIABLE_CLEANUP
00423 #define CS_STATIC_VARIABLE_CLEANUP  \
00424         csStaticVarCleanup (0);
00425 #endif
00426 
00438 #ifndef CS_IMPLEMENT_STATIC_VAR_EXT
00439 #define CS_IMPLEMENT_STATIC_VAR_EXT(getterFunc,Type,initParam,kill_how) \
00440 extern "C" {                                                            \
00441 static Type *getterFunc ## _v=0;                                        \
00442 static Type* getterFunc ();                                             \
00443 static void getterFunc ## _kill ();                                     \
00444 static void getterFunc ## _kill_array ();                               \
00445 void getterFunc ## _kill ()                                             \
00446 {                                                                       \
00447   (void)(&getterFunc ## _kill_array);                                   \
00448   delete getterFunc ## _v;                                              \
00449   getterFunc ## _v = 0;                                                 \
00450 }                                                                       \
00451 void getterFunc ## _kill_array ()                                       \
00452 {                                                                       \
00453   (void)(&getterFunc ## _kill);                                         \
00454   delete [] getterFunc ## _v;                                           \
00455   getterFunc ## _v = 0;                                                 \
00456 }                                                                       \
00457 Type* getterFunc ()                                                     \
00458 {                                                                       \
00459   if (!getterFunc ## _v)                                                \
00460   {                                                                     \
00461     getterFunc ## _v = new Type initParam;                              \
00462     csStaticVarCleanup (getterFunc ## kill_how);                        \
00463   }                                                                     \
00464   return getterFunc ## _v;                                              \
00465 }                                                                       \
00466 }
00467 #endif
00468 
00469 #ifndef CS_IMPLEMENT_STATIC_VAR
00470 #define CS_IMPLEMENT_STATIC_VAR(getterFunc,Type,initParam) \
00471  CS_IMPLEMENT_STATIC_VAR_EXT(getterFunc,Type,initParam,_kill)    
00472 #endif
00473 
00474 #ifndef CS_IMPLEMENT_STATIC_VAR_ARRAY
00475 #define CS_IMPLEMENT_STATIC_VAR_ARRAY(getterFunc,Type,initParam) \
00476  CS_IMPLEMENT_STATIC_VAR_EXT(getterFunc,Type,initParam,_kill_array)    
00477 #endif
00478 
00486 #ifndef CS_DECLARE_STATIC_CLASSVAR
00487 #define CS_DECLARE_STATIC_CLASSVAR(var,getterFunc,Type)       \
00488 static Type *var;                                             \
00489 static Type *getterFunc ();                                   
00490 #endif
00491 
00492 #ifndef CS_DECLARE_STATIC_CLASSVAR_REF
00493 #define CS_DECLARE_STATIC_CLASSVAR_REF(var,getterFunc,Type)   \
00494 static Type *var;                                             \
00495 static Type &getterFunc ();                                   
00496 #endif
00497 
00508 #ifndef CS_IMPLEMENT_STATIC_CLASSVAR_EXT
00509 #define CS_IMPLEMENT_STATIC_CLASSVAR_EXT(Class,var,getterFunc,Type,initParam,\
00510   kill_how)                                                     \
00511 Type *Class::var = 0;                                           \
00512 extern "C" {                                                    \
00513 static void Class ## _ ## getterFunc ## _kill ();               \
00514 static void Class ## _ ## getterFunc ## _kill_array ();         \
00515 void Class ## _ ## getterFunc ## _kill ()                       \
00516 {                                                               \
00517   delete Class::getterFunc ();                                  \
00518   (void)(&Class ## _ ## getterFunc ## _kill_array);             \
00519 }                                                               \
00520 void Class ## _ ## getterFunc ## _kill_array ()                 \
00521 {                                                               \
00522   delete [] Class::getterFunc ();                               \
00523   (void)(&Class ## _ ## getterFunc ## _kill);                   \
00524 }                                                               \
00525 }                                                               \
00526 Type* Class::getterFunc ()                                      \
00527 {                                                               \
00528   if (!var)                                                     \
00529   {                                                             \
00530     var = new Type initParam;                                   \
00531     csStaticVarCleanup (Class ## _ ## getterFunc ## kill_how);  \
00532   }                                                             \
00533   return var;                                                   \
00534 }
00535 #endif
00536 
00537 #ifndef CS_IMPLEMENT_STATIC_CLASSVAR
00538 #define CS_IMPLEMENT_STATIC_CLASSVAR(Class,var,getterFunc,Type,initParam) \
00539   CS_IMPLEMENT_STATIC_CLASSVAR_EXT(Class,var,getterFunc,Type,initParam,_kill)
00540 #endif
00541 
00542 #ifndef CS_IMPLEMENT_STATIC_CLASSVAR_ARRAY
00543 #define CS_IMPLEMENT_STATIC_CLASSVAR_ARRAY(Class,var,getterFunc,Type,\
00544   initParam) \
00545   CS_IMPLEMENT_STATIC_CLASSVAR_EXT(Class,var,getterFunc,Type,initParam,\
00546     _kill_array)
00547 #endif
00548 
00549 #ifndef CS_IMPLEMENT_STATIC_CLASSVAR_REF_EXT
00550 #define CS_IMPLEMENT_STATIC_CLASSVAR_REF_EXT(Class,var,getterFunc,Type,\
00551   initParam,kill_how) \
00552 Type *Class::var = 0;                                          \
00553 extern "C" {                                                   \
00554 static void Class ## _ ## getterFunc ## _kill ();              \
00555 static void Class ## _ ## getterFunc ## _kill_array ();        \
00556 void Class ## _ ## getterFunc ## _kill ()                      \
00557 {                                                              \
00558   (void) &Class ## _ ## getterFunc ## _kill_array;              \
00559   delete &Class::getterFunc ();                                \
00560 }                                                              \
00561 void Class ## _ ## getterFunc ## _kill_array ()                \
00562 {                                                              \
00563   (void) &Class ## _ ## getterFunc ## _kill;                    \
00564   delete [] &Class::getterFunc ();                             \
00565 }                                                              \
00566 }                                                              \
00567 Type &Class::getterFunc ()                                     \
00568 {                                                              \
00569   if (!var)                                                    \
00570   {                                                            \
00571     var = new Type initParam;                                  \
00572     csStaticVarCleanup (Class ## _ ## getterFunc ## kill_how); \
00573   }                                                            \
00574   return *var;                                                 \
00575 }
00576 #endif
00577 
00578 #ifndef CS_IMPLEMENT_STATIC_CLASSVAR_REF
00579 #define CS_IMPLEMENT_STATIC_CLASSVAR_REF(Class,var,getterFunc,Type,initParam)\
00580   CS_IMPLEMENT_STATIC_CLASSVAR_REF_EXT(Class,var,getterFunc,Type,\
00581     initParam,_kill)
00582 #endif
00583 
00584 #ifndef CS_IMPLEMENT_STATIC_CLASSVAR_REF_ARRAY
00585 #define CS_IMPLEMENT_STATIC_CLASSVAR_REF_ARRAY(Class,var,getterFunc,Type,\
00586   initParam) \
00587   CS_IMPLEMENT_STATIC_CLASSVAR_REF_EXT(Class,var,getterFunc,Type,initParam,\
00588     _kill_array)
00589 #endif
00590 
00591 // The following define should only be enabled if you have defined
00592 // a special version of overloaded new that accepts two additional
00593 // parameters: a (void*) pointing to the filename and an int with the
00594 // line number. This is typically used for memory debugging.
00595 // In csutil/memdebug.cpp there is a memory debugger which can (optionally)
00596 // use this feature. Note that if CS_EXTENSIVE_MEMDEBUG is enabled while
00597 // the memory debugger is not the memory debugger will still provide the
00598 // needed overloaded operators so you can leave CS_EXTENSIVE_MEMDEBUG on in
00599 // that case and the only overhead will be a little more arguments to 'new'.
00600 // Do not enable CS_EXTENSIVE_MEMDEBUG if your platform or your own code
00601 // defines its own 'new' operator, since this version will interfere with your
00602 // own.
00603 // CS_MEMORY_TRACKER is treated like CS_EXTENSIVE_MEMDEBUG here.
00604 // Same for CS_REF_TRACKER.
00605 #ifndef CS_DEBUG
00606 #  undef CS_EXTENSIVE_MEMDEBUG
00607 #  undef CS_REF_TRACKER
00608 #else
00609 #  if defined(CS_EXTENSIVE_MEMDEBUG) && defined(CS_MEMORY_TRACKER)
00610 #    error Do not use CS_EXTENSIVE_MEMDEBUG and CS_MEMORY_TRACKER together!
00611 #  endif
00612 #endif
00613 #if defined(CS_EXTENSIVE_MEMDEBUG) || defined(CS_MEMORY_TRACKER)
00614 extern void* operator new (size_t s, void* filename, int line);
00615 extern void* operator new[] (size_t s, void* filename, int line);
00616 #define CS_EXTENSIVE_MEMDEBUG_NEW new ((void*)__FILE__, __LINE__)
00617 #define new CS_EXTENSIVE_MEMDEBUG_NEW
00618 #endif
00619 
00620 #ifdef CS_DEBUG
00621 #  if !defined (CS_DEBUG_BREAK)
00622 #    if defined (CS_PLATFORM_WIN32)
00623 #      define CS_DEBUG_BREAK ::DebugBreak()
00624 #    elif defined (CS_PROCESSOR_X86)
00625 #      if defined (CS_COMPILER_GCC)
00626 #        define CS_DEBUG_BREAK asm ("int $3")
00627 #      else
00628 #        define CS_DEBUG_BREAK _asm int 3
00629 #      endif
00630 #    else
00631 #      define CS_DEBUG_BREAK { static int x = 0; x /= x; }
00632 #    endif
00633 #  endif
00634 #  if !defined (CS_ASSERT)
00635 #    if defined (CS_COMPILER_MSVC)
00636 #      define CS_ASSERT(x) assert(x)
00637 #    else
00638 #      include <stdio.h>
00639 #      define CS_ASSERT(x) \
00640          if (!(x)) \
00641          { \
00642            fprintf (stderr, __FILE__ ":%d: failed assertion '%s'\n", \
00643              int(__LINE__), #x); \
00644            CS_DEBUG_BREAK; \
00645          }
00646 #    endif
00647 #  endif
00648 #  if !defined (CS_ASSERT_MSG)
00649 #      define CS_ASSERT_MSG(msg,x) CS_ASSERT(((msg) && (x)))
00650 #  endif
00651 #else
00652 #  undef  CS_DEBUG_BREAK
00653 #  define CS_DEBUG_BREAK
00654 #  undef  CS_ASSERT
00655 #  define CS_ASSERT(x)
00656 #  undef  CS_ASSERT_MSG
00657 #  define CS_ASSERT_MSG(m,x)
00658 #endif
00659 
00671 #if !defined(CS_DEPRECATED_METHOD) || defined(DOXYGEN_RUN)
00672 #  if defined(CS_COMPILER_MSVC)
00673 #    define CS_DEPRECATED_METHOD                /*__declspec(deprecated)*/
00674       /* Disabled: Unfortunately, MSVC is overzealous with warnings; 
00675          it even emits one when a deprecated method is overridden, e.g. when 
00676          implementing an interface method. */
00677 #  else
00678 #    define CS_DEPRECATED_METHOD
00679 #  endif
00680 #endif
00681 
00691 #if !defined(CS_DEPRECATED_TYPE) || defined(DOXYGEN_RUN)
00692 #  if defined(CS_COMPILER_MSVC)
00693 #    define CS_DEPRECATED_TYPE
00694 #  else
00695 #    define CS_DEPRECATED_TYPE
00696 #  endif
00697 #endif
00698 
00710 #if !defined(CS_CONST_METHOD) || defined(DOXYGEN_RUN)
00711 #define CS_CONST_METHOD
00712 #endif
00713 
00726 #if !defined(CS_PURE_METHOD) || defined(DOXYGEN_RUN)
00727 #define CS_PURE_METHOD
00728 #endif
00729 
00730 // Check if the csosdefs.h defined either CS_LITTLE_ENDIAN or CS_BIG_ENDIAN
00731 #if !defined (CS_LITTLE_ENDIAN) && !defined (CS_BIG_ENDIAN)
00732 #  error No CS_XXX_ENDIAN macro defined in your OS-specific csosdefs.h!
00733 #endif
00734 
00735 /*
00736  * This is a bit of overkill but if you're sure your CPU doesn't require
00737  * strict alignment add your CPU to the !defined below to get slightly
00738  * smaller and faster code in some cases.
00739  *
00740  * @@@ In the future, this should be moved to csconfig.h and determined as
00741  * part of the configuration process.
00742  */
00743 #if !defined (CS_PROCESSOR_X86)
00744 #  define CS_STRICT_ALIGNMENT
00745 #endif
00746 
00747 // Adjust some definitions contained in csconfig.h
00748 #if !defined (CS_PROCESSOR_X86) || !defined (CS_HAVE_NASM)
00749 #  undef CS_HAVE_MMX
00750 #  undef CS_HAVE_NASM
00751 #endif
00752 
00753 // Use special knowledge of IEEE float format in some cases for CPU's that are
00754 // known to support it
00755 #if !defined (CS_IEEE_DOUBLE_FORMAT)
00756 #  if defined (CS_PROCESSOR_X86) || \
00757       defined (CS_PROCESSOR_POWERPC) || \
00758       defined (CS_PROCESSOR_M68K)
00759 #    define CS_IEEE_DOUBLE_FORMAT
00760 #  endif
00761 #endif
00762 
00763 // gcc can perform usefull checking for printf/scanf format strings, just add
00764 // this define at the end of the function declaration
00765 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
00766 #  define CS_GNUC_PRINTF(format_idx, arg_idx) \
00767      __attribute__((format (__printf__, format_idx, arg_idx)))
00768 #  define CS_GNUC_SCANF(format_idx, arg_idx) \
00769      __attribute__((format (__scanf__, format_idx, arg_idx)))
00770 #else
00771 #  define CS_GNUC_PRINTF(format_idx, arg_idx)
00772 #  define CS_GNUC_SCANF(format_idx, arg_idx)
00773 #endif
00774 
00775 // Remove __attribute__ on non GNUC compilers.
00776 #ifndef __GNUC__
00777 #define __attribute__(x)
00778 #endif
00779 
00780 // Support for alignment and packing of structures.
00781 #if !defined(CS_STRUCT_ALIGN_4BYTE_BEGIN)
00782 #  if defined(__GNUC__) && defined(CS_STRICT_ALIGNMENT)
00783 #    define CS_STRUCT_ALIGN_4BYTE_BEGIN
00784 #    define CS_STRUCT_ALIGN_4BYTE_END __attribute__ ((aligned(4)))
00785 #  else
00786 #    define CS_STRUCT_ALIGN_4BYTE_BEGIN
00787 #    define CS_STRUCT_ALIGN_4BYTE_END
00788 #  endif
00789 #endif
00790 
00791 // Macro used to define static implicit pointer conversion function.
00792 // Only use within a class declaration.
00793 #ifndef _CS_IMPLICITPTRCAST_NAME
00794 #  define _CS_IMPLICITPTRCAST_NAME __ImplicitPtrCast
00795 #endif
00796 
00818 #define CS_IMPLEMENT_IMPLICIT_PTR_CAST(classname) \
00819   inline static classname* _CS_IMPLICITPTRCAST_NAME (classname* ptr) \
00820   { \
00821     return ptr;\
00822   }
00823 
00832 #define CS_IMPLICIT_PTR_CAST(classname, ptr) \
00833   (classname::_CS_IMPLICITPTRCAST_NAME(ptr))
00834 
00838 #ifdef CS_HAVE_VA_COPY
00839 #  define CS_VA_COPY(dest, src)         va_copy(dest, src)
00840 #else
00841 #  ifdef CS_HAVE___VA_COPY
00842 #    define CS_VA_COPY(dest, src)       __va_copy(dest, src)
00843 #  else
00844 #    define CS_VA_COPY(dest, src)       dest = src;
00845 #  endif
00846 #endif
00847 
00852 #if defined(CS_COMPILER_GCC)
00853 #  define CS_FUNCTION_NAME              __PRETTY_FUNCTION__
00854 #elif defined(__FUNCTION__)
00855 #  define CS_FUNCTION_NAME              __FUNCTION__
00856 #else
00857 #  define CS_FUNCTION_NAME              "<?\?\?>"
00858 #endif
00859 
00860 #define CS_STRING_TO_WIDE_(x)   L ## x
00861 
00868 #define CS_STRING_TO_WIDE(x)    CS_STRING_TO_WIDE_(x)
00869 
00870 #endif // __CS_CSSYSDEF_H__

Generated for Crystal Space by doxygen 1.4.4