From 6b89b020c50ca897cbcc505b17fece0d19dab320 Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Tue, 6 Nov 2012 17:08:58 +0000 Subject: [PATCH] Add public interface for mfs pool class. Correct the documentation for MFS: constructor takes extend_by and unit_size in that order. Copied from Perforce Change: 180372 ServerID: perforce.ravenbrook.com --- mps/code/mpscmfs.h | 56 ++++++++++++++++++++++++++++++++++ mps/code/poolmfs.c | 11 +++++-- mps/manual/source/pool/mfs.rst | 12 ++++---- 3 files changed, 71 insertions(+), 8 deletions(-) create mode 100644 mps/code/mpscmfs.h diff --git a/mps/code/mpscmfs.h b/mps/code/mpscmfs.h new file mode 100644 index 00000000000..4a46e10a84b --- /dev/null +++ b/mps/code/mpscmfs.h @@ -0,0 +1,56 @@ +/* mpscamfs.h: MEMORY POOL SYSTEM CLASS "MFS" + * + * $Id$ + * Copyright (c) 2001-2012 Ravenbrook Limited. See end of file for license. + */ + +#ifndef mpscmfs_h +#define mpscmfs_h + +#include "mps.h" + +extern mps_class_t mps_class_mfs(void); + +#endif /* mpscmfs_h */ + + +/* C. COPYRIGHT AND LICENSE + * + * Copyright (C) 2001-2012 Ravenbrook Limited . + * All rights reserved. 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: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. 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. + * + * 3. 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. + */ diff --git a/mps/code/poolmfs.c b/mps/code/poolmfs.c index 82044e37589..ad4140a4479 100644 --- a/mps/code/poolmfs.c +++ b/mps/code/poolmfs.c @@ -1,7 +1,7 @@ /* poolmfs.c: MANUAL FIXED SMALL UNIT POOL * * $Id$ - * Copyright (c) 2001 Ravenbrook Limited. See end of file for license. + * Copyright (c) 2001-2012 Ravenbrook Limited. See end of file for license. * * This is the implementation of the MFS pool class. * @@ -32,6 +32,7 @@ */ +#include "mpscmfs.h" #include "poolmfs.h" #include "mpm.h" @@ -282,6 +283,12 @@ PoolClass PoolClassMFS(void) } +mps_class_t mps_class_mfs(void) +{ + return (mps_class_t)PoolClassMFS(); +} + + Bool MFSCheck(MFS mfs) { Arena arena; @@ -305,7 +312,7 @@ Bool MFSCheck(MFS mfs) /* C. COPYRIGHT AND LICENSE * - * Copyright (C) 2001-2002 Ravenbrook Limited . + * Copyright (C) 2001-2012 Ravenbrook Limited . * All rights reserved. This is an open source license. Contact * Ravenbrook for commercial licensing options. * diff --git a/mps/manual/source/pool/mfs.rst b/mps/manual/source/pool/mfs.rst index d77ede12c41..b1a78a9e5cf 100644 --- a/mps/manual/source/pool/mfs.rst +++ b/mps/manual/source/pool/mfs.rst @@ -82,14 +82,14 @@ MFS interface mps_res_t mps_pool_create(mps_pool_t *pool_o, mps_arena_t arena, mps_class_t mps_class_mfs(), - mps_size_t unit_size, - mps_size_t extend_size) - - ``unit_size`` is the :term:`size` of blocks that will be allocated - from this pool, in :term:`bytes (1)`. It must be at least one - :term:`word`. + mps_size_t extend_size, + mps_size_t unit_size) ``extend_size`` is the :term:`size` of segment that the pool will request from the :term:`arena`. It must be at least as big as ``unit_size``. If this is not a multiple of ``unit_size``, there will be wasted space in each segment. + + ``unit_size`` is the :term:`size` of blocks that will be allocated + from this pool, in :term:`bytes (1)`. It must be at least one + :term:`word`.