]> gitweb.factorcode.org Git - factor.git/commitdiff
change all stat, statfs, statvfs and calendar structs
authorDoug Coleman <doug.coleman@gmail.com>
Sun, 30 Aug 2009 09:06:41 +0000 (04:06 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Sun, 30 Aug 2009 09:06:41 +0000 (04:06 -0500)
30 files changed:
basis/calendar/unix/unix.factor
basis/io/files/info/unix/bsd/bsd.factor
basis/io/files/info/unix/freebsd/freebsd.factor
basis/io/files/info/unix/linux/linux.factor
basis/io/files/info/unix/macosx/macosx.factor
basis/io/files/info/unix/netbsd/netbsd.factor
basis/io/files/info/unix/openbsd/openbsd.factor
basis/io/files/info/unix/unix.factor
basis/unix/stat/freebsd/32/32.factor [deleted file]
basis/unix/stat/freebsd/32/tags.txt [deleted file]
basis/unix/stat/freebsd/64/64.factor [deleted file]
basis/unix/stat/freebsd/64/tags.txt [deleted file]
basis/unix/stat/freebsd/freebsd.factor
basis/unix/stat/linux/32/32.factor
basis/unix/stat/linux/64/64.factor
basis/unix/stat/macosx/macosx.factor
basis/unix/stat/netbsd/32/32.factor
basis/unix/stat/netbsd/64/64.factor
basis/unix/stat/openbsd/openbsd.factor
basis/unix/stat/stat.factor
basis/unix/statfs/freebsd/freebsd.factor
basis/unix/statfs/linux/linux.factor
basis/unix/statfs/macosx/macosx.factor
basis/unix/statfs/openbsd/openbsd.factor
basis/unix/statvfs/freebsd/freebsd.factor
basis/unix/statvfs/linux/linux.factor
basis/unix/statvfs/macosx/macosx.factor
basis/unix/statvfs/netbsd/netbsd.factor
basis/unix/statvfs/openbsd/openbsd.factor
basis/unix/time/time.factor

index aa4e8f7e9a29f276a6bbaa3e8ca0c6794a91bfe3..28e54b89fb5d95fa01d1119d3a9fbdb2ab9cf28d 100644 (file)
@@ -1,28 +1,27 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: alien alien.c-types alien.syntax arrays calendar
-kernel math unix unix.time unix.types namespaces system ;
+kernel math unix unix.time unix.types namespaces system
+accessors classes.struct ;
 IN: calendar.unix
 
 : timeval>seconds ( timeval -- seconds )
-    [ timeval-sec seconds ] [ timeval-usec microseconds ] bi
-    time+ ;
+    [ sec>> seconds ] [ usec>> microseconds ] bi time+ ;
 
 : timeval>unix-time ( timeval -- timestamp )
     timeval>seconds since-1970 ;
 
 : timespec>seconds ( timespec -- seconds )
-    [ timespec-sec seconds ] [ timespec-nsec nanoseconds ] bi
-    time+ ;
+    [ sec>> seconds ] [ nsec>> nanoseconds ] bi time+ ;
 
 : timespec>unix-time ( timespec -- timestamp )
     timespec>seconds since-1970 ;
 
 : get-time ( -- alien )
-    f time <time_t> localtime ;
+    f time <time_t> localtime tm memory>struct ;
 
 : timezone-name ( -- string )
-    get-time tm-zone ;
+    get-time zone>> ;
 
 M: unix gmt-offset ( -- hours minutes seconds )
-    get-time tm-gmtoff 3600 /mod 60 /mod ;
+    get-time gmtoff>> 3600 /mod 60 /mod ;
index 6d0f3e716140194243a53ab21682809d9bb22061..64fcd0b5d62e733a3f0388e502b4f77835fd0238 100644 (file)
@@ -12,10 +12,7 @@ M: bsd new-file-info ( -- class ) bsd-file-info new ;
 M: bsd stat>file-info ( stat -- file-info )
     [ call-next-method ] keep
     {
-        [ stat-st_flags >>flags ]
-        [ stat-st_gen >>gen ]
-        [
-            stat-st_birthtimespec timespec>unix-time
-            >>birth-time
-        ]
+        [ st_flags>> >>flags ]
+        [ st_gen>> >>gen ]
+        [ st_birthtimespec>> timespec>unix-time >>birth-time ]
     } cleave ;
index 61d7a1d92118ade4effb6fffc4a4bc8bca361e25..8c55166cb7cc54a9855c813e1f49dcef3512a8e7 100644 (file)
@@ -4,7 +4,8 @@ USING: accessors alien.c-types alien.syntax combinators
 io.backend io.files io.files.info io.files.unix kernel math system unix
 unix.statfs.freebsd unix.statvfs.freebsd unix.getfsstat.freebsd
 sequences grouping alien.strings io.encodings.utf8 unix.types
-specialized-arrays.direct.uint arrays io.files.info.unix ;
+specialized-arrays.direct.uint arrays io.files.info.unix
+classes.struct ;
 IN: io.files.info.unix.freebsd
 
 TUPLE: freebsd-file-system-info < unix-file-system-info
@@ -13,43 +14,43 @@ version io-size owner syncreads syncwrites asyncreads asyncwrites ;
 M: freebsd new-file-system-info freebsd-file-system-info new ;
 
 M: freebsd file-system-statfs ( path -- byte-array )
-    "statfs" <c-object> [ statfs io-error ] keep ;
+    \ statfs <struct> [ statfs io-error ] keep ;
 
 M: freebsd statfs>file-system-info ( file-system-info statvfs -- file-system-info )
     {
-        [ statfs-f_version >>version ]
-        [ statfs-f_type >>type ]
-        [ statfs-f_flags >>flags ]
-        [ statfs-f_bsize >>block-size ]
-        [ statfs-f_iosize >>io-size ]
-        [ statfs-f_blocks >>blocks ]
-        [ statfs-f_bfree >>blocks-free ]
-        [ statfs-f_bavail >>blocks-available ]
-        [ statfs-f_files >>files ]
-        [ statfs-f_ffree >>files-free ]
-        [ statfs-f_syncwrites >>syncwrites ]
-        [ statfs-f_asyncwrites >>asyncwrites ]
-        [ statfs-f_syncreads >>syncreads ]
-        [ statfs-f_asyncreads >>asyncreads ]
-        [ statfs-f_namemax >>name-max ]
-        [ statfs-f_owner >>owner ]
-        [ statfs-f_fsid 2 <direct-uint-array> >array >>id ]
-        [ statfs-f_fstypename utf8 alien>string >>type ]
-        [ statfs-f_mntfromname utf8 alien>string >>device-name ]
-        [ statfs-f_mntonname utf8 alien>string >>mount-point ]
+        [ f_version>> >>version ]
+        [ f_type>> >>type ]
+        [ f_flags>> >>flags ]
+        [ f_bsize>> >>block-size ]
+        [ f_iosize>> >>io-size ]
+        [ f_blocks>> >>blocks ]
+        [ f_bfree>> >>blocks-free ]
+        [ f_bavail>> >>blocks-available ]
+        [ f_files>> >>files ]
+        [ f_ffree>> >>files-free ]
+        [ f_syncwrites>> >>syncwrites ]
+        [ f_asyncwrites>> >>asyncwrites ]
+        [ f_syncreads>> >>syncreads ]
+        [ f_asyncreads>> >>asyncreads ]
+        [ f_namemax>> >>name-max ]
+        [ f_owner>> >>owner ]
+        [ f_fsid>> 2 <direct-uint-array> >array >>id ]
+        [ f_fstypename>> utf8 alien>string >>type ]
+        [ f_mntfromname>> utf8 alien>string >>device-name ]
+        [ f_mntonname>> utf8 alien>string >>mount-point ]
     } cleave ;
 
 M: freebsd file-system-statvfs ( path -- byte-array )
-    "statvfs" <c-object> [ statvfs io-error ] keep ;
+    \ statvfs <struct> [ \ statvfs io-error ] keep ;
 
 M: freebsd statvfs>file-system-info ( file-system-info statvfs -- file-system-info )
     {
-        [ statvfs-f_favail >>files-available ]
-        [ statvfs-f_frsize >>preferred-block-size ]
+        [ f_favail>> >>files-available ]
+        [ f_frsize>> >>preferred-block-size ]
     } cleave ;
 
 M: freebsd file-systems ( -- array )
     f 0 0 getfsstat dup io-error
-    "statfs" <c-array> dup dup length 0 getfsstat io-error
-    "statfs" heap-size group
-    [ statfs-f_mntonname alien>native-string file-system-info ] map ;
+    \ statfs <struct> dup dup length 0 getfsstat io-error
+    statfs heap-size group
+    [ f_mntonname>> alien>native-string file-system-info ] map ;
index a8eb9b65a040ce940439728d1d2f155a6613e730..bcf3d5f5a491a9bbee462d8ccee4b6300ed4ae98 100644 (file)
@@ -5,7 +5,7 @@ io.backend io.encodings.utf8 io.files io.files.info io.streams.string
 io.files.unix kernel math.order namespaces sequences sorting
 system unix unix.statfs.linux unix.statvfs.linux io.files.links
 specialized-arrays.direct.uint arrays io.files.info.unix assocs
-io.pathnames unix.types ;
+io.pathnames unix.types classes.struct ;
 FROM: csv => delimiter ;
 IN: io.files.info.unix.linux
 
@@ -15,30 +15,30 @@ namelen ;
 M: linux new-file-system-info linux-file-system-info new ;
 
 M: linux file-system-statfs ( path -- byte-array )
-    "statfs64" <c-object> [ statfs64 io-error ] keep ;
+    \ statfs64 <struct> [ statfs64 io-error ] keep ;
 
 M: linux statfs>file-system-info ( struct -- statfs )
     {
-        [ statfs64-f_type >>type ]
-        [ statfs64-f_bsize >>block-size ]
-        [ statfs64-f_blocks >>blocks ]
-        [ statfs64-f_bfree >>blocks-free ]
-        [ statfs64-f_bavail >>blocks-available ]
-        [ statfs64-f_files >>files ]
-        [ statfs64-f_ffree >>files-free ]
-        [ statfs64-f_fsid 2 <direct-uint-array> >array >>id ]
-        [ statfs64-f_namelen >>namelen ]
-        [ statfs64-f_frsize >>preferred-block-size ]
+        [ f_type>> >>type ]
+        [ f_bsize>> >>block-size ]
+        [ f_blocks>> >>blocks ]
+        [ f_bfree>> >>blocks-free ]
+        [ f_bavail>> >>blocks-available ]
+        [ f_files>> >>files ]
+        [ f_ffree>> >>files-free ]
+        [ f_fsid>> 2 <direct-uint-array> >array >>id ]
+        [ f_namelen>> >>namelen ]
+        [ f_frsize>> >>preferred-block-size ]
         ! [ statfs64-f_spare >>spare ]
     } cleave ;
 
 M: linux file-system-statvfs ( path -- byte-array )
-    "statvfs64" <c-object> [ statvfs64 io-error ] keep ;
+    \ statvfs64 <struct> [ statvfs64 io-error ] keep ;
 
 M: linux statvfs>file-system-info ( struct -- statfs )
     {
-        [ statvfs64-f_flag >>flags ]
-        [ statvfs64-f_namemax >>name-max ]
+        [ f_flag>> >>flags ]
+        [ f_namemax>> >>name-max ]
     } cleave ;
 
 TUPLE: mtab-entry file-system-name mount-point type options
index cfc13ba015790a0c295f9d5e54e52857e0705ba6..bd40f3953465e653c70fdb3303360ece1455cfda 100644 (file)
@@ -4,7 +4,7 @@ USING: accessors alien.c-types alien.strings combinators
 grouping io.encodings.utf8 io.files kernel math sequences
 system unix io.files.unix specialized-arrays.direct.uint arrays
 unix.statfs.macosx unix.statvfs.macosx unix.getfsstat.macosx
-io.files.info.unix io.files.info ;
+io.files.info.unix io.files.info classes.struct struct-arrays ;
 IN: io.files.info.unix.macosx
 
 TUPLE: macosx-file-system-info < unix-file-system-info
@@ -12,41 +12,39 @@ io-size owner type-id filesystem-subtype ;
 
 M: macosx file-systems ( -- array )
     f <void*> dup 0 getmntinfo64 dup io-error
-    [ *void* ] dip
-    "statfs64" heap-size [ * memory>byte-array ] keep group
-    [ statfs64-f_mntonname utf8 alien>string file-system-info ] map ;
-    ! [ [ new-file-system-info ] dip statfs>file-system-info ] map ;
+    [ *void* ] dip \ statfs64 <direct-struct-array>
+    [ f_mntonname>> utf8 alien>string file-system-info ] { } map-as ;
 
 M: macosx new-file-system-info macosx-file-system-info new ;
 
 M: macosx file-system-statfs ( normalized-path -- statfs )
-    "statfs64" <c-object> [ statfs64 io-error ] keep ;
+    \ statfs64 <struct> [ statfs64 io-error ] keep ;
 
 M: macosx file-system-statvfs ( normalized-path -- statvfs )
-    "statvfs" <c-object> [ statvfs io-error ] keep ;
+    \ statvfs <struct> [ statvfs io-error ] keep ;
 
 M: macosx statfs>file-system-info ( file-system-info byte-array -- file-system-info' )
     {
-        [ statfs64-f_bsize >>block-size ]
-        [ statfs64-f_iosize >>io-size ]
-        [ statfs64-f_blocks >>blocks ]
-        [ statfs64-f_bfree >>blocks-free ]
-        [ statfs64-f_bavail >>blocks-available ]
-        [ statfs64-f_files >>files ]
-        [ statfs64-f_ffree >>files-free ]
-        [ statfs64-f_fsid 2 <direct-uint-array> >array >>id ]
-        [ statfs64-f_owner >>owner ]
-        [ statfs64-f_type >>type-id ]
-        [ statfs64-f_flags >>flags ]
-        [ statfs64-f_fssubtype >>filesystem-subtype ]
-        [ statfs64-f_fstypename utf8 alien>string >>type ]
-        [ statfs64-f_mntonname utf8 alien>string >>mount-point ]
-        [ statfs64-f_mntfromname utf8 alien>string >>device-name ]
+        [ f_bsize>> >>block-size ]
+        [ f_iosize>> >>io-size ]
+        [ f_blocks>> >>blocks ]
+        [ f_bfree>> >>blocks-free ]
+        [ f_bavail>> >>blocks-available ]
+        [ f_files>> >>files ]
+        [ f_ffree>> >>files-free ]
+        [ f_fsid>> >>id ]
+        [ f_owner>> >>owner ]
+        [ f_type>> >>type-id ]
+        [ f_flags>> >>flags ]
+        [ f_fssubtype>> >>filesystem-subtype ]
+        [ f_fstypename>> utf8 alien>string >>type ]
+        [ f_mntonname>> utf8 alien>string >>mount-point ]
+        [ f_mntfromname>> utf8 alien>string >>device-name ]
     } cleave ;
 
 M: macosx statvfs>file-system-info ( file-system-info byte-array -- file-system-info' )
     {
-        [ statvfs-f_frsize >>preferred-block-size ]
-        [ statvfs-f_favail >>files-available ]
-        [ statvfs-f_namemax >>name-max ]
+        [ f_frsize>> >>preferred-block-size ]
+        [ f_favail>> >>files-available ]
+        [ f_namemax>> >>name-max ]
     } cleave ;
index 4f284b5f44810a3eedf5963cd92147f01201fc82..015b8d3250e27afd8e228f58afdc87095a6a01cb 100644 (file)
@@ -4,7 +4,7 @@ USING: alien.syntax kernel unix.stat math unix
 combinators system io.backend accessors alien.c-types
 io.encodings.utf8 alien.strings unix.types io.files.unix
 io.files io.files.info unix.statvfs.netbsd unix.getfsstat.netbsd arrays
-grouping sequences io.encodings.utf8
+grouping sequences io.encodings.utf8 classes.struct
 specialized-arrays.direct.uint io.files.info.unix ;
 IN: io.files.info.unix.netbsd
 
@@ -16,38 +16,37 @@ idx mount-from ;
 M: netbsd new-file-system-info netbsd-file-system-info new ;
 
 M: netbsd file-system-statvfs
-    "statvfs" <c-object> [ statvfs io-error ] keep ;
+    \ statvfs <struct> [ statvfs io-error ] keep ;
 
 M: netbsd statvfs>file-system-info ( file-system-info statvfs -- file-system-info' )
     {
-        [ statvfs-f_flag >>flags ]
-        [ statvfs-f_bsize >>block-size ]
-        [ statvfs-f_frsize >>preferred-block-size ]
-        [ statvfs-f_iosize >>io-size ]
-        [ statvfs-f_blocks >>blocks ]
-        [ statvfs-f_bfree >>blocks-free ]
-        [ statvfs-f_bavail >>blocks-available ]
-        [ statvfs-f_bresvd >>blocks-reserved ]
-        [ statvfs-f_files >>files ]
-        [ statvfs-f_ffree >>files-free ]
-        [ statvfs-f_favail >>files-available ]
-        [ statvfs-f_fresvd >>files-reserved ]
-        [ statvfs-f_syncreads >>sync-reads ]
-        [ statvfs-f_syncwrites >>sync-writes ]
-        [ statvfs-f_asyncreads >>async-reads ]
-        [ statvfs-f_asyncwrites >>async-writes ]
-        [ statvfs-f_fsidx 2 <direct-uint-array> >array >>idx ]
-        [ statvfs-f_fsid >>id ]
-        [ statvfs-f_namemax >>name-max ]
-        [ statvfs-f_owner >>owner ]
-        ! [ statvfs-f_spare >>spare ]
-        [ statvfs-f_fstypename utf8 alien>string >>type ]
-        [ statvfs-f_mntonname utf8 alien>string >>mount-point ]
-        [ statvfs-f_mntfromname utf8 alien>string >>device-name ]
+        [ f_flag>> >>flags ]
+        [ f_bsize>> >>block-size ]
+        [ f_frsize>> >>preferred-block-size ]
+        [ f_iosize>> >>io-size ]
+        [ f_blocks>> >>blocks ]
+        [ f_bfree>> >>blocks-free ]
+        [ f_bavail>> >>blocks-available ]
+        [ f_bresvd>> >>blocks-reserved ]
+        [ f_files>> >>files ]
+        [ f_ffree>> >>files-free ]
+        [ f_favail>> >>files-available ]
+        [ f_fresvd>> >>files-reserved ]
+        [ f_syncreads>> >>sync-reads ]
+        [ f_syncwrites>> >>sync-writes ]
+        [ f_asyncreads>> >>async-reads ]
+        [ f_asyncwrites>> >>async-writes ]
+        [ f_fsidx>> 2 <direct-uint-array> >array >>idx ]
+        [ f_fsid>> >>id ]
+        [ f_namemax>> >>name-max ]
+        [ f_owner>> >>owner ]
+        [ f_fstypename>> utf8 alien>string >>type ]
+        [ f_mntonname>> utf8 alien>string >>mount-point ]
+        [ f_mntfromname>> utf8 alien>string >>device-name ]
     } cleave ;
 
 M: netbsd file-systems ( -- array )
     f 0 0 getvfsstat dup io-error
-    "statvfs" <c-array> dup dup length 0 getvfsstat io-error
-    "statvfs" heap-size group
-    [ statvfs-f_mntonname utf8 alien>string file-system-info ] map ;
+    \ statvfs <c-type-array> dup dup length 0 getvfsstat io-error
+    \ statvfs heap-size group
+    [ f_mntonname>> utf8 alien>string file-system-info ] map ;
index 0fe4c4bec0243341a743fdc25e0d0c9aca6b5e28..507abccdac29cfd20b1b9578b91ea5e9984b4d5e 100644 (file)
@@ -4,7 +4,8 @@ USING: accessors alien.c-types alien.strings alien.syntax
 combinators io.backend io.files io.files.info io.files.unix kernel math
 sequences system unix unix.getfsstat.openbsd grouping
 unix.statfs.openbsd unix.statvfs.openbsd unix.types
-specialized-arrays.direct.uint arrays io.files.info.unix ;
+specialized-arrays.direct.uint arrays io.files.info.unix
+classes.struct ;
 IN: io.files.unix.openbsd
 
 TUPLE: freebsd-file-system-info < unix-file-system-info
@@ -14,42 +15,39 @@ owner ;
 M: openbsd new-file-system-info freebsd-file-system-info new ;
 
 M: openbsd file-system-statfs
-    "statfs" <c-object> [ statfs io-error ] keep ;
+    \ statfs <struct> [ statfs io-error ] keep ;
 
 M: openbsd statfs>file-system-info ( file-system-info statfs -- file-system-info' )
     {
-        [ statfs-f_flags >>flags ]
-        [ statfs-f_bsize >>block-size ]
-        [ statfs-f_iosize >>io-size ]
-        [ statfs-f_blocks >>blocks ]
-        [ statfs-f_bfree >>blocks-free ]
-        [ statfs-f_bavail >>blocks-available ]
-        [ statfs-f_files >>files ]
-        [ statfs-f_ffree >>files-free ]
-        [ statfs-f_favail >>files-available ]
-        [ statfs-f_syncwrites >>sync-writes ]
-        [ statfs-f_syncreads >>sync-reads ]
-        [ statfs-f_asyncwrites >>async-writes ]
-        [ statfs-f_asyncreads >>async-reads ]
-        [ statfs-f_fsid 2 <direct-uint-array> >array >>id ]
-        [ statfs-f_namemax >>name-max ]
-        [ statfs-f_owner >>owner ]
-        ! [ statfs-f_spare >>spare ]
-        [ statfs-f_fstypename alien>native-string >>type ]
-        [ statfs-f_mntonname alien>native-string >>mount-point ]
-        [ statfs-f_mntfromname alien>native-string >>device-name ]
+        [ f_flags>> >>flags ]
+        [ f_bsize>> >>block-size ]
+        [ f_iosize>> >>io-size ]
+        [ f_blocks>> >>blocks ]
+        [ f_bfree>> >>blocks-free ]
+        [ f_bavail>> >>blocks-available ]
+        [ f_files>> >>files ]
+        [ f_ffree>> >>files-free ]
+        [ f_favail>> >>files-available ]
+        [ f_syncwrites>> >>sync-writes ]
+        [ f_syncreads>> >>sync-reads ]
+        [ f_asyncwrites>> >>async-writes ]
+        [ f_asyncreads>> >>async-reads ]
+        [ f_fsid>> 2 <direct-uint-array> >array >>id ]
+        [ f_namemax>> >>name-max ]
+        [ f_owner>> >>owner ]
+        [ f_fstypename>> alien>native-string >>type ]
+        [ f_mntonname>> alien>native-string >>mount-point ]
+        [ f_mntfromname>> alien>native-string >>device-name ]
     } cleave ;
 
 M: openbsd file-system-statvfs ( normalized-path -- statvfs )
-    "statvfs" <c-object> [ statvfs io-error ] keep ;
+    \ statvfs <struct> [ statvfs io-error ] keep ;
 
 M: openbsd statvfs>file-system-info ( file-system-info statvfs -- file-system-info' )
-    {
-        [ statvfs-f_frsize >>preferred-block-size ]
-    } cleave ;
+    f_frsize>> >>preferred-block-size ;
 
 M: openbsd file-systems ( -- seq )
     f 0 0 getfsstat dup io-error
-    "statfs" <c-array> dup dup length 0 getfsstat io-error 
-    "statfs" heap-size group 
-    [ statfs-f_mntonname alien>native-string file-system-info ] map ;
+    statfs <c-type-array> dup dup length 0 getfsstat io-error 
+    statfs heap-size group 
+    [ f_mntonname>> alien>native-string file-system-info ] map ;
index 94cb60a2c6b43aac945f04987f663c75bd727e34..20b3513c6cd26b47d51983e25ed4fdcdccd51368 100644 (file)
@@ -4,7 +4,7 @@ USING: accessors kernel system math math.bitwise strings arrays
 sequences combinators combinators.short-circuit alien.c-types
 vocabs.loader calendar calendar.unix io.files.info
 io.files.types io.backend io.directories unix unix.stat unix.time unix.users
-unix.groups ;
+unix.groups classes.struct struct-arrays ;
 IN: io.files.info.unix
 
 TUPLE: unix-file-system-info < file-system-info
@@ -69,19 +69,19 @@ M: unix stat>file-info ( stat -- file-info )
     [ new-file-info ] dip
     {
         [ stat>type >>type ]
-        [ stat-st_size >>size ]
-        [ stat-st_mode >>permissions ]
-        [ stat-st_ctimespec timespec>unix-time >>created ]
-        [ stat-st_mtimespec timespec>unix-time >>modified ]
-        [ stat-st_atimespec timespec>unix-time >>accessed ]
-        [ stat-st_uid >>uid ]
-        [ stat-st_gid >>gid ]
-        [ stat-st_dev >>dev ]
-        [ stat-st_ino >>ino ]
-        [ stat-st_nlink >>nlink ]
-        [ stat-st_rdev >>rdev ]
-        [ stat-st_blocks >>blocks ]
-        [ stat-st_blksize >>blocksize ]
+        [ st_size>> >>size ]
+        [ st_mode>> >>permissions ]
+        [ st_ctimespec>> timespec>unix-time >>created ]
+        [ st_mtimespec>> timespec>unix-time >>modified ]
+        [ st_atimespec>> timespec>unix-time >>accessed ]
+        [ st_uid>> >>uid ]
+        [ st_gid>> >>gid ]
+        [ st_dev>> >>dev ]
+        [ st_ino>> >>ino ]
+        [ st_nlink>> >>nlink ]
+        [ st_rdev>> >>rdev ]
+        [ st_blocks>> >>blocks ]
+        [ st_blksize>> >>blocksize ]
         [ drop dup blocks>> standard-unix-block-size * >>size-on-disk ]
     } cleave ;
 
@@ -98,12 +98,12 @@ M: unix stat>file-info ( stat -- file-info )
     } case ;
 
 M: unix stat>type ( stat -- type )
-    stat-st_mode n>file-type ;
+    st_mode>> n>file-type ;
 
 <PRIVATE
 
 : stat-mode ( path -- mode )
-    normalize-path file-status stat-st_mode ;
+    normalize-path file-status st_mode>> ;
 
 : chmod-set-bit ( path mask ? -- )
     [ dup stat-mode ] 2dip
@@ -179,14 +179,12 @@ M: unix copy-file-and-info ( from to -- )
 
 <PRIVATE
 
-: make-timeval-array ( array -- byte-array )
-    [ [ "timeval" <c-object> ] unless* ] map concat ;
-
 : timestamp>timeval ( timestamp -- timeval )
     unix-1970 time- duration>microseconds make-timeval ;
 
 : timestamps>byte-array ( timestamps -- byte-array )
-    [ dup [ timestamp>timeval ] when ] map make-timeval-array ;
+    [ [ timestamp>timeval ] [ \ timeval <struct> ] if* ] map
+    \ timeval >struct-array ;
 
 PRIVATE>
 
@@ -202,8 +200,7 @@ PRIVATE>
     f swap 2array set-file-times ;
 
 : set-file-ids ( path uid gid -- )
-    [ normalize-path ] 2dip
-    [ [ -1 ] unless* ] bi@ chown io-error ;
+    [ normalize-path ] 2dip [ -1 or ] bi@ chown io-error ;
 
 GENERIC: set-file-user ( path string/id -- )
 
diff --git a/basis/unix/stat/freebsd/32/32.factor b/basis/unix/stat/freebsd/32/32.factor
deleted file mode 100644 (file)
index 3692dea..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-USING: kernel alien.syntax math ;
-
-IN: unix.stat
-
-! FreeBSD 8.0-CURRENT
-
-C-STRUCT: stat
-    { "__dev_t"    "st_dev" }
-    { "ino_t"      "st_ino" }
-    { "mode_t"     "st_mode" }
-    { "nlink_t"    "st_nlink" }
-    { "uid_t"      "st_uid" }
-    { "gid_t"      "st_gid" }
-    { "__dev_t"    "st_rdev" }
-    { "timespec"   "st_atimespec" }
-    { "timespec"   "st_mtimespec" }
-    { "timespec"   "st_ctimespec" }
-    { "off_t"      "st_size" }
-    { "blkcnt_t"   "st_blocks" }
-    { "blksize_t"  "st_blksize" }
-    { "fflags_t"   "st_flags" }
-    { "__uint32_t" "st_gen" }
-    { "__int32_t"  "st_lspare" }
-    { "timespec"   "st_birthtimespec" }
-! not sure about the padding here.
-    { "__uint32_t" "pad0" }
-    { "__uint32_t" "pad1" } ;
-
-FUNCTION: int stat  ( char* pathname, stat* buf ) ;
-FUNCTION: int lstat ( char* pathname, stat* buf ) ;
diff --git a/basis/unix/stat/freebsd/32/tags.txt b/basis/unix/stat/freebsd/32/tags.txt
deleted file mode 100644 (file)
index 6bf6830..0000000
+++ /dev/null
@@ -1 +0,0 @@
-unportable
diff --git a/basis/unix/stat/freebsd/64/64.factor b/basis/unix/stat/freebsd/64/64.factor
deleted file mode 100644 (file)
index 73ba676..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-USING: kernel alien.syntax math ;
-IN: unix.stat
-
-! FreeBSD 8.0-CURRENT
-! untested
-
-C-STRUCT: stat
-    { "__dev_t"    "st_dev" }
-    { "ino_t"      "st_ino" }
-    { "mode_t"     "st_mode" }
-    { "nlink_t"    "st_nlink" }
-    { "uid_t"      "st_uid" }
-    { "gid_t"      "st_gid" }
-    { "__dev_t"    "st_rdev" }
-    { "timespec"   "st_atimespec" }
-    { "timespec"   "st_mtimespec" }
-    { "timespec"   "st_ctimespec" }
-    { "off_t"      "st_size" }
-    { "blkcnt_t"   "st_blocks" }
-    { "blksize_t"  "st_blksize" }
-    { "fflags_t"   "st_flags" }
-    { "__uint32_t" "st_gen" }
-    { "__int32_t"  "st_lspare" }
-    { "timespec"   "st_birthtimespec" }
-! not sure about the padding here.
-    { "__uint32_t" "pad0" }
-    { "__uint32_t" "pad1" } ;
-
-FUNCTION: int stat  ( char* pathname, stat* buf ) ;
-FUNCTION: int lstat ( char* pathname, stat* buf ) ;
diff --git a/basis/unix/stat/freebsd/64/tags.txt b/basis/unix/stat/freebsd/64/tags.txt
deleted file mode 100644 (file)
index 6bf6830..0000000
+++ /dev/null
@@ -1 +0,0 @@
-unportable
index 299d0ecab58f14381a0dc5178f504ad0d577acfd..02f31f3682e34ab176c6ba6dbd36f089f1456e89 100644 (file)
@@ -1,7 +1,27 @@
-USING: layouts combinators vocabs.loader ;
+USING: kernel alien.syntax math classes.struct ;
 IN: unix.stat
 
-cell-bits {
-    { 32 [ "unix.stat.freebsd.32" require ] }
-    { 64 [ "unix.stat.freebsd.64" require ] }
-} case
+! FreeBSD 8.0-CURRENT
+
+STRUCT: stat
+    { st_dev __dev_t }
+    { st_ino ino_t }
+    { st_mode mode_t }
+    { st_nlink nlink_t }
+    { st_uid uid_t }
+    { st_gid git_t }
+    { st_rdev __dev_t }
+    { st_atimespec timespec }
+    { st_mtimespec timespec }
+    { st_ctimespec timespec }
+    { st_size off_t }
+    { st_blocks blkcnt_t }
+    { st_blksize blksize_t }
+    { st_flags fflags_t }
+    { st_gen _uint32_t }
+    { st_lspare __int32_t }
+    { st_birthtimespec timespec }
+    { pad0 __int32_t[2] }
+
+FUNCTION: int stat  ( char* pathname, stat* buf ) ;
+FUNCTION: int lstat ( char* pathname, stat* buf ) ;
index 98c4b90f3251a6924a027bf9e852aff31a71a567..324237d64557f252c5819c074f65a1b4009bb700 100644 (file)
@@ -1,25 +1,24 @@
-USING: kernel alien.syntax math sequences unix
-alien.c-types arrays accessors combinators ;
+USING: kernel alien.syntax math classes.struct ;
 IN: unix.stat
 
 ! stat64
-C-STRUCT: stat
-    { "dev_t"      "st_dev" }
-    { "ushort"     "__pad1" }
-    { "__ino_t"     "__st_ino" }
-    { "mode_t"     "st_mode" }
-    { "nlink_t"    "st_nlink" }
-    { "uid_t"      "st_uid" }
-    { "gid_t"      "st_gid" }
-    { "dev_t"      "st_rdev" }
-    { { "ushort" 2 } "__pad2" }
-    { "off64_t"    "st_size" }
-    { "blksize_t"  "st_blksize" }
-    { "blkcnt64_t" "st_blocks" }
-    { "timespec"   "st_atimespec" }
-    { "timespec"   "st_mtimespec" }
-    { "timespec"   "st_ctimespec" }
-    { "ulonglong"  "st_ino" } ;
+STRUCT: stat
+    { st_dev dev_t }
+    { __pad1 ushort }
+    { __st_ino __ino_t }
+    { st_mode mode_t }
+    { st_nlink nlink_t }
+    { st_uid uid_t }
+    { st_gid gid_t }
+    { st_rdev dev_t }
+    { __pad2 ushort[2] }
+    { st_size off64_t }
+    { st_blksize blksize_t }
+    { st_blocks blkcnt64_t }
+    { st_atimespec timespec }
+    { st_mtimespec timespec }
+    { st_ctimespec timespec }
+    { st_ino ulonglong } ;
 
 FUNCTION: int __xstat64  ( int ver, char* pathname, stat* buf ) ;
 FUNCTION: int __lxstat64 ( int ver, char* pathname, stat* buf ) ;
index 581525dda0a9faa7ac215fcaf2066b9bb731a6d2..cfd6553ca3b96ca268d091c31e45fcac33d6604e 100644 (file)
@@ -1,27 +1,24 @@
-USING: kernel alien.syntax math sequences unix
-alien.c-types arrays accessors combinators ;
+USING: kernel alien.syntax math classes.struct ;
 IN: unix.stat
 
 ! Ubuntu 7.10 64-bit
 
-C-STRUCT: stat
-    { "dev_t"     "st_dev" }
-    { "ino_t"     "st_ino" }
-    { "nlink_t"   "st_nlink" }
-    { "mode_t"    "st_mode" }
-    { "uid_t"     "st_uid" }
-    { "gid_t"     "st_gid" }
-    { "int"       "pad0" }
-    { "dev_t"     "st_rdev" }
-    { "off64_t"     "st_size" }
-    { "blksize_t" "st_blksize" }
-    { "blkcnt64_t"  "st_blocks" }
-    { "timespec"  "st_atimespec" }
-    { "timespec"  "st_mtimespec" }
-    { "timespec"  "st_ctimespec" }
-    { "long"      "__unused0" }
-    { "long"      "__unused1" }
-    { "long"      "__unused2" } ;
+STRUCT: stat
+    { st_dev dev_t }
+    { st_ino ino_t }
+    { st_nlink nlink_t }
+    { st_mode mode_t }
+    { st_uid uid_t }
+    { st_gid gid_t }
+    { pad0 int }
+    { st_rdev dev_t }
+    { st_size off64_t }
+    { st_blksize blksize_t }
+    { st_blocks blkcnt64_t }
+    { st_atimespec timespec }
+    { st_mtimespec timespec }
+    { st_ctimespec timespec }
+    { __unused0 long[3] } ;
 
 FUNCTION: int __xstat64  ( int ver, char* pathname, stat* buf ) ;
 FUNCTION: int __lxstat64 ( int ver, char* pathname, stat* buf ) ;
index 2656ec71e104975f0705b00e8da28d8e9044ed72..afab727ddb5a011045d1bab82bc17b811a56838a 100644 (file)
@@ -1,30 +1,30 @@
-USING: kernel alien.syntax math unix math.bitwise
-alien.c-types alien sequences grouping accessors combinators ;
+USING: alien.c-types arrays accessors combinators classes.struct
+alien.syntax ;
 IN: unix.stat
 
 ! Mac OS X ppc
 
 ! stat64 structure
-C-STRUCT: stat
-    { "dev_t"      "st_dev" }
-    { "mode_t"     "st_mode" }
-    { "nlink_t"    "st_nlink" }
-    { "ino64_t"    "st_ino" }
-    { "uid_t"      "st_uid" }
-    { "gid_t"      "st_gid" }
-    { "dev_t"      "st_rdev" }
-    { "timespec"   "st_atimespec" }
-    { "timespec"   "st_mtimespec" }
-    { "timespec"   "st_ctimespec" }
-    { "timespec"   "st_birthtimespec" }
-    { "off_t"      "st_size" }
-    { "blkcnt_t"   "st_blocks" }
-    { "blksize_t"  "st_blksize" }
-    { "__uint32_t" "st_flags" }
-    { "__uint32_t" "st_gen" }
-    { "__int32_t"  "st_lspare" }
-    { "__int64_t"  "st_qspare0" }
-    { "__int64_t"  "st_qspare1" } ;
+STRUCT: stat
+    { st_dev dev_t }
+    { st_mode mode_t }
+    { st_nlink nlink_t }
+    { st_ino ino64_t }
+    { st_uid uid_t }
+    { st_gid gid_t }
+    { st_rdev dev_t }
+    { st_atimespec timespec }
+    { st_mtimespec timespec }
+    { st_ctimespec timespec }
+    { st_birthtimespec timespec }
+    { st_size off_t }
+    { st_blocks blkcnt_t }
+    { st_blksize blksize_t }
+    { st_flags __uint32_t }
+    { st_gen __uint32_t }
+    { st_lspare __int32_t }
+    { st_qspare0 __int64_t }
+    { st_qspare1 __int64_t } ;
 
 FUNCTION: int stat64  ( char* pathname, stat* buf ) ;
 FUNCTION: int lstat64 ( char* pathname, stat* buf ) ;
index c4cf5cc7a0951773d0df22eece0d5dbd47aa8b81..98403313b8728b5920814cb8aa8d5de11dac2e39 100644 (file)
@@ -1,26 +1,26 @@
-USING: kernel alien.syntax math ;
+USING: kernel alien.syntax math classes.struct ;
 IN: unix.stat
 
 ! NetBSD 4.0
 
-C-STRUCT: stat
-    { "dev_t" "st_dev" }
-    { "mode_t" "st_mode" }
-    { "ino_t" "st_ino" }
-    { "nlink_t" "st_nlink" }
-    { "uid_t" "st_uid" }
-    { "gid_t" "st_gid" }
-    { "dev_t" "st_rdev" }
-    { "timespec" "st_atimespec" }
-    { "timespec" "st_mtimespec" }
-    { "timespec" "st_ctimespec" }
-    { "timespec" "st_birthtimespec" }
-    { "off_t" "st_size" }
-    { "blkcnt_t" "st_blocks" }
-    { "blksize_t" "st_blksize" }
-    { "uint32_t" "st_flags" }
-    { "uint32_t" "st_gen" }
-    { { "uint32_t" 2 } "st_qspare" } ;
+STRUCT: stat
+    { st_dev dev_t }
+    { st_mode mode_t }
+    { st_ino ino_t }
+    { st_nlink nlink_t }
+    { st_uid uid_t }
+    { st_gid gid_t }
+    { st_rdev dev_t }
+    { st_atimespec timespec }
+    { st_mtimespec timespec }
+    { st_ctimespec timespec }
+    { st_birthtimespec timespec }
+    { st_size off_t }
+    { st_blocks blkcnt_t }
+    { st_blksize blksize_t }
+    { st_flags uint32_t }
+    { st_gen uint32_t }
+    { st_qspare uint32_t[2] } ;
 
 FUNCTION: int __stat30  ( char* pathname, stat* buf ) ;
 FUNCTION: int __lstat30 ( char* pathname, stat* buf ) ;
index cd9286c6ba410be22bea6375fae133fad9884e13..c532e7e9ff655484c3465c1c8609bb3070a3752f 100644 (file)
@@ -1,26 +1,26 @@
-USING: kernel alien.syntax math ;
+USING: kernel alien.syntax math classes.struct ;
 IN: unix.stat
 
 ! NetBSD 4.0
 
-C-STRUCT: stat
-    { "dev_t" "st_dev" }
-    { "ino_t" "st_ino" }
-    { "mode_t" "st_mode" }
-    { "nlink_t" "st_nlink" }
-    { "uid_t" "st_uid" }
-    { "gid_t" "st_gid" }
-    { "dev_t" "st_rdev" }
-    { "timespec" "st_atimespec" }
-    { "timespec" "st_mtimespec" }
-    { "timespec" "st_ctimespec" }
-    { "off_t" "st_size" }
-    { "blkcnt_t" "st_blocks" }
-    { "blksize_t" "st_blksize" }
-    { "uint32_t" "st_flags" }
-    { "uint32_t" "st_gen" }
-    { "uint32_t" "st_spare0" }
-    { "timespec" "st_birthtimespec" } ;
+STRUCT: stat
+    { st_dev dev_t }
+    { st_ino ino_t }
+    { st_mode mode_t }
+    { st_nlink nlink_t }
+    { st_uid uid_t }
+    { st_gid gid_t }
+    { st_rdev dev_t }
+    { st_atimespec timespec }
+    { st_mtimespec timespec }
+    { st_ctimespec timespec }
+    { st_size off_t }
+    { st_blocks blkcnt_t }
+    { st_blksize blksize_t }
+    { st_flags uint32_t }
+    { st_gen uint32_t }
+    { st_spare0 uint32_t }
+    { st_birthtimespec timespec } ;
 
 FUNCTION: int __stat13 ( char* pathname, stat* buf ) ;
 FUNCTION: int __lstat13 ( char* pathname, stat* buf ) ;
index f76d4c6e18e2331fa50b19e62bd4fa674bbbaf8b..f326a5592d2e640742e2a104040433f34ea7c448 100644 (file)
@@ -1,28 +1,28 @@
-USING: kernel alien.syntax math ;
+USING: kernel alien.syntax math classes.struct ;
 IN: unix.stat
 
 ! OpenBSD 4.2
 
-C-STRUCT: stat
-    { "dev_t" "st_dev" }
-    { "ino_t" "st_ino" }
-    { "mode_t" "st_mode" }
-    { "nlink_t" "st_nlink" }
-    { "uid_t" "st_uid" }
-    { "gid_t" "st_gid" }
-    { "dev_t" "st_rdev" }
-    { "int32_t" "st_lspare0" }
-    { "timespec" "st_atimespec" }
-    { "timespec" "st_mtimespec" }
-    { "timespec" "st_ctimespec" }
-    { "off_t" "st_size" }
-    { "int64_t" "st_blocks" }
-    { "u_int32_t" "st_blksize" }
-    { "u_int32_t" "st_flags" }
-    { "u_int32_t" "st_gen" }
-    { "int32_t" "st_lspare1" }
-    { "timespec" "st_birthtimespec" }
-    { { "int64_t" 2 } "st_qspare" } ;
+STRUCT: stat
+    { st_dev dev_t }
+    { st_ino ino_t }
+    { st_mode mode_t }
+    { st_nlink nlink_t }
+    { st_uid uid_t }
+    { st_gid gid_t }
+    { st_rdev dev_ti }
+    { st_lspare0 int32_t }
+    { st_atimespec timespec }
+    { st_mtimespec timespec }
+    { st_ctimespec timespec }
+    { st_size off_t }
+    { st_blocks int64_t }
+    { st_blksize u_int32_t }
+    { st_flags u_int32_t }
+    { st_gen u_int32_t }
+    { st_lspare1 int32_t }
+    { st_birthtimespec timespec }
+    { st_qspare int64_t[2] } ;
 
 FUNCTION: int stat  ( char* pathname, stat* buf ) ;
 FUNCTION: int lstat ( char* pathname, stat* buf ) ;
index c3ab099d380e90a08381e7cfb86702c664cbc864..de5b4055d975d2ea43b4c0d9b34953f197eac05b 100644 (file)
@@ -1,5 +1,5 @@
 USING: kernel system combinators alien.syntax alien.c-types
-math io.backend.unix vocabs.loader unix ;
+math io.backend.unix vocabs.loader unix classes.struct ;
 IN: unix.stat
 
 ! File Types
@@ -15,8 +15,8 @@ CONSTANT: S_IFLNK  OCT: 120000   ! Symbolic link.
 CONSTANT: S_IFSOCK OCT: 140000   ! Socket.
 CONSTANT: S_IFWHT  OCT: 160000   ! Whiteout.
 
-C-STRUCT: fsid
-    { { "int" 2 } "__val" } ;
+STRUCT: fsid
+    { __val int[2] } ;
 
 TYPEDEF: fsid __fsid_t
 TYPEDEF: fsid fsid_t
@@ -30,7 +30,7 @@ TYPEDEF: fsid fsid_t
 } case >>
 
 : file-status ( pathname -- stat )
-    "stat" <c-object> [ [ stat ] unix-system-call drop ] keep ;
+    \ stat <struct> [ [ stat ] unix-system-call drop ] keep ;
 
 : link-status ( pathname -- stat )
-    "stat" <c-object> [ [ lstat ] unix-system-call drop ] keep ;
+    \ stat <struct> [ [ lstat ] unix-system-call drop ] keep ;
index 70e2d5e561938fa9ec886492c18897640636aec8..d1e7949a54a34e7035a0af38278d609ed55691ed 100644 (file)
@@ -1,34 +1,34 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.syntax unix.types unix.stat ;
+USING: alien.syntax unix.types unix.stat classes.struct ;
 IN: unix.statfs.freebsd
 
 CONSTANT: MFSNAMELEN      16            ! length of type name including null */
 CONSTANT: MNAMELEN        88            ! size of on/from name bufs
 CONSTANT: STATFS_VERSION  HEX: 20030518 ! current version number 
 
-C-STRUCT: statfs
-    { "uint32_t" "f_version" }
-    { "uint32_t" "f_type" }
-    { "uint64_t" "f_flags" }
-    { "uint64_t" "f_bsize" }
-    { "uint64_t" "f_iosize" }
-    { "uint64_t" "f_blocks" }
-    { "uint64_t" "f_bfree" }
-    { "int64_t"  "f_bavail" }
-    { "uint64_t" "f_files" }
-    { "int64_t"  "f_ffree" }
-    { "uint64_t" "f_syncwrites" }
-    { "uint64_t" "f_asyncwrites" }
-    { "uint64_t" "f_syncreads" }
-    { "uint64_t" "f_asyncreads" }
-    { { "uint64_t" 10 } "f_spare" }
-    { "uint32_t" "f_namemax" }
-    { "uid_t"    "f_owner" }
-    { "fsid_t"   "f_fsid" }
-    { { "char" 80 } "f_charspare" }
-    { { "char" MFSNAMELEN } "f_fstypename" }
-    { { "char" MNAMELEN } "f_mntfromname" }
-    { { "char" MNAMELEN } "f_mntonname" } ;
+STRUCT: statfs
+    { f_version uint32_t }
+    { f_type uint32_t }
+    { f_flags uint64_t }
+    { f_bsize uint64_t }
+    { f_iosize uint64_t }
+    { f_blocks uint64_t }
+    { f_bfree uint64_t }
+    { f_bavail int64_t }
+    { f_files uint64_t }
+    { f_ffree int64_t }
+    { f_syncwrites uint64_t }
+    { f_asyncwrites uint64_t }
+    { f_syncreads uint64_t }
+    { f_asyncreads uint64_t }
+    { f_spare uint64_t[10] }
+    { f_namemax uint32_t }
+    { f_owner uid_t }
+    { f_fsid fsid_t }
+    { f_charspare char[80] }
+    { f_fstypename { "char" MFSNAMELEN } }
+    { f_mntfromname { "char" MNAMELEN } }
+    { f_mntonname { "char" MNAMELEN } } ;
 
 FUNCTION: int statfs ( char* path, statvfs* buf ) ;
index c0db5ced1d899f220962879bf94e96c57d340c87..42d66ff1baad52095481696b2a2f39008e20e8d1 100644 (file)
@@ -1,19 +1,19 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.syntax unix.types unix.stat ;
+USING: alien.syntax unix.types unix.stat classes.struct ;
 IN: unix.statfs.linux
 
-C-STRUCT: statfs64
-    { "__SWORD_TYPE" "f_type" }
-    { "__SWORD_TYPE" "f_bsize" }
-    { "__fsblkcnt64_t" "f_blocks" }
-    { "__fsblkcnt64_t" "f_bfree" }
-    { "__fsblkcnt64_t" "f_bavail" }
-    { "__fsfilcnt64_t" "f_files" }
-    { "__fsfilcnt64_t" "f_ffree" }
-    { "__fsid_t" "f_fsid" }
-    { "__SWORD_TYPE" "f_namelen" }
-    { "__SWORD_TYPE" "f_frsize" }
-    { { "__SWORD_TYPE" 5 } "f_spare" } ;
+STRUCT: statfs64
+    { f_type __SWORD_TYPE }
+    { f_bsize __SWORD_TYPE }
+    { f_blocks __fsblkcnt64_t }
+    { f_bfree __fsblkcnt64_t }
+    { f_bavail __fsblkcnt64_t }
+    { f_files __fsblkcnt64_t }
+    { f_ffree __fsblkcnt64_t }
+    { f_fsid __fsid_t }
+    { f_namelen __SWORD_TYPE }
+    { f_frsize __SWORD_TYPE }
+    { f_spare __SWORD_TYPE[5] } ;
 
 FUNCTION: int statfs64 ( char* path, statfs64* buf ) ;
index c26294973032acc6ec91003797b1fe7d289f40c7..38709f64fe8ca4f18fd59b323b269ff807d09a1b 100644 (file)
@@ -3,7 +3,7 @@
 USING: alien.c-types io.encodings.utf8 io.encodings.string
 kernel sequences unix.stat accessors unix combinators math
 grouping system alien.strings math.bitwise alien.syntax
-unix.types ;
+unix.types classes.struct ;
 IN: unix.statfs.macosx
 
 CONSTANT: MNT_RDONLY  HEX: 00000001
@@ -65,9 +65,9 @@ CONSTANT: VFS_CTL_NEWADDR HEX: 00010004
 CONSTANT: VFS_CTL_TIMEO   HEX: 00010005
 CONSTANT: VFS_CTL_NOLOCKS HEX: 00010006
 
-C-STRUCT: vfsquery
-    { "uint32_t" "vq_flags" }
-    { { "uint32_t" 31 } "vq_spare" } ;
+STRUCT: vfsquery
+    { vq_flags uint32_t }
+    { vq_spare uint32_t[31] } ;
 
 CONSTANT: VQ_NOTRESP  HEX: 0001
 CONSTANT: VQ_NEEDAUTH HEX: 0002
@@ -95,26 +95,26 @@ CONSTANT: MFSNAMELEN 15
 CONSTANT: MNAMELEN 90
 CONSTANT: MFSTYPENAMELEN 16
 
-C-STRUCT: fsid_t
-    { { "int32_t" 2 } "val" } ;
+STRUCT: fsid_t
+    { val int32_t[2] } ;
 
-C-STRUCT: statfs64
-    { "uint32_t"        "f_bsize" }
-    { "int32_t"         "f_iosize" }
-    { "uint64_t"        "f_blocks" }
-    { "uint64_t"        "f_bfree" }
-    { "uint64_t"        "f_bavail" }
-    { "uint64_t"        "f_files" }
-    { "uint64_t"        "f_ffree" }
-    { "fsid_t"          "f_fsid" }
-    { "uid_t"           "f_owner" }
-    { "uint32_t"        "f_type" }
-    { "uint32_t"        "f_flags" }
-    { "uint32_t"        "f_fssubtype" }
-    { { "char" MFSTYPENAMELEN } "f_fstypename" }
-    { { "char" MAXPATHLEN } "f_mntonname" }
-    { { "char" MAXPATHLEN } "f_mntfromname" }
-    { { "uint32_t" 8 } "f_reserved" } ;
+STRUCT: statfs64
+    { f_bsize uint32_t }
+    { f_iosize int32_t }
+    { f_blocks uint64_t }
+    { f_bfree uint64_t }
+    { f_bavail uint64_t }
+    { f_files uint64_t }
+    { f_ffree uint64_t }
+    { f_fsid fsid_t }
+    { f_owner uid_t }
+    { f_type uint32_t }
+    { f_flags uint32_t }
+    { f_fssubtype uint32_t }
+    { f_fstypename { "char" MFSTYPENAMELEN } }
+    { f_mntonname { "char" MAXPATHLEN } }
+    { f_mntfromname { "char" MAXPATHLEN } }
+    { f_reserved uint32_t[8] } ;
 
 FUNCTION: int statfs64 ( char* path, statfs64* buf ) ;
 FUNCTION: int getmntinfo64 ( statfs64** mntbufp, int flags ) ;
index 60590be4ea0275a901d12be20ca876ac832ad849..590faf82a636a83cf905c1ff7012d07c72a92d3c 100644 (file)
@@ -1,33 +1,33 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.syntax unix.types unix.stat ;
+USING: alien.syntax unix.types unix.stat classes.struct ;
 IN: unix.statfs.openbsd
 
 CONSTANT: MFSNAMELEN 16
 CONSTANT: MNAMELEN 90
 
-C-STRUCT: statfs
-    { "u_int32_t"       "f_flags" }
-    { "u_int32_t"       "f_bsize" }
-    { "u_int32_t"       "f_iosize" }
-    { "u_int64_t"       "f_blocks" }
-    { "u_int64_t"       "f_bfree" }
-    { "int64_t"         "f_bavail" }
-    { "u_int64_t"       "f_files" }
-    { "u_int64_t"       "f_ffree" }
-    { "int64_t"         "f_favail" }
-    { "u_int64_t"       "f_syncwrites" }
-    { "u_int64_t"       "f_syncreads" }
-    { "u_int64_t"       "f_asyncwrites" }
-    { "u_int64_t"       "f_asyncreads" }
-    { "fsid_t"          "f_fsid" }
-    { "u_int32_t"       "f_namemax" }
-    { "uid_t"           "f_owner" }
-    { "u_int32_t"       "f_ctime" }
-    { { "u_int32_t" 3 } "f_spare" }
-    { { "char" MFSNAMELEN } "f_fstypename" }
-    { { "char" MNAMELEN } "f_mntonname" }
-    { { "char" MNAMELEN } "f_mntfromname" }
-    { { "char" 160 } "mount_info" } ;
+STRUCT: statfs
+    { f_flags u_int32_t }
+    { f_bsize u_int32_t }
+    { f_iosize u_int32_t }
+    { f_blocks u_int64_t }
+    { f_bfree u_int64_t }
+    { f_bavail int64_t }
+    { f_files u_int64_t }
+    { f_ffree u_int64_t }
+    { f_favail int64_t }
+    { f_syncwrites u_int64_t }
+    { f_syncreads u_int64_t }
+    { f_asyncwrites u_int64_t }
+    { f_asyncreads u_int64_t }
+    { f_fsid fsid_t }
+    { f_namemax u_int32_t }
+    { f_owner uid_t }
+    { f_ctime u_int32_t }
+    { f_spare u_int32_t[3] }
+    { f_fstypename { "char" MFSNAMELEN } }
+    { f_mntonname { "char" MNAMELEN } }
+    { f_mntfromname { "char" MNAMELEN } }
+    { mount_info char[160] } ;
 
 FUNCTION: int statfs ( char* path, statvfs* buf ) ;
index 3140b8500476d78556d961745f9364381ddbab88..2fcd0c7372f0385150971916bfadea80b07c68c0 100644 (file)
@@ -1,20 +1,20 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.syntax ;
+USING: alien.syntax classes.struct ;
 IN: unix.statvfs.freebsd
 
-C-STRUCT: statvfs
-    { "fsblkcnt_t"  "f_bavail" }
-    { "fsblkcnt_t"  "f_bfree" }
-    { "fsblkcnt_t"  "f_blocks" }
-    { "fsfilcnt_t"  "f_favail" }
-    { "fsfilcnt_t"  "f_ffree" }
-    { "fsfilcnt_t"  "f_files" }
-    { "ulong"   "f_bsize" }
-    { "ulong"   "f_flag" }
-    { "ulong"   "f_frsize" }
-    { "ulong"   "f_fsid" }
-    { "ulong"   "f_namemax" } ;
+STRUCT: statvfs
+    { f_bavail fsblkcnt_t }
+    { f_bfree fsblkcnt_t }
+    { f_blocks fsblkcnt_t }
+    { f_favail fsfilcnt_t }
+    { f_ffree fsfilcnt_t }
+    { f_files fsfilcnt_t }
+    { f_bsize ulong }
+    { f_flag ulong }
+    { f_frsize ulong }
+    { f_fsid ulong }
+    { f_namemax ulong } ;
 
 ! Flags
 CONSTANT: ST_RDONLY   HEX: 1 ! Read-only file system
index c92fef6aaaeb551d7e202dde934e1ba6984add26..6e408c8fa45214ae891bd528104e10fbec6d5a93 100644 (file)
@@ -1,21 +1,21 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.syntax ;
+USING: alien.syntax classes.struct ;
 IN: unix.statvfs.linux
 
-C-STRUCT: statvfs64
-    { "ulong" "f_bsize" }
-    { "ulong" "f_frsize" }
-    { "__fsblkcnt64_t" "f_blocks" }
-    { "__fsblkcnt64_t" "f_bfree" }
-    { "__fsblkcnt64_t" "f_bavail" }
-    { "__fsfilcnt64_t" "f_files" }
-    { "__fsfilcnt64_t" "f_ffree" }
-    { "__fsfilcnt64_t" "f_favail" }
-    { "ulong" "f_fsid" }
-    { "ulong" "f_flag" }
-    { "ulong" "f_namemax" }
-    { { "int" 6 } "__f_spare" } ;
+STRUCT: statvfs64
+    { f_bsize ulong }
+    { f_frsize ulong }
+    { f_blocks __fsblkcnt64_t }
+    { f_bfree __fsblkcnt64_t }
+    { f_bavail __fsblkcnt64_t }
+    { f_files __fsfilcnt64_t }
+    { f_ffree __fsfilcnt64_t }
+    { f_favail __fsfilcnt64_t }
+    { f_fsid ulong }
+    { f_flag ulong }
+    { f_namemax ulong }
+    { __f_spare int[6] } ;
 
 FUNCTION: int statvfs64 ( char* path, statvfs64* buf ) ;
 
index 0aafad69fa6966a630bc60dd27117fdc09bae2a5..3b1fe71a6a8cf41f442e4578860bcbd78d2570f7 100644 (file)
@@ -1,20 +1,20 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.syntax ;
+USING: alien.syntax classes.struct ;
 IN: unix.statvfs.macosx
 
-C-STRUCT: statvfs
-    { "ulong"   "f_bsize" }
-    { "ulong"   "f_frsize" }
-    { "fsblkcnt_t"  "f_blocks" }
-    { "fsblkcnt_t"  "f_bfree" }
-    { "fsblkcnt_t"  "f_bavail" }
-    { "fsfilcnt_t"  "f_files" }
-    { "fsfilcnt_t"  "f_ffree" }
-    { "fsfilcnt_t"  "f_favail" }
-    { "ulong"   "f_fsid" }
-    { "ulong"   "f_flag" }
-    { "ulong"   "f_namemax" } ;
+STRUCT: statvfs
+    { f_bsize ulong }
+    { f_frsize ulong }
+    { f_blocks fsblkcnt_t }
+    { f_bfree fsblkcnt_t }
+    { f_bavail fsblkcnt_t }
+    { f_files fsfilcnt_t }
+    { f_ffree fsfilcnt_t }
+    { f_favail fsfilcnt_t }
+    { f_fsid ulong }
+    { f_flag ulong }
+    { f_namemax ulong } ;
 
 ! Flags
 CONSTANT: ST_RDONLY   HEX: 1 ! Read-only file system
index 1adc1a3da8435cbd9a9327bb3d040b46de53db47..25c96dc15d32c8898907ac27a4846e5bb08859bb 100644 (file)
@@ -1,35 +1,35 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.syntax ;
+USING: alien.syntax classes.struct ;
 IN: unix.statvfs.netbsd
 
 CONSTANT: _VFS_NAMELEN    32
 CONSTANT: _VFS_MNAMELEN   1024
 
-C-STRUCT: statvfs
-    { "ulong"   "f_flag" }
-    { "ulong"   "f_bsize" }
-    { "ulong"   "f_frsize" }
-    { "ulong"   "f_iosize" }
-    { "fsblkcnt_t" "f_blocks" }
-    { "fsblkcnt_t" "f_bfree" }
-    { "fsblkcnt_t" "f_bavail" }
-    { "fsblkcnt_t" "f_bresvd" }
-    { "fsfilcnt_t" "f_files" }
-    { "fsfilcnt_t" "f_ffree" }
-    { "fsfilcnt_t" "f_favail" }
-    { "fsfilcnt_t" "f_fresvd" }
-    { "uint64_t"   "f_syncreads" }
-    { "uint64_t"   "f_syncwrites" }
-    { "uint64_t"   "f_asyncreads" }
-    { "uint64_t"   "f_asyncwrites" }
-    { "fsid_t"    "f_fsidx" }
-    { "ulong"   "f_fsid" }
-    { "ulong"   "f_namemax" }
-    { "uid_t"   "f_owner" }
-    { { "uint32_t" 4 } "f_spare" }
-    { { "char" _VFS_NAMELEN } "f_fstypename" }
-    { { "char" _VFS_MNAMELEN } "f_mntonname" }
-    { { "char" _VFS_MNAMELEN } "f_mntfromname" } ;
+STRUCT: statvfs
+    { f_flag ulong }
+    { f_bsize ulong }
+    { f_frsize ulong }
+    { f_iosize ulong }
+    { f_blocks fsblkcnt_t }
+    { f_bfree fsblkcnt_t }
+    { f_bavail fsblkcnt_t }
+    { f_bresvd fsblkcnt_t }
+    { f_files fsfilcnt_t }
+    { f_ffree fsfilcnt_t }
+    { f_favail fsfilcnt_t }
+    { f_fresvd fsfilcnt_t }
+    { f_syncreads uint64_t }
+    { f_syncwrites uint64_t }
+    { f_asyncreads uint64_t }
+    { f_asyncwrites uint64_t }
+    { f_fsidx fsid_t }
+    { f_fsid ulong }
+    { f_namemax ulong }
+    { f_owner uid_t }
+    { f_spare uint32_t[4] }
+    { f_fstypename { "char" _VFS_NAMELEN } }
+    { f_mntonname { "char" _VFS_MNAMELEN } }
+    { f_mntfromname { "char" _VFS_MNAMELEN } } ;
 
 FUNCTION: int statvfs ( char* path, statvfs* buf ) ;
index 4ca8d0749daa8b7377264bf0424c6a8ac2dc7378..f2d12c29cc89c52f685be003424bee1139966bca 100644 (file)
@@ -1,20 +1,20 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.syntax ;
+USING: alien.syntax classes.struct ;
 IN: unix.statvfs.openbsd
 
-C-STRUCT: statvfs
-    { "ulong" "f_bsize" }
-    { "ulong" "f_frsize" }
-    { "fsblkcnt_t" "f_blocks" }
-    { "fsblkcnt_t" "f_bfree" }
-    { "fsblkcnt_t" "f_bavail" }
-    { "fsfilcnt_t" "f_files" }
-    { "fsfilcnt_t" "f_ffree" }
-    { "fsfilcnt_t" "f_favail" }
-    { "ulong" "f_fsid" }
-    { "ulong" "f_flag" }
-    { "ulong" "f_namemax" } ;
+STRUCT: statvfs
+    { f_bsize ulong }
+    { f_frsize ulong }
+    { f_blocks fsblkcnt_t }
+    { f_bfree fsblkcnt_t }
+    { f_bavail fsblkcnt_t }
+    { f_files fsfilcnt_t }
+    { f_ffree fsfilcnt_t }
+    { f_favail fsfilcnt_t }
+    { f_fsid ulong }
+    { f_flag ulong }
+    { f_namemax ulong } ;
 
 CONSTANT: ST_RDONLY       1
 CONSTANT: ST_NOSUID       2
index 9847b097789b0fd3aa7d20411f980b330e1c63f9..4f5ac9930966cd4ee5acfebf1d58a285b79e928a 100644 (file)
@@ -1,40 +1,41 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel alien.syntax alien.c-types math unix.types ;
+USING: kernel alien.syntax alien.c-types math unix.types
+classes.struct accessors ;
 IN: unix.time
 
-C-STRUCT: timeval
-    { "long" "sec" }
-    { "long" "usec" } ;
+STRUCT: timeval
+    { sec long }
+    { usec long } ;
 
-C-STRUCT: timespec
-    { "time_t" "sec" }
-    { "long" "nsec" } ;
+STRUCT: timespec
+    { sec time_t }
+    { nsec long } ;
 
 : make-timeval ( us -- timeval )
     1000000 /mod
-    "timeval" <c-object>
-    [ set-timeval-usec ] keep
-    [ set-timeval-sec ] keep ;
+    timeval <struct>
+        swap >>usec
+        swap >>sec ;
 
 : make-timespec ( us -- timespec )
     1000000 /mod 1000 *
-    "timespec" <c-object>
-    [ set-timespec-nsec ] keep
-    [ set-timespec-sec ] keep ;
+    timespec <struct>
+        swap >>nsec
+        swap >>sec ;
 
-C-STRUCT: tm
-    { "int" "sec" }    ! Seconds: 0-59 (K&R says 0-61?)
-    { "int" "min" }    ! Minutes: 0-59
-    { "int" "hour" }   ! Hours since midnight: 0-23
-    { "int" "mday" }   ! Day of the month: 1-31
-    { "int" "mon" }    ! Months *since* january: 0-11
-    { "int" "year" }   ! Years since 1900
-    { "int" "wday" }   ! Days since Sunday (0-6)
-    { "int" "yday" }   ! Days since Jan. 1: 0-365
-    { "int" "isdst" }  ! +1 Daylight Savings Time, 0 No DST,
-    { "long" "gmtoff" } ! Seconds: 0-59 (K&R says 0-61?)
-    { "char*" "zone" } ;
+STRUCT: tm
+    { sec int }
+    { min int }
+    { hour int }
+    { mday int }
+    { mon int }
+    { year int }
+    { wday int }
+    { yday int }
+    { isdst int }
+    { gmtoff long }
+    { zone char* } ;
 
 FUNCTION: time_t time ( time_t* t ) ;
 FUNCTION: tm* localtime ( time_t* clock ) ;