File:  [Research Unix] / researchv10no / libc / gen / memmove.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:21:35 2018 UTC (8 years, 1 month ago) by root
Branches: belllabs, MAIN
CVS tags: researchv10, HEAD
researchv10 Norman

/* Copyright AT&T Bell Laboratories, 1994 */
#include <stddef.h>
#include <string.h>

enum { S = sizeof(long) };

void *
memmove(void *to, const void *from, size_t n)
{
	char *out = to;
	const char *in = from;
	if(out > in) {
		in += n;
		out += n;
		if((in-out)%S == 0) {
			for( ; (in-(char*)0)%S && n>0; n--)
				*--out = *--in;
			for( ; n>=S; n-=S) {
				out -= S;
				in -= S;
				*(long*)out = *(long*)in;
			}
		}
		for( ; n>0; n--)
			*--out = *--in;
	} else {
		if((in-out)%S == 0) {
			for( ; (in-(char*)0)%S && n>0; n--)
				*out++ = *in++;
			for( ; n>=S; n-=S) {
				*(long*)out = *(long*)in;
				out += S;
				in += S;
			}
		}
		for( ; n>0; n--)
			*out++ = *in++;
	}
	return(to);
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.