29 _controlfp_s(&old_val,p_val,mask);
34 _controlfp_s(&dummy,old_val,mask);
59 sse_control(
unsigned p_mask,
unsigned p_val) : m_mask(p_mask) {
60 __control87_2(p_val,p_mask,NULL,&m_oldval);
63 __control87_2(m_oldval,m_mask,NULL,&m_oldval);
80 template<
typename T>
static void release(
T* p_ptr) {
delete p_ptr;}
84 template<
typename T>
static void release(
T* p_ptr) {
delete[] p_ptr;}
88 static void release(
void * p_ptr) {free(p_ptr);}
92 template<
typename T,
typename t_releaser = releaser_delete >
100 inline bool is_valid()
const {
return m_ptr != NULL;}
101 inline bool is_empty()
const {
return m_ptr == NULL;}
105 inline void attach(
T * p_ptr) {release(); m_ptr = p_ptr;}
106 inline const t_self &
operator=(
T * p_ptr) {
set(p_ptr);
return *
this;}
114 inline void set(
T * p_ptr) {attach(p_ptr);}
116 ptrholder_t(
const t_self &) {
throw pfc::exception_not_implemented();}
117 const t_self &
operator=(
const t_self & ) {
throw pfc::exception_not_implemented();}
123 template<
typename t_releaser>
132 inline bool is_valid()
const {
return m_ptr != NULL;}
133 inline bool is_empty()
const {
return m_ptr == NULL;}
137 inline void attach(T * p_ptr) {release(); m_ptr = p_ptr;}
138 inline const t_self &
operator=(T * p_ptr) {
set(p_ptr);
return *
this;}
145 inline void set(T * p_ptr) {attach(p_ptr);}
147 ptrholder_t(
const t_self &) {
throw pfc::exception_not_implemented();}
148 const t_self &
operator=(
const t_self & ) {
throw pfc::exception_not_implemented();}
160 #define PFC_DEBUGLOG ::pfc::debugLog()._formatter() 163 template<
typename t_type,t_type p_initval>
173 template<
typename t_base>
178 TEMPLATE_CONSTRUCTOR_FORWARD_FLOOD_WITH_INITIALIZER(
instanceTracker,t_base,{g_list +=
this;});
180 instanceTracker(
const t_self & p_other) : t_base( (const t_base &)p_other) {g_list +=
this;}
185 template<
typename t_callback>
static void forEach(t_callback & p_callback) {instanceList().enumerate(p_callback);}
190 template<
typename t_base>
195 template<
typename TClass>
206 template<
typename t_callback>
static void forEach(t_callback & p_callback) {instanceList().enumerate(p_callback);}
211 template<
typename TClass>
239 m_next = m_obj->m_data;
240 m_obj->m_data =
this;
243 if (!m_flag) m_obj->m_data = m_next;
245 bool get()
const {
return m_flag;}
255 enum {slice = 1024*1024};
261 m_data.set_size( (newSize + slice - 1) / slice );
263 for(
size_t walk = 0; walk < m_data.get_size(); ++walk) {
264 size_t thisSlice = slice;
265 if (walk + 1 == m_data.get_size()) {
266 size_t cut = newSize % slice;
267 if (cut) thisSlice = cut;
269 void* ptr = malloc(thisSlice);
270 if (ptr == NULL) {clear();
throw std::bad_alloc();}
271 m_data[walk] = (uint8_t*)ptr;
275 size_t size()
const {
return m_size;}
277 for(
size_t walk = 0; walk < m_data.get_size(); ++walk) free(m_data[walk]);
281 void read(
void * ptrOut,
size_t bytes,
size_t offset) {
282 PFC_ASSERT( offset + bytes <= size() );
283 uint8_t * outWalk = (uint8_t*) ptrOut;
285 size_t o1 = offset / slice, o2 = offset % slice;
286 size_t delta = slice - o2;
if (delta > bytes) delta = bytes;
287 memcpy(outWalk, m_data[o1] + o2, delta);
293 void write(
const void * ptrIn,
size_t bytes,
size_t offset) {
294 PFC_ASSERT( offset + bytes <= size() );
295 const uint8_t * inWalk = (
const uint8_t*) ptrIn;
297 size_t o1 = offset / slice, o2 = offset % slice;
298 size_t delta = slice - o2;
if (delta > bytes) delta = bytes;
299 memcpy(m_data[o1] + o2, inWalk, delta);
305 uint8_t *
_slicePtr(
size_t which) {
return m_data[which];}
308 if (which + 1 == _sliceCount()) {
309 size_t s = m_size % slice;
318 PFC_CLASS_NOT_COPYABLE_EX(
bigmem)
322 double exp_int(
double base,
int exp );
sse_control(unsigned p_mask, unsigned p_val)
void outputDebugLine(const char *msg)
array_t< uint8_t * > m_data
double exp_int(double base, int exp)
objDestructNotifyScope(objDestructNotify &obj)
t_self & operator>>(t_self &p_dest)
void write(const void *ptrIn, size_t bytes, size_t offset)
static const t_instanceList & instanceList()
static void release(T *p_ptr)
instanceTrackerV2(const t_self &p_other)
ptrholder_t(const t_self &)
t_type replace_null_t(t_type &p_var)
size_t _sliceSize(size_t which)
objDestructNotifyData * m_data
objDestructNotifyData * m_next
static void release(T *p_ptr)
uint8_t * _slicePtr(size_t which)
pfc::avltree_t< TClass * > t_instanceList
t_self & operator>>(t_self &p_dest)
instanceTracker< t_base > t_self
static void release(void *p_ptr)
~objDestructNotifyScope()
instanceTrackerV2< TClass > t_self
string8_fastalloc string_formatter
fpu_control_flushdenormal()
static t_instanceList g_list
fpu_control(unsigned p_mask, unsigned p_val)
void read(void *ptrOut, size_t bytes, size_t offset)
const t_self & operator=(const t_self &)
vartoggle_t< bool > booltoggle
sse_control_flushdenormal()
t_self & operator<<(t_self &p_source)
t_self & operator<<(t_self &p_source)
fpu_control_roundnearest()
const t_self & operator=(const t_self &)
Assumes t_freefunc to never throw exceptions.
void resize(size_t newSize)
pfc::avltree_t< t_self * > t_list
ptrholder_t(const t_self &)
vartoggle_t(T &p_var, const T &val)
const t_self & operator=(T *p_ptr)
static const t_list & instanceList()
ptrholder_t< T, t_releaser > t_self
ptrholder_t< T, t_releaser > t_self
static void forEach(t_callback &p_callback)
const t_self & operator=(T *p_ptr)
static void forEach(t_callback &p_callback)
instanceTracker(const t_self &p_other)