summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore22
-rw-r--r--.travis.yml9
-rw-r--r--Makefile39
-rw-r--r--Makefile.am88
-rw-r--r--clib/Makefile34
-rw-r--r--clib/Rules.cunit.mk45
-rw-r--r--clib/Rules.mk74
-rw-r--r--clib/Rules.test.mk93
-rw-r--r--clib/array.h446
-rw-r--r--clib/array_iter.h223
-rw-r--r--clib/assert.h49
-rw-r--r--clib/bitset.h366
-rw-r--r--clib/builtin.h73
-rw-r--r--clib/crc32.h61
-rw-r--r--clib/cunit/map.c308
-rw-r--r--clib/cunit/map.h26
-rw-r--r--clib/cunit/slab.c70
-rw-r--r--clib/cunit/slab.h26
-rw-r--r--clib/cunit/vector.c176
-rw-r--r--clib/cunit/vector.h26
-rw-r--r--clib/db.h449
-rw-r--r--clib/dispatch.h100
-rw-r--r--clib/exception.h306
-rw-r--r--clib/heap.h77
-rw-r--r--clib/map.h245
-rw-r--r--clib/map_iter.h164
-rw-r--r--clib/memory_leak_detection.h378
-rw-r--r--clib/mq.h151
-rw-r--r--clib/queue.h1
-rw-r--r--clib/signal.h79
-rw-r--r--clib/slab.h229
-rw-r--r--clib/src/array.c497
-rw-r--r--clib/src/array_iter.c187
-rw-r--r--clib/src/crc32.c157
-rw-r--r--clib/src/crc32_main.c83
-rw-r--r--clib/src/db.c407
-rw-r--r--clib/src/dispatch.c162
-rw-r--r--clib/src/err.c16
-rw-r--r--clib/src/exception.c152
-rw-r--r--clib/src/heap.c159
-rw-r--r--clib/src/memory_leak_detection.c1275
-rw-r--r--clib/src/mq.c215
-rw-r--r--clib/src/signal.c142
-rw-r--r--clib/src/slab.c24
-rw-r--r--clib/src/table.c686
-rw-r--r--clib/src/table_iter.c145
-rw-r--r--clib/src/timer.c140
-rw-r--r--clib/src/tree.c19
-rw-r--r--clib/src/tree_iter.c1
-rw-r--r--clib/src/vector.c669
-rw-r--r--clib/src/vector_iter.c184
-rw-r--r--clib/src/watch.c142
-rw-r--r--clib/stack.h106
-rw-r--r--clib/table.h279
-rw-r--r--clib/table_iter.h179
-rw-r--r--clib/test/array.c77
-rw-r--r--clib/test/dispatch.c70
-rw-r--r--clib/test/exception.c1
-rw-r--r--clib/test/heap.c45
-rw-r--r--clib/test/map.c83
-rw-r--r--clib/test/mq.c81
-rw-r--r--clib/test/slab.c58
-rw-r--r--clib/test/splay.c103
-rw-r--r--clib/test/table.c109
-rw-r--r--clib/test/vector.c90
-rw-r--r--clib/test/watch.c51
-rw-r--r--clib/timer.h84
-rw-r--r--clib/tree.h1
-rw-r--r--clib/vector.h439
-rw-r--r--clib/vector_iter.h188
-rw-r--r--clib/watch.h94
-rw-r--r--clib/x86/Makefile29
-rw-r--r--clib/x86/cunit/Makefile31
-rw-r--r--clib/x86/test/Makefile31
-rw-r--r--configure.ac43
-rw-r--r--ecc/Makefile34
-rw-r--r--ecc/Rules.mk44
-rw-r--r--ecc/src/main.c1
-rw-r--r--ecc/x86/Makefile30
-rw-r--r--fcp/Makefile34
-rw-r--r--fcp/Rules.mk54
-rw-r--r--fcp/ppc/Makefile33
-rw-r--r--fcp/src/cmd_copy.c1
-rw-r--r--fcp/src/cmd_erase.c1
-rw-r--r--fcp/src/cmd_list.c1
-rw-r--r--fcp/src/cmd_probe.c186
-rw-r--r--fcp/src/cmd_read.c1
-rw-r--r--fcp/src/cmd_trunc.c1
-rw-r--r--fcp/src/cmd_user.c1
-rw-r--r--fcp/src/cmd_write.c1
-rw-r--r--fcp/src/main.c1
-rw-r--r--fcp/src/misc.c1
-rw-r--r--fcp/x86/Makefile31
-rw-r--r--ffs/Makefile34
-rw-r--r--ffs/Rules.mk54
-rw-r--r--ffs/Rules.test.mk49
-rw-r--r--ffs/libffs.h1
-rw-r--r--ffs/src/libffs.c9
-rw-r--r--ffs/src/libffs2.c1
-rw-r--r--ffs/x86/Makefile31
-rw-r--r--fpart/Makefile34
-rw-r--r--fpart/Rules.mk54
-rw-r--r--fpart/Rules.test.mk49
-rwxr-xr-xfpart/fpart.sh4
-rw-r--r--fpart/ppc/Makefile33
-rw-r--r--fpart/src/cmd_add.c2
-rw-r--r--fpart/src/cmd_create.c1
-rw-r--r--fpart/src/cmd_delete.c1
-rw-r--r--fpart/src/cmd_erase.c1
-rw-r--r--fpart/src/cmd_list.c1
-rw-r--r--fpart/src/cmd_trunc.c1
-rw-r--r--fpart/src/cmd_user.c1
-rw-r--r--fpart/src/command.c1
-rw-r--r--fpart/src/main.c1
-rw-r--r--fpart/x86/Makefile31
115 files changed, 194 insertions, 12823 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..6f0ebdb
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,22 @@
+*.a
+aclocal.m4
+ar-lib
+autom4te.cache/
+compile
+config.h
+config.h.in
+config.log
+config.status
+configure
+depcomp
+.deps
+.dirstamp
+ecc/ecc
+fcp/fcp
+fpart/fpart
+install-sh
+Makefile
+Makefile.in
+missing
+*.o
+stamp-h1
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..492c25f
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,9 @@
+language: c
+
+sudo: required
+dist: trusty
+
+script:
+ - autoreconf -i && ./configure && make
+ - PATH=./fpart/:./fcp/:./ffs/:$PATH ./fpart/fpart.sh
+
diff --git a/Makefile b/Makefile
deleted file mode 100644
index b740f9a..0000000
--- a/Makefile
+++ /dev/null
@@ -1,39 +0,0 @@
-# IBM_PROLOG_BEGIN_TAG
-# This is an automatically generated prolog.
-#
-# $Source: Makefile $
-#
-# 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
-SUBDIRS = clib fcp ecc ffs fpart
-
-.PHONY: subdirs $(SUBDIRS)
-subdirs: $(SUBDIRS)
-
-fpart:: ffs clib
-fcp:: ffs clib
-ecc:: clib
-
-$(SUBDIRS)::
- $(MAKE) -C $@ $(MAKECMDGOALS)
-
-all install: $(SUBDIRS)
-
-clean distclean: $(SUBDIRS)
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..c2c7317
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,88 @@
+AM_CFLAGS = -I${srcdir}/clib/ -std=gnu99 -D_GNU_SOURCE -I${srcdir}/ffs/ -fshort-enums -fPIC -D_FILE_OFFSET_BITS=64
+AM_LDFLAGS = -L. -fPIC -Wl,-whole-archive -Wl,-no-whole-archive
+
+bin_PROGRAMS = ecc/ecc fpart/fpart fcp/fcp
+
+noinst_LIBRARIES = libclib.a libffs.a
+
+libclib_a_SOURCES = \
+ clib/src/err.c \
+ clib/src/misc.c \
+ clib/src/ecc.c \
+ clib/src/list.c \
+ clib/src/list_iter.c \
+ clib/src/tree.c \
+ clib/src/tree_iter.c \
+ clib/src/value.c \
+ clib/src/trace_indent.c \
+ clib/src/checksum.c
+
+libffs_a_SOURCES = ffs/src/libffs.c ffs/src/libffs2.c
+
+ecc_ecc_SOURCES = ecc/src/main.c
+ecc_ecc_LDADD = libffs.a libclib.a
+
+fpart_fpart_LDADD = libffs.a libclib.a
+fpart_fpart_SOURCES = \
+ fpart/src/cmd_create.c \
+ fpart/src/cmd_add.c \
+ fpart/src/cmd_delete.c \
+ fpart/src/cmd_list.c \
+ fpart/src/cmd_erase.c \
+ fpart/src/cmd_trunc.c \
+ fpart/src/cmd_user.c \
+ fpart/src/command.c \
+ fpart/src/main.c
+
+fcp_fcp_SOURCES = \
+ fcp/src/cmd_copy.c \
+ fcp/src/cmd_user.c \
+ fcp/src/misc.c \
+ fcp/src/cmd_erase.c \
+ fcp/src/cmd_read.c \
+ fcp/src/cmd_write.c \
+ fcp/src/cmd_list.c \
+ fcp/src/cmd_trunc.c \
+ fcp/src/main.c
+fcp_fcp_LDADD = libffs.a libclib.a
+
+EXTRA_DIST = fpart/fpart.sh LICENSE NOTICE
+
+noinst_HEADERS = \
+./clib/align.h \
+./clib/attribute.h \
+./clib/bb_trace.h \
+./clib/checksum.h \
+./clib/compare.h \
+./clib/cunit/ecc.h \
+./clib/cunit/splay.h \
+./clib/cunit/tree.h \
+./clib/ecc.h \
+./clib/err.h \
+./clib/hash.h \
+./clib/ident.h \
+./clib/libclib.h \
+./clib/list.h \
+./clib/list_iter.h \
+./clib/max.h \
+./clib/min.h \
+./clib/misc.h \
+./clib/nargs.h \
+./clib/raii.h \
+./clib/trace_indent.h \
+./clib/tree_iter.h \
+./clib/type.h \
+./clib/value.h \
+./clib/version.h \
+./clib/builtin.h \
+./clib/queue.h \
+./clib/tree.h \
+./ecc/src/main.h \
+./fcp/src/main.h \
+./fcp/src/misc.h \
+./ffs/ffs.h \
+./ffs/libffs2.h \
+./ffs/src/ffs-fsp.h \
+./ffs/test/test_libffs.h \
+./ffs/libffs.h \
+./fpart/src/main.h
diff --git a/clib/Makefile b/clib/Makefile
deleted file mode 100644
index d4a990b..0000000
--- a/clib/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-# IBM_PROLOG_BEGIN_TAG
-# This is an automatically generated prolog.
-#
-# $Source: clib/Makefile $
-#
-# 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
-SUBDIRS=x86
-
-.PHONY: subdirs $(SUBDIRS)
-
-subdirs: $(SUBDIRS)
-
-$(SUBDIRS)::
- $(MAKE) -C $@ $(MAKECMDGOALS)
-
-all clean install: $(SUBDIRS)
diff --git a/clib/Rules.cunit.mk b/clib/Rules.cunit.mk
deleted file mode 100644
index 9fe4338..0000000
--- a/clib/Rules.cunit.mk
+++ /dev/null
@@ -1,45 +0,0 @@
-# IBM_PROLOG_BEGIN_TAG
-# This is an automatically generated prolog.
-#
-# $Source: clib/Rules.cunit.mk $
-#
-# 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
-CFLAGS += -std=gnu99 -D__USE_GNU -I$(DEPTH)/apps
-LDFLAGS = -rdynamic -L$(DEPTH)/apps/clib/$(ARCH_DEP_DIR)
-
-TARGETS=clib
-
-OBJS=slab.o splay.o map.o vector.o ecc.o tree.o clib.o
-
-vpath %.h ../../src
-vpath %.c ../../cunit
-
-all: $(TARGETS)
-
-clib: $(OBJS) $(DEPTH)/apps/clib/$(ARCH_DEP_DIR)/libclib.a
- $(CC) $(LDFLAGS) -o $@ $^ -lcunit -lrt
-
-clean:
- $(RM) $(OBJS) $(TARGETS)
-
-install:
- $(INSTALL) -d $(CLIB_INSTALL)
- $(INSTALL) $(TARGETS) $(CLIB_INSTALL)
diff --git a/clib/Rules.mk b/clib/Rules.mk
deleted file mode 100644
index 342fd0f..0000000
--- a/clib/Rules.mk
+++ /dev/null
@@ -1,74 +0,0 @@
-# IBM_PROLOG_BEGIN_TAG
-# This is an automatically generated prolog.
-#
-# $Source: clib/Rules.mk $
-#
-# 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
-CFLAGS += -D_GNU_SOURCE -std=gnu99 -fshort-enums -D_FILE_OFFSET_BITS=64
-CFLAGS += -iquote$(DEPTH) -fPIC
-
-LDFLAGS=-L.
-
-# array.o array_iter.o dispatch.o watch.o signal.o heap.o
-
-OBJS = err.o crc32.o misc.o ecc.o \
- exception.o slab.o \
- list.o list_iter.o \
- tree.o tree_iter.o \
- vector.o vector_iter.o \
- table.o table_iter.o \
- value.o mq.o \
- memory_leak_detection.o \
- trace_indent.o checksum.o
-
-
-TARGETS=libclib.so libclib.a crc32
-
-vpath %.c ../src
-vpath %.h ..
-
-all: $(TARGETS)
-
-libclib.so: $(OBJS)
- $(CC) $(LDFLAGS) -shared -Wl,-soname,$@ -o $@ $^ -lpthread \
- -lrt
-
-libclib.a: $(OBJS)
- $(AR) -r $@ $^
-
-db.o: db.c db.h
- $(CC) $(CFLAGS) -DSQLITE3 -c $^
-
-crc32: crc32.c crc32_main.c
- $(CC) $(CFLAGS) -o $@ $^
-
-clean distclean:
- $(RM) *.so *.o *.gch *.CKP *.lst $(TARGETS)
- $(RM) html latex
-
-install: $(TARGETS) ../*.h
- $(INSTALL) -d $(CLIB_INSTALL)/include/clib $(CLIB_INSTALL)/{bin,lib}
- $(INSTALL) ../crc32.h $(CLIB_INSTALL)/include
- $(INSTALL) ../*.h $(CLIB_INSTALL)/include/clib
- $(INSTALL) libclib.so libclib.a $(CLIB_INSTALL)/lib
- $(INSTALL) crc32 $(CLIB_INSTALL)/bin
- $(MAKE) -C test $@
- $(MAKE) -C cunit $@
diff --git a/clib/Rules.test.mk b/clib/Rules.test.mk
deleted file mode 100644
index bcb1fb1..0000000
--- a/clib/Rules.test.mk
+++ /dev/null
@@ -1,93 +0,0 @@
-# IBM_PROLOG_BEGIN_TAG
-# This is an automatically generated prolog.
-#
-# $Source: clib/Rules.test.mk $
-#
-# 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
-CFLAGS += -std=gnu99 -D__USE_GNU -I$(DEPTH)/apps
-LDFLAGS = -rdynamic -L$(DEPTH)/apps/clib/$(ARCH_DEP_DIR)
-
-TARGETS=exception \
- slab \
- list \
- ecc \
- tree \
- splay \
- map \
- table \
- mq \
- vector \
- checksum \
- err
-
-vpath %.h ../../src
-vpath %.c ../../test
-
-all: $(TARGETS)
-
-exception: exception.o ../libclib.so
- $(CC) $(LDFLAGS) -o $@ $^
-
-slab: slab.o ../libclib.so
- $(CC) $(LDFLAGS) -o $@ $^
-
-list: list.o ../libclib.so
- $(CC) $(LDFLAGS) -o $@ $^
-
-tree: tree.o ../libclib.so
- $(CC) $(LDFLAGS) -o $@ $^
-
-splay: splay.o ../libclib.so
- $(CC) $(LDFLAGS) -o $@ $^
-
-map: map.o ../libclib.so
- $(CC) $(LDFLAGS) -o $@ $^
-
-mq: mq.o ../libclib.so
- $(CC) $(LDFLAGS) -o $@ $^
-
-table: table.o ../libclib.so
- $(CC) $(LDFLAGS) -o $@ $^
-
-watch: watch.o ../libclib.so
- $(CC) $(LDFLAGS) -o $@ $^
-
-dispatch: dispatch.o ../libclib.so
- $(CC) $(LDFLAGS) -o $@ $^
-
-vector: vector.o ../libclib.so
- $(CC) $(LDFLAGS) -o $@ $^
-
-checksum: checksum.o ../libclib.so
- $(CC) $(LDFLAGS) -o $@ $^
-
-err: err.o ../libclib.so
- $(CC) $(LDFLAGS) -o $@ $^
-
-ecc: ecc.o ../libclib.so
- $(CC) $(LDFLAGS) -o $@ $^
-
-clean:
- $(RM) $(TARGETS:=.o) $(TARGETS)
-
-install:
- $(INSTALL) -d $(CLIB_INSTALL)
- $(INSTALL) $(TARGETS) $(CLIB_INSTALL)
diff --git a/clib/array.h b/clib/array.h
deleted file mode 100644
index 4a70843..0000000
--- a/clib/array.h
+++ /dev/null
@@ -1,446 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/array.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 array.h
- * @brief Array container
- * @details An array class whose elements are partitioned into data `pages'
- * that are allocated upon first-touch, possibly leading to a pages
- * that are sparsely populated.
- * @details For example,
- * @code
- * #include <clib/array.h>
- * #include <clib/array_iter.h>
- *
- * int main(const int argc, const char * argv[]) {
- * array_t a;
- * array_init(&a, 4, 1024);
- *
- * array_dump(&a, stdout);
- *
- * array_put(&a, 52, (uint32_t[]){52});
- * array_put(&a, 53, (uint32_t[]){53});
- * array_put(&a, 167, (uint32_t[]){167});
- * array_put(&a, 223, (uint32_t[]){223});
- * array_put(&a, 78, (uint32_t[]){78});
- * array_put(&a, 205, (uint32_t[]){205});
- * array_put(&a, 183, (uint32_t[]){183});
- * array_put(&a, 150, (uint32_t[]){150});
- * array_put(&a, 90, (uint32_t[]){90});
- * array_put(&a, 66, (uint32_t[]){66});
- * array_put(&a, 91, (uint32_t[]){91});
- * array_put(&a, 45, (uint32_t[]){45});
- * array_put(&a, 211, (uint32_t[]){211});
- *
- * uint32_t arr[] = {985,986,987,988,990,991,992,993,994};
- * array_put(&a, 985, arr, 9);
- *
- * array_iter_t it;
- * array_iter_init(&it, &a, AI_FLAG_FWD);
- *
- * uint32_t * j;
- * array_for_each(&it, j) {
- * printf("arr[%d]\n", *j);
- * }
- *
- * array_dump(&a, stdout);
- * array_delete(&a);
- *
- * return 0;
- * }
- * @endcode
- * @author Shaun Wetzstein <shaun@us.ibm.com>
- * @date 2010-2011
- */
-
-#ifndef __ARRAY_H__
-#define __ARRAY_H__
-
-#include <stdbool.h>
-#include <stdint.h>
-
-#include "builtin.h"
-#include "mqueue.h"
-#include "tree.h"
-#include "nargs.h"
-
-/* ======================================================================= */
-
-typedef struct array array_t; //!< Alias for the @em array class
-
-/*!
- * @brief Array container class
- */
-struct array {
- uint32_t magic; //!< Array magic number
-
- uint32_t page_size; //!< Array data page size (in bytes)
-
- uint16_t elem_size; //!< Array element size (in bytes)
- uint16_t elem_num; //!< Array element count (per page)
-
- size_t size; //!< Number of initialized elements
- size_t pages; //!< Number of data pages allocated (currently)
-
- size_t low; //!< @private
- size_t high; //!< @private
-
- size_t map_size; //!< @private
- tree_t tree; //!< @private
-};
-
-/* ======================================================================= */
-
-/*!
- * @brief Constructs an @em array container object
- * @details For example,
- * @code
- * ...
- * array_t ar;
- * array_init(&ar, 4, 1024);
- * ...
- * @endcode
- * @memberof array
- * @param self [in] array object @em self pointer
- * @param elem_size [in] array element size, in bytes
- * @param elem_num [in] array element number, per data page
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern void array_init(array_t * self, size_t elem_size, size_t elem_num)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Destructs an @em array container object
- * @details Deallocate all backing storage associated with this \em array object
- * @details For example,
- * @code
- * ...
- * array_init(&ar, 4, 1024);
- * array_put(&ar, 524, &count);
- * array_delete(&ar);
- * ...
- * @endcode
- * @memberof array
- * @param self [in] array object @em self pointer
- * @return None
- */
-extern void array_delete(array_t * self)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Returns a reference to the element at position @em idx in the @em array
- * @details For example,
- * @code
- * ...
- * array_init(&ar, 4, 1024);
- * array_put(&ar, 524, &count);
- * printf("ar[524] = %d\n", *(int *)array_at(&ar, 524));
- * array_delete(&ar);
- * ...
- * @endcode
- * @memberof array
- * @param self [in] array object @em self pointer
- * @param elem_num [in] array element index
- * @return Reference to array element at @em idx on SUCCESS
- * @throws UNEXPECTED if @em self pointer is NULL
- * @throws UNEXPECTED if array element at @em idx is uninitialized
- */
-extern const void *array_at(array_t * self, size_t elem_num)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @fn void array_get(array_t * self, size_t elem_off, const void * ptr, size_t elem_num=1)
- * @brief Copy content from the @em array
- * @details Copies @em elem_num element(s) starting at position @em elem_off in the source @em array to destination pointer @em ptr
- * @note If the fourth parameter is omitted, it defaults to 1
- * @details For example,
- * @code
- * ...
- * array_init(&ar, 4, 1024);
- * array_put(&ar, 524, &count);
- * array_get(&ar, 524, &count);
- * array_delete(&ar);
- * ...
- * @endcode
- * @memberof array
- * @param self [in] array object @em self pointer
- * @param elem_off [in] array element index
- * @param ptr [out] Destination storage pointer
- * @param elem_num [in] Desgination element count (optional)
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-/*! @cond */
-#define array_put(...) STRCAT(array_put, NARGS(__VA_ARGS__))(__VA_ARGS__)
-extern void array_get3(array_t * self, size_t elem_off, void *ptr)
-/*! @cond */
-__nonnull((1, 3)) /*! @endcond */ ;
-extern void array_get4(array_t * self, size_t elem_off, void *ptr,
- size_t elem_num)
-/*! @cond */
-__nonnull((1, 3)) /*! @endcond */ ;
-/*! @endcond */
-
-/*!
- * @fn void array_put(array_t * self, size_t elem_off, const void * ptr, size_t elem_num=1)
- * @brief Assign new content to the @em array
- * @details Copies @em elem_num element(s) from source pointer @em ptr to the destination @em array starting at position @em elem_off
- * @note If the fourth parameter is omitted, it defaults to 1
- * @details For example,
- * @code
- * ...
- * array_init(&ar, 4, 1024);
- * array_put(&ar, 524, &count);
- * array_get(&ar, 524, &count);
- * array_delete(&ar);
- * ...
- * @endcode
- * @memberof array
- * @param self [in] array object @em self pointer
- * @param elem_off [in] array element index
- * @param ptr [in] Source storage pointer
- * @param elem_num [in] Source element count (optional)
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-/*! @cond */
-#define array_put(...) STRCAT(array_put, NARGS(__VA_ARGS__))(__VA_ARGS__)
-extern void array_put3(array_t * self, size_t elem_off, const void *ptr)
-/*! @cond */
-__nonnull((1, 3)) /*! @endcond */ ;
-extern void array_put4(array_t * self, size_t elem_off, const void *ptr,
- size_t elem_num)
-/*! @cond */
-__nonnull((1, 3)) /*! @endcond */ ;
-/*! @endcond */
-
-/*!
- * @fn bool array_status(array_t * self, size_t elem_num, bool state)
- * @brief Set or return the initialized status of the @em array element at position @em idx
- * @note If the third parameter is omitted, the element's current status is returned
- * @details For example,
- * @code
- * ...
- * array_init(&ar, 4, 1024);
- * array_put(&ar, 524, &count);
- * printf("%d %d\n", array_status(&ar, 524), array_status(&ar, 600));
- * array_delete(&ar);
- * ...
- * @endcode
- * @memberof array
- * @param self [in] array object @em self pointer
- * @param elem_num [in] array element index
- * @param state [in] Element state (optional)
- * @return None
- * @throws UNEXPECTED if @em idx is out of bounds
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-/*! @cond */
-#define array_status(...) STRCAT(array_status, NARGS(__VA_ARGS__))(__VA_ARGS__)
-extern bool array_status2(array_t * self, size_t elem_num)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-extern bool array_status3(array_t * self, size_t elem_num, bool state)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-/*! @endcond */
-
-/*!
- * @fn size_t array_size(array_t * self, size_t size = 1)
- * @brief Return or set the size of the @em array
- * @details Return or set the number of allocated elements in the @em array
- * @details For example,
- * @code
- * ...
- * array_init(&ar, 4, 1024);
- * array_size(&ar, 2040);
- * array_delete(&ar);
- * ...
- * @endcode
- * @memberof array
- * @param self [in] array object @em self pointer
- * @param size [in] New array size
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-#define array_size(...) STRCAT(array_size, NARGS(__VA_ARGS__))(__VA_ARGS__)
-extern size_t array_size1(array_t * self)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-extern void array_size2(array_t * self, size_t size)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Return pages of the @em array container
- * @details Return the number of pages in the @em array container
- * @details For example,
- * @code
- * ...
- * array_init(&ar, 4, 1024);
- * array_size(&ar, 2040);
- * printf("pages = %d\n", array_pages(&ar));
- * array_delete(&ar);
- * ...
- * @endcode
- * @memberof array
- * @param self [in] array object @em self pointer
- * @return The number of pages that conform the array's content
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern size_t array_pages(array_t * self)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Return capacity of the @em array
- * @details Return the number of allocated and unallocated elements in the @em array container
- * @details For example,
- * @code
- * ...
- * array_init(&ar, 4, 1024);
- * array_size(&ar, 2040);
- * printf("capacity = %d\n", array_capacity(&ar));
- * array_delete(&ar);
- * ...
- * @endcode
- * @memberof array
- * @param self [in] array object @em self pointer
- * @return The number of total elements that conform the array's content
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern size_t array_capacity(array_t * self)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Return @em array index lower bound
- * @details For example,
- * @code
- * ...
- * array_init(&ar, 4, 1024);
- * array_put(&ar, 7, &count);
- * array_put(&ar, 7000, &count);
- * printf("low = %d\n", array_low(&ar));
- * array_delete(&ar);
- * ...
- * @endcode
- * @memberof array
- * @param self [in] array object @em self pointer
- * @return non-0 on success
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern size_t array_low(array_t * self)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Return @em array index upper bound
- * @details For example,
- * @code
- * ...
- * array_init(&ar, 4, 1024);
- * array_put(&ar, 7, &count);
- * array_put(&ar, 7000, &count);
- * printf("high = %d\n", array_high(&ar));
- * array_delete(&ar);
- * ...
- * @endcode
- * @memberof array
- * @param self [in] array object @em self pointer
- * @return non-0 on success
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern size_t array_high(array_t * self)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Send (write) an @em array object to a message queue
- * @details For example,
- * @code
- * ...
- * array_init(&ar, 4, 1024);
- * array_put(&ar, 7, &count);
- * array_put(&ar, 7000, &count);
- * ...
- * mqueue mq;
- * mqueue_init(&mq, "my_server");
- * mqueue_create(&mq, gettid());
- * ...
- * array_send(&ar, &mq);
- * array_delete(&ar);
- * ...
- * @endcode
- * @memberof array
- * @param self [in] array object @em self pointer
- * @return non-0 on success
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern void array_send(array_t * self, mqueue_t * mq)
-/*! @cond */
-__nonnull((1, 2)) /*! @endcond */ ;
-
-/*!
- * @brief receive (read) an @em array object from a message queue
- * @details For example,
- * @code
- * ...
- * array ar;
- * ...
- * mqueue mq;
- * mqueue_open(&mq, path);
- * ...
- * array_receive(&ar, &mq);
- * array_dump(&ar);
- * ...
- * @endcode
- * @memberof array
- * @param self [in] array object @em self pointer
- * @return non-0 on success
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern void array_receive(array_t * self, mqueue_t * mq)
-/*! @cond */
-__nonnull((1, 2)) /*! @endcond */ ;
-
-/*!
- * @brief Pretty print the contents of an @em array to stdout
- * @memberof array
- * @param self [in] array object @em self pointer
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern void array_dump(array_t * self, FILE * out)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/* ======================================================================= */
-
-#endif /* __ARRAY_H__ */
diff --git a/clib/array_iter.h b/clib/array_iter.h
deleted file mode 100644
index 6eaa370..0000000
--- a/clib/array_iter.h
+++ /dev/null
@@ -1,223 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/array_iter.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 array_iter.h
- * @brief Sparse Array Iterator
- * @details An array class whose elements are partitioned into data `pages'
- * that are allocated upon first-touch.
- * @code
- * ...
- * array_t arr;
- * array_init(&arr, sizeof(uint32_t), 1024);
- * ...
- * array_iter_t it;
- * array_iter_init(&it, &arr, VI_FLAG_FWD);
- *
- * uint32_t * j;
- * array_for_each(&it, j) {
- * printf("arr[%d] = %d\n", it.idx, *j);
- * }
- * ...
- * @endcode
- * @author Shaun Wetzstein <shaun@us.ibm.com>
- * @date 2010-2011
- */
-
-#ifndef __ARRAY_ITER_H__
-#define __ARRAY_ITER_H__
-
-#include <stdbool.h>
-#include <stdint.h>
-
-#include "builtin.h"
-#include "array.h"
-
-/* ======================================================================= */
-
-typedef struct array_iter array_iter_t; //!< Alias for the @em array_iter class
-
-/*!
- * @brief Array iterator
- * @details Array iterator class
-*/
-struct array_iter {
- array_t *array; //!< Reference to the target array object
- int32_t idx; //!< Current position of the iterator
- uint32_t flags; //!< Iterator configuration flags
-};
-
-/* ======================================================================= */
-
-#define AI_FLAG_NONE 0x00000000 //!< No flag mask
-#define AI_FLAG_FWD 0x00000000 //!< Forward (FWD) flag mask
-#define AI_FLAG_BWD 0x00000002 //!< Backward (BWD) flag mask
-#define AI_FLAG_MASK 0x00000003 //!< All flags mask
-
-/*!
- * @brief Initializes an @em array_iter iterator object
- * @details For example,
- * @code
- * ...
- * array_t ar;
- * array_init(&ar, 4, 1024);
- * ...
- * array_iter_t it;
- * array_iter_init(&it, &ar, AI_FLAG_FWD);
- * ...
- * @endcode
- * @memberof array_iter
- * @param self [in] array_iter object @em self pointer
- * @param array [in] array container object to iterate
- * @param flags [in] iterator configuration flags
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- * @throws UNEXPECTED if @em array pointer is NULL
- */
-extern void array_iter_init(array_iter_t * self, array_t * array,
- uint32_t flags)
-/*! @cond */
-__nonnull((1, 2)) /*! @endcond */ ;
-
-/*!
- * @brief Resets an @em array iterator object
- * @details For example,
- * @code
- * ...
- * array_t ar;
- * array_init(&ar, 4, 1024);
- * ...
- * array_iter_t it;
- * array_iter_init(&it, &ar, AI_FLAG_FWD);
- * array_iter_clear(&it);
- * ...
- * @endcode
- * @memberof array_iter
- * @param self [in] array_iter object @em self pointer
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern void array_iter_clear(array_iter_t * self)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Return a pointer to @em array element bytes at the current iterator position
- * @details For example,
- * @code
- * ...
- * array_t ar;
- * array_init(&ar, 4, 1024);
- * ...
- * array_iter_t it;
- * array_iter_init(&it, &ar, AI_FLAG_FWD);
- * ...
- * data_t * d = (data_t *)array_iter_elem(&it);
- * ...
- * @endcode
- * @memberof array_iter
- * @param self [in] array_iter object @em self pointer
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern const void *array_iter_elem(array_iter_t * self)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @fn const void * array_iter_inc(array_iter_t * self, size_t count = 1)
- * @brief Increment the position of an @em array iterator
- * @details If the second (2nd) parameter is omitted, the iterator is incremented by one (1) position.
- * @details For example,
- * @code
- * ...
- * array_t ar;
- * array_init(&ar, 4, 1024);
- * ...
- * array_iter_t it;
- * array_iter_init(&it, &ar, AI_FLAG_FWD);
- * array_iter_inc(&it);
- * ...
- * @endcode
- * @memberof array_iter
- * @param self [in] array_iter object @em self pointer
- * @param count [in] Number of positions to increment (optional)
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-/*! @cond */
-#define array_iter_inc(...) STRCAT(array_iter_inc, NARGS(__VA_ARGS__))(__VA_ARGS__)
-extern const void *array_iter_inc1(array_iter_t * self)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-extern const void *array_iter_inc2(array_iter_t * self, size_t count)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-/*! @endcond */
-
-/*!
- * @fn const void * array_iter_dec(array_iter_t * self, size_t count = 1)
- * @brief decrement the position of an @em array iterator
- * @note If the second (2nd) parameter is omitted, the iterator is decremented by one (1) position.
- * @details For example,
- * @code
- * ...
- * array_t ar;
- * array_init(&ar, 4, 1024);
- * ...
- * array_iter_t it;
- * array_iter_init(&it, &ar, AI_FLAG_FWD);
- * array_iter_dec(&it, 3);
- * ...
- * @endcode
- * @memberof array_iter
- * @param self [in] array_iter object @em self pointer
- * @param count [in] Number of positions to decrement (optional)
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-/*! @cond */
-#define array_iter_dec(...) STRCAT(array_iter_dec, NARGS(__VA_ARGS__))(__VA_ARGS__)
-extern const void *array_iter_dec1(array_iter_t * self)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-extern const void *array_iter_dec2(array_iter_t * self, size_t count)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-/*! @endcond */
-
-/*!
- * @def array_for_each(it, i)
- * @hideinitializer
- * @brief Array for-each algorithm
- * @param it [in] Tree iterator object
- * @param i [in] Tree element variable
- */
-#define array_for_each(it, i) \
- for (i = (typeof(i))array_iter_elem(it); \
- i != NULL; \
- i = (typeof(i))array_iter_inc(it, 1))
-
-/* ======================================================================= */
-
-#endif /* __ARRAY_ITER_H__ */
diff --git a/clib/assert.h b/clib/assert.h
deleted file mode 100644
index 421d074..0000000
--- a/clib/assert.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/assert.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 assert.h
- * @brief Assertion helpers
- * @author Shaun Wetzstein <shaun@us.ibm.com>
- * @date 2010-2011
- */
-
-#ifdef assert
-#undef assert
-#endif
-
-/*!
- * @def assert(e)
- * @hideinitializer
- * @brief Check for program assertion failures
- * @param e [in] assertion expression
- * @throws ASSERTION iff expression @em e evaluates @em false
- */
-
-#ifdef NDEBUG
-#define assert(e) ((void)0)
-#else
-#include "exception.h"
-#define assert(e) ((void)((e) ? (void)0 : throw_bytes(ASSERTION, __STRING((e)), strlen(__STRING((e))))))
-#endif
diff --git a/clib/bitset.h b/clib/bitset.h
deleted file mode 100644
index 04b5b4f..0000000
--- a/clib/bitset.h
+++ /dev/null
@@ -1,366 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/bitset.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 bitset.h
- * @brief bitset container
- * @details bitsets are a special container that are design to store
- * bits (elements with only 2 possible values: 0 or 1)
- * @details For example,
- * @code
- * #include <clib/bitset.h>
- * #include <clib/bitset_iter.h>
- *
- * int main(const int argc, const char * argv[]) {
- * bitset_t a;
- * bitset_init(&a, 4, 1024);
- *
- * bitset_size(&a, 10);
- *
- * int i;
- * for (i=0; i<10; i++)
- * bitset_put(&a, i, &i);
- * bitset_put(&a, 223, (uint32_t[]){223});
- *
- * bitset_iter_t it;
- * bitset_iter_init(&it, &a, VI_FLAG_FWD);
- *
- * uint32_t * j;
- * bitset_for_each(&it, j) {
- * printf("vec[%d]\n", *j);
- * }
- *
- * bitset_dump(&a, stdout);
- * bitset_delete(&a);
- *
- * return 0;
- * }
- * @endcode
- * @author Shaun Wetzstein <shaun@us.ibm.com>
- * @date 2010-2011
- */
-
-#ifndef __bitset_H__
-#define __bitset_H__
-
-#include <stdbool.h>
-#include <stdint.h>
-
-#include "builtin.h"
-
-#include "nargs.h"
-#include "mqueue.h"
-#include "tree.h"
-
-/* ======================================================================= */
-
-typedef struct bitset bitset_t; //!< Alias for the @em bitset class
-
-/*!
- * @brief bitset container
- * @details bitset container
- */
-struct bitset { //! The bitset class
- uint32_t magic; //!< bitset magic number
-
- uint32_t page_size; //!< bitset data page size (in bytes)
-
- uint16_t elem_size; //!< bitset element size (in bytes)
- uint16_t elem_num; //!< bitset element count (per page)
-
- size_t size; //!< Number of initialized elements
- size_t pages; //!< Number of data pages allocated (currently)
-
- tree_t tree; //!< @private
-};
-
-/* ======================================================================= */
-
-/*!
- * @brief Constructs an @em bitset container object
- * @details For example,
- * @code
- * ...
- * bitset_t ar;
- * bitset_init(&ar, 4, 1024);
- * ...
- * @endcode
- * @memberof bitset
- * @param self [in] bitset object @em self pointer
- * @param elem_size [in] bitset element size, in bytes
- * @param elem_num [in] bitset element number, per data page
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-/*! @cond */
-#define bitset_init(...) STRCAT(bitset_init, NARGS(__VA_ARGS__))(__VA_ARGS__)
-extern void bitset_init2(bitset_t * self, size_t elem_size)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-extern void bitset_init3(bitset_t * self, size_t elem_size, size_t page_size)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-/*! @endcond */
-
-/*!
- * @brief Destructs an @em bitset container object
- * @details Deallocate all backing storage associated with this \em bitset object
- * @details For example,
- * @code
- * ...
- * bitset_init(&ar, 4, 1024);
- * bitset_put(&ar, 524, &count);
- * bitset_delete(&ar);
- * ...
- * @endcode
- * @memberof bitset
- * @param self [in] bitset object @em self pointer
- * @return None
- */
-extern void bitset_delete(bitset_t * self)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Returns a reference to the element at position @em idx in the @em bitset
- * @details For example,
- * @code
- * ...
- * bitset_init(&ar, 4, 1024);
- * bitset_put(&ar, 524, &count);
- * printf("ar[524] = %d\n", *(int *)bitset_at(&ar, 524));
- * bitset_delete(&ar);
- * ...
- * @endcode
- * @memberof bitset
- * @param self [in] bitset object @em self pointer
- * @param elem_num [in] bitset element index
- * @return Reference to bitset element at @em idx on SUCCESS
- * @throws UNEXPECTED if @em self pointer is NULL
- * @throws UNEXPECTED if bitset element at @em idx is uninitialized
- */
-extern const void *bitset_at(bitset_t * self, size_t elem_num)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @fn void bitset_get(bitset_t * self, size_t elem_off, const void * ptr, size_t elem_num=1)
- * @brief Copy content from the @em bitset
- * @details Copies @em elem_num element(s) starting at position @em elem_off in the source @em bitset to destination pointer @em ptr
- * @note If the fourth parameter is omitted, it defaults to 1
- * @details For example,
- * @code
- * ...
- * bitset_init(&ar, 4, 1024);
- * bitset_put(&ar, 524, &count);
- * bitset_get(&ar, 524, &count);
- * bitset_delete(&ar);
- * ...
- * @endcode
- * @memberof bitset
- * @param self [in] bitset object @em self pointer
- * @param elem_off [in] bitset element index
- * @param ptr [out] Destination storage pointer
- * @param elem_num [in] Desgination element count (optional)
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-/*! @cond */
-#define bitset_get(...) STRCAT(bitset_get, NARGS(__VA_ARGS__))(__VA_ARGS__)
-extern void bitset_get3(bitset_t * self, size_t elem_off, void *ptr)
-/*! @cond */
-__nonnull((1, 3)) /*! @endcond */ ;
-extern void bitset_get4(bitset_t * self, size_t elem_off, void *ptr,
- size_t elem_num)
-/*! @cond */
-__nonnull((1, 3)) /*! @endcond */ ;
-/*! @endcond */
-
-/*!
- * @fn void bitset_put(bitset_t * self, size_t elem_off, const void * ptr, size_t elem_num=1)
- * @brief Assign new content to the @em bitset
- * @details Copies @em elem_num element(s) from source pointer @em ptr to the destination @em bitset starting at position @em elem_off
- * @note If the fourth parameter is omitted, it defaults to 1
- * @details For example,
- * @code
- * ...
- * bitset_init(&ar, 4, 1024);
- * bitset_put(&ar, 524, &count);
- * bitset_get(&ar, 524, &count);
- * bitset_delete(&ar);
- * ...
- * @endcode
- * @memberof bitset
- * @param self [in] bitset object @em self pointer
- * @param elem_off [in] bitset element index
- * @param ptr [in] Source storage pointer
- * @param elem_num [in] Source element count (optional)
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-/*! @cond */
-#define bitset_put(...) STRCAT(bitset_put, NARGS(__VA_ARGS__))(__VA_ARGS__)
-extern void bitset_put3(bitset_t * self, size_t elem_off, const void *ptr)
-/*! @cond */
-__nonnull((1, 3)) /*! @endcond */ ;
-extern void bitset_put4(bitset_t * self, size_t elem_off, const void *ptr,
- size_t elem_num)
-/*! @cond */
-__nonnull((1, 3)) /*! @endcond */ ;
-/*! @endcond */
-
-/*!
- * @fn size_t bitset_size(bitset_t * self, size_t size = 1)
- * @brief Return or set the size of the @em bitset
- * @details Return or set the number of allocated elements in the @em bitset
- * @details For example,
- * @code
- * ...
- * bitset_init(&ar, 4, 1024);
- * bitset_size(&ar, 2040);
- * bitset_delete(&ar);
- * ...
- * @endcode
- * @memberof bitset
- * @param self [in] bitset object @em self pointer
- * @param size [in] New bitset size
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-/*! @cond */
-#define bitset_size(...) STRCAT(bitset_size, NARGS(__VA_ARGS__))(__VA_ARGS__)
-extern size_t bitset_size1(bitset_t * self)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-extern void bitset_size2(bitset_t * self, size_t size)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-/*! @endcond */
-
-/*!
- * @brief Return pages of the @em bitset container
- * @details Return the number of pages in the @em bitset container
- * @details For example,
- * @code
- * ...
- * bitset_init(&ar, 4, 1024);
- * bitset_size(&ar, 2040);
- * printf("pages = %d\n", bitset_pages(&ar));
- * bitset_delete(&ar);
- * ...
- * @endcode
- * @memberof bitset
- * @param self [in] bitset object @em self pointer
- * @return The number of pages that conform the bitset's content
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern size_t bitset_pages(bitset_t * self)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Return capacity of the @em bitset
- * @details Return the number of allocated and unallocated elements in the @em bitset container
- * @details For example,
- * @code
- * ...
- * bitset_init(&ar, 4, 1024);
- * bitset_size(&ar, 2040);
- * printf("capacity = %d\n", bitset_capacity(&ar));
- * bitset_delete(&ar);
- * ...
- * @endcode
- * @memberof bitset
- * @param self [in] bitset object @em self pointer
- * @return The number of total elements that conform the bitset's content
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern size_t bitset_capacity(bitset_t * self)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Send (write) an @em bitset object to a message queue
- * @details For example,
- * @code
- * ...
- * bitset_init(&ar, 4, 1024);
- * bitset_put(&ar, 7, &count);
- * bitset_put(&ar, 7000, &count);
- * ...
- * mqueue mq;
- * mqueue_init(&mq, "my_server");
- * mqueue_create(&mq, gettid());
- * ...
- * bitset_send(&ar, &mq);
- * bitset_delete(&ar);
- * ...
- * @endcode
- * @memberof bitset
- * @param self [in] bitset object @em self pointer
- * @return non-0 on success
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern void bitset_send(bitset_t * self, mqueue_t * mq)
-/*! @cond */
-__nonnull((1, 2)) /*! @endcond */ ;
-
-/*!
- * @brief receive (read) an @em bitset object from a message queue
- * @details For example,
- * @code
- * ...
- * bitset ar;
- * ...
- * mqueue mq;
- * mqueue_open(&mq, path);
- * ...
- * bitset_receive(&ar, &mq);
- * bitset_dump(&ar);
- * ...
- * @endcode
- * @memberof bitset
- * @param self [in] bitset object @em self pointer
- * @return non-0 on success
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern void bitset_receive(bitset_t * self, mqueue_t * mq)
-/*! @cond */
-__nonnull((1, 2)) /*! @endcond */ ;
-
-/*!
- * @brief Pretty print the contents of an @em bitset to stdout
- * @memberof bitset
- * @param self [in] bitset object @em self pointer
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern void bitset_dump(bitset_t * self, FILE * out)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/* ======================================================================= */
-
-#endif /* __bitset_H__ */
diff --git a/clib/builtin.h b/clib/builtin.h
index 5a7ac08..79692f4 100644
--- a/clib/builtin.h
+++ b/clib/builtin.h
@@ -33,31 +33,6 @@
#define __BUILTIN_H__
/*!
- * @def likely(x)
- * @hideinitializer
- * @brief Indicate an expression is likely to occur
- * @param x [in] Expression
- */
-#define likely(x) __builtin_expect(!!(x), 1)
-
-/*!
- * @def unlikely(x)
- * @hideinitializer
- * @brief Indicate an expression is unlikely to occur
- * @param x [in] Expression
- */
-#define unlikely(x) __builtin_expect(!!(x), 0)
-
-/*!
- * @def parity(x)
- * @hideinitializer
- * @brief Return parity of the input
- * @param x [in] Object
- */
-#define parity(x) __builtin_parity((x))
-#define ffs(x) __builtin_ffs((x))
-
-/*!
* @def popcount(x)
* @hideinitializer
* @brief Return number of 0b'1' bits of an int
@@ -66,54 +41,6 @@
#define popcount(x) __builtin_popcount((x))
/*!
- * @def ctz(x)
- * @hideinitializer
- * @brief Count trailing zeros of an int
- * @param x [in] @em int value
- */
-#define ctz(x) __builtin_ctz((x))
-
-/*!
- * @def ctzl(x)
- * @hideinitializer
- * @brief Count trailing zeros of a long
- * @param x [in] @em long value
- */
-#define ctzl(x) __builtin_ctzl((x))
-
-/*!
- * @def ctzll(x)
- * @hideinitializer
- * @brief Count trailing zeros of a long long
- * @param x [in] @em long @em long value
- */
-#define ctzll(x) __builtin_ctzll((x))
-
-/*!
- * @def clz(x)
- * @hideinitializer
- * @brief Count leading zeros of an int
- * @param x [in] @em int value
- */
-#define clz(x) __builtin_clzl((x))
-
-/*!
- * @def clzl(x)
- * @hideinitializer
- * @brief Count leading zeros of a long
- * @param x [in] @em long value
- */
-#define clzl(x) __builtin_clzl((x))
-
-/*!
- * @def clzll(x)
- * @hideinitializer
- * @brief Count leading zeros of a long long
- * @param x [in] @em long long value
- */
-#define clzll(x) __builtin_clzll((x))
-
-/*!
* @def caller(x)
* @hideinitializer
* @brief Return callers return address
diff --git a/clib/crc32.h b/clib/crc32.h
deleted file mode 100644
index e83226c..0000000
--- a/clib/crc32.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/crc32.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 crc32.h
- * @brief 32-bit CRC
- * @details Gary Brown's CRC32 algorithm for polynomial:
- * X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0
- * @author Gary Brown
- * @date 2010-2011
- */
-
-#ifndef __CRC32_H__
-#define __CRC32_H__
-
-#include <stddef.h>
-#include <stdint.h>
-
-/*!
- * @brief Compute a 32-bit CRC value for an octet
- * @param c [in] Input data (octet)
- * @param crc [in] Input 32-bit CRC value
- * @return 32-bit CRC value
- */
-extern uint32_t clib_crc32(unsigned char c, uint32_t crc);
-
-/*!
- * @brief Copy bytes from the source reference to the destination reference
- * while computing a 32-bit CRC
- * @param __dst [in] Destination reference
- * @param __src [in] Source reference
- * @param __n [in] Number of bytes to copy / compute
- * @return 32-bit CRC value
- */
-extern uint32_t memcpy32(void *__restrict __dst, const void *__restrict __src,
- size_t __n)
-/*! @cond */
-__THROW __nonnull((2)) /*! @endcond */ ;
-
-#endif /* __CRC32_H__ */
diff --git a/clib/cunit/map.c b/clib/cunit/map.c
deleted file mode 100644
index 6162344..0000000
--- a/clib/cunit/map.c
+++ /dev/null
@@ -1,308 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/cunit/map.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/libclib.h>
-
-#include <clib/slab.h>
-#include <clib/map.h>
-#include <clib/map_iter.h>
-
-#include <CUnit/Basic.h>
-
-#define COUNT 20000
-#define SEED 22
-
-slab_t slab;
-
-typedef struct {
- map_node_t node;
- int i;
- float f;
-} data_t;
-
-static int init_map(void) {
- slab_init(&slab, "my_slab", sizeof(data_t), 4096);
- return 0;
-}
-
-static int clean_map(void) {
- slab_delete(&slab);
- return 0;
-}
-
-static void __insert(map_t * t, int i) {
- data_t * d = (data_t *)slab_alloc(&slab);
-
- i %= INT32_MAX;
-
- d->i = i;
- d->f = (float)i;
- map_node_init(&d->node, (const void *)(intptr_t)(d->i));
-
- if (map_insert(t, &d->node) < 0) {
- err_t * err = err_get();
- fprintf(stderr, "%s(%d): %.*s\n",
- err_file(err), err_line(err), err_size(err),
- (const char *)err_data(err));
- }
-}
-
-static data_t * __remove(map_t * t, int i) {
-
- i %= INT32_MAX;
-
- map_node_t * n = map_find(t, (const void *)i);
- if (n == NULL) map_dump(t, stdout);
- CU_ASSERT_PTR_NOT_NULL_FATAL(n);
-
- map_remove(t, n);
-
- data_t * d = container_of(n, data_t, node);
- CU_ASSERT_PTR_NOT_NULL_FATAL(n);
-
- if (0 <= i)
- CU_ASSERT((int)d->node.key == i);
-
- return d;
-}
-
-static int compare(const void * v1, const void * v2) {
- const int i1 = (const int)v1, i2 = (const int)v2;
- return i1 - i2;
-}
-
-static void map_1(void) {
- map_t t;
- map_init(&t, compare);
-
- CU_ASSERT(map_min(&t) == NULL);
- CU_ASSERT(map_max(&t) == NULL);
- CU_ASSERT(map_empty(&t) == true);
- CU_ASSERT(map_size(&t) == 0);
-}
-
-static void map_2(void) {
- map_t t;
- map_init(&t, compare);
-
- CU_ASSERT(map_empty(&t) == true);
- CU_ASSERT(map_size(&t) == 0);
-
- for (int i=1; i<=COUNT; i++)
- __insert(&t, i);
-
- CU_ASSERT(map_empty(&t) == false);
- CU_ASSERT(map_size(&t) == COUNT);
-
- for (int i=1; i<=COUNT; i++) {
- CU_ASSERT(i == (int)map_min(&t)->key);
- CU_ASSERT(COUNT == (int)map_max(&t)->key);
- __remove(&t, (int)map_min(&t)->key);
- CU_ASSERT(map_size(&t) + i == COUNT);
- }
-
- CU_ASSERT(map_empty(&t) == true);
- CU_ASSERT(map_size(&t) == 0);
-
- for (int i=1; i<=COUNT; i++)
- __insert(&t, i);
-
- CU_ASSERT(map_empty(&t) == false);
- CU_ASSERT(map_size(&t) == COUNT);
-
- for (int i=1; i<=COUNT; i++) {
- CU_ASSERT(1 == (int)map_min(&t)->key);
- CU_ASSERT(COUNT - i + 1 == (int)map_max(&t)->key);
- __remove(&t, (int)map_max(&t)->key);
- CU_ASSERT(map_size(&t) + i == COUNT);
- }
-
- CU_ASSERT(map_empty(&t) == true);
- CU_ASSERT(map_size(&t) == 0);
-}
-
-static void map_3(void) {
- map_t t;
- map_init(&t, compare);
-
- CU_ASSERT(map_empty(&t) == true);
- CU_ASSERT(map_size(&t) == 0);
-
- for (int i=1; i<=COUNT; i++)
- __insert(&t, COUNT - i + 1);
-
- CU_ASSERT(map_empty(&t) == false);
- CU_ASSERT(map_size(&t) == COUNT);
-
- for (int i=1; i<=COUNT; i++) {
- CU_ASSERT(1 == (int)map_min(&t)->key);
- CU_ASSERT(COUNT - i + 1 == (int)map_max(&t)->key);
- __remove(&t, (int)map_max(&t)->key);
- CU_ASSERT(map_size(&t) + i == COUNT);
- }
-
- CU_ASSERT(map_empty(&t) == true);
- CU_ASSERT(map_size(&t) == 0);
-
- for (int i=1; i<=COUNT; i++)
- __insert(&t, COUNT - i + 1);
-
- CU_ASSERT(map_empty(&t) == false);
- CU_ASSERT(map_size(&t) == COUNT);
-
- for (int i=1; i<=COUNT; i++) {
- CU_ASSERT(i == (int)map_min(&t)->key);
- CU_ASSERT(COUNT == (int)map_max(&t)->key);
- __remove(&t, (int)map_min(&t)->key);
- CU_ASSERT(map_size(&t) + i == COUNT);
- }
-
- CU_ASSERT(map_empty(&t) == true);
- CU_ASSERT(map_size(&t) == 0);
-}
-
-static void map_4(void) {
- map_t t;
- map_init(&t, compare);
-
- CU_ASSERT(map_empty(&t) == true);
- CU_ASSERT(map_size(&t) == 0);
-
- srandom(SEED);
- for (int i=1; i<=COUNT; i++)
- __insert(&t, (int)random());
-
- CU_ASSERT(map_empty(&t) == false);
- CU_ASSERT(map_size(&t) == COUNT);
-
- for (int i=1; i<=COUNT; i++) {
- __remove(&t, (int)map_min(&t)->key);
- CU_ASSERT(map_size(&t) + i == COUNT);
- }
-
- CU_ASSERT(map_empty(&t) == true);
- CU_ASSERT(map_size(&t) == 0);
-
- srandom(SEED);
- for (int i=1; i<=COUNT; i++)
- __insert(&t, (int)random());
-
- CU_ASSERT(map_empty(&t) == false);
- CU_ASSERT(map_size(&t) == COUNT);
-
- for (int i=1; i<=COUNT; i++) {
- __remove(&t, (int)map_max(&t)->key);
- CU_ASSERT(map_size(&t) + i == COUNT);
- }
-
- CU_ASSERT(map_empty(&t) == true);
- CU_ASSERT(map_size(&t) == 0);
-
- srandom(SEED);
- for (int i=1; i<=COUNT; i++)
- __insert(&t, (int)random());
-
- CU_ASSERT(map_empty(&t) == false);
- CU_ASSERT(map_size(&t) == COUNT);
-
- srandom(SEED);
- for (int i=1; i<=COUNT; i++) {
- __remove(&t, (int)random());
- CU_ASSERT(map_size(&t) + i == COUNT);
- }
-
- CU_ASSERT(map_empty(&t) == true);
- CU_ASSERT(map_size(&t) == 0);
-}
-
-static void map_5(void) {
- map_t t;
- map_init(&t, compare);
-
- CU_ASSERT(map_empty(&t) == true);
- CU_ASSERT(map_size(&t) == 0);
-
- srandom(SEED);
- for (int i=1; i<=COUNT; i++)
- __insert(&t, (int)random());
-
- CU_ASSERT(map_empty(&t) == false);
- CU_ASSERT(map_size(&t) == COUNT);
-
- data_t * d;
- int key = 0;
-
- map_iter_t it;
- map_iter_init(&it, &t, MI_FLAG_FWD);
- map_for_each(&it, d, node) {
- CU_ASSERT(key < (int)d->node.key);
- key = (int)d->node.key;
- }
-
- key = INT32_MAX;
- map_iter_init(&it, &t, MI_FLAG_BWD);
- map_for_each(&it, d, node) {
- CU_ASSERT((int)d->node.key < key);
- key = (int)d->node.key;
- }
-}
-
-static void map_6(void) {
- map_t t;
- map_init(&t, compare);
-
- CU_ASSERT(map_empty(&t) == true);
- CU_ASSERT(map_size(&t) == 0);
-
- srandom(SEED);
- for (int i=1; i<=COUNT; i++)
- __insert(&t, (int)random());
-
- CU_ASSERT(map_empty(&t) == false);
- CU_ASSERT(map_size(&t) == COUNT);
-
- srandom(SEED);
- for (int i=1; i<=COUNT; i++) {
- map_node_t * node = map_find(&t, (const void *)random());
- CU_ASSERT_PTR_NOT_NULL_FATAL(node);
- }
-}
-
-void map_test(void) {
- CU_pSuite suite = CU_add_suite("map", init_map, clean_map);
- if (NULL == suite)
- return;
-
- if (CU_add_test(suite, "test of --> map_1", map_1) == NULL) return;
- if (CU_add_test(suite, "test of --> map_2", map_2) == NULL) return;
- if (CU_add_test(suite, "test of --> map_3", map_3) == NULL) return;
- if (CU_add_test(suite, "test of --> map_4", map_4) == NULL) return;
- if (CU_add_test(suite, "test of --> map_5", map_5) == NULL) return;
- if (CU_add_test(suite, "test of --> map_6", map_6) == NULL) return;
-}
diff --git a/clib/cunit/map.h b/clib/cunit/map.h
deleted file mode 100644
index 11e4007..0000000
--- a/clib/cunit/map.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/cunit/map.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 map_test(void);
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/cunit/vector.c b/clib/cunit/vector.c
deleted file mode 100644
index cd0f34c..0000000
--- a/clib/cunit/vector.c
+++ /dev/null
@@ -1,176 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/cunit/vector.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/libclib.h>
-
-#include <clib/crc32.h>
-#include <clib/vector.h>
-
-#include <CUnit/Basic.h>
-
-#define COUNT 10000
-#define SEED 41
-
-static int init_vector(void) {
- return 0;
-}
-
-static int clean_vector(void) {
- return 0;
-}
-
-static void vector_1(void) {
- vector_t v;
-
- CU_ASSERT(vector_init(&v, "my_vector", 0) == -1)
- err_t * err = err_get();
- fprintf(stderr, "%s(%d): %.*s\n",
- err_file(err), err_line(err), err_size(err),
- (const char *)err_data(err));
-
- for (size_t i=VECTOR_ELEM_MIN; i<=VECTOR_ELEM_MAX; i++) {
- CU_ASSERT(vector_init(&v, "my_vector", i) == 0);
-
- CU_ASSERT(vector_size(&v) == 0);
- CU_ASSERT(vector_pages(&v) == 0);
- CU_ASSERT(vector_capacity(&v) == 0);
- CU_ASSERT(vector_elem_size(&v) == i);
- CU_ASSERT(vector_elem_size(&v) * v.hdr.elem_num <= v.hdr.page_size);
-
- CU_ASSERT(vector_delete(&v) == 0);
- }
-}
-
-uint32_t crc2;
-
-static void vector_2(void) {
- vector_t v;
-
- CU_ASSERT(vector_init(&v, "my_vector.bin", 1) == 0);
- CU_ASSERT(vector_size(&v) == 0);
- CU_ASSERT(vector_pages(&v) == 0);
- CU_ASSERT(vector_capacity(&v) == 0);
- CU_ASSERT(vector_elem_size(&v) == 1);
-
- CU_ASSERT(vector_size(&v, COUNT) == COUNT);
- CU_ASSERT(COUNT <= vector_capacity(&v));
- CU_ASSERT(COUNT <= vector_size(&v));
- CU_ASSERT(3 <= vector_pages(&v));
-
- for (int i=0; i<COUNT; i++) {
- unsigned char c = (unsigned char)i;
- crc2 = clib_crc32(c, crc2);
- CU_ASSERT(vector_put(&v, i, &c) == 0);
- }
- CU_ASSERT_FATAL(crc2 != 0);
-
- FILE * f = fopen(v.hdr.name, "w");
- CU_ASSERT_FATAL(f != NULL);
- CU_ASSERT(COUNT < vector_save(&v, f));
- fclose(f), f = NULL;
-
- CU_ASSERT(vector_delete(&v) == 0);
-}
-
-uint32_t crc3;
-
-static void vector_3(void) {
- vector_t v;
- vector_init(&v, __func__, 1);
-
- CU_ASSERT(vector_size(&v) == 0);
- CU_ASSERT(vector_pages(&v) == 0);
- CU_ASSERT(vector_capacity(&v) == 0);
- CU_ASSERT(vector_elem_size(&v) == 1);
-
- FILE * f = fopen("my_vector.bin", "r");
- CU_ASSERT_FATAL(f != NULL);
- CU_ASSERT(COUNT < vector_load(&v, f));
- fclose(f), f = NULL;
-
- crc3 = 0;
-
- for (int i=0; i<COUNT; i++) {
- unsigned char c;
- vector_get(&v, i, &c);
- crc3 = clib_crc32(c, crc3);
- }
- CU_ASSERT_FATAL(crc3 != 0);
-
- CU_ASSERT_FATAL(crc2 == crc3);
-
- vector_delete(&v);
-}
-
-static void vector_4(void) {
- vector_t v;
-
- if (vector_init(&v, NULL, 0) < 0) {
- err_t * err = err_get();
- fprintf(stderr, "%s(%d): UNEXPECTED: %.*s\n",
- err_file(err), err_line(err), err_size(err),
- (const char *)err_data(err));
- }
-
- if (vector_init(&v, "my_vector", 0) < 0) {
- err_t * err = err_get();
- fprintf(stderr, "%s(%d): UNEXPECTED: %.*s\n",
- err_file(err), err_line(err), err_size(err),
- (const char *)err_data(err));
- }
-
- for (size_t i=VECTOR_ELEM_MIN; i<=VECTOR_ELEM_MAX; i+=3) {
- vector_init(&v, "my_vector", i);
-
- CU_ASSERT(vector_size(&v) == 0);
- CU_ASSERT(vector_pages(&v) == 0);
- CU_ASSERT(vector_capacity(&v) == 0);
- CU_ASSERT(vector_elem_size(&v) == i);
- CU_ASSERT(vector_elem_size(&v) * v.hdr.elem_num <= v.hdr.page_size);
-
- vector_size(&v, COUNT);
-
- CU_ASSERT(vector_size(&v) == COUNT);
- CU_ASSERT(vector_size(&v) <= vector_capacity(&v));
- CU_ASSERT(0 < vector_pages(&v));
-
- vector_delete(&v);
- }
-}
-
-void vector_test(void) {
- CU_pSuite suite = CU_add_suite("vector", init_vector, clean_vector);
- if (NULL == suite)
- return;
-
- if (CU_add_test(suite, "vector_1: vector_init()", vector_1) == NULL) return;
- if (CU_add_test(suite, "vector_2: vector_save()", vector_2) == NULL) return;
- if (CU_add_test(suite, "vector_3: vector_load()", vector_3) == NULL) return;
- if (CU_add_test(suite, "vector_4: vector_size()", vector_4) == NULL) return;
-}
diff --git a/clib/cunit/vector.h b/clib/cunit/vector.h
deleted file mode 100644
index 91dfd4e..0000000
--- a/clib/cunit/vector.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/cunit/vector.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 vector_test(void);
diff --git a/clib/db.h b/clib/db.h
deleted file mode 100644
index 184fb99..0000000
--- a/clib/db.h
+++ /dev/null
@@ -1,449 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/db.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 db.h
- * @brief Database client
- * @details Embedded database API wrapper
- * @author Shaun Wetzstein <shaun@us.ibm.com>
- * @date 2010-2011
- */
-
-#ifndef __DB_H__
-#define __DB_H__
-
-#include <stdbool.h>
-#include <stdint.h>
-#include <sqlite3.h>
-
-#include "exception.h"
-
-/* ======================================================================= */
-
-#define DB_ROW SQLITE_ROW //!< Statement contains another row @hideinitializer
-#define DB_DONE SQLITE_DONE //!< Statement contains no more rows @hideinitializer
-#define DB_OK SQLITE_OK //!< Database command ok @hideinitializer
-
-#define DB 4 //!< Database exception class
-#define SQL 5 //!< Statement exception class
-
-typedef struct db db_t; //!< Alias for the @em db class
-typedef struct statement statement_t; //!< Alias for the @em statement class
-
-/*!
- * @brief Database access class
- */
-struct db {
-#ifdef SQLITE3
- const char *path; //!< @private
- sqlite3 *db; //!< @private
-#endif
-};
-
-typedef enum transaction_type transaction_type_t; //!< Alias for the @em transaction_type enum
-
-/*!
- * @brief Transaction types
- */
-enum transaction_type {
- tt_ERROR = -1, //!< Invalid / unknown transaction
- tt_DEFERRED, //!< Defferred locking transaction
- tt_IMMEDIATE, //!< Immediate locking transaction
- tt_EXCLUSIVE, //!< Exclusive locking transaction
-};
-
-#ifdef SQLITE3
-typedef sqlite3_context db_context_t; //!< User-defined database context
-typedef sqlite3_value db_value_t; //!< User-defined value
-#else
-#error MUST define db_context_t and db_value_t
-#endif
-
-/*!
- * @brief User-defined function
- */
-typedef void (*db_f) (db_context_t *, int, db_value_t **);
-
-/*!
- * @brief Statement class
- */
-struct statement {
- db_t *db; //!< Database object
-#ifdef SQLITE3
- sqlite3_stmt *stmt; //!< @private
-#endif
-};
-
-/* ======================================================================= */
-
-#if 0
-extern db_t *db_new(const char *) __nonnull((1));
-#endif
-
-/*!
- * @brief Constructs a @em db object
- * @memberof db
- * @param self [in] db object @em self pointer
- * @param path [in] db file name
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern int db_init(db_t * self, const char *path)
-/*! @cond */
-__nonnull((1, 2)) /*! @endcond */ ;
-
-/*!
- * @brief Destructs a @em db object
- * @memberof db
- * @param self [in] db object @em self pointer
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern int db_delete(db_t * self)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Execute a SQL txt statement
- * @memberof db
- * @param self [in] db object @em self pointer
- * @param fmt [in] printf-like format string
- * @param ... [in] printf-like arguments
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern int db_execute(db_t * self, const char *fmt, ...)
-/*! @cond */
-__nonnull((1, 2)) /*! @endcond */ ;
-
-/*!
- * @brief Open a @em db object
- * @memberof db
- * @param self [in] db object @em self pointer
- * @param flags [in] Open flagsprintf-like format string
- * @return 0 on success, non-0 otherwise
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern int db_open(db_t * self, int flags)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Close a @em db object
- * @memberof db
- * @param self [in] db object @em self pointer
- * @return 0 on success, non-0 otherwise
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern int db_close(db_t * self)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Register a user-defined function on a @em db object
- * @memberof db
- * @param self [in] db object @em self pointer
- * @param name [in] db function name
- * @param argc [in] Function argument count
- * @param func [in] User-defined function
- * @param data [in] User-defined data passed to @em finc
- * @return 0 on siccess, non-0 otherwise
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern int db_register_function(db_t * self, const char *name, int argc,
- db_f func, void *data)
-/*! @cond */
-__nonnull((1, 2)) /*! @endcond */ ;
-
-/*!
- * @brief Start a database transaction
- * @memberof db
- * @param self [in] db object @em self pointer
- * @param type [in] Transaction type
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern int db_begin(db_t * self, transaction_type_t type)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Commit a database transaction
- * @memberof db
- * @param self [in] db object @em self pointer
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern int db_commit(db_t * self)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Rollback a database transaction
- * @memberof db
- * @param self [in] db object @em self pointer
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern int db_rollback(db_t * self)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/* ======================================================================= */
-
-#if 0
-extern statement_t *statement_new(db_t *) __nonnull((1));
-#endif
-
-/*!
- * @brief Constructs a @em statement object
- * @memberof statement
- * @param self [in] statement object @em self pointer
- * @param db [in] Pointer to owning database object
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern int statement_init(statement_t * self, db_t * db)
-/*! @cond */
-__nonnull((1, 2)) /*! @endcond */ ;
-
-/*!
- * @brief Destructs a @em statement object
- * @memberof statement
- * @param self [in] statement object @em self pointer
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern int statement_delete(statement_t * self)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Prepare a @em statement object for execution
- * @memberof statement
- * @param self [in] statement object @em self pointer
- * @return DB_ROW when a row is available, DB_DONE when no more rows left
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern int statement_prepare(statement_t * self, const char *sql)
-/*! @cond */
-__nonnull((1, 2)) /*! @endcond */ ;
-
-/*!
- * @brief Execute the next step of @em statement object
- * @memberof statement
- * @param self [in] statement object @em self pointer
- * @return DB_OK on success, non-0 otherwise
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern int statement_step(statement_t * self)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Reset a @em statement object
- * @memberof statement
- * @param self [in] statement object @em self pointer
- * @return DB_OK on success, non-0 otherwise
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern int statement_reset(statement_t * self)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Finalize a @em statement object
- * @memberof statement
- * @param self [in] statement object @em self pointer
- * @return DB_OK on success, non-0 otherwise
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern int statement_finalize(statement_t * self)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Binds an integer to a bound variable of a @em statement object
- * @memberof statement
- * @param self [in] statement object @em self pointer
- * @param pos [in] Bound varialble position number
- * @param val [in] Integer value
- * @return DB_OK on success, non-0 otherwise
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern int statement_bind_int(statement_t * self, int pos, int val)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Binds a long long integer to a bound variable of a @em statement object
- * @memberof statement
- * @param self [in] statement object @em self pointer
- * @param pos [in] Bound varialble position number
- * @param val [in] Long Long Integer value
- * @return DB_OK on success, non-0 otherwise
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern int statement_bind_int64(statement_t * self, int pos, int64_t val)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Binds a text string to a bound variable of a @em statement object
- * @memberof statement
- * @param self [in] statement object @em self pointer
- * @param pos [in] Bound varialble position number
- * @param val [in] Text string value
- * @return DB_OK on success, non-0 otherwise
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern int statement_bind_text(statement_t * self, int pos, const char *val)
-/*! @cond */
-__nonnull((1, 3)) /*! @endcond */ ;
-
-/*!
- * @brief Binds a blob to a bound variable of a @em statement object
- * @memberof statement
- * @param self [in] statement object @em self pointer
- * @param pos [in] Bound varialble position number
- * @param val [in] Blob value
- * @param len [in] Lengh of blob value (in bytes)
- * @return DB_OK on success, non-0 otherwise
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern int statement_bind_blob(statement_t * self, int pos, const void *val,
- int len)
-/*! @cond */
-__nonnull((1, 3)) /*! @endcond */ ;
-
-/*!
- * @brief Return an integer from the result set of a @em statement object
- * @memberof statement
- * @param self [in] statement object @em self pointer
- * @param pos [in] Column position number
- * @return DB_OK on success, non-0 otherwise
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern int statement_column_int(statement_t * self, int pos)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Return an long long integer from the result set of a @em statement object
- * @memberof statement
- * @param self [in] statement object @em self pointer
- * @param pos [in] Column position number
- * @return DB_OK on success, non-0 otherwise
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern int64_t statement_column_int64(statement_t * self, int pos)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Return the length of a column from the result set of a @em statement object
- * @memberof statement
- * @param self [in] statement object @em self pointer
- * @param pos [in] Column position number
- * @return DB_OK on success, non-0 otherwise
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern int statement_column_bytes(statement_t * self, int pos)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Return a text string from the result set of a @em statement object
- * @memberof statement
- * @param self [in] statement object @em self pointer
- * @param pos [in] Column position number
- * @return DB_OK on success, non-0 otherwise
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern const unsigned char *statement_column_text(statement_t * self, int pos)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Return a blob from the result set of a @em statement object
- * @memberof statement
- * @param self [in] statement object @em self pointer
- * @param pos [in] Column position number
- * @return DB_OK on success, non-0 otherwise
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern const void *statement_column_blob(statement_t * self, int pos)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-#ifdef SQLITE3
-#define DBERR(d) ({ \
- err_t * _e = (err_t *)malloc(sizeof(*_e) + ERR_DATA_SIZE); \
- memset(_e, 0, sizeof(*_e) + ERR_DATA_SIZE); \
- _e->size = snprintf(_e->data, ERR_DATA_SIZE, "%s (code=%d)", \
- sqlite3_errmsg(d), sqlite3_errcode(d)); \
- _e->magic = ERR_MAGIC, _e->type = DB, _e->code = sqlite3_errcode(d); \
- _e->file = __FILE__, _e->line = __LINE__; \
- err_put(_e); \
- })
-
-#define SQLERR(d,s) ({ \
- err_t * _e = (err_t *)malloc(sizeof(*_e) + ERR_DATA_SIZE); \
- memset(_e, 0, sizeof(*_e) + ERR_DATA_SIZE); \
- _e->size = snprintf(_e->data, ERR_DATA_SIZE, "'%s' => %s (code=%d)", \
- sqlite3_sql(s), sqlite3_errmsg(d), \
- sqlite3_errcode(d)); \
- _e->magic = ERR_MAGIC, _e->type = SQL, _e->code = sqlite3_errcode(d); \
- _e->file = __FILE__, _e->line = __LINE__; \
- err_put(_e); \
- })
-#if 0
-#define throw_db(x) ({ \
- char __e[strlen(sqlite3_errmsg((x))) + 32]; \
- __exc_throw(DB,((void*)__e), \
- sprintf(__e, "(%d) %s", \
- sqlite3_errcode((x)), \
- sqlite3_errmsg((x))), \
- __FILE__, __LINE__); \
- })
-
-#define throw_statement(x,s) ({ \
- char __e[strlen(sqlite3_errmsg((x))) + \
- strlen(sqlite3_sql((s))) + 32]; \
- __exc_throw(STATEMENT,((void*)__e), \
- sprintf(__e, "(%d) %s\n%s", \
- sqlite3_errcode((x)), \
- sqlite3_errmsg((x)), \
- sqlite3_sql((s))), \
- __FILE__, __LINE__); \
- })
-#endif
-#else
-#error FIX ME
-#endif
-
-/* ======================================================================= */
-
-#endif /* __DB_H__ */
diff --git a/clib/dispatch.h b/clib/dispatch.h
deleted file mode 100644
index 410423b..0000000
--- a/clib/dispatch.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/dispatch.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: dispatch.h
- * Author: Shaun Wetzstein <shaun@us.ibm.com>
- * Descr: File descriptor activity callback dispatcher
- * Note:
- * Date: 10/03/10
- */
-
-#ifndef __DISPATCH_H__
-#define __DISPATCH_H__
-
-#include <stdint.h>
-#include <stdbool.h>
-
-#include <sys/epoll.h>
-
-#include "attribute.h"
-#include "builtin.h"
-#include "assert.h"
-
-#include "tree.h"
-#include "array.h"
-
-#define DISPATCH_READ EPOLLIN
-#define DISPATCH_WRITE EPOLLOUT
-#define DISPATCH_READ_HUP EPOLLRDHUP
-#define DISPATCH_READ_PRIORITY EPOLLPRI
-#define DISPATCH_ERROR EPOLLERR
-#define DISPATCH_WRITE_HUP EPOLLRDHUP
-#define DISPATCH_EDGE_TRIGGER EPOLLET
-#define DISPATCH_ONE_SHOT EPOLLONESHOT
-
-/* ======================================================================= */
-
-typedef struct dispatch dispatch_t;
-typedef struct dispatch_callback dispatch_callback_t;
-typedef struct dispatch_event dispatch_event_t;
-
-typedef int (*dispatch_f) (dispatch_event_t *, void *);
-
-struct dispatch {
- int fd;
- array_t events;
-};
-
-struct dispatch_callback {
- int fd;
- void *data;
- dispatch_f func;
-};
-
-struct dispatch_event {
- int fd;
- uint32_t events;
-};
-
-/* ======================================================================= */
-
-extern void dispatch_init(dispatch_t *) __nonnull((1));
-
-extern void dispatch_delete(dispatch_t *) __nonnull((1));
-
-extern int dispatch_fileno(dispatch_t *) __nonnull((1));
-
-extern int dispatch_add(dispatch_t *, int, uint32_t, dispatch_callback_t *)
-__nonnull((1, 4));
-extern void dispatch_remove(dispatch_t *, int) __nonnull((1));
-
-#define dispatch_wait(...) STRCAT(dispatch_wait, NARGS(__VA_ARGS__))(__VA_ARGS__)
-extern void dispatch_wait1(dispatch_t *) __nonnull((1));
-extern void dispatch_wait2(dispatch_t *, int) __nonnull((1));
-
-/* ======================================================================= */
-
-#endif /* __DISPATCH_H__ */
diff --git a/clib/exception.h b/clib/exception.h
deleted file mode 100644
index 2874447..0000000
--- a/clib/exception.h
+++ /dev/null
@@ -1,306 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/exception.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 exception.h
- * @brief Exceptions for C
- * @details This file implements setjump / longjump based exceptions
- * @note Using these macros will create an exception context in each thread
- * @author Shaun Wetzstein <shaun@us.ibm.com>
- * @date 2008-2011
- */
-
-#ifndef __EXCEPTION_H__
-#define __EXCEPTION_H__
-
-#include <setjmp.h>
-#include <pthread.h>
-#include <stdlib.h>
-#include <string.h>
-
-#define EX_PAGE_SIZE 4096 //!< Max. size of an exception payload
-#define EXC_MAGIC 0x45584350 //!< Magic number, i.e. "EXCP"
-
-#define ASSERTION 1 //!< Assertion exception class
-//#define UNEXPECTED 2 //!< Unexpected result exception class
-//#define ERRNO 3 //!< @em errno error exception class
-#define EXC_LAST 4
-
-typedef struct exception_frame exception_frame_t; //!< Alias for the @em exception_frame class
-
-/*!
- * @brief Exception class
- */
-typedef struct {
- int ex; //!< Exception class
-
- const char *file; //!< Source file exception was thrown
- int line; //!< Source line exception was thrown
-
- void *data; //!< User-defined data associated with the exception
- int size; //!< Size (in bytes) of the user-defined data
-} exception_t;
-
-/*!
- * @brief Exception frame class
- */
-struct exception_frame {
- unsigned long magic; //!< @private
- exception_frame_t *prev; //!< @private
- jmp_buf jmp; //!< @private
- exception_t exc; //!< @private
-};
-
-/*!
- * @def try
- * @brief Simulate a try {...} catch {...} else {...} end_try block
- * @hideinitializer
- * @details For example,
- * @code
- * ...
- * #define ERROR 4
- * ...
- * exception_t * ex;
- * ...
- * try {
- * ...
- * } catch (ERROR, ex) {
- * fprintf(stderr, "caught ERROR exception at: %s(%d)\n",
- * ex->file, ex->line);
- * struct ErrorStruct * err = (struct ErrorStruct *)ex->data
- * ...format and log err...
- * } end_try
- * @endcode
- */
-#define try \
-do { \
- __exc_init(); \
- exception_frame_t __frame; \
- memset(&__frame, 0, sizeof(__frame)); \
- __frame.magic = EXC_MAGIC, __frame.prev = __exc_get_frame(); \
- __exc_set_frame(&__frame); \
- volatile int __flag = setjmp(__frame.jmp); \
- if (__flag == 0) {
-
-/*!
- * @def catch
- * @brief Simulate a try {...} catch {...} else {...} end_try block
- * @hideinitializer
- * @details For example,
- * @code
- * ...
- * exception_t ex;
- * ...
- * try {
- * ....
- * } catch (TYPE1, ex) {
- * ...
- * } catch (TYPE2, ex) {
- * ...
- * } catch (TYPE3, ex) {
- * ...
- * } else (ex) {
- * ...
- * } end_try
- * @endcode
- */
-#define catch(x, e) \
- } else if (__flag == (x)) { \
- exception_frame_t * __tmp = __exc_get_frame(); \
- (e) = __tmp->exc, (e).ex = (__flag); \
-
-/*!
- * @def else
- * @brief Simulate a try {...} catch {...} else {...} end_try block
- * @hideinitializer
- * @details For example,
- * @code
- * ...
- * exception_t ex;
- * ...
- * try {
- * ....
- * } catch (TYPE1, ex) {
- * ...
- * } catch (TYPE2, ex) {
- * ...
- * } catch (TYPE3, ex) {
- * ...
- * } else (ex) {
- * ...
- * } end_try
- * @endcode
- */
-#define else(e) catch(__flag, (e))
-
-/*!
- * @def end_try
- * @brief Simulate a try {...} catch {...} else {...} end_try block
- * @hideinitializer
- */
-#define end_try \
- } else { \
- __exc_set_frame(__frame.prev); \
- throw_bytes(__flag, __frame.exc.data, __frame.exc.size); \
- } \
- __exc_set_frame(__frame.prev); \
-} while (0);
-
-/*!
- * @def throw(x, f, ...)
- * @brief Throw a C exception with printf-like formatting
- * @hideinitializer
- * @param x [in] Exception class
- * @param d [in] Pointer to user-defined data
- * @param s [in] Size of user-defined data (in bytes)
- * @details For example,
- * @code
- * ...
- * #define ERRNO_STRING
- * ...
- * #define throw_errno_string(x) \
- * throw(ERRNO_STRING, "errno=%d : %s", (x),
- * (void*)strerror((x)), __FILE__, __LINE__)
- * ...
- * if (rc < 0)
- * throw_errno_string(errno);
- * ...
- * exception_t ex;
- * ...
- * catch (ERRNO_STRING ex) {
- * fprintf(strerr, "EXCEPTION: errno: %s in file: %s on line: %d\n",
- * (char *)ex.data, ex.file, ex.line);
- * exit(1);
- * }
- * @endcode
- */
-#define throw(x, f, ...) ({ \
- char __d[EX_PAGE_SIZE]; \
- __exc_throw((x), __d, snprintf(__d, sizeof __d, (f), ##__VA_ARGS__),\
- __FILE__, __LINE__); \
-})
-
-/*!
- * @def rethrow(x, f, ...)
- * @brief Rethrow a C exception from within a try ... catch ... end_try block
- * @hideinitializer
- * @param e [in] Exception object
- * @details For example,
- * @code
- * ...
- * exception_t ex;
- * ...
- * catch (ERRNO_STRING ex) {
- * fprintf(strerr, "EXCEPTION: errno: %s in file: %s on line: %d\n",
- * (char *)ex.data, ex.file, ex.line);
- * rethrow(ex);
- * }
- * @endcode
- */
-#define rethrow(e) ({ \
- __exc_rethrow((e).ex, (e).data, (e).size, (e).file, (e).line); \
-})
-
-/*!
- * @def throw_bytes(x, d, s)
- * @brief Throw a C exception with user-defined data
- * @hideinitializer
- * @param x [in] Exception class
- * @param d [in] Pointer to user-defined data
- * @param s [in] Size of user-defined data (in bytes)
- * @details For example,
- * @code
- * ...
- * #define ERRNO_STRING
- * ...
- * #define throw_errno_string(x) \
- * throw_bytes(ERRNO_STRING, (void*)strerror((x)),
- * strlen(strerror((x)), __FILE__, __LINE__)
- * ...
- * if (rc < 0)
- * throw_errno_string(errno);
- * ...
- * exception_t ex;
- * ...
- * catch (ERRNO_STRING ex) {
- * fprintf(strerr, "EXCEPTION: errno: %s in file: %s on line: %d\n",
- * (char *)ex.data, ex.file, ex.line);
- * exit(1);
- * }
- * @endcode
- */
-#define throw_bytes(x, d, s) \
- __exc_throw((x), (d), (s), __FILE__, __LINE__)
-
-/*!
- * @def throw_unexpected(x)
- * @brief Throw a message (NULL terminated C string), due to an @em
- * unexpected error
- * @hideinitializer
- * @param x [in] Unexpected error message
- * @details For example,
- * @code
- * ...
- * rc = foo_function();
- * if (rc < 0)
- * throw_unexpected("Invalid return code from foo_function()");
- * ...
- * @endcode
- */
-#define throw_unexpected(x) ({ \
- __exc_throw(UNEXPECTED,((void*)x), strlen((x)), \
- __FILE__, __LINE__); \
- })
-
-/*!
- * @def throw_errno(x)
- * @brief Throw an errno number, due to an invalid function result.
- * @hideinitializer
- * @param x [in] Unexpected errno number
- * @details For example,
- * @code
- * ...
- * rc = open(...);
- * if (rc == -1)
- * throw_errno(errno);
- * ...
- * @endcode
- */
-#define throw_errno(x) ({ \
- __exc_throw(ERRNO,(void*)(x), 0, \
- __FILE__, __LINE__); \
- })
-
-/*! @cond */
-extern void __exc_init(void);
-extern exception_frame_t *__exc_get_frame(void);
-extern void __exc_set_frame(exception_frame_t *);
-extern int __exc_throw(int, void *, int, const char *, int);
-extern int __exc_rethrow(int, void *, int, const char *, int);
-extern void __exc_backtrace(const char *, ...);
-extern const char *__exc_name(int exc);
-/*! @endcond */
-
-#endif /* __EXCEPTION_H__ */
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/map.h b/clib/map.h
deleted file mode 100644
index e625ac8..0000000
--- a/clib/map.h
+++ /dev/null
@@ -1,245 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/map.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: map.h
- * Author: Shaun Wetzstein <shaun@us.ibm.com>
- * Descr: Map container
- * Note:
- * Date: 10/22/10
- */
-
-#ifndef __MAP_H__
-#define __MAP_H__
-
-#include <stdint.h>
-#include <stdbool.h>
-
-#include "builtin.h"
-#include "compare.h"
-#include "type.h"
-
-#include "tree.h"
-
-/* ==================================================================== */
-
-typedef tree_t map_t; //!< Alias for the @em map class
-typedef tree_node_t map_node_t; //!< Alias for the @em map_node class
-
-/*!
- * @brief Constructs a @em map_node object
- * @memberof map_node
- * @param self [in] map_node object @em self pointer
- * @param key [in] pointer to key bytes
- * @return Reference to an initialized map_node object on SUCCESS
- */
-static inline map_node_t *map_node_init(map_node_t *, const void *)
-/*! @cond */
-__nonnull((1, 2)) /*! @endcond */ ;
-
-/*!
- * @fn void map_init(map_t * self, compare_f cmp = default_compare)
- * @brief Constructs a @em map object
- * @memberof map
- * @param self [in] map_node object @em self pointer
- * @param cmp [in] Reference to the @em map_node compare function
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-/*! @cond */
-#define map_init(...) STRCAT(map_init, NARGS(__VA_ARGS__))(__VA_ARGS__)
-static inline int map_init1(map_t *)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-static inline int map_init2(map_t *, compare_f)
-/*! @cond */
-__nonnull((1, 2)) /*! @endcond */ ;
-/*! @endcond */
-
-/*!
- * @brief Insert a new @em map_node into the @em map container
- * @memberof map
- * @param self [in] map object @em self pointer
- * @param node [in] Reference to the @em map_node to insert
- * @return @em true if the @em map_node was inserted, @em false otherwise
- * @throws UNEXPECTED if @em self pointer is NULL
- * @throws UNEXPECTED if @em map_node.key points to a duplicate key
- */
-static inline int map_insert(map_t *, map_node_t *)
-/*! @cond */
-__nonnull((1, 2)) /*! @endcond */ ;
-
-/*!
- * @brief Removes a @em map_node from the @em map container
- * @memberof map
- * @param self [in] map object @em self pointer
- * @param node [in] Reference to the @em map_node to remove
- * @return @em true if the @em map_node was removed, @em false otherwise
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-static inline int map_remove(map_t *, map_node_t *)
-/*! @cond */
-__nonnull((1, 2)) /*! @endcond */ ;
-
-/*!
- * @brief Find a @em map_node within the @em map container
- * @memberof map
- * @param self [in] map object @em self pointer
- * @param key [in] Reference to the @em key to find
- * @return Reference to a @em map_node on SUCCESS, false otherwise
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-static inline map_node_t *map_find(map_t *, const void *)
-/*! @cond */
-__nonnull((1, 2)) /*! @endcond */ ;
-
-/*!
- * @brief Hexdump the contents of a @em map to @em out output stream
- * @memberof map
- * @param self [in] map object @em self pointer
- * @param out [in] Reference to the @em out output stream
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-static inline void map_dump(map_t *, FILE *)
-/*! @cond */
-__nonnull((1, 2)) /*! @endcond */ ;
-
-/*!
- * @brief Return whether a @em map container is empty
- * @memberof map
- * @param self [in] map object @em self pointer
- * @return @em true if @em map is empty, false otherwise
- */
-static inline bool map_empty(map_t *)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Return the node count of a @em map container
- * @memberof map
- * @param self [in] map object @em self pointer
- * @return @em 0 if @em map is empty, @em non-0 otherwise
- */
-static inline size_t map_size(map_t *)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Return the minimum @em map_node of a @em map container
- * @memberof map
- * @param self [in] map object @em self pointer
- * @return Reference to a @em map_node if @em self is non-NULL, NULL otherwise
- */
-static inline map_node_t *map_min(map_t *)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Return the maximum @em map_node of a @em map container
- * @memberof map
- * @param self [in] map object @em self pointer
- * @return Reference to a @em map_node if @em self is non-NULL, NULL otherwise
- */
-static inline map_node_t *map_max(map_t *)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/* ==================================================================== */
-
-static inline map_node_t *map_node_init(map_node_t * self, const void *key)
-{
- return (map_node_t *) tree_node_init((tree_node_t *) self, key);
-}
-
-/* ==================================================================== */
-
-static inline int map_init1(map_t * self)
-{
- assert(self != NULL);
- return tree_init((tree_t *) self, default_compare);
-}
-
-static inline int map_init2(map_t * self, compare_f cmp)
-{
- assert(self != NULL);
- assert(cmp != NULL);
- return tree_init((tree_t *) self, cmp);
-}
-
-static inline int map_insert(map_t * self, map_node_t * node)
-{
- assert(self != NULL);
- assert(node != NULL);
- return splay_insert((tree_t *) self, (tree_node_t *) node);
-}
-
-static inline int map_remove(map_t * self, map_node_t * node)
-{
- assert(self != NULL);
- assert(node != NULL);
- return splay_remove((tree_t *) self, (tree_node_t *) node);
-}
-
-static inline map_node_t *map_find(map_t * self, const void *key)
-{
- assert(self != NULL);
- assert(key != NULL);
- return (map_node_t *) tree_find((tree_t *) self, key);
-}
-
-static inline bool map_empty(map_t * self)
-{
- assert(self != NULL);
- return tree_empty((tree_t *) self);
-}
-
-static inline void map_dump(map_t * self, FILE * out)
-{
- assert(self != NULL);
- tree_dump((tree_t *) self, out ? out : stdout);
-}
-
-static inline size_t map_size(map_t * self)
-{
- assert(self != NULL);
- return tree_size((tree_t *) self);
-}
-
-static inline map_node_t *map_min(map_t * self)
-{
- assert(self != NULL);
- return tree_min((tree_t *) self);
-}
-
-static inline map_node_t *map_max(map_t * self)
-{
- assert(self != NULL);
- return tree_max((tree_t *) self);
-}
-
-/* ==================================================================== */
-
-#endif /* __MAP_H__ */
diff --git a/clib/map_iter.h b/clib/map_iter.h
deleted file mode 100644
index 4940625..0000000
--- a/clib/map_iter.h
+++ /dev/null
@@ -1,164 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/map_iter.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: map_iter.h
- * Author: Shaun Wetzstein <shaun@us.ibm.com>
- * Descr: Iterator for the Map container
- * Note:
- * Date: 10/22/10
- */
-
-#ifndef __MAP_ITER_H__
-#define __MAP_ITER_H__
-
-#include <stdint.h>
-#include <stdbool.h>
-
-#include "builtin.h"
-
-#include "map.h"
-#include "tree_iter.h"
-
-/* ==================================================================== */
-
-typedef tree_iter_t map_iter_t;
-
-/* ==================================================================== */
-
-#define MI_FLAG_NONE TI_FLAG_NONE
-#define MI_FLAG_FWD TI_FLAG_FWD
-#define MI_FLAG_BWD TI_FLAG_BWD
-
-/*!
- * @brief Initializes an @em map_iter iterator object
- * @memberof map_iter
- * @param self [in] map_iter object @em self pointer
- * @param map [in] map container object to iterate
- * @param flags [in] iterator configuration flags
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- * @throws UNEXPECTED if @em map pointer is NULL
- */
-static inline int map_iter_init(map_iter_t *, map_t *, uint32_t)
-/*! @cond */
-__nonnull((1, 2)) /*! @endcond */ ;
-
-/*!
- * @brief Resets an @em map iterator object
- * @memberof map_iter
- * @param self [in] map_iter object @em self pointer
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-static inline int map_iter_clear(map_iter_t *)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Return a pointer to a @em map_node element at the current iterator
- * position
- * @memberof map_iter
- * @param self [in] map_iter object @em self pointer
- * @return non-NULL on success, NULL otherwise
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-static inline map_node_t *map_iter_elem(map_iter_t *)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Increment the position of an @em map iterator
- * @memberof map_iter
- * @param self [in] map_iter object @em self pointer
- * @param count [in] Number of positions to increment
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-static inline map_node_t *map_iter_inc(map_iter_t *)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Decrement the position of an @em map iterator
- * @memberof map_iter
- * @param self [in] map_iter object @em self pointer
- * @param count [in] Number of positions to decrement
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-static inline map_node_t *map_iter_dec(map_iter_t *)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @def map_for_each(it, i, m)
- * @hideinitializer
- * @brief Tree for-each algorithm
- * @param it [in] Tree iterator object
- * @param i [in] Tree element variable
- * @param m [in] Member name
- */
-#define map_for_each(it, i, m) \
- for (map_iter_clear(it), i = container_of_var(map_iter_elem(it), i, m); \
- map_iter_elem(it) != NULL; \
- i = container_of_var(map_iter_inc(it), i, m))
-
-/* ==================================================================== */
-
-static inline int map_iter_init(map_iter_t * self, map_t * map, uint32_t flags)
-{
- assert(self != NULL);
- assert(map != NULL);
- return tree_iter_init((tree_iter_t *) self, (tree_t *) map, flags);
-}
-
-int map_iter_clear(map_iter_t * self)
-{
- assert(self != NULL);
- return tree_iter_clear((tree_iter_t *) self);
-}
-
-static inline map_node_t *map_iter_elem(map_iter_t * self)
-{
- assert(self != NULL);
- return (map_node_t *) tree_iter_elem((tree_iter_t *) self);
-}
-
-static inline map_node_t *map_iter_inc(map_iter_t * self)
-{
- assert(self != NULL);
- return (map_node_t *) tree_iter_inc((tree_iter_t *) self);
-}
-
-static inline map_node_t *map_iter_dec(map_iter_t * self)
-{
- assert(self != NULL);
- return (map_node_t *) tree_iter_dec((tree_iter_t *) self);
-}
-
-/* ==================================================================== */
-
-#endif /* __MAP_ITER_H__ */
diff --git a/clib/memory_leak_detection.h b/clib/memory_leak_detection.h
deleted file mode 100644
index d15ae97..0000000
--- a/clib/memory_leak_detection.h
+++ /dev/null
@@ -1,378 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/memory_leak_detection.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 */
-
-#ifndef MEMORY_LEAK_DETECTION_H
-
-#define MEMORY_LEAK_DETECTION_H 1
-
-#if ( FIND_MEMORY_LEAK > 0 )
-
-#warning Memory Leak Detection enabled!
-
-/* ================================================================= */
-/* ================================================================= */
-/* */
-/* The following functions are not meant to be called directly! Use */
-/* macros defined after the functions instead of the functions */
-/* themselves. */
-/* ================================================================= */
-/* ================================================================= */
-
-/*********************************************************************/
-/* */
-/* Function Name: MEMORY_func */
-/* */
-/* Descriptive Name: This function acts as a replacement for */
-/* malloc. It allocates memory (using malloc) */
-/* and enters that memory into a tracking */
-/* structure so that memory leaks, if any, may */
-/* be found. */
-/* */
-/* Input: size_t sz - The number of bytes to be allocated. */
-/* unsigned int Alignment - 0 for non-aligned (normal) */
-/* malloc, > 0 to return an */
-/* address aligned on a specific */
-/* memory boundary. If > 0, then */
-/* Alignment must be a power of 2 */
-/* and a multiple of sizeof(void *)*/
-/* void ** Memory_Location - The address of a variable which*/
-/* will hold the address of the */
-/* allocated by this function. */
-/* const char * mod_name - The name of the module from which*/
-/* this function was called. */
-/* const char * func - The name of the function from which */
-/* this function was called. */
-/* const int line - The line number of the code containing */
-/* the call to this function. */
-/* */
-/* Output: If Success : The function return value will be 0. */
-/* *Memory_Location will be set to the address*/
-/* of the first byte of the user portion of */
-/* any memory that was allocated. */
-/* */
-/* If Failure : The function return value will be EINVAL or*/
-/* ENOMEM. Errors may be reported on stderr. */
-/* *Memory_Location will be set to NULL. */
-/* */
-/* Error Handling: This function will abort if an error is */
-/* is detected. Errors could be lack of memory, or*/
-/* corruption of the internal structures used to */
-/* track allocated blocks of memory. */
-/* */
-/* Side Effects: Memory may be allocated, errors may be reported */
-/* on stderr. */
-/* */
-/* Notes: */
-/* */
-/*********************************************************************/
-int MEMORY_func(size_t sz,
- unsigned int Alignment,
- void **Memory_Location,
- const char *mod_name, const char *func, const int line);
-
-/*********************************************************************/
-/* */
-/* Function Name: MALLOC_func */
-/* */
-/* Descriptive Name: This function acts as a replacement for */
-/* malloc. It allocates memory (using malloc) */
-/* and enters that memory into a tracking */
-/* structure so that memory leaks, if any, may */
-/* be found. */
-/* */
-/* Input: size_t sz - The number of bytes to be allocated. */
-/* const char * mod_name - The name of the module from which*/
-/* this function was called. */
-/* const char * func - The name of the function from which */
-/* this function was called. */
-/* const int line - The line number of the code containing */
-/* the call to this function. */
-/* */
-/* Output: If Success : The function return value will be non-NULL.*/
-/* */
-/* If Failure : The function return value will be NULL. */
-/* Errors may be reported on stderr. */
-/* */
-/* Error Handling: This function will abort if an error is */
-/* is detected. Errors could be lack of memory, or*/
-/* corruption of the internal structures used to */
-/* track allocated blocks of memory. */
-/* */
-/* Side Effects: Memory may be allocated, errors may be reported */
-/* on stderr. */
-/* */
-/* Notes: */
-/* */
-/*********************************************************************/
-void *MALLOC_func(size_t sz, const char *mod_name, const char *func,
- const int line);
-
-/*********************************************************************/
-/* */
-/* Function Name: FREE_func */
-/* */
-/* Descriptive Name: This function frees a block of memory being */
-/* tracked by this module and removes the block */
-/* from its tracking structures. */
-/* */
-/* Input: const void * p - The address of the block of memory to */
-/* be freed. */
-/* const char * mod_name - The name of the module requesting*/
-/* the block of memory be freed. */
-/* const char * func - The name of the function requesting */
-/* the block of memory be freed. */
-/* const int line - The line number of the line of code in */
-/* module calling this function. */
-/* */
-/* Output: If Success : None. */
-/* */
-/* If Failure : Errors may be reported to stderr. */
-/* */
-/* Error Handling: This function causes the internal structures */
-/* of this module to be checked as part of the */
-/* process of freeing the address p. This may */
-/* cause errors to be reported on stderr. If any */
-/* errors are found, then the address p may not be */
-/* freed. */
-/* */
-/* Side Effects: The block of memory associated with the address p */
-/* will be freed and available for reallocation. */
-/* Also, the memory tracking structures in this */
-/* module will undergo a series of checks. */
-/* */
-/* Notes: This function was not intended to be called directly but */
-/* rather through the macro FREE. */
-/* */
-/*********************************************************************/
-void FREE_func(const void *p, const char *mod_name, const char *func,
- const int line);
-
-/*********************************************************************/
-/* */
-/* Function Name: Print_Leak_List */
-/* */
-/* Descriptive Name: This function walks the list of allocated */
-/* memory blocks and prints information about */
-/* each one. If this is done at program exit, */
-/* the resulting list of memory blocks most */
-/* likely represents leaked memory. */
-/* */
-/* Input: None. */
-/* */
-/* Output: If Success : If there are any memory blocks being */
-/* tracked by this module, information about */
-/* block still being tracked will be sent to */
-/* stderr. */
-/* */
-/* If Failure : Error messages may be sent to stderr. */
-/* */
-/* Error Handling: If errors are detected, then error messages are */
-/* output on stderr. */
-/* */
-/* Side Effects: The internal structures of this module are checked*/
-/* for errors with any errors being reported on */
-/* stderr. */
-/* */
-/* Notes: */
-/* */
-/*********************************************************************/
-void Print_Leak_List(void);
-
-/*********************************************************************/
-/* */
-/* Function Name: Test_Address_Allocation */
-/* */
-/* Descriptive Name: This function tests the specified address to */
-/* to see if it lies within an allocated block */
-/* tracked by this module. */
-/* */
-/* Input: void * p - The address to be tested. */
-/* */
-/* Output: If Success : If the address p was found, then 0 will be */
-/* returned if the address is the start of */
-/* a block of allocated memory. If the */
-/* address p was found within an allocated */
-/* block of memory, then 1 is returned. */
-/* */
-/* If Failure : If the address p was NOT found, then 2 is */
-/* returned. If there was an error in the */
-/* memory tracking system then 3 will be */
-/* returned. */
-/* */
-/* Error Handling: This function relies on the error handling */
-/* built into the Check_Leak_List function and */
-/* has no error handling of its own. */
-/* */
-/* Side Effects: If the list of memory allocations contains errors */
-/* then those errors will be detected and reported */
-/* on stderr. */
-/* */
-/* Notes: If NULL is passed in as the address to test, then the */
-/* integrity of the internal tracking structures will be */
-/* checked, in which case a return value of 0 signifies */
-/* that the internal tracking structures have passed the */
-/* checks and a return value of 3 indicates that errors */
-/* were found. */
-/* */
-/*********************************************************************/
-unsigned int Test_Address_Allocation(void *p);
-
-/*********************************************************************/
-/* */
-/* Function Name: Duplicate_String */
-/* */
-/* Descriptive Name: This function duplicates a string. The memory*/
-/* allocated for the duplicate is allocated */
-/* using the MALLOC_func routine in this module */
-/* and is thus tracked by this module. */
-/* */
-/* Input: const char * Source - The string to be copied. */
-/* const char * mod_name - The name of the module containing*/
-/* the function which called this */
-/* function. */
-/* const char * func - The name of the function calling */
-/* this function. */
-/* const int line - The line number of the line of code in */
-/* module calling this function. */
-/* */
-/* Output: If Success : The function return value will be non-NULL */
-/* and will point to a duplicate of the */
-/* string given in Source. */
-/* */
-/* If Failure : The function return value will be NULL. */
-/* */
-/* Error Handling: Any errors detected by this function result in */
-/* a function return value of NULL. */
-/* */
-/* Side Effects: The memory tracking features of this module are */
-/* employed to allocate memory for the duplicate */
-/* string produced by this funciton. */
-/* */
-/* Notes: */
-/* */
-/*********************************************************************/
-char *Duplicate_String(const char *Source,
- const char *mod_name, const char *func, const int line);
-
-/*********************************************************************/
-/* */
-/* Function Name: Realloc_func */
-/* */
-/* Descriptive Name: This function performs the same function as */
-/* the realloc function in the ANSI C library. */
-/* */
-/* Input: const void * p - The address of the block of memory to */
-/* be reallocated. */
-/* size_t size - The size of the memory block to return. */
-/* const char * mod_name - The name of the module requesting*/
-/* the block of memory be freed. */
-/* const char * func - The name of the function requesting */
-/* the block of memory be freed. */
-/* const int line - The line number of the line of code in */
-/* module calling this function. */
-/* */
-/* Output: If Success : The function return value will be a pointer*/
-/* to the new block of memory. */
-/* */
-/* If Failure : NULL will be returned and errno will be set*/
-/* to a non-null error code. */
-/* */
-/* Error Handling: This function causes the internal structures */
-/* of this module to be checked. This may */
-/* cause errors to be reported on stderr. If any */
-/* errors are found, then the address p may not be */
-/* freed. */
-/* */
-/* Side Effects: A new block of memory of size bytes will be */
-/* allocated, the contents of the current block will */
-/* be copied to the new block (at least as much as */
-/* will fit, and the current block will be freed. */
-/* This will cause internal structures in this module*/
-/* to be modified accordingly. */
-/* */
-/* Notes: This function was not intended to be called directly but */
-/* rather through the macro REALLOC. */
-/* */
-/* If p is NULL, then this will cause this function to */
-/* behave like malloc. */
-/* */
-/* If size is 0, then this will cause this function to */
-/* behave like free. */
-/* */
-/*********************************************************************/
-void *Realloc_func(void *p,
- size_t size,
- const char *mod_name, const char *func, const int line);
-
-/* ================================================================= */
-/* ================================================================= */
-/* */
-/* Macros to use for accessing the functions in this module. */
-/* */
-/* ================================================================= */
-/* ================================================================= */
-
-#ifdef MALLOC
-#undef MALLOC
-#endif
-#ifdef FREE
-#undef FREE
-#endif
-
-/* This macro should be used in place of posix_memalign. */
-#define POSIX_MEMALIGN(a, b, c ) MEMORY_func( c, b, a, __FILE__, __func__, __LINE__ )
-
-/* This macro should be used in place of the malloc function. */
-#define MALLOC( a ) MALLOC_func( a, __FILE__, __func__, __LINE__ )
-
-/* This macro should be used in place of the free function. */
-#define FREE( a ) FREE_func( a, __FILE__, __func__, __LINE__ )
-
-/* This macro should be used to print a list of allocated memory blocks. */
-#define PRINT_ALLOCATION_LIST Print_Leak_List()
-
-/* This macro should be used to see if an address lies within a block of
- memory being tracked by this module. */
-#define ADDRESS_CHECK( p ) Test_Address_Allocation( p )
-
-/* This macro should be used in place of the strdup function. */
-#define STRDUP( p ) Duplicate_String( p, __FILE__, __func__, __LINE__ )
-
-/* This macro should be used in place of the realloc function. */
-#define REALLOC( p, s ) Realloc_func( p, s, __FILE__, __func__, __LINE__ )
-
-#else
-
-#define POSIX_MEMALIGN(a, b, c ) posix_memalign( a, b, c )
-#define MALLOC(s) malloc(s)
-#define FREE(p) free(p)
-#define PRINT_ALLOCATION_LIST
-#define ADDRESS_CHECK( p ) 0
-#define STRDUP( p ) strdup( p )
-#define REALLOC( p, s ) realloc( p, s )
-
-#endif
-
-#endif
diff --git a/clib/mq.h b/clib/mq.h
deleted file mode 100644
index 23657c6..0000000
--- a/clib/mq.h
+++ /dev/null
@@ -1,151 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/mq.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 mqueue.h
- * @brief Message queues
- * @author Shaun Wetzstein <shaun@us.ibm.com>
- * @date 2010-2011
- */
-
-#ifndef __MQUEUE_H__
-#define __MQUEUE_H__
-
-#include <stdint.h>
-#include <stdbool.h>
-#include <mqueue.h>
-
-#include "attribute.h"
-
-/* ==================================================================== */
-
-typedef struct mqueue mqueue_t; //!< Alias for the @em mqueue class
-typedef struct mq_attr mqueue_attr_t;
-
-#define INIT_MQUEUE {NULL,-1,-1}
-
-/*!
- * @brief POSIX message queues
- */
-struct mqueue {
- char *service; //!< Message queue name
-
- mqd_t in; //!< Inbound message queue
- mqd_t out; //!< Outbound message queue
-};
-
-/* ==================================================================== */
-
-/*!
- * @brief Constructs a @em mqueue object
- * @memberof mqueue
- * @param self [in] mqueue object @em self pointer
- * @param service [in] mqueue service name
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern int mqueue_init(mqueue_t *, const char *)
-/*! @cond */
-__nonnull((1, 2)) /*! @endcond */ ;
-
-/*!
- * @brief Destructs a @em mqueue object
- * @details Closes all message queues associated with this \em mqueue object
- * @memberof mqueue
- * @param self [in] mqueue object @em self pointer
- * @return None
- */
-extern int mqueue_delete(mqueue_t *)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Create the server-side of a @em mqueue object
- * @memberof mqueue
- * @param self [in] mqueue object @em self pointer
- * @param tid [in] thread id
- * @return None
- */
-extern int mqueue_create(mqueue_t *, pid_t)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Create the client-side of a @em mqueue object
- * @memberof mqueue
- * @param self [in] mqueue object @em self pointer
- * @param path [in] FIX ME
- * @return None
- */
-extern int mqueue_open(mqueue_t *, char *)
-/*! @cond */
-__nonnull((1, 2)) /*! @endcond */ ;
-
-/*!
- * @brief Close a @em mqueue object
- * @memberof mqueue
- * @param self [in] mqueue object @em self pointer
- * @param path [in] FIX ME
- * @return None
- */
-extern int mqueue_close(mqueue_t *, char *)
-/*! @cond */
-__nonnull((1, 2)) /*! @endcond */ ;
-
-/*!
- * @brief Get message queue operating attributes of a @em mqueue object
- * @memberof mqueue
- * @param self [in] mqueue object @em self pointer
- * @return Initialized mqueue_attr object
- */
-extern mqueue_attr_t mqueue_getattr(mqueue_t *)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Write (send) a message to a @em mqueue object
- * @memberof mqueue
- * @param self [in] mqueue object @em self pointer
- * @param ptr [in] Reference to data bytes to send
- * @param ptr [in] Length (in bytes) of the data bytes
- * @return non-0 on success, 0 othereise
- */
-extern int mqueue_send(mqueue_t *, void *, size_t)
-/*! @cond */
-__nonnull((1, 2)) /*! @endcond */ ;
-
-/*!
- * @brief Read (receive) a message from a @em mqueue object
- * @memberof mqueue
- * @param self [in] mqueue object @em self pointer
- * @param ptr [out] Reference to data bytes to send
- * @param ptr [in] Length (in bytes) of the buffer referenced by @em ptr
- * @return non-0 on success, 0 othereise
- */
-extern int mqueue_receive(mqueue_t *, void *, size_t)
-/*! @cond */
-__nonnull((1, 2)) /*! @endcond */ ;
-
-#endif /* __MQUEUE_H__ */
diff --git a/clib/queue.h b/clib/queue.h
index 6e5c028..30ad80c 100644
--- a/clib/queue.h
+++ b/clib/queue.h
@@ -43,7 +43,6 @@ typedef list_node queue_node;
#define queue_init(q) list_init((list *)(q))
#define queue_push(q,n) list_add_tail((list *)(q),(n))
#define queue_pop(q) list_remove_head((list *)(q))
-#define stack_empty(q) list_empty((list *)(q))
#define queue_dump(q,s) list_dump((list *)(q),(s))
#define queue_entry(n, t, m) list_entry((n),(t),(m))
diff --git a/clib/signal.h b/clib/signal.h
deleted file mode 100644
index 06f2243..0000000
--- a/clib/signal.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/signal.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: signal.h
- * Author: Shaun Wetzstein <shaun@us.ibm.com>
- * Descr: File descriptor activity callback signaler
- * Note:
- * Date: 10/03/10
- */
-
-#ifndef __SIGNAL_H__
-#define __SIGNAL_H__
-
-#include <stdint.h>
-#include <stdbool.h>
-
-#include <sys/epoll.h>
-#include <sys/signalfd.h>
-
-#include "attribute.h"
-#include "builtin.h"
-#include "assert.h"
-
-#include "tree.h"
-#include "array.h"
-
-/* ======================================================================= */
-
-typedef struct signal signal_t;
-typedef struct signalfd_siginfo signal_event_t;
-
-struct signal {
- int fd;
-
- sigset_t mask;
- int flags;
-};
-
-/* ======================================================================= */
-
-extern void signal_init(signal_t * self) __nonnull((1));
-extern void signal_delete(signal_t * self) __nonnull((1));
-
-extern int signal_fileno(signal_t * self) __nonnull((1));
-
-extern int signal_setmask(signal_t * self, const sigset_t mask) __nonnull((1));
-
-#if 0
-#define signalfd_wait(...) STRCAT(signalfd_wait, NARGS(__VA_ARGS__))(__VA_ARGS__)
-extern void signal_wait1(signal_t *) __nonnull((1));
-extern void signal_wait2(_sisignal_tgnal *, int) __nonnull((1));
-#endif
-
-/* ======================================================================= */
-
-#endif /* __SIGNAL_H__ */
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/array.c b/clib/src/array.c
deleted file mode 100644
index 4a0581a..0000000
--- a/clib/src/array.c
+++ /dev/null
@@ -1,497 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/src/array.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 */
-
-/*
- * File: array.c
- * Author: Shaun Wetzstein <shaun@us.ibm.com>
- * Descr: Sparse Array
- * Note:
- * Date: 08/29/10
- */
-
-#include <unistd.h>
-#include <stdarg.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 "hash.h"
-#include "array.h"
-#include "slab.h"
-#include "mqueue.h"
-#include "tree.h"
-#include "tree_iter.h"
-#include "bb_trace.h"
-#include "memory_leak_detection.h"
-
-/*! @cond */
-#define ARRAY_ELEM_SIZE_MIN 1
-#define ARRAY_ELEM_NUM_MIN 64
-
-#define ARRAY_MAGIC 0x48444152
-#define ARRAY_NODE_MAGIC 0x4E444152
-/*! @endcond */
-
-/* ======================================================================= */
-
-/*! @cond */
-typedef struct array_node array_node_t;
-
-struct array_node {
- uint32_t magic;
- uint32_t address;
-
- tree_node_t node;
-};
-
-const char *__array_msg[] = {
- "array: unexpected NULL pointer",
- "array: unexpected cache and/or alloc size",
- "array: out-of-memory",
- "array: uninitialized array element",
- "array: unexpected magic number",
- "array: unexpected NULL message channel",
-};
-
-#define ARRAY_NULL (__array_msg[0])
-#define ARRAY_SIZE (__array_msg[1])
-#define ARRAY_OOM (__array_msg[2])
-#define ARRAY_UNINIT_ELEM (__array_msg[3])
-#define ARRAY_MAGIC_CHECK (__array_msg[4])
-#define ARRAY_MQ_NULL (__array_msg[5])
-/*! @endcond */
-
-/* ======================================================================= */
-
-#define __index_to_page(i,s) \
-({ \
- typeof(i) _p = ((i) / (s)); \
- (i) >= 0 ? _p :_p - 1; \
-})
-
-#define __index_to_page_hashed(i,s) \
-({ \
- typeof(i) _h = int64_hash1(__index_to_page((i),(s))); \
- _h; \
-})
-
-#define __page_to_low(p,s) \
-({ \
- typeof(p) _l = (p) * (s); \
- (p) >= 0 ? _l : _l - 1; \
-})
-
-#define __page_to_high(p,s) \
-({ \
- typeof(p) _h = (p) * (s) + (s) - (typeof(p))1; \
- _h; \
-})
-
-/* ======================================================================= */
-
-static array_node_t *__array_grow(array_t * self, size_t idx)
-{
- if (unlikely(self == NULL))
- throw_unexpected(ARRAY_NULL);
-
- array_node_t *node = NULL;
- switch (POSIX_MEMALIGN
- ((void **)&node, self->page_size, self->page_size)) {
- case EINVAL:
- throw_unexpected(ARRAY_SIZE);
- case ENOMEM:
- throw_unexpected(ARRAY_OOM);
- }
- assert(node != NULL);
-
- node->magic = ARRAY_NODE_MAGIC;
- node->address = (uint32_t) node;
-
- const void *key =
- (const void *)__index_to_page_hashed(idx, self->elem_num);
- tree_node_init(&node->node, key);
-
- splay_insert(&self->tree, &node->node);
- self->pages++;
-
- size_t page = __index_to_page(idx, self->elem_num);
-
- self->low = min(self->low, __page_to_low(page, self->elem_num));
- self->high = max(self->high, __page_to_high(page, self->elem_num));
-
- return node;
-}
-
-static int __array_compare(const int i1, const int i2)
-{
- return i1 - i2;
-}
-
-void array_init(array_t * self, size_t elem_size, size_t elem_num)
-{
- if (unlikely(self == NULL))
- throw_unexpected(ARRAY_NULL);
-
- self->magic = ARRAY_MAGIC;
- self->high = 0;
- self->low = UINT32_MAX;
- self->size = 0;
- self->pages = 0;
-
- self->elem_size = max(elem_size, ARRAY_ELEM_SIZE_MIN);
- self->elem_num = max(elem_num, ARRAY_ELEM_NUM_MIN);
-
- self->page_size = __round_pow2(elem_size * elem_num);
-
- self->map_size = align(elem_num / CHAR_BIT, sizeof(uint32_t));
-
- self->elem_num =
- (self->page_size - sizeof(array_node_t) -
- self->map_size) / self->elem_size;
-
- tree_init(&self->tree, (compare_f) __array_compare);
-}
-
-static void __array_delete(array_t * self)
-{
- if (self != NULL) {
- while (self->tree.root != NULL) {
- array_node_t *node;
- node =
- container_of(tree_root(&self->tree), array_node_t,
- node);
- splay_remove(&self->tree, &node->node);
- FREE(node);
- }
- tree_init(&self->tree, (compare_f) __array_compare);
- }
-}
-
-void array_delete(array_t * self)
-{
- __array_delete(self);
-}
-
-static void *__array_find_page(array_t * self, size_t idx)
-{
- const void *hash =
- (const void *)__index_to_page_hashed(idx, self->elem_num);
- tree_node_t *node = tree_find(&self->tree, hash);
-
- if (node == NULL)
- return (void *)__array_grow(self, idx);
- else
- return (void *)container_of(node, array_node_t, node);
-
- return NULL;
-}
-
-static uint8_t *__array_find_map(array_t * self, size_t idx)
-{
- if (unlikely(self == NULL))
- throw_unexpected(ARRAY_NULL);
-
- const void *hash =
- (const void *)__index_to_page_hashed(idx, self->elem_num);
- uint8_t *map = (uint8_t *) tree_find(&self->tree, hash);
- if (map != NULL)
- map += sizeof(tree_node_t);
-
- return map;
-}
-
-const void *array_at(array_t * self, size_t idx)
-{
- if (unlikely(self == NULL))
- throw_unexpected(ARRAY_NULL);
-
- uint32_t offset = idx % self->elem_num;
-
- uint8_t *map = __array_find_page(self, idx);
- map += sizeof(array_node_t);
-
- uint8_t byte = offset / CHAR_BIT;
- uint8_t mask = 0x80 >> (offset % CHAR_BIT);
-
- if ((map[byte] & mask) == 0)
- throw_unexpected(ARRAY_UNINIT_ELEM);
-
- return map + self->map_size + (self->elem_size * offset);
-}
-
-void array_get3(array_t * self, size_t elem_off, void *ptr)
-{
- return array_get4(self, elem_off, ptr, 1);
-}
-
-void array_get4(array_t * self, size_t elem_off, void *ptr, size_t elem_num)
-{
- if (unlikely(self == NULL))
- throw_unexpected(ARRAY_NULL);
-
- while (0 < elem_num) {
- memcpy(ptr, array_at(self, elem_off), self->elem_size);
-
- elem_off++;
- elem_num--;
-
- ptr += self->elem_size;
- }
-}
-
-void __array_put(array_t * self, size_t elem_off, const void *ptr)
-{
- if (unlikely(self == NULL))
- throw_unexpected(ARRAY_NULL);
-
- uint32_t offset = elem_off % self->elem_num;
-
- uint8_t *map = __array_find_page(self, elem_off);
- map += sizeof(array_node_t);
-
- uint8_t byte = offset / CHAR_BIT;
- uint8_t mask = 0x80 >> (offset % CHAR_BIT);
-
- if ((map[byte] & mask) == 0)
- self->size++;
-
- map[byte] |= mask;
-
- memcpy(map + self->map_size + (self->elem_size * offset),
- ptr, self->elem_size);
-}
-
-void array_put3(array_t * self, size_t elem_off, const void *ptr)
-{
- return array_put4(self, elem_off, ptr, 1);
-}
-
-void array_put4(array_t * self, size_t elem_off, const void *ptr,
- size_t elem_num)
-{
- if (unlikely(self == NULL))
- throw_unexpected(ARRAY_NULL);
-
- while (0 < elem_num) {
- __array_put(self, elem_off, ptr);
-
- elem_off++;
- elem_num--;
-
- ptr += self->elem_size;
- }
-}
-
-bool array_status2(array_t * self, size_t idx)
-{
- uint8_t *map = __array_find_map(self, idx);
-
- uint32_t offset = idx % self->elem_num;
- uint8_t byte = offset / CHAR_BIT;
- uint8_t mask = 0x80 >> (offset % CHAR_BIT);
-
- return ! !(map[byte] & mask);
-}
-
-bool array_status3(array_t * self, size_t idx, bool status)
-{
- uint8_t *map = __array_find_map(self, idx);
-
- if (map == NULL) {
- map = (uint8_t *) __array_grow(self, idx);
- map += sizeof(array_node_t);
- }
-
- uint32_t offset = idx % self->elem_num;
- uint8_t byte = offset / CHAR_BIT;
- uint8_t mask = 0x80 >> (offset % CHAR_BIT);
-
- bool ret = ! !(map[byte] & mask);
-
- map[byte] &= ~mask;
- if (status)
- map[byte] |= mask;
-
- return ret;
-}
-
-void array_resize(array_t * self, size_t size)
-{
- if (unlikely(self == NULL))
- throw_unexpected(ARRAY_NULL);
- while (0 < size) {
- (void)__array_grow(self, self->high + 1);
- size /= self->elem_num;
- }
-}
-
-size_t array_size(array_t * self)
-{
- if (unlikely(self == NULL))
- throw_unexpected(ARRAY_NULL);
- return self->size;
-}
-
-size_t array_pages(array_t * self)
-{
- if (unlikely(self == NULL))
- throw_unexpected(ARRAY_NULL);
- return self->pages;
-}
-
-size_t array_capacity(array_t * self)
-{
- if (unlikely(self == NULL))
- throw_unexpected(ARRAY_NULL);
- return self->high - self->low + 1;
-}
-
-size_t array_low(array_t * self)
-{
- if (unlikely(self == NULL))
- throw_unexpected(ARRAY_NULL);
- return self->low;
-}
-
-size_t array_high(array_t * self)
-{
- if (unlikely(self == NULL))
- throw_unexpected(ARRAY_NULL);
- return self->high;
-}
-
-void array_send(array_t * self, mqueue_t * mq)
-{
- if (unlikely(self == NULL))
- throw_unexpected(ARRAY_NULL);
- if (unlikely(mq == NULL))
- throw_unexpected(ARRAY_MQ_NULL);
-
- mqueue_send(mq, (char *)self, sizeof(*self));
-
- tree_iter_t it;
- tree_iter_init(&it, &self->tree, TI_FLAG_FWD);
-
- array_node_t *node;
- tree_for_each(&it, node, node) {
- if (node->magic != ARRAY_NODE_MAGIC)
- throw_unexpected(ARRAY_MAGIC_CHECK);
-
- mqueue_send(mq, (char *)node, self->page_size);
- }
-}
-
-void array_receive(array_t * self, mqueue_t * mq)
-{
- if (unlikely(self == NULL))
- throw_unexpected(ARRAY_NULL);
- if (unlikely(mq == NULL))
- throw_unexpected(ARRAY_MQ_NULL);
-
- __array_delete(self);
-
- mqueue_attr_t attr = mqueue_getattr(mq);
-
- array_node_t *node = NULL;
- switch (POSIX_MEMALIGN
- ((void **)&node, attr.mq_msgsize, attr.mq_msgsize)) {
- case EINVAL:
- throw_unexpected(ARRAY_SIZE);
- case ENOMEM:
- throw_unexpected(ARRAY_OOM);
- }
- assert(node != NULL);
-
- ssize_t len = mqueue_receive(mq, (void *)node, attr.mq_msgsize);
- assert(0 < len);
-
- memcpy(self, (void *)node, sizeof(*self));
- tree_init(&self->tree, (compare_f) __array_compare);
-
- for (int i = 0; i < array_pages(self); i++) {
- if (node == NULL) {
- switch (POSIX_MEMALIGN
- ((void **)&node, attr.mq_msgsize,
- attr.mq_msgsize)) {
- case EINVAL:
- throw_unexpected(ARRAY_SIZE);
- case ENOMEM:
- throw_unexpected(ARRAY_OOM);
- }
- }
-
- len = mqueue_receive(mq, (void *)node, attr.mq_msgsize);
- assert(0 < len);
-
- node->address = (uint32_t) node;
- tree_node_init(&node->node, node->node.key);
- splay_insert(&self->tree, &node->node);
-
- node = NULL;
- }
-}
-
-void array_dump(array_t * self, FILE * out)
-{
- if (self != NULL) {
- fprintf(out,
- "array: [ page_size: %5u pages: %5u map_size: %5u capacity: %10u ]\n",
- self->page_size, self->pages, self->map_size,
- array_capacity(self));
- fprintf(out,
- " [ elem_size: %5u elem_num: %5u size: %10u range: (%u....%u) ]\n",
- self->elem_size, self->elem_num, array_size(self),
- array_low(self), array_high(self));
-
- dump_memory(out, (unsigned long)self, self, sizeof(*self));
-
- tree_iter_t it;
- for (tree_iter_init(&it, &self->tree, TI_FLAG_FWD);
- tree_iter_elem(&it); tree_iter_inc(&it)) {
- array_node_t *node;
- node =
- container_of(tree_iter_elem(&it), array_node_t,
- node);
-
- fprintf(out, "magic[%x] address[%x]\n",
- node->magic, node->address);
- fprintf(out,
- "n[%p] left[%p] right[%p] parent[%p] key[%p] \n",
- &node->node, node->node.left, node->node.right,
- node->node.parent, node->node.key);
-
- dump_memory(out, (unsigned long)node, node,
- self->page_size);
- }
- }
-}
-
-/* ======================================================================= */
diff --git a/clib/src/array_iter.c b/clib/src/array_iter.c
deleted file mode 100644
index f7569c9..0000000
--- a/clib/src/array_iter.c
+++ /dev/null
@@ -1,187 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/src/array_iter.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 */
-
-/*
- * File: array_iter.c
- * Author: Shaun Wetzstein <shaun@us.ibm.com>
- * Descr: dynamic array
- * Note:
- * Date: 10/22/10
- */
-
-#include <unistd.h>
-#include <stdarg.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 "hash.h"
-#include "nargs.h"
-#include "array_iter.h"
-
-/* ======================================================================= */
-
-const char *__array_iter_msg[] = {
- "array_iter: unexpected NULL pointer",
- "array_iter: index out-of-range",
-};
-
-#define ARRAY_ITER_NULL (__array_iter_msg[0])
-#define ARRAY_ITER_RANGE (__array_iter_msg[1])
-
-/* ======================================================================= */
-
-static inline const void *__array_iter_bwd(array_iter_t * self)
-{
- size_t low = array_low(self->array);
- const void *ret = NULL;
-
- if (low < self->idx)
- self->idx--;
-
- while (low < self->idx) {
- if (array_status(self->array, self->idx))
- break;
- self->idx--;
- }
-
- if (low < self->idx)
- ret = array_at(self->array, self->idx);
-
- return ret;
-}
-
-static inline const void *__array_iter_fwd(array_iter_t * self)
-{
- size_t high = array_high(self->array);
- const void *ret = NULL;
-
- if (self->idx < high)
- self->idx++;
-
- while (self->idx < high) {
- if (array_status(self->array, self->idx))
- break;
- self->idx++;
- }
-
- if (self->idx < high)
- ret = array_at(self->array, self->idx);
-
- return ret;
-}
-
-void array_iter_init(array_iter_t * self, array_t * array, uint32_t flags)
-{
- if (unlikely(self == NULL))
- throw_unexpected(ARRAY_ITER_NULL);
- if (unlikely(array == NULL))
- throw_unexpected(ARRAY_ITER_NULL);
-
- self->flags = flags;
- self->array = array;
-
- if (self->flags & AI_FLAG_BWD) {
- self->idx = array_high(self->array);
- __array_iter_bwd(self);
- } else {
- self->idx = array_low(self->array);
- __array_iter_fwd(self);
- }
-}
-
-void array_iter_clear(array_iter_t * self)
-{
- if (unlikely(self == NULL))
- throw_unexpected(ARRAY_ITER_NULL);
-
- if (self->flags & AI_FLAG_BWD)
- self->idx = array_high(self->array);
- else
- self->idx = array_low(self->array);
-
- self->array = NULL;
-}
-
-const void *array_iter_elem(array_iter_t * self)
-{
- if (unlikely(self == NULL))
- throw_unexpected(ARRAY_ITER_NULL);
- if (self->idx < array_low(self->array))
- throw_unexpected(ARRAY_ITER_RANGE);
- if (array_high(self->array) <= self->idx)
- throw_unexpected(ARRAY_ITER_RANGE);
-
- return array_status(self->array, self->idx) ?
- array_at(self->array, self->idx) : NULL;
-}
-
-const void *array_iter_inc1(array_iter_t * self)
-{
- return array_iter_inc2(self, 1);
-}
-
-const void *array_iter_inc2(array_iter_t * self, size_t inc)
-{
- if (unlikely(self == NULL))
- throw_unexpected(ARRAY_ITER_NULL);
-
- const void *ret = NULL;
-
- if (self->flags & AI_FLAG_BWD)
- ret = __array_iter_bwd(self);
- else
- ret = __array_iter_fwd(self);
-
- return ret;
-}
-
-const void *array_iter_dec1(array_iter_t * self)
-{
- return array_iter_dec2(self, 1);
-}
-
-const void *array_iter_dec2(array_iter_t * self, size_t dec)
-{
- if (unlikely(self == NULL))
- throw_unexpected(ARRAY_ITER_NULL);
-
- const void *ret = NULL;
-
- if (self->flags & AI_FLAG_BWD)
- ret = __array_iter_fwd(self);
- else
- ret = __array_iter_bwd(self);
-
- return ret;
-}
-
-/* ======================================================================= */
diff --git a/clib/src/crc32.c b/clib/src/crc32.c
deleted file mode 100644
index 580e597..0000000
--- a/clib/src/crc32.c
+++ /dev/null
@@ -1,157 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/src/crc32.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 */
-
-/* Crc - 32 BIT ANSI X3.66 CRC checksum files */
-
-#include <stdio.h>
-#include <stdint.h>
-
-#include "crc32.h"
-
-/**********************************************************************\
-|* Demonstration program to compute the 32-bit CRC used as the frame *|
-|* check sequence in ADCCP (ANSI X3.66, also known as FIPS PUB 71 *|
-|* and FED-STD-1003, the U.S. versions of CCITT's X.25 link-level *|
-|* protocol). The 32-bit FCS was added via the Federal Register, *|
-|* 1 June 1982, p.23798. I presume but don't know for certain that *|
-|* this polynomial is or will be included in CCITT V.41, which *|
-|* defines the 16-bit CRC (often called CRC-CCITT) polynomial. FIPS *|
-|* PUB 78 says that the 32-bit FCS reduces otherwise undetected *|
-|* errors by a factor of 10^-5 over 16-bit FCS. *|
-\**********************************************************************/
-
-/* Copyright (C) 1986 Gary S. Brown. You may use this program, or
- code or tables extracted from it, as desired without restriction.*/
-
-/* First, the polynomial itself and its table of feedback terms. The */
-/* polynomial is */
-/* X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 */
-/* Note that we take it "backwards" and put the highest-order term in */
-/* the lowest-order bit. The X^32 term is "implied"; the LSB is the */
-/* X^31 term, etc. The X^0 term (usually shown as "+1") results in */
-/* the MSB being 1. */
-
-/* Note that the usual hardware shift register implementation, which */
-/* is what we're using (we're merely optimizing it by doing eight-bit */
-/* chunks at a time) shifts bits into the lowest-order term. In our */
-/* implementation, that means shifting towards the right. Why do we */
-/* do it this way? Because the calculated CRC must be transmitted in */
-/* order from highest-order term to lowest-order term. UARTs transmit */
-/* characters in order from LSB to MSB. By storing the CRC this way, */
-/* we hand it to the UART in the order low-byte to high-byte; the UART */
-/* sends each low-bit to hight-bit; and the result is transmission bit */
-/* by bit from highest- to lowest-order term without requiring any bit */
-/* shuffling on our part. Reception works similarly. */
-
-/* The feedback terms table consists of 256, 32-bit entries. Notes: */
-/* */
-/* 1. The table can be generated at runtime if desired; code to do so */
-/* is shown later. It might not be obvious, but the feedback */
-/* terms simply represent the results of eight shift/xor opera- */
-/* tions for all combinations of data and CRC register values. */
-/* */
-/* 2. The CRC accumulation logic is the same for all CRC polynomials, */
-/* be they sixteen or thirty-two bits wide. You simply choose the */
-/* appropriate table. Alternatively, because the table can be */
-/* generated at runtime, you can start by generating the table for */
-/* the polynomial in question and use exactly the same "updcrc", */
-/* if your application needn't simultaneously handle two CRC */
-/* polynomials. (Note, however, that XMODEM is strange.) */
-/* */
-/* 3. For 16-bit CRCs, the table entries need be only 16 bits wide; */
-/* of course, 32-bit entries work OK if the high 16 bits are zero. */
-/* */
-/* 4. The values must be right-shifted by eight bits by the "updcrc" */
-/* logic; the shift must be unsigned (bring in zeroes). On some */
-/* hardware you could probably optimize the shift in assembler by */
-/* using byte-swap instructions. */
-
-static uint32_t __crc32_table[] = { /* CRC polynomial 0xedb88320 */
- 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
- 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
- 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
- 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
- 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
- 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
- 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
- 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
- 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
- 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
- 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,
- 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
- 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,
- 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
- 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
- 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
- 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,
- 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
- 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,
- 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
- 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
- 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
- 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,
- 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
- 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
- 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
- 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,
- 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
- 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
- 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
- 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
- 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
- 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
- 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
- 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
- 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
- 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
- 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
- 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,
- 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
- 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
- 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
- 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
-};
-
-inline uint32_t clib_crc32(unsigned char octet, uint32_t crc)
-{
- return __crc32_table[(crc ^ (uint8_t) octet) & 0xff] ^ (crc >> 8);
-}
-
-uint32_t memcpy32(void *__restrict __dst, const void *__restrict __src,
- size_t __n)
-{
- register uint32_t __crc = 0xFFFFFFFF;
-
- if (__dst == NULL)
- for (; __n; --__n, ++__src) {
- __crc = clib_crc32(*(uint8_t *) __src, __crc);
- } else
- for (; __n; --__n, ++__src, ++__dst) {
- __crc = clib_crc32(*(uint8_t *) __src, __crc);
- *(uint8_t *) __dst = *(uint8_t *) __src;
- }
-
- return ~__crc;
-}
diff --git a/clib/src/crc32_main.c b/clib/src/crc32_main.c
deleted file mode 100644
index 889d096..0000000
--- a/clib/src/crc32_main.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/src/crc32_main.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 <errno.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include "crc32.h"
-
-void usage(void)
-{
- printf("Usage: crc32 infile\n");
-}
-
-int main(int argc, const char *argv[])
-{
- if (argc != 2) {
- usage();
- return 1;
- }
-
- int fd = open(argv[1], O_RDONLY);
- if (fd < 0) {
- printf("open %s: %s\n", argv[1], strerror(errno));
- return 1;
- }
-
- struct stat stat;
- int rc = fstat(fd, &stat);
- if (rc < 0) {
- printf("stat %s: %s\n", argv[1], strerror(errno));
- return 1;
- }
-
- off_t filesize = stat.st_size;
-
- void *in_buf = mmap(NULL, filesize, PROT_READ, MAP_PRIVATE, fd, 0);
- if (in_buf == MAP_FAILED) {
- /* FIXME could still try to use read().... */
- printf("mmap %d failed: %s\n", (uint32_t)filesize, strerror(errno));
- return 1;
- }
-
- rc = close(fd);
- if (rc < 0) {
- printf("close %s: %s\n", argv[1], strerror(errno));
- return 1;
- }
-
- unsigned long crc32 = memcpy32(NULL, in_buf, filesize);
-
- printf("%#010lx", crc32), fflush(stdout);
-
- return 0;
-}
diff --git a/clib/src/db.c b/clib/src/db.c
deleted file mode 100644
index 0f3c930..0000000
--- a/clib/src/db.c
+++ /dev/null
@@ -1,407 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/src/db.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 */
-
-/*
- * File: db.c
- * Author: Shaun Wetzstein <shaun@us.ibm.com>
- * Descr: SQlite wrapper
- * Note:
- * Date: 02/25/11
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <malloc.h>
-#include <sqlite3.h>
-#include <stdint.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-
-#include "assert.h"
-#include "err.h"
-
-#include "db.h"
-
-/* =======================================================================*/
-
-int db_init(db_t * self, const char *path)
-{
- assert(self != NULL);
-
- self->path = strdup(path);
- if (self->path == NULL) {
- ERRNO(errno);
- return -1;
- }
-
- self->db = NULL;
-
- return 0;
-}
-
-int db_delete(db_t * self)
-{
- if (self != NULL) {
- db_close(self);
- if (self->path != NULL)
- free((char *)self->path);
- memset(self, 0, sizeof(*self));
- }
-
- return 0;
-}
-
-int db_execute(db_t * self, const char *fmt, ...)
-{
- assert(self != NULL);
-
- va_list ap;
- va_start(ap, fmt);
- char *sql = NULL;
- vasprintf(&sql, fmt, ap);
-
- assert(sql != NULL);
-
- int rc = sqlite3_exec(self->db, sql, NULL, NULL, NULL);
- if (sql != NULL)
- free(sql);
-
- if (rc != DB_OK) {
- DBERR(self->db);
- return -1;
- }
-
- return 0;
-}
-
-int db_open(db_t * self, int flags)
-{
- assert(self != NULL);
-
- int rc = DB_OK;
-
- if (self->db != NULL)
- db_close(self);
-
- rc = sqlite3_open_v2(self->path, &self->db, flags, NULL);
- if (rc != DB_OK) {
- DBERR(self->db);
- return -1;
- }
-
- return rc;
-}
-
-int db_close(db_t * self)
-{
- assert(self != NULL);
-
- int rc = DB_OK;
-
- if (self->db != NULL) {
- /* finalize statements */
- rc = sqlite3_close(self->db);
- }
-
- return rc;
-}
-
-int db_register_function(db_t * self, const char *name, int argc, db_f func,
- void *data)
-{
- assert(self != NULL);
-
- int rc = DB_OK;
-
- rc = sqlite3_create_function(self->db, name, argc, SQLITE_ANY, data,
- func, NULL, NULL);
- if (rc != 0) {
- DBERR(self->db);
- return -1;
- }
-
- return rc;
-}
-
-int db_begin(db_t * self, transaction_type_t type)
-{
- assert(self != NULL);
-
- const char *tran_type = NULL;
-
- switch (type) {
- case tt_DEFERRED:
- tran_type = "DEFERRED";
- break;
- case tt_IMMEDIATE:
- tran_type = "IMMEDIATE";
- break;
- case tt_EXCLUSIVE:
- tran_type = "EXCLUSIVE";
- break;
- default:
- UNEXPECTED("'%d' invalid transaction type", type);
- return -1;
- }
-
- return db_execute(self, "BEGIN %s TRANSACTION", tran_type);
-}
-
-int db_commit(db_t * self)
-{
- assert(self != NULL);
- return db_execute(self, "COMMIT TRANSACTION");
-}
-
-int db_rollback(db_t * self)
-{
- assert(self != NULL);
- return db_execute(self, "ROLLBACK TRANSACTION");
-}
-
-/* =======================================================================*/
-
-int statement_init(statement_t * self, db_t * db)
-{
- assert(self != NULL);
- assert(db != NULL);
-
- self->db = db;
- self->stmt = NULL;
-
- return 0;
-}
-
-int statement_delete(statement_t * self)
-{
- assert(self != NULL);
-
- if (self->stmt != NULL) {
- statement_finalize(self);
- self->stmt = NULL;
- }
-
- self->db = NULL;
- free(self);
-
- return 0;
-}
-
-int statement_prepare(statement_t * self, const char *sql)
-{
- assert(self != NULL);
- assert(sql != NULL);
-
- int rc = DB_OK;
-
- if (self->stmt != NULL) {
- rc = sqlite3_finalize(self->stmt);
- if (rc != DB_OK) {
- SQLERR(self->db->db, self->stmt);
- return -1;
- }
- }
-
- rc = sqlite3_prepare_v2(self->db->db, sql, -1, &self->stmt, NULL);
- if (rc != DB_OK) {
- SQLERR(self->db->db, self->stmt);
- return -1;
- }
-
- return rc;
-}
-
-int statement_step(statement_t * self)
-{
- assert(self != NULL);
-
- int rc = DB_OK;
-
- if (self->stmt != NULL) {
- rc = sqlite3_step(self->stmt);
-
- switch (rc) {
- case DB_DONE:
- case DB_ROW:
- break;
- default:
- SQLERR(self->db->db, self->stmt);
- return -1;
- }
- }
-
- return rc;
-}
-
-int statement_reset(statement_t * self)
-{
- self = NULL;
- return 0;
-}
-
-int statement_finalize(statement_t * self)
-{
- assert(self != NULL);
-
- int rc = DB_OK;
-
- if (self->stmt != NULL) {
- rc = sqlite3_finalize(self->stmt);
- if (rc != DB_OK) {
- SQLERR(self->db->db, self->stmt);
- return -1;
- }
- self->stmt = NULL;
- }
-
- return rc;
-}
-
-int statement_bind_int(statement_t * self, int pos, int val)
-{
- assert(self != NULL);
-
- int rc = DB_OK;
-
- if (self->stmt != NULL) {
- rc = sqlite3_bind_int(self->stmt, pos, val);
- if (rc != DB_OK) {
- SQLERR(self->db->db, self->stmt);
- return -1;
- }
- }
-
- return rc;
-}
-
-int statement_bind_int64(statement_t * self, int pos, int64_t val)
-{
- assert(self != NULL);
-
- int rc = DB_OK;
-
- if (self->stmt != NULL) {
- rc = sqlite3_bind_int64(self->stmt, pos, val);
- if (rc != DB_OK) {
- SQLERR(self->db->db, self->stmt);
- return -1;
- }
- }
-
- return rc;
-}
-
-int statement_bind_text(statement_t * self, int pos, const char *val)
-{
- assert(self != NULL);
-
- int rc = DB_OK;
-
- if (self->stmt != NULL) {
- rc = sqlite3_bind_text(self->stmt, pos, val, -1,
- SQLITE_TRANSIENT);
- if (rc != DB_OK) {
- SQLERR(self->db->db, self->stmt);
- return -1;
- }
- }
-
- return rc;
-}
-
-int statement_bind_blob(statement_t * self, int pos, const void *val, int size)
-{
- assert(self != NULL);
-
- int rc = DB_OK;
-
- if (self->stmt != NULL) {
- rc = sqlite3_bind_blob(self->stmt, pos, val, size,
- SQLITE_TRANSIENT);
- if (rc != DB_OK) {
- SQLERR(self->db->db, self->stmt);
- return -1;
- }
- }
-
- return rc;
-}
-
-int statement_column_int(statement_t * self, int pos)
-{
- assert(self != NULL);
- return sqlite3_column_int(self->stmt, pos);
-}
-
-int64_t statement_column_int64(statement_t * self, int pos)
-{
- assert(self != NULL);
- return sqlite3_column_int64(self->stmt, pos);
-}
-
-int statement_column_bytes(statement_t * self, int pos)
-{
- assert(self != NULL);
- return sqlite3_column_bytes(self->stmt, pos);
-}
-
-const unsigned char *statement_column_text(statement_t * self, int pos)
-{
- assert(self != NULL);
-
- const unsigned char *rc = NULL;
-
- if (self->stmt != NULL) {
- rc = sqlite3_column_text(self->stmt, pos);
- if (rc == NULL) {
- SQLERR(self->db->db, self->stmt);
- return NULL;
- }
- }
-
- return rc;
-}
-
-const void *statement_column_blob(statement_t * self, int pos)
-{
- assert(self != NULL);
-
- const void *rc = NULL;
-
- if (self->stmt != NULL) {
- rc = sqlite3_column_blob(self->stmt, pos);
- if (rc == NULL) {
- SQLERR(self->db->db, self->stmt);
- return NULL;
- }
- }
-
- return rc;
-}
-
-/* =======================================================================*/
diff --git a/clib/src/dispatch.c b/clib/src/dispatch.c
deleted file mode 100644
index 046d554..0000000
--- a/clib/src/dispatch.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/src/dispatch.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 */
-
-/*
- * File: dispatch.c
- * Author: Shaun Wetzstein <shaun@us.ibm.com>
- * Descr:
- * Note:
- * Date: 10/03/10
- */
-
-#include <unistd.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <malloc.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-
-#include "misc.h"
-#include "nargs.h"
-#include "dispatch.h"
-
-#define DISPATCH_PAGE_SIZE 64
-#define DISPATCH_EVENT_SIZE 10
-
-/* ======================================================================= */
-
-const char *__dispatch_msg[] = {
- "dispatch: unexpected NULL self pointer",
- "dispatch: unexpected NULL callback structure",
-};
-
-#define DISPATCH_NULL (__dispatch_msg[0])
-#define DISPATCH_CALLBACK_NULL (__dispatch_msg[1])
-
-/* ======================================================================= */
-
-void dispatch_init(dispatch_t * self)
-{
- if (unlikely(self == NULL))
- throw_unexpected(DISPATCH_NULL);
-
- if (self->fd != -1)
- close(self->fd), self->fd = -1;
-
- self->fd = epoll_create1(EPOLL_CLOEXEC);
- if (unlikely(self->fd == -1))
- throw_errno(errno);
-
- array_init(&self->events, sizeof(struct epoll_event),
- DISPATCH_PAGE_SIZE);
-}
-
-void dispatch_delete(dispatch_t * self)
-{
- if (unlikely(self == NULL))
- throw_unexpected(DISPATCH_NULL);
- close(self->fd), self->fd = -1;
- array_delete(&self->events);
-}
-
-int dispatch_fileno(dispatch_t * self)
-{
- if (unlikely(self == NULL))
- throw_unexpected(DISPATCH_NULL);
- return self->fd;
-}
-
-int dispatch_add(dispatch_t * self, int fd, uint32_t events,
- dispatch_callback_t * cb)
-{
- if (unlikely(self == NULL))
- throw_unexpected(DISPATCH_NULL);
-
- array_status(&self->events, fd, true);
-
- struct epoll_event *ep;
- ep = (struct epoll_event *)array_at(&self->events, fd);
- ep->events = events;
- ep->data.u64 = (uint64_t) fd << 32;
- ep->data.ptr = (void *)cb;
-
- if (unlikely(epoll_ctl(self->fd, EPOLL_CTL_ADD, fd, ep)))
- throw_errno(errno);
-
- return fd;
-}
-
-void dispatch_remove(dispatch_t * self, int fd)
-{
- if (unlikely(self == NULL))
- throw_unexpected(DISPATCH_NULL);
-
- if (unlikely(epoll_ctl(self->fd, EPOLL_CTL_DEL, fd, NULL)))
- throw_errno(errno);
-
- array_status(&self->events, fd, false);
-}
-
-void dispatch_wait1(dispatch_t * self)
-{
- dispatch_wait2(self, -1);
-}
-
-void dispatch_wait2(dispatch_t * self, int timeout)
-{
- if (unlikely(self == NULL))
- throw_unexpected(DISPATCH_NULL);
-
- if (-1 < self->fd) {
- struct epoll_event events[DISPATCH_EVENT_SIZE];
-
- int rc = epoll_wait(self->fd, events,
- DISPATCH_EVENT_SIZE, timeout);
-
- if (0 < rc) {
- dump_memory(stdout, 0, events, sizeof(events));
- }
- for (int n = 0; n < rc; n++) {
- dispatch_callback_t *cb =
- (dispatch_callback_t *) events[n].data.ptr;
- if (cb != NULL) {
- printf
- ("cb[%p] fd[%d] data[%p] ep->data.u64[%lld]\n",
- cb, cb->fd, cb->data, events[n].data.u64);
- if (cb->func != NULL) {
- // dispatch_event ev = {events[n].data.u64 >> 32, events[n].events};
- dispatch_event_t ev =
- { cb->fd, events[n].events };
- cb->func(&ev, cb->data);
- }
- }
- }
- }
-}
-
-/* ======================================================================= */
diff --git a/clib/src/err.c b/clib/src/err.c
index 8312ffd..838c22f 100644
--- a/clib/src/err.c
+++ b/clib/src/err.c
@@ -44,7 +44,7 @@
#include "err.h"
-static pthread_key_t __err_key = 0;
+static list_t *__err_key = 0;
static const char *__err_type_name[] = {
[ERR_NONE] = "none",
@@ -68,7 +68,7 @@ void err_delete(err_t * self)
err_t *err_get(void)
{
- list_t *list = (list_t *) pthread_getspecific(__err_key);
+ list_t *list = __err_key;
err_t *self = NULL;
@@ -77,7 +77,7 @@ err_t *err_get(void)
if (list_empty(list)) {
free(list), list = NULL;
- assert(pthread_setspecific(__err_key, list) == 0);
+ __err_key = list;
}
}
@@ -88,13 +88,13 @@ void err_put(err_t * self)
{
assert(self != NULL);
- list_t *list = pthread_getspecific(__err_key);
+ list_t *list = __err_key;
if (list == NULL) {
list = (list_t *) malloc(sizeof(*list));
assert(list != NULL);
list_init(list);
- assert(pthread_setspecific(__err_key, list) == 0);
+ __err_key = list;
}
list_add_head(list, &self->node);
@@ -207,9 +207,3 @@ const char *err_type_name(err_t * self)
return __err_type_name[self->type];
}
-/* =======================================================================*/
-
-__constructor static void __err__ctor__(void)
-{
- assert(pthread_key_create(&__err_key, NULL) == 0);
-}
diff --git a/clib/src/exception.c b/clib/src/exception.c
deleted file mode 100644
index 747bb7d..0000000
--- a/clib/src/exception.c
+++ /dev/null
@@ -1,152 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/src/exception.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 */
-
-/*
- * File: exc.c
- * Author: Shaun Wetzstein <shaun@us.ibm.com>
- * Descr: {set,long}jmp implementation of exceptions for C code.
- * Note: using these macros will create an exception context
- * in each thread.
- * Date: 7/06/09
- */
-
-#include <errno.h>
-#include <assert.h>
-#include <pthread.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <execinfo.h>
-
-#include "exception.h"
-#include "misc.h"
-
-/* =======================================================================*/
-
-const char *exception_name[] = {
- "assertion",
- "unexpected",
- "errno",
-};
-
-typedef struct exception_context {
- pthread_once_t once;
- pthread_key_t key;
-} exception_context;
-
-/* =======================================================================*/
-
-static exception_context __exc_ctx = { PTHREAD_ONCE_INIT, 0 };
-
-static inline void __exc_key_create(void)
-{
- if (pthread_key_create(&__exc_ctx.key, NULL))
- __exc_throw(ASSERTION, NULL, 0, __FILE__, __LINE__);
-}
-
-/* =======================================================================*/
-
-void __exc_init(void)
-{
- if (pthread_once(&__exc_ctx.once, __exc_key_create))
- __exc_throw(ASSERTION, NULL, 0, __FILE__, __LINE__);
-}
-
-exception_frame_t *__exc_get_frame(void)
-{
- return (exception_frame_t *) (pthread_getspecific(__exc_ctx.key));
-}
-
-void __exc_set_frame(exception_frame_t * f)
-{
- if (pthread_setspecific(__exc_ctx.key, f))
- __exc_throw(ASSERTION, NULL, 0, __FILE__, __LINE__);
-}
-
-void __exc_backtrace(const char *fmt, ...)
-{
- if (fmt != NULL) {
- va_list va;
- va_start(va, fmt);
- vfprintf(stderr, fmt, va);
- va_end(va);
- }
-
- fprintf(stderr, "========== backtrace ==========\n");
- void *bt[1024];
- int nr = backtrace(bt, sizeof bt);
- backtrace_symbols_fd(bt, nr, fileno(stderr));
- fprintf(stderr, "========== backtrace ==========\n");
-}
-
-int __exc_throw(int ex, void *data, int size, const char *file, int line)
-{
- extern char *program_invocation_short_name;
-
- exception_frame_t *frame = __exc_get_frame();
-
- if (frame == NULL) {
- __exc_backtrace
- ("*** UNHANDLED EXCEPTION *** -- %s: %s(%d) ex=%d\n\n",
- program_invocation_short_name, file, line, ex);
- abort();
- }
-
- if (frame->magic != EXC_MAGIC) {
- __exc_backtrace
- ("*** CORRUPTED EXCEPTION FRAME *** -- %s: %s(%d) ex=%d\n\n",
- program_invocation_short_name, file, line, ex);
- abort();
- }
-
- frame->exc.file = file;
- frame->exc.line = line;
-
- frame->exc.data = data;
- frame->exc.size = size;
-
- longjmp(frame->jmp, ex);
-
- return -1;
-}
-
-int __exc_rethrow(int ex, void *data, int size, const char *file, int line)
-{
- exception_frame_t *frame = __exc_get_frame();
-
- if (frame != NULL)
- __exc_set_frame(frame->prev);
-
- return __exc_throw(ex, data, size, file, line);
-}
-
-const char *__exc_name(int exc)
-{
- return (exc < 0 || EXC_LAST <= exc) ? NULL : exception_name[exc];
-}
-
-__constructor void __exc_ctor(void)
-{
- __exc_init();
-}
diff --git a/clib/src/heap.c b/clib/src/heap.c
deleted file mode 100644
index 625f9e5..0000000
--- a/clib/src/heap.c
+++ /dev/null
@@ -1,159 +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"
-#include "memory_leak_detection.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/src/memory_leak_detection.c b/clib/src/memory_leak_detection.c
deleted file mode 100644
index 07c6bd3..0000000
--- a/clib/src/memory_leak_detection.c
+++ /dev/null
@@ -1,1275 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/src/memory_leak_detection.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 */
-
-#define PROGRAM_VERSION "0.0.0.1"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <pthread.h>
-#include <string.h>
-#include <errno.h>
-#include <execinfo.h>
-#include "bb_trace.h"
-
-/*--------------------------------------------------
- * Private Constants
- --------------------------------------------------*/
-
-#define LEAK_SIGNATURE 8283471
-#define SENTINEL_VALUE 0xD9B79573
-
-/*--------------------------------------------------
- * Private Type definitions
- --------------------------------------------------*/
-
-typedef unsigned int Sentinel_t;
-
-struct _Memory_Leak_Data {
- unsigned int Signature; /* Indentify this structure in memory */
- void *Mem_Address; /* The address actually returned by malloc. */
- unsigned int User_Size; /* The size of the allocation as requested by the user. */
- unsigned int Alignment; /* The alignment requested by the user. */
- const char *Module_Name; /* The name of the module containing the function which allocated this memory. */
- const char *Function_Name; /* The name of the function which allocated this memory. */
- unsigned int Line_Number; /* The line number of the MALLOC call in the function which allocated this memory. */
- struct _Memory_Leak_Data *Next; /* The next allocated block of memory (if any). */
- struct _Memory_Leak_Data *Previous; /* The previous allocated block of memory (if any). */
- Sentinel_t Starting_Sentinel; /* The starting sentinel used to detect buffer overrun/memory overwrite errors. */
-};
-
-typedef struct _Memory_Leak_Data Memory_Leak_Data_t;
-
-/*--------------------------------------------------
- Private global variables.
---------------------------------------------------*/
-
-static pthread_mutex_t Memory_Leak_Lock = PTHREAD_MUTEX_INITIALIZER; /* Mutex to serialize access to the chain of allocations. */
-static Memory_Leak_Data_t *Memory_Chain = NULL; /* The start of our chain of allocations. */
-static unsigned int Memory_Chain_Entries = 0; /* The number of items in our chain. */
-
-/*--------------------------------------------------
- Local functions
---------------------------------------------------*/
-
-void print_backtrace(void)
-{
-#define BT_SIZE 20
- void *bt[BT_SIZE];
- int nr = backtrace(&bt[0], BT_SIZE);
-
- fprintf(stderr, "========== backtrace ==========\n");
- backtrace_symbols_fd(bt, nr, fileno(stderr));
- fprintf(stderr, "========== backtrace ==========\n");
-
- return;
-}
-
-/*********************************************************************/
-/* */
-/* Function Name: Check_Leak_List */
-/* */
-/* Descriptive Name: */
-/* */
-/* Input: */
-/* */
-/* Output: If Success : */
-/* */
-/* If Failure : */
-/* */
-/* Error Handling: */
-/* */
-/* Side Effects: */
-/* */
-/* Notes: */
-/* */
-/*********************************************************************/
-static int Check_Leak_List(const void *p)
-{
- Memory_Leak_Data_t *Current_Item; /* Used to walk the memory allocation chain. */
- Memory_Leak_Data_t *Previous_Item; /* Used to check the memory allocation chain. */
- Sentinel_t *Ending_Sentinel; /* To allow access to the sentinel at the end of the allocated memory. */
- unsigned int Data_Start; /* The address of the first byte of the data area of the current allocation. */
- unsigned int Data_End; /* The first byte after the data area of the current allocation. */
- unsigned int Address_To_Test; /* The address we are looking for. */
- unsigned int Address_Found = 2; /* Used to track whether the address was found in the allocation list.
- If 2, then the address was not found. If 0, then the address was found and
- it is the start of the data area of an allocation. If 1, then the address
- was found and it lies within the data area of an allocation. */
- int rc = 0; /* Holds the return code. Assume success. */
- unsigned int Count = 0;
-
- FUNCTION_ENTRY()
-
- PRINT_FUNCTION_PARAMETER("Parameters:\n")
- PRINT_FUNCTION_PARAMETER(" p = %p\n", p)
-
- USER3_PRINT_LINE("Memory_Chain = %p", Memory_Chain)
- Current_Item = Memory_Chain;
- Previous_Item = NULL;
-
- if (p != NULL) {
- USER3_PRINT_LINE
- ("Request: Check the memory allocation list for p = %p.\n",
- p);
- } else {
- USER3_PRINT_LINE
- ("Request: Check the integrity of the memory allocation list.\n");
- USER3_PRINT_LINE(" Items expected in list: %d\n",
- Memory_Chain_Entries);
- }
-
- while (Current_Item != NULL) {
- /* Perform some simple checks on the items in the memory allocation list. */
- if (Current_Item->Signature == LEAK_SIGNATURE) {
-
- if (Current_Item->Starting_Sentinel == SENTINEL_VALUE) {
-
- /* Check the ending sentinel. */
- Ending_Sentinel =
- (Sentinel_t *) ((unsigned long)Current_Item +
- sizeof(Memory_Leak_Data_t) +
- Current_Item->User_Size);
- if (*Ending_Sentinel == SENTINEL_VALUE) {
-
- /* Check the previous pointer. */
- if (Current_Item->Previous ==
- Previous_Item) {
-
- if (p != NULL) {
- /* We have an address to check. Does this address lie within this memory allocation? */
- Data_End =
- (unsigned long)
- Ending_Sentinel;
- Data_Start =
- (unsigned
- long)((unsigned
- long)
- Current_Item
- +
- sizeof
- (Memory_Leak_Data_t));
- Address_To_Test =
- (unsigned long)p;
-
- if (Address_To_Test ==
- Data_Start) {
- /* This address was returned to the user by MALLOC_func. */
- Address_Found =
- 0;
- break;
- } else {
-
- if ((Address_To_Test > Data_Start) && (Address_To_Test < Data_End)) {
- /* The address lies within the data area of the current allocation. */
- Address_Found
- = 1;
- break;
- }
-
- }
-
- }
-
- } else {
- /* We have a pointer problem! The previous pointer field does not point to the previous entry in the list! */
- rc = 3;
- fprintf(stderr,
- "Link Error! The previous pointer of the current item does not point to the previous item in the allocation list!\n");
- fprintf(stderr,
- "Current_Item->Previous = %p, Actual Previous Item is %p.\n",
- Current_Item->Previous,
- Previous_Item);
- fprintf(stderr,
- "Item position in list: %d\n",
- Count);
- print_backtrace();
- }
-
- } else {
- rc = 3;
- fprintf(stderr,
- "Possible overrun error -- ending sentinel corrupted!\n"
- " Header Address: %p\n"
- " User Address: %p\n"
- " Size: %d\n"
- " Allocated in module %s, function %s, at line %d\n",
- Current_Item,
- (void *)((unsigned long)
- Current_Item +
- sizeof
- (Memory_Leak_Data_t)),
- Current_Item->User_Size,
- Current_Item->Module_Name,
- Current_Item->Function_Name,
- Current_Item->Line_Number);
- print_backtrace();
- }
-
- } else {
- rc = 3;
- fprintf(stderr,
- "Memory Overwrite Error! Starting Sentinel is incorrect!\n Following data may be incorrect!\n"
- " Header Address: %p\n"
- " Address: %p\n" " Size: %d\n"
- " Allocated in module %s, function %s, at line %d\n",
- Current_Item,
- (void *)((unsigned long)Current_Item +
- sizeof(Memory_Leak_Data_t)),
- Current_Item->User_Size,
- Current_Item->Module_Name,
- Current_Item->Function_Name,
- Current_Item->Line_Number);
- print_backtrace();
- }
-
- Count += 1;
-
- } else {
- rc = 3;
- fprintf(stderr,
- "Memory Overwrite Error! Memory management data signature is incorrect! Data Dump:\n"
- " Header Address: %p\n"
- " Signature: Actual[%u, 0x%x], Expected[%u, 0x%x]\n"
- " User Address: %p\n"
- " Size: [%u, 0x%x]\n"
- " Starting Sentinel: Actual[%u, 0x%x], Expected[%u, 0x%x]\n"
- " Next: %p\n" " Previous: %p\n"
- " Module: %p\n" " Function: %p\n"
- " Line [%u, ox%x]\n", Current_Item,
- Current_Item->Signature,
- Current_Item->Signature, LEAK_SIGNATURE,
- LEAK_SIGNATURE,
- (void *)((unsigned long)Current_Item +
- sizeof(Memory_Leak_Data_t)),
- Current_Item->User_Size,
- Current_Item->User_Size,
- Current_Item->Starting_Sentinel,
- Current_Item->Starting_Sentinel, SENTINEL_VALUE,
- SENTINEL_VALUE, Current_Item->Next,
- Current_Item->Previous,
- Current_Item->Module_Name,
- Current_Item->Function_Name,
- Current_Item->Line_Number,
- Current_Item->Line_Number);
- fprintf(stderr,
- "Memory_Chain = %p\nMemory_Chain_Entries = %u\nCurrent_Item = %p, Count = %u\n\n",
- Memory_Chain, Memory_Chain_Entries,
- Current_Item, Count);
- print_backtrace();
-
- break;
- }
-
- Previous_Item = Current_Item;
- Current_Item = Current_Item->Next;
- }
-
- if (p != NULL) {
-
- if (rc == 0) {
- rc = Address_Found;
- }
-
- } else {
-
- if ((Count != Memory_Chain_Entries) && (rc == 0)) {
- fprintf(stderr,
- "The number of entries found in the allocation list [%u] != list count [%u]!!\n\n",
- Count, Memory_Chain_Entries);
- print_backtrace();
- rc = 3;
- }
-
- }
-
- FUNCTION_RETURN("%i", rc)
-}
-
-/*********************************************************************/
-/* */
-/* Function Name: Add_Memory_Allocation_To_Chain */
-/* */
-/* Descriptive Name: Adds a memory tracking object to the list of */
-/* memory tracking objects which represents all */
-/* memory allocations being tracked by this */
-/* module. */
-/* */
-/* Input: Memory_Leak_Data_t * Memory_Leak_Data - The memory */
-/* tracking object to add. */
-/* */
-/* Output: If Success : None. */
-/* */
-/* If Failure : None. */
-/* */
-/* Error Handling: None. */
-/* */
-/* Side Effects: Other memory tracking objects may be modified. */
-/* The count of objects being tracked will be */
-/* incremented. */
-/* */
-/* Notes: */
-/* */
-/*********************************************************************/
-static void Add_Memory_Allocation_To_Chain(Memory_Leak_Data_t *
- Memory_Leak_Data)
-{
-
- FUNCTION_ENTRY()
-
- PRINT_FUNCTION_PARAMETER("Parameters:\n")
- PRINT_FUNCTION_PARAMETER(" Memory_Leak_Data = %p",
- Memory_Leak_Data)
-
- if (Memory_Chain) {
- /* Other allocations exist. Insert at the head of the chain. */
- Memory_Leak_Data->Next = Memory_Chain;
- Memory_Chain->Previous = Memory_Leak_Data;
- } else {
- /* This is the first allocation. */
- Memory_Leak_Data->Next = NULL;
- }
-
- /* Update the pointer to the start of the allocation list. */
- Memory_Chain = Memory_Leak_Data;
-
- /* Update the count of entries in the memory chain. */
- Memory_Chain_Entries += 1;
-
- FUNCTION_EXIT()
-}
-
-/*********************************************************************/
-/* */
-/* Function Name: Remove_Memory_Allocation_From_Chain */
-/* */
-/* Descriptive Name: Removes a memory tracking object from */
-/* the linked list of memory tracking */
-/* objects representing current memory */
-/* allocations. */
-/* */
-/* Input: Memory_Leak_Data_t * Memory_Leak_Data - the memory */
-/* tracking object to remove. */
-/* */
-/* Output: If Success : None. */
-/* */
-/* If Failure : None. */
-/* */
-/* Error Handling: None. */
-/* */
-/* Side Effects: Other memory tracking objects may be modified. */
-/* The memory tracking object being removed will be */
-/* zeroed out and freed. */
-/* */
-/* Notes: */
-/* */
-/*********************************************************************/
-static void Remove_Memory_Allocation_From_Chain(Memory_Leak_Data_t *
- Memory_Leak_Data)
-{
- Memory_Leak_Data_t *Temp; /* Used when adjusting the memory allocation chain. */
- Sentinel_t *Ending_Sentinel; /* To allow access to the sentinel at the end of the allocated memory. */
-
- FUNCTION_ENTRY()
-
- /* Are we the first item in the chain? */
- if (Memory_Leak_Data->Previous == NULL) {
-
- /* We are at the head of the chain, which means that Memory_Chain points to us!
- * Point Memory_Chain to the Memory_Leak_Data_t that follows us (if any).
- */
- Memory_Chain = Memory_Leak_Data->Next;
-
- /* Is there another item in the chain? If so, update it. */
- if (Memory_Chain != NULL)
- Memory_Chain->Previous = NULL;
-
- } else {
-
- /* Are we the last item in the chain? */
- if (Memory_Leak_Data->Next == NULL) {
-
- /* We are at the end of the memory chain with at least 1 entry before us. */
- Temp = Memory_Leak_Data->Previous;
- Temp->Next = NULL;
- } else {
- /* We are in the middle of the chain. */
- Temp = Memory_Leak_Data->Previous;
- Temp->Next = Memory_Leak_Data->Next;
- Temp = Memory_Leak_Data->Next;
- Temp->Previous = Memory_Leak_Data->Previous;
- }
-
- }
-
- /* Adjust the count of entries in the memory chain. */
- Memory_Chain_Entries -= 1;
-
- /* Calculate the address of the ending sentinel so that we can access it. */
- Ending_Sentinel =
- (Sentinel_t *) ((unsigned long)Memory_Leak_Data +
- sizeof(Memory_Leak_Data_t) +
- Memory_Leak_Data->User_Size);
-
- /* Clean out the memory leak data. */
- Memory_Leak_Data->Function_Name = NULL;
- Memory_Leak_Data->Line_Number = 0;
- Memory_Leak_Data->Module_Name = NULL;
- Memory_Leak_Data->Signature = 0;
- Memory_Leak_Data->Starting_Sentinel = 0;
- Memory_Leak_Data->User_Size = 0;
- Memory_Leak_Data->Next = NULL;
- Memory_Leak_Data->Previous = NULL;
- *Ending_Sentinel = 0;
-
- free(Memory_Leak_Data->Mem_Address);
-
- FUNCTION_EXIT()
-}
-
-/*--------------------------------------------------
- API Functions
---------------------------------------------------*/
-
-/*********************************************************************/
-/* */
-/* Function Name: Print_Leak_List */
-/* */
-/* Descriptive Name: This function walks the list of allocated */
-/* memory blocks and prints information about */
-/* each one. If this is done at program exit, */
-/* the resulting list of memory blocks most */
-/* likely represents leaked memory. */
-/* */
-/* Input: None. */
-/* */
-/* Output: If Success : If there are any memory blocks being */
-/* tracked by this module, information about */
-/* block still being tracked will be sent to */
-/* stderr. */
-/* */
-/* If Failure : Error messages may be sent to stderr. */
-/* */
-/* Error Handling: If errors are detected, then error messages are */
-/* output on stderr. */
-/* */
-/* Side Effects: The internal structures of this module are checked*/
-/* for errors with any errors being reported on */
-/* stderr. */
-/* */
-/* Notes: */
-/* */
-/*********************************************************************/
-void Print_Leak_List(void)
-{
- Memory_Leak_Data_t *Current_Item; /* Used to walk the memory allocation chain. */
- Sentinel_t *Ending_Sentinel; /* To allow access to the sentinel at the end of the allocated memory. */
-
- API_FUNCTION_ENTRY()
-
- /* Get lock. */
- pthread_mutex_lock(&Memory_Leak_Lock);
-
- Current_Item = Memory_Chain;
-
- fprintf(stderr,
- "\n\nMemory_Chain is %p, and Memory_Chain_Entries is %u.\n",
- Memory_Chain, Memory_Chain_Entries);
- fprintf(stderr, "\nCurrent Memory Allocation List\n\n");
-
- while (Current_Item != NULL) {
- /* Perform some simple checks on the data before we print it. */
- if (Current_Item->Signature == LEAK_SIGNATURE) {
-
- if (Current_Item->Starting_Sentinel == SENTINEL_VALUE) {
-
- /* Check the ending sentinel. */
- Ending_Sentinel =
- (Sentinel_t *) ((unsigned long)Current_Item +
- sizeof(Memory_Leak_Data_t) +
- Current_Item->User_Size);
- if (*Ending_Sentinel == SENTINEL_VALUE) {
- fprintf(stderr,
- "Memory Allocation Record\n");
- } else {
- fprintf(stderr,
- "\nPossible overrun error -- ending sentinel corrupted!\n");
- }
-
- fprintf(stderr,
- " Allocation Block: %p\n"
- " Header Address: %p\n"
- " User Address: %p\n"
- " Alignment: %u\n"
- " Size: %d\n"
- " Allocated in module %s, function %s, at line %d\n\n",
- Current_Item->Mem_Address,
- Current_Item,
- (void *)((unsigned long)Current_Item +
- sizeof(Memory_Leak_Data_t)),
- Current_Item->Alignment,
- Current_Item->User_Size,
- Current_Item->Module_Name,
- Current_Item->Function_Name,
- Current_Item->Line_Number);
- } else {
- fprintf(stderr,
- "\nMemory Overwrite Error! Starting Sentinel is incorrect!\n Following data may be incorrect!\n");
- fprintf(stderr,
- " Allocation Block: %p\n"
- " Header Address: %p\n"
- " User Address: %p\n"
- " Alignment: %u\n" " Size: %d\n"
- " Allocated in module %s, function %s, at line %d\n\n",
- Current_Item->Mem_Address, Current_Item,
- (void *)((unsigned long)Current_Item +
- sizeof(Memory_Leak_Data_t)),
- Current_Item->Alignment,
- Current_Item->User_Size,
- Current_Item->Module_Name,
- Current_Item->Function_Name,
- Current_Item->Line_Number);
- }
-
- } else {
- fprintf(stderr,
- "\n\nMemory Overwrite Error! Memory management data signature is incorrect! Data Dump:\n");
- fprintf(stderr,
- " Allocation Block: %p\n"
- " Header Address: %p\n"
- " Signature: Actual[%u, 0x%x], Expected[%u, 0x%x]\n"
- " Address: %p\n" " Alignment: %u\n"
- " Size: [%u, 0x%x]\n"
- " Starting Sentinel: Actual[%u, 0x%x], Expected[%u, 0x%x]\n"
- " Next: %p\n" " Previous: %p\n"
- " Module: %p\n" " Function: %p\n"
- " Line [%u, ox%x]\n",
- Current_Item->Mem_Address, Current_Item,
- Current_Item->Signature,
- Current_Item->Signature, LEAK_SIGNATURE,
- LEAK_SIGNATURE,
- (void *)((unsigned long)Current_Item +
- sizeof(Memory_Leak_Data_t)),
- Current_Item->Alignment,
- Current_Item->User_Size,
- Current_Item->User_Size,
- Current_Item->Starting_Sentinel,
- Current_Item->Starting_Sentinel, SENTINEL_VALUE,
- SENTINEL_VALUE, Current_Item->Next,
- Current_Item->Previous,
- Current_Item->Module_Name,
- Current_Item->Function_Name,
- Current_Item->Line_Number,
- Current_Item->Line_Number);
- fprintf(stderr,
- "Memory_Chain = %p\nMemory_Chain_Entries = %u\nCurrent_Item = %p\n\n",
- Memory_Chain, Memory_Chain_Entries,
- Current_Item);
- break;
- }
-
- Current_Item = Current_Item->Next;
- }
-
- /* Release lock. */
- pthread_mutex_unlock(&Memory_Leak_Lock);
-
- API_FUNCTION_EXIT()
-
-}
-
-/*********************************************************************/
-/* */
-/* Function Name: MEMORY_func */
-/* */
-/* Descriptive Name: This function acts as a replacement for */
-/* malloc. It allocates memory (using malloc) */
-/* and enters that memory into a tracking */
-/* structure so that memory leaks, if any, may */
-/* be found. */
-/* */
-/* Input: size_t sz - The number of bytes to be allocated. */
-/* unsigned int Alignment - 0 for non-aligned (normal) */
-/* malloc, > 0 to return an */
-/* address aligned on a specific */
-/* memory boundary. If > 0, then */
-/* Alignment must be a power of 2 */
-/* and a multiple of sizeof(void *)*/
-/* void ** Memory_Location - The address of a variable which*/
-/* will hold the address of the */
-/* allocated by this function. */
-/* const char * mod_name - The name of the module from which*/
-/* this function was called. */
-/* const char * func - The name of the function from which */
-/* this function was called. */
-/* const int line - The line number of the code containing */
-/* the call to this function. */
-/* */
-/* Output: If Success : The function return value will be 0. */
-/* *Memory_Location will be set to the address*/
-/* of the first byte of the user portion of */
-/* any memory that was allocated. */
-/* */
-/* If Failure : The function return value will be EINVAL or*/
-/* ENOMEM. Errors may be reported on stderr. */
-/* *Memory_Location will be set to NULL. */
-/* */
-/* Error Handling: This function will abort if an error is */
-/* is detected. Errors could be lack of memory, or*/
-/* corruption of the internal structures used to */
-/* track allocated blocks of memory. */
-/* */
-/* Side Effects: Memory may be allocated, errors may be reported */
-/* on stderr. */
-/* */
-/* Notes: */
-/* */
-/*********************************************************************/
-int MEMORY_func(size_t sz,
- unsigned int Alignment,
- void **Memory_Location,
- const char *mod_name, const char *func, const int line)
-{
- Memory_Leak_Data_t *Memory_Leak_Data; /* For accessing our memory tracking data. */
- void *ptr = NULL; /* To hold the address that will be returned to the caller. */
- size_t New_Size; /* Used to adjust the size of the memory allocation. */
- Sentinel_t *Ending_Sentinel; /* To allow access to the sentinel at the end of the allocated memory. */
- unsigned int Proposed_User_Address; /* Used to calculate the address to return to the caller. */
- unsigned int Shift_Amount; /* Used when adjusting the address returned to caller to ensure proper alignment. */
- int Error = 0;
- unsigned int i = 0; /* Used when calculating powers of two to check the alignment. */
- unsigned int Power_Of_Two = 1; /* Used when calculating powers of two to check the alignment. */
-
-#define MAX_POWER_OF_TWO 31
-
- API_FUNCTION_ENTRY()
-
- PRINT_API_PARAMETER("Parameters:\n")
- PRINT_API_PARAMETER(" sz = %d", sz)
- PRINT_API_PARAMETER(" Alignment = %d", Alignment)
- PRINT_API_PARAMETER(" Memory_Location = %p", Memory_Location)
- PRINT_API_PARAMETER(" mod_name = %s", mod_name)
- PRINT_API_PARAMETER(" func = %s", func)
- PRINT_API_PARAMETER(" line = %i", line)
-
- /* Check the size of the request. */
- if (sz == 0) {
- Error = EINVAL;
- fprintf(stderr,
- "MALLOC: request is invalid - size[%lu] in module %s, function %s at line %d\n",
- sz, mod_name, func, line);
- print_backtrace();
- }
-
- /* Check the alignment, if one was specified. */
- if (Alignment > 0) {
- if (Alignment % sizeof(void *)) {
- /* Improper alignment! */
- Error = EINVAL;
- } else {
- do {
- Power_Of_Two *= 2;
- i++;
- } while ((Power_Of_Two != Alignment)
- && (i < MAX_POWER_OF_TWO));
-
- if (Power_Of_Two != Alignment) {
- Error = EINVAL;
- }
-
- }
-
- if (Error) {
- fprintf(stderr,
- "MEMORY_func: request for aligned memory uses invalid alignment! size[%lu], alignment [%u] in module %s, function %s at line %d\n",
- sz, Alignment, mod_name, func, line);
- }
-
- }
-
- if (Memory_Location == NULL) {
- Error = EINVAL;
- fprintf(stderr,
- "MEMORY_func: Location to place address of allocated memory is NULL! size[%lu], alignment [%u] in module %s, function %s at line %d\n",
- sz, Alignment, mod_name, func, line);
- } else
- *Memory_Location = NULL;
-
- if (Error != 0) {
- API_FUNCTION_RETURN("%i", Error);
- }
-
- USER3_PRINT_LINE
- ("MEMORY_func: processing request - size[%u], alignment[%u] from module %s, function %s at line %d\n",
- sz, Alignment, mod_name, func, line);
-
- /* Check */
-
- /* Get lock. */
- pthread_mutex_lock(&Memory_Leak_Lock);
-
- /* Check the memory allocation list. If the list is bad, then abort because we are already screwed ... */
- if (!Check_Leak_List(NULL)) {
-
- /* Adjust the size of the request to account for the additional memory we need to track this request. */
- New_Size =
- sz + sizeof(Memory_Leak_Data_t) + sizeof(Sentinel_t) +
- Alignment;
-
- /* Get the memory. */
- ptr = malloc(New_Size);
-
- /* Was the memory available? */
- if (ptr != NULL) {
- /* Determine where to put our memory leak data. */
- if (Alignment == 0) {
- /* We can place the memory leak data right at the start of the memory block we got from malloc. */
- Memory_Leak_Data = (Memory_Leak_Data_t *) ptr;
- } else {
- Proposed_User_Address =
- (unsigned long)ptr +
- sizeof(Memory_Leak_Data_t);
- Shift_Amount =
- Alignment -
- (Proposed_User_Address % Alignment);
- Memory_Leak_Data =
- (Memory_Leak_Data_t *) ((unsigned long)ptr +
- Shift_Amount);
- }
-
- /* Save the address returned by malloc() for use with free(). */
- Memory_Leak_Data->Mem_Address = ptr;
-
- /* Create the address to return to the caller. This address should be the first byte after
- our memory leak data. */
- ptr =
- (void *)((unsigned long)Memory_Leak_Data +
- sizeof(Memory_Leak_Data_t));
-
- /* Calculate the address of the trailing sentinel. */
- Ending_Sentinel =
- (Sentinel_t *) ((unsigned long)ptr + sz);
-
- /* Initialize our memory leak data. */
- Memory_Leak_Data->Signature = LEAK_SIGNATURE;
- Memory_Leak_Data->User_Size = sz;
- Memory_Leak_Data->Alignment = Alignment;
- Memory_Leak_Data->Module_Name = mod_name;
- Memory_Leak_Data->Function_Name = func;
- Memory_Leak_Data->Line_Number = line;
- Memory_Leak_Data->Previous = NULL;
- Memory_Leak_Data->Next = NULL;
- Memory_Leak_Data->Starting_Sentinel = SENTINEL_VALUE;
- *Ending_Sentinel = SENTINEL_VALUE;
-
- USER3_PRINT_LINE
- ("MALLOC: Allocated header at %p ( = user address %p) size[%u] in module %s, function %s at line %d\n",
- Memory_Leak_Data, ptr, sz, mod_name, func, line);
- Add_Memory_Allocation_To_Chain(Memory_Leak_Data);
- USER3_PRINT_LINE
- ("MALLOC: Memory_Chain is %p, and Memory_Chain_Entries is %u.\n",
- Memory_Chain, Memory_Chain_Entries);
-
- /* Set up return value. */
- *Memory_Location = ptr;
- } else {
-
- fprintf(stderr,
- "MALLOC: Memory allocation failed - no more memory available at this time!\n");
- print_backtrace();
-
- USER3_PRINT_LINE
- ("MALLOC: request was issued from module %s, function %s at line %d\n",
- mod_name, func, line);
-
- }
-
- } else {
- fprintf(stderr,
- "MALLOC: Found the memory leak data to be corrupted! Aborting!\n");
- print_backtrace();
- }
-
- /* Release lock. */
- pthread_mutex_unlock(&Memory_Leak_Lock);
-
- API_FUNCTION_RETURN("%i", Error)
-
-}
-
-/*********************************************************************/
-/* */
-/* Function Name: MALLOC_func */
-/* */
-/* Descriptive Name: This function acts as a replacement for */
-/* malloc. It allocates memory (using malloc) */
-/* and enters that memory into a tracking */
-/* structure so that memory leaks, if any, may */
-/* be found. */
-/* */
-/* Input: size_t sz - The number of bytes to be allocated. */
-/* const char * mod_name - The name of the module from which*/
-/* this function was called. */
-/* const char * func - The name of the function from which */
-/* this function was called. */
-/* const int line - The line number of the code containing */
-/* the call to this function. */
-/* */
-/* Output: If Success : The function return value will be non-NULL.*/
-/* */
-/* If Failure : The function return value will be NULL. */
-/* Errors may be reported on stderr. */
-/* */
-/* Error Handling: This function will abort if an error is */
-/* is detected. Errors could be lack of memory, or*/
-/* corruption of the internal structures used to */
-/* track allocated blocks of memory. */
-/* */
-/* Side Effects: Memory may be allocated, errors may be reported */
-/* on stderr. */
-/* */
-/* Notes: */
-/* */
-/*********************************************************************/
-void *MALLOC_func(size_t sz, const char *mod_name, const char *func,
- const int line)
-{
- void *Return_Value;
- int Error;
-
- Error = MEMORY_func(sz, 0, &Return_Value, mod_name, func, line);
-
- if (Error != 0)
- return NULL;
- else
- return Return_Value;
-}
-
-/*********************************************************************/
-/* */
-/* Function Name: FREE_func */
-/* */
-/* Descriptive Name: This function frees a block of memory being */
-/* tracked by this module and removes the block */
-/* from its tracking structures. */
-/* */
-/* Input: const void * p - The address of the block of memory to */
-/* be freed. */
-/* const char * mod_name - The name of the module requesting*/
-/* the block of memory be freed. */
-/* const char * func - The name of the function requesting */
-/* the block of memory be freed. */
-/* const int line - The line number of the line of code in */
-/* module calling this function. */
-/* */
-/* Output: If Success : None. */
-/* */
-/* If Failure : Errors may be reported to stderr. */
-/* */
-/* Error Handling: This function causes the internal structures */
-/* of this module to be checked as part of the */
-/* process of freeing the address p. This may */
-/* cause errors to be reported on stderr. If any */
-/* errors are found, then the address p may not be */
-/* freed. */
-/* */
-/* Side Effects: The block of memory associated with the address p */
-/* will be freed and available for reallocation. */
-/* Also, the memory tracking structures in this */
-/* module will undergo a series of checks. */
-/* */
-/* Notes: This function was not intended to be called directly but */
-/* rather through the macro FREE. */
-/* */
-/*********************************************************************/
-void FREE_func(const void *p, const char *mod_name, const char *func,
- const int line)
-{
- Memory_Leak_Data_t *Memory_Leak_Data; /* For accessing our memory tracking data. */
-
- API_FUNCTION_ENTRY()
-
- PRINT_API_PARAMETER("Parameters:\n")
- PRINT_API_PARAMETER(" p = %p", p)
- PRINT_API_PARAMETER(" mod_name = %s", mod_name)
- PRINT_API_PARAMETER(" func = %s", func)
- PRINT_API_PARAMETER(" line = %i", line)
-
- /* Check the address passed to us. It must not be NULL, and must be > sizeof(Memory_Leak_Data_t) to
- * prevent wrap around when we subtract sizeof(Memory_Leak_Data_t) to get the starting address of
- * the memory leak data associated with p.
- */
- if ((p == NULL) || ((unsigned long)p <= sizeof(Memory_Leak_Data_t))) {
- fprintf(stderr,
- "FREE: request has invalid user address [%p]. Request came from module %s, function %s, line %d\n",
- p, mod_name, func, line);
- print_backtrace();
- return;
- } else {
- USER3_PRINT_LINE
- ("FREE: request to free [%p] received from module %s, function %s, line %d\n",
- p, mod_name, func, line);
- }
-
- /* Get lock. */
- pthread_mutex_lock(&Memory_Leak_Lock);
-
- /* Check the memory allocation list for errors. */
- if (!Check_Leak_List(NULL)) {
-
- /* Is the address given to us in the memory allocation list? */
- if (!Check_Leak_List(p)) {
- /* Get access to the memory leak data. */
- Memory_Leak_Data =
- (Memory_Leak_Data_t *) ((unsigned long)p -
- sizeof(Memory_Leak_Data_t));
-
- USER3_PRINT_LINE
- ("FREE: Calling free on header address %p ( = user address %p) from module %s, function %s, line %d\n",
- Memory_Leak_Data, p, mod_name, func, line);
- Remove_Memory_Allocation_From_Chain(Memory_Leak_Data);
- USER3_PRINT_LINE
- ("FREE: Memory_Chain is %p, and Memory_Chain_Entries is %u.\n",
- Memory_Chain, Memory_Chain_Entries);
-
- } else {
- /* The address given to us was not in the memory allocation list! If we free this address, who knows what will happen! */
- fprintf(stderr,
- "FREE: Invalid address! The address %p was not provided by MALLOC or has been passed to FREE more than once!\n",
- p);
- fprintf(stderr,
- " Request came from module %s, function %s, line %d\n",
- mod_name, func, line);
- print_backtrace();
- }
-
- } else {
- fprintf(stderr,
- "FREE: Aborting due to errors in the memory leak data!\n");
- USER3_PRINT_LINE
- ("FREE: request was submitted by module %s, function %s at line %d\n",
- mod_name, func, line);
- print_backtrace();
-
- }
-
- pthread_mutex_unlock(&Memory_Leak_Lock);
-
- USER3_PRINT_LINE("FREE: request is complete.\n");
-
- API_FUNCTION_EXIT()
-}
-
-/*********************************************************************/
-/* */
-/* Function Name: Test_Address_Allocation */
-/* */
-/* Descriptive Name: This function tests the specified address to */
-/* to see if it lies within an allocated block */
-/* tracked by this module. */
-/* */
-/* Input: void * p - The address to be tested. */
-/* */
-/* Output: If Success : If the address p was found, then 0 will be */
-/* returned if the address is the start of */
-/* a block of allocated memory. If the */
-/* address p was found within an allocated */
-/* block of memory, then 1 is returned. */
-/* */
-/* If Failure : If the address p was NOT found, then 2 is */
-/* returned. If there was an error in the */
-/* memory tracking system then 3 will be */
-/* returned. */
-/* */
-/* Error Handling: This function relies on the error handling */
-/* built into the Check_Leak_List function and */
-/* has no error handling of its own. */
-/* */
-/* Side Effects: If the list of memory allocations contains errors */
-/* then those errors will be detected and reported */
-/* on stderr. */
-/* */
-/* Notes: If NULL is passed in as the address to test, then the */
-/* integrity of the internal tracking structures will be */
-/* checked, in which case a return value of 0 signifies */
-/* that the internal tracking structures have passed the */
-/* checks and a return value of 3 indicates that errors */
-/* were found. */
-/* */
-/*********************************************************************/
-unsigned int Test_Address_Allocation(void *p)
-{
- unsigned int rc = 0;
-
- API_FUNCTION_ENTRY()
-
- PRINT_API_PARAMETER("Parameters:\n")
- PRINT_API_PARAMETER(" p = %p", p)
-
- /* Get lock. */
- pthread_mutex_lock(&Memory_Leak_Lock);
-
- rc = Check_Leak_List(p);
-
- /* Release lock. */
- pthread_mutex_unlock(&Memory_Leak_Lock);
-
- API_FUNCTION_RETURN("%i", rc);
-}
-
-/*********************************************************************/
-/* */
-/* Function Name: Duplicate_String */
-/* */
-/* Descriptive Name: This function duplicates a string. The memory*/
-/* allocated for the duplicate is allocated */
-/* using the MALLOC_func routine in this module */
-/* and is thus tracked by this module. */
-/* */
-/* Input: const char * Source - The string to be copied. */
-/* const char * mod_name - The name of the module containing*/
-/* the function which called this */
-/* function. */
-/* const char * func - The name of the function calling */
-/* this function. */
-/* const int line - The line number of the line of code in */
-/* module calling this function. */
-/* */
-/* Output: If Success : The function return value will be non-NULL */
-/* and will point to a duplicate of the */
-/* string given in Source. */
-/* */
-/* If Failure : The function return value will be NULL. */
-/* */
-/* Error Handling: Any errors detected by this function result in */
-/* a function return value of NULL. */
-/* */
-/* Side Effects: The memory tracking features of this module are */
-/* employed to allocate memory for the duplicate */
-/* string produced by this funciton. */
-/* */
-/* Notes: */
-/* */
-/*********************************************************************/
-char *Duplicate_String(const char *Source,
- const char *mod_name, const char *func, const int line)
-{
- char *Result;
-
- Result = (char *)MALLOC_func(strlen(Source) + 1, mod_name, func, line);
- if (Result != NULL)
- strcpy(Result, Source);
-
- return Result;
-}
-
-/*********************************************************************/
-/* */
-/* Function Name: Realloc_func */
-/* */
-/* Descriptive Name: This function performs the same function as */
-/* the realloc function in the ANSI C library. */
-/* */
-/* Input: const void * p - The address of the block of memory to */
-/* be reallocated. */
-/* size_t size - The size of the memory block to return. */
-/* const char * mod_name - The name of the module requesting*/
-/* the block of memory be freed. */
-/* const char * func - The name of the function requesting */
-/* the block of memory be freed. */
-/* const int line - The line number of the line of code in */
-/* module calling this function. */
-/* */
-/* Output: If Success : The function return value will be a pointer*/
-/* to the new block of memory. */
-/* */
-/* If Failure : NULL will be returned and errno will be set*/
-/* to a non-null error code. */
-/* */
-/* Error Handling: This function causes the internal structures */
-/* of this module to be checked. This may */
-/* cause errors to be reported on stderr. If any */
-/* errors are found, then the address p may not be */
-/* freed. */
-/* */
-/* Side Effects: A new block of memory of size bytes will be */
-/* allocated, the contents of the current block will */
-/* be copied to the new block (at least as much as */
-/* will fit, and the current block will be freed. */
-/* This will cause internal structures in this module*/
-/* to be modified accordingly. */
-/* */
-/* Notes: This function was not intended to be called directly but */
-/* rather through the macro REALLOC. */
-/* */
-/* If p is NULL, then this will cause this function to */
-/* behave like malloc. */
-/* */
-/* If size is 0, then this will cause this function to */
-/* behave like free. */
-/* */
-/*********************************************************************/
-void *Realloc_func(void *p, size_t size, const char *mod_name, const char *func,
- const int line)
-{
- Memory_Leak_Data_t *Memory_Leak_Data; /* For accessing our memory tracking data. */
- int Error = 0;
- unsigned int Copy_Size = 0;
- void *Return_Value = NULL;
-
- API_FUNCTION_ENTRY()
-
- PRINT_API_PARAMETER("Parameters:\n")
- PRINT_API_PARAMETER(" p = %p", p)
- PRINT_API_PARAMETER(" size = %u", size)
- PRINT_API_PARAMETER(" mod_name = %s", mod_name)
- PRINT_API_PARAMETER(" func = %s", func)
- PRINT_API_PARAMETER(" line = %i", line)
-
- /* Check the address passed to us. If it is NULL and size > 0, then we are merely doing a malloc. */
- if ((p == NULL) && (size > 0)) {
- USER3_PRINT_LINE
- ("REALLOC: p was NULL and size > 0, acting as MALLOC.\n")
- Return_Value = MALLOC_func(size, mod_name, func, line);
- if (Return_Value == NULL) {
- errno = ENOMEM;
- }
- } else {
- /* If size is 0 and p is not NULL, then we are doing a free. */
- if ((p != NULL) && (size == 0)) {
- USER3_PRINT_LINE
- ("REALLOC: p was non-NULL but size is 0, acting as FREE.\n")
- FREE_func(p, mod_name, func, line);
- } else {
- /* Do we have real work to do? */
- if ((p != NULL) && (size != 0)) {
- USER3_PRINT_LINE
- ("REALLOC: p was non-NULL and size > 0, we have actual work to do!.\n")
-
- /* Get lock. */
- pthread_mutex_lock(&Memory_Leak_Lock);
-
- /* Check the memory allocation list for errors. */
- if (!Check_Leak_List(NULL)) {
-
- /* Is the address given to us in the memory allocation list? */
- if (!Check_Leak_List(p)) {
- /* Get access to the memory leak data. */
- Memory_Leak_Data =
- (Memory_Leak_Data_t
- *) ((unsigned long)p -
- sizeof
- (Memory_Leak_Data_t));
-
- /* Release the lock so that MEMORY_func can get it. */
- pthread_mutex_unlock
- (&Memory_Leak_Lock);
-
- /* Call MEMORY_func to get the memory we need and add it to the list of memory blocks we are tracking. */
- Error =
- MEMORY_func(size,
- Memory_Leak_Data->
- Alignment,
- &Return_Value,
- mod_name, func,
- line);
- if (Error != 0) {
- Return_Value = NULL;
- errno = ENOMEM;
- } else {
-
- /* We have the replacement memory. Now lets copy what we can from the original block to the new block. */
- if (size >
- Memory_Leak_Data->
- User_Size) {
- Copy_Size =
- Memory_Leak_Data->
- User_Size;
- } else {
- Copy_Size =
- size;
- }
-
- /* Copy the data to be preserved from the original memory block to the new memory block. */
- memcpy(Return_Value, p,
- Copy_Size);
-
- /* Zero out the original memory block ... this can catch errors as users should not assume that
- * realloc will leave their original memory block intact.
- */
- memset(p, 0x0,
- Memory_Leak_Data->
- User_Size);
-
- /* Get the lock again. */
- pthread_mutex_lock
- (&Memory_Leak_Lock);
-
- USER3_PRINT_LINE
- ("REALLOC: Calling free on header address %p ( = user address %p) from module %s, function %s, line %d\n",
- Memory_Leak_Data,
- p, mod_name, func,
- line);
- Remove_Memory_Allocation_From_Chain
- (Memory_Leak_Data);
- USER3_PRINT_LINE
- ("REALLOC: Memory_Chain is %p, and Memory_Chain_Entries is %u.\n",
- Memory_Chain,
- Memory_Chain_Entries);
-
- }
-
- } else {
- /* The address given to us was not in the memory allocation list! If we free this address, who knows what will happen! */
- fprintf(stderr,
- "REALLOC: Invalid address! The address %p was not provided by MALLOC or has been passed to FREE already!\n",
- p);
- fprintf(stderr,
- " Request came from module %s, function %s, line %d\n",
- mod_name, func, line);
- print_backtrace();
- }
-
- } else {
- fprintf(stderr,
- "REALLOC: Aborting due to errors in the memory leak data!\n");
- USER3_PRINT_LINE
- ("REALLOC: request was submitted by module %s, function %s at line %d\n",
- mod_name, func, line);
- print_backtrace();
-
- }
-
- pthread_mutex_unlock(&Memory_Leak_Lock);
-
- }
-
- }
-
- }
-
- USER3_PRINT_LINE("REALLOC: request is complete.\n");
-
- API_FUNCTION_RETURN("%p", Return_Value)
-}
diff --git a/clib/src/mq.c b/clib/src/mq.c
deleted file mode 100644
index cf75e89..0000000
--- a/clib/src/mq.c
+++ /dev/null
@@ -1,215 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/src/mq.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 */
-
-/*
- * File: mqueue.c
- * Author: Shaun Wetzstein <shaun@us.ibm.com>
- * Descr: POSIX message queue wrapper
- * Note:
- * Date: 10/07/10
- */
-
-#include <unistd.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <malloc.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-#include <fcntl.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include "libclib.h"
-#include "mq.h"
-
-#define MQUEUE_ROOT "/dev/mqueue"
-
-/* ======================================================================= */
-
-int mqueue_init(mqueue_t * self, const char *service)
-{
- assert(self != NULL);
-
- self->service = strdup(service);
- self->in = self->out = (mqd_t) - 1;
-
- return 0;
-}
-
-int mqueue_create(mqueue_t * self, pid_t tid)
-{
- assert(self != NULL);
-
- char path[pathconf(MQUEUE_ROOT, _PC_PATH_MAX)];
-
- sprintf(path, "%s/%d->%s", MQUEUE_ROOT, tid, self->service);
-
- self->out = open(path, O_WRONLY | O_CREAT, S_IWUSR);
- if (self->out == (mqd_t) - 1) {
- ERRNO(errno);
- return -1;
- }
-
- sprintf(path, "%s/%d<-%s", MQUEUE_ROOT, tid, self->service);
-
- self->in = open(path, O_RDONLY | O_CREAT, S_IRUSR);
- if (self->in == (mqd_t) - 1) {
- ERRNO(errno);
- return -1;
- }
-
- return 0;
-}
-
-int mqueue_open(mqueue_t * self, char *path)
-{
- assert(self != NULL);
-
- if (path != NULL) {
- char *endp = NULL;
- (void)strtol(path + 1, &endp, 10);
-
- if (strncmp(endp, "->", 2) == 0) {
- self->in = mq_open((char *)path, O_RDONLY,
- S_IRWXU, NULL);
- if (self->in == (mqd_t) - 1) {
- ERRNO(errno);
- return -1;
- }
- } else if (strncmp(endp, "<-", 2) == 0) {
- self->out = mq_open((char *)path, O_WRONLY,
- S_IRWXU, NULL);
- if (self->out == (mqd_t) - 1) {
- ERRNO(errno);
- return -1;
- }
- } else {
- UNEXPECTED("'%s' invalid service", path);
- return -1;
- }
- }
-
- return 0;
-}
-
-int mqueue_close(mqueue_t * self, char *path)
-{
- assert(self != NULL);
-
- if (path != NULL) {
- char *endp = NULL;
- (void)strtol(path + 1, &endp, 10);
-
- if (strncmp(endp, "->", 2) == 0) {
- if (self->in != (mqd_t) - 1)
- mq_close(self->in), self->in = (mqd_t) - 1;
- } else if (strncmp(endp, "<-", 2) == 0) {
- if (self->out != (mqd_t) - 1)
- mq_close(self->out), self->out = (mqd_t) - 1;
- } else {
- UNEXPECTED("'%s' invalid service", path);
- return -1;
- }
- }
-
- return 0;
-}
-
-mqueue_attr_t mqueue_getattr(mqueue_t * self)
-{
- assert(self != NULL);
-
- mqueue_attr_t attr;
- mq_getattr(self->in, &attr);
-
- return attr;
-}
-
-int mqueue_delete(mqueue_t * self)
-{
- assert(self != NULL);
-
- char path[pathconf(MQUEUE_ROOT, _PC_PATH_MAX)];
- if (self->in != (mqd_t) - 1) {
- sprintf(path, "%s/%d->%s",
- MQUEUE_ROOT, gettid(), self->service);
- unlink(path);
- if (mq_close(self->in) == (mqd_t) - 1) {
- ERRNO(errno);
- return -1;
- }
- self->in = (mqd_t) - 1;
- }
-
- if (self->out != (mqd_t) - 1) {
- sprintf(path, "%s/%d<-%s",
- MQUEUE_ROOT, gettid(), self->service);
- unlink(path);
- if (mq_close(self->in) == (mqd_t) - 1) {
- ERRNO(errno);
- return -1;
- }
- self->out = (mqd_t) - 1;
- }
-
- if (self->service) {
- free((void *)self->service);
- self->service = NULL;
- }
-
- return 0;
-}
-
-int mqueue_send(mqueue_t * self, void *ptr, size_t len)
-{
- assert(self != NULL);
-
- int rc = mq_send(self->out, (char *)ptr, len, 0);
- if (rc == -1) {
- ERRNO(errno);
- return -1;
- }
-
- return rc;
-}
-
-int mqueue_receive(mqueue_t * self, void *ptr, size_t len)
-{
- assert(self != NULL);
-
- int rc = mq_receive(self->in, (char *)ptr, len, 0);
- if (rc == -1) {
- ERRNO(errno);
- return -1;
- }
-
- return rc;
-}
-
-/* ======================================================================= */
diff --git a/clib/src/signal.c b/clib/src/signal.c
deleted file mode 100644
index 609cc49..0000000
--- a/clib/src/signal.c
+++ /dev/null
@@ -1,142 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/src/signal.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 */
-
-/*
- * File: signal.c
- * Author: Shaun Wetzstein <shaun@us.ibm.com>
- * Descr:
- * Note:
- * Date: 10/03/10
- */
-
-#include <unistd.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <malloc.h>
-#include <stdint.h>
-#include <signal.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-
-#include "misc.h"
-#include "signal.h"
-
-/* ======================================================================= */
-
-const char *__signal_msg[] = {
- "signal: unexpected NULL self pointer",
- "signal: unexpected NULL callback structure",
-};
-
-#define SIGNAL_NULL (__signal_msg[0])
-
-/* ======================================================================= */
-
-void signal_init(signal_t * self)
-{
- if (unlikely(self == NULL))
- throw_unexpected(SIGNAL_NULL);
-
- if (self->fd != -1)
- close(self->fd), self->fd = -1;
-
- sigemptyset(&self->mask);
- self->flags = SFD_CLOEXEC;
-
- self->fd = signalfd(self->fd, &self->mask, self->flags);
- if (unlikely(self->fd == -1))
- throw_errno(errno);
-}
-
-void signal_delete(signal_t * self)
-{
- if (unlikely(self == NULL))
- throw_unexpected(SIGNAL_NULL);
-
- close(self->fd), self->fd = -1;
-
- if (sigprocmask(SIG_UNBLOCK, &self->mask, NULL) == -1)
- throw_errno(errno);
-
- sigemptyset(&self->mask);
- self->flags = 0;
-}
-
-int signal_fileno(signal_t * self)
-{
- if (unlikely(self == NULL))
- throw_unexpected(SIGNAL_NULL);
- return self->fd;
-}
-
-int signal_setmask(signal_t * self, const sigset_t mask)
-{
- if (unlikely(self == NULL))
- throw_unexpected(SIGNAL_NULL);
-
- self->mask = mask;
-
- if (sigprocmask(SIG_BLOCK, &self->mask, NULL) == -1)
- throw_errno(errno);
-
- self->fd = signalfd(self->fd, &self->mask, self->flags);
- if (unlikely(self->fd == -1))
- throw_errno(errno);
-
- return self->fd;
-}
-
-#if 0
-void signal_wait1(signal_t * self)
-{
- signal_wait2(self, -1);
-}
-
-void signal_wait2(signal_t * self, int timeout)
-{
- if (unlikely(self == NULL))
- throw_unexpected(SIGNAL_NULL);
-
- struct epoll_event events[signal_EVENT_SIZE];
-
- int rc = epoll_wait(self->fd, events,
- signal_EVENT_SIZE, timeout);
-
- for (int n = 0; n < rc; n++) {
- signal_callback *cb = (signal_callback *) events[n].data.ptr;
- if (cb != NULL)
- if (cb->func != NULL)
- cb->func((signal_event[1]) { {
- events[n].data.u64 >> 32,
- events[n].events}
- }
- , cb->data);
- }
-}
-#endif
-
-/* ======================================================================= */
diff --git a/clib/src/slab.c b/clib/src/slab.c
index 9ee4353..8ddfca3 100644
--- a/clib/src/slab.c
+++ b/clib/src/slab.c
@@ -127,7 +127,7 @@ int slab_init5(slab_t * self, const char *name, uint32_t alloc_size,
{
assert(self != NULL);
- if (unlikely(MAGIC_CHECK(self->hdr.id, SLAB_MAGIC) == false))
+ if (MAGIC_CHECK(self->hdr.id, SLAB_MAGIC) == false)
slab_delete(self);
alloc_size = align(alloc_size, sizeof(void *));
@@ -189,10 +189,10 @@ int slab_init5(slab_t * self, const char *name, uint32_t alloc_size,
int slab_delete(slab_t * self)
{
- if (unlikely(self == NULL))
+ if (self == NULL)
return 0;
- if (unlikely(MAGIC_CHECK(self->hdr.id, SLAB_MAGIC))) {
+ if (MAGIC_CHECK(self->hdr.id, SLAB_MAGIC)) {
UNEXPECTED("'%s' invalid or corrupt slab object",
self->hdr.name);
return -1;
@@ -234,7 +234,7 @@ void *slab_alloc(slab_t * self)
if (0 < node->free)
break;
- if (unlikely(tree_iter_elem(&it) == NULL))
+ if (tree_iter_elem(&it) == NULL)
node = __slab_grow(self);
assert(node != NULL);
@@ -247,11 +247,11 @@ void *slab_alloc(slab_t * self)
if (node->bitmap[map_pos] != UINT32_MAX)
break;
- if (unlikely(node->bitmap[map_pos] == UINT32_MAX)) {
+ if (node->bitmap[map_pos] == UINT32_MAX) {
UNEXPECTED("'%s' cache is corrupted", self->hdr.name);
return NULL;
}
- if (unlikely(self->hdr.bitmap_size <= map_pos)) {
+ if (self->hdr.bitmap_size <= map_pos) {
UNEXPECTED("'%s' cache is corrupted", self->hdr.name);
return NULL;
}
@@ -259,7 +259,7 @@ void *slab_alloc(slab_t * self)
uint32_t bit = clzl(~node->bitmap[map_pos]);
uint32_t mask = 0x80000000 >> bit;
- if (unlikely((node->bitmap[map_pos] & mask) == mask)) {
+ if ((node->bitmap[map_pos] & mask) == mask) {
UNEXPECTED("'%s' cache is corrupted", self->hdr.name);
return NULL;
}
@@ -278,14 +278,14 @@ int slab_free(slab_t * self, void *ptr)
assert(self != NULL);
assert(!MAGIC_CHECK(self->hdr.id, SLAB_MAGIC));
- if (unlikely(ptr == NULL))
+ if (ptr == NULL)
return 0;
slab_node_t *node = (slab_node_t *) ((uintptr_t) ptr &
~(self->hdr.page_size - 1));
assert(node != NULL);
- if (unlikely(SLAB_NODE_MAGIC_CHECK(node->magic))) {
+ if (SLAB_NODE_MAGIC_CHECK(node->magic)) {
int64_t hash = int64_hash1((int64_t) node);
if (splay_find(&self->tree, (const void *)hash) == NULL) {
UNEXPECTED("'%s' invalid slab_node pointer, %p",
@@ -297,7 +297,7 @@ int slab_free(slab_t * self, void *ptr)
void *data = (void *)node->bitmap + self->hdr.bitmap_size;
assert(data != NULL);
- if (unlikely(ptr < data)) {
+ if (ptr < data) {
UNEXPECTED("'%s' pointer out-of-range, %p",
self->hdr.name, ptr);
return -1;
@@ -307,7 +307,7 @@ int slab_free(slab_t * self, void *ptr)
uint32_t mask = 0x80000000 >> slot;
size_t map_pos = slot / INT32_BIT;
- if (unlikely((node->bitmap[map_pos] & mask) != mask)) {
+ if ((node->bitmap[map_pos] & mask) != mask) {
UNEXPECTED("'%s' double free detected, %p",
self->hdr.name, ptr);
return -1;
@@ -362,7 +362,7 @@ void slab_dump(slab_t * self, FILE * out)
out = stdout;
if (self != NULL) {
- if (unlikely(MAGIC_CHECK(self->hdr.id, SLAB_MAGIC))) {
+ if (MAGIC_CHECK(self->hdr.id, SLAB_MAGIC)) {
UNEXPECTED("'%s' invalid or corrupt slab object",
self->hdr.name);
return;
diff --git a/clib/src/table.c b/clib/src/table.c
deleted file mode 100644
index 82a35aa..0000000
--- a/clib/src/table.c
+++ /dev/null
@@ -1,686 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/src/table.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 */
-
-/*
- * File: table.c
- * Author: Shaun Wetzstein <shaun@us.ibm.com>
- * Descr:
- * Note:
- * Date: 08/21/10
- */
-
-#include <unistd.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <malloc.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-
-#include "libclib.h"
-#include "table.h"
-#include "vector_iter.h"
-
-#define TABLE_PAGE_SIZE 4096
-#define TABLE_PAGE_DIVISOR 32
-
-/* ======================================================================= */
-int table_init(table_t * self, const char *name, uint32_t col_nr)
-{
- assert(self != NULL);
- assert(name != NULL);
-
- if (col_nr == 0) {
- UNEXPECTED("'%d' invalid column number", col_nr);
- return -1;
- }
-
- self->hdr.id[IDENT_MAGIC_0] = TABLE_MAGIC[IDENT_MAGIC_0];
- self->hdr.id[IDENT_MAGIC_1] = TABLE_MAGIC[IDENT_MAGIC_1];
- self->hdr.id[IDENT_MAGIC_2] = TABLE_MAGIC[IDENT_MAGIC_2];
- self->hdr.id[IDENT_MAGIC_3] = TABLE_MAGIC[IDENT_MAGIC_3];
-
- self->hdr.id[IDENT_MAJOR] = CLIB_MAJOR;
- self->hdr.id[IDENT_MINOR] = CLIB_MINOR;
- self->hdr.id[IDENT_PATCH] = CLIB_PATCH;
-
- if (__BYTE_ORDER == __LITTLE_ENDIAN)
- self->hdr.id[IDENT_FLAGS] |= TABLE_FLAG_LSB;
- if (__BYTE_ORDER == __BIG_ENDIAN)
- self->hdr.id[IDENT_FLAGS] |= TABLE_FLAG_MSB;
-
- /* FIX ME -- handle this more elegantly */
- //assert((col_nr * sizeof(value_t)) < TABLE_PAGE_SIZE);
-
- self->hdr.col_nr = col_nr;
-
- if (name == NULL || *name == '\0')
- memset(self->hdr.name, 0, sizeof(self->hdr.name));
- else
- strncpy(self->hdr.name, name, sizeof(self->hdr.name));
-
- char name_vector[strlen(self->hdr.name) + 5];
-
- size_t row_size = self->hdr.col_nr * sizeof(value_t);
-
- sprintf(name_vector, "%s.table", self->hdr.name);
- vector_init(&self->table, name_vector, row_size,
- __round_pow2(row_size * TABLE_PAGE_DIVISOR));
-
- sprintf(name_vector, "%s.string", self->hdr.name);
- vector_init(&self->string, name_vector, 1, TABLE_PAGE_SIZE);
-
- sprintf(name_vector, "%s.blob", self->hdr.name);
- vector_init(&self->blob, name_vector, 1, TABLE_PAGE_SIZE);
-
- return 0;
-}
-
-int table_delete(table_t * self)
-{
- if (unlikely(self == NULL))
- return 0;
-
- if (MAGIC_CHECK(self->hdr.id, TABLE_MAGIC)) {
- UNEXPECTED("'%2.2x%2.2x%2.2x%2.2x' invalid table magic "
- "'%2.2x%2.2x%2.2x%2.2x",
- self->hdr.id[IDENT_MAGIC_0],
- self->hdr.id[IDENT_MAGIC_1],
- self->hdr.id[IDENT_MAGIC_2],
- self->hdr.id[IDENT_MAGIC_3],
- TABLE_MAGIC[IDENT_MAGIC_0],
- TABLE_MAGIC[IDENT_MAGIC_2],
- TABLE_MAGIC[IDENT_MAGIC_3],
- TABLE_MAGIC[IDENT_MAGIC_3]);
- return -1;
- }
-
- if (0 < vector_size(&self->table)) {
- vector_iter_t it;
- if (vector_iter_init(&it, &self->table, VI_FLAG_FWD) < 0)
- return -1;
-
- value_t *v;
- vector_for_each(&it, v)
- for (size_t c = 0; c < self->hdr.col_nr; c++)
- value_clear(v + c);
- }
-
- if (vector_delete(&self->table) < 0)
- return -1;
- if (vector_delete(&self->string) < 0)
- return -1;
- if (vector_delete(&self->blob) < 0)
- return -1;
-
- return 0;
-}
-
-value_t *table_get(table_t * self, size_t row, size_t col)
-{
- assert(self != NULL);
- assert(!MAGIC_CHECK(self->hdr.id, TABLE_MAGIC));
-
- row++; /* hide the column names */
-
- return (value_t *) vector_at(&self->table,
- row * self->hdr.col_nr + col);
-}
-
-value_t *table_row2(table_t * self, size_t row_nr)
-{
- assert(self != NULL);
- assert(!MAGIC_CHECK(self->hdr.id, TABLE_MAGIC));
-
- row_nr++; /* hide the column names */
-
- return (value_t *) vector_at(&self->table, row_nr * self->hdr.col_nr);
-}
-
-int table_row3(table_t * self, size_t row_nr, value_t * row)
-{
- assert(self != NULL);
- assert(row != NULL);
- assert(!MAGIC_CHECK(self->hdr.id, TABLE_MAGIC));
-
- row_nr++; /* hide the column names */
-
- if (vector_size(&self->table) <= row_nr + 1) {
- if (vector_size(&self->table, row_nr + 1) < 0)
- return -1;
- } else {
- value_t *old;
- old = (value_t *) vector_at(&self->table, row_nr);
- assert(old != NULL);
-
- for (size_t col_nr = 0; col_nr < self->hdr.col_nr; col_nr++)
- value_clear(old + col_nr);
- }
-
- if (vector_put(&self->table, row_nr, row) < 0)
- return -1;
-
- for (size_t col_nr = 0; col_nr < self->hdr.col_nr; col_nr++)
- if (value_type(row + col_nr) == VT_STR ||
- value_type(row + col_nr) == VT_BLOB)
- value_type(row + col_nr, VT_UNKNOWN);
-
- return 0;
-}
-
-value_t *table_column(table_t * self, value_t * row, size_t col)
-{
- assert(self != NULL);
- assert(row != NULL);
- assert(!MAGIC_CHECK(self->hdr.id, TABLE_MAGIC));
- assert(col < self->hdr.col_nr);
-
- return (void *)row + (vector_elem_size(&self->table) * col);
-}
-
-int table_put(table_t * self, size_t row, size_t col, value_t * val)
-{
- assert(self != NULL);
- assert(val != NULL);
- assert(!MAGIC_CHECK(self->hdr.id, TABLE_MAGIC));
-
- row++; /* hide the column names */
-
- size_t size = (row + 1) * self->hdr.col_nr;
-
- if (vector_size(&self->table) <= size)
- if (vector_size(&self->table, size) < 0)
- return -1;
-
- /* free existing pointer data */
- value_t *old = (value_t *) vector_at(&self->table,
- row * self->hdr.col_nr + col);
- assert(old != NULL);
- value_clear(old);
-
- vector_put(&self->table, row * self->hdr.col_nr + col, (void *)val, 1);
-
- if ((value_type(val) == VT_STR) || (value_type(val) == VT_BLOB))
- value_type(val, VT_UNKNOWN);
-
- return 0;
-}
-
-const char *table_name2(table_t * self, size_t col_nr)
-{
- assert(self != NULL);
- assert(!MAGIC_CHECK(self->hdr.id, TABLE_MAGIC));
- assert(col_nr < self->hdr.col_nr);
-
- const char *rc = NULL;
-
- value_t *row = (value_t *) vector_at(&self->table, 0);
- if (row != NULL) {
- value_t *col = row + col_nr;
- switch (value_type(col)) {
- case VT_STR_OFF:
- rc = vector_at(&self->string, col->u64);
- break;
- case VT_STR_INLINE:
- rc = (const char *)col->data;
- break;
- case VT_STR_CONST:
- case VT_STR:
- rc = value_string(col);
- break;
- default:
- rc = NULL;
- }
- }
-
- return rc;
-}
-
-int _table_name3(table_t * self, size_t col_nr, const char *name)
-{
- return _table_name4(self, col_nr, name, strlen(name));
-}
-
-int _table_name4(table_t * self, size_t col_nr, const char *name, size_t len)
-{
- assert(self != NULL);
- assert(!MAGIC_CHECK(self->hdr.id, TABLE_MAGIC));
- assert(col_nr < self->hdr.col_nr);
-
- if (vector_size(&self->table) <= 0)
- if (vector_size(&self->table, 1) < 0)
- return -1;
-
- value_t *row = (value_t *) vector_at(&self->table, 0);
- if (row != NULL)
- value_string(row + col_nr, name, len);
-
- return 0;
-}
-
-size_t table_rows(table_t * self)
-{
- assert(self != NULL);
- assert(!MAGIC_CHECK(self->hdr.id, TABLE_MAGIC));
- return vector_size(&self->table) - 1;
-}
-
-size_t table_columns(table_t * self)
-{
- assert(self != NULL);
- assert(!MAGIC_CHECK(self->hdr.id, TABLE_MAGIC));
- return self->hdr.col_nr;
-}
-
-int table_serialize(table_t * self)
-{
- assert(self != NULL);
- assert(!MAGIC_CHECK(self->hdr.id, TABLE_MAGIC));
-
- vector_iter_t it;
- vector_iter_init(&it, &self->table, VI_FLAG_FWD);
-
- value_t *row;
- vector_for_each(&it, row) {
- for (size_t c = 0; c < self->hdr.col_nr; c++) {
- value_t *col = row + c;
-
- value_type_t type = value_type(col);
- size_t len = value_size(col);
-
- vector_t *vec = NULL;
- if (type == VT_STR)
- vec = &self->string, type = VT_STR_OFF, len++;
- else if (type == VT_BLOB)
- vec = &self->blob, type = VT_BLOB_OFF;
- else
- continue;
-
- uint64_t off = vector_size(vec);
-
- if (vector_size(vec, off + len) < 0)
- return -1;
- if (vector_put(vec, off, col->ptr, len) < 0)
- return -1;
-
- free(col->ptr), col->ptr = NULL;
-
- col->u64 = off;
- value_type(col, type);
- }
- }
-
- return 0;
-}
-
-ssize_t table_save(table_t * self, FILE * out)
-{
- assert(self != NULL);
- assert(out != NULL);
- assert(!MAGIC_CHECK(self->hdr.id, TABLE_MAGIC));
-
- /* ============= */
-
- int header_swap(table_header_t * hdr) {
- assert(hdr != NULL);
-
- if (hdr->id[IDENT_FLAGS] & TABLE_FLAG_MSB) {
- hdr->col_nr = htobe32(hdr->col_nr);
- } else if (hdr->id[IDENT_FLAGS] & TABLE_FLAG_LSB) {
- hdr->col_nr = htole32(hdr->col_nr);
- } else {
- UNEXPECTED("'%s' invalid or corrupt table object => "
- "'%x'", hdr->name, hdr->id[IDENT_FLAGS]);
- return -1;
- }
-
- return 0;
- }
-
- /* ============= */
-
- ssize_t len = 0;
-
- table_header_t hdr = self->hdr;
- if (header_swap(&hdr) < 0)
- return -1;
-
- clearerr(out);
- len = fwrite(&self->hdr, 1, sizeof(self->hdr), out);
- if (len != sizeof(self->hdr)) {
- if (ferror(out)) {
- ERRNO(errno);
- return -1;
- }
- }
-
- ssize_t rc = vector_save(&self->table, out);
- if (rc < 0)
- return -1;
- len += rc;
-
- rc = vector_save(&self->string, out);
- if (rc < 0)
- return -1;
- len += rc;
-
- rc = vector_save(&self->blob, out);
- if (rc < 0)
- return -1;
- len += rc;
-
- return len;
-}
-
-int table_deserialize(table_t * self)
-{
- assert(self != NULL);
- assert(!MAGIC_CHECK(self->hdr.id, TABLE_MAGIC));
-
- vector_iter_t it;
- vector_iter_init(&it, &self->table, VI_FLAG_FWD);
-
- value_t *row;
- vector_for_each(&it, row) {
- for (size_t c = 0; c < self->hdr.col_nr; c++) {
- value_t *col = row + c;
-
- value_type_t type = value_type(col);
- size_t len = value_size(col);
-
- switch (type) {
- uint64_t off;
- case VT_STR_OFF:
- len++;
- value_type(col, VT_STR);
- case VT_BLOB_OFF:
- off = col->u64;
- col->ptr = malloc(len);
-
- if (col->ptr == NULL) {
- ERRNO(errno);
- return -1;
- }
-
- if (vector_get(&self->string, off, col->ptr,
- len) < 0)
- return -1;
-
- if (value_type(col) == VT_BLOB_OFF)
- value_type(col, VT_BLOB);
- break;
- case VT_STR:
- case VT_BLOB:
- case VT_STR_CONST:
- UNEXPECTED("'%s' invalid or corrupt type %d",
- self->hdr.name, type);
- return -1;
- default:
- ;
- }
- }
- }
-
- if (vector_delete(&self->string) < 0)
- return -1;
- if (vector_delete(&self->blob) < 0)
- return -1;
-
- return 0;
-}
-
-ssize_t table_load(table_t * self, FILE * in)
-{
- assert(self != NULL);
-
- /* ============= */
-
- int header_swap(table_header_t * hdr) {
- assert(hdr != NULL);
- if (hdr->id[IDENT_FLAGS] & TABLE_FLAG_MSB) {
- hdr->col_nr = be32toh(hdr->col_nr);
- } else if (hdr->id[IDENT_FLAGS] & TABLE_FLAG_LSB) {
- hdr->col_nr = le32toh(hdr->col_nr);
- } else {
- UNEXPECTED("'%s' invalid or corrupt table object => "
- "'%x'", hdr->name, hdr->id[IDENT_FLAGS]);
- return -1;
- }
-
- return 0;
- }
-
- int table_swap(table_t * tbl) {
- vector_iter_t it;
- if (vector_iter_init(&it, &tbl->table, VI_FLAG_FWD) < 0)
- return -1;
-
- value_t *row;
- vector_for_each(&it, row) {
- for (size_t c = 0; c < self->hdr.col_nr; c++) {
- value_t *col = row + c;
-
- value_type_t type = value_type(row);
-
-#define iBE(s) value_i##s(col, be##s##toh(value_i##s(col)))
-#define uBE(s) value_u##s(col, be##s##toh(value_u##s(col)))
-#define iLE(s) value_i##s(col, le##s##toh(value_i##s(col)))
-#define uLE(s) value_u##s(col, le##s##toh(value_u##s(col)))
-
- if (tbl->hdr.id[IDENT_FLAGS] & TABLE_FLAG_MSB) {
- switch (type) {
- case VT_I16:
- iBE(16);
- break;
- case VT_U16:
- uBE(16);
- break;
- case VT_I32:
- iBE(32);
- break;
- case VT_U32:
- uBE(32);
- break;
- case VT_I64:
- iBE(64);
- break;
- case VT_U64:
- uBE(64);
- break;
- case VT_STR_OFF:
- case VT_BLOB_OFF:
- col->u64 = be64toh(col->u64);
- break;
- default:
- ;
- }
- } else if (tbl->hdr.id[IDENT_FLAGS] &
- TABLE_FLAG_LSB) {
- switch (type) {
- case VT_I16:
- iLE(16);
- break;
- case VT_U16:
- uLE(16);
- break;
- case VT_I32:
- iLE(32);
- break;
- case VT_U32:
- uLE(32);
- break;
- case VT_I64:
- iLE(64);
- break;
- case VT_U64:
- uLE(64);
- break;
- case VT_STR_OFF:
- case VT_BLOB_OFF:
- col->u64 = le64toh(col->u64);
- break;
- default:
- ;
- }
- } else {
- UNEXPECTED("'%s' invalid or corrupt "
- "table object => '%x'",
- tbl->hdr.name,
- tbl->hdr.id[IDENT_FLAGS]);
- return -1;
- }
- }
- }
-
- return 0;
- }
-
- /* ============= */
-
- // zero'd table will cause a magic check
- (void)table_delete(self);
-
- clearerr(in);
- size_t len = fread(&self->hdr, 1, sizeof(self->hdr), in);
- if (len != sizeof(self->hdr)) {
- if (feof(in)) {
- UNEXPECTED("'%s' end-of-file encountered",
- self->hdr.name);
- return -1;
- }
- if (ferror(in)) {
- ERRNO(errno);
- return -1;
- }
- }
-
- assert(!MAGIC_CHECK(self->hdr.id, TABLE_MAGIC));
-
- if (header_swap(&self->hdr) < 0)
- return -1;
-
- ssize_t rc = vector_load(&self->table, in);
- if (rc < 0)
- return -1;
- len += rc;
-
- if (table_swap(self) < 0)
- return -1;
-
- rc = vector_load(&self->string, in);
- if (rc < 0)
- return -1;
- len += rc;
-
- rc = vector_load(&self->blob, in);
- if (rc < 0)
- return -1;
- len += rc;
-
- return len;
-}
-
-void table_print(table_t * self, FILE * out)
-{
- if (self != NULL) {
- if (unlikely(MAGIC_CHECK(self->hdr.id, TABLE_MAGIC))) {
- UNEXPECTED("'%s' invalid or corrupt table object",
- self->hdr.name);
- return;
- }
-
- vector_iter_t it;
- vector_iter_init(&it, &self->table, VI_FLAG_FWD);
-
- value_t *row;
- vector_for_each(&it, row)
- for (size_t c = 0; c < self->hdr.col_nr; c++)
- value_dump(row + c, out);
-
- vector_dump(&self->string, out);
- }
-}
-
-void table_dump(table_t * self, FILE * out)
-{
- if (self != NULL) {
- if (unlikely(MAGIC_CHECK(self->hdr.id, TABLE_MAGIC))) {
- UNEXPECTED("'%s' invalid or corrupt table object",
- self->hdr.name);
- return;
- }
-
- fprintf(out,
- "table: [ size: %ld cols: %ld rows: %ld name: '%s']\n",
- sizeof(value_t), table_columns(self), table_rows(self),
- self->hdr.name);
-
- dump_memory(out, (unsigned long)&self->hdr, &self->hdr,
- sizeof(self->hdr));
-
- vector_dump(&self->table, out);
- vector_dump(&self->string, out);
- vector_dump(&self->blob, out);
- }
-}
-
-#if 0
-void table_sort(table_t * self, compare_f cmp)
-{
- /* The exchange function swaps two rows within the table
- * exchange(table_t * self, size_t i, size_t j)
- */
-
- /* The partition method receives a list or sublist, and places the first element
- * in its correct position within the list. It also ensures that all elements to
- * the left of this are smaller, and all to the right are larger.
- *
- * partition(a[], p, r)
- * i = p
- * j = r + 1
- * pivot = a[p]
- * do {
- * do i = i + 1 while (a[i]<pivot)
- * do j = j - 1 while (a[j]>pivot)
- * if (i < j) exchange(a[i], a[j])
- * } while (i<j)
- * exchange(a[p], a[j])
- * return j
- */
-
- /*
- * quicksort(a[], p, r)
- * if r > p then
- * j = partition(a[], p, r)
- * quicksort(a[], p, j-1)
- * quicksort(a[], j+1, r)
- *
- */
-}
-#endif
-
-/* ======================================================================= */
diff --git a/clib/src/table_iter.c b/clib/src/table_iter.c
deleted file mode 100644
index e8a3f59..0000000
--- a/clib/src/table_iter.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/src/table_iter.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 */
-
-/*
- * File: table_iter.c
- * Author: Shaun Wetzstein <shaun@us.ibm.com>
- * Descr:
- * Note:
- * Date: 10/22/10
- */
-
-#include <unistd.h>
-#include <stdarg.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 "table_iter.h"
-
-/* ======================================================================= */
-
-int table_iter_init(table_iter_t * self, table_t * table, uint32_t flags)
-{
- assert(self != NULL);
- assert(table != NULL);
-
- self->flags = flags;
- self->table = table;
-
- if (self->flags & TI_FLAG_BWD) {
- if (vector_iter_init(&self->it, &table->table, VI_FLAG_BWD) < 0)
- return -1;
- } else {
- if (vector_iter_init(&self->it, &table->table, VI_FLAG_FWD) < 0)
- return -1;
- }
-
- return vector_iter_inc(&self->it) != NULL;
-}
-
-int table_iter_clear(table_iter_t * self)
-{
- assert(self != NULL);
-
- if (vector_iter_clear(&self->it) < 0)
- return -1;
-
- self->table = NULL;
-
- return 0;
-}
-
-const value_t *table_iter_elem(table_iter_t * self)
-{
- assert(self != NULL);
- return (value_t *) vector_iter_elem(&self->it);
-}
-
-const value_t *table_iter_inc1(table_iter_t * self)
-{
- return table_iter_inc2(self, 1);
-}
-
-const value_t *table_iter_inc2(table_iter_t * self, size_t count)
-{
- assert(self != NULL);
-
- const value_t *v = NULL;
-
- for (size_t i = 0; i < count; i++) {
- if (self->flags & TI_FLAG_BWD) {
- v = (value_t *) vector_iter_dec(&self->it); // columns
- } else {
- v = (value_t *) vector_iter_inc(&self->it); // columns
- }
- }
-
- return v;
-}
-
-const value_t *table_iter_dec1(table_iter_t * self)
-{
- return table_iter_dec2(self, 1);
-}
-
-const value_t *table_iter_dec2(table_iter_t * self, size_t count)
-{
- assert(self != NULL);
-
- const value_t *v = NULL;
-
- for (size_t i = 0; i < count; i++) {
- if (self->flags & TI_FLAG_BWD) {
- v = (value_t *) vector_iter_inc(&self->it); // columns
- } else {
- v = (value_t *) vector_iter_dec(&self->it); // columns
- }
- }
-
- return v;
-}
-
-size_t table_iter_pos1(table_iter_t * self)
-{
- assert(self != NULL);
- return vector_iter_pos(&self->it) + 1;
-}
-
-int table_iter_pos2(table_iter_t * self, size_t pos)
-{
- assert(self != NULL);
- assert(pos < table_rows(self->table));
- return vector_iter_pos(&self->it, pos + 1);
-}
-
-/* ======================================================================= */
diff --git a/clib/src/timer.c b/clib/src/timer.c
deleted file mode 100644
index ffe9e8f..0000000
--- a/clib/src/timer.c
+++ /dev/null
@@ -1,140 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/src/timer.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 */
-
-/*
- * File: timer.c
- * Author: Shaun Wetzstein <shaun@us.ibm.com>
- * Descr:
- * Note:
- * Date: 10/03/10
- */
-
-#include <unistd.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <malloc.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-
-#include "misc.h"
-#include "timer.h"
-
-#define TIMER_PAGE_SIZE 64
-#define TIMER_EVENT_SIZE 64
-
-/* ======================================================================= */
-
-const char *__timer_msg[] = {
- "timer: unexpected NULL self pointer",
- "timer: unexpected NULL callback structure",
-};
-
-#define TIMER_NULL (__timer_msg[0])
-#define TIMER_CALLBACK_NULL (__timer_msg[1])
-
-/* ======================================================================= */
-
-void timer_init(timer * self, int clock)
-{
- if (unlikely(self == NULL))
- throw_unexpected(TIMER_NULL);
-
- if (self->fd != -1)
- close(self->fd), self->fd = -1;
-
- self->fd = timerfd_create(clock, TFD_CLOEXEC);
- if (unlikely(self->fd == -1))
- throw_errno(errno);
-
- vector_init(&self->callbacks, "callbacks",
- sizeof(timer_callback), TIMER_PAGE_SIZE);
-}
-
-void timer_delete(timer * self)
-{
- if (unlikely(self == NULL))
- throw_unexpected(TIMER_NULL);
- close(self->fd), self->fd = -1;
-}
-
-int timer_fileno(timer * self)
-{
- if (unlikely(self == NULL))
- throw_unexpected(TIMER_NULL);
- return self->fd;
-}
-
-uint32_t timer_add(timer * self, timer_callback * cb)
-{
- if (unlikely(self == NULL))
- throw_unexpected(TIMER_NULL);
-
- if (access(path, F_OK) != 0)
- throw_errno(errno);
-
- uint32_t wd = inotify_add_timer(self->fd, path, events);
- if (unlikely((int)wd == -1))
- throw_errno(errno);
-
- if (cb != NULL)
- vcetor_put(&self->callbacks, wd, cb);
-
- return wd;
-}
-
-void timer_remove(timer * self, uint32_t wd)
-{
- if (unlikely(self == NULL))
- throw_unexpected(TIMER_NULL);
-
- int rc = inotify_rm_timer(self->fd, wd);
- if (unlikely(rc == -1))
- throw_errno(errno);
-
- array_status(&self->callbacks, wd, false);
-}
-
-void timer_wait(timer * self)
-{
- if (unlikely(self == NULL))
- throw_unexpected(TIMER_NULL);
-
- /* FIX ME */
-
- timer_event events[timer_EVENT_SIZE];
-
- int n = read(self->fd, events, sizeof events);
- printf("n[%d]\n", n);
-
- for (int i = 0; i < (n / sizeof *events); i++)
- printf("%d: wd[%d] mask[%x] cookie[%x] name[%.*s]\n",
- i, events[i].wd, events[i].mask, events[i].cookie,
- events[i].len, events[i].name);
-}
-
-/* ======================================================================= */
diff --git a/clib/src/tree.c b/clib/src/tree.c
index 5cd4c08..60db5cc 100644
--- a/clib/src/tree.c
+++ b/clib/src/tree.c
@@ -43,7 +43,6 @@
#include "libclib.h"
#include "tree.h"
-#include "slab.h"
/* ======================================================================= */
@@ -137,9 +136,9 @@ __tree_new_root(tree_t * self, tree_node_t * node, tree_node_t * left,
node->right = right;
node->parent = NULL;
- if (unlikely(right != NULL))
+ if (right != NULL)
right->parent = node;
- if (unlikely(left != NULL))
+ if (left != NULL)
left->parent = node;
self->root = node;
@@ -153,7 +152,7 @@ int tree_insert(tree_t * self, tree_node_t * node)
__tree_new_min(self, node);
__tree_new_max(self, node);
- if (unlikely(self->root == NULL)) {
+ if (self->root == NULL) {
__tree_new_root(self, node, NULL, NULL);
self->size++;
} else {
@@ -224,7 +223,7 @@ int tree_remove(tree_t * self, tree_node_t * node)
assert(self != NULL);
assert(node != NULL);
- if (unlikely(self->root == NULL) || unlikely(node == NULL))
+ if (self->root == NULL || node == NULL)
return 0;
/* =========================== */
@@ -366,7 +365,7 @@ int tree_walk(tree_t * self, tree_walk_f walk_func)
int __tree_walk(tree_node_t * root) {
int rc = 0;
- if (likely(root != NULL)) {
+ if (root != NULL) {
__tree_walk(root->left);
rc = walk_func(root);
__tree_walk(root->right);
@@ -407,7 +406,7 @@ void tree_node_dump(tree_node_t * node, FILE * out)
return;
void __tree_node_dump(tree_node_t * root, int level) {
- if (likely(root != NULL)) {
+ if (root != NULL) {
if (0 < level) {
for (int i = 0; i < level; i++)
fprintf(out, " ");
@@ -529,7 +528,7 @@ int splay_insert(tree_t * self, tree_node_t * node)
__tree_new_min(self, node);
__tree_new_max(self, node);
- if (unlikely(self->root == NULL)) {
+ if (self->root == NULL) {
node->left = node->right = node->parent = NULL;
self->root = node;
self->size = 1;
@@ -570,7 +569,7 @@ int splay_remove(tree_t * self, tree_node_t * node)
assert(self != NULL);
assert(node != NULL);
- if (unlikely(self->root == NULL) || unlikely(node == NULL))
+ if (self->root == NULL || node == NULL)
return 0;
if (node == self->min)
@@ -591,7 +590,7 @@ int splay_remove(tree_t * self, tree_node_t * node)
}
#else
if (self->root->left != NULL && self->root->right != NULL) {
- if (parity(int64_hash1((int64_t) self->root))) {
+ if (__builtin_parity(int64_hash1((int64_t) self->root))) {
x = splay(self->root->left, node->key,
self->compare);
x->right = self->root->right;
diff --git a/clib/src/tree_iter.c b/clib/src/tree_iter.c
index f94fe0e..2e1993d 100644
--- a/clib/src/tree_iter.c
+++ b/clib/src/tree_iter.c
@@ -42,7 +42,6 @@
#include <limits.h>
#include "libclib.h"
-#include "vector.h"
#include "tree_iter.h"
/* ======================================================================= */
diff --git a/clib/src/vector.c b/clib/src/vector.c
deleted file mode 100644
index 73aa5c4..0000000
--- a/clib/src/vector.c
+++ /dev/null
@@ -1,669 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/src/vector.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 */
-
-/*
- * File: vector.c
- * Author: Shaun Wetzstein <shaun@us.ibm.com>
- * Descr: dynamic vector
- * Note:
- * Date: 08/29/10
- */
-
-#include <unistd.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <malloc.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-
-#include "libclib.h"
-
-#include "vector.h"
-#include "tree.h"
-#include "tree_iter.h"
-#include "mq.h"
-
-/* ======================================================================= */
-
-/*! @cond */
-#define VECTOR_NODE_MAGIC "VCND"
-
-#define VECTOR_NODE_MAGIC_CHECK(m) ({ \
- bool rc = (((m)[0] != VECTOR_NODE_MAGIC[0]) || \
- ((m)[1] != VECTOR_NODE_MAGIC[1]) || \
- ((m)[2] != VECTOR_NODE_MAGIC[2]) || \
- ((m)[3] != VECTOR_NODE_MAGIC[3])); \
- rc; \
- })
-
-typedef struct vector_node vector_node_t;
-
-struct vector_node {
- uint8_t magic[4];
-
- uint32_t address;
- tree_node_t node;
-
- uint8_t data[];
-};
-
-#define VECTOR_PAGE_MAX UINT16_MAX
-#define VECTOR_PAGE_DIVISOR 32
-
-#define __index_to_page(i,s) \
-({ \
- typeof(i) _p = ((i) / (s)); \
- _p; \
-})
-
-#define __index_to_page_hashed(i,s) \
-({ \
- typeof(i) _h = int64_hash1(__index_to_page((i),(s))); \
- _h; \
-})
-/*! @endcond */
-
-/* ======================================================================= */
-
-static vector_node_t *__vector_find_page(vector_t * self, uint64_t idx)
-{
- const void *hash;
- hash = (const void *)__index_to_page_hashed(idx, self->hdr.elem_num);
-
- tree_node_t *node = tree_find(&self->tree, hash);
- if (unlikely(node == NULL)) {
- UNEXPECTED("'%ld' index out of range", idx);
- return NULL;
- }
-
- return container_of(node, vector_node_t, node);
-}
-
-static int __vector_shrink(vector_t * self)
-{
- assert(self != NULL);
-
- vector_node_t *node = __vector_find_page(self,
- vector_capacity(self) - 1);
- assert(node != NULL);
-
- int rc = splay_remove(&self->tree, &node->node);
-
- free(node);
- self->hdr.page_count--;
-
- return rc;
-}
-
-static vector_node_t *__vector_grow(vector_t * self)
-{
- assert(self != NULL);
- assert(!MAGIC_CHECK(self->hdr.id, VECTOR_MAGIC));
-
- vector_node_t *node = NULL;
- int rc = posix_memalign((void **)&node, sizeof(void *),
- self->hdr.page_size);
- if (rc != 0) {
- ERRNO(errno);
- return NULL;
- }
-
- memset(node, 0, self->hdr.page_size);
-
- node->magic[0] = VECTOR_NODE_MAGIC[0];
- node->magic[1] = VECTOR_NODE_MAGIC[1];
- node->magic[2] = VECTOR_NODE_MAGIC[2];
- node->magic[3] = VECTOR_NODE_MAGIC[3];
-
- node->address = (ulong) node;
-
- uint64_t hash = __index_to_page_hashed(vector_capacity(self),
- self->hdr.elem_num);
-
- tree_node_init(&node->node, (const void *)hash);
- if (splay_insert(&self->tree, &node->node) < 0) {
- free(node);
- return NULL;
- }
- self->hdr.page_count++;
-
- return node;
-}
-
-static int __vector_compare(const int i1, const int i2)
-{
- return i1 - i2;
-}
-
-/* ======================================================================= */
-
-int vector_init3(vector_t * self, const char *name, uint32_t elem_size)
-{
- uint32_t page_size = max(sysconf(_SC_PAGESIZE),
- __round_pow2(elem_size * VECTOR_PAGE_DIVISOR));
- return vector_init4(self, name, elem_size, page_size);
-}
-
-int vector_init4(vector_t * self, const char *name, uint32_t elem_size,
- uint32_t page_size)
-{
- assert(self != NULL);
-
- if (unlikely(MAGIC_CHECK(self->hdr.id, VECTOR_MAGIC)) == false)
- vector_delete(self);
-
- if (elem_size < VECTOR_ELEM_MIN || VECTOR_ELEM_MAX < elem_size) {
- UNEXPECTED("'%d' elem_size out of range [%d..%d]",
- elem_size, VECTOR_ELEM_MIN, VECTOR_ELEM_MAX);
- return -1;
- }
-
- page_size = __round_pow2(page_size);
- if (page_size / elem_size < VECTOR_PAGE_DIVISOR) {
- UNEXPECTED("'%d' page_size out of range [%d..%d]",
- page_size, elem_size * VECTOR_PAGE_DIVISOR,
- VECTOR_PAGE_MAX);
- return -1;
- }
-
- memset(self, 0, sizeof *self);
-
- self->hdr.id[IDENT_MAGIC_0] = VECTOR_MAGIC[IDENT_MAGIC_0];
- self->hdr.id[IDENT_MAGIC_1] = VECTOR_MAGIC[IDENT_MAGIC_1];
- self->hdr.id[IDENT_MAGIC_2] = VECTOR_MAGIC[IDENT_MAGIC_2];
- self->hdr.id[IDENT_MAGIC_3] = VECTOR_MAGIC[IDENT_MAGIC_3];
-
- self->hdr.id[IDENT_MAJOR] = CLIB_MAJOR;
- self->hdr.id[IDENT_MINOR] = CLIB_MINOR;
- self->hdr.id[IDENT_PATCH] = CLIB_PATCH;
-
- if (__BYTE_ORDER == __LITTLE_ENDIAN)
- self->hdr.id[IDENT_FLAGS] |= VECTOR_FLAG_LSB;
- if (__BYTE_ORDER == __BIG_ENDIAN)
- self->hdr.id[IDENT_FLAGS] |= VECTOR_FLAG_MSB;
-
- self->hdr.page_size = page_size;
- self->hdr.elem_size = elem_size;
- self->hdr.elem_num = (self->hdr.page_size - sizeof(vector_node_t)) /
- self->hdr.elem_size;
-
- if (name != NULL && *name != '\0')
- strncpy(self->hdr.name, name, sizeof(self->hdr.name));
-
- tree_init(&self->tree, (compare_f) __vector_compare);
-
- return 0;
-}
-
-int vector_delete(vector_t * self)
-{
- if (unlikely(self == NULL))
- return 0;
-
- assert(!MAGIC_CHECK(self->hdr.id, VECTOR_MAGIC));
-
- tree_iter_t it;
- tree_iter_init(&it, &self->tree, TI_FLAG_FWD);
-
- vector_node_t *node;
- tree_for_each(&it, node, node) {
- if (VECTOR_NODE_MAGIC_CHECK(node->magic)) {
- UNEXPECTED("'%s' invalid or corrupt vector_node"
- "object => '%.4s'", self->hdr.name,
- node->magic);
- return -1;
- }
-
- if (splay_remove(&self->tree, &node->node) < 0)
- return -1;
-
- memset(node, 0, sizeof(*node));
- free(node);
- }
-
- self->hdr.page_count = self->hdr.size = 0;
-
- return 0;
-}
-
-const void *vector_at(vector_t * self, uint32_t idx)
-{
- assert(self != NULL);
- assert(!MAGIC_CHECK(self->hdr.id, VECTOR_MAGIC));
- assert(idx < self->hdr.size);
-
- vector_node_t *node = __vector_find_page(self, idx);
- return node->data + (self->hdr.elem_size * (idx % self->hdr.elem_num));
-}
-
-int vector_get3(vector_t * self, uint32_t idx, void *ptr)
-{
- return vector_get4(self, idx, ptr, 1);
-}
-
-int vector_get4(vector_t * self, uint32_t idx, void *ptr, uint32_t count)
-{
- assert(self != NULL);
- assert(!MAGIC_CHECK(self->hdr.id, VECTOR_MAGIC));
-
- while (0 < count) {
- memcpy(ptr, vector_at(self, idx), self->hdr.elem_size);
-
- idx++;
- count--;
-
- ptr += self->hdr.elem_size;
- }
-
- return 0;
-}
-
-static inline int __vector_put(vector_t * self, uint32_t idx, const void *ptr)
-{
- assert(self != NULL);
- assert(!MAGIC_CHECK(self->hdr.id, VECTOR_MAGIC));
-
- vector_node_t *node = __vector_find_page(self, idx);
- assert(node != NULL);
-
- if (VECTOR_NODE_MAGIC_CHECK(node->magic)) {
- UNEXPECTED("'%s' invalid or corrupt vector_node object => "
- "'%.4s'", self->hdr.name, node->magic);
- return -1;
- }
-
- memcpy(node->data + (self->hdr.elem_size * (idx % self->hdr.elem_num)),
- ptr, self->hdr.elem_size);
-
- return 0;
-}
-
-int vector_put3(vector_t * self, uint32_t idx, const void *ptr)
-{
- return vector_put4(self, idx, ptr, 1);
-}
-
-int vector_put4(vector_t * self, uint32_t idx, const void *ptr, uint32_t count)
-{
- assert(self != NULL);
- assert(!MAGIC_CHECK(self->hdr.id, VECTOR_MAGIC));
- assert(idx < self->hdr.size);
-
- while (0 < count) {
- if (__vector_put(self, idx, ptr) < 0)
- return -1;
-
- idx++;
- count--;
-
- ptr += self->hdr.elem_size;
- }
-
- return 0;
-}
-
-uint32_t vector_size1(vector_t * self)
-{
- assert(self != NULL);
- return self->hdr.size;
-}
-
-int vector_size2(vector_t * self, uint32_t size)
-{
- assert(self != NULL);
- assert(!MAGIC_CHECK(self->hdr.id, VECTOR_MAGIC));
-
- size_t pages = __index_to_page(size, self->hdr.elem_num) + 1;
-
- if (vector_pages(self) < pages) {
- while (vector_pages(self) < pages)
- (void)__vector_grow(self);
- } else if (pages < vector_pages(self)) {
- if (size <= 0)
- vector_delete(self);
- else
- while (pages < vector_pages(self))
- if (__vector_shrink(self) < 0)
- return -1;
- }
-
- return self->hdr.size = size;
-}
-
-uint32_t vector_pages(vector_t * self)
-{
- assert(self != NULL);
- assert(!MAGIC_CHECK(self->hdr.id, VECTOR_MAGIC));
- return self->hdr.page_count;
-}
-
-uint32_t vector_capacity(vector_t * self)
-{
- assert(self != NULL);
- assert(!MAGIC_CHECK(self->hdr.id, VECTOR_MAGIC));
- return self->hdr.page_count * self->hdr.elem_num;
-}
-
-uint32_t vector_elem_size(vector_t * self)
-{
- assert(self != NULL);
- assert(!MAGIC_CHECK(self->hdr.id, VECTOR_MAGIC));
- return self->hdr.elem_size;
-}
-
-ssize_t vector_save(vector_t * self, FILE * out)
-{
- assert(self != NULL);
- assert(out != NULL);
- assert(!MAGIC_CHECK(self->hdr.id, VECTOR_MAGIC));
-
- int header_swap(vector_header_t * hdr) {
- assert(hdr != NULL);
-
- if (hdr->id[IDENT_FLAGS] & VECTOR_FLAG_MSB) {
- hdr->page_size = htobe32(hdr->page_size);
- hdr->elem_size = htobe16(hdr->elem_size);
- hdr->elem_num = htobe16(hdr->elem_num);
- hdr->size = htobe32(hdr->size);
- hdr->page_count = htobe32(hdr->page_count);
- } else if (hdr->id[IDENT_FLAGS] & VECTOR_FLAG_LSB) {
- hdr->page_size = htole32(hdr->page_size);
- hdr->elem_size = htole16(hdr->elem_size);
- hdr->elem_num = htole16(hdr->elem_num);
- hdr->size = htole32(hdr->size);
- hdr->page_count = htole32(hdr->page_count);
- } else {
- UNEXPECTED("'%s' invalid or corrupt flash object => "
- "'%x'", hdr->name, hdr->id[IDENT_FLAGS]);
- return -1;
- }
-
- return 0;
- }
-
- ssize_t save(vector_t * self, FILE * out) {
- tree_iter_t it;
- tree_iter_init(&it, &self->tree, TI_FLAG_FWD);
-
- ssize_t len = 0;
-
- vector_node_t *node;
- tree_for_each(&it, node, node) {
- if (VECTOR_NODE_MAGIC_CHECK(node->magic)) {
- UNEXPECTED("'%s' invalid or corrupt vector_node"
- "object => '%.4s'", self->hdr.name,
- node->magic);
- return -1;
- }
-
- size_t rc;
-
- vector_node_t copy = *node;
-
- copy.address = 0;
- copy.node.left = copy.node.right = NULL;
- copy.node.parent = NULL;
-
- rc = fwrite((char *)&copy, 1, sizeof(copy), out);
- if (rc != sizeof(copy)) {
- if (ferror(out)) {
- ERRNO(errno);
- return -1;
- }
- }
- len += rc;
-
- rc = fwrite((char *)node->data, 1,
- self->hdr.page_size - sizeof(*node), out);
- if (rc != self->hdr.page_size - sizeof(*node)) {
- if (ferror(out)) {
- ERRNO(errno);
- return -1;
- }
- }
- len += rc;
- }
-
- return len;
- }
-
- ssize_t total = 0;
-
- vector_header_t hdr = self->hdr;
- if (header_swap(&hdr) < 0)
- return -1;
-
- clearerr(out);
- total = fwrite(&hdr, 1, sizeof(hdr), out);
- if (total != sizeof(hdr)) {
- if (ferror(out)) {
- ERRNO(errno);
- return -1;
- }
- }
-
- total += save(self, out);
-
- return total;
-}
-
-ssize_t vector_load(vector_t * self, FILE * in)
-{
- assert(self != NULL);
- assert(in != NULL);
- assert(!MAGIC_CHECK(self->hdr.id, VECTOR_MAGIC));
-
- int header_swap(vector_header_t * hdr) {
- assert(hdr != NULL);
-
- if (hdr->id[IDENT_FLAGS] & VECTOR_FLAG_MSB) {
- hdr->page_size = be32toh(hdr->page_size);
- hdr->elem_size = be16toh(hdr->elem_size);
- hdr->elem_num = be16toh(hdr->elem_num);
- hdr->size = be32toh(hdr->size);
- hdr->page_count = be32toh(hdr->page_count);
- } else if (hdr->id[IDENT_FLAGS] & VECTOR_FLAG_LSB) {
- hdr->page_size = le32toh(hdr->page_size);
- hdr->elem_size = le16toh(hdr->elem_size);
- hdr->elem_num = le16toh(hdr->elem_num);
- hdr->size = le32toh(hdr->size);
- hdr->page_count = le32toh(hdr->page_count);
- } else {
- UNEXPECTED("'%s' invalid or corrupt flash object => "
- "'%x'", hdr->name, hdr->id[IDENT_FLAGS]);
- return -1;
- }
-
- return 0;
- }
-
- vector_delete(self);
-
- clearerr(in);
- ssize_t len = fread(&self->hdr, 1, sizeof(self->hdr), in);
- if (len != sizeof(self->hdr)) {
- if (feof(in)) {
- UNEXPECTED("'%s' end-of-file encountered",
- self->hdr.name);
- return -1;
- }
- if (ferror(in)) {
- ERRNO(errno);
- return -1;
- }
- }
-
- if (header_swap(&self->hdr) < 0)
- return -1;
-
- assert(!MAGIC_CHECK(self->hdr.id, VECTOR_MAGIC));
-
- tree_init(&self->tree, (compare_f) __vector_compare);
- vector_node_t *node = NULL;
-
- for (size_t i = 0; i < vector_pages(self); i++) {
- size_t rc = posix_memalign((void **)&node, sizeof(void *),
- self->hdr.page_size);
- if (rc != 0) {
- ERRNO(errno);
- return -1;
- }
- memset(node, 0, self->hdr.page_size);
-
- rc = fread((void *)node, 1, self->hdr.page_size, in);
- if (rc != self->hdr.page_size) {
- if (feof(in)) {
- UNEXPECTED("'%s' end-of-file encountered",
- self->hdr.name);
- return -1;
- }
- if (ferror(in)) {
- ERRNO(errno);
- return -1;
- }
- }
-
- len += rc;
-
- if (VECTOR_NODE_MAGIC_CHECK(node->magic)) {
- UNEXPECTED("'%s' invalid or corrupt vector_node "
- "object => '%.4s'", self->hdr.name,
- node->magic);
- return -1;
- }
-
- node->address = (ulong) node;
- tree_node_init(&node->node, node->node.key);
- splay_insert(&self->tree, &node->node);
-
- node = NULL;
- }
-
- return len;
-}
-
-int vector_send(vector_t * self, mqueue_t * mq)
-{
- assert(self != NULL);
- assert(mq != NULL);
- assert(!MAGIC_CHECK(self->hdr.id, VECTOR_MAGIC));
-
- mqueue_send(mq, (char *)self, sizeof(*self));
-
- tree_iter_t it;
- tree_iter_init(&it, &self->tree, TI_FLAG_FWD);
-
- vector_node_t *node;
- tree_for_each(&it, node, node) {
- assert(!VECTOR_NODE_MAGIC_CHECK(node->magic));
- mqueue_send(mq, (char *)node, self->hdr.page_size);
- }
-
- return 0;
-}
-
-int vector_receive(vector_t * self, mqueue_t * mq)
-{
- assert(self != NULL);
- assert(mq != NULL);
- assert(!MAGIC_CHECK(self->hdr.id, VECTOR_MAGIC));
-
- vector_delete(self);
-
- mqueue_attr_t attr = mqueue_getattr(mq);
-
- vector_node_t *node = NULL;
- size_t rc = posix_memalign((void **)&node, attr.mq_msgsize,
- attr.mq_msgsize);
- if (rc != 0) {
- ERRNO(errno);
- return -1;
- }
-
- ssize_t len = mqueue_receive(mq, (void *)node, attr.mq_msgsize);
- assert(0 < len);
-
- assert(!MAGIC_CHECK(self->hdr.id, VECTOR_MAGIC));
-
- memcpy(self, (void *)node, sizeof(*self));
- tree_init(&self->tree, (compare_f) __vector_compare);
-
- for (size_t i = 0; i < vector_pages(self); i++) {
- rc = posix_memalign((void **)&node, attr.mq_msgsize,
- attr.mq_msgsize);
- if (rc != 0) {
- ERRNO(errno);
- return -1;
- }
-
- len = mqueue_receive(mq, (void *)node, attr.mq_msgsize);
- assert(0 < len);
-
- assert(!VECTOR_NODE_MAGIC_CHECK(node->magic));
-
- node->address = (ulong) node;
- tree_node_init(&node->node, node->node.key);
- splay_insert(&self->tree, &node->node);
-
- node = NULL;
- }
-
- return 0;
-}
-
-void vector_dump(vector_t * self, FILE * out)
-{
- if (out == NULL)
- out = stdout;
-
- if (self != NULL) {
- assert(!unlikely(MAGIC_CHECK(self->hdr.id, VECTOR_MAGIC)));
-
- fprintf(out, "%s: page_size: %d elem_size: %d elem_num: %d -- "
- "size: %d capacity: %d -- page_count: %d\n",
- self->hdr.name, self->hdr.page_size,
- self->hdr.elem_size, self->hdr.elem_num,
- vector_size(self), vector_capacity(self),
- self->hdr.page_count);
-
- tree_iter_t it;
- tree_iter_init(&it, &self->tree, TI_FLAG_FWD);
-
- vector_node_t *node;
- tree_for_each(&it, node, node) {
- fprintf(out, "magic[%.4s] node: %p data: %p -- "
- "address: %x\n", node->magic, &node->node,
- node->data, node->address);
-
- dump_memory(out, (unsigned long)node, node,
- self->hdr.page_size);
- }
- }
-}
-
-/* ======================================================================= */
diff --git a/clib/src/vector_iter.c b/clib/src/vector_iter.c
deleted file mode 100644
index f3db641..0000000
--- a/clib/src/vector_iter.c
+++ /dev/null
@@ -1,184 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/src/vector_iter.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 */
-
-/*
- * File: vector_iter.c
- * Author: Shaun Wetzstein <shaun@us.ibm.com>
- * Descr: dynamic array
- * Note:
- * Date: 10/22/10
- */
-
-#include <unistd.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <malloc.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-
-#include "libclib.h"
-#include "vector_iter.h"
-
-/* ======================================================================= */
-
-static inline const void *__vector_iter_bwd(vector_iter_t * self)
-{
- size_t low = 0;
- const void *ret = NULL;
-
- if (low < self->idx)
- self->idx--;
-
- if (low < self->idx)
- ret = vector_at(self->vector, self->idx);
-
- return ret;
-}
-
-static inline const void *__vector_iter_fwd(vector_iter_t * self)
-{
- size_t high = vector_size(self->vector);
- const void *ret = NULL;
-
- if (self->idx < high)
- self->idx++;
-
- if (self->idx < high)
- ret = vector_at(self->vector, self->idx);
-
- return ret;
-}
-
-int vector_iter_init(vector_iter_t * self, vector_t * vector, uint32_t flags)
-{
- assert(self != NULL);
- assert(vector != NULL);
-
- self->flags = flags;
- self->vector = vector;
-
- if (self->flags & VI_FLAG_BWD) {
- self->idx = vector_size(self->vector);
- __vector_iter_bwd(self);
- } else {
- self->idx = 0;
- }
-
- return 0;
-}
-
-int vector_iter_clear(vector_iter_t * self)
-{
- assert(self != NULL);
-
- if (self->flags & VI_FLAG_BWD)
- self->idx = vector_size(self->vector);
- else
- self->idx = 0;
-
- self->vector = NULL;
- return 0;
-}
-
-const void *vector_iter_elem(vector_iter_t * self)
-{
- assert(self != NULL);
-
- if (vector_capacity(self->vector) <= self->idx) {
- UNEXPECTED("'%d' index out-of-range", self->idx);
- return NULL;
- }
-
- if (vector_size(self->vector) <= self->idx)
- return NULL;
-
- return vector_at(self->vector, self->idx);
-}
-
-const void *vector_iter_inc1(vector_iter_t * self)
-{
- return vector_iter_inc2(self, 1);
-}
-
-const void *vector_iter_inc2(vector_iter_t * self, size_t count)
-{
- assert(self != NULL);
-
- const void *ret = NULL;
-
- for (size_t i = 0; i < count; i++) {
- if (self->flags & VI_FLAG_BWD)
- ret = __vector_iter_bwd(self);
- else
- ret = __vector_iter_fwd(self);
- }
-
- return ret;
-}
-
-const void *vector_iter_dec1(vector_iter_t * self)
-{
- return vector_iter_dec2(self, 1);
-}
-
-const void *vector_iter_dec2(vector_iter_t * self, size_t count)
-{
- assert(self != NULL);
-
- const void *ret = NULL;
-
- for (size_t i = 0; i < count; i++) {
- if (self->flags & VI_FLAG_BWD)
- ret = __vector_iter_fwd(self);
- else
- ret = __vector_iter_bwd(self);
- }
-
- return ret;
-}
-
-size_t vector_iter_pos1(vector_iter_t * self)
-{
- assert(self != NULL);
- return self->idx;
-}
-
-int vector_iter_pos2(vector_iter_t * self, size_t pos)
-{
- assert(self != NULL);
-
- if (vector_size(self->vector) <= pos) {
- UNEXPECTED("'%ld' index out-of-range", pos);
- return -1;
- }
-
- self->idx = pos;
- return 0;
-}
-
-/* ======================================================================= */
diff --git a/clib/src/watch.c b/clib/src/watch.c
deleted file mode 100644
index 508a424..0000000
--- a/clib/src/watch.c
+++ /dev/null
@@ -1,142 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/src/watch.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 */
-
-/*
- * File: watch.c
- * Author: Shaun Wetzstein <shaun@us.ibm.com>
- * Descr:
- * Note:
- * Date: 10/03/10
- */
-
-#include <unistd.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <malloc.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-
-#include "misc.h"
-#include "nargs.h"
-#include "watch.h"
-
-#define WATCH_PAGE_SIZE 64
-#define WATCH_EVENT_SIZE 64
-
-/* ======================================================================= */
-
-const char *__watch_msg[] = {
- "watch: unexpected NULL self pointer",
- "watch: unexpected NULL callback structure",
-};
-
-#define WATCH_NULL (__watch_msg[0])
-#define WATCH_CALLBACK_NULL (__watch_msg[1])
-
-/* ======================================================================= */
-
-void watch_init(watch_t * self)
-{
- if (unlikely(self == NULL))
- throw_unexpected(WATCH_NULL);
-
- if (self->fd != -1)
- close(self->fd), self->fd = -1;
-
- self->fd = inotify_init1(IN_CLOEXEC);
- if (unlikely(self->fd == -1))
- throw_errno(errno);
-
- array_init(&self->callbacks, sizeof(watch_callback_t), WATCH_PAGE_SIZE);
-}
-
-void watch_delete(watch_t * self)
-{
- if (unlikely(self == NULL))
- throw_unexpected(WATCH_NULL);
- close(self->fd), self->fd = -1;
- array_delete(&self->callbacks);
-}
-
-int watch_fileno(watch_t * self)
-{
- if (unlikely(self == NULL))
- throw_unexpected(WATCH_NULL);
- return self->fd;
-}
-
-uint32_t watch_add(watch_t * self, const char *path, uint32_t events,
- watch_callback_t * cb)
-{
- if (unlikely(self == NULL))
- throw_unexpected(WATCH_NULL);
-
- if (access(path, F_OK) != 0)
- throw_errno(errno);
-
- uint32_t wd = inotify_add_watch(self->fd, path, events);
- if (unlikely((int)wd == -1))
- throw_errno(errno);
-
- if (cb != NULL)
- array_put(&self->callbacks, wd, cb, 1);
-
- return wd;
-}
-
-void watch_remove(watch_t * self, uint32_t wd)
-{
- if (unlikely(self == NULL))
- throw_unexpected(WATCH_NULL);
-
- int rc = inotify_rm_watch(self->fd, wd);
- if (unlikely(rc == -1))
- throw_errno(errno);
-
- array_status(&self->callbacks, wd, false);
-}
-
-void watch_wait(watch_t * self)
-{
- if (unlikely(self == NULL))
- throw_unexpected(WATCH_NULL);
-
- /* FIX ME */
-
- watch_event_t events[WATCH_EVENT_SIZE];
-
- ssize_t n = read(self->fd, events, sizeof events);
- printf("n[%d]\n", n);
-
- for (ssize_t i = 0; i < (ssize_t) (n / sizeof *events); i++)
- printf("%d: wd[%d] mask[%x] cookie[%x] name[%.*s]\n",
- i, events[i].wd, events[i].mask, events[i].cookie,
- events[i].len, events[i].name);
-}
-
-/* ======================================================================= */
diff --git a/clib/stack.h b/clib/stack.h
deleted file mode 100644
index 12a9ea7..0000000
--- a/clib/stack.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/stack.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 stack.h
- * @brief stack container
- * @details
- * A stack is a data structure (container) used for collecting a sequence of elements.
- * stack allow for efficient insertion, removal and retreival of elements.
- *
- * @details For example,
- * @code
- * #include <clib/stack.h>
- * #include <clib/stack_iter.h>
- *
- * int main(const int argc, const char * argv[]) {
- * typedef struct {
- * stack_node_t node;
- * int i;
- * float f;
- * } data_t;
- *
- * slab_t s;
- * slab_init(&s, sizeof(data_t), 0);
- *
- * stack_t a;
- * stack_init(&a);
- *
- * int i;
- * for (i=0; i<10; i++) {
- * data_t * d = (data_t *)slab_alloc(&s);
- *
- * d->i = i;
- * d->f = (float)i;
- *
- * stack_add_tail(&l, &d->node);
- * }
- *
- * data_t * d;
- * stack_for_each(&l, d, node) {
- * printf("i: %d f: %f\n", d->i, d->f);
- * }
- *
- * stack_dump(&l, stdout);
- * slab_delete(&s);
- *
- * return 0;
- * }
- * @endcode
- * @author Shaun Wetzstein <shaun@us.ibm.com>
- * @date 2010-2011
- */
-
-#ifndef __STACK_H__
-#define __STACK_H__
-
-#include "list.h"
-#include "type.h"
-
-typedef list stack;
-typedef list_node stack_node;
-
-#define stack_init(s) list_init((list *)(s))
-#define stack_push(s,n) list_add_tail((list *)(s),(n))
-#define stack_pop(s) list_remove_tail((list *)(s))
-#define stack_empty(s) list_empty((list *)(s))
-#define stack_dump(s,o) list_dump((list *)(s),(o))
-
-#define stack_entry(n, t, m) list_entry((n),(t),(m))
-#define stack_top(s) list_head((list *)(s))
-#define stack_bottom(s) list_tail((list *)(s))
-
-#define stack_for_each(s, i, m) \
- for (i = container_of_var(s->node.next, i, m); \
- &i->m != &(s)->node; \
- i = container_of_var(i->m.next, i, m))
-
-#define stack_for_each_safe(s, i, n, m) \
- for (i = container_of_var((s)->node.next, i, m), \
- n = container_of_var(i->m.next, i, m); \
- &i->m != &(s)->node; \
- i = n, n = container_of_var(i->m.next, i, m))
-
-#endif /* __STACK_H__ */
diff --git a/clib/table.h b/clib/table.h
deleted file mode 100644
index ceed6d1..0000000
--- a/clib/table.h
+++ /dev/null
@@ -1,279 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/table.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 table.h
- * @brief Table Container
- * @details For example,
- * @code
- * #include <clib/array.h>
- * #include <clib/array_iter.h>
- *
- * int main(const int argc, const char * argv[]) {
- * table t;
- * table_init(&t, COLS);
- *
- * const char * str = "column0 is a really long string";
- *
- * table_name(&t, "table name");
- * table_name(&t, 0, str);
- * table_name(&t, 1, "column1");
- * table_name(&t, 2, "column2");
- * table_name(&t, 3, "column3");
- * table_name(&t, 4, "column4");
- *
- * printf("%s\n", table_name(&t, 0));
- *
- * size_t r, c;
- * value v;
- *
- * for (r=0; r<COLS; r++) {
- * for (c=0; c<COLS; c++) {
- * table_put(&t, r, c,
- * value_set(&v, r * COLS + c));
- *
- * printf("t[%d][%d] --> %d\n", r, c, r * COLS + c);
- * }
- * }
- *
- * table_iter it;
- * table_iter_init(&it, &t);
- *
- * value * val;
- * table_for_each(&it, val)
- * value_dump(val, stdout);
- *
- * table_delete(&t);
- *
- * return 0;
- * }
- * @endcode
- * @author Shaun Wetzstein <shaun@us.ibm.com>
- * @date 2010-2011
- */
-
-#ifndef __TABLE_H__
-#define __TABLE_H__
-
-#include <stdint.h>
-#include <stdbool.h>
-
-#include "compare.h"
-#include "vector.h"
-#include "value.h"
-#include "mqueue.h"
-
-/* ======================================================================= */
-
-#define TABLE_NAME_SIZE 52 //!< Maximum table name size (in bytes)
-
-#define TABLE_MAGIC "TBLE" //!< Table magic number
-
-#define TABLE_FLAG_LSB 0x01 //!< little-endian header data
-#define TABLE_FLAG_MSB 0x02 //!< big-endian header data
-
-#define INIT_TABLE_HEADER {INIT_IDENT,{0,},0}
-#define INIT_TABLE {INIT_TABLE_HEADER,INIT_VECTOR,INIT_VECTOR,INIT_VECTOR}
-
-/*!
- * @brief table container header
- */
-struct table_header {
- ident_t id; //!< Identification
- char name[TABLE_NAME_SIZE]; //!< Table name
-
- size_t col_nr; //!< Number of columns
-};
-typedef struct table_header table_header_t; //!< Alias for the @em table_header class
-
-/*!
- * @brief table container
- */
-struct table { //!< The Table class
- table_header_t hdr; //!< Table metadata
-
- vector_t table; //!< @private
- vector_t string; //!< @private
- vector_t blob; //!< @private
-};
-typedef struct table table_t; //!< Alias for the @em table class
-
-/* ==================================================================== */
-
-/*!
- * @brief Constructs a @em table object
- * @memberof table
- * @param self [in] table object @em self pointer
- * @param name [in] table object @em name string
- * @param col_nr [in] Number of columns
- * @return None
- */
-extern int table_init(table_t *, const char *, uint32_t)
-/*! @cond */
-__nonnull((1, 2)) /*! @endcond */ ;
-
-/*!
- * @brief Destructs an @em table container object
- * @details Deallocate all backing storage associated with this \em table object
- * @memberof table
- * @param self [in] table object @em self pointer
- * @return None
- */
-extern int table_delete(table_t *)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Copy content from the @em table
- * @memberof table
- * @param self [in] table object @em self pointer
- * @param row [in] Row number
- * @param col [out] Column number
- * @return Reference to @em value on success, NULL otherwise
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern value_t *table_get(table_t *, size_t, size_t)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @fn const void * table_row(table_iter_t * self, size_t row_nr,
- * [ value_t * row ])
- */
-/*! @cond */
-#define table_row(...) STRCAT(table_row, NARGS(__VA_ARGS__))(__VA_ARGS__)
-extern value_t *table_row2(table_t *, size_t)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-extern int table_row3(table_t *, size_t, value_t *)
-/*! @cond */
-__nonnull((1, 3)) /*! @endcond */ ;
-/* !endcond */
-
-extern value_t *table_column(table_t *, value_t *, size_t)
-/*! @cond */
-__nonnull((1, 2)) /*! @endcond */ ;
-
-/*!
- * @brief Assign new content to the @em table
- * @memberof table
- * @param self [in] table object @em self pointer
- * @param row [in] Row number
- * @param col [in] Column number
- * @param value [in] Reference to source @em value
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern int table_put(table_t *, size_t, size_t, value_t *)
-/*! @cond */
-__nonnull((1, 4)) /*! @endcond */ ;
-
-/*!
- * @fn const char * table_name(table_t * self, size_t col, const char * name,
- * size_t len)
- * @brief Set or return the name of a column within a @em table
- * @note If the fourth parameter is omitted, the @em name is assumed to contain
- * a trailing NULL-byte
- * @note If the third parameter is omitted, the column's current name is
- * returned
- * @memberof table
- * @param self [in] table object @em self pointer
- * @param col [in] Column number
- * @param name [in] New column name string (optional)
- * @param len [in] New column name string length (optional)
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-
-/*! @cond */
-#define table_name(...) STRCAT(table_name, NARGS(__VA_ARGS__))(__VA_ARGS__)
-extern const char *table_name2(table_t *, size_t) __nonnull((1));
-
-#define table_name3(t,c,s) \
- choose_expr(const_expr(s), \
- _table_name3((t),(c),(const char *)(s)), \
- _table_name3((t),(c),(const char *)(s)))
-
-extern int _table_name3(table_t *, size_t, const char *) __nonnull((1, 3));
-
-#define table_name4(t,c,s,l) \
- choose_expr(const_expr(s), \
- _table_name4((t),(c),(const char *)(s),(l)), \
- _table_name4((t),(c),(const char *)(s),(l)))
-
-extern int _table_name4(table_t *, size_t, const char *, size_t)
-__nonnull((1, 3));
-/*! @endcond */
-
-/*!
- * @brief Return the number of rows in the @em table
- * @memberof table
- * @param self [in] table object @em self pointer
- * @return None
- */
-extern size_t table_rows(table_t *) /*! @cond */ __nonnull((1)) /*! @endcond */
-;
-
-/*!
- * @brief Return the number of column in the @em table
- * @memberof table
- * @param self [in] table object @em self pointer
- * @return None
- */
-extern size_t table_columns(table_t *)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-extern int table_serialize(table_t *)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-extern int table_deserialize(table_t *)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-extern ssize_t table_save(table_t *, FILE *)
-/*! @cond */
-__nonnull((1, 2)) /*! @endcond */ ;
-
-extern ssize_t table_load(table_t *, FILE *)
-/*! @cond */
-__nonnull((1, 2)) /*! @endcond */ ;
-
-extern void table_print(table_t *, FILE *)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-extern void table_dump(table_t *, FILE *)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-extern int table_sort(table_t *, compare_f)
-/*! @cond */
-__nonnull((1, 2)) /*! @endcond */ ;
-
-/* ==================================================================== */
-
-#endif /* __TABLE_H__ */
diff --git a/clib/table_iter.h b/clib/table_iter.h
deleted file mode 100644
index 664534b..0000000
--- a/clib/table_iter.h
+++ /dev/null
@@ -1,179 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/table_iter.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 table_iter.h
- * @brief Table Iterator
- * @code
- * ...
- * table_iter_t it;
- * table_iter_init(&it, &t);
- *
- * value_t * val;
- * table_for_each(&it, val) {
- * if (value_type(val) != VT_UNKNOWN)
- * value_dump(val, stdout);
- * }
- * ...
- * @endcode
- * @author Shaun Wetzstein <shaun@us.ibm.com>
- * @date 2010-2011
- */
-
-#ifndef __TABLE_ITER_H__
-#define __TABLE_ITER_H__
-
-#include <stdint.h>
-#include <stdbool.h>
-
-#include "attribute.h"
-
-#include "value.h"
-#include "table.h"
-#include "vector_iter.h"
-
-/* ======================================================================= */
-
-typedef struct table_iter table_iter_t; //!< Alias for the @em table class
-
-/*!
- * @brief Table iterator
- */
-struct table_iter {
- table_t *table; //!< Reference to the target table object
- vector_iter_t it; //!< Current position of the table
- uint32_t flags; //!< Iterator configuration flags
-};
-
-/* ==================================================================== */
-
-#define TI_FLAG_NONE 0x00000000 //!< No flag mask
-#define TI_FLAG_FWD 0x00000001 //!< Forward (FWD) flag mask
-#define TI_FLAG_BWD 0x00000002 //!< Backwards (BWD) flag mask
-#define TI_FLAG_MASK 0x00000003 //!< All flag mask
-
-/*!
- * @brief Initializes an @em table_iter iterator object
- * @memberof table_iter
- * @param self [in] table_iter object @em self pointer
- * @param table [in] table container object to iterate
- * @param flags [in] iterator configuration flags
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- * @throws UNEXPECTED if @em table pointer is NULL
- */
-extern int table_iter_init(table_iter_t *, table_t *, uint32_t)
-/*! @cond */
-__nonnull((1, 2)) /*! @endcond */ ;
-
-/*!
- * @brief Resets an @em table iterator object
- * @memberof table_iter
- * @param self [in] table_iter object @em self pointer
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern int table_iter_clear(table_iter_t *)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Return a pointer to @em value element at the current iterator position
- * @memberof table_iter
- * @param self [in] table_iter object @em self pointer
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern const value_t *table_iter_elem(table_iter_t *)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Increment the position of an @em table iterator
- * @memberof table_iter
- * @param self [in] table_iter object @em self pointer
- * @param count [in] Number of positions to increment
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-#define table_iter_inc(...) STRCAT(table_iter_inc, NARGS(__VA_ARGS__))(__VA_ARGS__)
-extern const value_t *table_iter_inc1(table_iter_t *)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-extern const value_t *table_iter_inc2(table_iter_t *, size_t)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Decrement the position of an @em table iterator
- * @memberof table_iter
- * @param self [in] table_iter object @em self pointer
- * @param count [in] Number of positions to decrement
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-#define table_iter_dec(...) STRCAT(table_iter_dec, NARGS(__VA_ARGS__))(__VA_ARGS__)
-extern const value_t *table_iter_dec1(table_iter_t *)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-extern const value_t *table_iter_dec2(table_iter_t *, size_t)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @fn const void * table_iter_pos(table_iter_t * self, size_t pos)
- * @brief Return or set the iterator position witin the @em table
- * @details If the second (2nd) parameter is omitted, this functions returns
- * the current position.
- * @memberof table_iter
- * @param self [in] table_iter object @em self pointer
- * @param pos [in] new iterator position (optional)
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-/*! @cond */
-#define table_iter_pos(...) STRCAT(table_iter_pos, NARGS(__VA_ARGS__))(__VA_ARGS__)
-extern size_t table_iter_pos1(table_iter_t *)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-extern int table_iter_pos2(table_iter_t *, size_t)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-/*! @endcond */
-
-/*!
- * @def table_for_each_row(it, i)
- * @hideinitializer
- * @brief Table for-each-row element algorithm
- * @param it [in] Table iterator object
- * @param r [in] Value element variable (row)
- */
-#define table_for_each(it,r) \
- for (r = (typeof(r))table_iter_elem((it)); \
- r != NULL; \
- r = (typeof(r))table_iter_inc((it)))
-
-/* ==================================================================== */
-
-#endif /* __TABLE_ITER_H__ */
diff --git a/clib/test/array.c b/clib/test/array.c
deleted file mode 100644
index f5148e4..0000000
--- a/clib/test/array.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/test/array.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/array.h>
-#include <clib/array_iter.h>
-
-#define SIZE 2550
-
-int main(const int argc, const char * argv[]) {
- array_t a;
- array_init(&a, 4, 1024);
-
-printf("size[%d]\n", array_size(&a));
-printf("pages[%d]\n", array_pages(&a));
-printf("capacity[%d]\n", array_capacity(&a));
-printf("low[%u] high[%u]\n", array_low(&a), array_high(&a));
-exit(1);
-
- array_dump(&a, stdout);
-
- array_put(&a, 52, (uint32_t[]){52});
- array_put(&a, 53, (uint32_t[]){53});
- array_put(&a, 167, (uint32_t[]){167});
- array_put(&a, 223, (uint32_t[]){223});
- array_put(&a, 78, (uint32_t[]){78});
- array_put(&a, 205, (uint32_t[]){205});
- array_put(&a, 183, (uint32_t[]){183});
- array_put(&a, 150, (uint32_t[]){150});
- array_put(&a, 90, (uint32_t[]){90});
- array_put(&a, 66, (uint32_t[]){66});
- array_put(&a, 91, (uint32_t[]){91});
- array_put(&a, 45, (uint32_t[]){45});
- array_put(&a, 211, (uint32_t[]){211});
-
- uint32_t arr[] = {985,986,987,988,990,991,992,993,994};
- array_put(&a, 985, arr, 9);
-
- array_iter_t it;
- array_iter_init(&it, &a, AI_FLAG_FWD);
-
- uint32_t * j;
- array_for_each(&it, j) {
- printf("arr[%d]\n", *j);
- }
-
- array_dump(&a, stdout);
- array_delete(&a);
-
- return 0;
-}
diff --git a/clib/test/dispatch.c b/clib/test/dispatch.c
deleted file mode 100644
index 88718f7..0000000
--- a/clib/test/dispatch.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/test/dispatch.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 <unistd.h>
-
-#include <clib/watch.h>
-#include <clib/dispatch.h>
-
-int callback(dispatch_event_t * ev, void * ptr) {
- char buf[256];
- int rc;
-
- rc = read(ev->fd, buf, sizeof buf);
- printf("rc[%d]\n", rc);
-
- printf("fd[%x]\n", ev->fd);
- printf("events[%x]\n", ev->events);
-
- return 0;
-}
-
-int main(const int argc, const char * argv[]) {
- watch_t w;
- watch_init(&w);
-
- watch_callback_t wc = {
- .data = NULL,
- .func = NULL,
- };
-
- watch_add(&w, "/dev/mqueue", IN_CREATE | IN_ATTRIB, &wc);
-
- dispatch_t d;
- dispatch_init(&d);
-
- dispatch_callback_t dc = {
- .data = NULL,
- .func = callback,
- };
-
- dispatch_add(&d, watch_fileno(&w), EPOLLIN, &dc);
- dispatch_wait(&d);
-
- return 0;
-}
diff --git a/clib/test/exception.c b/clib/test/exception.c
index 3461630..b8f33c5 100644
--- a/clib/test/exception.c
+++ b/clib/test/exception.c
@@ -27,7 +27,6 @@
#include <stdio.h>
#include <clib/exception.h>
-#include <clib/memory_leak_detection.h>
#define EXCEPTION_FOO 1
#define EXCEPTION_BAR 2
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;
-}
diff --git a/clib/test/map.c b/clib/test/map.c
deleted file mode 100644
index 4ef7ba6..0000000
--- a/clib/test/map.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/test/map.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/map.h>
-
-struct data {
- map_node_t node;
- int i;
- float f;
-};
-typedef struct data data_t;
-
-int main (void) {
- slab_t s = INIT_SLAB;
- slab_init(&s, "my_slab", sizeof(data_t), 0);
-
- int compare(const int i1, const int i2) {
- return i1 - i2;
- }
-
- map_t m;
- map_init(&m, (compare_f)compare);
-
- int i;
- for (i=0; i<100; i++) {
- data_t * d = (data_t *)slab_alloc(&s);
-
- printf("i[%d]\n", i);
-
- d->i = i;
- d->f = (float)i;
-
- map_node_init(&d->node, (const void *)(d->i));
- map_insert(&m, &d->node);
- }
-
-#if 1
- i = 6;
- map_node_t * n = map_find(&m, (const void *)(i));
- map_remove(&m, n);
- n = map_find(&m, (const void *)i);
-
- i = 2;
- map_find(&m, (const void *)i);
- i = 8;
- map_find(&m, (const void *)i);
-#endif
-
- map_dump(&m, stdout);
- slab_delete(&s);
-
- return 0;
-}
-
diff --git a/clib/test/mq.c b/clib/test/mq.c
deleted file mode 100644
index 8cdcb0c..0000000
--- a/clib/test/mq.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/test/mq.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 <unistd.h>
-
-#include <clib/vector.h>
-#include <clib/vector_iter.h>
-
-#include <clib/misc.h>
-#include <clib/mq.h>
-
-#define SIZE 2550
-
-int main(void) {
- vector_t a = INIT_VECTOR;
- vector_init(&a, "my_vector", 4, 1024);
-
- vector_put(&a, 52, (uint32_t[]){52});
- vector_put(&a, 53, (uint32_t[]){53});
- vector_put(&a, 167, (uint32_t[]){167});
- vector_put(&a, 223, (uint32_t[]){223});
- vector_put(&a, 78, (uint32_t[]){78});
- vector_put(&a, 205, (uint32_t[]){205});
- vector_put(&a, 183, (uint32_t[]){183});
- vector_put(&a, 150, (uint32_t[]){150});
- vector_put(&a, 90, (uint32_t[]){90});
- vector_put(&a, 66, (uint32_t[]){66});
- vector_put(&a, 91, (uint32_t[]){91});
- vector_put(&a, 45, (uint32_t[]){45});
- vector_put(&a, 211, (uint32_t[]){211});
- uint32_t arr[] = {55,56,57,58,59,60,61,62,63};
- vector_put(&a, 985, arr, 9);
-
- vector_iter_t it;
- vector_iter_init(&it, &a, VI_FLAG_FWD);
-
- uint32_t * j;
- vector_for_each(&it, j) {
- printf("XXX i[%d]\n", *j);
- }
-
- vector_dump(&a, stdout);
-
- mqueue_t mq = INIT_MQUEUE;
- mqueue_init(&mq, "dbs");
- mqueue_create(&mq, gettid());
-
- vector_send(&a, &mq);
- vector_delete(&a);
-
- sleep(1);
-
- mqueue_delete(&mq);
-
- return 0;
-}
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;
-}
-
diff --git a/clib/test/table.c b/clib/test/table.c
deleted file mode 100644
index e93dddb..0000000
--- a/clib/test/table.c
+++ /dev/null
@@ -1,109 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/test/table.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/table.h>
-#include <clib/table_iter.h>
-
-#define COLS 5
-
-int main(void) {
- table_t t = INIT_TABLE;
- table_init(&t, "table", COLS);
-
- const char * str = "column4 is a really long assed string";
-
- table_name(&t, 0, "column0");
- table_name(&t, 1, "column1");
- table_name(&t, 2, "column2");
- table_name(&t, 3, "column3");
- table_name(&t, 4, str);
-
- printf("%s\n", table_name(&t, 4));
- printf("cols: %d\n", table_columns(&t));
- printf("rows: %d\n", table_rows(&t));
-
- table_dump(&t, stdout);
-
- table_iter_t it;
- table_iter_init(&it, &t, TI_FLAG_FWD);
-
- size_t r, c;
-
- value_t * val;
- table_for_each(&it, val) {
- for (c=0; c<COLS; c++)
- value_dump(val+c, stdout);
- }
- printf("xxx =================\n");
-
- value_t v[COLS];
-
- for (r=0; r<COLS; r++) {
- for (c=0; c<COLS; c++) {
- printf("t[%d][%d] --> %d\n", r, c, r * COLS + c);
- value_i32(v+c, r * COLS + c);
- value_dump(v+c, stdout);
- }
- table_row(&t, r, v);
- }
- table_dump(&t, stdout);
- printf("yyy =================\n");
-
- table_for_each(&it, val) {
- for (c=0; c<COLS; c++)
- value_dump(val+c, stdout);
- }
- printf("zzz =================\n");
-
- FILE * f = fopen("table.bin", "w+");
- table_serialize(&t);
- table_save(&t, f);
- table_delete(&t);
- fclose(f);
-
- printf("111 =================\n");
-
- f = fopen("table.bin", "r+");
- table_load(&t, f);
- table_deserialize(&t);
- table_dump(&t, stdout);
- fclose(f);
-
- table_iter_init(&it, &t, TI_FLAG_FWD);
- table_for_each(&it, val) {
- for (c=0; c<COLS; c++)
- value_dump(val+c, stdout);
- }
- printf("aaa =================\n");
-
- table_dump(&t, stdout);
- table_delete(&t);
-
- return 0;
-}
diff --git a/clib/test/vector.c b/clib/test/vector.c
deleted file mode 100644
index 262f1cf..0000000
--- a/clib/test/vector.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/test/vector.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/vector.h>
-#include <clib/vector_iter.h>
-
-int main(void) {
- vector_t a = INIT_VECTOR;
- vector_init(&a, "foo", 4, 1024);
-
- vector_size(&a, 1000);
-
- vector_put(&a, 0, (uint32_t[]){0xffffffff});
- vector_put(&a, 1, (uint32_t[]){0xffffffff});
- vector_put(&a, 52, (uint32_t[]){52});
- vector_put(&a, 53, (uint32_t[]){53});
- vector_put(&a, 167, (uint32_t[]){167});
- vector_put(&a, 223, (uint32_t[]){223});
- vector_put(&a, 78, (uint32_t[]){78});
- vector_put(&a, 205, (uint32_t[]){205});
- vector_put(&a, 183, (uint32_t[]){183});
- vector_put(&a, 150, (uint32_t[]){150});
- vector_put(&a, 90, (uint32_t[]){90});
- vector_put(&a, 66, (uint32_t[]){66});
- vector_put(&a, 91, (uint32_t[]){91});
- vector_put(&a, 45, (uint32_t[]){45});
- vector_put(&a, 211, (uint32_t[]){211});
-
- uint32_t arr[] = {985,986,987,988,990,991,992,993,994};
- vector_put(&a, 985, arr, 9);
-
- vector_dump(&a, stdout);
-
- vector_size(&a, 200);
-
- vector_dump(&a, stdout);
-
- FILE *f = fopen("vector.bin", "w+");
- vector_save(&a, f);
- fclose(f);
-
- vector_delete(&a);
-
- f = fopen("vector.bin", "r");
- vector_load(&a, f);
- fclose(f);
-
-#if 1
- vector_iter_t it;
- vector_iter_init(&it, &a, VI_FLAG_FWD);
-
- uint32_t * j;
- vector_for_each(&it, j) {
- printf("arr[%d] = %d\n", it.idx, *j);
- }
-#endif
-
- vector_dump(&a, stdout);
-
- vector_delete(&a);
-
- return 0;
-}
diff --git a/clib/test/watch.c b/clib/test/watch.c
deleted file mode 100644
index 4e0305a..0000000
--- a/clib/test/watch.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/test/watch.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 <unistd.h>
-
-#include <clib/watch.h>
-
-int callback(watch_event_t * we) {
- printf("hello\n");
- return 0;
-}
-
-int main(const int argc, const char * argv[]) {
- watch_t w;
- watch_init(&w);
-
- watch_callback_t cb = {
- .data = NULL,
- .func = callback,
- };
-
- watch_add(&w, "/dev/mqueue", IN_CREATE | IN_ATTRIB, &cb);
- watch_wait(&w);
-
- return 0;
-}
diff --git a/clib/timer.h b/clib/timer.h
deleted file mode 100644
index 45e7e1b..0000000
--- a/clib/timer.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/timer.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: timer.h
- * Author: Shaun Wetzstein <shaun@us.ibm.com>
- * Descr: Timer
- * Note:
- * Date: 10/03/10
- */
-
-#ifndef __TIMER_H__
-#define __TIMER_H__
-
-#include <stdint.h>
-#include <stdbool.h>
-#include <time.h>
-
-#include <sys/timerfd.h>
-
-#include "attribute.h"
-#include "builtin.h"
-#include "assert.h"
-#include "vector.h"
-
-/* ==================================================================== */
-
-typedef struct timer_struct timer_t;
-typedef struct timer_callback_struct timer_callback_t;
-typedef struct timer_event_struct timer_event_t;
-
-typedef int (*timer_f) (timer_event *);
-
-struct timer_struct {
- int fd;
- vector_t callbacks;
-};
-
-struct timer_callback_struct {
- void *data;
- timer_f func;
-};
-
-struct timer_event_struct {
-};
-
-/* ======================================================================= */
-
-extern void timer_init(timer *, int) __nonnull((1));
-extern void timer_delete(timer *) __nonnull((1));
-
-extern int timer_fileno(timer *) __nonnull((1));
-
-extern uint32_t timer_add(timer *, const char *, uint32_t,
- timer_callback *) __nonnull((1, 2));
-extern void timer_remove(timer *, uint32_t) __nonnull((1));
-
-extern void timer_wait(timer *) __nonnull((1));
-
-/* ======================================================================= */
-
-#endif /* __timer_H__ */
diff --git a/clib/tree.h b/clib/tree.h
index f6736f8..dafdf38 100644
--- a/clib/tree.h
+++ b/clib/tree.h
@@ -69,7 +69,6 @@
#include <stdio.h>
#include <string.h>
-#include "exception.h"
#include "builtin.h"
#include "compare.h"
#include "type.h"
diff --git a/clib/vector.h b/clib/vector.h
deleted file mode 100644
index 1d39b4f..0000000
--- a/clib/vector.h
+++ /dev/null
@@ -1,439 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/vector.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 vector.h
- * @brief Vector container
- * @details Vectors are a container whose elements are in sequential order
- * @details For example,
- * @code
- * #include <clib/vector.h>
- * #include <clib/vector_iter.h>
- *
- * int main(const int argc, const char * argv[]) {
- * vector_t a;
- * vector_init(&a, 4, 1024);
- *
- * vector_size(&a, 10);
- *
- * int i;
- * for (i=0; i<10; i++)
- * vector_put(&a, i, &i);
- * vector_put(&a, 223, (uint32_t[]){223});
- *
- * vector_iter_t it;
- * vector_iter_init(&it, &a, VI_FLAG_FWD);
- *
- * uint32_t * j;
- * vector_for_each(&it, j) {
- * printf("vec[%d]\n", *j);
- * }
- *
- * vector_dump(&a, stdout);
- * vector_delete(&a);
- *
- * return 0;
- * }
- * @endcode
- * @author Shaun Wetzstein <shaun@us.ibm.com>
- * @date 2010-2011
- */
-
-#ifndef __VECTOR_H__
-#define __VECTOR_H__
-
-#include <sys/uio.h>
-
-#include <stdbool.h>
-#include <stdint.h>
-
-#include "version.h"
-#include "nargs.h"
-#include "ident.h"
-#include "mq.h"
-#include "tree.h"
-
-/* ======================================================================= */
-
-#define VECTOR_MAGIC "VCTR"
-
-#define VECTOR_NAME_SIZE 40 //!< Maximum vector name size (in bytes)
-
-#define VECTOR_FLAG_LSB 0x01 //!< Little-endian header data
-#define VECTOR_FLAG_MSB 0x02 //!< Big-endian header data
-
-#define VECTOR_ELEM_MIN 1 //!< Minimum element size (in bytes)
-#define VECTOR_ELEM_MAX 8192 //!< Maximum element size (in bytes)
-
-#define INIT_VECTOR_HEADER {INIT_IDENT,{0,},0,0,0,0,0}
-#define INIT_VECTOR {INIT_VECTOR_HEADER, INIT_TREE}
-
-/*!
- * @brief vector container header
- */
-struct vector_header {
- ident_t id; //!< identification
- char name[VECTOR_NAME_SIZE]; //!< vector name
-
- uint32_t page_size; //!< data page size (in bytes)
- uint32_t page_count; //!< number of data pages allocated (currently)
-
- uint32_t elem_size; //!< element size (in bytes)
- uint32_t elem_num; //!< element count (per page)
-
- uint32_t size; //!< number of initialized elements
-};
-typedef struct vector_header vector_header_t; //!< Alias for the @em vector_header class
-
-/*!
- * @brief vector container
- */
-struct vector { //! The vector class
- vector_header_t hdr; //!< Table metadata
-
- tree_t tree; //!< @private
-};
-typedef struct vector vector_t; //!< Alias for the @em vector class
-
-/* ======================================================================= */
-
-/*!
- * @fn void vector_init(vector_t * self, const char * name, uint32_t elem_size [, uint32_t page_size])
- * @brief Constructs an @em vector container object
- * @details For example,
- * @code
- * ...
- * vector_t ar;
- * vector_init(&ar, 4, 1024);
- * ...
- * @endcode
- * @memberof vector
- * @param self [in] vector object @em self pointer
- * @param name [in] vector object @em name string
- * @param elem_size [in] vector element size, in bytes
- * @param page_size [in] size of page, in bytes
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-/*! @cond */
-#define vector_init(...) STRCAT(vector_init, NARGS(__VA_ARGS__))(__VA_ARGS__)
-extern int vector_init3(vector_t *, const char *, uint32_t)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-extern int vector_init4(vector_t *, const char *, uint32_t, uint32_t)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-/*! @endcond */
-
-/*!
- * @brief Destructs an @em vector container object
- * @details Deallocate all backing storage associated with this \em vector object
- * @details For example,
- * @code
- * ...
- * vector_init(&ar, 4, 1024);
- * vector_put(&ar, 524, &count);
- * vector_delete(&ar);
- * ...
- * @endcode
- * @memberof vector
- * @param self [in] vector object @em self pointer
- * @return None
- */
-extern int vector_delete(vector_t *)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Returns a reference to the element at position @em idx in the @em vector
- * @details For example,
- * @code
- * ...
- * vector_init(&ar, 4, 1024);
- * vector_put(&ar, 524, &count);
- * printf("ar[524] = %d\n", *(int *)vector_at(&ar, 524));
- * vector_delete(&ar);
- * ...
- * @endcode
- * @memberof vector
- * @param self [in] vector object @em self pointer
- * @param idx [in] vector element index
- * @return Reference to vector element at @em idx on SUCCESS
- * @throws UNEXPECTED if @em self pointer is NULL
- * @throws UNEXPECTED if vector element at @em idx is uninitialized
- */
-extern const void *vector_at(vector_t *, uint32_t)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @fn void vector_get(vector_t * self, uint32_t idx, const void * ptr, uint32_t count=1)
- * @brief Copy content from the @em vector
- * @details Copies @em elem_num element(s) starting at position @em elem_off in the source @em vector to destination pointer @em ptr
- * @note If the fourth parameter is omitted, it defaults to 1
- * @details For example,
- * @code
- * ...
- * vector_init(&ar, 4, 1024);
- * vector_put(&ar, 524, &count);
- * vector_get(&ar, 524, &count);
- * vector_delete(&ar);
- * ...
- * @endcode
- * @memberof vector
- * @param self [in] vector object @em self pointer
- * @param idx [in] vector element index
- * @param ptr [out] Destination storage pointer
- * @param count [in] Desgination element count (optional)
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-/*! @cond */
-#define vector_get(...) STRCAT(vector_get, NARGS(__VA_ARGS__))(__VA_ARGS__)
-extern int vector_get3(vector_t *, uint32_t, void *)
-/*! @cond */
-__nonnull((1, 3)) /*! @endcond */ ;
-extern int vector_get4(vector_t *, uint32_t, void *, uint32_t)
-/*! @cond */
-__nonnull((1, 3)) /*! @endcond */ ;
-/*! @endcond */
-
-/*!
- * @fn void vector_put(vector_t * self, uint32_t idx, const void * ptr, uint32_t count=1)
- * @brief Assign new content to the @em vector
- * @details Copies @em elem_num element(s) from source pointer @em ptr to the destination @em vector starting at position @em elem_off
- * @note If the fourth parameter is omitted, it defaults to 1
- * @details For example,
- * @code
- * ...
- * vector_init(&ar, 4, 1024);
- * vector_put(&ar, 524, &count);
- * vector_get(&ar, 524, &count);
- * vector_delete(&ar);
- * ...
- * @endcode
- * @memberof vector
- * @param self [in] vector object @em self pointer
- * @param idx [in] vector element index
- * @param ptr [in] Source storage pointer
- * @param count [in] Source element count (optional)
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-/*! @cond */
-#define vector_put(...) STRCAT(vector_put, NARGS(__VA_ARGS__))(__VA_ARGS__)
-extern int vector_put3(vector_t *, uint32_t, const void *)
-/*! @cond */
-__nonnull((1, 3)) /*! @endcond */ ;
-extern int vector_put4(vector_t *, uint32_t, const void *, uint32_t)
-/*! @cond */
-__nonnull((1, 3)) /*! @endcond */ ;
-/*! @endcond */
-
-/*!
- * @fn uint32_t vector_size(vector_t * self, uint32_t size = 1)
- * @brief Return or set the size of the @em vector
- * @details Return or set the number of allocated elements in the @em vector
- * @details For example,
- * @code
- * ...
- * vector_init(&ar, 4, 1024);
- * vector_size(&ar, 2040);
- * vector_delete(&ar);
- * ...
- * @endcode
- * @memberof vector
- * @param self [in] vector object @em self pointer
- * @param size [in] New vector size
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-/*! @cond */
-#define vector_size(...) STRCAT(vector_size, NARGS(__VA_ARGS__))(__VA_ARGS__)
-extern uint32_t vector_size1(vector_t *)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-extern int vector_size2(vector_t *, uint32_t)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-/*! @endcond */
-
-/*!
- * @brief Return pages of the @em vector container
- * @details Return the number of pages in the @em vector container
- * @details For example,
- * @code
- * ...
- * vector_init(&ar, 4, 1024);
- * vector_size(&ar, 2040);
- * printf("pages = %d\n", vector_pages(&ar));
- * vector_delete(&ar);
- * ...
- * @endcode
- * @memberof vector
- * @param self [in] vector object @em self pointer
- * @return The number of pages that conform the vector's content
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern uint32_t vector_pages(vector_t *)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Return capacity of the @em vector
- * @details Return the number of allocated and unallocated elements in the @em vector container
- * @details For example,
- * @code
- * ...
- * vector_init(&ar, 4, 1024);
- * vector_size(&ar, 2040);
- * printf("capacity = %d\n", vector_capacity(&ar));
- * vector_delete(&ar);
- * ...
- * @endcode
- * @memberof vector
- * @param self [in] vector object @em self pointer
- * @return The number of total elements that conform the vector's content
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern uint32_t vector_capacity(vector_t *)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-extern uint32_t vector_elem_size(vector_t *)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Save (write) an @em vector object to a stream
- * @details For example,
- * @code
- * ...
- * vector_init(&ar, 4, 1024);
- * vector_put(&ar, 7, &count);
- * vector_put(&ar, 7000, &count);
- * ...
- * FILE * f = fopen("...", "w");
- * ...
- * vector_save(&ar, f);
- * vector_delete(&ar);
- * ...
- * @endcode
- * @memberof vector
- * @param self [in] vector object @em self pointer
- * @param out [in] save destination stream
- * @return non-0 on success
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern ssize_t vector_save(vector_t *, FILE *)
-/*! @cond */
-__nonnull((1, 2)) /*! @endcond */ ;
-
-/*!
- * @brief Load (read) a @em vector object from a stream
- * @details For example,
- * @code
- * ...
- * vector ar;
- * ...
- * FILE * f = fopen("...", "r");
- * ...
- * vector_load(&ar, f);
- * vector_dump(&ar);
- * ...
- * @endcode
- * @memberof vector
- * @param self [in] vector object @em self pointer
- * @param in [in] load source stream
- * @return non-0 on success
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern ssize_t vector_load(vector_t *, FILE *)
-/*! @cond */
-__nonnull((1, 2)) /*! @endcond */ ;
-
-/*!
- * @brief Send (write) an @em vector object to a message queue
- * @details For example,
- * @code
- * ...
- * vector_init(&ar, 4, 1024);
- * vector_put(&ar, 7, &count);
- * vector_put(&ar, 7000, &count);
- * ...
- * mqueue mq;
- * mqueue_init(&mq, "my_server");
- * mqueue_create(&mq, gettid());
- * ...
- * vector_send(&ar, &mq);
- * vector_delete(&ar);
- * ...
- * @endcode
- * @memberof vector
- * @param self [in] vector object @em self pointer
- * @return non-0 on success
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern int vector_send(vector_t *, mqueue_t *)
-/*! @cond */
-__nonnull((1, 2)) /*! @endcond */ ;
-
-/*!
- * @brief receive (read) an @em vector object from a message queue
- * @details For example,
- * @code
- * ...
- * vector ar;
- * ...
- * mqueue mq;
- * mqueue_open(&mq, path);
- * ...
- * vector_receive(&ar, &mq);
- * vector_dump(&ar);
- * ...
- * @endcode
- * @memberof vector
- * @param self [in] vector object @em self pointer
- * @return non-0 on success
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern int vector_receive(vector_t *, mqueue_t *)
-/*! @cond */
-__nonnull((1, 2)) /*! @endcond */ ;
-
-/*!
- * @brief Pretty print the contents of an @em vector to stdout
- * @memberof vector
- * @param self [in] vector object @em self pointer
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern void vector_dump(vector_t *, FILE *)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/* ======================================================================= */
-
-#endif /* __VECTOR_H__ */
diff --git a/clib/vector_iter.h b/clib/vector_iter.h
deleted file mode 100644
index 764a7fc..0000000
--- a/clib/vector_iter.h
+++ /dev/null
@@ -1,188 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/vector_iter.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 vector_iter.h
- * @brief Vector Iterator
- * @details Vectors are a kind of sequence container. As such, their elements
- * are ordered following a strict linear sequence.
- * @code
- * ...
- * vector_t vec;
- * vector_init(&vec, sizeof(uint32_t), 1024);
- * ...
- * vector_iter_t it;
- * vector_iter_init(&it, &vec, VI_FLAG_FWD);
- *
- * uint32_t * j;
- * vector_for_each(&it, j) {
- * printf("vec[%d] = %d\n", it.idx, *j);
- * }
- * ...
- * @endcode
- * @author Shaun Wetzstein <shaun@us.ibm.com>
- * @date 2010-2011
- */
-
-#ifndef __VECTOR_ITER_H__
-#define __VECTOR_ITER_H__
-
-#include <stdbool.h>
-#include <stdint.h>
-
-#include "builtin.h"
-#include "vector.h"
-
-/* ======================================================================= */
-
-typedef struct vector_iter vector_iter_t; //!< Alias for the @em vector_iter class
-
-/*!
- * @brief vector iterator
- * @details Vector iterator class
- */
-struct vector_iter {
- vector_t *vector; //!< Reference to the target vector object
- uint32_t idx; //!< Current position of the iterator
- uint32_t flags; //!< Iterator configuration flags
-};
-
-/* ======================================================================= */
-
-#define VI_FLAG_NONE 0x00000000 //!< No flag mask
-#define VI_FLAG_FWD 0x00000000 //!< Forward (FWD) flag mask
-#define VI_FLAG_BWD 0x00000002 //!< Backward (BWD) flag mask
-#define VI_FLAG_MASK 0x00000003 //!< All flags mask
-
-/*!
- * @brief Initializes an @em vector_iter iterator object
- * @memberof vector_iter
- * @param self [in] vector_iter object @em self pointer
- * @param vector [in] vector container object to iterate
- * @param flags [in] iterator configuration flags
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- * @throws UNEXPECTED if @em array pointer is NULL
- */
-extern int vector_iter_init(vector_iter_t *, vector_t *, uint32_t)
-/*! @cond */
-__nonnull((1, 2)) /*! @endcond */ ;
-
-/*!
- * @brief Resets an @em vector iterator object
- * @memberof vector_iter
- * @param self [in] vector_iter object @em self pointer
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern int vector_iter_clear(vector_iter_t *)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @brief Return a pointer to @em vector element bytes at the current iterator position
- * @memberof vector_iter
- * @param self [in] vector_iter object @em self pointer
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-extern const void *vector_iter_elem(vector_iter_t *)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-
-/*!
- * @fn const void * vector_iter_inc(vector_iter_t * self, size_t count)
- * @brief Increment the position of an @em vector iterator
- * @details If the second (2nd) parameter is omitted, the iterator is
- * incremented by one (1) position.
- * @memberof vector_iter
- * @param self [in] vector_iter object @em self pointer
- * @param count [in] Number of positions to increment (optional)
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-/*! @cond */
-#define vector_iter_inc(...) STRCAT(vector_iter_inc, NARGS(__VA_ARGS__))(__VA_ARGS__)
-extern const void *vector_iter_inc1(vector_iter_t *)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-extern const void *vector_iter_inc2(vector_iter_t *, size_t)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-/*! @endcond */
-
-/*!
- * @fn const void * vector_iter_dec(vector_iter_t * self, size_t count)
- * @brief decrement the position of an @em vector iterator
- * @note If the second (2nd) parameter is omitted, the iterator is decremented by one (1) position.
- * @memberof vector_iter
- * @param self [in] vector_iter object @em self pointer
- * @param count [in] Number of positions to decrement (optional)
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-/*! @cond */
-#define vector_iter_dec(...) STRCAT(vector_iter_dec, NARGS(__VA_ARGS__))(__VA_ARGS__)
-extern const void *vector_iter_dec1(vector_iter_t *)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-extern const void *vector_iter_dec2(vector_iter_t *, size_t)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-/*! @endcond */
-
-/*!
- * @fn const void * vector_iter_pos(vector_iter_t * self, size_t pos)
- * @brief Return or set the iterator position witin the @em vector
- * @details If the second (2nd) parameter is omitted, this functions returns the current position.
- * @memberof vector_iter
- * @param self [in] vector_iter object @em self pointer
- * @param pos [in] new iterator position (optional)
- * @return None
- * @throws UNEXPECTED if @em self pointer is NULL
- */
-/*! @cond */
-#define vector_iter_pos(...) STRCAT(vector_iter_pos, NARGS(__VA_ARGS__))(__VA_ARGS__)
-extern size_t vector_iter_pos1(vector_iter_t *)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-extern int vector_iter_pos2(vector_iter_t *, size_t)
-/*! @cond */
-__nonnull((1)) /*! @endcond */ ;
-/*! @endcond */
-
-/*!
- * @def vector_for_each(it, i)
- * @hideinitializer
- * @brief Vector for-each algorithm
- * @param it [in] Tree iterator object
- * @param i [in] Tree element variable
- */
-#define vector_for_each(it, i) \
- for (i = (typeof(i))vector_iter_elem(it); \
- i != NULL; \
- i = (typeof(i))vector_iter_inc(it))
-
-/* ======================================================================= */
-
-#endif /* __VECTOR_ITER_H__ */
diff --git a/clib/watch.h b/clib/watch.h
deleted file mode 100644
index 00e005c..0000000
--- a/clib/watch.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: clib/watch.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: watch.h
- * Author: Shaun Wetzstein <shaun@us.ibm.com>
- * Descr: Directory activity callback monitor
- * Note:
- * Date: 10/03/10
- */
-
-#ifndef __WATCH_H__
-#define __WATCH_H__
-
-#include <stdint.h>
-#include <stdbool.h>
-
-#include <sys/inotify.h>
-
-#include "attribute.h"
-#include "builtin.h"
-#include "assert.h"
-
-#include "array.h"
-
-/* ==================================================================== */
-
-#define WATCH_ACCESS IN_ACCESS
-#define WATCH_ATTRIB IN_ATTRIB
-#define WATCH_CLOSE_WRITE IN_CLOSE_WRITE
-#define WATCH_CLOSE_NOWRITE IN_CLOSE_NOWRITE
-#define WATCH_CREATE IN_CREATE
-#define WATCH_DELETE IN_DELETE
-#define WATCH_DELETE_SELF IN_DELETE_SELF
-#define WATCH_MODIFY IN_MODIFY
-#define WATCH_MOVE_SELF IN_MOVE_SELF
-#define WATCH_MOVE_FROM IN_MOVE_FROM
-#define WATCH_MOVE_TO IN_MOVE_TO
-#define WATCH_OPEN IN_OPEN
-
-typedef struct watch watch_t;
-typedef struct watch_callback watch_callback_t;
-typedef struct inotify_event watch_event_t;
-
-typedef int (*watch_f) (watch_event_t *);
-
-struct watch {
- int fd;
- array_t callbacks;
-};
-
-struct watch_callback {
- void *data;
- watch_f func;
-};
-
-/* ======================================================================= */
-
-extern void watch_init(watch_t * self) __nonnull((1));
-extern void watch_delete(watch_t * self) __nonnull((1));
-
-extern int watch_fileno(watch_t * self) __nonnull((1));
-
-extern uint32_t watch_add(watch_t * self, const char *path, uint32_t events,
- watch_callback_t * cb) __nonnull((1, 2));
-extern void watch_remove(watch_t * self, uint32_t wd) __nonnull((1));
-
-extern void watch_wait(watch_t * self) __nonnull((1));
-
-/* ======================================================================= */
-
-#endif /* __watch_H__ */
diff --git a/clib/x86/Makefile b/clib/x86/Makefile
deleted file mode 100644
index 30da3b1..0000000
--- a/clib/x86/Makefile
+++ /dev/null
@@ -1,29 +0,0 @@
-# IBM_PROLOG_BEGIN_TAG
-# This is an automatically generated prolog.
-#
-# $Source: clib/x86/Makefile $
-#
-# 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
-DEPTH = ..
-
-CLIB_INSTALL = $(INST_USR_X86)
-
-include ../Rules.mk
diff --git a/clib/x86/cunit/Makefile b/clib/x86/cunit/Makefile
deleted file mode 100644
index 99c4a30..0000000
--- a/clib/x86/cunit/Makefile
+++ /dev/null
@@ -1,31 +0,0 @@
-# IBM_PROLOG_BEGIN_TAG
-# This is an automatically generated prolog.
-#
-# $Source: clib/x86/cunit/Makefile $
-#
-# 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
-DEPTH = ../../../..
-include $(DEPTH)/integration/Rules.mk
-include $(DEPTH)/integration/Rules.x86.mk
-
-CLIB_INSTALL = $(INST_TESTS_X86)/clib
-
-include ../../Rules.cunit.mk
diff --git a/clib/x86/test/Makefile b/clib/x86/test/Makefile
deleted file mode 100644
index f2986b7..0000000
--- a/clib/x86/test/Makefile
+++ /dev/null
@@ -1,31 +0,0 @@
-# IBM_PROLOG_BEGIN_TAG
-# This is an automatically generated prolog.
-#
-# $Source: clib/x86/test/Makefile $
-#
-# 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
-DEPTH = ../../../..
-include $(DEPTH)/integration/Rules.mk
-include $(DEPTH)/integration/Rules.x86.mk
-
-CLIB_INSTALL = $(INST_TESTS_X86)/clib
-
-include ../../Rules.test.mk
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..57b3d58
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,43 @@
+# -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+AC_INIT([ffs], [1.0], [https://github.com/open-power/ffs])
+AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])
+AC_CONFIG_SRCDIR([ecc/src/main.h])
+AC_CONFIG_HEADERS([config.h])
+
+# Checks for programs.
+AC_PROG_CC
+AC_PROG_RANLIB
+AM_PROG_AR
+
+# Checks for libraries.
+
+# Checks for header files.
+AC_CHECK_HEADERS([fcntl.h limits.h malloc.h stddef.h stdint.h stdlib.h string.h unistd.h])
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_C_INLINE
+AC_TYPE_INT16_T
+AC_TYPE_INT32_T
+AC_TYPE_INT64_T
+AC_TYPE_INT8_T
+AC_TYPE_MODE_T
+AC_TYPE_OFF_T
+AC_TYPE_PID_T
+AC_TYPE_SIZE_T
+AC_TYPE_SSIZE_T
+AC_TYPE_UINT16_T
+AC_TYPE_UINT32_T
+AC_TYPE_UINT64_T
+AC_TYPE_UINT8_T
+
+# Checks for library functions.
+AC_FUNC_FSEEKO
+AC_FUNC_MALLOC
+AC_FUNC_MMAP
+AC_FUNC_REALLOC
+AC_CHECK_FUNCS([ftruncate memmove memset pathconf regcomp strcasecmp strchr strdup strerror strncasecmp strrchr strtol strtoul strtoull])
+
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
diff --git a/ecc/Makefile b/ecc/Makefile
deleted file mode 100644
index 7802e86..0000000
--- a/ecc/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-# IBM_PROLOG_BEGIN_TAG
-# This is an automatically generated prolog.
-#
-# $Source: ecc/Makefile $
-#
-# 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
-SUBDIRS=x86
-
-.PHONY: subdirs $(SUBDIRS)
-
-subdirs: $(SUBDIRS)
-
-$(SUBDIRS)::
- $(MAKE) -C $@ $(MAKECMDGOALS)
-
-all clean install: $(SUBDIRS)
diff --git a/ecc/Rules.mk b/ecc/Rules.mk
deleted file mode 100644
index ed3c46d..0000000
--- a/ecc/Rules.mk
+++ /dev/null
@@ -1,44 +0,0 @@
-# IBM_PROLOG_BEGIN_TAG
-# This is an automatically generated prolog.
-#
-# $Source: ecc/Rules.mk $
-#
-# 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
-CFLAGS += -D_GNU_SOURCE -std=gnu99 -D_FILE_OFFSET_BITS=64 -I$(DEPTH)/.. -iquote..
-LDFLAGS += -L. -L$(DEPTH)/../clib/x86
-
-OBJS=main.o
-
-TARGETS=ecc
-
-vpath %.c ../src
-vpath %.h ..
-
-all: $(TARGETS)
-
-ecc: main.o $(DEPTH)/../clib/x86/libclib.a
- $(CC) $(LDFLAGS) -o $@ $^ -lpthread
-
-install: $(TARGETS)
- $(INSTALL) ecc $(ECC_INSTALL)/bin
-
-clean distclean:
- $(RM) -f $(TARGETS) $(OBJS)
diff --git a/ecc/src/main.c b/ecc/src/main.c
index 53dbf47..ab0bcb4 100644
--- a/ecc/src/main.c
+++ b/ecc/src/main.c
@@ -45,7 +45,6 @@
#include <ctype.h>
#include <clib/attribute.h>
-#include <clib/assert.h>
#include <clib/misc.h>
#include <clib/min.h>
#include <clib/ecc.h>
diff --git a/ecc/x86/Makefile b/ecc/x86/Makefile
deleted file mode 100644
index 753b03f..0000000
--- a/ecc/x86/Makefile
+++ /dev/null
@@ -1,30 +0,0 @@
-# IBM_PROLOG_BEGIN_TAG
-# This is an automatically generated prolog.
-#
-# $Source: ecc/x86/Makefile $
-#
-# 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
-DEPTH = ..
-
-ARCH=x86
-ECC_INSTALL = $(INST_USR_X86)
-
-include ../Rules.mk
diff --git a/fcp/Makefile b/fcp/Makefile
deleted file mode 100644
index a80dcbb..0000000
--- a/fcp/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-# IBM_PROLOG_BEGIN_TAG
-# This is an automatically generated prolog.
-#
-# $Source: fcp/Makefile $
-#
-# 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
-SUBDIRS=x86
-
-.PHONY: subdirs $(SUBDIRS)
-
-subdirs: $(SUBDIRS)
-
-$(SUBDIRS)::
- $(MAKE) -C $@ $(MAKECMDGOALS)
-
-all clean install: $(SUBDIRS)
diff --git a/fcp/Rules.mk b/fcp/Rules.mk
deleted file mode 100644
index d5fcd12..0000000
--- a/fcp/Rules.mk
+++ /dev/null
@@ -1,54 +0,0 @@
-# IBM_PROLOG_BEGIN_TAG
-# This is an automatically generated prolog.
-#
-# $Source: fcp/Rules.mk $
-#
-# 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
-CFLAGS += -D_GNU_SOURCE -std=gnu99 -D_FILE_OFFSET_BITS=64
-CFLAGS += -I$(DEPTH)/.. -iquote..
-
-LDFLAGS += -L.
-
-NAME=fcp
-
-CLIB=$(DEPTH)/../clib/x86/libclib.a
-FFS=$(DEPTH)/../ffs/x86/libffs.a
-
-OBJS=cmd_list.o cmd_read.o cmd_write.o cmd_erase.o \
- cmd_copy.o cmd_trunc.o cmd_user.o misc.o main.o
-
-TARGETS=$(NAME)
-
-vpath %.c ../src
-vpath %.h ..
-
-all: $(TARGETS)
-
-$(NAME): $(OBJS) $(FFS) $(CLIB)
- $(CC) $(LDFLAGS) -Wl,-no-whole-archive \
- -o $@ $^ -lpthread -ldl -lrt
-
-install: $(TARGETS)
- $(INSTALL) fcp $(FCP_INSTALL)/bin
- $(INSTALL) ../fcp.sh $(FCP_INSTALL_TEST)
-
-clean distclean:
- $(RM) -f $(TARGETS) $(OBJS)
diff --git a/fcp/ppc/Makefile b/fcp/ppc/Makefile
deleted file mode 100644
index c0302ce..0000000
--- a/fcp/ppc/Makefile
+++ /dev/null
@@ -1,33 +0,0 @@
-# IBM_PROLOG_BEGIN_TAG
-# This is an automatically generated prolog.
-#
-# $Source: fcp/ppc/Makefile $
-#
-# 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
-DEPTH = ../../..
-include $(DEPTH)/integration/Rules.mk
-include $(DEPTH)/integration/Rules.ppc.mk
-
-ARCH=ppc
-FCP_INSTALL = $(INST_USR)
-FCP_INSTALL_TEST = $(INST_TESTS)
-
-include ../Rules.mk
diff --git a/fcp/src/cmd_copy.c b/fcp/src/cmd_copy.c
index 6a0d8f6..be6bbe9 100644
--- a/fcp/src/cmd_copy.c
+++ b/fcp/src/cmd_copy.c
@@ -46,7 +46,6 @@
#include <regex.h>
#include <clib/attribute.h>
-#include <clib/assert.h>
#include <clib/list.h>
#include <clib/list_iter.h>
#include <clib/misc.h>
diff --git a/fcp/src/cmd_erase.c b/fcp/src/cmd_erase.c
index c1a7f2f..17fc9b7 100644
--- a/fcp/src/cmd_erase.c
+++ b/fcp/src/cmd_erase.c
@@ -46,7 +46,6 @@
#include <regex.h>
#include <clib/attribute.h>
-#include <clib/assert.h>
#include <clib/list.h>
#include <clib/list_iter.h>
#include <clib/misc.h>
diff --git a/fcp/src/cmd_list.c b/fcp/src/cmd_list.c
index a781441..92d855b 100644
--- a/fcp/src/cmd_list.c
+++ b/fcp/src/cmd_list.c
@@ -46,7 +46,6 @@
#include <regex.h>
#include <clib/attribute.h>
-#include <clib/assert.h>
#include <clib/list.h>
#include <clib/list_iter.h>
#include <clib/misc.h>
diff --git a/fcp/src/cmd_probe.c b/fcp/src/cmd_probe.c
deleted file mode 100644
index e06f6c3..0000000
--- a/fcp/src/cmd_probe.c
+++ /dev/null
@@ -1,186 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG */
-/* This is an automatically generated prolog. */
-/* */
-/* $Source: fcp/src/cmd_probe.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 */
-
-/*
- * File: cmd_probe.c
- * Author: Shaun Wetzstein <shaun@us.ibm.com>
- * Descr: probe implementation
- * Date: 01/30/2013
- */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include <fcntl.h>
-#include <string.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdbool.h>
-#include <unistd.h>
-#include <getopt.h>
-#include <errno.h>
-#include <ctype.h>
-#include <regex.h>
-
-#include <clib/attribute.h>
-#include <clib/assert.h>
-#include <clib/list.h>
-#include <clib/list_iter.h>
-#include <clib/misc.h>
-#include <clib/min.h>
-#include <clib/err.h>
-#include <clib/raii.h>
-
-#include <spinor/spinor.h>
-#include <spinor/aardvark.h>
-
-#include <dbgx/rwflash.h>
-
-#include "misc.h"
-#include "main.h"
-
-static int aa_probe(int verbose)
-{
- int size = 16;
-
- uint16_t ports[size];
- uint32_t unique_ids[size];
-
- int rc = aa_find_devices_ext(size, ports, size, unique_ids);
-
- fprintf(stdout, "%d aardvark(s) found:\n", rc);
-
- for (int i = 0; i < min(rc, 16); i++) {
- if (ports[i] & AA_PORT_NOT_FREE) {
- fprintf(stdout, " %d: [%04d-%06d] ===> BUSY",
- ports[i] & ~AA_PORT_NOT_FREE,
- unique_ids[i] / 1000000,
- unique_ids[i] % 1000000);
-
- continue;
- }
-
- spinor_t * nor = spinor_open(ports[i]);
- if (nor == NULL) {
- debug("unable to open aaflash on port '%d'\n", ports[i]);
- continue;
- }
-
- if (spinor_configure(nor) < 0) {
- debug("unable to configure Aardvark on port '%d'\n",
- ports[i]);
- continue;
- }
-
- fprintf(stdout, " %d: [%04d-%06d] => ",
- ports[i] & ~AA_PORT_NOT_FREE,
- unique_ids[i] / 1000000, unique_ids[i] % 1000000);
-
- spinor_id_t id;
- if (spinor_read_id(nor, id) < 0) {
- debug("unable to read device id\n");
- continue;
- }
-
- fprintf(stdout, "%s %s %s",
- spinor_id_mfg(id), spinor_id_type(id),
- spinor_id_capacity(id));
-
- fprintf(stdout, " [%2.2x %2.2x %2.2x]\n",
- id[0], id[1], id[2]);
-
- if (spinor_close(nor) < 0) {
- debug("unable to read device id\n");
- continue;
- }
-
- nor = NULL;
- }
-
- fprintf(stdout, "\n");
-
- return 0;
-}
-
-static int rw_probe(const char * host, int verbose)
-{
- assert(host != NULL);
-
- rwflash_cookie_t * cookie = rwflash_cookie_open(host, verbose);
- if (cookie == NULL) {
- debug("unable to open rwflash on host '%s'\n", host);
- return -1;
- }
-
- if (rwflash_cookie_init(cookie) < 0) {
- debug("unable to init rwflash on host '%s'\n", host);
- return -1;
- }
-
- if (rwflash_cookie_probe(cookie) < 0) {
- debug("unable to probe rwflash on host '%s'\n", host);
- return -1;
- }
-
- uint8_t * id = spinor_id(rwflash_cookie_spinor(cookie));
- if (id == NULL) {
- debug("invalid id rwflash on host '%s'\n", host);
- return -1;
- }
-
- fprintf(stdout, " %s ===> %s %s %s",
- host,
- spinor_id_mfg(id), spinor_id_type(id),
- spinor_id_capacity(id));
-
- fprintf(stdout, " [%2.2x %2.2x %2.2x]\n",
- id[0], id[1], id[2]);
-
- return 0;
-}
-
-int command_probe(args_t * args)
-{
- assert(args != NULL);
-
- int rc = 0;
-
- char * type = args->dst_type;
- char * target = args->dst_target;
-
- int verbose = args->verbose == f_VERBOSE;
-
- if (strcasecmp(type, TYPE_AA) == 0) {
- rc = aa_probe(verbose);
- } else if (strcasecmp(type, TYPE_RW) == 0) {
- rc = rw_probe(target, verbose);
- } else {
- UNEXPECTED("NOT IMPLEMENTED YET!");
- rc = -1;
- }
-
- return rc;
-}
diff --git a/fcp/src/cmd_read.c b/fcp/src/cmd_read.c
index b7c8666..0745c21 100644
--- a/fcp/src/cmd_read.c
+++ b/fcp/src/cmd_read.c
@@ -45,7 +45,6 @@
#include <ctype.h>
#include <clib/attribute.h>
-#include <clib/assert.h>
#include <clib/list.h>
#include <clib/list_iter.h>
#include <clib/misc.h>
diff --git a/fcp/src/cmd_trunc.c b/fcp/src/cmd_trunc.c
index 75a98f4..7ee11ca 100644
--- a/fcp/src/cmd_trunc.c
+++ b/fcp/src/cmd_trunc.c
@@ -46,7 +46,6 @@
#include <regex.h>
#include <clib/attribute.h>
-#include <clib/assert.h>
#include <clib/list.h>
#include <clib/list_iter.h>
#include <clib/misc.h>
diff --git a/fcp/src/cmd_user.c b/fcp/src/cmd_user.c
index 139c48b..8496f7a 100644
--- a/fcp/src/cmd_user.c
+++ b/fcp/src/cmd_user.c
@@ -46,7 +46,6 @@
#include <regex.h>
#include <clib/attribute.h>
-#include <clib/assert.h>
#include <clib/list.h>
#include <clib/list_iter.h>
#include <clib/misc.h>
diff --git a/fcp/src/cmd_write.c b/fcp/src/cmd_write.c
index ec3d6db..b3ef89b 100644
--- a/fcp/src/cmd_write.c
+++ b/fcp/src/cmd_write.c
@@ -46,7 +46,6 @@
#include <regex.h>
#include <clib/attribute.h>
-#include <clib/assert.h>
#include <clib/list.h>
#include <clib/list_iter.h>
#include <clib/misc.h>
diff --git a/fcp/src/main.c b/fcp/src/main.c
index 5c1d280..335bcf2 100644
--- a/fcp/src/main.c
+++ b/fcp/src/main.c
@@ -46,7 +46,6 @@
#include <regex.h>
#include <clib/attribute.h>
-#include <clib/assert.h>
#include <clib/list.h>
#include <clib/list_iter.h>
#include <clib/misc.h>
diff --git a/fcp/src/misc.c b/fcp/src/misc.c
index f0dbe45..004db7d 100644
--- a/fcp/src/misc.c
+++ b/fcp/src/misc.c
@@ -46,7 +46,6 @@
#include <regex.h>
#include <clib/attribute.h>
-#include <clib/assert.h>
#include <clib/version.h>
#include <clib/list.h>
#include <clib/list_iter.h>
diff --git a/fcp/x86/Makefile b/fcp/x86/Makefile
deleted file mode 100644
index b2dfe43..0000000
--- a/fcp/x86/Makefile
+++ /dev/null
@@ -1,31 +0,0 @@
-# IBM_PROLOG_BEGIN_TAG
-# This is an automatically generated prolog.
-#
-# $Source: fcp/x86/Makefile $
-#
-# 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
-DEPTH = ..
-
-ARCH=x86
-FCP_INSTALL = $(INST_USR_X86)
-FCP_INSTALL_TEST = $(INST_TESTS_X86)
-
-include ../Rules.mk
diff --git a/ffs/Makefile b/ffs/Makefile
deleted file mode 100644
index b47320f..0000000
--- a/ffs/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-# IBM_PROLOG_BEGIN_TAG
-# This is an automatically generated prolog.
-#
-# $Source: ffs/Makefile $
-#
-# 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
-SUBDIRS=x86
-
-.PHONY: subdirs $(SUBDIRS)
-
-subdirs: $(SUBDIRS)
-
-$(SUBDIRS)::
- $(MAKE) -C $@ $(MAKECMDGOALS)
-
-all clean install: $(SUBDIRS)
diff --git a/ffs/Rules.mk b/ffs/Rules.mk
deleted file mode 100644
index c014ffa..0000000
--- a/ffs/Rules.mk
+++ /dev/null
@@ -1,54 +0,0 @@
-# IBM_PROLOG_BEGIN_TAG
-# This is an automatically generated prolog.
-#
-# $Source: ffs/Rules.mk $
-#
-# 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
-CFLAGS += -D_GNU_SOURCE -std=gnu99 -D_FILE_OFFSET_BITS=64
-CFLAGS += -I$(DEPTH)/.. -I$(DEPTH)/boot/fsp2_ipl -iquote.. -fPIC
-
-LDFLAGS += -L.
-
-NAME=libffs
-
-CLIB=$(DEPTH)/../clib/x86/libclib.a
-
-OBJS=$(NAME).o $(NAME)2.o
-
-TARGETS=$(NAME).so $(NAME).a
-
-vpath %.c ../src
-vpath %.h ..
-
-all: $(TARGETS)
-
-$(NAME).so: $(OBJS)
- $(CC) $(LDFLAGS) -shared -Wl,-soname,$@ -o $@ $^
-
-$(NAME).a: $(OBJS)
- $(AR) -r $@ $^
-
-install: $(TARGETS)
- $(INSTALL) libffs.so libffs.a $(FFS_INSTALL)/lib
- $(INSTALL) ../ffs.h ../libffs.h ../libffs2.h $(FFS_INSTALL)/include
-
-clean distclean:
- $(RM) -f $(TARGETS) $(OBJS)
diff --git a/ffs/Rules.test.mk b/ffs/Rules.test.mk
deleted file mode 100644
index cedeb3e..0000000
--- a/ffs/Rules.test.mk
+++ /dev/null
@@ -1,49 +0,0 @@
-# IBM_PROLOG_BEGIN_TAG
-# This is an automatically generated prolog.
-#
-# $Source: ffs/Rules.test.mk $
-#
-# 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
-CFLAGS += -D_GNU_SOURCE -std=gnu99 -D_FILE_OFFSET_BITS=64 -I$(DEPTH)/apps -iquote..
-LDFLAGS += -L. -L$(DEPTH)/apps/clib/$(ARCH_DEP_DIR)
-
-OBJS=test_libffs.o
-
-TARGETS=test_libffs
-
-vpath %.c ../test
-vpath %.h ..
-
-all: $(TARGETS)
-
-#libffs.a: $(OBJS)
-# $(AR) -r $@ $^
-
-test_libffs: test_libffs.o ../ppc/libffs.a $(DEPTH)/apps/clib/$(ARCH_DEP_DIR)/libclib.a
- $(CC) $(LDFLAGS) -o $@ $^ -lpthread
-
-install: $(TARGETS)
- $(INSTALL) ../test/test_libffs $(TEST_LIBFFS_INSTALL)
- $(INSTALL) ../test/libffs_test.sh $(TEST_LIBFFS_INSTALL)
- $(INSTALL) ../test/ffs_tool_test.sh $(TEST_LIBFFS_INSTALL)
-
-clean distclean:
- $(RM) -f $(TARGETS) $(OBJS)
diff --git a/ffs/libffs.h b/ffs/libffs.h
index d74e365..2380a62 100644
--- a/ffs/libffs.h
+++ b/ffs/libffs.h
@@ -29,7 +29,6 @@
#include <stdbool.h>
#include <stdarg.h>
-#include <clib/exception.h>
#include "ffs.h"
diff --git a/ffs/src/libffs.c b/ffs/src/libffs.c
index 55e33bf..7e20bef 100644
--- a/ffs/src/libffs.c
+++ b/ffs/src/libffs.c
@@ -48,7 +48,6 @@
#include "libffs.h"
-#include <clib/assert.h>
#include <clib/builtin.h>
#include <clib/checksum.h>
#include <clib/misc.h>
@@ -268,7 +267,7 @@ static int __entries_read(ffs_hdr_t * hdr, FILE * file, off_t offset)
#if 0
static void __entries_write(ffs_hdr_t * hdr, FILE * file, off_t offset)
{
- if (unlikely(hdr == NULL))
+ if (hdr == NULL)
ffs_throw(UNEX, 10400, "NULL hdr pointer");
if (hdr->magic != FFS_MAGIC)
ffs_throw(UNEX, 10401, "magic number mismatch '%x' != "
@@ -740,7 +739,7 @@ int __ffs_fclose(ffs_t * self)
int __ffs_close(ffs_t * self)
{
- if (unlikely(self == NULL))
+ if (self == NULL)
return 0;
if (self->dirty == true)
@@ -1353,7 +1352,7 @@ ssize_t __ffs_entry_copy(ffs_t *self, ffs_t *in, const char *path)
assert(in != NULL);
assert(path != NULL);
- if (unlikely(*path == '\0'))
+ if (*path == '\0')
return 0;
ffs_entry_t *src = __find_entry(in->hdr, path);
@@ -1433,7 +1432,7 @@ ssize_t __ffs_entry_compare(ffs_t * self, ffs_t * in, const char *path)
assert(in != NULL);
assert(path != NULL);
- if (unlikely(*path == '\0'))
+ if (*path == '\0')
return 0;
ffs_entry_t *src = __find_entry(in->hdr, path);
diff --git a/ffs/src/libffs2.c b/ffs/src/libffs2.c
index 741dfa5..f6c8531 100644
--- a/ffs/src/libffs2.c
+++ b/ffs/src/libffs2.c
@@ -46,7 +46,6 @@
#include "libffs2.h"
-#include <clib/assert.h>
#include <clib/builtin.h>
#include <clib/checksum.h>
#include <clib/misc.h>
diff --git a/ffs/x86/Makefile b/ffs/x86/Makefile
deleted file mode 100644
index 025c50e..0000000
--- a/ffs/x86/Makefile
+++ /dev/null
@@ -1,31 +0,0 @@
-# IBM_PROLOG_BEGIN_TAG
-# This is an automatically generated prolog.
-#
-# $Source: ffs/x86/Makefile $
-#
-# 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
-DEPTH = ..
-
-ARCH=x86
-FFS_INSTALL = $(INST_USR_X86)
-FFS_INSTALL_TEST = $(INST_TESTS_X86)
-
-include ../Rules.mk
diff --git a/fpart/Makefile b/fpart/Makefile
deleted file mode 100644
index afda672..0000000
--- a/fpart/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-# IBM_PROLOG_BEGIN_TAG
-# This is an automatically generated prolog.
-#
-# $Source: fpart/Makefile $
-#
-# 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
-SUBDIRS=x86
-
-.PHONY: subdirs $(SUBDIRS)
-
-subdirs: $(SUBDIRS)
-
-$(SUBDIRS)::
- $(MAKE) -C $@ $(MAKECMDGOALS)
-
-all clean install: $(SUBDIRS)
diff --git a/fpart/Rules.mk b/fpart/Rules.mk
deleted file mode 100644
index 11a26fa..0000000
--- a/fpart/Rules.mk
+++ /dev/null
@@ -1,54 +0,0 @@
-# IBM_PROLOG_BEGIN_TAG
-# This is an automatically generated prolog.
-#
-# $Source: fpart/Rules.mk $
-#
-# 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
-CFLAGS += -D_GNU_SOURCE -std=gnu99 -D_FILE_OFFSET_BITS=64
-CFLAGS += -I$(DEPTH)/.. -iquote..
-
-LDFLAGS += -L.
-
-NAME=fpart
-
-CLIB=$(DEPTH)/../clib/x86/libclib.a
-FFS=$(DEPTH)/../ffs/x86/libffs.a
-
-OBJS=cmd_create.o cmd_add.o cmd_delete.o cmd_list.o \
- cmd_erase.o cmd_trunc.o cmd_user.o command.o main.o
-
-TARGETS=$(NAME)
-
-vpath %.c ../src
-vpath %.h ..
-
-all: $(TARGETS)
-
-$(NAME): $(OBJS) $(FFS) $(DBGX) $(SPINOR) $(CLIB)
- $(CC) $(LDFLAGS) -Wl,-whole-archive $(DBGX) -Wl,-no-whole-archive \
- -o $@ $^ -lpthread -ldl -lrt
-
-install: $(TARGETS)
- $(INSTALL) fpart $(FPART_INSTALL)/bin
- $(INSTALL) ../fpart.sh $(FPART_INSTALL_TEST)
-
-clean distclean:
- $(RM) -f $(TARGETS) $(OBJS)
diff --git a/fpart/Rules.test.mk b/fpart/Rules.test.mk
deleted file mode 100644
index 2b93477..0000000
--- a/fpart/Rules.test.mk
+++ /dev/null
@@ -1,49 +0,0 @@
-# IBM_PROLOG_BEGIN_TAG
-# This is an automatically generated prolog.
-#
-# $Source: fpart/Rules.test.mk $
-#
-# 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
-CFLAGS += -D_GNU_SOURCE -std=gnu99 -D_FILE_OFFSET_BITS=64 -I$(DEPTH)/apps -iquote..
-LDFLAGS += -L. -L$(DEPTH)/apps/clib/$(ARCH_DEP_DIR)
-
-OBJS=test_libffs.o
-
-TARGETS=test_libffs
-
-vpath %.c ../test
-vpath %.h ..
-
-all: $(TARGETS)
-
-#libffs.a: $(OBJS)
-# $(AR) -r $@ $^
-
-test_libffs: test_libffs.o ../ppc/libffs.a $(DEPTH)/apps/clib/$(ARCH_DEP_DIR)/libclib.a
- $(CC) $(LDFLAGS) -o $@ $^ -lpthread
-
-install: $(TARGETS)
- $(INSTALL) ../test/test_libffs $(TEST_LIBFFS_INSTALL)
- $(INSTALL) ../test/libffs_test.sh $(TEST_LIBFFS_INSTALL)
- $(INSTALL) ../test/ffs_tool_test.sh $(TEST_LIBFFS_INSTALL)
-
-clean distclean:
- $(RM) -f $(TARGETS) $(OBJS)
diff --git a/fpart/fpart.sh b/fpart/fpart.sh
index b59876e..7f915e8 100755
--- a/fpart/fpart.sh
+++ b/fpart/fpart.sh
@@ -38,7 +38,7 @@ MKDIR=mkdir
GREP=grep
HEAD=head
HEX=hexdump
-CRC=crc32
+CRC=sha1sum
DD=dd
DIFF=diff
@@ -92,7 +92,7 @@ function size()
function crc()
{
- local crc=$(${CRC} ${2})
+ local crc=$(${CRC} ${2}|cut -f 1 -d ' ')
if [[ ${1} == ${crc} ]]; then
echo "[PASSED] crc: '${2}' ===> expect=${1}, actual=${crc}"
else
diff --git a/fpart/ppc/Makefile b/fpart/ppc/Makefile
deleted file mode 100644
index 4dccb3d..0000000
--- a/fpart/ppc/Makefile
+++ /dev/null
@@ -1,33 +0,0 @@
-# IBM_PROLOG_BEGIN_TAG
-# This is an automatically generated prolog.
-#
-# $Source: fpart/ppc/Makefile $
-#
-# 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
-DEPTH = ../../..
-include $(DEPTH)/integration/Rules.mk
-include $(DEPTH)/integration/Rules.ppc.mk
-
-ARCH=ppc
-FPART_INSTALL = $(INST_USR)
-FPART_INSTALL_TEST = $(INST_TESTS)
-
-include ../Rules.mk
diff --git a/fpart/src/cmd_add.c b/fpart/src/cmd_add.c
index 2d8d578..7c23ce9 100644
--- a/fpart/src/cmd_add.c
+++ b/fpart/src/cmd_add.c
@@ -45,9 +45,7 @@
#include <ctype.h>
#include <regex.h>
-#include <clib/exception.h>
#include <clib/attribute.h>
-#include <clib/assert.h>
#include <clib/list.h>
#include <clib/list_iter.h>
#include <clib/misc.h>
diff --git a/fpart/src/cmd_create.c b/fpart/src/cmd_create.c
index 6bebc99..9c4cf6a 100644
--- a/fpart/src/cmd_create.c
+++ b/fpart/src/cmd_create.c
@@ -46,7 +46,6 @@
#include <regex.h>
#include <clib/attribute.h>
-#include <clib/assert.h>
#include <clib/list.h>
#include <clib/list_iter.h>
#include <clib/misc.h>
diff --git a/fpart/src/cmd_delete.c b/fpart/src/cmd_delete.c
index 16e13e5..46ad6b7 100644
--- a/fpart/src/cmd_delete.c
+++ b/fpart/src/cmd_delete.c
@@ -46,7 +46,6 @@
#include <regex.h>
#include <clib/attribute.h>
-#include <clib/assert.h>
#include <clib/list.h>
#include <clib/list_iter.h>
#include <clib/misc.h>
diff --git a/fpart/src/cmd_erase.c b/fpart/src/cmd_erase.c
index 931283c..c05bde5 100644
--- a/fpart/src/cmd_erase.c
+++ b/fpart/src/cmd_erase.c
@@ -46,7 +46,6 @@
#include <regex.h>
#include <clib/attribute.h>
-#include <clib/assert.h>
#include <clib/list.h>
#include <clib/list_iter.h>
#include <clib/misc.h>
diff --git a/fpart/src/cmd_list.c b/fpart/src/cmd_list.c
index 19eee56..92d049b 100644
--- a/fpart/src/cmd_list.c
+++ b/fpart/src/cmd_list.c
@@ -46,7 +46,6 @@
#include <regex.h>
#include <clib/attribute.h>
-#include <clib/assert.h>
#include <clib/list.h>
#include <clib/list_iter.h>
#include <clib/misc.h>
diff --git a/fpart/src/cmd_trunc.c b/fpart/src/cmd_trunc.c
index ac5c5ee..3c755f5 100644
--- a/fpart/src/cmd_trunc.c
+++ b/fpart/src/cmd_trunc.c
@@ -45,7 +45,6 @@
#include <ctype.h>
#include <regex.h>
-#include <clib/assert.h>
#include <clib/list.h>
#include <clib/list_iter.h>
#include <clib/misc.h>
diff --git a/fpart/src/cmd_user.c b/fpart/src/cmd_user.c
index af61cf0..1819f4d 100644
--- a/fpart/src/cmd_user.c
+++ b/fpart/src/cmd_user.c
@@ -46,7 +46,6 @@
#include <regex.h>
#include <clib/attribute.h>
-#include <clib/assert.h>
#include <clib/list.h>
#include <clib/list_iter.h>
#include <clib/misc.h>
diff --git a/fpart/src/command.c b/fpart/src/command.c
index 3f25abb..6b4e56e 100644
--- a/fpart/src/command.c
+++ b/fpart/src/command.c
@@ -46,7 +46,6 @@
#include <regex.h>
#include <clib/attribute.h>
-#include <clib/assert.h>
#include <clib/list.h>
#include <clib/list_iter.h>
#include <clib/misc.h>
diff --git a/fpart/src/main.c b/fpart/src/main.c
index 4ceeee2..044ea93 100644
--- a/fpart/src/main.c
+++ b/fpart/src/main.c
@@ -46,7 +46,6 @@
#include <regex.h>
#include <clib/attribute.h>
-#include <clib/assert.h>
#include <clib/list.h>
#include <clib/list_iter.h>
#include <clib/misc.h>
diff --git a/fpart/x86/Makefile b/fpart/x86/Makefile
deleted file mode 100644
index 104532b..0000000
--- a/fpart/x86/Makefile
+++ /dev/null
@@ -1,31 +0,0 @@
-# IBM_PROLOG_BEGIN_TAG
-# This is an automatically generated prolog.
-#
-# $Source: fpart/x86/Makefile $
-#
-# 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
-DEPTH = ..
-
-ARCH=x86
-FPART_INSTALL = $(INST_USR_X86)
-FPART_INSTALL_TEST = $(INST_TESTS_X86)
-
-include ../Rules.mk
OpenPOWER on IntegriCloud