Loading ...
Sorry, an error occurred while loading the content.
 

Re: [patch] has("win64") returns 0 in 64-bit Vim

Expand Messages
  • Matt Wozniski
    ... Isn t that only checking the type of CPU that the vim binary was built with, instead of whether it was built as an x64 binary? Or does defining WIN64
    Message 1 of 10 , Jan 5, 2010
      On Tue, Jan 5, 2010 at 8:52 AM, Sergey Khorev wrote:
      > Hi,
      >
      > has("win64") returns 0 even for x64 version of Vim. It seems we need
      > to define WIN64 for this to work. Something like that:
      >
      > *** ../vim72.323/src/Make_mvc.mak       Wed Dec 23 09:36:54 2009
      > --- src/Make_mvc.mak    Tue Jan  5 16:46:26 2010
      > ***************
      > *** 314,319 ****
      > --- 314,323 ----
      >  #>>>>> end of choices
      >  ###########################################################################
      >
      > + !if ("$(CPU)" == "AMD64") || ("$(CPU)" == "IA64")
      > + CFLAGS=$(CFLAGS) -DWIN64
      > + !endif
      > +
      >  !ifdef OS
      >  OS_TYPE       = winnt
      >  DEL_TREE = rmdir /s /q
      >
      >
      > --
      > Sergey Khorev
      > http://sites.google.com/site/khorser
      > Can anybody think of a good tagline I can steal?

      Isn't that only checking the type of CPU that the vim binary was built
      with, instead of whether it was built as an x64 binary? Or does
      defining WIN64 cause an x64 binary to be built instead?

      I'm not sure what has("win64") should be returning based only on
      reading the help, but I'd imagine it should either be a) whether the
      vim binary itself is a 64 bit binary, or b) whether the OS that the
      binary is running on is a 64-bit version of windows. The latter seems
      more useful, but I'm not sure just from the help. If I'm right,
      though, it would have to be a runtime test; nothing at compile time
      could do the trick.

      ~Matt
    • Sergey Khorev
      Well, ... CPU in makefile defines target CPU. -DWIN64 passed to compiler does nothing besides pointing out to source code we are targeting x64 or IA64. ...
      Message 2 of 10 , Jan 5, 2010
        Well,

        > Isn't that only checking the type of CPU that the vim binary was built
        > with, instead of whether it was built as an x64 binary?  Or does
        > defining WIN64 cause an x64 binary to be built instead?

        CPU in makefile defines target CPU.
        -DWIN64 passed to compiler does nothing besides pointing out to source
        code we are targeting x64 or IA64.

        > I'm not sure what has("win64") should be returning based only on
        > reading the help, but I'd imagine it should either be a) whether the
        > vim binary itself is a 64 bit binary, or  b) whether the OS that the
        > binary is running on is a 64-bit version of windows.  The latter seems
        > more useful, but I'm not sure just from the help.  If I'm right,
        > though, it would have to be a runtime test; nothing at compile time
        > could do the trick.

        Source code clearly states it was meant as a compile-time check:
        #ifdef WIN64
        "win64",
        #endif

        Honestly, I'm not sure what's the point in knowledge what OS version
        we are running.

        --
        Sergey Khorev
        http://sites.google.com/site/khorser
        Can anybody think of a good tagline I can steal?
      • Bram Moolenaar
        ... In many places in the code _WIN64 is checked for, but the list for has() uses WIN64. Perhaps we should change them all to WIN64 to be consistent with
        Message 3 of 10 , Jan 5, 2010
          Sergey Khorev wrote:

          > has("win64") returns 0 even for x64 version of Vim. It seems we need
          > to define WIN64 for this to work. Something like that:
          >
          > *** ../vim72.323/src/Make_mvc.mak Wed Dec 23 09:36:54 2009
          > --- src/Make_mvc.mak Tue Jan 5 16:46:26 2010
          > ***************
          > *** 314,319 ****
          > --- 314,323 ----
          > #>>>>> end of choices
          > ###########################################################################
          >
          > + !if ("$(CPU)" == "AMD64") || ("$(CPU)" == "IA64")
          > + CFLAGS=$(CFLAGS) -DWIN64
          > + !endif
          > +
          > !ifdef OS
          > OS_TYPE = winnt
          > DEL_TREE = rmdir /s /q

          In many places in the code _WIN64 is checked for, but the list for has()
          uses WIN64.

          Perhaps we should change them all to WIN64 to be consistent with WIN32,
          and then define WIN64 in vim.h when _WIN64 is defined.

          --
          From "know your smileys":
          y:-) Bad toupee

          /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
          /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
          \\\ download, build and distribute -- http://www.A-A-P.org ///
          \\\ help me help AIDS victims -- http://ICCF-Holland.org ///
        • Matt Wozniski
          ... OK, then. ... I can conceive of a plugin that dynamically loads a DLL - or another program - that requires a 64-bit windows, which would need to know that
          Message 4 of 10 , Jan 5, 2010
            On Tue, Jan 5, 2010 at 2:17 PM, Sergey Khorev wrote:
            > Well,
            >
            >> Isn't that only checking the type of CPU that the vim binary was built
            >> with, instead of whether it was built as an x64 binary?  Or does
            >> defining WIN64 cause an x64 binary to be built instead?
            >
            > CPU in makefile defines target CPU.
            > -DWIN64 passed to compiler does nothing besides pointing out to source
            > code we are targeting x64 or IA64.

            OK, then.

            >> I'm not sure what has("win64") should be returning based only on
            >> reading the help, but I'd imagine it should either be a) whether the
            >> vim binary itself is a 64 bit binary, or  b) whether the OS that the
            >> binary is running on is a 64-bit version of windows.  The latter seems
            >> more useful, but I'm not sure just from the help.  If I'm right,
            >> though, it would have to be a runtime test; nothing at compile time
            >> could do the trick.
            >
            > Source code clearly states it was meant as a compile-time check:
            > #ifdef WIN64
            >        "win64",
            > #endif
            >
            > Honestly, I'm not sure what's the point in knowledge what OS version
            > we are running.

            I can conceive of a plugin that dynamically loads a DLL - or another
            program - that requires a 64-bit windows, which would need to know
            that the host OS supports it. In this case, you'd want to know that
            the OS is 64 bit, even if the vim binary is 32-bit. But as I said, I
            can see the argument either way. It should obviously be consistent
            with whatever win16 and win32 do, so if they're compile-time
            architecture checks, all is fine.

            ~Matt
          • Sergey Khorev
            Matt, ... I m afraid you cannot load 64-bit DLL into 32-bit process even in x64 Windows. In fact, that was why I looked into has( win64 ) -- Sergey Khorev
            Message 5 of 10 , Jan 5, 2010
              Matt,

              > I can conceive of a plugin that dynamically loads a DLL - or another
              > program - that requires a 64-bit windows, which would need to know
              > that the host OS supports it.  In this case, you'd want to know that
              > the OS is 64 bit, even if the vim binary is 32-bit.  But as I said, I
              > can see the argument either way.  It should obviously be consistent
              > with whatever win16 and win32 do, so if they're compile-time
              > architecture checks, all is fine.

              I'm afraid you cannot load 64-bit DLL into 32-bit process even in x64
              Windows. In fact, that was why I looked into has("win64")

              --
              Sergey Khorev
              http://sites.google.com/site/khorser
              Can anybody think of a good tagline I can steal?
            • Sergey Khorev
              Hi, ... That will be inconsistent with WIN32 because it is defined in Makefile :) What about changing all occurrences of _WIN64 to WIN64 and defining WIN64 in
              Message 6 of 10 , Jan 5, 2010
                Hi,

                > In many places in the code _WIN64 is checked for, but the list for has()
                > uses WIN64.
                >
                > Perhaps we should change them all to WIN64 to be consistent with WIN32,
                > and then define WIN64 in vim.h when _WIN64 is defined.

                That will be inconsistent with WIN32 because it is defined in Makefile :)
                What about changing all occurrences of _WIN64 to WIN64 and defining
                WIN64 in makefile?

                On second thought, I don't like either ways. It seems more consistent
                to change the single occurrence of WIN64 in eval.c to _WIN64. Anyway,
                64-bit binary returns 1 for has("win32") so we don't have to make
                WIN64 to behave like another WIN32.

                --
                Sergey Khorev
                http://sites.google.com/site/khorser
                Can anybody think of a good tagline I can steal?
              • Bram Moolenaar
                ... The simplest would be to change the #ifdef: ... *************** *** 11453,11459 **** #if defined(UNIX) && (defined(__CYGWIN32__) || defined(__CYGWIN__))
                Message 7 of 10 , Jan 6, 2010
                  Sergey Khorev wrote:

                  > Hi,
                  >
                  > > In many places in the code _WIN64 is checked for, but the list for has()
                  > > uses WIN64.
                  > >
                  > > Perhaps we should change them all to WIN64 to be consistent with WIN32,
                  > > and then define WIN64 in vim.h when _WIN64 is defined.
                  >
                  > That will be inconsistent with WIN32 because it is defined in Makefile :)
                  > What about changing all occurrences of _WIN64 to WIN64 and defining
                  > WIN64 in makefile?
                  >
                  > On second thought, I don't like either ways. It seems more consistent
                  > to change the single occurrence of WIN64 in eval.c to _WIN64. Anyway,
                  > 64-bit binary returns 1 for has("win32") so we don't have to make
                  > WIN64 to behave like another WIN32.

                  The simplest would be to change the #ifdef:

                  *** ../vim-7.2.325/src/eval.c 2009-12-31 13:18:05.000000000 +0100
                  --- src/eval.c 2010-01-06 16:28:23.000000000 +0100
                  ***************
                  *** 11453,11459 ****
                  #if defined(UNIX) && (defined(__CYGWIN32__) || defined(__CYGWIN__))
                  "win32unix",
                  #endif
                  ! #ifdef WIN64
                  "win64",
                  #endif
                  #ifdef EBCDIC
                  --- 11453,11459 ----
                  #if defined(UNIX) && (defined(__CYGWIN32__) || defined(__CYGWIN__))
                  "win32unix",
                  #endif
                  ! #if defined(WIN64) || defined(_WIN64)
                  "win64",
                  #endif
                  #ifdef EBCDIC


                  Does that work without the change to the Makefile?

                  --
                  Where do you want to crash today?

                  /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
                  /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
                  \\\ download, build and distribute -- http://www.A-A-P.org ///
                  \\\ help me help AIDS victims -- http://ICCF-Holland.org ///
                • Sergey Khorev
                  ... Agreed ... Yes, it works. -- Sergey Khorev http://sites.google.com/site/khorser Can anybody think of a good tagline I can steal? -- You received this
                  Message 8 of 10 , Jan 6, 2010
                    > The simplest would be to change the #ifdef:

                    Agreed

                    > Does that work without the change to the Makefile?

                    Yes, it works.

                    --
                    Sergey Khorev
                    http://sites.google.com/site/khorser
                    Can anybody think of a good tagline I can steal?
                  • Tony Mechelynck
                    ... There is more: in Vim versions built before the +foobar feature was defined, has( foobar ) returns zero by design. This means that a has() feature which
                    Message 9 of 10 , Mar 11, 2010
                      On 05/01/10 20:30, Matt Wozniski wrote:
                      > On Tue, Jan 5, 2010 at 2:17 PM, Sergey Khorev wrote:
                      >> Well,
                      >>
                      >>> Isn't that only checking the type of CPU that the vim binary was built
                      >>> with, instead of whether it was built as an x64 binary? Or does
                      >>> defining WIN64 cause an x64 binary to be built instead?
                      >>
                      >> CPU in makefile defines target CPU.
                      >> -DWIN64 passed to compiler does nothing besides pointing out to source
                      >> code we are targeting x64 or IA64.
                      >
                      > OK, then.
                      >
                      >>> I'm not sure what has("win64") should be returning based only on
                      >>> reading the help, but I'd imagine it should either be a) whether the
                      >>> vim binary itself is a 64 bit binary, or b) whether the OS that the
                      >>> binary is running on is a 64-bit version of windows. The latter seems
                      >>> more useful, but I'm not sure just from the help. If I'm right,
                      >>> though, it would have to be a runtime test; nothing at compile time
                      >>> could do the trick.
                      >>
                      >> Source code clearly states it was meant as a compile-time check:
                      >> #ifdef WIN64
                      >> "win64",
                      >> #endif
                      >>
                      >> Honestly, I'm not sure what's the point in knowledge what OS version
                      >> we are running.
                      >
                      > I can conceive of a plugin that dynamically loads a DLL - or another
                      > program - that requires a 64-bit windows, which would need to know
                      > that the host OS supports it. In this case, you'd want to know that
                      > the OS is 64 bit, even if the vim binary is 32-bit. But as I said, I
                      > can see the argument either way. It should obviously be consistent
                      > with whatever win16 and win32 do, so if they're compile-time
                      > architecture checks, all is fine.
                      >
                      > ~Matt
                      >

                      There is more: in Vim versions built before the +foobar feature was
                      defined, has('foobar') returns zero by design. This means that a has()
                      feature which would return 1 for "this is a 32-bit version of Vim
                      running on a 64-bit OS" would necessarily be unreliable.


                      Best regards,
                      Tony.
                      --
                      I've enjoyed just about as much of this as I can stand.

                      --
                      You received this message from the "vim_dev" maillist.
                      Do not top-post! Type your reply below the text you are replying to.
                      For more information, visit http://www.vim.org/maillist.php
                    Your message has been successfully submitted and would be delivered to recipients shortly.