Mercurial > projects > ldc
comparison druntime/src/compiler/dmd/arraycat.d @ 759:d3eb054172f9
Added copy of druntime from DMD 2.020 modified for LDC.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Tue, 11 Nov 2008 01:52:37 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
758:f04dde6e882c | 759:d3eb054172f9 |
---|---|
1 /** | |
2 * Part of the D programming language runtime library. | |
3 */ | |
4 | |
5 /* | |
6 * Copyright (C) 2004-2007 by Digital Mars, www.digitalmars.com | |
7 * Written by Walter Bright | |
8 * | |
9 * This software is provided 'as-is', without any express or implied | |
10 * warranty. In no event will the authors be held liable for any damages | |
11 * arising from the use of this software. | |
12 * | |
13 * Permission is granted to anyone to use this software for any purpose, | |
14 * including commercial applications, and to alter it and redistribute it | |
15 * freely, in both source and binary form, subject to the following | |
16 * restrictions: | |
17 * | |
18 * o The origin of this software must not be misrepresented; you must not | |
19 * claim that you wrote the original software. If you use this software | |
20 * in a product, an acknowledgment in the product documentation would be | |
21 * appreciated but is not required. | |
22 * o Altered source versions must be plainly marked as such, and must not | |
23 * be misrepresented as being the original software. | |
24 * o This notice may not be removed or altered from any source | |
25 * distribution. | |
26 */ | |
27 | |
28 /* | |
29 * Modified by Sean Kelly for use with the D Runtime Project | |
30 */ | |
31 | |
32 module rt.arraycat; | |
33 | |
34 private | |
35 { | |
36 import stdc.string; | |
37 debug import stdc.stdio; | |
38 } | |
39 | |
40 extern (C): | |
41 | |
42 byte[] _d_arraycopy(size_t size, byte[] from, byte[] to) | |
43 { | |
44 debug printf("f = %p,%d, t = %p,%d, size = %d\n", | |
45 from.ptr, from.length, to.ptr, to.length, size); | |
46 | |
47 if (to.length != from.length) | |
48 { | |
49 throw new Exception("lengths don't match for array copy"); | |
50 } | |
51 else if (to.ptr + to.length * size <= from.ptr || | |
52 from.ptr + from.length * size <= to.ptr) | |
53 { | |
54 memcpy(to.ptr, from.ptr, to.length * size); | |
55 } | |
56 else | |
57 { | |
58 throw new Exception("overlapping array copy"); | |
59 } | |
60 return to; | |
61 } |