[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] trunk r114447: Some minor cleanups of recently-added bool
From: |
Paul Eggert |
Subject: |
[Emacs-diffs] trunk r114447: Some minor cleanups of recently-added bool vector code. |
Date: |
Tue, 24 Sep 2013 04:28:45 +0000 |
User-agent: |
Bazaar (2.6b2) |
------------------------------------------------------------
revno: 114447
revision-id: address@hidden
parent: address@hidden
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Mon 2013-09-23 21:28:06 -0700
message:
Some minor cleanups of recently-added bool vector code.
* conf_post.h (assume): Always return void. Use lint version
only if GCC and MSC versions don't apply.
* conf_post.h (assume):
* data.c (USC_MSC_POPCOUNT, count_trailing_zero_bits):
Depend on _MSC_VER, not __MSC_VER, for consistency with
the rest of Emacs.
* data.c (bool_vector_spare_mask, popcount_size_t_generic)
(popcount_size_t_msc, popcount_size_t_gcc, popcount_size_t)
(bool_vector_binop_driver, count_trailing_zero_bits)
(size_t_to_host_endian): Now static, not static inline;
the latter isn't needed with modern compilers and doesn't
work with older compilers anyway.
modified:
src/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-1438
src/alloc.c alloc.c-20091113204419-o5vbwnq5f7feedwu-252
src/conf_post.h conf_post.h-20120730211826-q0qbxxwh2emw52hd-1
src/data.c data.c-20091113204419-o5vbwnq5f7feedwu-251
src/lisp.h lisp.h-20091113204419-o5vbwnq5f7feedwu-253
src/xdisp.c xdisp.c-20091113204419-o5vbwnq5f7feedwu-240
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog 2013-09-24 03:44:58 +0000
+++ b/src/ChangeLog 2013-09-24 04:28:06 +0000
@@ -1,5 +1,19 @@
2013-09-24 Paul Eggert <address@hidden>
+ Some minor cleanups of recently-added bool vector code.
+ * conf_post.h (assume): Always return void. Use lint version
+ only if GCC and MSC versions don't apply.
+ * conf_post.h (assume):
+ * data.c (USC_MSC_POPCOUNT, count_trailing_zero_bits):
+ Depend on _MSC_VER, not __MSC_VER, for consistency with
+ the rest of Emacs.
+ * data.c (bool_vector_spare_mask, popcount_size_t_generic)
+ (popcount_size_t_msc, popcount_size_t_gcc, popcount_size_t)
+ (bool_vector_binop_driver, count_trailing_zero_bits)
+ (size_t_to_host_endian): Now static, not static inline;
+ the latter isn't needed with modern compilers and doesn't
+ work with older compilers anyway.
+
* alloc.c (valgrind_p): Use bool for boolean.
2013-09-23 Dmitry Antipov <address@hidden>
=== modified file 'src/alloc.c'
--- a/src/alloc.c 2013-09-24 03:44:58 +0000
+++ b/src/alloc.c 2013-09-24 04:28:06 +0000
@@ -981,7 +981,7 @@
#define ABLOCKS_BASE(abase) (abase)
#else
#define ABLOCKS_BASE(abase) \
- (1 & (intptr_t) ABLOCKS_BUSY (abase) ? abase : ((void**)abase)[-1])
+ (1 & (intptr_t) ABLOCKS_BUSY (abase) ? abase : ((void **)abase)[-1])
#endif
/* The list of free ablock. */
@@ -1036,7 +1036,7 @@
aligned = (base == abase);
if (!aligned)
- ((void**)abase)[-1] = base;
+ ((void **) abase)[-1] = base;
#ifdef DOUG_LEA_MALLOC
/* Back to a reasonable maximum of mmap'ed areas. */
@@ -2016,10 +2016,9 @@
verify (sizeof (size_t) * CHAR_BIT == BITS_PER_SIZE_T);
verify ((BITS_PER_SIZE_T & (BITS_PER_SIZE_T - 1)) == 0);
-static
-ptrdiff_t
+static ptrdiff_t
bool_vector_payload_bytes (ptrdiff_t nr_bits,
- ptrdiff_t* exact_needed_bytes_out)
+ ptrdiff_t *exact_needed_bytes_out)
{
ptrdiff_t exact_needed_bytes;
ptrdiff_t needed_bytes;
@@ -2068,7 +2067,7 @@
+ total_payload_bytes),
word_size) / word_size;
- p = (struct Lisp_Bool_Vector* ) allocate_vector (needed_elements);
+ p = (struct Lisp_Bool_Vector *) allocate_vector (needed_elements);
XSETVECTOR (val, p);
XSETPVECTYPESIZE (XVECTOR (val), PVEC_BOOL_VECTOR, 0, 0);
@@ -2617,9 +2616,9 @@
verify (VECTOR_BLOCK_SIZE <= (1 << PSEUDOVECTOR_SIZE_BITS));
/* Round up X to nearest mult-of-ROUNDUP_SIZE --- use at compile time. */
-#define vroundup_ct(x) ROUNDUP((size_t)(x), roundup_size)
+#define vroundup_ct(x) ROUNDUP ((size_t) (x), roundup_size)
/* Round up X to nearest mult-of-ROUNDUP_SIZE --- use at runtime. */
-#define vroundup(x) (assume((x) >= 0), vroundup_ct(x))
+#define vroundup(x) (assume ((x) >= 0), vroundup_ct (x))
/* Rounding helps to maintain alignment constraints if USE_LSB_TAG. */
=== modified file 'src/conf_post.h'
--- a/src/conf_post.h 2013-09-23 08:25:48 +0000
+++ b/src/conf_post.h 2013-09-24 04:28:06 +0000
@@ -252,18 +252,17 @@
# define __has_builtin(x) 0
#endif
-/* assume(cond) tells the compiler (and lint) that a certain condition
- * will always hold, and that it should optimize (or check) accordingly. */
-#if defined lint
+/* Tell the compiler (and lint) that COND will always hold, and that
+ it should optimize (or check) accordingly. */
+#if (__has_builtin (__builtin_unreachable) \
+ || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) || __GNUC__ > 4)
+# define assume(cond) ((cond) ? (void) 0 : __builtin_unreachable ())
+#elif defined _MSC_VER
+# define assume(cond) __assume (cond)
+#elif defined lint
# define assume(cond) ((cond) ? (void) 0 : abort ())
-#elif (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) || __GNUC__ > 4
-# define assume(cond) ((cond) || (__builtin_unreachable(), 0))
-#elif defined (__clang__) && __has_builtin (__builtin_unreachable)
-# define assume(cond) ((cond) || (__builtin_unreachable(), 0))
-#elif defined __MSC_VER
-# define assume(cond) __assume ((cond))
#else
-# define assume(cond) (0 && (cond))
+# define assume(cond) ((void) (0 && (cond)))
#endif
/* Use this to suppress gcc's `...may be used before initialized' warnings. */
=== modified file 'src/data.c'
--- a/src/data.c 2013-09-22 09:31:55 +0000
+++ b/src/data.c 2013-09-24 04:28:06 +0000
@@ -617,7 +617,7 @@
struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (sym);
if (blv->fwd)
/* In set_internal, we un-forward vars when their value is
- set to Qunbound. */
+ set to Qunbound. */
return Qt;
else
{
@@ -628,7 +628,7 @@
}
case SYMBOL_FORWARDED:
/* In set_internal, we un-forward vars when their value is
- set to Qunbound. */
+ set to Qunbound. */
return Qt;
default: emacs_abort ();
}
@@ -1996,7 +1996,7 @@
}
/* This code is disabled now that we use the selected frame to return
- keyboard-local-values. */
+ keyboard-local-values. */
#if 0
extern struct terminal *get_terminal (Lisp_Object display, int);
@@ -2963,15 +2963,14 @@
always allocate bool vectors with at least one size_t of storage so
that we don't have to special-case empty bit vectors. */
-static inline
-size_t
+static size_t
bool_vector_spare_mask (ptrdiff_t nr_bits)
{
eassert_and_assume (nr_bits > 0);
return (((size_t) 1) << (nr_bits % BITS_PER_SIZE_T)) - 1;
}
-#if __MSC_VER >= 1500 && (defined _M_IX86 || defined _M_X64)
+#if _MSC_VER >= 1500 && (defined _M_IX86 || defined _M_X64)
# define USE_MSC_POPCOUNT
#elif __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
# define USE_GCC_POPCOUNT
@@ -2984,8 +2983,7 @@
#endif
#ifdef NEED_GENERIC_POPCOUNT
-static inline
-unsigned int
+static unsigned int
popcount_size_t_generic (size_t val)
{
unsigned short j;
@@ -2999,8 +2997,7 @@
#endif
#ifdef USE_MSC_POPCOUNT
-static inline
-unsigned int
+static unsigned int
popcount_size_t_msc (size_t val)
{
unsigned int count;
@@ -3045,8 +3042,7 @@
#endif /* USE_MSC_POPCOUNT */
#ifdef USE_GCC_POPCOUNT
-static inline
-unsigned int
+static unsigned int
popcount_size_t_gcc (size_t val)
{
# if BITS_PER_SIZE_T == 64
@@ -3057,9 +3053,8 @@
}
#endif /* USE_GCC_POPCOUNT */
-static inline
-unsigned int
-popcount_size_t(size_t val)
+static unsigned int
+popcount_size_t (size_t val)
{
#if defined USE_MSC_POPCOUNT
return popcount_size_t_msc (val);
@@ -3067,7 +3062,7 @@
return popcount_size_t_gcc (val);
#else
return popcount_size_t_generic (val);
- #endif
+#endif
}
enum bool_vector_op { bool_vector_exclusive_or,
@@ -3076,8 +3071,7 @@
bool_vector_set_difference,
bool_vector_subsetp };
-static inline
-Lisp_Object
+static Lisp_Object
bool_vector_binop_driver (Lisp_Object op1,
Lisp_Object op2,
Lisp_Object dest,
@@ -3108,11 +3102,11 @@
}
eassert_and_assume (nr_bits >= 0);
- nr_words = ROUNDUP(nr_bits, BITS_PER_SIZE_T) / BITS_PER_SIZE_T;
-
- adata = (size_t*) XBOOL_VECTOR (dest)->data;
- bdata = (size_t*) XBOOL_VECTOR (op1)->data;
- cdata = (size_t*) XBOOL_VECTOR (op2)->data;
+ nr_words = ROUNDUP (nr_bits, BITS_PER_SIZE_T) / BITS_PER_SIZE_T;
+
+ adata = (size_t *) XBOOL_VECTOR (dest)->data;
+ bdata = (size_t *) XBOOL_VECTOR (op1)->data;
+ cdata = (size_t *) XBOOL_VECTOR (op2)->data;
i = 0;
do
{
@@ -3132,16 +3126,16 @@
if (op != bool_vector_subsetp)
adata[i] = mword;
- i += 1;
+ i++;
}
while (i < nr_words);
+
return changed ? dest : Qnil;
}
/* Compute the number of trailing zero bits in val. If val is zero,
return the number of bits in val. */
-static inline
-unsigned int
+static unsigned int
count_trailing_zero_bits (size_t val)
{
if (val == 0)
@@ -3151,7 +3145,7 @@
return __builtin_ctzll (val);
#elif defined USE_GCC_POPCOUNT && BITS_PER_SIZE_T == 32
return __builtin_ctz (val);
-#elif __MSC_VER && BITS_PER_SIZE_T == 64
+#elif _MSC_VER && BITS_PER_SIZE_T == 64
# pragma intrinsic _BitScanForward64
{
/* No support test needed: support since 386. */
@@ -3159,7 +3153,7 @@
_BitScanForward64 (&result, val);
return (unsigned int) result;
}
-#elif __MSC_VER && BITS_PER_SIZE_T == 32
+#elif _MSC_VER && BITS_PER_SIZE_T == 32
# pragma intrinsic _BitScanForward
{
/* No support test needed: support since 386. */
@@ -3171,7 +3165,7 @@
{
unsigned int count;
count = 0;
- for(val = ~val; val & 1; val >>= 1)
+ for (val = ~val; val & 1; val >>= 1)
++count;
return count;
@@ -3179,8 +3173,7 @@
#endif
}
-static inline
-size_t
+static size_t
size_t_to_host_endian (size_t val)
{
#ifdef WORDS_BIGENDIAN
@@ -3272,17 +3265,13 @@
nr_bits = min (nr_bits, XBOOL_VECTOR (b)->size);
}
- bdata = (size_t*) XBOOL_VECTOR (b)->data;
- adata = (size_t*) XBOOL_VECTOR (a)->data;
- i = 0;
+ bdata = (size_t *) XBOOL_VECTOR (b)->data;
+ adata = (size_t *) XBOOL_VECTOR (a)->data;
eassert_and_assume (nr_bits >= 0);
- while (i < nr_bits / BITS_PER_SIZE_T)
- {
- bdata[i] = ~adata[i];
- i += 1;
- }
+ for (i = 0; i < nr_bits / BITS_PER_SIZE_T; i++)
+ bdata[i] = ~adata[i];
if (nr_bits % BITS_PER_SIZE_T)
{
@@ -3298,7 +3287,7 @@
DEFUN ("bool-vector-count-matches", Fbool_vector_count_matches,
Sbool_vector_count_matches, 2, 2, 0,
doc: /* Count how many elements in A equal B.
-A must be a bool vector. B is a generalized bool. */)
+A must be a bool vector. B is a generalized bool. */)
(Lisp_Object a, Lisp_Object b)
{
ptrdiff_t count;
@@ -3312,11 +3301,11 @@
nr_bits = XBOOL_VECTOR (a)->size;
count = 0;
match = NILP (b) ? (size_t) -1 : 0;
- adata = (size_t*) XBOOL_VECTOR (a)->data;
+ adata = (size_t *) XBOOL_VECTOR (a)->data;
eassert_and_assume (nr_bits >= 0);
- for(i = 0; i < nr_bits / BITS_PER_SIZE_T; ++i)
+ for (i = 0; i < nr_bits / BITS_PER_SIZE_T; ++i)
count += popcount_size_t (adata[i] ^ match);
/* Mask out trailing parts of final mword. */
@@ -3335,7 +3324,7 @@
Sbool_vector_count_matches_at, 3, 3, 0,
doc: /* Count how many consecutive elements in A equal B at i.
A must be a bool vector. B is a generalized boolean. i is an
-index into the vector.*/)
+index into the vector. */)
(Lisp_Object a, Lisp_Object b, Lisp_Object i)
{
ptrdiff_t count;
@@ -3354,11 +3343,11 @@
if (XFASTINT (i) > nr_bits) /* Allow one past the end for convenience */
args_out_of_range (a, i);
- adata = (size_t*) XBOOL_VECTOR (a)->data;
+ adata = (size_t *) XBOOL_VECTOR (a)->data;
assume (nr_bits >= 0);
nr_words = ROUNDUP (nr_bits, BITS_PER_SIZE_T) / BITS_PER_SIZE_T;
-
+
pos = XFASTINT (i) / BITS_PER_SIZE_T;
offset = XFASTINT (i) % BITS_PER_SIZE_T;
count = 0;
@@ -3376,7 +3365,7 @@
mword >>= offset;
count = count_trailing_zero_bits (mword);
count = min (count, BITS_PER_SIZE_T - offset);
- pos += 1;
+ pos++;
if (count + offset < BITS_PER_SIZE_T)
return make_number (count);
}
=== modified file 'src/lisp.h'
--- a/src/lisp.h 2013-09-23 13:25:19 +0000
+++ b/src/lisp.h 2013-09-24 04:28:06 +0000
@@ -4359,15 +4359,13 @@
return 0;
}
-INLINE
-uint16_t
+INLINE uint16_t
swap16 (uint16_t val)
{
return (val << 8) | (val & 0xFF);
}
-INLINE
-uint32_t
+INLINE uint32_t
swap32 (uint32_t val)
{
uint32_t low = swap16 (val & 0xFFFF);
@@ -4376,8 +4374,7 @@
}
#ifdef UINT64_MAX
-INLINE
-uint64_t
+INLINE uint64_t
swap64 (uint64_t val)
{
uint64_t low = swap32 (val & 0xFFFFFFFF);
=== modified file 'src/xdisp.c'
--- a/src/xdisp.c 2013-09-23 13:25:19 +0000
+++ b/src/xdisp.c 2013-09-24 04:28:06 +0000
@@ -1882,8 +1882,7 @@
text, or we can't tell because W's current matrix is not up to
date. */
-static
-struct glyph *
+static struct glyph *
x_y_to_hpos_vpos (struct window *w, int x, int y, int *hpos, int *vpos,
int *dx, int *dy, int *area)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] trunk r114447: Some minor cleanups of recently-added bool vector code.,
Paul Eggert <=