comp.lang.ada
 help / color / mirror / Atom feed
* Ada.Directories.Size wraps on over 2Gb files
@ 2007-12-10 21:37 gpriv
  0 siblings, 0 replies; 5+ messages in thread
From: gpriv @ 2007-12-10 21:37 UTC (permalink / raw)


Couple of things that I found so far:

Ada.Directories.Size wraps on over 2Gb files returning negative
number.  I saw that was mentioned in

In addition to that:

In addition to that Ada.Direct_IO.Size returns 0 on the same while
End_Of_File is permanently true.  At the same time it is possible to
write files larger than 2G.

Types are all seem to be long integers, so it looks like truncation is
being made somewhere in C code (?)

Regards,

George.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Ada.Directories.Size wraps on over 2Gb files
@ 2007-12-10 21:38 gpriv
  2007-12-10 22:28 ` Stefan Bellon
  2007-12-11  1:29 ` Randy Brukardt
  0 siblings, 2 replies; 5+ messages in thread
From: gpriv @ 2007-12-10 21:38 UTC (permalink / raw)


Couple of things that I found so far:

Ada.Directories.Size wraps on over 2Gb files returning negative
number.  I saw that was mentioned in

In addition to that:

In addition to that Ada.Direct_IO.Size returns 0 on the same while
End_Of_File is permanently true.  At the same time it is possible to
write files larger than 2G.

Types are all seem to be long integers, so it looks like truncation is
being made somewhere in C code (?)

Regards,

George.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Ada.Directories.Size wraps on over 2Gb files
  2007-12-10 21:38 gpriv
@ 2007-12-10 22:28 ` Stefan Bellon
  2007-12-11  1:29 ` Randy Brukardt
  1 sibling, 0 replies; 5+ messages in thread
From: Stefan Bellon @ 2007-12-10 22:28 UTC (permalink / raw)


On Mo, 10 Dez, gpriv@axonx.com wrote:

[2GB limitation]

> Types are all seem to be long integers, so it looks like truncation is
> being made somewhere in C code (?)

I cannot speak for Ada.Directories.Size as I have not looked closer at
it, but the same 2 GB restriction is present on other parts of the GNAT
libraries at present as well (i.e. the whole of adaint.c does not make
use of O_LARGEFILE), so we ended up in coding our own binding to the
open/read/write/close category of functions with something like this:

#define _LARGEFILE_SOURCE
#define _LARGEFILE64_SOURCE
#define _FILE_OFFSET_BITS 64

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

#ifndef __MINGW32__
#define PERM (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
#define O_BINARY 0
#else
#define PERM (S_IREAD | S_IWRITE)
#define O_LARGEFILE 0
#endif

And later on we do something like the following:

int my_open(const char *pathname)
{   
    return open
        (pathname,
         O_RDONLY | O_BINARY | O_LARGEFILE);
}

int my_create(const char *pathname)
{
    return open
        (pathname,
         O_CREAT | O_WRONLY | O_TRUNC | O_BINARY | O_LARGEFILE,
         PERM);
}

NB: This is just an excerpt and only part of the code for illustration
purposes.

-- 
Stefan Bellon



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Ada.Directories.Size wraps on over 2Gb files
  2007-12-10 21:38 gpriv
  2007-12-10 22:28 ` Stefan Bellon
@ 2007-12-11  1:29 ` Randy Brukardt
  2007-12-11  1:36   ` gpriv
  1 sibling, 1 reply; 5+ messages in thread
From: Randy Brukardt @ 2007-12-11  1:29 UTC (permalink / raw)


<gpriv@axonx.com> wrote in message
news:0db40dde-17f0-40a9-9dc0-55f9b0a8e1b1@x69g2000hsx.googlegroups.com...
> Ada.Directories.Size wraps on over 2Gb files returning negative
> number.  I saw that was mentioned in

Sounds like a compiler bug. Ada.Directories.Size is supposed to return the
correct answer or Constraint_Error. Constraint_Error only if the type
File_Size can't hold the value (for instance, if it is 32-bits on a compiler
that only supports 32-bit integers). You didn't say what compiler that you
are using, but you should contact your vendor.

BTW, it isn't possible for Ada.Directories.Size to return a negative number
unless something is *really* screwed up, because type
Ada.Directories.File_Size does not include negative numbers. They'd have to
have suppressed range checking of the result...

                               Randy.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Ada.Directories.Size wraps on over 2Gb files
  2007-12-11  1:29 ` Randy Brukardt
@ 2007-12-11  1:36   ` gpriv
  0 siblings, 0 replies; 5+ messages in thread
From: gpriv @ 2007-12-11  1:36 UTC (permalink / raw)


On Dec 10, 8:29 pm, "Randy Brukardt" <ra...@rrsoftware.com> wrote:
> <gp...@axonx.com> wrote in message
>
> news:0db40dde-17f0-40a9-9dc0-55f9b0a8e1b1@x69g2000hsx.googlegroups.com...
>
> > Ada.Directories.Size wraps on over 2Gb files returning negative
> > number.  I saw that was mentioned in
>
> Sounds like a compiler bug. Ada.Directories.Size is supposed to return the
> correct answer or Constraint_Error. Constraint_Error only if the type
> File_Size can't hold the value (for instance, if it is 32-bits on a compiler
> that only supports 32-bit integers). You didn't say what compiler that you
> are using, but you should contact your vendor.
>
> BTW, it isn't possible for Ada.Directories.Size to return a negative number
> unless something is *really* screwed up, because type
> Ada.Directories.File_Size does not include negative numbers. They'd have to
> have suppressed range checking of the result...
>
>                                Randy.

I am using:

GPS 4.1.3 (20070913) hosted on pentium-mingw32msv
GNAT GPL 2007 (20070405-41)

with following:

   type File_Size is range 0 .. Long_Long_Integer'Last;
   --  The type File_Size represents the size of an external file

Range checks might been suppressed in the library.



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-12-11  1:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-12-10 21:37 Ada.Directories.Size wraps on over 2Gb files gpriv
  -- strict thread matches above, loose matches on Subject: below --
2007-12-10 21:38 gpriv
2007-12-10 22:28 ` Stefan Bellon
2007-12-11  1:29 ` Randy Brukardt
2007-12-11  1:36   ` gpriv

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox