cosmopolitan/libc/str/wcwidth_osx.internal.h
Justine Tunney 414667b1c9
Get TEST_LIBC_STR passing on AARCH64
It's now possible to run commands like:

    make -j8 m=aarch64 o/aarch64/test/libc/str

Which will cross-compile and run the test suites in a qemu-aarch64
binary that's vendored in the third_party/qemu/ folder within your
x86_64 build environment.
2023-05-12 18:09:23 -07:00

22 lines
763 B
C

#ifndef COSMOPOLITAN_LIBC_STR_WCWIDTH_OSX_H_
#define COSMOPOLITAN_LIBC_STR_WCWIDTH_OSX_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
extern const uint32_t kWcwidthOsx[591];
extern const uint8_t kWcwidthOsxIndex1[136];
extern const uint16_t kWcwidthOsxIndex2[228];
extern const uint32_t kWcwidthOsxIndex3[917];
static inline int _wcwidth_osx(uint32_t codePoint) {
uint32_t a, b, c, d;
a = kWcwidthOsxIndex1[codePoint >> 13];
b = kWcwidthOsxIndex2[a + ((codePoint >> 9) & 0xf)];
c = kWcwidthOsxIndex3[b + ((codePoint >> 5) & 0xf)];
d = c + (codePoint & 0x1f);
return (kWcwidthOsx[d >> 4] >> ((d & 0xf) << 1)) & 3;
}
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_STR_WCWIDTH_OSX_H_ */