1. Bug report in sqlite.

Hi

Received an email message from a chap who had downloaded and found a bug in sqlite3.ew

I've found a bug in eusqlite3.ew and don't know how to post it on the forum. 
 
Function sqlite_get_table() (line 467 in eusqlite3.ew)  is: 
 
  tmp_ptr_addr += 4 
 
but for 64 bit SQLite should be 
 
  tmp_ptr_adr += 8 
 

Just a note - sqlite3.ew is 32 bit only, and I have no plans to adapt it to 64 bit - if anyone wishes to do so, then they have my blessing. They may either take over the maintenance, or post the changes to me, and I will update the dropbox set. The 32 bit sqlite dlls run fine on a 64 bit system, if you are using 32 bit eu to call them.

Incidentally, is there a way to programmatically detect whether it is a 32 or 64 bit system the program is running on?

Chris

new topic     » topic index » view message » categorize

2. Re: Bug report in sqlite.

ChrisB said...

Hi

Received an email message from a chap who had downloaded and found a bug in sqlite3.ew

I've found a bug in eusqlite3.ew and don't know how to post it on the forum. 
 
Function sqlite_get_table() (line 467 in eusqlite3.ew)  is: 
 
  tmp_ptr_addr += 4 
 
but for 64 bit SQLite should be 
 
  tmp_ptr_adr += 8 
 

If one were going to adapt this library to 64bit, the correct change would probably be

include std/machine.e 
  tmp_ptr_adr += machine:ADDRESS_LENGTH 
ChrisB said...

Incidentally, is there a way to programmatically detect whether it is a 32 or 64 bit system the program is running on?

If asking for the bitness of the interpreter (e.g. 32bit eui.exe, regardless of if it is running on w7 x64 or w7 x32), then the process is simple:

Check if one is running on EU 4.0 first with the following ifdef.

ifdef EU4_0 then 
	-- 32bits 
end ifdef 

4.0.x has not been ported to, and does not support 64bits at all, so if one is using a 4.0.x interpreter, then the result is guaranteed to be a 32-bit process.

If using a pre-release or beta of 4.1.0, then use one of the following two ifdefs to check for a 32bit vs 64bit interpreter (or translator).

ifdef BITS32 then 
	-- 32bits 
end ifdef 
ifdef BITS64 then 
	-- 64bits 
end ifdef 

If you want to know the bitness of the OS itself, you can check that as well.

If using a pre-release or beta of 4.1.0, and BITS64 is defined, then you can safely assuming that the OS and CPU are 64bit. While projects like QEMU could theoretically run an x64 process on an x32 cpu, outside of special emulation techniques a 32bit cpu can't run a 64bit OS or 64bit processes, and in normal cases a 32bit OS can't run a 64bit process.

If using 4.0.x or using a 32bit 4.1, then on nix you can use std/os.e's uname() call - it returns the name of the arch as a string ("x86" vs "x86_64"). If you want to know if the CPU supports 64bit, even if the OS is still 32bit, then on GNU/Linux you can open up /proc/cpuinfo and check the flags line for " lm " (long mode) - if present, you have a 64bit cpu. Other nix systems like FreeBSD probably have similar tricks to use.

std/os.e:uname() still helps on windoze platforms (if it returns "Windows 3.1" or "Win32s" for example, you can probably safely assume 32 bits), but the docs omit any mention of an arch value.

But if you're willing to use pipeio, then you can do this:

 
    wmic os get Name | FIND "x64" 
        IF %ERRORLEVEL% EQU 0  ECHO "Windows 64 bit" 
	    IF %ERRORLEVEL% NEQ 0 ECHO "Windows 32 bit" 

https://social.technet.microsoft.com/Forums/en-US/8cb203b1-b708-4c43-814e-2ea615f6dac6/windows-command-to-find-the-version-?forum=winservergen

You can also try wrapping this C code:

 
BOOL Is64BitWindows() 
{ 
#if defined(_WIN64) 
 return TRUE;  // 64-bit programs run only on Win64 
#elif defined(_WIN32) 
 // 32-bit programs run on both 32-bit and 64-bit Windows 
 // so must sniff 
 BOOL f64 = FALSE; 
 return IsWow64Process(GetCurrentProcess(), &f64) && f64; 
#else 
 return FALSE; // Win64 does not support Win16 
#endif 
} 
 

https://blogs.msdn.microsoft.com/oldnewthing/20050201-00/?p=36553

https://msdn.microsoft.com/en-us/library/windows/desktop/ms684139(v=vs.85).aspx

I leave as an exercise to the reader on how to check if you have a 32bit Windoze OS on a CPU that supports 64bit as well.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu