Skip to content

Commit cb398d2

Browse files
committed
inline.h Move some #defines out of inside a function
This is just for clarity, as these are used by other functions later on.
1 parent 907f1f9 commit cb398d2

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

inline.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,6 +1275,23 @@ Perl_valid_utf8_to_uvchr(const U8 *s, STRLEN *retlen)
12751275

12761276
}
12771277

1278+
/* This looks like 0x010101... */
1279+
# define PERL_COUNT_MULTIPLIER (~ (UINTMAX_C(0)) / 0xFF)
1280+
1281+
/* This looks like 0x808080... */
1282+
# define PERL_VARIANTS_WORD_MASK (PERL_COUNT_MULTIPLIER * 0x80)
1283+
# define PERL_WORDSIZE sizeof(PERL_UINTMAX_T)
1284+
# define PERL_WORD_BOUNDARY_MASK (PERL_WORDSIZE - 1)
1285+
1286+
/* Evaluates to 0 if 'x' is at a word boundary; otherwise evaluates to 1, by
1287+
* or'ing together the lowest bits of 'x'. Hopefully the final term gets
1288+
* optimized out completely on a 32-bit system, and its mask gets optimized out
1289+
* on a 64-bit system */
1290+
# define PERL_IS_SUBWORD_ADDR(x) (1 & ( PTR2nat(x) \
1291+
| ( PTR2nat(x) >> 1) \
1292+
| ( ( (PTR2nat(x) \
1293+
& PERL_WORD_BOUNDARY_MASK) >> 2))))
1294+
12781295
/*
12791296
=for apidoc is_utf8_invariant_string
12801297
=for apidoc_item is_utf8_invariant_string_loc
@@ -1333,23 +1350,6 @@ Perl_is_utf8_invariant_string_loc(const U8* const s, STRLEN len, const U8 ** ep)
13331350

13341351
send = s + len;
13351352

1336-
/* This looks like 0x010101... */
1337-
# define PERL_COUNT_MULTIPLIER (~ (UINTMAX_C(0)) / 0xFF)
1338-
1339-
/* This looks like 0x808080... */
1340-
# define PERL_VARIANTS_WORD_MASK (PERL_COUNT_MULTIPLIER * 0x80)
1341-
# define PERL_WORDSIZE sizeof(PERL_UINTMAX_T)
1342-
# define PERL_WORD_BOUNDARY_MASK (PERL_WORDSIZE - 1)
1343-
1344-
/* Evaluates to 0 if 'x' is at a word boundary; otherwise evaluates to 1, by
1345-
* or'ing together the lowest bits of 'x'. Hopefully the final term gets
1346-
* optimized out completely on a 32-bit system, and its mask gets optimized out
1347-
* on a 64-bit system */
1348-
# define PERL_IS_SUBWORD_ADDR(x) (1 & ( PTR2nat(x) \
1349-
| ( PTR2nat(x) >> 1) \
1350-
| ( ( (PTR2nat(x) \
1351-
& PERL_WORD_BOUNDARY_MASK) >> 2))))
1352-
13531353
#ifndef EBCDIC
13541354

13551355
/* Do the word-at-a-time iff there is at least one usable full word. That

0 commit comments

Comments
 (0)