Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 74fbd0eb33bb08f719b79951bc4e329e > files > 47

xconq-7.5.0-1.20050612.5mdv2009.1.i586.rpm

<HTML>
<HEAD>
<!-- This HTML file has been created by texi2html 1.39
     from ./hacking.texi on 12 June 2005 -->

<TITLE>Hacking Xconq - Porting the Kernel</TITLE>
</HEAD>
<BODY>
Go to the <A HREF="hacking_1.html">first</A>, <A HREF="hacking_3.html">previous</A>, <A HREF="hacking_5.html">next</A>, <A HREF="hacking_35.html">last</A> section, <A HREF="hacking_toc.html">table of contents</A>.
<HR>


<H2><A NAME="SEC4" HREF="hacking_toc.html#SEC4">Porting the Kernel</A></H2>

<P>
The kernel must be in ANSI C.  Although the kernel uses stdio, it does
not assume the presence of a console (stdin, stdout, stderr).  For
instance, a graphical interface can arrange to disable stdin entirely
and direct stdout/stderr into a file (see the Mac interface sources for
an example).

</P>
<P>
You should be careful about memory consumption.  In general, the kernel
takes the attitude that if it was worth allocating, it's worth hanging
onto; and so the program does not free much storage.  Also, nearly all
of the allocation happens during startup.  Since a game may run for a
very long time (thousands of turns perhaps), it is important not to run
the risk of exhausting memory at a climactic moment in the game!

</P>
<P>
Also, the kernel should not exit on its own.  The only permissible times
are when the internal state is so damaged that interface error-handling
routines (see below) cannot be called safely.  Such situations are rare.
If you add something to the kernel and need to handle error situations,
then you should call one of the interface's error-handling routines.
There are distinct routines for problems during initializations vs
problems while running, and both error and warning routines.  Warning
routines may return, so kernel code should be prepared to continue on,
while error routines will never return.

</P>

<HR>
Go to the <A HREF="hacking_1.html">first</A>, <A HREF="hacking_3.html">previous</A>, <A HREF="hacking_5.html">next</A>, <A HREF="hacking_35.html">last</A> section, <A HREF="hacking_toc.html">table of contents</A>.
</BODY>
</HTML>