From 597422484cab69eca91cc10fa4b4e4a3c12f56bc Mon Sep 17 00:00:00 2001 From: Richard Brooksby Date: Fri, 16 Jun 2023 09:33:58 +0100 Subject: [PATCH] Removing mpsitr.c, a relic of custom/cet, and merging its contents into mpsi.c. reponse to review . --- mps/code/comm.gmk | 1 - mps/code/commpre.nmk | 1 - mps/code/mps.c | 1 - mps/code/mpsi.c | 83 ++++++++++++++++++++++++++++- mps/code/mpsitr.c | 121 ------------------------------------------- 5 files changed, 81 insertions(+), 126 deletions(-) delete mode 100644 mps/code/mpsitr.c diff --git a/mps/code/comm.gmk b/mps/code/comm.gmk index 6224ca98068..390ec785507 100644 --- a/mps/code/comm.gmk +++ b/mps/code/comm.gmk @@ -191,7 +191,6 @@ MPMCOMMON = \ meter.c \ mpm.c \ mpsi.c \ - mpsitr.c \ nailboard.c \ policy.c \ pool.c \ diff --git a/mps/code/commpre.nmk b/mps/code/commpre.nmk index 318f705c126..082ea5cc068 100644 --- a/mps/code/commpre.nmk +++ b/mps/code/commpre.nmk @@ -147,7 +147,6 @@ MPMCOMMON=\ [meter] \ [mpm] \ [mpsi] \ - [mpsitr] \ [nailboard] \ [policy] \ [pool] \ diff --git a/mps/code/mps.c b/mps/code/mps.c index 378965605a4..e7872b3c14a 100644 --- a/mps/code/mps.c +++ b/mps/code/mps.c @@ -81,7 +81,6 @@ #include "vm.c" #include "policy.c" #include "trans.c" -#include "mpsitr.c" /* Additional pool classes */ diff --git a/mps/code/mpsi.c b/mps/code/mpsi.c index 5f19333639e..10e26ab07a1 100644 --- a/mps/code/mpsi.c +++ b/mps/code/mpsi.c @@ -1,7 +1,7 @@ /* mpsi.c: MEMORY POOL SYSTEM C INTERFACE LAYER * * $Id$ - * Copyright (c) 2001-2020 Ravenbrook Limited. See end of file for license. + * Copyright (c) 2001-2023 Ravenbrook Limited. See end of file for license. * Portions copyright (c) 2002 Global Graphics Software. * * .purpose: This code bridges between the MPS interface to C, @@ -47,6 +47,7 @@ #include "mpm.h" #include "mps.h" #include "sac.h" +#include "trans.h" #include @@ -2081,9 +2082,87 @@ void _mps_args_set_key(mps_arg_s args[MPS_ARGS_MAX], unsigned i, } +/* Transforms */ + + +mps_res_t mps_transform_create(mps_transform_t *mps_transform_o, + mps_arena_t arena) +{ + Transform transform = NULL; + Res res; + + AVER(mps_transform_o != NULL); + + ArenaEnter(arena); + res = TransformCreate(&transform, arena); + ArenaLeave(arena); + if (res != ResOK) + return res; + + *mps_transform_o = (mps_transform_t)transform; + return MPS_RES_OK; +} + + +mps_res_t mps_transform_add_oldnew(mps_transform_t transform, + mps_addr_t *mps_old_list, + mps_addr_t *mps_new_list, + size_t mps_count) +{ + Ref *old_list = (Ref *)mps_old_list; + Ref *new_list = (Ref *)mps_new_list; + Count count = mps_count; + Arena arena; + Res res; + + AVER(mps_old_list != NULL); + AVER(mps_new_list != NULL); + /* count: cannot check */ + + arena = TransformArena(transform); + + ArenaEnter(arena); + res = TransformAddOldNew(transform, old_list, new_list, count); + ArenaLeave(arena); + + return res; +} + + +mps_res_t mps_transform_apply(mps_bool_t *applied_o, + mps_transform_t transform) +{ + Arena arena; + Res res; + + AVER(applied_o != NULL); + + arena = TransformArena(transform); + ArenaEnter(arena); + STACK_CONTEXT_BEGIN(arena) { + res = TransformApply(applied_o, transform); + } STACK_CONTEXT_END(arena); + ArenaLeave(arena); + + return res; +} + + +void mps_transform_destroy(mps_transform_t transform) +{ + Arena arena; + + arena = TransformArena(transform); + + ArenaEnter(arena); + TransformDestroy(transform); + ArenaLeave(arena); +} + + /* C. COPYRIGHT AND LICENSE * - * Copyright (C) 2001-2020 Ravenbrook Limited . + * Copyright (C) 2001-2023 Ravenbrook Limited . * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/mps/code/mpsitr.c b/mps/code/mpsitr.c deleted file mode 100644 index 522d8099691..00000000000 --- a/mps/code/mpsitr.c +++ /dev/null @@ -1,121 +0,0 @@ -/* mpsitr.c: MEMORY POOL SYSTEM C INTERFACE LAYER TO TRANSFORMS - * - * $Id$ - * Copyright (c) 2011-2022 Ravenbrook Limited. See end of file for license. - * - * .purpose: This code bridges between the MPS interface to transforms in - * and the internal implementation of Transforms in . - */ - -#include "mpm.h" -#include "mps.h" -#include "trans.h" -#include "ss.h" - - -SRCID(mpsitr, "$Id$"); - - -mps_res_t mps_transform_create(mps_transform_t *mps_transform_o, - mps_arena_t arena) -{ - Transform transform = NULL; - Res res; - - AVER(mps_transform_o != NULL); - - ArenaEnter(arena); - res = TransformCreate(&transform, arena); - ArenaLeave(arena); - if (res != ResOK) - return res; - - *mps_transform_o = (mps_transform_t)transform; - return MPS_RES_OK; -} - - -mps_res_t mps_transform_add_oldnew(mps_transform_t transform, - mps_addr_t *mps_old_list, - mps_addr_t *mps_new_list, - size_t mps_count) -{ - Ref *old_list = (Ref *)mps_old_list; - Ref *new_list = (Ref *)mps_new_list; - Count count = mps_count; - Arena arena; - Res res; - - AVER(mps_old_list != NULL); - AVER(mps_new_list != NULL); - /* count: cannot check */ - - arena = TransformArena(transform); - - ArenaEnter(arena); - res = TransformAddOldNew(transform, old_list, new_list, count); - ArenaLeave(arena); - - return res; -} - - -mps_res_t mps_transform_apply(mps_bool_t *applied_o, - mps_transform_t transform) -{ - Arena arena; - Res res; - - AVER(applied_o != NULL); - - arena = TransformArena(transform); - ArenaEnter(arena); - STACK_CONTEXT_BEGIN(arena) { - res = TransformApply(applied_o, transform); - } STACK_CONTEXT_END(arena); - ArenaLeave(arena); - - return res; -} - - -void mps_transform_destroy(mps_transform_t transform) -{ - Arena arena; - - arena = TransformArena(transform); - - ArenaEnter(arena); - TransformDestroy(transform); - ArenaLeave(arena); -} - - -/* C. COPYRIGHT AND LICENSE - * - * Copyright (C) 2011-2022 Ravenbrook Limited . - * - * 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. - * - * 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 AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDER OR 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. - */