UCommon
|
00001 // Copyright (C) 2006-2014 David Sugar, Tycho Softworks. 00002 // Copyright (C) 2015 Cherokees of Idaho. 00003 // 00004 // This file is part of GNU uCommon C++. 00005 // 00006 // GNU uCommon C++ is free software: you can redistribute it and/or modify 00007 // it under the terms of the GNU Lesser General Public License as published 00008 // by the Free Software Foundation, either version 3 of the License, or 00009 // (at your option) any later version. 00010 // 00011 // GNU uCommon C++ is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU Lesser General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU Lesser General Public License 00017 // along with GNU uCommon C++. If not, see <http://www.gnu.org/licenses/>. 00018 00026 #ifndef _UCOMMON_CONFIG_H_ 00027 #include <ucommon/platform.h> 00028 #endif 00029 00030 #ifndef _UCOMMON_CPR_H_ 00031 #define _UCOMMON_CPR_H_ 00032 00033 #ifdef _MSWINDOWS_ 00034 00035 extern "C" { 00036 __EXPORT int cpr_setenv(const char *s, const char *v, int p); 00037 00038 inline int setenv(const char *s, const char *v, int overwrite) 00039 {return cpr_setenv(s, v, overwrite);} 00040 } 00041 00042 #endif 00043 00044 00051 __EXPORT void cpr_runtime_error(const char *text); 00052 00053 extern "C" __EXPORT void *cpr_newp(void **handle, size_t size); 00054 00055 extern "C" __EXPORT void cpr_freep(void **handle); 00056 00063 extern "C" __EXPORT void *cpr_memalloc(size_t size) __MALLOC; 00064 00074 extern "C" __EXPORT void *cpr_memassign(size_t size, caddr_t address, size_t known) __MALLOC; 00075 00082 extern "C" __EXPORT void cpr_memswap(void *mem1, void *mem2, size_t size); 00083 00084 #ifdef UCOMMON_SYSRUNTIME 00085 00090 __EXPORT void *operator new(size_t size); 00091 00097 __EXPORT void *operator new[](size_t size); 00098 #endif 00099 00100 #ifdef UCOMMON_SYSRUNTIME 00101 00109 __EXPORT void *operator new[](size_t size, void *address); 00110 00120 __EXPORT void *operator new[](size_t size, void *address, size_t known); 00121 #endif 00122 00123 #ifdef UCOMMON_SYSRUNTIME 00124 00128 #if __cplusplus <= 199711L 00129 __EXPORT void operator delete(void *object); 00130 #else 00131 __EXPORT void operator delete(void *object) noexcept (true); 00132 #endif 00133 00138 #if __cplusplus <= 199711L 00139 __EXPORT void operator delete[](void *array); 00140 #else 00141 __EXPORT void operator delete[](void *array) noexcept(true); 00142 #endif 00143 00144 #ifdef __GNUC__ 00145 extern "C" __EXPORT void __cxa_pure_virtual(void); 00146 #endif 00147 #endif 00148 00149 extern "C" { 00150 __EXPORT uint16_t lsb_getshort(uint8_t *b); 00151 __EXPORT uint32_t lsb_getlong(uint8_t *b); 00152 __EXPORT uint16_t msb_getshort(uint8_t *b); 00153 __EXPORT uint32_t msb_getlong(uint8_t *b); 00154 00155 __EXPORT void lsb_setshort(uint8_t *b, uint16_t v); 00156 __EXPORT void lsb_setlong(uint8_t *b, uint32_t v); 00157 __EXPORT void msb_setshort(uint8_t *b, uint16_t v); 00158 __EXPORT void msb_setlong(uint8_t *b, uint32_t v); 00159 } 00160 00161 template <typename T> 00162 T *newp(T **handle) { 00163 return (T*)cpr_newp(handle, sizeof(T)); 00164 } 00165 00166 template <typename T> 00167 void freep(T **handle) { 00168 cpr_freep(handle); 00169 } 00170 00171 #endif