\doxysection{workspace/post-\/scarcity/src/memory/conspage.h File Reference}
\hypertarget{conspage_8h}{}\label{conspage_8h}\index{workspace/post-\/scarcity/src/memory/conspage.h@{workspace/post-\/scarcity/src/memory/conspage.h}}
{\ttfamily \#include "{}memory/consspaceobject.\+h"{}}\newline
Include dependency graph for conspage.\+h\+:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{conspage_8h__incl}
\end{center}
\end{figure}
This graph shows which files directly or indirectly include this file\+:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{conspage_8h__dep__incl}
\end{center}
\end{figure}
\doxysubsubsection*{Data Structures}
\begin{DoxyCompactItemize}
\item 
struct \mbox{\hyperlink{conspage_8h_structcons__page}{cons\+\_\+page}}
\begin{DoxyCompactList}\small\item\em a cons page is essentially just an array of cons space objects.  \mbox{\hyperlink{conspage_8h_structcons__page}{More...}}\end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \mbox{\hyperlink{conspage_8h_a384a2520aa9fc6aa1dc6528b2795edab}{CONSPAGESIZE}}~1024
\begin{DoxyCompactList}\small\item\em the number of cons cells on a cons page. \end{DoxyCompactList}\item 
\#define \mbox{\hyperlink{conspage_8h_a2656b2b52cfab9ff1a7f8cf63e5d111f}{NCONSPAGES}}~64
\begin{DoxyCompactList}\small\item\em the number of cons pages we will initially allow for. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
struct \mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\+\_\+pointer}} \mbox{\hyperlink{conspage_8h_a04ba7c874b05e9789d0aca9ee6b106a7}{allocate\+\_\+cell}} (uint32\+\_\+t tag)
\begin{DoxyCompactList}\small\item\em Allocates a cell with the specified {\ttfamily tag}. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{conspage_8h_a8078785bb1865878f934d02b28e600d9}{dump\+\_\+pages}} (\mbox{\hyperlink{fopen_8h_a8c81a077422f5e2410ba71eb75108f6e}{URL\+\_\+\+FILE}} \texorpdfstring{$\ast$}{*}output)
\begin{DoxyCompactList}\small\item\em dump the allocated pages to this {\ttfamily output} stream. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{conspage_8h_a7cf88f8487cd8fef12fdd78a2aaa6216}{free\+\_\+cell}} (struct \mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\+\_\+pointer}} pointer)
\begin{DoxyCompactList}\small\item\em Frees the cell at the specified {\ttfamily pointer}; for all the types of cons-\/space object which point to other cons-\/space objects, cascade the decrement. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{conspage_8h_aeb73441904896a283f5b57298479bc4a}{initialise\+\_\+cons\+\_\+pages}} ()
\begin{DoxyCompactList}\small\item\em initialise the cons page system; to be called exactly once during startup. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{conspage_8h_ab8d9d6417f194dca8d8322301cf37c7c}{summarise\+\_\+allocation}} ()
\end{DoxyCompactItemize}
\doxysubsubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
struct \mbox{\hyperlink{conspage_8h_structcons__page}{cons\+\_\+page}} \texorpdfstring{$\ast$}{*} \mbox{\hyperlink{conspage_8h_a7cce1a2d3dd8b5abe5e30622d94e6959}{conspages}} \mbox{[}\mbox{\hyperlink{conspage_8h_a2656b2b52cfab9ff1a7f8cf63e5d111f}{NCONSPAGES}}\mbox{]}
\begin{DoxyCompactList}\small\item\em An array of pointers to cons pages. \end{DoxyCompactList}\item 
struct \mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\+\_\+pointer}} \mbox{\hyperlink{conspage_8h_ae0a20197a96d9f07dac864b925cd0f32}{freelist}}
\begin{DoxyCompactList}\small\item\em The (global) pointer to the (global) freelist. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Data Structure Documentation}
\index{cons\_page@{cons\_page}}\label{structcons__page}
\Hypertarget{conspage_8h_structcons__page}
\doxysubsubsection{struct cons\+\_\+page}
a cons page is essentially just an array of cons space objects. 

