]> git.lizzy.rs Git - plan9front.git/commitdiff
kernel: remove ucalloc.c duplicates
authorcinap_lenrek <cinap_lenrek@felloff.net>
Sat, 13 Mar 2021 13:57:53 +0000 (14:57 +0100)
committercinap_lenrek <cinap_lenrek@felloff.net>
Sat, 13 Mar 2021 13:57:53 +0000 (14:57 +0100)
sys/src/9/kw/ucalloc.c [deleted file]
sys/src/9/omap/fns.h
sys/src/9/omap/ucalloc.c [deleted file]
sys/src/9/port/ucalloc.c
sys/src/9/teg2/fns.h

diff --git a/sys/src/9/kw/ucalloc.c b/sys/src/9/kw/ucalloc.c
deleted file mode 100644 (file)
index f7d142b..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * allocate uncached memory
- */
-#include "u.h"
-#include "../port/lib.h"
-#include "mem.h"
-#include "dat.h"
-#include "fns.h"
-
-#include <pool.h>
-
-typedef struct Private Private;
-struct Private {
-       Lock;
-       char    msg[256];
-       char*   cur;
-};
-
-static Private ucprivate;
-
-static void
-ucpoolpanic(Pool* p, char* fmt, ...)
-{
-       va_list v;
-       Private *pv;
-       char msg[sizeof pv->msg];
-
-       pv = p->private;
-       va_start(v, fmt);
-       vseprint(pv->cur, &pv->msg[sizeof pv->msg], fmt, v);
-       va_end(v);
-       memmove(msg, pv->msg, sizeof msg);
-       iunlock(pv);
-       panic("%s", msg);
-}
-
-static void
-ucpoolprint(Pool* p, char* fmt, ...)
-{
-       va_list v;
-       Private *pv;
-
-       pv = p->private;
-       va_start(v, fmt);
-       pv->cur = vseprint(pv->cur, &pv->msg[sizeof pv->msg], fmt, v);
-       va_end(v);
-}
-
-static void
-ucpoolunlock(Pool* p)
-{
-       Private *pv;
-       char msg[sizeof pv->msg];
-
-       pv = p->private;
-       if(pv->cur == pv->msg){
-               iunlock(pv);
-               return;
-       }
-
-       memmove(msg, pv->msg, sizeof msg);
-       pv->cur = pv->msg;
-       iunlock(pv);
-
-       iprint("%.*s", sizeof pv->msg, msg);
-}
-
-static void
-ucpoollock(Pool* p)
-{
-       Private *pv;
-
-       pv = p->private;
-       ilock(pv);
-       pv->pc = getcallerpc(&p);
-       pv->cur = pv->msg;
-}
-
-static void*
-ucarena(usize size)
-{
-       void *uv, *v;
-
-       assert(size == 1*MiB);
-
-       mainmem->maxsize += 1*MiB;
-       if((v = mallocalign(1*MiB, 1*MiB, 0, 0)) == nil ||
-           (uv = mmuuncache(v, 1*MiB)) == nil){
-               free(v);
-               mainmem->maxsize -= 1*MiB;
-               return nil;
-       }
-       return uv;
-}
-
-static Pool ucpool = {
-       .name           = "Uncached",
-       .maxsize        = 4*MiB,
-       .minarena       = 1*MiB-32,
-       .quantum        = 32,
-       .alloc          = ucarena,
-       .merge          = nil,
-       .flags          = /*POOL_TOLERANCE|POOL_ANTAGONISM|POOL_PARANOIA|*/0,
-
-       .lock           = ucpoollock,
-       .unlock         = ucpoolunlock,
-       .print          = ucpoolprint,
-       .panic          = ucpoolpanic,
-
-       .private        = &ucprivate,
-};
-
-void
-ucfree(void* v)
-{
-       if(v == nil)
-               return;
-       poolfree(&ucpool, v);
-}
-
-void*
-ucalloc(usize size)
-{
-       assert(size < ucpool.minarena-128);
-
-       return poolallocalign(&ucpool, size, 32, 0, 0);
-}
-
-void*
-ucallocalign(usize size, int align, usize span)
-{
-       assert(size < ucpool.minarena-128);
-
-       return poolallocalign(&ucpool, size, align, 0, span);
-}
index 831c3eb8ade653dcd45f09ca17773291048bd942..1515f4fba93253fc891460f9923b050f0e31c355 100644 (file)
@@ -125,7 +125,7 @@ uintptr mmukmap(uintptr, uintptr, usize);
 uintptr mmukunmap(uintptr, uintptr, usize);
 extern void* mmuuncache(void*, usize);
 extern void* ucalloc(usize);
