.. mode: -*- rst -*-

Library interface
=================

:Tag: design.mps.lib
:Author: Richard Brooksby
:Date: 1996-09-03
:Status: incomplete design
:Revision: $Id: //info.ravenbrook.com/project/mps/version/1.113/design/lib.txt#1 $
:Copyright: See `Copyright and License`_.
:Index terms: pair: library interface; design


Introduction
------------

_`.intro`: This document is the design of the MPS Library Interface, a
part of the plinth.

_`.readership`: Any MPS developer. Any clients that are prepared to
read this in order to get documentation.


Goals
-----

_`.goal`: The goals of the MPS library interface are:

_`.goal.host`: To control the dependency of the MPS on the hosted ISO
C library so that the core MPS remains freestanding (see
design.mps.exec-env).

_`.goal.free`: To allow the core MPS convenient access to ISO C
functionality that is provided on freestanding platforms (see
design.mps.exec-env.std.com.free).


Description
-----------

Overview
........

_`.overview.access`: The core MPS needs to access functionality that
could be provided by an ISO C hosted environment.

_`.overview.hosted`: The core MPS must not make direct use of any
facilities in the hosted environment (design.mps.exec-env). However,
it is sensible to make use of them when the MPS is deployed in a
hosted environment.

_`.overview.hosted.indirect`: The core MPS does not make any direct
use of hosted ISO C library facilities. Instead, it indirects through
the MPS Library Interface, impl.h.mpslib.

_`.overview.free`: The core MPS can make direct use of freestanding
ISO C library facilities and does not need to include any of the
header files ``<limits.h>``, ``<stdarg.h>``, and ``<stddef.h>``
directly.

_`.overview.complete`: The MPS Library Interface can be considered as
the complete "interface to ISO" (in that it provides direct access to
facilities that we get in a freestanding environment and equivalents
of any functionality we require from the hosted environment).

_`.overview.provision.client`: In a freestanding environment the
client is expected to provide functions meeting this interface to the
MPS.

_`.overview.provision.hosted`: In a hosted environment,
impl.c.mpsliban may be used. It just maps impl.h.mpslib directly onto
the ISO C library equivalents.

[missing diagram]


Outside the interface
.....................

We provide impl.c.mpsliban to the client, for two reasons:

#. the client can use it to connect the MPS to the ISO C library if it
   exists;

#. as an example implementation of the MPS Library Interface.


Implementation
--------------

_`.impl`: The MPS Library Interface comprises a header file
impl.h.mpslib and some documentation.

_`.impl.decl`: The header file defines the interface to definitions
which parallel those parts of the non-freestanding ISO headers which
are used by the MPS.

_`.impl.include`: The header file also includes the freestanding
headers ``<limits.h>``, ``<stdarg.h>``, and ``<stddef.h>`` (and not
``<float.h>``, though perhaps it should).


Document History
----------------

- 1996-09-03 RB_ Incomplete design.

- 2002-06-07 RB_ Converted from MMInfo database design document.

- 2013-05-23 GDR_ Converted to reStructuredText.

.. _RB: http://www.ravenbrook.com/consultants/rb/
.. _GDR: http://www.ravenbrook.com/consultants/gdr/


Copyright and License
---------------------

Copyright © 2013-2014 Ravenbrook Limited. All rights reserved.
<http://www.ravenbrook.com/>. This is an open source license. Contact
Ravenbrook for commercial licensing options.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

#. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.

#. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.

#. Redistributions in any form must be accompanied by information on how
   to obtain complete source code for this software and any
   accompanying software that uses this software.  The source code must
   either be included in the distribution or be available for no more than
   the cost of distribution plus a nominal fee, and must be freely
   redistributable under reasonable conditions.  For an executable file,
   complete source code means the source code for all modules it contains.
   It does not include source code for modules or files that typically
   accompany the major components of the operating system on which the
   executable file runs.

**This software is provided by the copyright holders and contributors
"as is" and any express or implied warranties, including, but not
limited to, the implied warranties of merchantability, fitness for a
particular purpose, or non-infringement, are disclaimed.  In no event
shall the copyright holders and contributors be liable for any direct,
indirect, incidental, special, exemplary, or consequential damages
(including, but not limited to, procurement of substitute goods or
services; loss of use, data, or profits; or business interruption)
however caused and on any theory of liability, whether in contract,
strict liability, or tort (including negligence or otherwise) arising in
any way out of the use of this software, even if advised of the
possibility of such damage.**