It might later have a local free list (i.\+e. list of free cells on this page) and a pointer to the next cons page, but my current view is that that\textquotesingle{}s probably unneccessary. 

Definition at line \mbox{\hyperlink{conspage_8h_source_l00048}{48}} of file \mbox{\hyperlink{conspage_8h_source}{conspage.\+h}}.



Collaboration diagram for cons\+\_\+page\+:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=181pt]{structcons__page__coll__graph}
\end{center}
\end{figure}
\begin{DoxyFields}{Data Fields}
\mbox{\Hypertarget{conspage_8h_aa1b41597ee18aa5db40910014d12d762}\label{conspage_8h_aa1b41597ee18aa5db40910014d12d762}} 
struct \mbox{\hyperlink{consspaceobject_8h_structcons__space__object}{cons\_space\_object}}&
cell\mbox{[}\mbox{\hyperlink{conspage_8h_a384a2520aa9fc6aa1dc6528b2795edab}{CONSPAGESIZE}}\mbox{]}&
\\
\hline

\end{DoxyFields}


\doxysubsection{Macro Definition Documentation}
\Hypertarget{conspage_8h_a384a2520aa9fc6aa1dc6528b2795edab}\label{conspage_8h_a384a2520aa9fc6aa1dc6528b2795edab} 
\index{conspage.h@{conspage.h}!CONSPAGESIZE@{CONSPAGESIZE}}
\index{CONSPAGESIZE@{CONSPAGESIZE}!conspage.h@{conspage.h}}
\doxysubsubsection{\texorpdfstring{CONSPAGESIZE}{CONSPAGESIZE}}
{\footnotesize\ttfamily \#define CONSPAGESIZE~1024}



the number of cons cells on a cons page. 

The maximum value this can be (and consequently, the size which, by version 1, it will default to) is the maximum value of an unsigned 32 bit integer, which is to say 4294967296. However, we\textquotesingle{}ll start small. 

Definition at line \mbox{\hyperlink{conspage_8h_source_l00024}{24}} of file \mbox{\hyperlink{conspage_8h_source}{conspage.\+h}}.

\Hypertarget{conspage_8h_a2656b2b52cfab9ff1a7f8cf63e5d111f}\label{conspage_8h_a2656b2b52cfab9ff1a7f8cf63e5d111f} 
\index{conspage.h@{conspage.h}!NCONSPAGES@{NCONSPAGES}}
\index{NCONSPAGES@{NCONSPAGES}!conspage.h@{conspage.h}}
\doxysubsubsection{\texorpdfstring{NCONSPAGES}{NCONSPAGES}}
{\footnotesize\ttfamily \#define NCONSPAGES~64}



the number of cons pages we will initially allow for. 

For convenience we\textquotesingle{}ll set up an array of cons pages this big; however, later we will want a mechanism for this to be able to grow dynamically to the maximum we can currently allow, which is 4294967296.

Note that this means the total number of addressable cons cells is 1.\+8e19, each of 20 bytes; or 3e20 bytes in total; and there are up to a maximum of 4e9 of heap space objects, each of potentially 4e9 bytes. So we\textquotesingle{}re talking about a potential total of 8e100 bytes of addressable memory, which is only slightly more than the number of atoms in the universe. 

Definition at line \mbox{\hyperlink{conspage_8h_source_l00040}{40}} of file \mbox{\hyperlink{conspage_8h_source}{conspage.\+h}}.



\doxysubsection{Function Documentation}
\Hypertarget{conspage_8h_a04ba7c874b05e9789d0aca9ee6b106a7}\label{conspage_8h_a04ba7c874b05e9789d0aca9ee6b106a7} 
\index{conspage.h@{conspage.h}!allocate\_cell@{allocate\_cell}}
\index{allocate\_cell@{allocate\_cell}!conspage.h@{conspage.h}}
\doxysubsubsection{\texorpdfstring{allocate\_cell()}{allocate\_cell()}}
{\footnotesize\ttfamily struct \mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\+\_\+pointer}} allocate\+\_\+cell (\begin{DoxyParamCaption}\item[{uint32\+\_\+t}]{tag }\end{DoxyParamCaption})}



