29 #ifndef _UCOMMON_MAPPED_H_
30 #define _UCOMMON_MAPPED_H_
32 #ifndef _UCOMMON_LINKED_H_
36 #ifndef _UCOMMON_THREAD_H_
40 #ifndef _UCOMMON_STRING_H_
78 void create(
const char *name,
size_t size = (
size_t)0);
84 virtual void fault(
void)
const;
119 static void remove(
const char *name);
125 inline operator bool()
const
126 {
return (size != 0);};
132 inline bool operator!()
const
133 {
return (size == 0);};
142 void *sbrk(
size_t size);
149 void *offset(
size_t offset)
const;
158 void copy(
size_t offset,
void *buffer,
size_t size)
const;
164 inline size_t len(
void)
171 inline caddr_t getStart(
void)
181 static void disable(
void);
203 inline void create(
const char *fname,
unsigned count)
204 {MappedMemory::create(fname, count * objsize);};
219 MappedReuse(
const char *name,
size_t size,
unsigned count);
276 inline void create(
const char *fn,
unsigned members)
277 {MappedMemory::create(fn, members *
sizeof(T));};
295 inline void initialize(
void)
296 {
new((caddr_t)offset(0)) T[size /
sizeof(T)];};
302 inline void *addLock(
void)
303 {
return sbrk(
sizeof(T));};
310 inline T *operator()(
unsigned member)
311 {
return static_cast<T*
>(offset(member *
sizeof(T)));}
317 inline T *operator()(
void)
318 {
return static_cast<T*
>(sbrk(
sizeof(T)));};
325 inline T& operator[](
unsigned member)
326 {
return *(operator()(member));};
332 inline unsigned getSize(
void)
333 {
return (
unsigned)(size /
sizeof(T));};
365 inline void initialize(
void)
366 {
new((caddr_t)pos(0)) T[size /
sizeof(T)];};
372 inline operator bool()
const
373 {
return MappedReuse::avail();};
379 inline bool operator!()
const
380 {
return !MappedReuse::avail();};
388 {
return mapped_reuse::get();};
395 inline T* operator*()
396 {
return mapped_reuse::get();};
403 inline T *pos(
size_t member)
404 {
return static_cast<T*
>(MappedReuse::offset(member *
sizeof(T)));};
412 {
return static_cast<T*
>(MappedReuse::get());};
422 {
return static_cast<T*
>(MappedReuse::getTimed(timeout));};
429 inline T *request(
void)
430 {
return static_cast<T*
>(MappedReuse::request());};
437 inline void removeLocked(T *
object)
438 {MappedReuse::removeLocked(
object);};
445 inline T *getLocked(
void)
446 {
return static_cast<T*
>(MappedReuse::getLocked());};
479 inline volatile const T *operator()(
unsigned member)
480 {
return static_cast<const T*
>(offset(member *
sizeof(T)));}
487 inline volatile const T &operator[](
unsigned member)
488 {
return *(operator()(member));};
490 inline volatile const T *
get(
unsigned member)
491 {
return static_cast<const T*
>(offset(member *
sizeof(T)));};
493 inline void copy(
unsigned member, T *buffer)
500 inline unsigned getCount(
void)
501 {
return (
unsigned)(size /
sizeof(T));};