Mercurial > projects > ldc
comparison 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 |
comparison
equal
deleted
inserted
replaced
1456:7b218ec1044f | 1458:e0b2d67cfe7c |
---|---|
1 /** | |
2 * Implementation of array copy support routines. | |
3 * | |
4 * Copyright: Copyright Digital Mars 2004 - 2009. | |
5 * License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>. | |
6 * Authors: Walter Bright, Sean Kelly | |
7 * | |
8 * Copyright Digital Mars 2004 - 2009. | |
9 * Distributed under the Boost Software License, Version 1.0. | |
10 * (See accompanying file LICENSE_1_0.txt or copy at | |
11 * http://www.boost.org/LICENSE_1_0.txt) | |
12 */ | |
13 module rt.arraycat; | |
14 | |
15 private | |
16 { | |
17 import core.stdc.string; | |
18 debug import core.stdc.stdio; | |
19 } | |
20 | |
21 extern (C): | |
22 | |
23 byte[] _d_arraycopy(size_t size, byte[] from, byte[] to) | |
24 { | |
25 debug printf("f = %p,%d, t = %p,%d, size = %d\n", | |
26 from.ptr, from.length, to.ptr, to.length, size); | |
27 | |
28 if (to.length != from.length) | |
29 { | |
30 throw new Exception("lengths don't match for array copy"); | |
31 } | |
32 else if (to.ptr + to.length * size <= from.ptr || | |
33 from.ptr + from.length * size <= to.ptr) | |
34 { | |
35 memcpy(to.ptr, from.ptr, to.length * size); | |
36 } | |
37 else | |
38 { | |
39 throw new Exception("overlapping array copy"); | |
40 } | |
41 return to; | |
42 } |