From 6951d2327b0f0b6999f66452d5c38d74136cdb12 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sat, 19 Nov 2016 15:51:24 +0000 Subject: Add memory.c/h --- frontends/amiga/memory.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100755 frontends/amiga/memory.c (limited to 'frontends/amiga/memory.c') diff --git a/frontends/amiga/memory.c b/frontends/amiga/memory.c new file mode 100755 index 000000000..a77d0cc47 --- /dev/null +++ b/frontends/amiga/memory.c @@ -0,0 +1,75 @@ +/* + * Copyright 2016 Chris Young + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include + +#include "amiga/memory.h" + +void *ami_misc_allocvec_clear(int size, UBYTE value) +{ +#ifdef __amigaos4__ + return AllocVecTags(size, AVT_ClearWithValue, value, TAG_DONE); +#else + void *mem = AllocVec(size, MEMF_ANY); + if (mem) memset(mem, value, size); + return mem; +#endif +} + +APTR ami_misc_itempool_create(int size) +{ +#ifdef __amigaos4__ + return AllocSysObjectTags(ASOT_ITEMPOOL, + ASOITEM_MFlags, MEMF_PRIVATE, + ASOITEM_ItemSize, size, + ASOITEM_GCPolicy, ITEMGC_AFTERCOUNT, + ASOITEM_GCParameter, 100, + TAG_DONE); +#else + return CreatePool(MEMF_ANY, 20 * size, size); +#endif +} + +void ami_misc_itempool_delete(APTR pool) +{ +#ifdef __amigaos4__ + FreeSysObject(ASOT_ITEMPOOL, pool); +#else + DeletePool(pool); +#endif +} + +APTR ami_misc_itempool_alloc(APTR pool, int size) +{ +#ifdef __amigaos4__ + return ItemPoolAlloc(pool); +#else + return AllocPooled(pool, size); +#endif +} + +void ami_misc_itempool_free(APTR restrict pool, APTR restrict item, int size) +{ +#ifdef __amigaos4__ + ItemPoolFree(pool, item); +#else + FreePooled(pool, item, size); +#endif +} + -- cgit v1.2.3 From 4b1b79582c5de530100b4ddb909163a6fb9b23c8 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sat, 19 Nov 2016 16:12:20 +0000 Subject: Move slab size def into memory.c --- frontends/amiga/memory.c | 4 ++++ frontends/amiga/memory.h | 1 + frontends/amiga/menu.c | 1 + frontends/amiga/os3support.c | 2 -- frontends/amiga/plotters.c | 1 + frontends/amiga/tree.c | 1 + 6 files changed, 8 insertions(+), 2 deletions(-) (limited to 'frontends/amiga/memory.c') diff --git a/frontends/amiga/memory.c b/frontends/amiga/memory.c index a77d0cc47..874f8521e 100755 --- a/frontends/amiga/memory.c +++ b/frontends/amiga/memory.c @@ -21,6 +21,10 @@ #include "amiga/memory.h" +#ifndef __amigaos4__ +ULONG __slab_max_size = 8192; /* Enable clib2's slab allocator */ +#endif + void *ami_misc_allocvec_clear(int size, UBYTE value) { #ifdef __amigaos4__ diff --git a/frontends/amiga/memory.h b/frontends/amiga/memory.h index 29a7ae111..1c51f3081 100644 --- a/frontends/amiga/memory.h +++ b/frontends/amiga/memory.h @@ -21,6 +21,7 @@ #include +/* Standard memory allocation */ void *ami_misc_allocvec_clear(int size, UBYTE value); /* Itempool cross-compatibility */ diff --git a/frontends/amiga/menu.c b/frontends/amiga/menu.c index 2eda5ff1b..feb5c2979 100644 --- a/frontends/amiga/menu.c +++ b/frontends/amiga/menu.c @@ -69,6 +69,7 @@ #include "amiga/libs.h" #include "amiga/menu.h" #include "amiga/memory.h" +#include "amiga/misc.h" #include "amiga/nsoption.h" #include "amiga/print.h" #include "amiga/search.h" diff --git a/frontends/amiga/os3support.c b/frontends/amiga/os3support.c index 6722ca83c..bdf633316 100644 --- a/frontends/amiga/os3support.c +++ b/frontends/amiga/os3support.c @@ -46,8 +46,6 @@ #define FAILURE (FALSE) #define NO ! -ULONG __slab_max_size = 8192; /* Enable clib2's slab allocator */ - /* Diskfont */ struct OutlineFont *OpenOutlineFont(STRPTR fileName, struct List *list, ULONG flags) { diff --git a/frontends/amiga/plotters.c b/frontends/amiga/plotters.c index 842e1bbac..073a95f3c 100644 --- a/frontends/amiga/plotters.c +++ b/frontends/amiga/plotters.c @@ -46,6 +46,7 @@ #include "amiga/font.h" #include "amiga/gui.h" #include "amiga/memory.h" +#include "amiga/misc.h" #include "amiga/rtg.h" #include "amiga/utf8.h" diff --git a/frontends/amiga/tree.c b/frontends/amiga/tree.c index 460eb2217..eea64ffea 100644 --- a/frontends/amiga/tree.c +++ b/frontends/amiga/tree.c @@ -67,6 +67,7 @@ #include "amiga/file.h" #include "amiga/libs.h" #include "amiga/memory.h" +#include "amiga/misc.h" #include "amiga/utf8.h" #include "amiga/sslcert.h" #include "amiga/drag.h" /* drag icon stuff */ -- cgit v1.2.3