Allocates a cell with the specified {\ttfamily tag}. 

Dangerous, primitive, low level.


\begin{DoxyParams}{Parameters}
{\em tag} & the tag of the cell to allocate -\/ must be a valid cons space tag. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the cons pointer which refers to the cell allocated. 
\end{DoxyReturn}
\begin{DoxyRefDesc}{Todo}
\item[\mbox{\hyperlink{todo__todo000006}{Todo}}]handle the case where another \doxylink{conspage_8h_structcons__page}{cons\+\_\+page} cannot be allocated; return an exception. Which, as we cannot create such an exception when cons space is exhausted, means we must construct it at init time. \end{DoxyRefDesc}


Definition at line \mbox{\hyperlink{conspage_8c_source_l00222}{222}} of file \mbox{\hyperlink{conspage_8c_source}{conspage.\+c}}.



References \mbox{\hyperlink{conspage_8c_source_l00222}{allocate\+\_\+cell()}}, \mbox{\hyperlink{consspaceobject_8h_source_l00635}{cons\+\_\+space\+\_\+object\+::count}}, \mbox{\hyperlink{debug_8h_source_l00021}{DEBUG\+\_\+\+ALLOC}}, \mbox{\hyperlink{debug_8c_source_l00101}{debug\+\_\+printf()}}, \mbox{\hyperlink{conspage_8c_source_l00046}{freelist}}, \mbox{\hyperlink{consspaceobject_8h_source_l00063}{FREETAG}}, \mbox{\hyperlink{conspage_8c_source_l00061}{make\+\_\+cons\+\_\+page()}}, \mbox{\hyperlink{consspaceobject_8h_source_l00277}{NIL}}, \mbox{\hyperlink{consspaceobject_8h_source_l00419}{cons\+\_\+pointer\+::offset}}, \mbox{\hyperlink{consspaceobject_8h_source_l00417}{cons\+\_\+pointer\+::page}}, \mbox{\hyperlink{consspaceobject_8h_a259b3afe36776f8ba8498fdf95904f25}{cons\+\_\+space\+\_\+object\+::payload}}, \mbox{\hyperlink{consspaceobject_8h_source_l00297}{pointer2cell}}, \mbox{\hyperlink{consspaceobject_8h_a21cb645ce4ae20308447dcd59534bf38}{cons\+\_\+space\+\_\+object\+::tag}}, \mbox{\hyperlink{consspaceobject_8h_source_l00030}{TAGLENGTH}}, and \mbox{\hyperlink{conspage_8c_source_l00034}{total\+\_\+cells\+\_\+allocated}}.



Referenced by \mbox{\hyperlink{conspage_8c_source_l00222}{allocate\+\_\+cell()}}, \mbox{\hyperlink{consspaceobject_8c_source_l00177}{make\+\_\+cons()}}, \mbox{\hyperlink{consspaceobject_8c_source_l00200}{make\+\_\+exception()}}, \mbox{\hyperlink{consspaceobject_8c_source_l00218}{make\+\_\+function()}}, \mbox{\hyperlink{integer_8c_source_l00089}{make\+\_\+integer()}}, \mbox{\hyperlink{consspaceobject_8c_source_l00240}{make\+\_\+lambda()}}, \mbox{\hyperlink{consspaceobject_8c_source_l00257}{make\+\_\+nlambda()}}, \mbox{\hyperlink{ratio_8c_source_l00312}{make\+\_\+ratio()}}, \mbox{\hyperlink{consspaceobject_8c_source_l00405}{make\+\_\+read\+\_\+stream()}}, \mbox{\hyperlink{real_8c_source_l00021}{make\+\_\+real()}}, \mbox{\hyperlink{consspaceobject_8c_source_l00379}{make\+\_\+special()}}, \mbox{\hyperlink{consspaceobject_8c_source_l00308}{make\+\_\+string\+\_\+like\+\_\+thing()}}, \mbox{\hyperlink{psse__time_8c_source_l00059}{make\+\_\+time()}}, \mbox{\hyperlink{vectorspace_8c_source_l00042}{make\+\_\+vec\+\_\+pointer()}}, and \mbox{\hyperlink{consspaceobject_8c_source_l00422}{make\+\_\+write\+\_\+stream()}}.

