System.Data.SQLite
Check-in [48466de4f9]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Simplify the native library pre-loading code. Also, allow the selected processor architecture to be overridden via the environment variable 'PreLoadSQLite_ProcessorArchitecture'.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 48466de4f918ba2dbe79488369fb3e5e775b594a
User & Date: mistachkin 2012-04-03 03:58:49
Context
2012-04-05
19:49
Add question #20 to FAQ. check-in: d982172318 user: mistachkin tags: trunk
2012-04-03
03:58
Simplify the native library pre-loading code. Also, allow the selected processor architecture to be overridden via the environment variable 'PreLoadSQLite_ProcessorArchitecture'. check-in: 48466de4f9 user: mistachkin tags: trunk
03:18
Clarify comments and semantics of the process 'bitness' checking in the native library pre-loading code. Closed-Leaf check-in: 77969440cd user: mistachkin tags: preLoad
2012-03-31
22:23
Minor enhancements to release archive verification tool. check-in: 377c46ce48 user: mistachkin tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to System.Data.SQLite/UnsafeNativeMethods.cs.

128
129
130
131
132
133
134





135
136

137




138
139
140
141
142
143
144
145
...
244
245
246
247
248
249
250











251
252
253
254
255
256
257
...
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
              //
              // TODO: Make sure this list is updated if the supported
              //       processor architecture names and/or platform names
              //       changes.
              //
              if (processorArchitecturePlatforms == null)
              {





                  processorArchitecturePlatforms =
                      new Dictionary<string, string>();






                  processorArchitecturePlatforms.Add("X86", "Win32");
                  processorArchitecturePlatforms.Add("AMD64", "x64");
                  processorArchitecturePlatforms.Add("IA64", "Itanium");
              }

              //
              // BUGBUG: What about other application domains?
              //
................................................................................
      /// The processor architecture of the current process -OR- null if it
      /// cannot be determined.  Always returns an empty string when running on
      /// the .NET Compact Framework.
      /// </returns>
      private static string GetProcessorArchitecture()
      {
#if !PLATFORM_COMPACTFRAMEWORK











          //
          // BUGBUG: Will this always be reliable?
          //
          return Environment.GetEnvironmentVariable(PROCESSOR_ARCHITECTURE);
#else
          //
          // BUGBUG: No way to determine this value on the .NET Compact
................................................................................
                  return null;

              string platformName;

              if (processorArchitecturePlatforms.TryGetValue(
                      processorArchitecture, out platformName))
              {
                  return platformName;
              }

              if (processorArchitecturePlatforms.TryGetValue(
#if !PLATFORM_COMPACTFRAMEWORK
                      processorArchitecture.ToUpperInvariant(),
#else
                      processorArchitecture.ToUpper(),
#endif
                      out platformName))
              {
                  return platformName;
              }
          }

          return null;
      }








>
>
>
>
>

|
>

>
>
>
>
|







 







>
>
>
>
>
>
>
>
>
>
>







 







<
<
<
<
<
<
<
<
<
<
<







128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
...
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
...
306
307
308
309
310
311
312











313
314
315
316
317
318
319
              //
              // TODO: Make sure this list is updated if the supported
              //       processor architecture names and/or platform names
              //       changes.
              //
              if (processorArchitecturePlatforms == null)
              {
                  //
                  // NOTE: Create the map of processor architecture names
                  //       to platform names using a case-insensitive string
                  //       comparer.
                  //
                  processorArchitecturePlatforms =
                      new Dictionary<string, string>(
                          StringComparer.OrdinalIgnoreCase);

                  //
                  // NOTE: Setup the list of platform names associated with
                  //       the supported processor architectures.
                  //
                  processorArchitecturePlatforms.Add("x86", "Win32");
                  processorArchitecturePlatforms.Add("AMD64", "x64");
                  processorArchitecturePlatforms.Add("IA64", "Itanium");
              }

              //
              // BUGBUG: What about other application domains?
              //
................................................................................
      /// The processor architecture of the current process -OR- null if it
      /// cannot be determined.  Always returns an empty string when running on
      /// the .NET Compact Framework.
      /// </returns>
      private static string GetProcessorArchitecture()
      {
#if !PLATFORM_COMPACTFRAMEWORK
          //
          // NOTE: If the "PreLoadSQLite_ProcessorArchitecture" environment
          //       variable is set, use it verbatim for the current processor
          //       architecture.
          //
          string processorArchitecture = Environment.GetEnvironmentVariable(
              "PreLoadSQLite_ProcessorArchitecture");

          if (processorArchitecture != null)
              return processorArchitecture;

          //
          // BUGBUG: Will this always be reliable?
          //
          return Environment.GetEnvironmentVariable(PROCESSOR_ARCHITECTURE);
#else
          //
          // BUGBUG: No way to determine this value on the .NET Compact
................................................................................
                  return null;

              string platformName;

              if (processorArchitecturePlatforms.TryGetValue(
                      processorArchitecture, out platformName))
              {











                  return platformName;
              }
          }

          return null;
      }