1 /* Zero byte detection, boolean. HPPA version.
2 Copyright (C) 2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
20 #define _STRING_FZB_H 1
22 #include <sys/cdefs.h>
23 #include <string-optype.h>
25 _Static_assert (sizeof (op_t
) == 4, "64-bit not supported");
27 /* Determine if any byte within X is zero. This is a pure boolean test. */
28 static __always_inline _Bool
31 /* It's more useful to expose a control transfer to the compiler
32 than to expose a proper boolean result. */
33 asm goto ("uxor,sbz %%r0,%0,%%r0\n\t"
34 "b,n %l1" : : "r"(x
) : : nbz
);
40 /* Likewise, but for byte equality between X1 and X2. */
41 static __always_inline _Bool
42 has_eq (op_t x1
, op_t x2
)
44 asm goto ("uxor,sbz %0,%1,%%r0\n\t"
45 "b,n %l2" : : "r"(x1
), "r"(x2
) : : nbz
);
51 /* Likewise, but for zeros in X1 and equal bytes between X1 and X2. */
52 static __always_inline _Bool
53 has_zero_eq (op_t x1
, op_t x2
)
55 asm goto ("uxor,sbz %%r0,%0,%%r0\n\t"
56 "uxor,nbz %0,%1,%%r0\n\t"
57 "b,n %l2" : : "r"(x1
), "r"(x2
) : : sbz
);
63 #endif /* _STRING_FZB_H */