summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStewart Smith <stewart@linux.vnet.ibm.com>2015-12-15 16:08:42 +1100
committerStewart Smith <stewart@linux.vnet.ibm.com>2015-12-15 16:48:06 +1100
commit70a008ea7ff9173f037c1e96d3e60a077edc0944 (patch)
treef30cf450a5494f7ec2a4577ed02b9fa54002ff99
parent4672f1232399d844eb18c7dbe9b8c5c2a2a6c726 (diff)
downloadffs-70a008ea7ff9173f037c1e96d3e60a077edc0944.zip
ffs-70a008ea7ff9173f037c1e96d3e60a077edc0944.tar.gz
remove unused slab
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
-rw-r--r--clib/Rules.mk2
-rw-r--r--clib/cunit/slab.c70
-rw-r--r--clib/cunit/slab.h26
-rw-r--r--clib/slab.h229
-rw-r--r--clib/src/tree.c1
-rw-r--r--clib/test/slab.c58
-rw-r--r--clib/test/splay.c103
7 files changed, 1 insertions, 488 deletions
diff --git a/clib/Rules.mk b/clib/Rules.mk
index fc3c7f8..556c2dc 100644
--- a/clib/Rules.mk
+++ b/clib/Rules.mk
@@ -28,7 +28,7 @@ CFLAGS += -iquote$(DEPTH) -fPIC
LDFLAGS=-L.
OBJS = err.o crc32.o misc.o ecc.o \
- exception.o slab.o \
+ exception.o \
list.o list_iter.o \
tree.o tree_iter.o \
value.o mq.o \
diff --git a/clib/cunit/slab.c b/clib/cunit/slab.c
deleted file mode 100644
index 9a1bb58..0000000
--- a/clib/cunit/slab.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/cunit/slab.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 <clib/exception.h>
-#include <clib/assert.h>
-#include <clib/type.h>
-
-#include <clib/slab.h>
-
-#include <CUnit/Basic.h>
-
-#define COUNT 10000
-#define SEED 41
-
-static int init_slab(void) {
- return 0;
-}
-
-static int clean_slab(void) {
- return 0;
-}
-
-static void slab_1(void) {
- slab_t s[SLAB_ALLOC_MAX+1] = {INIT_SLAB,};
-
- for (int i=SLAB_ALLOC_MIN; i<=SLAB_ALLOC_MAX; i+=3) {
- slab_init(&s[i], "my_slab", i);
-//slab_dump(&s[i], stdout);
-
- for (int j=0; j<COUNT; j++) {
- void * ptr = slab_alloc(&s[i]);
- memset(ptr, j, i);
- }
-
- slab_delete(&s[i]);
- }
-}
-
-void slab_test(void) {
- CU_pSuite suite = CU_add_suite("slab", init_slab, clean_slab);
- if (NULL == suite)
- return;
-
- if (CU_add_test(suite, "test of --> slab_1", slab_1) == NULL) return;
-}
diff --git a/clib/cunit/slab.h b/clib/cunit/slab.h
deleted file mode 100644
index 7bc86a9..0000000
--- a/clib/cunit/slab.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/cunit/slab.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 */
-
-void slab_test(void);
diff --git a/clib/slab.h b/clib/slab.h
deleted file mode 100644
index 40151a4..0000000
--- a/clib/slab.h
+++ /dev/null
@@ -1,229 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/slab.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 slab.h
- * @brief Slab allocator
- * @details A slab allocator is a bit-mapped allocator for which all allocations are the same size
- * @details For example,
- * @code
- * #include <clib/slab.h>
- *
- * #define SIZE 20000
- *
- * int main(const int argc, const char * argv[]) {
- * slab_t s = INIT_SLAB;
- * slab_init(&s, "my_slab", 16, 4096);
- *
- * void * ptr[SIZE] = {NULL,};
- *
- * int i;
- * for (i=0; i<SIZE; i++) {
- * ptr[i] = slab_alloc(&s);
- * }
- *
- * for (i=0; i<SIZE; i++) {
- * slab_free(&s, ptr[i]);
- * }
- *
- * slab_delete(&s);
- *
- * return 0;
- * }
- * @endcode
- * @author Shaun Wetzstein <shaun@us.ibm.com>
- * @date 2010-2011
- */
-
-#ifndef __SLAB_H__
-#define __SLAB_H__
-
-#include <stdbool.h>
-#include <stdint.h>
-
-#include "ident.h"
-#include "nargs.h"
-#include "tree.h"
-
-/* ======================================================================= */
-
-#define SLAB_MAGIC "SLAB"
-
-#define SLAB_NAME_SIZE 40 //!< Maximum vector name size (in bytes)
-
-#define SLAB_FLAG_LSB 0x01 //!< Little-endian header data
-#define SLAB_FLAG_MSB 0x02 //!< Big-endian header data
-
-#define SLAB_ALLOC_MIN 4
-#define SLAB_ALLOC_MAX 8192
-
-#define INIT_SLAB_HEADER {INIT_IDENT,{0,},0,0,0,0,0,0}
-#define INIT_SLAB {INIT_SLAB_HEADER,INIT_TREE}
-
-/*!
- * @brief Slab allocator header
- */
-struct slab_header {
- ident_t id; //!< identification
- char name[SLAB_NAME_SIZE]; //!< slab name
-
- uint32_t page_size; //!< page size
- uint32_t align_size; //!< page alignment size
- uint32_t page_count; //!< page count
-
- uint32_t alloc_size; //!< allocation size
- uint32_t data_size; //!< data size
- uint32_t bitmap_size; //!< bitmap size
-};
-typedef struct slab_header slab_header_t;
-
-/*!
- * @brief Slab allocator
- */
-struct slab { //!< The slab class
- slab_header_t hdr;
-
- tree_t tree; //!< @private
-};
-typedef struct slab slab_t; //!< Alias for the @em slab class
-
-/* ======================================================================= */
-
-/*!
- * @brief Constructs a @em slab allocator
- * @memberof slab
- * @param self [in] self object
- * @name name [in] name strnig ('\0' terminated)
- * @param alloc_size [in] allocation size (in bytes)
- * @param page_size [in] page size (in bytes)
- * @return None
- */
-/*! @cond */
-#define slab_init(...) STRCAT(slab_init, NARGS(__VA_ARGS__))(__VA_ARGS__)
-extern int slab_init3(slab_t * self, const char *name, uint32_t alloc_size)
-__nonnull((1, 2));
-extern int slab_init4(slab_t * self, const char *name, uint32_t alloc_size,
- size_t page_size) __nonnull((1, 2));
-extern int slab_init5(slab_t * self, const char *name, uint32_t alloc_size,
- size_t page_size, size_t align_size) __nonnull((1, 2));
-/*! @endcond */
-
-/*!
- * @brief Deallocate the memory associated with a @em slab allocator
- * @memberof slab
- * @param self [in] slab object @em self pointer
- * @note Upon success, the cache tree is deallocated from the heap
- * @return None
- */
-extern int slab_delete(slab_t * self)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Allocate first available slot in the @em slab allocator
- * @memberof slab
- * @param self [in] slab object @em self pointer
- * @return non-NULL on success, NULL otherwise
- */
-extern void *slab_alloc(slab_t * self)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Deallocate a slot in the @em slab allocator
- * @memberof slab
- * @param self [in] slab object @em self pointer
- * @param ptr [in] pointer to a slab allocation
- * @note Upon success, a slab slot is deallocated from the slab object
- * @return None
- */
-extern int slab_free(slab_t * self, void *ptr)
-/*! @cond */
-__nonnull((1, 2)) /*! @endcond */ ;
-
-/*!
- * @brief Return the allocation (i.e. slot) size of the @em slab allocator
- * @memberof slab
- * @param self [in] slab object @em self pointer
- * @return non-0 on success, 0 otherwise
- */
-extern size_t slab_alloc_size(slab_t * self)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Return the page (i.e. slot) size of the @em slab allocator
- * @memberof slab
- * @param self [in] slab object @em self pointer
- * @return non-0 on success, 0 otherwise
- */
-extern size_t slab_page_size(slab_t * self)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Return the data size of the @em slab allocator
- * @memberof slab
- * @param self [in] slab object @em self pointer
- * @return non-0 on success, 0 otherwise
- */
-extern size_t slab_data_size(slab_t * self)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Return the map (i.e. slot) size of the @em slab allocator
- * @memberof slab
- * @param self [in] slab object @em self pointer
- * @return non-0 on success, 0 otherwise
- */
-extern size_t slab_bitmap_size(slab_t * self)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Return the alignment size of the @em slab allocator
- * @memberof slab
- * @param self [in] slab object @em self pointer
- * @return non-0 on success, 0 otherwise
- */
-extern size_t slab_align_size(slab_t * self)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Pretty print the contents of a @em slab to stdout
- * @memberof slab
- * @param self [in] slab object @em self pointer
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern void slab_dump(slab_t * self, FILE * out)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/* ======================================================================= */
-
-#endif /* __SLAB_H__ */
diff --git a/clib/src/tree.c b/clib/src/tree.c
index 5cd4c08..e7230a4 100644
--- a/clib/src/tree.c
+++ b/clib/src/tree.c
@@ -43,7 +43,6 @@
#include "libclib.h"
#include "tree.h"
-#include "slab.h"
/* ======================================================================= */
diff --git a/clib/test/slab.c b/clib/test/slab.c
deleted file mode 100644
index 9128768..0000000
--- a/clib/test/slab.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/test/slab.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/slab.h>
-
-#define SIZE 6500
-#define ALLOC 16
-#define PAGE 4096
-
-int main(void) {
- slab_t s = INIT_SLAB;
- slab_init(&s, "my_slab", ALLOC, PAGE);
-
- void * ptr[SIZE] = {NULL,};
-
- int i;
- for (i=0; i<SIZE; i++) {
- ptr[i] = slab_alloc(&s);
- memset(ptr[i], i % 256, ALLOC);
- }
-
- slab_dump(&s, stdout);
-
- for (i=0; i<SIZE; i++) {
- slab_free(&s, ptr[i]);
- }
-
- slab_dump(&s, stdout);
- slab_delete(&s);
-
- return 0;
-}
diff --git a/clib/test/splay.c b/clib/test/splay.c
deleted file mode 100644
index 1704028..0000000
--- a/clib/test/splay.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/test/splay.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/assert.h>
-#include <clib/slab.h>
-#include <clib/type.h>
-#include <clib/tree.h>
-
-struct data {
- tree_node_t node;
- int i;
- float f;
-};
-typedef struct data data_t;
-
-static inline int hash(int key) {
- key = ~key + (key << 15);
- key = key ^ (key >> 12);
- key = key + (key << 2);
- key = key ^ (key >> 4);
- key = key * 2057;
- key = key ^ (key >> 16);
-
- return key;
-}
-
-int main (void) {
- slab_t s = INIT_SLAB;
- slab_init(&s, "my_slab", sizeof(data_t), 4096);
-
- int compare(const int i1, const int i2) {
- return i1 - i2;
- }
-
- tree_t l = INIT_TREE;
- tree_init(&l, (compare_f)compare);
-
- int i;
- for (i=0; i<10000; i++) {
- data_t * d = (data_t *)slab_alloc(&s);
-
- d->i = hash(i);
- d->f = (float)i;
-
- tree_node_init(&d->node, (const void *)d->i);
- splay_insert(&l, &d->node);
- }
-
- tree_dump(&l, stdout);
-
- i = hash(6);
- tree_node_t * n = tree_find(&l, (const void *)i);
- printf("n[%p]\n", n);
-
- data_t * d = container_of(n, data_t, node);
- printf("d->i[%d]\n", d->i);
-
- splay_remove(&l, n);
- n = tree_find(&l, (const void *)i);
- printf("n[%p]\n", n);
-
- i = 2;
- splay_find(&l, (const void *)i);
- i = 8;
- splay_find(&l, (const void *)i);
-
-#if 0
- slab_dump(&s, stdout);
- tree_delete(&l, d, node);
-#endif
-
- tree_dump(&l, stdout);
- slab_delete(&s);
-
- return 0;
-}
-
OpenPOWER on IntegriCloud