Add spellcheck example

One of the benefits of implementing system call support from scratch is
that we're able to have embedded zip filesystem support which trickles
into libraries such as stdio, without unportable symbolic interposition.
It's also be great if we could say open("gs://bucket/object", O_RDONLY)
for seamless GCS, similar to Java NIO, but abstracted by the C library.
This commit is contained in:
Justine Tunney 2020-06-27 12:00:43 -07:00
parent 0ad0408ac6
commit b5b60015f5
6 changed files with 180 additions and 1 deletions

View file

@ -36,6 +36,7 @@ uint64_t bitreverse64(uint64_t) libcesque pureconst;
unsigned long roundup2pow(unsigned long) libcesque pureconst;
unsigned long roundup2log(unsigned long) libcesque pureconst;
unsigned long rounddown2pow(unsigned long) libcesque pureconst;
unsigned long hamming(unsigned long, unsigned long) pureconst;
/*───────────────────────────────────────────────────────────────────────────│─╗
cosmopolitan § bits » no assembly required

View file

@ -19,6 +19,9 @@
*/
#include "libc/bits/bits.h"
unsigned long(hamming)(unsigned long x, unsigned long y) {
/**
* Counts number of different bits.
*/
unsigned long hamming(unsigned long x, unsigned long y) {
return popcount(x ^ y);
}