/usr/include/d/ldc/arrayinit.d is in libphobos2-ldc-dev 1:0.17.1-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | module ldc.arrayinit;
private import ldc.intrinsics;
extern(C):
int memcmp(void*,void*,size_t);
size_t strlen(char*);
// per-element array init routines
void _d_array_init_i16(ushort* a, size_t n, ushort v)
{
auto p = a;
auto end = a+n;
while (p !is end)
*p++ = v;
}
void _d_array_init_i32(uint* a, size_t n, uint v)
{
auto p = a;
auto end = a+n;
while (p !is end)
*p++ = v;
}
void _d_array_init_i64(ulong* a, size_t n, ulong v)
{
auto p = a;
auto end = a+n;
while (p !is end)
*p++ = v;
}
void _d_array_init_float(float* a, size_t n, float v)
{
auto p = a;
auto end = a+n;
while (p !is end)
*p++ = v;
}
void _d_array_init_double(double* a, size_t n, double v)
{
auto p = a;
auto end = a+n;
while (p !is end)
*p++ = v;
}
void _d_array_init_real(real* a, size_t n, real v)
{
auto p = a;
auto end = a+n;
while (p !is end)
*p++ = v;
}
void _d_array_init_cfloat(cfloat* a, size_t n, cfloat v)
{
auto p = a;
auto end = a+n;
while (p !is end)
*p++ = v;
}
void _d_array_init_cdouble(cdouble* a, size_t n, cdouble v)
{
auto p = a;
auto end = a+n;
while (p !is end)
*p++ = v;
}
void _d_array_init_creal(creal* a, size_t n, creal v)
{
auto p = a;
auto end = a+n;
while (p !is end)
*p++ = v;
}
void _d_array_init_pointer(void** a, size_t n, void* v)
{
auto p = a;
auto end = a+n;
while (p !is end)
*p++ = v;
}
void _d_array_init_mem(void* a, size_t na, void* v, size_t nv)
{
auto p = a;
auto end = a + na*nv;
while (p !is end) {
llvm_memcpy(p,v,nv,0);
p += nv;
}
}
/*
void _d_array_init(TypeInfo ti, void* a)
{
auto initializer = ti.next.init();
auto isize = initializer.length;
auto q = initializer.ptr;
if (isize == 1)
memset(p, *cast(ubyte*)q, size);
else if (isize == int.sizeof)
{
int init = *cast(int*)q;
size /= int.sizeof;
for (size_t u = 0; u < size; u++)
{
(cast(int*)p)[u] = init;
}
}
else
{
for (size_t u = 0; u < size; u += isize)
{
memcpy(p + u, q, isize);
}
}
}*/
// for array cast
size_t _d_array_cast_len(size_t len, size_t elemsz, size_t newelemsz)
{
if (newelemsz == 1) {
return len*elemsz;
}
else if ((len*elemsz) % newelemsz) {
throw new Exception("Bad array cast");
}
return (len*elemsz)/newelemsz;
}
// slice copy when assertions are enabled
void _d_array_slice_copy(void* dst, size_t dstlen, void* src, size_t srclen)
{
if (dstlen != 0) assert(dst);
if (dstlen != 0) assert(src);
if (dstlen != srclen)
throw new Exception("lengths don't match for array copy");
else if (dst+dstlen <= src || src+srclen <= dst)
llvm_memcpy!size_t(dst, src, dstlen, 0);
else
throw new Exception("overlapping array copy");
}
|