diff options
| author | Paul Eggert | 2013-11-04 23:11:24 -0800 |
|---|---|---|
| committer | Paul Eggert | 2013-11-04 23:11:24 -0800 |
| commit | df5b49306e8e82e2f18ed3243700c11ca7835750 (patch) | |
| tree | d98fffc7d11d4565b6132e83f54ca3f3c547b1d4 /src/lread.c | |
| parent | 693698093480628b7438ca0fd1614b00acfd1137 (diff) | |
| download | emacs-df5b49306e8e82e2f18ed3243700c11ca7835750.tar.gz emacs-df5b49306e8e82e2f18ed3243700c11ca7835750.zip | |
Simplify and port recent bool vector changes.
* configure.ac (BITSIZEOF_SIZE_T, SIZEOF_SIZE_T):
New symbols to configure.
* src/alloc.c (ROUNDUP): Move here from lisp.h, since it's now used
only in this file. Use a more-efficient implementation if the
second argument is a power of 2.
(ALIGN): Rewrite in terms of ROUNDUP. Make it a function.
Remove no-longer-necessary compile-time checks.
(bool_vector_exact_payload_bytes): New function.
(bool_vector_payload_bytes): Remove 2nd arg; callers that need
exact payload changed to call the new function. Do not assume
that the arg or result fits in ptrdiff_t.
(bool_vector_fill): New function.
(Fmake_bool_vector): Use it. Don't assume bit counts fit
in ptrdiff_t.
(vroundup_ct): Don't assume arg fits in size_t.
* src/category.c (SET_CATEGORY_SET): Remove. All callers now just
invoke set_category_set.
(set_category_set): 2nd arg is now EMACS_INT and 3rd is now bool.
All callers changed. Use bool_vector_set.
* src/category.h (XCATEGORY_SET): Remove; no longer needed.
(CATEGORY_MEMBER): Now a function. Rewrite in terms of
bool_vector_bitref.
* src/data.c (Faref): Use bool_vector_ref.
(Faset): Use bool_vector_set.
(bits_word_to_host_endian): Don't assume you can shift by CHAR_BIT.
(Fbool_vector_not, Fbool_vector_count_matches)
(Fbool_vector_count_matches_at): Don't assume CHAR_BIT == 8.
* src/fns.c (concat): Use bool_vector_ref.
(Ffillarray): Use bool_vector_fill.
(mapcar1): Use bool_vector_ref.
(sxhash_bool_vector): Hash words, not bytes.
* src/lisp.h (BOOL_VECTOR_BITS_PER_CHAR): Now a macro as well as
a constant, since it's now used in #if.
(bits_word, BITS_WORD_MAX, BITS_PER_BITS_WORD): Fall back on
unsigned char on unusual architectures, so that we no longer
assume that the number of bits per bits_word is a power of two or
is a multiple of 8 or of CHAR_BIT.
(Qt): Add forward decl.
(struct Lisp_Bool_Vector): Don't assume EMACS_INT is aligned
at least as strictly as bits_word.
(bool_vector_data, bool_vector_uchar_data): New accessors.
All data structure accesses changed to use them.
(bool_vector_words, bool_vector_bitref, bool_vector_ref)
(bool_vector_set): New functions.
(bool_vector_fill): New decl.
(ROUNDUP): Move to alloc.c as described above.
Diffstat (limited to 'src/lread.c')
| -rw-r--r-- | src/lread.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/lread.c b/src/lread.c index 618b0cadb53..7e4f5d38d09 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -2580,6 +2580,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list) | |||
| 2580 | EMACS_INT size_in_chars | 2580 | EMACS_INT size_in_chars |
| 2581 | = ((XFASTINT (length) + BOOL_VECTOR_BITS_PER_CHAR - 1) | 2581 | = ((XFASTINT (length) + BOOL_VECTOR_BITS_PER_CHAR - 1) |
| 2582 | / BOOL_VECTOR_BITS_PER_CHAR); | 2582 | / BOOL_VECTOR_BITS_PER_CHAR); |
| 2583 | unsigned char *data; | ||
| 2583 | 2584 | ||
| 2584 | UNREAD (c); | 2585 | UNREAD (c); |
| 2585 | tmp = read1 (readcharfun, pch, first_in_list); | 2586 | tmp = read1 (readcharfun, pch, first_in_list); |
| @@ -2594,10 +2595,11 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list) | |||
| 2594 | invalid_syntax ("#&..."); | 2595 | invalid_syntax ("#&..."); |
| 2595 | 2596 | ||
| 2596 | val = Fmake_bool_vector (length, Qnil); | 2597 | val = Fmake_bool_vector (length, Qnil); |
| 2597 | memcpy (XBOOL_VECTOR (val)->data, SDATA (tmp), size_in_chars); | 2598 | data = bool_vector_uchar_data (val); |
| 2599 | memcpy (data, SDATA (tmp), size_in_chars); | ||
| 2598 | /* Clear the extraneous bits in the last byte. */ | 2600 | /* Clear the extraneous bits in the last byte. */ |
| 2599 | if (XINT (length) != size_in_chars * BOOL_VECTOR_BITS_PER_CHAR) | 2601 | if (XINT (length) != size_in_chars * BOOL_VECTOR_BITS_PER_CHAR) |
| 2600 | XBOOL_VECTOR (val)->data[size_in_chars - 1] | 2602 | data[size_in_chars - 1] |
| 2601 | &= (1 << (XINT (length) % BOOL_VECTOR_BITS_PER_CHAR)) - 1; | 2603 | &= (1 << (XINT (length) % BOOL_VECTOR_BITS_PER_CHAR)) - 1; |
| 2602 | return val; | 2604 | return val; |
| 2603 | } | 2605 | } |