[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
Brian Gaeke
gaeke at cs.uiuc.edu
Fri Dec 12 09:39:02 PST 2003
Changes in directory llvm/lib/ExecutionEngine/Interpreter:
ExternalFunctions.cpp updated: 1.69 -> 1.70
---
Log message:
Dynamically get the right-sized member of a GenericValue to hold a size_t, and
use it to return the result of strlen.
---
Diffs of the changes: (+8 -2)
Index: llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp:1.69 llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp:1.70
--- llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp:1.69 Thu Nov 13 00:06:01 2003
+++ llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp Fri Dec 12 09:38:06 2003
@@ -481,11 +481,17 @@
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;
}
More information about the llvm-commits
mailing list