From 29ef99663939d7b661ce04f48d2fcc22a9f67019 Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Sat, 1 Mar 2008 07:11:44 -0600 Subject: [PATCH] Move time related items from unix to unix.time --- extra/calendar/unix/unix.factor | 4 +++- extra/io/unix/files/files.factor | 4 ++-- extra/unix/time/time.factor | 32 ++++++++++++++++++++++++++++++++ extra/unix/unix.factor | 26 -------------------------- 4 files changed, 37 insertions(+), 29 deletions(-) create mode 100644 extra/unix/time/time.factor diff --git a/extra/calendar/unix/unix.factor b/extra/calendar/unix/unix.factor index 4e1833af06..30e22c487b 100644 --- a/extra/calendar/unix/unix.factor +++ b/extra/calendar/unix/unix.factor @@ -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 ; diff --git a/extra/io/unix/files/files.factor b/extra/io/unix/files/files.factor index a5a4e64c03..db3cf674c7 100755 --- a/extra/io/unix/files/files.factor +++ b/extra/io/unix/files/files.factor @@ -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 diff --git a/extra/unix/time/time.factor b/extra/unix/time/time.factor new file mode 100644 index 0000000000..460631d9ea --- /dev/null +++ b/extra/unix/time/time.factor @@ -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" + [ set-timespec-nsec ] keep + [ set-timespec-sec ] keep ; + +FUNCTION: time_t time ( time_t* t ) ; +FUNCTION: tm* localtime ( time_t* clock ) ; \ No newline at end of file diff --git a/extra/unix/unix.factor b/extra/unix/unix.factor index f83120a96f..9cc8552f98 100755 --- a/extra/unix/unix.factor +++ b/extra/unix/unix.factor @@ -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" - [ 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 ) ;