\Hypertarget{conspage_8h_a8078785bb1865878f934d02b28e600d9}\label{conspage_8h_a8078785bb1865878f934d02b28e600d9} 
\index{conspage.h@{conspage.h}!dump\_pages@{dump\_pages}}
\index{dump\_pages@{dump\_pages}!conspage.h@{conspage.h}}
\doxysubsubsection{\texorpdfstring{dump\_pages()}{dump\_pages()}}
{\footnotesize\ttfamily void dump\+\_\+pages (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{fopen_8h_a8c81a077422f5e2410ba71eb75108f6e}{URL\+\_\+\+FILE}} \texorpdfstring{$\ast$}{*}}]{output }\end{DoxyParamCaption})}



dump the allocated pages to this {\ttfamily output} stream. 



Definition at line \mbox{\hyperlink{conspage_8c_source_l00124}{124}} of file \mbox{\hyperlink{conspage_8c_source}{conspage.\+c}}.



References \mbox{\hyperlink{conspage_8h_source_l00024}{CONSPAGESIZE}}, \mbox{\hyperlink{dump_8c_source_l00059}{dump\+\_\+object()}}, \mbox{\hyperlink{conspage_8c_source_l00040}{initialised\+\_\+cons\+\_\+pages}}, and \mbox{\hyperlink{fopen_8h_source_l00050}{url\+\_\+fwprintf}}.



Referenced by \mbox{\hyperlink{init_8c_source_l00206}{main()}}.

\Hypertarget{conspage_8h_a7cf88f8487cd8fef12fdd78a2aaa6216}\label{conspage_8h_a7cf88f8487cd8fef12fdd78a2aaa6216} 
\index{conspage.h@{conspage.h}!free\_cell@{free\_cell}}
\index{free\_cell@{free\_cell}!conspage.h@{conspage.h}}
\doxysubsubsection{\texorpdfstring{free\_cell()}{free\_cell()}}
{\footnotesize\ttfamily void free\+\_\+cell (\begin{DoxyParamCaption}\item[{struct \mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\+\_\+pointer}}}]{pointer }\end{DoxyParamCaption})}



Frees the cell at the specified {\ttfamily pointer}; for all the types of cons-\/space object which point to other cons-\/space objects, cascade the decrement. 

Dangerous, primitive, low level.

@pointer the cell to free 

Definition at line \mbox{\hyperlink{conspage_8c_source_l00143}{143}} of file \mbox{\hyperlink{conspage_8c_source}{conspage.\+c}}.



