System.Data.SQLite

Check-in [77969440cd]
Login

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

Overview
Comment:Clarify comments and semantics of the process 'bitness' checking in the native library pre-loading code.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | preLoad
Files: files | file ages | folders
SHA1: 77969440cd5a01b466ffa7a48560dc3609cd63da
User & Date: mistachkin 2012-04-03 03:18:47.893
Context
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-04-02
17:58
Start of work on improving the platform detection in the native library pre-loading code. check-in: 621d22239e user: mistachkin tags: preLoad
Changes
Unified Diff Ignore Whitespace Patch
Changes to System.Data.SQLite/UnsafeNativeMethods.cs.
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
                      new Dictionary<string, Platform>(
                          StringComparer.OrdinalIgnoreCase);

                  //
                  // NOTE: Setup the list of platform names associated with
                  //       the supported processor architectures.
                  //
                  processorArchitecturePlatforms.Add("X86",
                      new Platform("Win32", 32));

                  processorArchitecturePlatforms.Add("AMD64",
                      new Platform("x64", 64));

                  processorArchitecturePlatforms.Add("IA64",
                      new Platform("Itanium", 64));







|







191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
                      new Dictionary<string, Platform>(
                          StringComparer.OrdinalIgnoreCase);

                  //
                  // NOTE: Setup the list of platform names associated with
                  //       the supported processor architectures.
                  //
                  processorArchitecturePlatforms.Add("x86",
                      new Platform("Win32", 32));

                  processorArchitecturePlatforms.Add("AMD64",
                      new Platform("x64", 64));

                  processorArchitecturePlatforms.Add("IA64",
                      new Platform("Itanium", 64));
307
308
309
310
311
312
313





314
315
316
317
318
319
320
      /// </summary>
      /// <returns>
      /// The number of bits used to represent memory addresses for the
      /// current process or zero if this value cannot be determined.
      /// </returns>
      private static int GetProcessBits()
      {





          return IntPtr.Size * 8;
      }

      /////////////////////////////////////////////////////////////////////////
      /// <summary>
      /// Queries and returns the processor architecture of the current
      /// process.







>
>
>
>
>







307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
      /// </summary>
      /// <returns>
      /// The number of bits used to represent memory addresses for the
      /// current process or zero if this value cannot be determined.
      /// </returns>
      private static int GetProcessBits()
      {
          //
          // NOTE: The number of bits used to represent memory addresses for
          //       the current process is the size of an IntPtr (in bytes),
          //       multiplied by the number of bits per byte (8).
          //
          return IntPtr.Size * 8;
      }

      /////////////////////////////////////////////////////////////////////////
      /// <summary>
      /// Queries and returns the processor architecture of the current
      /// process.
335
336
337
338
339
340
341







342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362

363
364
365
366
367
368
369
          string processorArchitecture = Environment.GetEnvironmentVariable(
              "PreLoadSQLite_ProcessorArchitecture");

          if (processorArchitecture != null)
              return processorArchitecture;

          //







          // BUGBUG: Will this always be reliable?  There seems to be some
          //         evidence that this is not necessarily 100% reliable on
          //         some 64-bit platforms for child processes started from
          //         a WoW64 process (e.g. the Visual Studio debugger).
          //
          processorArchitecture = Environment.GetEnvironmentVariable(
              PROCESSOR_ARCHITECTURE);

          if (processorArchitecture != null)
          {
              if (processorArchitecturePlatforms == null)
                  return null;

              Platform platform;

              if (processorArchitecturePlatforms.TryGetValue(
                      processorArchitecture, out platform) &&
                  (platform != null) &&
                  (platform.Bits == GetProcessBits()))
              {
                  return processorArchitecture;

              }
          }

          return null;
#else
          //
          // BUGBUG: No way to determine this value on the .NET Compact







>
>
>
>
>
>
>
|
<
<
<
|
|
|

|
|
<
<
<
|

|
|
|
|
|
|
>







340
341
342
343
344
345
346
347
348
349
350
351
352
353
354



355
356
357
358
359
360



361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
          string processorArchitecture = Environment.GetEnvironmentVariable(
              "PreLoadSQLite_ProcessorArchitecture");

          if (processorArchitecture != null)
              return processorArchitecture;

          //
          // NOTE: We cannot sanity check the processor architecture value
          //       without the mappings between processor architecture names
          //       and platform bits; therefore, return null in that case.
          //
          if (processorArchitecturePlatforms != null)
          {
              //
              // BUGBUG: Will this always be reliable?



              //
              processorArchitecture = Environment.GetEnvironmentVariable(
                  PROCESSOR_ARCHITECTURE);

              if (processorArchitecture != null)
              {



                  Platform platform;

                  if (processorArchitecturePlatforms.TryGetValue(
                          processorArchitecture, out platform) &&
                      (platform != null) &&
                      (platform.Bits == GetProcessBits()))
                  {
                      return processorArchitecture;
                  }
              }
          }

          return null;
#else
          //
          // BUGBUG: No way to determine this value on the .NET Compact