/usr/include/falcon/spage.h is in falconpl-dev 0.9.6.9-git20120606-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | /*
FALCON - The Falcon Programming Language.
FILE: flc_itempage.h
Definition of the page that holds items.
-------------------------------------------------------------------
Author: Giancarlo Niccolai
Begin: lun ott 4 2004
-------------------------------------------------------------------
(C) Copyright 2004: the FALCON developers (see list in AUTHORS file)
See LICENSE file for licensing details.
*/
/** \file
Definition of a segregated allocation page.
A SAP is a memory page where all the allocated objects has the same size (and possibly are of the
same type).
The SAP is a template class that is instantiated by providint the size of the items at compile
time.
*/
#ifndef flc_flc_spage_H
#define flc_flc_spage_H
#include <falcon/heap.h>
#include <falcon/types.h>
#include <falcon/llist.h>
namespace Falcon {
/**
\note This is old code to be removed.
*/
class MemPage:public LinkableElement
{
protected:
uint16 m_lastFree;
public:
MemPage( MemPage *prev=0, MemPage *next=0 ):
LinkableElement( prev, next )
{}
void *operator new( size_t ) throw() { return HeapMem::getPage(); }
void *operator new( size_t, void *pos ) throw() { return pos; }
void operator delete( void *page ) { HeapMem::freePage( page ); }
};
class MemPageList: public LinkedList< MemPage > {};
/** Definition of a segregated allocation page.
A SAP is a memory page where all the allocated objects has the same size (and possibly are of the
same type).
The SAP is a template class that is instantiated by providint the size of the items at compile
time.
\note This is old code to be removed.
*/
template <class _T>
class SegregatedPage: public MemPage
{
public:
SegregatedPage( SegregatedPage<_T> *prev=0, SegregatedPage<_T> *next=0 ):
MemPage( prev, next )
{
m_lastFree = sizeof( SegregatedPage<_T> );
}
void *nextItem() {
if ( m_lastFree + sizeof(_T) > PAGE_SIZE )
return 0;
void *data= (void *)( ((char *) this) + m_lastFree );
m_lastFree += sizeof(_T);
return data;
}
void backItem() {
if ( m_lastFree > sizeof(SegregatedPage<_T>) )
m_lastFree -= sizeof( _T );
}
void resetPage() { m_lastFree = sizeof( SegregatedPage<_T> ); }
_T *currentItem()
{
if ( m_lastFree == sizeof( SegregatedPage<_T> ) )
return 0;
return ((_T *) (((char *) this)+m_lastFree)) -1;
}
_T *firstItem() {
return (_T *) ((char*)this + sizeof( SegregatedPage<_T> ) );
}
_T *lastItem() {
return ((_T *) ((char*)this + sizeof( SegregatedPage<_T> ))) +
( (PAGE_SIZE - sizeof( SegregatedPage<_T> )) / sizeof( _T) );
}
};
}
#endif
/* end of flc_spage.h */
|