* Implement array indexing in lli
* Add external atoi method as well as floor, and srand


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1355 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
index 00549a4..b42fb50 100644
--- a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
+++ b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
@@ -213,6 +213,14 @@
   return GenericValue();
 }
 
+// int atoi(char *)
+GenericValue lle_X_atoi(MethodType *M, const vector<GenericValue> &Args) {
+  assert(Args.size() == 1);
+  GenericValue GV;
+  GV.IntVal = atoi((char*)Args[0].PointerVal);
+  return GV;
+}
+
 // double pow(double, double)
 GenericValue lle_X_pow(MethodType *M, const vector<GenericValue> &Args) {
   assert(Args.size() == 2);
@@ -237,6 +245,14 @@
   return GV;
 }
 
+// double floor(double)
+GenericValue lle_X_floor(MethodType *M, const vector<GenericValue> &Args) {
+  assert(Args.size() == 1);
+  GenericValue GV;
+  GV.DoubleVal = floor(Args[0].DoubleVal);
+  return GV;
+}
+
 // double drand48()
 GenericValue lle_X_drand48(MethodType *M, const vector<GenericValue> &Args) {
   assert(Args.size() == 0);
@@ -260,6 +276,12 @@
   return GenericValue();
 }
 
+// void srand(uint)
+GenericValue lle_X_srand(MethodType *M, const vector<GenericValue> &Args) {
+  assert(Args.size() == 1);
+  srand(Args[0].UIntVal);
+  return GenericValue();
+}
 
 // int printf(sbyte *, ...) - a very rough implementation to make output useful.
 GenericValue lle_X_printf(MethodType *M, const vector<GenericValue> &Args) {
@@ -352,8 +374,11 @@
   FuncNames["lle_X_exit"]         = lle_X_exit;
   FuncNames["lle_X_malloc"]       = lle_X_malloc;
   FuncNames["lle_X_free"]         = lle_X_free;
+  FuncNames["lle_X_atoi"]         = lle_X_atoi;
   FuncNames["lle_X_pow"]          = lle_X_pow;
   FuncNames["lle_X_log"]          = lle_X_log;
+  FuncNames["lle_X_floor"]        = lle_X_floor;
+  FuncNames["lle_X_srand"]        = lle_X_srand;
   FuncNames["lle_X_drand48"]      = lle_X_drand48;
   FuncNames["lle_X_srand48"]      = lle_X_srand48;
   FuncNames["lle_X_lrand48"]      = lle_X_lrand48;