Project

General

Profile

Actions

Bug #4564

closed

mingw-w64, truncate, ftruncate and ftello -- properly evalute it's existence

Added by luislavena (Luis Lavena) almost 13 years ago. Updated almost 13 years ago.

Status:
Closed
Target version:
ruby -v:
-
Backport:
[ruby-core:35678]

Description

=begin
Hello,

I'm using latest mingw-w64 builds that target in a experimental way GCC 4.7.0 codebase (gcc trunk)

mingw-w64 also combines improved CRT and headers support, which in this case included truncate, ftruncate and ftello support.

Ruby's trunk for win32 currently redefines those blindly, and even forces these functions presence to be used.

The attached patch proposes rely on configure's ability to detect these functions presence, conditionally define the missing functions and rename these functions to avoid redefinitions.

Assigning to Mr. Nobuyoshi Nakada and Mr. Usaku Nakamura for review and approval.

I've tested this against GCC 3.4.5, 4.5.1, 4.5.2 and 4.7.0, all on Windows. These patches should not affect any Linux version, however could affect Visual Studio builds.

Thank you for your time looking into this.

=end


Files

Actions #1

Updated by usa (Usaku NAKAMURA) almost 13 years ago

  • Status changed from Open to Assigned

=begin
It seems good.
Check in, please.
=end

Updated by luislavena (Luis Lavena) almost 13 years ago

  • Status changed from Assigned to Closed
  • Assignee changed from nobu (Nobuyoshi Nakada) to luislavena (Luis Lavena)
  • % Done changed from 0 to 100

=begin
Thank you.

Committed in r31262
=end

Updated by nobu (Nobuyoshi Nakada) almost 13 years ago

  • Status changed from Closed to Open
  • % Done changed from 100 to 0

=begin
Since ftruncate and truncate on mingw use int32_t and are useless at all, so this change causes failures to handle over 2GB files.
I'll revert this and succeeding changes or fix to use ftruncate64 instead.
=end

Updated by luislavena (Luis Lavena) almost 13 years ago

=begin
Thank you Nobu,

Dunno how I missed this detail.

Please revert this until I provide a proper patch that consistently uses ftruncate64.
=end

Updated by nobu (Nobuyoshi Nakada) almost 13 years ago

=begin
Try:

open("a.data", "w") {|f| f.truncate(1<<32)}

Currently this makes an empty file, while a 4GB file previously.
I consider this is a degrade.
=end

Actions #6

Updated by nobu (Nobuyoshi Nakada) almost 13 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
This issue was solved with changeset r31351.
Luis, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • include/ruby/win32.h (ftruncate, truncate, ftello, fseeko): non-64
    versions on mingw are useless because they use int32_t. fixes #4564
    =end

Updated by luislavena (Luis Lavena) almost 13 years ago

Thank you Nobu,

Thing is that current 1.9.2 with MinGW do not work as you mentioned:

C:\Users\Luis>ruby -ve "File.open('a.data', 'w') { |f| f.truncate(1 dir a.data
 Directory of C:\Users\Luis

22/05/2011  01:36 p.m.                 0 a.data

But works on trunk:

C:\Users\Luis>ruby -ve "File.open('a.data', 'w') { |f| f.truncate(1 dir a.data
 Directory of C:\Users\Luis

22/05/2011  01:37 p.m.     4.294.967.296 a.data

Updated by nobu (Nobuyoshi Nakada) almost 13 years ago

  • ruby -v changed from ruby 1.9.3dev (2011-04-10 trunk 31255) [i386-mingw32] to -

Hi,

At Mon, 23 May 2011 02:38:25 +0900,
Luis Lavena wrote in [ruby-core:36391]:

Thing is that current 1.9.2 with MinGW do not work as you mentioned:

C:\Users\Luis>ruby -ve "File.open('a.data', 'w') { |f| f.truncate(1 dir a.data
 Directory of C:\Users\Luis

22/05/2011  01:36 p.m.                 0 a.data

Thanks.
Then it should be a bug in 1.9.2. Mswin32 version works as expected at least.

--
Nobu Nakada

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0