[SCM] Lisaac compiler branch, nb-lib-os-64-rebase, updated. lisaac-0.12-625-g2bc21e9
Nicolas Boulay
nicolas at boulay.name
Sun Apr 11 16:56:48 UTC 2010
The following commit has been merged in the nb-lib-os-64-rebase branch:
commit 2bc21e9c4472caf623da83ddd8b259e7c181663b
Author: Nicolas Boulay <nicolas at boulay.name>
Date: Sun Apr 11 18:44:16 2010 +0200
support 64 bits rebase to current master
diff --git a/lib/internal/os_support/unix/file_system/file_unix.li b/lib/internal/os_support/unix/file_system/file_unix.li
index afa0e95..d3a208a 100644
--- a/lib/internal/os_support/unix/file_system/file_unix.li
+++ b/lib/internal/os_support/unix/file_system/file_unix.li
@@ -19,102 +19,119 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := FILE_UNIX;
- - copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-
+ - copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag, 2009 Nicolas Boulay";
+
- comment := "File management";
-
+
+ //
+ // "getconf LFS_CFLAGS" for 64 bits off_t file offset is needed in the compiler command line to have:
+ // -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
+ //
+
+ - external := `
+ /*FILE_UNIX*/
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+ `;
+
Section Inherit
-
+
+ parent_entry_unix:Expanded ENTRY_UNIX;
-
+
+ parent_file:Expanded FILE;
-
-Section Private
-
- + stream:POINTER; // Unix file pointer (FILE *).
+
+Section Private
+
+ + stream:INTEGER_32 := -1; // Unix file descripter (int).
Section Public
-
+
//
// Physical implementation.
//
-
- - is_open:BOOLEAN <- stream != NULL;
-
- - size:UINTEGER_32 <-
+
+ - is_open:BOOLEAN <- stream != -1;
+
+ - size:INTEGER_64 <-
( + pe:NATIVE_ARRAY(CHARACTER);
- + result:UINTEGER_32;
+ + result:INTEGER_64; //off_t type
pe := path.to_external;
- `{ struct stat t; stat(@pe,&t)`;
- result := `t.st_size`:UINTEGER_32;
+ `{ struct stat t; stat(@pe,&t)`;
+ result := `t.st_size`:INTEGER_64;
`}`;
result
);
-
- - cursor:UINTEGER_32 <-
- ( + str:POINTER;
- str := stream;
- `ftell((FILE *)@str)`:UINTEGER_32
+
+ - cursor:INTEGER_64 <-
+ [
+ ...
+ -? {stream != -1};
+ ]
+ ( + str:INTEGER;
+ str := stream;
+ `lseek(@str,0,SEEK_CUR)`:INTEGER_64
);
-
- - set_cursor n:UINTEGER_32 <-
+
+ - set_cursor n:INTEGER_64 <-
[
...
- -? {stream != NULL};
+ -? {stream != -1};
-? {n <= size};
+ -? {n >= 0};
]
- ( + str:POINTER;
- str := stream;
- `fseek((FILE*)(@str), at n,SEEK_SET)`;
- );
-
+ ( + str:INTEGER;
+ str := stream;
+ `lseek((@str), at n,SEEK_SET)`;
+ );
+
- open:BOOLEAN <-
[
- -? {stream = NULL};
+ -? {stream = -1};
]
- ( + pa:NATIVE_ARRAY(CHARACTER);
-
+ ( + pa:NATIVE_ARRAY(CHARACTER);
+
pa := path.to_external;
- stream := `fopen((char*)@pa,"r+b")`:(POINTER);
- stream != NULL
- );
+ stream := `open((char*)@pa,O_RDWR)`:(INTEGER_32);
+ stream != -1
+ );
- open_read_only:BOOLEAN <-
- ( + pa:NATIVE_ARRAY(CHARACTER);
+ ( + pa:NATIVE_ARRAY(CHARACTER);
pa := path.to_external;
- stream := `fopen((char*)@pa,"rb")`:(POINTER);
- stream != NULL
- );
-
+ stream := `open((char*)@pa,O_RDONLY)`:(INTEGER_32);
+ stream != -1
+ );
+
- close <-
[
- -? {stream != NULL};
+ -? {stream != -1};
]
- ( + str:POINTER;
-
- str := stream;
- `fclose((FILE*)(@str))`;
- stream := NULL;
+ ( + str:INTEGER;
+
+ str := stream;
+ `close(@str)`;
+ stream := -1;
);
-
-Section FILE
-
- - physical_read buf:NATIVE_ARRAY(UINTEGER_8) size s:INTEGER :INTEGER <-
- // return size read or 0 if end of input (-1 on error => exception ?)
- ( + str:POINTER;
- str := stream;
- `fread((void *)(@buf),(size_t)(1), (size_t)(@s),(FILE*)(@str))`:(INTEGER)
+
+Section FILE
+
+ - physical_read buf:NATIVE_ARRAY(UINTEGER_8) size s:INTEGER_64 :INTEGER_64 <-
+ // return size read or 0 if end of input (-1 on error)
+ ( + str:INTEGER;
+ str := stream;
+ `read((@str),(@buf),(size_t)(@s))`:(INTEGER_64)
);
-
- - physical_write buf:NATIVE_ARRAY(UINTEGER_8) size s:INTEGER :INTEGER <-
- // return size read or 0 if end of input (-1 on error => exception ?)
- ( + str:POINTER;
- str := stream;
- `fwrite((void *)(@buf),(size_t)(1), (size_t)(@s),(FILE*)(@str))`:(INTEGER)
+
+ - physical_write buf:NATIVE_ARRAY(UINTEGER_8) size s:INTEGER_64 :INTEGER_64 <-
+ // return size read or 0 if end of input (-1 on error)
+ ( + str:INTEGER;
+ str := stream;
+ `write((@str),(@buf),(size_t)(@s))`:(INTEGER_64)
);
+
-
-
+
diff --git a/lib/standard/file_system/file.li b/lib/standard/file_system/file.li
index 356ccf4..0b50e04 100644
--- a/lib/standard/file_system/file.li
+++ b/lib/standard/file_system/file.li
@@ -19,55 +19,55 @@
// http://isaacproject.u-strasbg.fr/ //
///////////////////////////////////////////////////////////////////////////////
Section Header
-
+
+ name := FILE;
- - copyright := "2003-2007 Benoit Sonntag, Jerome Hilbert";
-
+ - copyright := "2003-2007 Benoit Sonntag, Jerome Hilbert, 2009 Nicolas Boulay";
+
- comment := "Abstract File Management";
-
+
Section Inherit
-
- - parent_entry:ENTRY := ENTRY;
-
+
+ - parent_entry:ENTRY := ENTRY;
+
Section Public
-
- - cursor:UINTEGER_32 <-
+
+ - cursor:INTEGER_64 <-
[
-? {is_open};
]
- (
+ (
deferred;
0
);
-
- - size:UINTEGER_32 <-
- (
+
+ - size:INTEGER_64 <-
+ (
deferred;
0
);
-
- - set_cursor n:UINTEGER_32 <-
+
+ - set_cursor n:INTEGER_64 <-
[
-? {is_open};
-? {n <= size};
]
(
- deferred;
+ deferred;
);
-
+
//
// Update.
//
-
+
- is_empty:BOOLEAN <- size = 0;
// Is collection empty ?
-
+
//
// Read.
//
-
- - read dest:OBJECT :INTEGER <-
+
+ - read dest:OBJECT :INTEGER_64 <-
// WARNING: It's good for Mapping objects, else serializable is necessary.
[
-? {is_open};
@@ -75,40 +75,40 @@ Section Public
( + buf:NATIVE_ARRAY(UINTEGER_8);
buf := CONVERT(OBJECT,NATIVE_ARRAY(UINTEGER_8)).on dest;
physical_read buf size (dest.object_size)
- );
-
- - read dest:ARRAYED size nb_elt:INTEGER :INTEGER <-
+ );
+
+ - read dest:ARRAYED size nb_elt:INTEGER_64 :INTEGER_64 <-
[
-? {is_open};
]
( + buf:NATIVE_ARRAY(UINTEGER_8);
- + index,s:INTEGER;
- + result:INTEGER;
- + new_count:INTEGER;
-
+ + index,s:INTEGER_64;
+ + result:INTEGER_64;
+ + new_count:INTEGER_64;
+
new_count := dest.count + nb_elt;
dest.set_capacity new_count;
buf := dest.to_native_array_uinteger_8;
index := dest.count * dest.element_sizeof;
- s := nb_elt * dest.element_sizeof;
+ s := nb_elt * dest.element_sizeof;
result := physical_read (buf+index) size s;
dest.set_count new_count;
? {result % dest.element_sizeof = 0};
result / dest.element_sizeof
);
-
+
//
// Write.
//
-
- - write src:ARRAYED from start:INTEGER size nb_elt:INTEGER :INTEGER <-
+
+ - write src:ARRAYED from start:INTEGER_64 size nb_elt:INTEGER_64 :INTEGER_64 <-
[
-? {is_open};
]
( + buf:NATIVE_ARRAY(UINTEGER_8);
- + index,s:INTEGER;
- + result:INTEGER;
-
+ + index,s:INTEGER_64;
+ + result:INTEGER_64;
+
buf := src.to_native_array_uinteger_8;
index := (start-src.lower) * src.element_sizeof;
s := nb_elt * src.element_sizeof;
@@ -116,37 +116,37 @@ Section Public
? {result % src.element_sizeof = 0};
result / src.element_sizeof
);
-
- - write src:ARRAYED size nb_elt:INTEGER :INTEGER <-
+
+ - write src:ARRAYED size nb_elt:INTEGER_64 :INTEGER_64 <-
(
write src from (src.lower) size nb_elt
);
-
- - write src:ARRAYED :INTEGER <-
+
+ - write src:ARRAYED :INTEGER_64 <-
(
write src size (src.count)
);
-
+
//
// Close.
//
-
+
- close <-
- (
+ (
deferred;
)
[
+? {! is_open};
];
-
+
- open_read_only:BOOLEAN <-
(
deferred;
);
-
+
Section FILE
-
- - physical_read buf:NATIVE_ARRAY(UINTEGER_8) size s:INTEGER :INTEGER <-
+
+ - physical_read buf:NATIVE_ARRAY(UINTEGER_8) size s:INTEGER_64 :INTEGER_64 <-
[
-? {is_open};
]
@@ -157,19 +157,19 @@ Section FILE
[
+? { (cursor = Old cursor + s ) || {cursor = size} };
];
-
- - physical_write buf:NATIVE_ARRAY(UINTEGER_8) size s:INTEGER :INTEGER <-
+
+ - physical_write buf:NATIVE_ARRAY(UINTEGER_8) size s:INTEGER_64 :INTEGER_64 <-
[
-? {is_open};
]
- (
+ (
deferred;
0
)
[
+? {cursor = Old cursor + s};
];
-
-
-
-
+
+
+
+
--
Lisaac compiler
More information about the Lisaac-commits
mailing list