ucommon/cpr.h

Go to the documentation of this file.
00001 // Copyright (C) 2006-2010 David Sugar, Tycho Softworks.
00002 //
00003 // This file is part of GNU uCommon C++.
00004 //
00005 // GNU uCommon C++ is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU Lesser General Public License as published
00007 // by the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // GNU uCommon C++ 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
00013 // GNU Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public License
00016 // along with GNU uCommon C++.  If not, see <http://www.gnu.org/licenses/>.
00017 
00025 #ifndef _UCOMMON_CONFIG_H_
00026 #include <ucommon/platform.h>
00027 #endif
00028 
00029 #ifndef _UCOMMON_CPR_H_
00030 #define _UCOMMON_CPR_H_
00031 
00032 #ifdef  _MSWINDOWS_
00033 
00034 extern "C" {
00035     __EXPORT int cpr_setenv(const char *s, const char *v, int p);
00036 
00037     inline int setenv(const char *s, const char *v, int overwrite)
00038         {return cpr_setenv(s, v, overwrite);}
00039 }
00040 
00041 #endif
00042 
00043 
00050 __EXPORT void cpr_runtime_error(const char *text);
00051 
00058 extern "C" __EXPORT void *cpr_memalloc(size_t size) __MALLOC;
00059 
00069 extern "C" __EXPORT void *cpr_memassign(size_t size, caddr_t address, size_t known) __MALLOC;
00070 
00077 extern "C" __EXPORT void cpr_memswap(void *mem1, void *mem2, size_t size);
00078 
00079 #ifndef _UCOMMON_EXTENDED_
00080 
00085 inline void *operator new(size_t size)
00086     {return cpr_memalloc(size);}
00087 
00093 inline void *operator new[](size_t size)
00094     {return cpr_memalloc(size);}
00095 #endif
00096 
00097 #ifndef _UCOMMON_EXTENDED_
00098 
00106 inline void *operator new[](size_t size, caddr_t address)
00107     {return cpr_memassign(size, address, size);}
00108 
00118 inline void *operator new[](size_t size, caddr_t address, size_t known)
00119     {return cpr_memassign(size, address, known);}
00120 #endif
00121 
00131 inline void *operator new(size_t size, size_t extra)
00132     {return cpr_memalloc(size + extra);}
00133 
00142 inline void *operator new(size_t size, caddr_t address)
00143     {return cpr_memassign(size, address, size);}
00144 
00155 inline void *operator new(size_t size, caddr_t address, size_t known)
00156     {return cpr_memassign(size, address, known);}
00157 
00158 #ifndef _UCOMMON_EXTENDED_
00159 
00163 inline void operator delete(void *object)
00164     {free(object);}
00165 
00170 inline void operator delete[](void *array)
00171     {free(array);}
00172 
00173 #ifdef  __GNUC__
00174 extern "C" __EXPORT void __cxa_pure_virtual(void);
00175 #endif
00176 #endif
00177 
00178 extern "C" {
00179     __EXPORT uint16_t lsb_getshort(uint8_t *b);
00180     __EXPORT uint32_t lsb_getlong(uint8_t *b);
00181     __EXPORT uint16_t msb_getshort(uint8_t *b);
00182     __EXPORT uint32_t msb_getlong(uint8_t *b);
00183 
00184     __EXPORT void lsb_setshort(uint8_t *b, uint16_t v);
00185     __EXPORT void lsb_setlong(uint8_t *b, uint32_t v);
00186     __EXPORT void msb_setshort(uint8_t *b, uint16_t v);
00187     __EXPORT void msb_setlong(uint8_t *b, uint32_t v);
00188 }
00189 
00190 #endif

Generated on 14 Aug 2013 for UCommon by  doxygen 1.4.7