summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStewart Smith <stewart@linux.vnet.ibm.com>2015-12-15 15:59:21 +1100
committerStewart Smith <stewart@linux.vnet.ibm.com>2015-12-15 16:48:06 +1100
commit5690d7ee13ec02b28e62301bac32b5f5cfa6f761 (patch)
tree58da27b230201a699f84951af04ba6c3cc3b0e52
parentd38494a9cbcf12db3d923362b754299b64dc4aec (diff)
downloadffs-5690d7ee13ec02b28e62301bac32b5f5cfa6f761.zip
ffs-5690d7ee13ec02b28e62301bac32b5f5cfa6f761.tar.gz
remove unused array
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
-rw-r--r--clib/array.h446
-rw-r--r--clib/array_iter.h223
-rw-r--r--clib/src/array.c496
-rw-r--r--clib/src/array_iter.c187
-rw-r--r--clib/src/timer.c140
-rw-r--r--clib/test/array.c77
6 files changed, 0 insertions, 1569 deletions
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/src/array.c b/clib/src/array.c
deleted file mode 100644
index ed4a41a..0000000
--- a/clib/src/array.c
+++ /dev/null
@@ -1,496 +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"
-
-/*! @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/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/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;
-}
OpenPOWER on IntegriCloud