-extern void* ucallocalign(usize size, int align, int span);
+extern void* ucallocalign(usize size, int align, usize span);
 extern void ucfree(void*);
 
 /*
diff --git a/sys/src/9/omap/ucalloc.c b/sys/src/9/omap/ucalloc.c
deleted file mode 100644 (file)
index 37e8564..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * allocate uncached memory
- */
-#include "u.h"
-#include "../port/lib.h"
-#include "mem.h"
-#include "dat.h"
-#include "fns.h"
-
-#include <pool.h>
-
-typedef struct Private Private;
-struct Private {
-       Lock;
-       char    msg[256];
-       char*   cur;
-};
-
-static Private ucprivate;
-
-static void
-ucpoolpanic(Pool* p, char* fmt, ...)
-{
-       va_list v;
-       Private *pv;
-       char msg[sizeof pv->msg];
-
-       pv = p->private;
-       va_start(v, fmt);
-       vseprint(pv->cur, &pv->msg[sizeof pv->msg], fmt, v);
-       va_end(v);
-       memmove(msg, pv->msg, sizeof msg);
-       iunlock(pv);
-       panic("%s", msg);
-}
-
-static void
-ucpoolprint(Pool* p, char* fmt, ...)
-{
-       va_list v;
-       Private *pv;
-
-       pv = p->private;
-       va_start(v, fmt);
-       pv->cur = vseprint(pv->cur, &pv->msg[sizeof pv->msg], fmt, v);
-       va_end(v);
-}
-
-static void
-ucpoolunlock(Pool* p)
-{
-       Private *pv;
-       char msg[sizeof pv->msg];
-
-       pv = p->private;
-       if(pv->cur == pv->msg){
-               iunlock(pv);
-               return;
-       }
-
-       memmove(msg, pv->msg, sizeof msg);
-       pv->cur = pv->msg;
-       iunlock(pv);
-
-       iprint("%.*s", sizeof pv->msg, msg);
-}
-
-static void
-ucpoollock(Pool* p)
-{
-       Private *pv;
-
-       pv = p->private;
-       ilock(pv);
-       pv->pc = getcallerpc(&p);
-       pv->cur = pv->msg;
-}
-
-static void*
-ucarena(usize size)
-{
-       void *uv, *v;
-
-       assert(size == 1*MiB);
-
-       mainmem->maxsize += 1*MiB;
-       if((v = mallocalign(1*MiB, 1*MiB, 0, 0)) == nil ||
-           (uv = mmuuncache(v, 1*MiB)) == nil){
-               free(v);
-               mainmem->maxsize -= 1*MiB;
-               return nil;
-       }
-       return uv;
-}
-
-static Pool ucpool = {
-       .name           = "Uncached",
-       .maxsize        = 4*MiB,
-       .minarena       = 1*MiB-32,
-       .quantum        = 32,
-       .alloc          = ucarena,
-       .merge          = nil,
-       .flags          = /*POOL_TOLERANCE|POOL_ANTAGONISM|POOL_PARANOIA|*/0,
-
-       .lock           = ucpoollock,
-       .unlock         = ucpoolunlock,
-       .print          = ucpoolprint,
-       .panic          = ucpoolpanic,
-
-       .private        = &ucprivate,
-};
-
-void
-ucfree(void* v)
-{
-       if(v == nil)
-               return;
-       poolfree(&ucpool, v);
-}
-
-void*
-ucalloc(usize size)
-{
-       assert(size < ucpool.minarena-128);
-
-       return poolallocalign(&ucpool, size, 32, 0, 0);
-}
-
-void*
-ucallocalign(usize size, int align, int span)
-{
-       assert(size < ucpool.minarena-128);
-
-       return poolallocalign(&ucpool, size, align, 0, span);
-}
index 625553fe24ae3d30d5575d558db1227205dc6b4e..02267c625eea467f0e12dfe7498e092858ae77ec 100644 (file)
@@ -119,7 +119,7 @@ ucfree(void* v)
 }
 
 void*
-ucallocalign(usize size, int align, int span)
+ucallocalign(usize size, int align, usize span)
 {
        void *v;
 
index a425e301abf300c379480b647bf185cbebc06d17..ce35b70576e160761e8119430fb6b36e59ab5b32 100644 (file)
@@ -164,7 +164,7 @@ uintptr mmukmap(uintptr, uintptr, usize);
 uintptr mmukunmap(uintptr, uintptr, usize);
 extern void* mmuuncache(void*, usize);
 extern void* ucalloc(usize);
-extern void* ucallocalign(usize size, int align, int span);
+extern void* ucallocalign(usize size, int align, usize span);
 extern void ucfree(void*);
 
 /*