Hello
I have discussed with Shigeharu Takeno the way to get information of working gnuplot
1. 32 bit or 64 bit
2. working OS name (but not build OS name)
We know Build OS (in reality is is not as shown below) information is omitted at the change
2013-02-26 Ethan A Merritt merritt@u.washington.edu
src/show.c src/version.c src/version.h src/plot.c:
Remove the "Build system" line from the version information shown on
entry. It never did report the build system, only the system reported
by the machine it was currently running on. Could be replaced if
someone wants to figure out a generic way to have autoconf fill in the
OS definition in syscfg.h
The omitted information is just we want to know.
We talked that it is very convenient to get above 1. and 2. information as GPVAL_ variables like GPVAL_OSBITNUM, and GPVAL_OSNAME.
How do the developer think about that?
Tatsuro
What is the information needed for?
I do not know the situation on Windows, but on linux it is complicated.
There is not a clear break between 32 and 64 bit support.
On linux the program may be compiled 32-bit even if the operating system is 64-bit. And for some purposes like LFS (large file support) the program may support 64-bit access even if the operating system is 32-bit.
The command
uname -i
reports the instruction set used in the linux kernel (for example i686 or x86_64), but does not tell you whether that same instruction set was used to compile a particular program.The command
file /usr/local/bin/gnuplot
reports the architecture used to compile and link the executable (for example "ELF 32-bit LSB executable, Intel 80386") but does not tell you whether it is running on a 32- or 64- bit operating system.Thanks for reply
First I tell situation on windows
For windows, on 64 bit OS, both 32bit and 64 bit applications can run, but on 32 OS, only 32 bit applications can work.
For 4.6.7, start up Screen tells on gnuplot for windows
Note that both binaries are built on 64 bit windows.
But 32 bit binary is built with 32 bit mingw toolkit and 64 bit binary is built with 64 bit mingw toolkit.
64 bit version gnuplot on windows 7 64bit
32 bit version gnuplot on windows 7 64bit
Therefore situation is simple.
The request on this ticket is Shigeharu's one. So I cannot surely say but he might want to get information whether gnuplot is working in 32 or 64 bit.
I will confirm this point from Shigeharu.
Tatsuro
Last edit: Tatsuro MATSUOKA 2015-06-20
The reasons that I want to know the OS information in gnuplot script and on command window are the followings:
For ms-win,
1) I want to know the binary version simply,
2) It may help us to install the newer version,
3) GPVAL_* may be used on "if" statements if there are some differences between 32bit version and 64bit version,
4) We can add the information to bug reports when we send it.
For unix,
5) if we can know the OS information by GPVAL* variable, we can use it on "if" statements in the gnuplot script which we run on several computers.
In fact, I use several OS ordinarily, FreeBSD, Solaris, and MS-Windows.
I still do not understand exactly what information you want to store in a GPVAL* variable.
On unix, which of these do you want?
I am sorry, but I don't need it strongly.
I want the information to distinguish computers gnuplot is running on.
Mainly, it is enough to show the OS name (
uname -s
) andarchitecture name (
uname -p
).Normally, the information of running machine may be better than
the one of build machine. But, for the the Windows binary,
I want to know whether it is the 32bit-version or not.
In some case, the value such as sizeof(int) or endian may be needed,
but I don't need it now.
By the way, the result of "uname -i" depends on OS.
'uname -i' returns the name of kernel configuration file (GENERIC)
on FreeBSD, and it returns platform name (SUNW,Ultra-5_10) on Solaris.
cf. https://en.wikipedia.org/wiki/Uname
I don't know the value of ELF header in the program, too.
To distinguish whether application is working on 32 bit or 64 bit on windows, you can use dumpbin /headers.
The file dumpbin.exe can be obtained it if you install Microsoft visual studio (Express Edition is enough.)
See:
https://msdn.microsoft.com/en-us/library/c1h23y6c.aspx
The attached patch teaches gnuplot to fill in the variables
GPVAL_SYSNAME (e.g. linux)
GPVAL_MACHINE (e.g. 686 x86_64)
GPVAL_BITS (32 or 64)
The first two variables are filled in using the system call uname(),
and therefore they only work if HAVE_UNAME is defined.
Probably windows does not supply uname(), but I am not sure.
Please report back if Windows does supply uname(), or suggest
a different system call to use on Windows.
Please modify your patch
to
because Solaris' uname() returns 1 (manual says "non-negative value") when succeeded.
FreeBSD's uname() returns 0 when it succeeded.
Linux
* I have confirmed the change works on Ubuntu 64 bit and 32 bit.
Windows
* As you expected, the change does not work.
As alternative way, I need time to find way.
I have collected information how to get GPVAL_SYSNAME (e.g. linux) GPVAL_MACHINE (e.g. 686 x86_64) on native windows.
(The way get GPVAL_BITS information is not related OS type. (outside #ifdef HAVE_UNAME))
I have a question how to implement the functionality on windows.(written in end part of the post.)
Before talking about native windows, I would like talk about cygwin
On 32 bit cygwin (working on 64 bit win 7)
On 64 bit cygwin (working on 64 bit win 7)
NT-6.1 means windows 7 (or Windows Server 2008 R2)
WOW means here WOW64 which is the system to run 32bit application on 64 bit windows OS. I have not executed patched gnuplot on 32 bit cygwin on 32 bit windows. But perhaps on 32 bit cygwin on 32 bit windows, value of GPVAL_SYSNAME is CYGWIN_NT-(version) (no WOW).
Now I talk about output info for windows.
I would like to set the value in the same way on cygwin.
Question
#
# Weekend I will have a trip and on next week I will have hard jobs.
# The code upload will be done after that.
I have made a patch for windows.
It should be applied after gpval_uname.patch is applied.
To get windows OS version, I used an external header file (findversion.h) from
https://bitbucket.org/AnyCPU/findversion
First I planned to use "GetVersionEx" function in windows api but it deprecated on windows 8.1 and Visual Studio 2013.
So I would like to use findversion.h for windows version determination.
This is an additional dependency so that it may be effective when HAVE_FINDVERSION_H is defined which will be defined in Makefile to add -DHAVE_FINDVERSION_H to CFLAGS.
For architecture determination, I used "GetSystemInfo" windows API.
I refereed here.
http://www.codeproject.com/Tips/117594/Getting-Processor-architecture-in-x-and-x-bit
To distinguish cpu among i386, i486, i586, or i686 is difficult,
GPVAL_MACHINE prints x86 for intel 32 bit (working) architecture.
For win7 64 bit
32bit binary
64bit binary
I have examined on win 8.1 and XP. Version numbers are printed as expected
(6.3 win 8.1, 5.1 win XP).
WOW64 detection is not implemented because of simplicity. If it will be better to be implemented I will consider the implement.
Last edit: Tatsuro MATSUOKA 2015-07-09
https://bitbucket.org/AnyCPU/findversion
I have attached cloned source.
I have discussed for this matter with Shigeharu Takeno.
I have modified the patch.
If flag "HAVE_FINDVERSION_H" is not set, GPVAL_SYSNAME mere returns "Windows" but not unimplemented.
I have confirmed the patches are included into the cvs tree and the cvs source works on windows, cygwin and ubuntu. Thanks!
Last edit: Tatsuro MATSUOKA 2015-07-16
findversion.h
is simple and short enough and has a MIT license. So it's imho best to include it in CVS. There are two more places where we useGetVersionEx
which could also use this macro.On second thought, that might not be the best idea. First of all you cannot include this as is in several C files, as you get "multiple definition" errors. Second, and more importantly, [bugs:#1851] proofs that the work-around just worked for Windows 8.1 but now fails on Windows 10, see also Targeting your application for Windows on MSDN.
Since the patch attached to [bugs:#1851] makes
GetVersionEx
work again on Windows up to version 10, we should just rely on that everywhere. MS for some reason seems to be destined to make it difficult to determine the Windows version in a program.Related
Bugs:
#1851