References \mbox{\hyperlink{consspaceobject_8c_source_l00035}{check\+\_\+tag()}}, \mbox{\hyperlink{consspaceobject_8h_source_l00046}{CONSTV}}, \mbox{\hyperlink{consspaceobject_8h_source_l00635}{cons\+\_\+space\+\_\+object\+::count}}, \mbox{\hyperlink{debug_8h_source_l00021}{DEBUG\+\_\+\+ALLOC}}, \mbox{\hyperlink{debug_8c_source_l00136}{debug\+\_\+dump\+\_\+object()}}, \mbox{\hyperlink{debug_8c_source_l00101}{debug\+\_\+printf()}}, \mbox{\hyperlink{consspaceobject_8c_source_l00080}{dec\+\_\+ref()}}, \mbox{\hyperlink{consspaceobject_8h_source_l00057}{EXCEPTIONTV}}, \mbox{\hyperlink{vectorspace_8c_source_l00123}{free\+\_\+vso()}}, \mbox{\hyperlink{conspage_8c_source_l00046}{freelist}}, \mbox{\hyperlink{consspaceobject_8h_source_l00063}{FREETAG}}, \mbox{\hyperlink{consspaceobject_8h_source_l00068}{FREETV}}, \mbox{\hyperlink{consspaceobject_8h_source_l00080}{FUNCTIONTV}}, \mbox{\hyperlink{consspaceobject_8h_source_l00090}{INTEGERTV}}, \mbox{\hyperlink{consspaceobject_8h_source_l00111}{LAMBDATV}}, \mbox{\hyperlink{consspaceobject_8h_source_l00277}{NIL}}, \mbox{\hyperlink{consspaceobject_8h_source_l00168}{NLAMBDATV}}, \mbox{\hyperlink{consspaceobject_8h_source_l00419}{cons\+\_\+pointer\+::offset}}, \mbox{\hyperlink{consspaceobject_8h_source_l00417}{cons\+\_\+pointer\+::page}}, \mbox{\hyperlink{consspaceobject_8h_a259b3afe36776f8ba8498fdf95904f25}{cons\+\_\+space\+\_\+object\+::payload}}, \mbox{\hyperlink{consspaceobject_8h_source_l00297}{pointer2cell}}, \mbox{\hyperlink{consspaceobject_8h_source_l00179}{RATIOTV}}, \mbox{\hyperlink{consspaceobject_8h_source_l00189}{READTV}}, \mbox{\hyperlink{consspaceobject_8h_source_l00211}{SPECIALTV}}, \mbox{\hyperlink{consspaceobject_8h_source_l00221}{STRINGTV}}, \mbox{\hyperlink{consspaceobject_8h_source_l00231}{SYMBOLTV}}, \mbox{\hyperlink{consspaceobject_8h_a21cb645ce4ae20308447dcd59534bf38}{cons\+\_\+space\+\_\+object\+::tag}}, \mbox{\hyperlink{consspaceobject_8h_source_l00030}{TAGLENGTH}}, \mbox{\hyperlink{conspage_8c_source_l00035}{total\+\_\+cells\+\_\+freed}}, \mbox{\hyperlink{fopen_8c_source_l00258}{url\+\_\+fclose()}}, \mbox{\hyperlink{consspaceobject_8h_source_l00262}{VECTORPOINTTV}}, and \mbox{\hyperlink{consspaceobject_8h_source_l00272}{WRITETV}}.



Referenced by \mbox{\hyperlink{consspaceobject_8c_source_l00080}{dec\+\_\+ref()}}.

