diff options
Diffstat (limited to 'libc/string/generic')
-rw-r--r-- | libc/string/generic/memcopy.h | 41 | ||||
-rw-r--r-- | libc/string/generic/memcpy.c | 1 | ||||
-rw-r--r-- | libc/string/generic/pagecopy.h | 4 | ||||
-rw-r--r-- | libc/string/generic/strtok_r.c | 14 |
4 files changed, 28 insertions, 32 deletions
diff --git a/libc/string/generic/memcopy.h b/libc/string/generic/memcopy.h index fa3bc4e8d..df1ba9a97 100644 --- a/libc/string/generic/memcopy.h +++ b/libc/string/generic/memcopy.h @@ -107,6 +107,24 @@ typedef unsigned char byte; } \ } while (0) +/* Copy *up to* NBYTES bytes from SRC_BP to DST_BP, with + the assumption that DST_BP is aligned on an OPSIZ multiple. If + not all bytes could be easily copied, store remaining number of bytes + in NBYTES_LEFT, otherwise store 0. */ +/* extern void _wordcopy_fwd_aligned __P ((long int, long int, size_t)); */ +/* extern void _wordcopy_fwd_dest_aligned __P ((long int, long int, size_t)); */ +#define WORD_COPY_FWD(dst_bp, src_bp, nbytes_left, nbytes) \ + do \ + { \ + if (src_bp % OPSIZ == 0) \ + _wordcopy_fwd_aligned (dst_bp, src_bp, (nbytes) / OPSIZ); \ + else \ + _wordcopy_fwd_dest_aligned (dst_bp, src_bp, (nbytes) / OPSIZ); \ + src_bp += (nbytes) & -OPSIZ; \ + dst_bp += (nbytes) & -OPSIZ; \ + (nbytes_left) = (nbytes) % OPSIZ; \ + } while (0) + /* Copy *up to* NBYTES_TO_COPY bytes from SRC_END_PTR to DST_END_PTR, beginning at the words (of type op_t) right before the pointers and continuing towards smaller addresses. May take advantage of that @@ -130,26 +148,3 @@ typedef unsigned char byte; /* Threshold value for when to enter the unrolled loops. */ #define OP_T_THRES 16 - -#ifdef __ARCH_HAS_BWD_MEMCPY__ - -/* Copy *up to* NBYTES bytes from SRC_BP to DST_BP, with - the assumption that DST_BP is aligned on an OPSIZ multiple. If - not all bytes could be easily copied, store remaining number of bytes - in NBYTES_LEFT, otherwise store 0. */ -/* extern void _wordcopy_fwd_aligned __P ((long int, long int, size_t)); */ -/* extern void _wordcopy_fwd_dest_aligned __P ((long int, long int, size_t)); */ -#define WORD_COPY_FWD(dst_bp, src_bp, nbytes_left, nbytes) \ - do \ - { \ - if (src_bp % OPSIZ == 0) \ - _wordcopy_fwd_aligned (dst_bp, src_bp, (nbytes) / OPSIZ); \ - else \ - _wordcopy_fwd_dest_aligned (dst_bp, src_bp, (nbytes) / OPSIZ); \ - src_bp += (nbytes) & -OPSIZ; \ - dst_bp += (nbytes) & -OPSIZ; \ - (nbytes_left) = (nbytes) % OPSIZ; \ - } while (0) - -#endif /* __ARCH_HAS_BWD_MEMCPY__ */ - diff --git a/libc/string/generic/memcpy.c b/libc/string/generic/memcpy.c index 4284f2fe5..a19e0c335 100644 --- a/libc/string/generic/memcpy.c +++ b/libc/string/generic/memcpy.c @@ -22,6 +22,7 @@ #include <string.h> #include "memcopy.h" #include "pagecopy.h" +#include "_memcpy_fwd.c" /* Experimentally off - libc_hidden_proto(memcpy) */ diff --git a/libc/string/generic/pagecopy.h b/libc/string/generic/pagecopy.h index 5a0ada1fa..b00db493b 100644 --- a/libc/string/generic/pagecopy.h +++ b/libc/string/generic/pagecopy.h @@ -40,7 +40,7 @@ */ -#if PAGE_COPY_THRESHOLD +#if defined PAGE_COPY_THRESHOLD && PAGE_COPY_THRESHOLD #include <assert.h> @@ -48,7 +48,7 @@ do \ { \ if ((nbytes) >= PAGE_COPY_THRESHOLD && \ - PAGE_OFFSET ((dstp) - (srcp)) == 0) \ + PAGE_OFFSET ((dstp) - (srcp)) == 0) \ { \ /* The amount to copy is past the threshold for copying \ pages virtually with kernel VM operations, and the \ diff --git a/libc/string/generic/strtok_r.c b/libc/string/generic/strtok_r.c index d082d226e..7648212f7 100644 --- a/libc/string/generic/strtok_r.c +++ b/libc/string/generic/strtok_r.c @@ -29,17 +29,17 @@ # define __rawmemchr strchr /* Experimentally off - libc_hidden_proto(strchr) */ #endif - -/* Parse S into tokens separated by characters in DELIM. +#if 0 + Parse S into tokens separated by characters in DELIM. If S is NULL, the saved pointer in SAVE_PTR is used as the next starting point. For example: char s[] = "-abc-=-def"; char *sp; - x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def" - x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL - x = strtok_r(NULL, "=", &sp); // x = NULL - // s = "abc\0-def\0" -*/ + x = strtok_r(s, "-", &sp); /* x = "abc", sp = "=-def" */ + x = strtok_r(NULL, "-=", &sp); /* x = "def", sp = NULL */ + x = strtok_r(NULL, "=", &sp); /* x = NULL */ + /* s = "abc\0-def\0" */ +#endif char *strtok_r (char *s, const char *delim, char **save_ptr) { char *token; |