From e479f3b944614f28c42ec597ec473652f3ac9912 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 10 Sep 2017 21:38:43 +0300 Subject: kvec: Add kv_drop() which is to be used like `(void)kv_pop(kvec)` --- src/nvim/lib/kvec.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/nvim/lib') diff --git a/src/nvim/lib/kvec.h b/src/nvim/lib/kvec.h index 584282d773..4e5fb0d794 100644 --- a/src/nvim/lib/kvec.h +++ b/src/nvim/lib/kvec.h @@ -64,6 +64,14 @@ #define kv_max(v) ((v).capacity) #define kv_last(v) kv_A(v, kv_size(v) - 1) +/// Drop last n items from kvec without resizing +/// +/// Previously spelled as `(void)kv_pop(v)`, repeated n times. +/// +/// @param[out] v Kvec to drop items from. +/// @param[in] n Number of elements to drop. +#define kv_drop(v, n) ((v).size -= (n)) + #define kv_resize(v, s) \ ((v).capacity = (s), \ (v).items = xrealloc((v).items, sizeof((v).items[0]) * (v).capacity)) -- cgit From ad58e50b45ddb73f0582590b9e96da49f34174d0 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 8 Oct 2017 22:09:12 +0300 Subject: kvec: Add kv_Z which is like kv_A, but zero is the last value --- src/nvim/lib/kvec.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/nvim/lib') diff --git a/src/nvim/lib/kvec.h b/src/nvim/lib/kvec.h index 4e5fb0d794..ee1b890cb9 100644 --- a/src/nvim/lib/kvec.h +++ b/src/nvim/lib/kvec.h @@ -62,7 +62,8 @@ #define kv_pop(v) ((v).items[--(v).size]) #define kv_size(v) ((v).size) #define kv_max(v) ((v).capacity) -#define kv_last(v) kv_A(v, kv_size(v) - 1) +#define kv_Z(v, i) kv_A(v, kv_size(v) - (i) - 1) +#define kv_last(v) kv_Z(v, 0) /// Drop last n items from kvec without resizing /// -- cgit From 7c97f783935ec122fbf0d7d070c00804738abd6a Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 11 Sep 2017 01:27:46 +0300 Subject: klee: Start preparing for klee tests First stage: something compiling without klee, but with a buch of dirty hacks - done. Second stage: something running under klee, able to emit useful results, but still using dirty hacks - done. Third stage: make CMake care about clang argumnets - not done, may be omitted if proves to be too hard. Not that klee can be run on CI in any case. --- src/nvim/lib/ringbuf.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/nvim/lib') diff --git a/src/nvim/lib/ringbuf.h b/src/nvim/lib/ringbuf.h index 12b75ec65a..e63eae70b0 100644 --- a/src/nvim/lib/ringbuf.h +++ b/src/nvim/lib/ringbuf.h @@ -15,6 +15,7 @@ #ifndef NVIM_LIB_RINGBUF_H #define NVIM_LIB_RINGBUF_H +#include #include #include #include @@ -73,6 +74,32 @@ typedef struct { \ RBType *buf_end; \ } TypeName##RingBuffer; +/// Dummy item free macros, for use in RINGBUF_INIT +/// +/// This macros actually does nothing. +/// +/// @param[in] item Item to be freed. +#define RINGBUF_DUMMY_FREE(item) + +/// Static ring buffer +/// +/// @warning Ring buffers created with this macros must neither be freed nor +/// deallocated. +/// +/// @param scope Ring buffer scope. +/// @param TypeName Ring buffer type name. +/// @param RBType Type of the single ring buffer element. +/// @param varname Variable name. +/// @param rbsize Ring buffer size. +#define RINGBUF_STATIC(scope, TypeName, RBType, varname, rbsize) \ +static RBType _##varname##_buf[rbsize]; \ +scope TypeName##RingBuffer varname = { \ + .buf = _##varname##_buf, \ + .next = _##varname##_buf, \ + .first = NULL, \ + .buf_end = _##varname##_buf + rbsize - 1, \ +}; + /// Initialize a new ring buffer /// /// @param TypeName Ring buffer type name. Actual type name will be -- cgit From 4b81f627c6c031f286fec404bf42235847713181 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 27 Jan 2018 18:23:03 +0100 Subject: build/gcc: disable -Warray-bounds entirely #7923 We need to disable -Warray-bounds locally for kbtree.h, but we can't because _Pragma("GCC diagnostic pop") is broken in GCC 5.x+. So this commit disables -Warray-bounds entirely (for GCC only). GCC bug: "_Pragma diagnostic 'ignored' in macro with strict-overflow not suppressing warning fully with -Werror" https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66099 ref https://github.com/neovim/neovim/pull/7083#issuecomment-326323599 closes #7921 --- src/nvim/lib/kbtree.h | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) (limited to 'src/nvim/lib') diff --git a/src/nvim/lib/kbtree.h b/src/nvim/lib/kbtree.h index a3943054e6..e2688064a8 100644 --- a/src/nvim/lib/kbtree.h +++ b/src/nvim/lib/kbtree.h @@ -390,34 +390,14 @@ #define KBTREE_INIT(name, key_t, __cmp, T) \ KBTREE_INIT_IMPL(name, key_t, kbnode_##name##_t, __cmp, T, (sizeof(kbnode_##name##_t)+(2*T)*sizeof(void *))) -#if (!defined(__clang__) && !defined(__INTEL_COMPILER)) && (__GNUC__ > 4 ) - -// The index trickery shouldn't be UB anymore, -// still it is to much for gcc:s -Werror=array-bounds -# define __KB_PRAGMA_START \ - _Pragma("GCC diagnostic push") \ - _Pragma("GCC diagnostic ignored \"-Warray-bounds\"") - -# define __KB_PRAGMA_END \ - _Pragma("GCC diagnostic pop") \ - -#else - -# define __KB_PRAGMA_START -# define __KB_PRAGMA_END - -#endif - #define KBTREE_INIT_IMPL(name, key_t, kbnode_t, __cmp, T, ILEN) \ - __KB_PRAGMA_START \ __KB_TREE_T(name, key_t, T) \ __KB_GET_AUX1(name, key_t, kbnode_t, __cmp) \ __KB_GET(name, key_t, kbnode_t) \ __KB_INTERVAL(name, key_t, kbnode_t) \ __KB_PUT(name, key_t, kbnode_t, __cmp, T, ILEN) \ __KB_DEL(name, key_t, kbnode_t, T) \ - __KB_ITR(name, key_t, kbnode_t) \ - __KB_PRAGMA_END + __KB_ITR(name, key_t, kbnode_t) #define KB_DEFAULT_SIZE 512 -- cgit From 2c414fbbb1a869a4d9d3dd1076d198945ee74a7e Mon Sep 17 00:00:00 2001 From: b-r-o-c-k Date: Wed, 28 Feb 2018 19:14:27 -0600 Subject: build/msvc: Fix missing restrict keyword MSVC has the __restrict keyword and a marco is defined for it in `win_defs.h`. --- src/nvim/lib/kvec.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/lib') diff --git a/src/nvim/lib/kvec.h b/src/nvim/lib/kvec.h index ee1b890cb9..ad56c9237b 100644 --- a/src/nvim/lib/kvec.h +++ b/src/nvim/lib/kvec.h @@ -41,6 +41,7 @@ #include #include "nvim/memory.h" +#include "nvim/os/os_defs.h" #define kv_roundup32(x) \ ((--(x)), \ -- cgit