summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStewart Smith <stewart@linux.vnet.ibm.com>2015-12-15 16:00:21 +1100
committerStewart Smith <stewart@linux.vnet.ibm.com>2015-12-15 16:48:06 +1100
commit0e3baa21f276cb551d086e5b028ac9f7f0b7e4d2 (patch)
tree4953c8722ffa091a6e967a18e22f59d3dad16b4b
parent5690d7ee13ec02b28e62301bac32b5f5cfa6f761 (diff)
downloadffs-0e3baa21f276cb551d086e5b028ac9f7f0b7e4d2.zip
ffs-0e3baa21f276cb551d086e5b028ac9f7f0b7e4d2.tar.gz
remove unused heap
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
-rw-r--r--clib/Rules.mk2
-rw-r--r--clib/heap.h77
-rw-r--r--clib/src/heap.c158
-rw-r--r--clib/test/heap.c45
4 files changed, 1 insertions, 281 deletions
diff --git a/clib/Rules.mk b/clib/Rules.mk
index fcca1a6..a3c7f7b 100644
--- a/clib/Rules.mk
+++ b/clib/Rules.mk
@@ -27,7 +27,7 @@ CFLAGS += -iquote$(DEPTH) -fPIC
LDFLAGS=-L.
-# array.o array_iter.o signal.o heap.o
+# array.o array_iter.o signal.o
OBJS = err.o crc32.o misc.o ecc.o \
exception.o slab.o \
diff --git a/clib/heap.h b/clib/heap.h
deleted file mode 100644
index 1c07e9a..0000000
--- a/clib/heap.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/heap.h $ */
-/* */
-/* OpenPOWER FFS Project */
-/* */
-/* Contributors Listed Below - COPYRIGHT 2014,2015 */
-/* [+] International Business Machines Corp. */
-/* */
-/* */
-/* Licensed under the Apache License, Version 2.0 (the "License"); */
-/* you may not use this file except in compliance with the License. */
-/* You may obtain a copy of the License at */
-/* */
-/* http://www.apache.org/licenses/LICENSE-2.0 */
-/* */
-/* Unless required by applicable law or agreed to in writing, software */
-/* distributed under the License is distributed on an "AS IS" BASIS, */
-/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
-/* implied. See the License for the specific language governing */
-/* permissions and limitations under the License. */
-/* */
-/* IBM_PROLOG_END_TAG */
-
-/*
- * File: heap.h
- * Author: Shaun Wetzstein <shaun@us.ibm.com>
- * Descr: Arena based (slab) memory allocator
- * Note:
- * Date: 07/28/10
- */
-
-#ifndef __HEAP_H__
-#define __HEAP_H__
-
-#include <stdlib.h>
-
-#include "slab.h"
-
-/* ======================================================================= */
-
-typedef struct heap heap_t;
-
-struct heap {
- size_t page_size;
- size_t alloc_size;
-
- size_t slab_size;
- slab_t *slab[];
-};
-
-/* ======================================================================= */
-
-#define heap_init(a,c) (__heap_init((h),(a),(c),__FILE__,__LINE__))
-extern void __heap_init(heap_t * self, size_t alloc_size, size_t cache_size,
- const char *file, int line);
-
-#define heap_new(a,c) (__heap_new((a),(c),__FILE__,__LINE__))
-extern heap_t *__heap_new(size_t alloc_size, size_t cache_size,
- const char *file, int line);
-#define heap_delete(h) (__heap_delete((h),__FILE__,__LINE__))
-extern void __heap_delete(heap_t * self, const char *file,
- int line) __nonnull((1));
-
-#define heap_alloc(h,s) (__heap_alloc((h),(s),__FILE__,__LINE__))
-extern void *__heap_alloc(heap_t * self, size_t size, const char *file,
- int line) __nonnull((1));
-#define heap_free(h,p) (__heap_free((h),(p),__FILE__,__LINE__))
-extern void __heap_free(heap_t * self, void *ptr, const char *file,
- int line) __nonnull((1, 2));
-
-extern void heap_dump(heap_t * self, FILE * out) __nonnull((1));
-
-/* ======================================================================= */
-
-#endif /* __HEAP_H__ */
diff --git a/clib/src/heap.c b/clib/src/heap.c
deleted file mode 100644
index 26fe246..0000000
--- a/clib/src/heap.c
+++ /dev/null
@@ -1,158 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/src/heap.c $ */
-/* */
-/* OpenPOWER FFS Project */
-/* */
-/* Contributors Listed Below - COPYRIGHT 2014,2015 */
-/* [+] International Business Machines Corp. */
-/* */
-/* */
-/* Licensed under the Apache License, Version 2.0 (the "License"); */
-/* you may not use this file except in compliance with the License. */
-/* You may obtain a copy of the License at */
-/* */
-/* http://www.apache.org/licenses/LICENSE-2.0 */
-/* */
-/* Unless required by applicable law or agreed to in writing, software */
-/* distributed under the License is distributed on an "AS IS" BASIS, */
-/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
-/* implied. See the License for the specific language governing */
-/* permissions and limitations under the License. */
-/* */
-/* IBM_PROLOG_END_TAG */
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <malloc.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-
-#include "assert.h"
-#include "misc.h"
-#include "slab.h"
-#include "heap.h"
-#include "bb_trace.h"
-
-/* ======================================================================= */
-
-static const char *__heap_msg[] = {
- "heap: unexpected NULL pointer"
- "heap: unexpected cache and/or alloc size",
- "heap: unexpected alloc size",
-};
-
-#define HEAP_NULL (__heap_msg[0])
-#define HEAP_SIZE (__heap_msg[1])
-#define HEAP_ALLOC (__heap_msg[2])
-
-/* ======================================================================= */
-
-void heap_dump(heap_t * self, FILE * out)
-{
- if (self == NULL)
- return;
-
- size_t i;
-
- fprintf(out,
- "*******************************************************************\n");
- for (i = 0; i < self->slab_size; i++)
- if (self->slab[i] != NULL)
- slab_dump(self->slab[i], out);
- fprintf(out,
- "*******************************************************************\n");
-}
-
-heap_t *__heap_new(size_t alloc_size, size_t page_size, const char *file,
- int line)
-{
- alloc_size = max(__round_pow2(alloc_size), CACHE_ALLOC_MIN);
- page_size = max(__round_pow2(page_size), CACHE_SIZE_MIN);
-
- if (alloc_size < CACHE_ALLOC_MIN || CACHE_ALLOC_MAX < alloc_size)
- throw_unexpected(HEAP_SIZE);
- if (page_size < CACHE_SIZE_MIN || CACHE_SIZE_MAX < page_size)
- throw_unexpected(HEAP_SIZE);
-
- heap_t *self = (heap_t *) MALLOC(sizeof(*self) +
- sizeof(*self->slab) * page_size /
- alloc_size);
- assert(self != NULL);
-
- self->page_size = page_size;
- self->alloc_size = alloc_size;
- self->slab_size = page_size / alloc_size;
-
- memset(self->slab, 0, self->slab_size * sizeof(*self->slab));
-
- return self;
-}
-
-void __heap_delete(heap_t * self, const char *file, int line)
-{
- if (unlikely(self == NULL))
- return;
-
- size_t i;
- for (i = 0; i < self->slab_size; i++) {
- if (self->slab[i] != NULL) {
- slab_delete(self->slab[i]);
- self->slab[i] = NULL;
- }
- }
-
- memset(self, 0, sizeof *self);
- FREE(self);
-}
-
-void *__heap_alloc(heap_t * self, size_t size, const char *file, int line)
-{
- if (unlikely(self == NULL))
- throw_unexpected(HEAP_NULL);
-
- size = max(align(size, self->alloc_size), self->alloc_size);
-
- size_t slab_pos = size / self->alloc_size - 1;
-
- if (unlikely(self->slab_size < slab_pos))
- throw_unexpected(HEAP_ALLOC);
-
- if (unlikely(self->slab[slab_pos] == NULL))
- self->slab[slab_pos] = slab_new(size, 0);
-
- return slab_alloc(self->slab[slab_pos]);
-}
-
-void __heap_free(heap_t * self, void *ptr, const char *file, int line)
-{
- if (unlikely(self == NULL))
- throw_unexpected(HEAP_NULL);
-
- void *data = (void *)((uint32_t) ptr & ~(self->page_size - 1));
- cache_t *c = (cache_t *) (data + self->page_size - sizeof(cache_t));
- cache_check(c);
- slab_free(cache_slab(c), ptr);
-}
-
-/* ======================================================================= */
-
-static uint32_t page_size;
-
-void heap_ctor(void) __constructor;
-void heap_ctor(void)
-{
- page_size = (const uint32_t)sysconf(_SC_PAGESIZE);
- assert(0 < page_size);
-}
-
-void heap_dtor(void) __destructor;
-void heap_dtor(void)
-{
-}
-
-/* ======================================================================= */
diff --git a/clib/test/heap.c b/clib/test/heap.c
deleted file mode 100644
index 8ab746f..0000000
--- a/clib/test/heap.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/test/heap.c $ */
-/* */
-/* OpenPOWER FFS Project */
-/* */
-/* Contributors Listed Below - COPYRIGHT 2014,2015 */
-/* [+] International Business Machines Corp. */
-/* */
-/* */
-/* Licensed under the Apache License, Version 2.0 (the "License"); */
-/* you may not use this file except in compliance with the License. */
-/* You may obtain a copy of the License at */
-/* */
-/* http://www.apache.org/licenses/LICENSE-2.0 */
-/* */
-/* Unless required by applicable law or agreed to in writing, software */
-/* distributed under the License is distributed on an "AS IS" BASIS, */
-/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
-/* implied. See the License for the specific language governing */
-/* permissions and limitations under the License. */
-/* */
-/* IBM_PROLOG_END_TAG */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <clib/heap.h>
-
-int main(const int argc, const char * argv[]) {
- heap_t h;
- heap_init(h, 0, 0);
-
- void * p5 = heap_alloc(&h, 5);
- void * p9 = heap_alloc(&h, 9);
- void * p13 = heap_alloc(&h, 13);
-
- heap_free(&h, p13);
- heap_free(&h, p5);
- heap_free(&h, p9);
-
- return 0;
-}
OpenPOWER on IntegriCloud