mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
Dynamically get the right-sized member of a GenericValue to hold a size_t, and
use it to return the result of strlen. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10433 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8b644f9073
commit
6c9d582738
@ -481,11 +481,17 @@ GenericValue lle_X_strcpy(FunctionType *M, const vector<GenericValue> &Args) {
|
||||
return PTOGV(strcpy((char*)GVTOP(Args[0]), (char*)GVTOP(Args[1])));
|
||||
}
|
||||
|
||||
// long strlen(const char *src);
|
||||
// size_t strlen(const char *src);
|
||||
GenericValue lle_X_strlen(FunctionType *M, const vector<GenericValue> &Args) {
|
||||
assert(Args.size() == 1);
|
||||
size_t strlenResult = strlen ((char *) GVTOP (Args[0]));
|
||||
GenericValue Ret;
|
||||
Ret.LongVal = strlen((char*)GVTOP(Args[0]));
|
||||
if (sizeof (size_t) == sizeof (uint64_t)) {
|
||||
Ret.ULongVal = strlenResult;
|
||||
} else {
|
||||
assert (sizeof (size_t) == sizeof (unsigned int));
|
||||
Ret.UIntVal = strlenResult;
|
||||
}
|
||||
return Ret;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user