Mercurial > projects > ldc
diff druntime/src/compiler/dmd/arraycat.d @ 1458:e0b2d67cfe7c
Added druntime (this should be removed once it works).
author | Robert Clipsham <robert@octarineparrot.com> |
---|---|
date | Tue, 02 Jun 2009 17:43:06 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/druntime/src/compiler/dmd/arraycat.d Tue Jun 02 17:43:06 2009 +0100 @@ -0,0 +1,42 @@ +/** + * Implementation of array copy support routines. + * + * Copyright: Copyright Digital Mars 2004 - 2009. + * License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>. + * Authors: Walter Bright, Sean Kelly + * + * Copyright Digital Mars 2004 - 2009. + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + */ +module rt.arraycat; + +private +{ + import core.stdc.string; + debug import core.stdc.stdio; +} + +extern (C): + +byte[] _d_arraycopy(size_t size, byte[] from, byte[] to) +{ + debug printf("f = %p,%d, t = %p,%d, size = %d\n", + from.ptr, from.length, to.ptr, to.length, size); + + if (to.length != from.length) + { + throw new Exception("lengths don't match for array copy"); + } + else if (to.ptr + to.length * size <= from.ptr || + from.ptr + from.length * size <= to.ptr) + { + memcpy(to.ptr, from.ptr, to.length * size); + } + else + { + throw new Exception("overlapping array copy"); + } + return to; +}