\Hypertarget{conspage_8h_aeb73441904896a283f5b57298479bc4a}\label{conspage_8h_aeb73441904896a283f5b57298479bc4a} 
\index{conspage.h@{conspage.h}!initialise\_cons\_pages@{initialise\_cons\_pages}}
\index{initialise\_cons\_pages@{initialise\_cons\_pages}!conspage.h@{conspage.h}}
\doxysubsubsection{\texorpdfstring{initialise\_cons\_pages()}{initialise\_cons\_pages()}}
{\footnotesize\ttfamily void initialise\+\_\+cons\+\_\+pages (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



initialise the cons page system; to be called exactly once during startup. 



Definition at line \mbox{\hyperlink{conspage_8c_source_l00257}{257}} of file \mbox{\hyperlink{conspage_8c_source}{conspage.\+c}}.



References \mbox{\hyperlink{conspage_8c_source_l00029}{conspageinitihasbeencalled}}, \mbox{\hyperlink{conspage_8c_source_l00051}{conspages}}, \mbox{\hyperlink{debug_8h_source_l00021}{DEBUG\+\_\+\+ALLOC}}, \mbox{\hyperlink{debug_8c_source_l00101}{debug\+\_\+printf()}}, \mbox{\hyperlink{conspage_8c_source_l00061}{make\+\_\+cons\+\_\+page()}}, and \mbox{\hyperlink{conspage_8h_source_l00040}{NCONSPAGES}}.



Referenced by \mbox{\hyperlink{init_8c_source_l00206}{main()}}.

\Hypertarget{conspage_8h_ab8d9d6417f194dca8d8322301cf37c7c}\label{conspage_8h_ab8d9d6417f194dca8d8322301cf37c7c} 
\index{conspage.h@{conspage.h}!summarise\_allocation@{summarise\_allocation}}
\index{summarise\_allocation@{summarise\_allocation}!conspage.h@{conspage.h}}
\doxysubsubsection{\texorpdfstring{summarise\_allocation()}{summarise\_allocation()}}
{\footnotesize\ttfamily void summarise\+\_\+allocation (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



Definition at line \mbox{\hyperlink{conspage_8c_source_l00271}{271}} of file \mbox{\hyperlink{conspage_8c_source}{conspage.\+c}}.



References \mbox{\hyperlink{conspage_8c_source_l00034}{total\+\_\+cells\+\_\+allocated}}, and \mbox{\hyperlink{conspage_8c_source_l00035}{total\+\_\+cells\+\_\+freed}}.



Referenced by \mbox{\hyperlink{init_8c_source_l00206}{main()}}.



\doxysubsection{Variable Documentation}
\Hypertarget{conspage_8h_a7cce1a2d3dd8b5abe5e30622d94e6959}\label{conspage_8h_a7cce1a2d3dd8b5abe5e30622d94e6959} 
\index{conspage.h@{conspage.h}!conspages@{conspages}}
\index{conspages@{conspages}!conspage.h@{conspage.h}}
\doxysubsubsection{\texorpdfstring{conspages}{conspages}}
{\footnotesize\ttfamily struct \mbox{\hyperlink{conspage_8h_structcons__page}{cons\+\_\+page}}\texorpdfstring{$\ast$}{*} conspages\mbox{[}\mbox{\hyperlink{conspage_8h_a2656b2b52cfab9ff1a7f8cf63e5d111f}{NCONSPAGES}}\mbox{]}\hspace{0.3cm}{\ttfamily [extern]}}



An array of pointers to cons pages. 



Definition at line \mbox{\hyperlink{conspage_8c_source_l00051}{51}} of file \mbox{\hyperlink{conspage_8c_source}{conspage.\+c}}.



Referenced by \mbox{\hyperlink{conspage_8c_source_l00257}{initialise\+\_\+cons\+\_\+pages()}}, and \mbox{\hyperlink{conspage_8c_source_l00061}{make\+\_\+cons\+\_\+page()}}.

\Hypertarget{conspage_8h_ae0a20197a96d9f07dac864b925cd0f32}\label{conspage_8h_ae0a20197a96d9f07dac864b925cd0f32} 
\index{conspage.h@{conspage.h}!freelist@{freelist}}
\index{freelist@{freelist}!conspage.h@{conspage.h}}
\doxysubsubsection{\texorpdfstring{freelist}{freelist}}
{\footnotesize\ttfamily struct \mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\+\_\+pointer}} freelist\hspace{0.3cm}{\ttfamily [extern]}}



The (global) pointer to the (global) freelist. 

Not sure whether this ultimately belongs in this file. 

Definition at line \mbox{\hyperlink{conspage_8c_source_l00046}{46}} of file \mbox{\hyperlink{conspage_8c_source}{conspage.\+c}}.



Referenced by \mbox{\hyperlink{conspage_8c_source_l00222}{allocate\+\_\+cell()}}, \mbox{\hyperlink{conspage_8c_source_l00143}{free\+\_\+cell()}}, and \mbox{\hyperlink{conspage_8c_source_l00061}{make\+\_\+cons\+\_\+page()}}.

