aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBrian Gaeke <gaeke@uiuc.edu>2003-12-12 15:38:06 +0000
committerBrian Gaeke <gaeke@uiuc.edu>2003-12-12 15:38:06 +0000
commit6c9d5827388d5b5a84ed5d1c5d5c8261ffcf014f (patch)
treee803f1c8d1bde6317d953852e69b416f7ee565a0 /lib
parent8b644f90736aa1c2c70d37f1337211d0718b95d2 (diff)
downloadexternal_llvm-6c9d5827388d5b5a84ed5d1c5d5c8261ffcf014f.zip
external_llvm-6c9d5827388d5b5a84ed5d1c5d5c8261ffcf014f.tar.gz
external_llvm-6c9d5827388d5b5a84ed5d1c5d5c8261ffcf014f.tar.bz2
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
Diffstat (limited to 'lib')
-rw-r--r--lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
index b547e52..2b9cda4 100644
--- a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
+++ b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
@@ -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;
}