3 memccpy, memchr, memcmp, memcpy, memmove, memset, tsmemcmp \- memory operations
11 void* memccpy(void *s1, void *s2, int c, usize n)
14 void* memchr(void *s, int c, usize n)
17 int memcmp(void *s1, void *s2, usize n)
20 void* memcpy(void *s1, void *s2, usize n)
23 void* memmove(void *s1, void *s2, usize n)
26 void* memset(void *s, int c, usize n)
28 .B #include <libsec.h>
31 int tsmemcmp(void *s1, void *s2, ulong n)
33 These functions operate efficiently on memory areas
34 (arrays of bytes bounded by a count, not terminated by a zero byte).
35 They do not check for the overflow of any receiving memory area.
38 copies bytes from memory area
42 stopping after the first occurrence of byte
44 has been copied, or after
46 bytes have been copied, whichever comes first.
47 It returns a pointer to the byte after
54 was not found in the first
60 returns a pointer to the first
72 compares its arguments, looking at the first
74 bytes only, and returns an integer
75 less than, equal to, or greater than 0,
78 is lexicographically less than, equal to, or
81 The comparison is bytewise unsigned.
86 bytes from memory area
96 except that it is guaranteed to work if
115 that is safe against timing attacks.
116 It does not stop when it sees a difference, this way it's runtime is function of
118 and not something that can lead clues to attackers.
120 All these routines have portable C implementations in
121 .BR /sys/src/libc/port .
122 Most also have machine-dependent assembly language implementations in
123 .BR /sys/src/libc/$objtype .
126 .BR /sys/src/libsec/port/tsmemcmp.c .
130 ANSI C does not require
132 to handle overlapping source and destination; on Plan 9, it does, so
142 are handed a negative count, they abort.
145 should not be used to compare sensitive data as it's vulnerable to timing attacks. Instead,