[Issue 21879] -betterC "undefined reference to '_memset32'"
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Apr 30 09:13:32 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=21879
--- Comment #2 from Blatnik <blatblatnik at gmail.com> ---
Also, this doesn't just happen with _memset32, it also happens with
short[4] s; s[] = 42; // ERROR: Undefined reference to _memset16.
int[4] i; i[] = 42; // ERROR: Undefined reference to _memset32.
long[4] l; l[] = 42; // ERROR: Undefined reference to _memset64.
float[4] f; f[] = 42; // ERROR: Undefined reference to _memsetFloat.
double[4] d; d[] = 42; // ERROR: Undefined reference to _memsetDouble.
real[4] r; r[] = 42; // ERROR: Undefined reference to _memset80.
void[][4] a; // ERROR: Undefined reference to _memset128ii.
struct S{} S[4] s; s[] = S.init; // ERROR: Undefined reference to _memsetn.
These are all of the ones I encountered while I was messing around with
-betterC. There may be more that I haven't found yet.
I looked at the assembly generated for each of these to figure out which
parameters these functions are called with.
Here is a quick-and-dirty implementation for each of them that you can copy
paste in some D file.
extern(C) void _memsetn(void* array, const void* value, size_t length, size_t
elemSize) // Struct[64] s; s[] = Struct.init;
{
import core.stdc.string : memmove;
for (size_t i = 0; i < length; ++i)
memmove(array + i * elemSize, value, elemSize);
}
extern(C) void _memset16(ushort* ushorts, ushort value, size_t length) //
short[64] s; s[] = 42;
{
for (size_t i = 0; i < length; ++i)
uints[i] = value;
}
extern(C) void _memset32(uint* uints, uint value, size_t length) // int[64] i;
i[] = 42;
{
for (size_t i = 0; i < length; ++i)
uints[i] = value;
}
extern(C) void _memset64(ulong* uints, ulong value, size_t length) // long[64]
l; l[] = 42;
{
for (size_t i = 0; i < length; ++i)
uints[i] = value;
}
extern(C) void _memsetFloat(float* floats, float value, size_t length) //
float[64] f; f[] = 42;
{
for (size_t i = 0; i < length; ++i)
floats[i] = value;
}
extern(C) void _memsetDouble(double* doubles, double value, size_t length) //
double[64] d; d[] = 42;
{
for (size_t i = 0; i < length; ++i)
doubles[i] = value;
}
extern(C) void _memset80(real* reals, real value, size_t length) // real[64] r;
d[] = 42;
{
for (size_t i = 0; i < length; ++i)
reals[i] = value;
}
extern(C) void _memset128ii(void *dest, void *value, size_t length) //
void[][64] a;
{
void[]* d = cast(void[]*) dest;
void[] s = *cast(void[]*) value;
for (size_t i = 0; i < length; ++i)
d[i] = s;
}
--
More information about the Digitalmars-d-bugs
mailing list