From 138fb272fae79587de3469493b55e4d18eadc722 Mon Sep 17 00:00:00 2001 From: Nicholas Date: Sat, 20 Nov 2021 20:12:21 -0800 Subject: Feat: added buffered io from plan9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As we no longer have the FILE type, we need to buffer our reading and writing so that we don't have to make so many syscalls. The API is nice so that we can buffer other readers. We will update it so that it eats io·Readers/io·Writers. --- src/base/mem/findc.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/base/mem/findc.c (limited to 'src/base/mem/findc.c') diff --git a/src/base/mem/findc.c b/src/base/mem/findc.c new file mode 100644 index 0000000..d3215c5 --- /dev/null +++ b/src/base/mem/findc.c @@ -0,0 +1,14 @@ +#include "internal.h" + +void * +mem·findc(void *addr, uintptr len, int c) +{ + uchar *a = addr; + + c &= 0xFF; + while(len-- > 0){ + if(*a++ == c) + return a-1; + } + return nil; +} -- cgit v1.2.1