This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug ada/11724] New: Ada Lseek->lseek() doesn't work with sizeof(off_t) != sizeof(long)


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11724

           Summary: Ada Lseek->lseek() doesn't work with sizeof(off_t) !=
                    sizeof(long)
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ada
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: M dot Drochner at fz-juelich dot de
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i386--netbsdelf2.0
  GCC host triplet: i386--netbsdelf2.0
GCC target triplet: i386--netbsdelf2.0

	GNAT.OS_Lib.Lseek takes a Long_Integer as File offset and imports the
libc lseek() function directly. lseek() assumes an off_t argument. On platforms
where off_t is 64 bits wide but long only 32 bits, wrong arguments are passed.

Environment:
System: NetBSD zelz26 1.6U NetBSD 1.6U (ZELZ26) #538: Wed Jul 30 00:07:30 MEST 2003 drochner@zelz26:/home/drochner/netbsd/sys/arch/i386/compile/ZELZ26 i386


	
host: i386--netbsdelf2.0
build: i386--netbsdelf2.0
target: i386--netbsdelf2.0
configured with: ./configure --prefix=/usr/pkg/gcc3-sav --host=i386--netbsdelf2.0 --enable-shared --enable-languages=c

How-To-Repeat:
	Build a program using GNAT.OS_Lib.Lseek and watch its system call
trace:

$ cat mist.adb
with GNAT.OS_Lib;

procedure mist is

fd: GNAT.OS_Lib.File_Descriptor;

begin
        fd := GNAT.OS_Lib.Open_Read("/tmp/mist", GNAT.OS_Lib.Binary);
        GNAT.OS_Lib.Lseek(fd, 16#1234#, GNAT.OS_Lib.Seek_Set);
end mist;
$ gnatmake mist
[...]
$ ktruss ./mist
[...]
  1513 mist     open("/tmp/mist", 0, 0x9)          = 3
  1513 mist     lseek(0x3, 0, 0x1234, 0, 0x8049462) Err#22 EINVAL

(The second argument (0) is padding, the following two are the
file offset, the "whence" passed is nonsense and leads to the error.)
------- Additional Comments From M dot Drochner at fz-juelich dot de  2003-07-30 09:32 -------
Fix:
	From the technical POV it would be preferrable to have a wide
enough type at Ada level. I can't judge whether this is an acceptable
interface change. (The book at http://www.pegasoft.ca/homes/book.html
assumes the existence of an "off_t" in its "Advanced Linux Programming"
chapter -- might be a mistake however.)
As a workaround, a C wrapper which imports the proper prototype from
<unistd.h> couls do the type conversion.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]