Make getopt() use portable to Linux.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@105922 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Core/Args.cpp b/source/Core/Args.cpp
index 3e38692..5ff57af 100644
--- a/source/Core/Args.cpp
+++ b/source/Core/Args.cpp
@@ -477,8 +477,12 @@
             }
         }
     }
+#ifdef __GLIBC__
+    optind = 0;
+#else
     optreset = 1;
     optind = 1;
+#endif
     int val;
     while (1)
     {
@@ -837,8 +841,12 @@
         }
     }
 
+#ifdef __GLIBC__
+    optind = 0;
+#else
     optreset = 1;
     optind = 1;
+#endif
     int val;
     while (1)
     {
@@ -974,8 +982,12 @@
         }
     }
 
+#ifdef __GLIBC__
+    optind = 0;
+#else
     optreset = 1;
     optind = 1;
+#endif
     opterr = 0;
 
     int val;
diff --git a/tools/driver/Driver.cpp b/tools/driver/Driver.cpp
index 0ae5187..6b0beb7 100644
--- a/tools/driver/Driver.cpp
+++ b/tools/driver/Driver.cpp
@@ -349,9 +349,12 @@
     }
 
     // Prepare for & make calls to getopt_long.
-
+#if __GLIBC__
+    optind = 0;
+#else
     optreset = 1;
     optind = 1;
+#endif
     int val;
     while (1)
     {