Move time related items from unix to unix.time

db4
Eduardo Cavazos 2008-03-01 07:11:44 -06:00
parent c3fd171547
commit 29ef996639
4 changed files with 37 additions and 29 deletions

View File

@ -1,5 +1,7 @@
USING: alien alien.c-types arrays calendar.backend
kernel structs math unix namespaces ;
kernel structs math unix.time namespaces ;
IN: calendar.unix
TUPLE: unix-calendar ;

View File

@ -1,8 +1,8 @@
! Copyright (C) 2005, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: io.backend io.nonblocking io.unix.backend io.files io
unix unix.stat kernel math continuations math.bitfields byte-arrays
alien combinators combinators.cleave calendar ;
unix unix.stat unix.time kernel math continuations math.bitfields
byte-arrays alien combinators combinators.cleave calendar ;
IN: io.unix.files

View File

@ -0,0 +1,32 @@
USING: kernel alien.syntax alien.c-types math ;
IN: unix.time
TYPEDEF: uint time_t
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" } ;
C-STRUCT: timespec
{ "time_t" "sec" }
{ "long" "nsec" } ;
: make-timespec ( ms -- timespec )
1000 /mod 1000000 *
"timespec" <c-object>
[ set-timespec-nsec ] keep
[ set-timespec-sec ] keep ;
FUNCTION: time_t time ( time_t* t ) ;
FUNCTION: tm* localtime ( time_t* clock ) ;

View File

@ -8,32 +8,8 @@ IN: unix
TYPEDEF: uint in_addr_t
TYPEDEF: uint socklen_t
TYPEDEF: uint time_t
TYPEDEF: ulong size_t
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" } ;
C-STRUCT: timespec
{ "time_t" "sec" }
{ "long" "nsec" } ;
: make-timespec ( ms -- timespec )
1000 /mod 1000000 *
"timespec" <c-object>
[ set-timespec-nsec ] keep
[ set-timespec-sec ] keep ;
: PROT_NONE 0 ; inline
: PROT_READ 1 ; inline
: PROT_WRITE 2 ; inline
@ -89,7 +65,6 @@ FUNCTION: ushort htons ( ushort n ) ;
FUNCTION: int ioctl ( int fd, ulong request, char* argp ) ;
FUNCTION: int lchown ( char* path, uid_t owner, gid_t group ) ;
FUNCTION: int listen ( int s, int backlog ) ;
FUNCTION: tm* localtime ( time_t* clock ) ;
FUNCTION: off_t lseek ( int fildes, off_t offset, int whence ) ;
FUNCTION: void* mmap ( void* addr, size_t len, int prot, int flags, int fd, off_t offset ) ;
FUNCTION: int munmap ( void* addr, size_t len ) ;
@ -117,7 +92,6 @@ FUNCTION: int setuid ( uid_t uid ) ;
FUNCTION: int socket ( int domain, int type, int protocol ) ;
FUNCTION: char* strerror ( int errno ) ;
FUNCTION: int system ( char* command ) ;
FUNCTION: time_t time ( time_t* t ) ;
FUNCTION: int unlink ( char* path ) ;
FUNCTION: int utimes ( char* path, timeval[2] times ) ;