CrystalSpace

Public API Reference

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 
00439 #ifndef CS_IMPLEMENT_STATIC_VAR_EXT
00440 #define CS_IMPLEMENT_STATIC_VAR_EXT(getterFunc,Type,initParam,kill_how) \
00441 extern "C" {                                                            \
00442 static Type *getterFunc ## _v=0;                                        \
00443 static Type* getterFunc ();                                             \
00444 static void getterFunc ## _kill ();                                     \
00445 static void getterFunc ## _kill_array ();                               \
00446 void getterFunc ## _kill ()                                             \
00447 {                                                                       \
00448   (void)(&getterFunc ## _kill_array);                                   \
00449   delete getterFunc ## _v;                                              \
00450   getterFunc ## _v = 0;                                                 \
00451 }                                                                       \
00452 void getterFunc ## _kill_array ()                                       \
00453 {                                                                       \
00454   (void)(&getterFunc ## _kill);                                         \
00455   delete [] getterFunc ## _v;                                           \
00456   getterFunc ## _v = 0;                                                 \
00457 }                                                                       \
00458 Type* getterFunc ()                                                     \
00459 {                                                                       \
00460   if (!getterFunc ## _v)                                                \
00461   {                                                                     \
00462     getterFunc ## _v = new Type initParam;                              \
00463     csStaticVarCleanup (getterFunc ## kill_how);                        \
00464   }                                                                     \
00465   return getterFunc ## _v;                                              \
00466 }                                                                       \
00467 }
00468 #endif
00469 
00470 #ifndef CS_IMPLEMENT_STATIC_VAR
00471 #define CS_IMPLEMENT_STATIC_VAR(getterFunc,Type,initParam) \
00472  CS_IMPLEMENT_STATIC_VAR_EXT(getterFunc,Type,initParam,_kill)    
00473 #endif
00474 
00475 #ifndef CS_IMPLEMENT_STATIC_VAR_ARRAY
00476 #define CS_IMPLEMENT_STATIC_VAR_ARRAY(getterFunc,Type,initParam) \
00477  CS_IMPLEMENT_STATIC_VAR_EXT(getterFunc,Type,initParam,_kill_array)    
00478 #endif
00479 
00487 #ifndef CS_DECLARE_STATIC_CLASSVAR
00488 #define CS_DECLARE_STATIC_CLASSVAR(var,getterFunc,Type)       \
00489 static Type *var;                                             \
00490 static Type *getterFunc ();                                   
00491 #endif
00492 
00493 #ifndef CS_DECLARE_STATIC_CLASSVAR_REF
00494 #define CS_DECLARE_STATIC_CLASSVAR_REF(var,getterFunc,Type)   \
00495 static Type *var;                                             \
00496 static Type &getterFunc ();                                   
00497 #endif
00498 
00509 #ifndef CS_IMPLEMENT_STATIC_CLASSVAR_EXT
00510 #define CS_IMPLEMENT_STATIC_CLASSVAR_EXT(Class,var,getterFunc,Type,initParam,\
00511   kill_how)                                                     \
00512 Type *Class::var = 0;                                           \
00513 extern "C" {                                                    \
00514 static void Class ## _ ## getterFunc ## _kill ();               \
00515 static void Class ## _ ## getterFunc ## _kill_array ();         \
00516 void Class ## _ ## getterFunc ## _kill ()                       \
00517 {                                                               \
00518   delete Class::getterFunc ();                                  \
00519   (void)(&Class ## _ ## getterFunc ## _kill_array);             \
00520 }                                                               \
00521 void Class ## _ ## getterFunc ## _kill_array ()                 \
00522 {                                                               \
00523   delete [] Class::getterFunc ();                               \
00524   (void)(&Class ## _ ## getterFunc ## _kill);                   \
00525 }                                                               \
00526 }                                                               \
00527 Type* Class::getterFunc ()                                      \
00528 {                                                               \
00529   if (!var)                                                     \
00530   {                                                             \
00531     var = new Type initParam;                                   \
00532     csStaticVarCleanup (Class ## _ ## getterFunc ## kill_how);  \
00533   }                                                             \
00534   return var;                                                   \
00535 }
00536 #endif
00537 
00538 #ifndef CS_IMPLEMENT_STATIC_CLASSVAR
00539 #define CS_IMPLEMENT_STATIC_CLASSVAR(Class,var,getterFunc,Type,initParam) \
00540   CS_IMPLEMENT_STATIC_CLASSVAR_EXT(Class,var,getterFunc,Type,initParam,_kill)
00541 #endif
00542 
00543 #ifndef CS_IMPLEMENT_STATIC_CLASSVAR_ARRAY
00544 #define CS_IMPLEMENT_STATIC_CLASSVAR_ARRAY(Class,var,getterFunc,Type,\
00545   initParam) \
00546   CS_IMPLEMENT_STATIC_CLASSVAR_EXT(Class,var,getterFunc,Type,initParam,\
00547     _kill_array)
00548 #endif
00549 
00550 #ifndef CS_IMPLEMENT_STATIC_CLASSVAR_REF_EXT
00551 #define CS_IMPLEMENT_STATIC_CLASSVAR_REF_EXT(Class,var,getterFunc,Type,\
00552   initParam,kill_how) \
00553 Type *Class::var = 0;                                          \
00554 extern "C" {                                                   \
00555 static void Class ## _ ## getterFunc ## _kill ();              \
00556 static void Class ## _ ## getterFunc ## _kill_array ();        \
00557 void Class ## _ ## getterFunc ## _kill ()                      \
00558 {                                                              \
00559   (void) &Class ## _ ## getterFunc ## _kill_array;              \
00560   delete &Class::getterFunc ();                                \
00561 }                                                              \
00562 void Class ## _ ## getterFunc ## _kill_array ()                \
00563 {                                                              \
00564   (void) &Class ## _ ## getterFunc ## _kill;                    \
00565   delete [] &Class::getterFunc ();                             \
00566 }                                                              \
00567 }                                                              \
00568 Type &Class::getterFunc ()                                     \
00569 {                                                              \
00570   if (!var)                                                    \
00571   {                                                            \
00572     var = new Type initParam;                                  \
00573     csStaticVarCleanup (Class ## _ ## getterFunc ## kill_how); \
00574   }                                                            \
00575   return *var;                                                 \
00576 }
00577 #endif
00578 
00579 #ifndef CS_IMPLEMENT_STATIC_CLASSVAR_REF
00580 #define CS_IMPLEMENT_STATIC_CLASSVAR_REF(Class,var,getterFunc,Type,initParam)\
00581   CS_IMPLEMENT_STATIC_CLASSVAR_REF_EXT(Class,var,getterFunc,Type,\
00582     initParam,_kill)
00583 #endif
00584 
00585 #ifndef CS_IMPLEMENT_STATIC_CLASSVAR_REF_ARRAY
00586 #define CS_IMPLEMENT_STATIC_CLASSVAR_REF_ARRAY(Class,var,getterFunc,Type,\
00587   initParam) \
00588   CS_IMPLEMENT_STATIC_CLASSVAR_REF_EXT(Class,var,getterFunc,Type,initParam,\
00589     _kill_array)
00590 #endif
00591 
00592 // The following define should only be enabled if you have defined
00593 // a special version of overloaded new that accepts two additional
00594 // parameters: a (void*) pointing to the filename and an int with the
00595 // line number. This is typically used for memory debugging.
00596 // In csutil/memdebug.cpp there is a memory debugger which can (optionally)
00597 // use this feature. Note that if CS_EXTENSIVE_MEMDEBUG is enabled while
00598 // the memory debugger is not the memory debugger will still provide the
00599 // needed overloaded operators so you can leave CS_EXTENSIVE_MEMDEBUG on in
00600 // that case and the only overhead will be a little more arguments to 'new'.
00601 // Do not enable CS_EXTENSIVE_MEMDEBUG if your platform or your own code
00602 // defines its own 'new' operator, since this version will interfere with your
00603 // own.
00604 // CS_MEMORY_TRACKER is treated like CS_EXTENSIVE_MEMDEBUG here.
00605 // Same for CS_REF_TRACKER.
00606 #ifndef CS_DEBUG
00607 #  undef CS_EXTENSIVE_MEMDEBUG
00608 #  undef CS_REF_TRACKER
00609 #else
00610 #  if defined(CS_EXTENSIVE_MEMDEBUG) && defined(CS_MEMORY_TRACKER)
00611 #    error Do not use CS_EXTENSIVE_MEMDEBUG and CS_MEMORY_TRACKER together!
00612 #  endif
00613 #endif
00614 #if defined(CS_EXTENSIVE_MEMDEBUG) || defined(CS_MEMORY_TRACKER)
00615 extern void* operator new (size_t s, void* filename, int line);
00616 extern void* operator new[] (size_t s, void* filename, int line);
00617 #define CS_EXTENSIVE_MEMDEBUG_NEW new ((void*)__FILE__, __LINE__)
00618 #define new CS_EXTENSIVE_MEMDEBUG_NEW
00619 #endif
00620 
00621 #ifdef CS_DEBUG
00622 #  if !defined (CS_DEBUG_BREAK)
00623 #    if defined (CS_PLATFORM_WIN32)
00624 #      define CS_DEBUG_BREAK ::DebugBreak()
00625 #    elif defined (CS_PROCESSOR_X86)
00626 #      if defined (CS_COMPILER_GCC)
00627 #        define CS_DEBUG_BREAK asm ("int $3")
00628 #      else
00629 #        define CS_DEBUG_BREAK _asm int 3
00630 #      endif
00631 #    else
00632 #      define CS_DEBUG_BREAK { static int x = 0; x /= x; }
00633 #    endif
00634 #  endif
00635 #  if !defined (CS_ASSERT_MSG)
00636     namespace CrystalSpace
00637     {
00638       namespace Debug
00639       {
00640         extern void AssertMessage (const char* expr, const char* filename, 
00641           int line, const char* msg = 0);
00642       } // namespace Debug
00643     } // namespace CrystalSpace
00644 #   define CS_ASSERT_MSG(msg,x)                                         \
00645       if (!(x)) CrystalSpace::Debug::AssertMessage (#x, __FILE__, __LINE__, msg);
00646 #  endif
00647 #  if !defined (CS_ASSERT)
00648 #    define CS_ASSERT(x)        CS_ASSERT_MSG(0, x)
00649 #  endif
00650 #else
00651 #  undef  CS_DEBUG_BREAK
00652 #  define CS_DEBUG_BREAK
00653 #  undef  CS_ASSERT
00654 #  define CS_ASSERT(x)          (void)0
00655 #  undef  CS_ASSERT_MSG
00656 #  define CS_ASSERT_MSG(m,x)    (void)0
00657 #endif
00658 
00685 #if !defined(CS_DEPRECATED_METHOD) || defined(DOXYGEN_RUN)
00686 #  if defined(CS_COMPILER_MSVC)
00687 #    define CS_DEPRECATED_METHOD                /*__declspec(deprecated)*/
00688       /* Disabled: Unfortunately, MSVC is overzealous with warnings; 
00689          it even emits one when a deprecated method is overridden, e.g. when 
00690          implementing an interface method. */
00691 #  else
00692 #    define CS_DEPRECATED_METHOD
00693 #  endif
00694 #endif
00695 
00705 #if !defined(CS_DEPRECATED_TYPE) || defined(DOXYGEN_RUN)
00706 #  if defined(CS_COMPILER_MSVC)
00707 #    define CS_DEPRECATED_TYPE
00708 #  else
00709 #    define CS_DEPRECATED_TYPE
00710 #  endif
00711 #endif
00712 
00724 #if !defined(CS_CONST_METHOD) || defined(DOXYGEN_RUN)
00725 #define CS_CONST_METHOD
00726 #endif
00727 
00740 #if !defined(CS_PURE_METHOD) || defined(DOXYGEN_RUN)
00741 #define CS_PURE_METHOD
00742 #endif
00743 
00744 // Check if the csosdefs.h defined either CS_LITTLE_ENDIAN or CS_BIG_ENDIAN
00745 #if !defined (CS_LITTLE_ENDIAN) && !defined (CS_BIG_ENDIAN)
00746 #  error No CS_XXX_ENDIAN macro defined in your OS-specific csosdefs.h!
00747 #endif
00748 
00749 /*
00750  * This is a bit of overkill but if you're sure your CPU doesn't require
00751  * strict alignment add your CPU to the !defined below to get slightly
00752  * smaller and faster code in some cases.
00753  *
00754  * @@@ In the future, this should be moved to csconfig.h and determined as
00755  * part of the configuration process.
00756  */
00757 #if !defined (CS_PROCESSOR_X86)
00758 #  define CS_STRICT_ALIGNMENT
00759 #endif
00760 
00761 // Adjust some definitions contained in csconfig.h
00762 #if !defined (CS_PROCESSOR_X86) || !defined (CS_HAVE_NASM)
00763 #  undef CS_HAVE_MMX
00764 #  undef CS_HAVE_NASM
00765 #endif
00766 
00767 // Use special knowledge of IEEE float format in some cases for CPU's that are
00768 // known to support it
00769 #if !defined (CS_IEEE_DOUBLE_FORMAT)
00770 #  if defined (CS_PROCESSOR_X86) || \
00771       defined (CS_PROCESSOR_POWERPC) || \
00772       defined (CS_PROCESSOR_M68K)
00773 #    define CS_IEEE_DOUBLE_FORMAT
00774 #  endif
00775 #endif
00776 
00777 // gcc can perform usefull checking for printf/scanf format strings, just add
00778 // this define at the end of the function declaration
00779 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
00780 #  define CS_GNUC_PRINTF(format_idx, arg_idx) \
00781      __attribute__((format (__printf__, format_idx, arg_idx)))
00782 #  define CS_GNUC_SCANF(format_idx, arg_idx) \
00783      __attribute__((format (__scanf__, format_idx, arg_idx)))
00784 #else
00785 #  define CS_GNUC_PRINTF(format_idx, arg_idx)
00786 #  define CS_GNUC_SCANF(format_idx, arg_idx)
00787 #endif
00788 
00789 // Remove __attribute__ on non GNUC compilers.
00790 #ifndef __GNUC__
00791 #define __attribute__(x)
00792 #endif
00793 
00794 // Support for alignment and packing of structures.
00795 #if !defined(CS_STRUCT_ALIGN_4BYTE_BEGIN)
00796 #  if defined(__GNUC__) && defined(CS_STRICT_ALIGNMENT)
00797 #    define CS_STRUCT_ALIGN_4BYTE_BEGIN
00798 #    define CS_STRUCT_ALIGN_4BYTE_END __attribute__ ((aligned(4)))
00799 #  else
00800 #    define CS_STRUCT_ALIGN_4BYTE_BEGIN
00801 #    define CS_STRUCT_ALIGN_4BYTE_END
00802 #  endif
00803 #endif
00804 
00805 #if defined(CS_COMPILER_MSVC)
00806   #define CS_ALIGNED_MEMBER(Member, Align)                              \
00807     __declspec(align(Align)) Member
00808 #elif defined(CS_COMPILER_GCC)
00809 
00821   #define CS_ALIGNED_MEMBER(Member, Align)                              \
00822     Member __attribute((aligned(Align)))
00823 #else
00824   #define CS_ALIGNED_MEMBER(Member, Align)      Member
00825 #endif
00826 
00827 // Macro used to define static implicit pointer conversion function.
00828 // Only use within a class declaration.
00829 #ifndef _CS_IMPLICITPTRCAST_NAME
00830 #  define _CS_IMPLICITPTRCAST_NAME __ImplicitPtrCast
00831 #endif
00832 
00854 #define CS_IMPLEMENT_IMPLICIT_PTR_CAST(classname) \
00855   inline static classname* _CS_IMPLICITPTRCAST_NAME (classname* ptr) \
00856   { \
00857     return ptr;\
00858   }
00859 
00868 #define CS_IMPLICIT_PTR_CAST(classname, ptr) \
00869   (classname::_CS_IMPLICITPTRCAST_NAME(ptr))
00870 
00874 #ifdef CS_HAVE_VA_COPY
00875 #  define CS_VA_COPY(dest, src)         va_copy(dest, src)
00876 #else
00877 #  ifdef CS_HAVE___VA_COPY
00878 #    define CS_VA_COPY(dest, src)       __va_copy(dest, src)
00879 #  else
00880 #    define CS_VA_COPY(dest, src)       dest = src;
00881 #  endif
00882 #endif
00883 
00888 #if defined(CS_COMPILER_GCC)
00889 #  define CS_FUNCTION_NAME              __PRETTY_FUNCTION__
00890 #elif defined(__FUNCTION__)
00891 #  define CS_FUNCTION_NAME              __FUNCTION__
00892 #else
00893 #  define CS_FUNCTION_NAME              "<?\?\?>"
00894 #endif
00895 
00896 #define CS_STRING_TO_WIDE_(x)   L ## x
00897 
00904 #define CS_STRING_TO_WIDE(x)    CS_STRING_TO_WIDE_(x)
00905 
00906 #endif // __CS_CSSYSDEF_H__

Generated for Crystal Space by doxygen 1.4.6