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_VISIBILITY_DEFAULT
00043 #  define CS_VISIBILITY_DEFAULT
00044 #endif
00045 #ifndef CS_VISIBILITY_HIDDEN
00046 #  define CS_VISIBILITY_HIDDEN
00047 #endif
00048 #ifndef CS_EXPORT_SYM_DLL
00049 #  define CS_EXPORT_SYM_DLL CS_VISIBILITY_DEFAULT
00050 #endif
00051 #ifndef CS_IMPORT_SYM_DLL
00052 #  define CS_IMPORT_SYM_DLL extern
00053 #endif
00054 #ifndef CS_EXPORT_SYM
00055 #  if defined(CS_BUILD_SHARED_LIBS)
00056 #    define CS_EXPORT_SYM CS_VISIBILITY_DEFAULT
00057 #  else
00058 #    define CS_EXPORT_SYM
00059 #  endif
00060 #endif
00061 #ifndef CS_IMPORT_SYM
00062 #  define CS_IMPORT_SYM
00063 #endif
00064 
00065 #include "csextern.h"
00066 
00067 /*
00068  * Default definitions for requested functionality.  Platform-specific
00069  * configuration files may override these.
00070  */
00071 
00072 #ifndef CS_FORCEINLINE
00073 # ifdef CS_COMPILER_GCC
00074 #  define CS_FORCEINLINE inline __attribute__((always_inline))
00075 #  if (__GNUC__ == 3) && (__GNUC_MINOR__ == 4)
00076     // Work around a gcc 3.4 issue where forcing inline doesn't always work
00077 #   define CS_FORCEINLINE_TEMPLATEMETHOD inline
00078 #  endif
00079 # else
00080 #  define CS_FORCEINLINE inline
00081 # endif
00082 #endif
00083 #ifndef CS_FORCEINLINE_TEMPLATEMETHOD
00084 # define CS_FORCEINLINE_TEMPLATEMETHOD CS_FORCEINLINE
00085 #endif
00086 
00091 #ifndef CS_ATTRIBUTE_MALLOC
00092 # define CS_ATTRIBUTE_MALLOC
00093 #endif
00094 
00106 #if !defined(CS_DEPRECATED_METHOD) || defined(DOXYGEN_RUN)
00107 #  if defined(CS_COMPILER_MSVC)
00108 #    define CS_DEPRECATED_METHOD        __declspec(deprecated)
00109       /* Unfortunately, MSVC is overzealous with warnings; it even emits one 
00110          when a deprecated method is overridden, e.g. when implementing an 
00111          interface method. 
00112          To work around this, use msvc_deprecated_warn_off.h/
00113          msvc_deprecated_warn_on.h. */
00114 #  else
00115 #    define CS_DEPRECATED_METHOD
00116 #  endif
00117 #endif
00118 
00123 #if !defined(CS_DEPRECATED_METHOD_MSG) || defined(DOXYGEN_RUN)
00124 #  if defined(CS_COMPILER_MSVC) && _MSC_VER >= 1400
00125 #    define CS_DEPRECATED_METHOD_MSG(msg) __declspec(deprecated(msg))
00126 #  else
00127 #    define CS_DEPRECATED_METHOD_MSG(msg) CS_DEPRECATED_METHOD
00128 #  endif
00129 #endif
00130 
00141 #if !defined(CS_DEPRECATED_TYPE) || defined(DOXYGEN_RUN)
00142 #  if defined(CS_COMPILER_MSVC)
00143 #    define CS_DEPRECATED_TYPE __declspec(deprecated)
00144 #  else
00145 #    define CS_DEPRECATED_TYPE
00146 #  endif
00147 #endif
00148 
00153 #if !defined(CS_DEPRECATED_TYPE_MSG) || defined(DOXYGEN_RUN)
00154 #  if defined(CS_COMPILER_MSVC) && _MSC_VER >= 1400
00155 #    define CS_DEPRECATED_TYPE_MSG(msg) __declspec(deprecated(msg))
00156 #  else
00157 #    define CS_DEPRECATED_TYPE_MSG(msg) CS_DEPRECATED_TYPE
00158 #  endif
00159 #endif
00160 
00165 #if defined(CS_COMPILER_MSVC) 
00166   #include <exception>
00167   #if !_HAS_EXCEPTIONS
00168     #define CS_NO_EXCEPTIONS
00169   #endif
00170 #elif defined(CS_COMPILER_GCC) && !defined(__EXCEPTIONS)
00171   #define CS_NO_EXCEPTIONS
00172 #endif
00173 
00178 #ifndef CS_MAXPATHLEN
00179 #define CS_MAXPATHLEN 1024
00180 #endif
00181 #include <stdio.h>
00182 #ifdef CS_HAVE_SYS_PARAM_H
00183 #include <sys/param.h>
00184 #endif
00185 
00192 #if defined(CS_COMPILER_GCC) && !defined(__STRICT_ANSI__)
00193 // In GCC we are able to declare stack vars of dynamic size directly
00194 #  define CS_ALLOC_STACK_ARRAY(type, var, size) \
00195      type var [size]
00196 #else
00197 #  include <stdlib.h>
00198 #  define CS_ALLOC_STACK_ARRAY(type, var, size) \
00199      type *var = (type *)alloca ((size) * sizeof (type))
00200 #  if defined(CS_COMPILER_GCC) && defined(__STRICT_ANSI__) && !defined(alloca)
00201 #    define alloca(x) __builtin_alloca(x)
00202 #  endif
00203 #endif
00204 
00205 
00206 
00207 
00212 #ifndef CS_TEMP_DIR
00213 class csString;
00214 
00215 namespace CS
00216 {
00217   namespace Macros
00218   {
00219     CS_DEPRECATED_METHOD_MSG("Use CS::Platform::GetTempDirectory () from "
00220       "syspath.h") CS_CRYSTALSPACE_EXPORT csString CS_TEMP_DIR ();
00221   }
00222 }
00223 #  define CS_TEMP_DIR CS::Macros::CS_TEMP_DIR.GetDataSafe()
00224 #endif
00225 
00226 
00231 #ifndef CS_TEMP_FILE
00232 class csString;
00233 
00234 namespace CS
00235 {
00236   namespace Macros
00237   {
00238     CS_DEPRECATED_METHOD_MSG("Use CS::Platform::GetTempFilename () from "
00239       "syspath.h") CS_CRYSTALSPACE_EXPORT csString CS_TEMP_FILE ();
00240   }
00241 }
00242 #  define CS_TEMP_FILE CS::Macros::CS_TEMP_FILE.GetDataSafe()
00243 #endif
00244 
00268 #define CS_HEADER_GLOBAL(X,Y) CS_HEADER_GLOBAL_COMPOSE(X,Y)
00269 #define CS_HEADER_GLOBAL_COMPOSE(X,Y) <X/Y>
00270 
00283 #define CS_HEADER_LOCAL(X,Y) CS_HEADER_LOCAL_COMPOSE1(X,Y)
00284 #define CS_HEADER_LOCAL_COMPOSE1(X,Y) CS_HEADER_LOCAL_COMPOSE2(X/Y)
00285 #define CS_HEADER_LOCAL_COMPOSE2(X) #X
00286 
00287 
00293 #if !defined(CS_EXPORTED_FUNCTION)
00294 #  if defined(CS_STATIC_LINKED)
00295 #    define CS_EXPORTED_FUNCTION extern "C"
00296 #  else
00297 #    define CS_EXPORTED_FUNCTION extern "C" CS_EXPORT_SYM_DLL
00298 #  endif
00299 #endif
00300 
00312 #if !defined(CS_EXPORTED_NAME)
00313 #  define CS_EXPORTED_NAME(Prefix, Suffix) Prefix ## Suffix
00314 #endif
00315 
00316 #ifndef CS_IMPLEMENT_PLATFORM_PLUGIN
00317 #  define CS_IMPLEMENT_PLATFORM_PLUGIN
00318 #endif
00319 
00320 #ifndef CS_IMPLEMENT_PLATFORM_APPLICATION
00321 #  define CS_IMPLEMENT_PLATFORM_APPLICATION
00322 #endif
00323 
00330 #ifndef CS_INITIALIZE_PLATFORM_APPLICATION
00331 #  define CS_INITIALIZE_PLATFORM_APPLICATION /* */
00332 /*
00333   This definition may seem odd, but it's here for doxygen's sake, which
00334   apparently fails to document empty macro definitions.
00335  */
00336 #endif
00337 
00338 typedef void (*csStaticVarCleanupFN) (void (*p)());
00339 extern csStaticVarCleanupFN csStaticVarCleanup;
00340 
00341 #ifndef CS_IMPLEMENT_STATIC_VARIABLE_REGISTRATION
00342 #  define CS_IMPLEMENT_STATIC_VARIABLE_REGISTRATION(Name)              \
00343 void Name (void (*p)())                                                \
00344 {                                                                      \
00345   static void (**a)() = 0;                                             \
00346   static int lastEntry = 0;                                            \
00347   static int maxEntries = 0;                                           \
00348                                                                        \
00349   if (p != 0)                                                          \
00350   {                                                                    \
00351     if (lastEntry >= maxEntries)                                       \
00352     {                                                                  \
00353       maxEntries += 10;                                                \
00354       if (a == 0)                                                      \
00355         a = (void (**)())malloc(maxEntries * sizeof(void*));           \
00356       else                                                             \
00357         a = (void (**)())realloc(a, maxEntries * sizeof(void*));       \
00358     }                                                                  \
00359     a[lastEntry++] = p;                                                \
00360   }                                                                    \
00361   else if (a != 0)                                                     \
00362   {                                                                    \
00363     for (int i = lastEntry - 1; i >= 0; i--)                           \
00364       a[i] ();                                                         \
00365     free (a);                                                          \
00366     a = 0;                                                             \
00367     lastEntry = 0;                                                     \
00368     maxEntries = 0;                                                    \
00369   }                                                                    \
00370 }
00371 #endif
00372 
00373 #ifndef CS_DEFINE_STATIC_VARIABLE_REGISTRATION
00374 #  define CS_DEFINE_STATIC_VARIABLE_REGISTRATION(func) \
00375     csStaticVarCleanupFN csStaticVarCleanup = &func
00376 #endif
00377 
00378 #ifndef CS_DECLARE_STATIC_VARIABLE_REGISTRATION
00379 #  define CS_DECLARE_STATIC_VARIABLE_REGISTRATION(func) \
00380     void func (void (*p)())
00381 #endif
00382 
00383 #ifndef CS_DECLARE_DEFAULT_STATIC_VARIABLE_REGISTRATION
00384 #  define CS_DECLARE_DEFAULT_STATIC_VARIABLE_REGISTRATION               \
00385     CS_CRYSTALSPACE_EXPORT                                              \
00386     CS_DECLARE_STATIC_VARIABLE_REGISTRATION (csStaticVarCleanup_csutil);
00387 #endif
00388 
00389 /* scfStaticallyLinked - Flag indicating whether external linkage was used when 
00390  * building the application. Determines whether SCF scans for plugins at 
00391  * startup.
00392  */
00396 #if defined(CS_BUILD_SHARED_LIBS)
00397 #  define CS_DEFINE_STATICALLY_LINKED_FLAG
00398 #elif defined(CS_STATIC_LINKED)
00399 #  define CS_DEFINE_STATICALLY_LINKED_FLAG  bool scfStaticallyLinked = true;
00400 #else
00401 #  define CS_DEFINE_STATICALLY_LINKED_FLAG  bool scfStaticallyLinked = false;
00402 #endif
00403 
00404 
00424 #ifndef CS_IMPLEMENT_FOREIGN_DLL
00425 #  if defined(CS_BUILD_SHARED_LIBS)
00426 #    define CS_IMPLEMENT_FOREIGN_DLL                                        \
00427        CS_IMPLEMENT_STATIC_VARIABLE_REGISTRATION(csStaticVarCleanup_local); \
00428        CS_DEFINE_STATICALLY_LINKED_FLAG                                     \
00429        CS_DEFINE_STATIC_VARIABLE_REGISTRATION (csStaticVarCleanup_local);
00430 #  else
00431 #    define CS_IMPLEMENT_FOREIGN_DLL                                        \
00432        CS_DECLARE_DEFAULT_STATIC_VARIABLE_REGISTRATION                      \
00433        CS_DEFINE_STATICALLY_LINKED_FLAG                                     \
00434        CS_DEFINE_STATIC_VARIABLE_REGISTRATION (csStaticVarCleanup_csutil);
00435 #  endif
00436 #endif
00437 
00446 #if defined(CS_STATIC_LINKED)
00447 
00448 #  ifndef CS_IMPLEMENT_PLUGIN
00449 #  define CS_IMPLEMENT_PLUGIN                                           \
00450           CS_IMPLEMENT_PLATFORM_PLUGIN 
00451 #  endif
00452 
00453 #elif !defined(CS_BUILD_SHARED_LIBS)
00454 
00455 #  ifndef CS_IMPLEMENT_PLUGIN
00456 #  define CS_IMPLEMENT_PLUGIN                                           \
00457           CS_IMPLEMENT_PLATFORM_PLUGIN                                  \
00458           CS_DEFINE_STATICALLY_LINKED_FLAG                              \
00459           CS_DECLARE_DEFAULT_STATIC_VARIABLE_REGISTRATION               \
00460           CS_DEFINE_STATIC_VARIABLE_REGISTRATION (csStaticVarCleanup_csutil);
00461 #  endif
00462 
00463 #else
00464 
00465 #  ifndef CS_IMPLEMENT_PLUGIN
00466 #  define CS_IMPLEMENT_PLUGIN                                           \
00467    CS_DEFINE_STATICALLY_LINKED_FLAG                                     \
00468    CS_IMPLEMENT_STATIC_VARIABLE_REGISTRATION(csStaticVarCleanup_local)  \
00469    CS_DEFINE_STATIC_VARIABLE_REGISTRATION (csStaticVarCleanup_local);   \
00470    CS_IMPLEMENT_PLATFORM_PLUGIN 
00471 #  endif
00472 
00473 #endif
00474 
00483 #ifndef CS_IMPLEMENT_APPLICATION
00484 #  define CS_IMPLEMENT_APPLICATION                                      \
00485   CS_DECLARE_DEFAULT_STATIC_VARIABLE_REGISTRATION                       \
00486   CS_DEFINE_STATICALLY_LINKED_FLAG                                      \
00487   CS_DEFINE_STATIC_VARIABLE_REGISTRATION (csStaticVarCleanup_csutil);   \
00488   CS_IMPLEMENT_PLATFORM_APPLICATION 
00489 #endif
00490 
00494 #ifndef CS_REGISTER_STATIC_FOR_DESTRUCTION
00495 #define CS_REGISTER_STATIC_FOR_DESTRUCTION(getterFunc)\
00496         csStaticVarCleanup (getterFunc);
00497 #endif
00498 
00502 #ifndef CS_STATIC_VARIABLE_CLEANUP
00503 #define CS_STATIC_VARIABLE_CLEANUP  \
00504         csStaticVarCleanup (0);
00505 #endif
00506 
00519 #ifndef CS_IMPLEMENT_STATIC_VAR_EXT
00520 #define CS_IMPLEMENT_STATIC_VAR_EXT(getterFunc,Type,initParam,kill_how) \
00521 namespace {                                                            \
00522 static Type *getterFunc ## _v=0;                                        \
00523 static Type* getterFunc ();                                             \
00524 static void getterFunc ## _kill ();                                     \
00525 static void getterFunc ## _kill_array ();                               \
00526 void getterFunc ## _kill ()                                             \
00527 {                                                                       \
00528   (void)(&getterFunc ## _kill_array);                                   \
00529   delete getterFunc ## _v;                                              \
00530   getterFunc ## _v = 0;                                                 \
00531 }                                                                       \
00532 void getterFunc ## _kill_array ()                                       \
00533 {                                                                       \
00534   (void)(&getterFunc ## _kill);                                         \
00535   delete [] getterFunc ## _v;                                           \
00536   getterFunc ## _v = 0;                                                 \
00537 }                                                                       \
00538 Type* getterFunc ()                                                     \
00539 {                                                                       \
00540   if (!getterFunc ## _v)                                                \
00541   {                                                                     \
00542     getterFunc ## _v = new Type initParam;                              \
00543     csStaticVarCleanup (getterFunc ## kill_how);                        \
00544   }                                                                     \
00545   return getterFunc ## _v;                                              \
00546 }                                                                       \
00547 }
00548 #endif
00549 
00550 #ifndef CS_IMPLEMENT_STATIC_VAR
00551 #define CS_IMPLEMENT_STATIC_VAR(getterFunc,Type,initParam) \
00552  CS_IMPLEMENT_STATIC_VAR_EXT(getterFunc,Type,initParam,_kill)    
00553 #endif
00554 
00555 #ifndef CS_IMPLEMENT_STATIC_VAR_ARRAY
00556 #define CS_IMPLEMENT_STATIC_VAR_ARRAY(getterFunc,Type,initParam) \
00557  CS_IMPLEMENT_STATIC_VAR_EXT(getterFunc,Type,initParam,_kill_array)    
00558 #endif
00559 
00567 #ifndef CS_DECLARE_STATIC_CLASSVAR
00568 #define CS_DECLARE_STATIC_CLASSVAR(var,getterFunc,Type)       \
00569 static Type *var;                                             \
00570 static Type *getterFunc ();                                   \
00571 static void getterFunc ## _kill ();                           \
00572 static void getterFunc ## _kill_array ();
00573 #endif
00574 
00575 #ifndef CS_DECLARE_STATIC_CLASSVAR_REF
00576 #define CS_DECLARE_STATIC_CLASSVAR_REF(var,getterFunc,Type)   \
00577 static Type *var;                                             \
00578 static Type &getterFunc ();                                   \
00579 static void getterFunc ## _kill ();                           \
00580 static void getterFunc ## _kill_array ();
00581 #endif
00582 
00593 #ifndef CS_IMPLEMENT_STATIC_CLASSVAR_EXT
00594 #define CS_IMPLEMENT_STATIC_CLASSVAR_EXT(Class,var,getterFunc,Type,initParam,\
00595   kill_how)                                                     \
00596 Type *Class::var = 0;                                           \
00597 void Class::getterFunc ## _kill ()                              \
00598 {                                                               \
00599   delete getterFunc ();                                         \
00600   var = 0;                                                      \
00601 }                                                               \
00602 void Class::getterFunc ## _kill_array ()                        \
00603 {                                                               \
00604   delete [] getterFunc ();                                      \
00605   var = 0;                                                      \
00606 }                                                               \
00607 Type* Class::getterFunc ()                                      \
00608 {                                                               \
00609   if (!var)                                                     \
00610   {                                                             \
00611     var = new Type initParam;                                   \
00612     csStaticVarCleanup (getterFunc ## kill_how);                \
00613   }                                                             \
00614   return var;                                                   \
00615 }
00616 #endif
00617 
00618 #ifndef CS_IMPLEMENT_STATIC_CLASSVAR
00619 #define CS_IMPLEMENT_STATIC_CLASSVAR(Class,var,getterFunc,Type,initParam) \
00620   CS_IMPLEMENT_STATIC_CLASSVAR_EXT(Class,var,getterFunc,Type,initParam,_kill)
00621 #endif
00622 
00623 #ifndef CS_IMPLEMENT_STATIC_CLASSVAR_ARRAY
00624 #define CS_IMPLEMENT_STATIC_CLASSVAR_ARRAY(Class,var,getterFunc,Type,\
00625   initParam) \
00626   CS_IMPLEMENT_STATIC_CLASSVAR_EXT(Class,var,getterFunc,Type,initParam,\
00627     _kill_array)
00628 #endif
00629 
00630 #ifndef CS_IMPLEMENT_STATIC_CLASSVAR_REF_EXT
00631 #define CS_IMPLEMENT_STATIC_CLASSVAR_REF_EXT(Class,var,getterFunc,Type,\
00632   initParam,kill_how) \
00633 Type *Class::var = 0;                                          \
00634 void Class::getterFunc ## _kill ()                             \
00635 {                                                              \
00636   delete &getterFunc ();                                       \
00637   var = 0;                                                     \
00638 }                                                              \
00639   void Class::getterFunc ## _kill_array ()                     \
00640 {                                                              \
00641   delete [] &getterFunc ();                                    \
00642   var = 0;                                                     \
00643 }                                                              \
00644 Type &Class::getterFunc ()                                     \
00645 {                                                              \
00646   if (!var)                                                    \
00647   {                                                            \
00648     var = new Type initParam;                                  \
00649     csStaticVarCleanup (getterFunc ## kill_how);               \
00650   }                                                            \
00651   return *var;                                                 \
00652 }
00653 #endif
00654 
00655 #ifndef CS_IMPLEMENT_STATIC_CLASSVAR_REF
00656 #define CS_IMPLEMENT_STATIC_CLASSVAR_REF(Class,var,getterFunc,Type,initParam)\
00657   CS_IMPLEMENT_STATIC_CLASSVAR_REF_EXT(Class,var,getterFunc,Type,\
00658     initParam,_kill)
00659 #endif
00660 
00661 #ifndef CS_IMPLEMENT_STATIC_CLASSVAR_REF_ARRAY
00662 #define CS_IMPLEMENT_STATIC_CLASSVAR_REF_ARRAY(Class,var,getterFunc,Type,\
00663   initParam) \
00664   CS_IMPLEMENT_STATIC_CLASSVAR_REF_EXT(Class,var,getterFunc,Type,initParam,\
00665     _kill_array)
00666 #endif
00667 
00672 #if defined(CS_COMPILER_GCC)
00673 #  define CS_FUNCTION_NAME              __PRETTY_FUNCTION__
00674 #elif defined(__FUNCTION__)
00675 #  define CS_FUNCTION_NAME              __FUNCTION__
00676 #else
00677 #  define CS_FUNCTION_NAME              "<?\?\?>"
00678 #endif
00679 
00680 #include <stdlib.h>
00681 #ifdef CS_HAVE_MALLOC_H
00682 #include <malloc.h>
00683 #endif
00684 #include <new>
00685 
00692 CS_DEPRECATED_METHOD_MSG("malloc override was removed; "
00693   "platform_malloc() unnecessary, use normal malloc() instead")
00694 CS_FORCEINLINE CS_ATTRIBUTE_MALLOC void* platform_malloc (size_t n)
00695 { return malloc (n); }
00696 CS_DEPRECATED_METHOD_MSG("malloc override was removed; "
00697   "platform_free() unnecessary, use normal free() instead")
00698 CS_FORCEINLINE void platform_free (void* p)
00699 { return free (p); }
00700 CS_DEPRECATED_METHOD_MSG("malloc override was removed; "
00701   "platform_realloc() unnecessary, use normal realloc() instead")
00702 CS_FORCEINLINE void* platform_realloc (void* p, size_t n)
00703 { return realloc (p, n); }
00704 CS_DEPRECATED_METHOD_MSG("malloc override was removed; "
00705   "platform_calloc() unnecessary, use normal calloc() instead")
00706 CS_FORCEINLINE CS_ATTRIBUTE_MALLOC void* platform_calloc (size_t n, size_t s)
00707 { return calloc (n, s); }
00708 
00709 namespace CS
00710 {
00711   struct AllocPlatform {};
00712   extern CS_CRYSTALSPACE_EXPORT const AllocPlatform allocPlatform;
00713 }
00718 CS_DEPRECATED_METHOD_MSG("operator new override was removed; "
00719   "using 'platform new' should be unnecessary")
00720 extern CS_CRYSTALSPACE_EXPORT void* operator new (size_t s, 
00721   const CS::AllocPlatform&) throw();
00726 CS_DEPRECATED_METHOD_MSG("operator new override was removed; "
00727   "using 'platform new' should be unnecessary")
00728 extern CS_CRYSTALSPACE_EXPORT void* operator new[] (size_t s, 
00729   const CS::AllocPlatform&) throw();
00730 CS_DEPRECATED_METHOD_MSG("operator new override was removed; "
00731   "using 'platform delete' should be unnecessary")
00732 extern CS_CRYSTALSPACE_EXPORT void operator delete (void* p, 
00733   const CS::AllocPlatform&) throw();
00734 CS_DEPRECATED_METHOD_MSG("operator new override was removed; "
00735   "using 'platform delete' should be unnecessary")
00736 extern CS_CRYSTALSPACE_EXPORT void operator delete[] (void* p, 
00737   const CS::AllocPlatform&) throw();
00739 
00740 #ifndef CS_NO_PTMALLOC
00741 
00742 
00746 extern CS_CRYSTALSPACE_EXPORT CS_ATTRIBUTE_MALLOC void* ptmalloc (size_t n);
00747 extern CS_CRYSTALSPACE_EXPORT void ptfree (void* p);
00748 extern CS_CRYSTALSPACE_EXPORT void* ptrealloc (void* p, size_t n);
00749 extern CS_CRYSTALSPACE_EXPORT CS_ATTRIBUTE_MALLOC void* ptcalloc (size_t n,
00750   size_t s);
00752 
00758 CS_FORCEINLINE CS_ATTRIBUTE_MALLOC void* cs_malloc (size_t n)
00759 { return ptmalloc (n); }
00760 CS_FORCEINLINE void cs_free (void* p)
00761 { ptfree (p); }
00762 CS_FORCEINLINE void* cs_realloc (void* p, size_t n)
00763 { return ptrealloc (p, n); }
00764 CS_FORCEINLINE CS_ATTRIBUTE_MALLOC void* cs_calloc (size_t n, size_t s)
00765 { return ptcalloc (n, s); }
00767 
00768 #else // CS_NO_PTMALLOC
00769 CS_FORCEINLINE CS_ATTRIBUTE_MALLOC void* cs_malloc (size_t n)
00770 { return malloc (n); }
00771 CS_FORCEINLINE void cs_free (void* p)
00772 { free (p); }
00773 CS_FORCEINLINE void* cs_realloc (void* p, size_t n)
00774 { return realloc (p, n); }
00775 CS_FORCEINLINE CS_ATTRIBUTE_MALLOC void* cs_calloc (size_t n, size_t s)
00776 { return calloc (n, s); }
00777 #endif // CS_NO_PTMALLOC
00778 
00779 
00780 #ifdef CS_USE_CUSTOM_ISDIR
00781 static inline bool isdir (const char *path, struct dirent *de)
00782 {
00783   int pathlen = strlen (path);
00784   char* fullname = new char[pathlen + 2 + strlen (de->d_name)];
00785   memcpy (fullname, path, pathlen + 1);
00786   if ((pathlen) && (fullname[pathlen-1] != CS_PATH_SEPARATOR))
00787   {
00788     fullname[pathlen++] = CS_PATH_SEPARATOR;
00789     fullname[pathlen] = 0;
00790   }
00791   strcat (&fullname [pathlen], de->d_name);
00792   struct stat st;
00793   stat (fullname, &st);
00794   delete[] fullname;
00795   return ((st.st_mode & S_IFMT) == S_IFDIR);
00796 }
00797 #endif
00798 
00799 
00800 // The following define should only be enabled if you have defined
00801 // a special version of overloaded new that accepts two additional
00802 // parameters: a (void*) pointing to the filename and an int with the
00803 // line number. This is typically used for memory debugging.
00804 // In csutil/memdebug.cpp there is a memory debugger which can (optionally)
00805 // use this feature. Note that if CS_EXTENSIVE_MEMDEBUG is enabled while
00806 // the memory debugger is not the memory debugger will still provide the
00807 // needed overloaded operators so you can leave CS_EXTENSIVE_MEMDEBUG on in
00808 // that case and the only overhead will be a little more arguments to 'new'.
00809 // Do not enable CS_EXTENSIVE_MEMDEBUG if your platform or your own code
00810 // defines its own 'new' operator, since this version will interfere with your
00811 // own.
00812 // CS_MEMORY_TRACKER is treated like CS_EXTENSIVE_MEMDEBUG here.
00813 // Same for CS_REF_TRACKER.
00814 #ifndef CS_DEBUG
00815 #  undef CS_EXTENSIVE_MEMDEBUG
00816 #  undef CS_REF_TRACKER
00817 #else
00818 #  if defined(CS_EXTENSIVE_MEMDEBUG) && defined(CS_MEMORY_TRACKER)
00819 #    error Do not use CS_EXTENSIVE_MEMDEBUG and CS_MEMORY_TRACKER together!
00820 #  endif
00821 #endif
00822 #if defined(CS_EXTENSIVE_MEMDEBUG) || defined(CS_MEMORY_TRACKER)
00823 extern void* CS_CRYSTALSPACE_EXPORT operator new (size_t s, 
00824   void* filename, int line);
00825 inline void operator delete (void* p, void*, int) { operator delete (p); }
00826 extern void* CS_CRYSTALSPACE_EXPORT operator new[] (size_t s, 
00827   void* filename, int line);
00828 inline void operator delete[] (void* p, void*, int) { operator delete[] (p); }
00829 
00830 inline void* operator new (size_t s)
00831 { return operator new (s, (void*)__FILE__, 0); }
00832 inline void* operator new[] (size_t s)
00833 { return operator new (s, (void*)__FILE__, 0); }
00834 
00835 #define CS_EXTENSIVE_MEMDEBUG_NEW new ((void*)CS_FUNCTION_NAME, __LINE__)
00836 #define new CS_EXTENSIVE_MEMDEBUG_NEW
00837 #endif
00838 
00839 namespace CS
00840 {
00841   namespace Debug
00842   {
00843     extern void CS_CRYSTALSPACE_EXPORT AssertMessage (const char* expr, 
00844       const char* filename, int line, const char* msg = 0);
00845   } // namespace Debug
00846 } // namespace CS
00847 
00848 #ifdef CS_DEBUG
00849 #  if !defined (CS_DEBUG_BREAK)
00850 #    if defined (CS_PLATFORM_WIN32)
00851 #      define CS_DEBUG_BREAK ::DebugBreak()
00852 #    elif defined (CS_PROCESSOR_X86)
00853 #      if defined (CS_COMPILER_GCC)
00854 #        define CS_DEBUG_BREAK asm ("int $3")
00855 #      else
00856 #        define CS_DEBUG_BREAK _asm int 3
00857 #      endif
00858 #    else
00859 #      define CS_DEBUG_BREAK { static int x = 0; x /= x; }
00860 #    endif
00861 #  endif
00862 #  if !defined (CS_ASSERT_MSG)
00863 #   define CS_ASSERT_MSG(msg,x)                                         \
00864       if (!(x)) CS::Debug::AssertMessage (#x, __FILE__, __LINE__, msg);
00865 #  endif
00866 #  if !defined (CS_ASSERT)
00867 #    define CS_ASSERT(x)        CS_ASSERT_MSG(0, x)
00868 #  endif
00869 #else
00870 #  undef  CS_DEBUG_BREAK
00871 #  define CS_DEBUG_BREAK
00872 #  undef  CS_ASSERT
00873 #  define CS_ASSERT(x)          (void)0
00874 #  undef  CS_ASSERT_MSG
00875 #  define CS_ASSERT_MSG(m,x)    (void)0
00876 #endif
00877 
00904 #if !defined(CS_CONST_METHOD) || defined(DOXYGEN_RUN)
00905 #define CS_CONST_METHOD
00906 #endif
00907 
00920 #if !defined(CS_PURE_METHOD) || defined(DOXYGEN_RUN)
00921 #define CS_PURE_METHOD
00922 #endif
00923 
00924 // Check if the csosdefs.h defined either CS_LITTLE_ENDIAN or CS_BIG_ENDIAN
00925 #if !defined (CS_LITTLE_ENDIAN) && !defined (CS_BIG_ENDIAN)
00926 #  error No CS_XXX_ENDIAN macro defined in your OS-specific csosdefs.h!
00927 #endif
00928 
00929 /*
00930  * This is a bit of overkill but if you're sure your CPU doesn't require
00931  * strict alignment add your CPU to the !defined below to get slightly
00932  * smaller and faster code in some cases.
00933  *
00934  * \todo In the future, this should be moved to csconfig.h and determined as
00935  * part of the configuration process.
00936  */
00937 #if defined (CS_PROCESSOR_SPARC)
00938 #  define CS_STRICT_ALIGNMENT
00939 #endif
00940 
00941 // Adjust some definitions contained in csconfig.h
00942 #if !defined (CS_PROCESSOR_X86) || !defined (CS_HAVE_NASM)
00943 #  undef CS_HAVE_MMX
00944 #  undef CS_HAVE_NASM
00945 #endif
00946 
00947 // Use special knowledge of IEEE float format in some cases for CPU's that are
00948 // known to support it
00949 #if !defined (CS_IEEE_DOUBLE_FORMAT)
00950 #  if defined (CS_PROCESSOR_X86) || \
00951       defined (CS_PROCESSOR_POWERPC) || \
00952       defined (CS_PROCESSOR_MIPS) || \
00953       defined (CS_PROCESSOR_SPARC) || \
00954       defined (CS_PROCESSOR_ALPHA) || \
00955       defined (CS_PROCESSOR_M68K)
00956 #    define CS_IEEE_DOUBLE_FORMAT
00957 #  endif
00958 #endif
00959 
00960 // gcc can perform usefull checking for printf/scanf format strings, just add
00961 // this define at the end of the function declaration
00962 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
00963 #  define CS_GNUC_PRINTF(format_idx, arg_idx) \
00964      __attribute__((format (__printf__, format_idx, arg_idx)))
00965 #  define CS_GNUC_SCANF(format_idx, arg_idx) \
00966      __attribute__((format (__scanf__, format_idx, arg_idx)))
00967 // Unfortunately, gcc doesn't support format argument checking for wide strings
00968 #  define CS_GNUC_WPRINTF(format_idx, arg_idx) \
00969      /*__attribute__((format (__wprintf__, format_idx, arg_idx)))*/
00970 #  define CS_GNUC_WSCANF(format_idx, arg_idx) \
00971      /*__attribute__((format (__wscanf__, format_idx, arg_idx)))*/
00972 #else
00973 #  define CS_GNUC_PRINTF(format_idx, arg_idx)
00974 #  define CS_GNUC_SCANF(format_idx, arg_idx)
00975 #  define CS_GNUC_WPRINTF(format_idx, arg_idx)
00976 #  define CS_GNUC_WSCANF(format_idx, arg_idx)
00977 #endif
00978 
00979 // Remove __attribute__ on non GNUC compilers.
00980 #ifndef __GNUC__
00981 #define __attribute__(x)
00982 #endif
00983 
00984 // Support for alignment and packing of structures.
00985 #if !defined(CS_STRUCT_ALIGN_4BYTE_BEGIN)
00986 #  if defined(__GNUC__) && defined(CS_STRICT_ALIGNMENT)
00987 #    define CS_STRUCT_ALIGN_4BYTE_BEGIN
00988 #    define CS_STRUCT_ALIGN_4BYTE_END __attribute__ ((aligned(4)))
00989 #  else
00990 #    define CS_STRUCT_ALIGN_4BYTE_BEGIN
00991 #    define CS_STRUCT_ALIGN_4BYTE_END
00992 #  endif
00993 #endif
00994 
00995 #if defined(CS_COMPILER_MSVC)
00996   #define CS_ALIGNED_MEMBER(Member, Align)                              \
00997     __declspec(align(Align)) Member
00998 #elif defined(CS_COMPILER_GCC)
00999 
01011   #define CS_ALIGNED_MEMBER(Member, Align)                              \
01012     Member __attribute((aligned(Align)))
01013 #else
01014   #define CS_ALIGNED_MEMBER(Member, Align)      Member
01015 #endif
01016 
01017 // Macro used to define static implicit pointer conversion function.
01018 // Only use within a class declaration.
01019 #ifndef _CS_IMPLICITPTRCAST_NAME
01020 #  define _CS_IMPLICITPTRCAST_NAME __ImplicitPtrCast
01021 #endif
01022 
01044 #define CS_IMPLEMENT_IMPLICIT_PTR_CAST(classname) \
01045   inline static classname* _CS_IMPLICITPTRCAST_NAME (classname* ptr) \
01046   { \
01047     return ptr;\
01048   }
01049 
01058 #define CS_IMPLICIT_PTR_CAST(classname, ptr) \
01059   (classname::_CS_IMPLICITPTRCAST_NAME(ptr))
01060 
01064 #ifdef CS_HAVE_VA_COPY
01065 #  define CS_VA_COPY(dest, src)         va_copy(dest, src)
01066 #else
01067 #  ifdef CS_HAVE___VA_COPY
01068 #    define CS_VA_COPY(dest, src)       __va_copy(dest, src)
01069 #  else
01070 #    define CS_VA_COPY(dest, src)       dest = src;
01071 #  endif
01072 #endif
01073 
01074 #define CS_STRING_TO_WIDE_(x)   L ## x
01075 
01082 #define CS_STRING_TO_WIDE(x)    CS_STRING_TO_WIDE_(x)
01083 
01084 #ifdef PACKAGE_NAME
01085 # define CS_NAMESPACE_PACKAGE_NAME       PACKAGE_NAME
01086 #else
01087 # define CS_NAMESPACE_PACKAGE_NAME       CS
01088 #endif
01089 
01113 #define CS_PLUGIN_NAMESPACE_BEGIN(name)                                     \
01114   namespace CS_NAMESPACE_PACKAGE_NAME { namespace Plugin { namespace name
01115 #define CS_PLUGIN_NAMESPACE_END(name)                                       \
01116   } }
01117 #define CS_PLUGIN_NAMESPACE_NAME(name)                                      \
01118   CS_NAMESPACE_PACKAGE_NAME::Plugin::name
01119 
01121 #endif // __CS_CSSYSDEF_H__

Generated for Crystal Space 1.2.1 by doxygen 1.5.3