]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branch 'macho' of git://github.com/erikcharlebois/factor 0.93
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Fri, 16 Apr 2010 03:51:50 +0000 (22:51 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Fri, 16 Apr 2010 03:51:50 +0000 (22:51 -0500)
basis/db/sqlite/ffi/ffi.factor
basis/formatting/formatting-docs.factor [changed mode: 0644->0755]
basis/formatting/formatting-tests.factor [changed mode: 0644->0755]
basis/system-info/linux/linux.factor
basis/unix/process/process.factor
extra/benchmark/fasta/fasta.factor
extra/cuda/ffi/ffi.factor

index c06581e1a2ed4f0269c42d61ccc9919bdab9148b..b5f9020ce9fb192cd4231530f512352018d599f6 100644 (file)
@@ -119,7 +119,7 @@ FUNCTION: int sqlite3_bind_double ( sqlite3_stmt* pStmt, int index, double x ) ;
 FUNCTION: int sqlite3_bind_int ( sqlite3_stmt* pStmt, int index, int n ) ;
 FUNCTION: int sqlite3_bind_int64 ( sqlite3_stmt* pStmt, int index, sqlite3_int64 n ) ;
 ! Bind the same function as above, but for unsigned 64bit integers
-FUNCTION-ALIAS: sqlite3-bind-uint64 ( pStmt index in64 -- int )
+FUNCTION-ALIAS: sqlite3-bind-uint64
     int sqlite3_bind_int64 ( sqlite3_stmt* pStmt, int index, sqlite3_uint64 in64 ) ;
 FUNCTION: int sqlite3_bind_null ( sqlite3_stmt* pStmt, int n ) ;
 FUNCTION: int sqlite3_bind_text ( sqlite3_stmt* pStmt, int index, c-string text, int len, int destructor ) ;
@@ -132,7 +132,7 @@ FUNCTION: c-string sqlite3_column_decltype ( sqlite3_stmt* pStmt, int col ) ;
 FUNCTION: int sqlite3_column_int ( sqlite3_stmt* pStmt, int col ) ;
 FUNCTION: sqlite3_int64 sqlite3_column_int64 ( sqlite3_stmt* pStmt, int col ) ;
 ! Bind the same function as above, but for unsigned 64bit integers
-FUNCTION-ALIAS: sqlite3-column-uint64 ( pStmt col -- uint64 )
+FUNCTION-ALIAS: sqlite3-column-uint64
     sqlite3_uint64 sqlite3_column_int64 ( sqlite3_stmt* pStmt, int col ) ;
 FUNCTION: double sqlite3_column_double ( sqlite3_stmt* pStmt, int col ) ;
 FUNCTION: c-string sqlite3_column_name ( sqlite3_stmt* pStmt, int col ) ;
old mode 100644 (file)
new mode 100755 (executable)
index 9625c40..100c88c
@@ -62,10 +62,6 @@ HELP: printf
         "USING: formatting ;"
         "1.23456789 \"%.3f\" printf"
         "1.235" }
-    { $example 
-        "USING: formatting ;"
-        "1234567890 \"%.5e\" printf"
-        "1.23457e+09" }
     { $example
         "USING: formatting ;"
         "12 \"%'#4d\" printf"
old mode 100644 (file)
new mode 100755 (executable)
index 35b1dff..740babf
@@ -1,83 +1,85 @@
 ! Copyright (C) 2008 John Benediktsson
 ! See http://factorcode.org/license.txt for BSD license
-USING: calendar kernel formatting tools.test ;
+USING: calendar kernel formatting tools.test system ;
 IN: formatting.tests
 
 [ "%s" printf ] must-infer 
 [ "%s" sprintf ] must-infer
 
-[ t ] [ "" "" sprintf = ] unit-test
-[ t ] [ "asdf" "asdf" sprintf = ] unit-test
-[ t ] [ "10" 10 "%d" sprintf = ] unit-test
-[ t ] [ "+10" 10 "%+d" sprintf = ] unit-test
-[ t ] [ "-10" -10 "%d" sprintf = ] unit-test
-[ t ] [ "  -10" -10 "%5d" sprintf = ] unit-test
-[ t ] [ "-0010" -10 "%05d" sprintf = ] unit-test
-[ t ] [ "+0010" 10 "%+05d" sprintf = ] unit-test
-[ t ] [ "123.456000" 123.456 "%f" sprintf = ] unit-test
-[ t ] [ "2.44" 2.436 "%.2f" sprintf = ] unit-test
-[ t ] [ "8.950" 8.950179003580072 "%.3f" sprintf = ] unit-test
-[ t ] [ "123.10" 123.1 "%01.2f" sprintf = ] unit-test
-[ t ] [ "1.2346" 1.23456789 "%.4f" sprintf = ] unit-test
-[ t ] [ "  1.23" 1.23456789 "%6.2f" sprintf = ] unit-test
-[ t ] [ "1.234000e+08" 123400000 "%e" sprintf = ] unit-test
-[ t ] [ "-1.234000e+08" -123400000 "%e" sprintf = ] unit-test
-[ t ] [ "1.234567e+08" 123456700 "%e" sprintf = ] unit-test
-[ t ] [ "3.625e+08" 362525200 "%.3e" sprintf = ] unit-test
-[ t ] [ "2.500000e-03" 0.0025 "%e" sprintf = ] unit-test
-[ t ] [ "2.500000E-03" 0.0025 "%E" sprintf = ] unit-test
-[ t ] [ "   1.0E+01" 10 "%10.1E" sprintf = ] unit-test
-[ t ] [ "  -1.0E+01" -10 "%10.1E" sprintf = ] unit-test
-[ t ] [ "  -1.0E+01" -10 "%+10.1E" sprintf = ] unit-test
-[ t ] [ "  +1.0E+01" 10 "%+10.1E" sprintf = ] unit-test
-[ t ] [ "-001.0E+01" -10 "%+010.1E" sprintf = ] unit-test
-[ t ] [ "+001.0E+01" 10 "%+010.1E" sprintf = ] unit-test
-[ t ] [ "ff" HEX: ff "%x" sprintf = ] unit-test
-[ t ] [ "FF" HEX: ff "%X" sprintf = ] unit-test
-[ t ] [ "0f" HEX: f "%02x" sprintf = ] unit-test
-[ t ] [ "0F" HEX: f "%02X" sprintf = ] unit-test
-[ t ] [ "2008-09-10" 
-        2008 9 10 "%04d-%02d-%02d" sprintf = ] unit-test
-[ t ] [ "Hello, World!" 
-        "Hello, World!" "%s" sprintf = ] unit-test
-[ t ] [ "printf test" 
-        "printf test" sprintf = ] unit-test
-[ t ] [ "char a = 'a'"
-        CHAR: a "char %c = 'a'" sprintf = ] unit-test
-[ t ] [ "00" HEX: 0 "%02x" sprintf = ] unit-test
-[ t ] [ "ff" HEX: ff "%02x" sprintf = ] unit-test
-[ t ] [ "0 message(s)"
-        0 "message" "%d %s(s)" sprintf = ] unit-test
-[ t ] [ "0 message(s) with %"
-        0 "message" "%d %s(s) with %%" sprintf = ] unit-test
-[ t ] [ "justif: \"left      \""
-        "left" "justif: \"%-10s\"" sprintf = ] unit-test
-[ t ] [ "justif: \"     right\""
-        "right" "justif: \"%10s\"" sprintf = ] unit-test
-[ t ] [ " 3: 0003 zero padded" 
-        3 " 3: %04d zero padded" sprintf = ] unit-test
-[ t ] [ " 3: 3    left justif" 
-        3 " 3: %-4d left justif" sprintf = ] unit-test
-[ t ] [ " 3:    3 right justif" 
-        3 " 3: %4d right justif" sprintf = ] unit-test
-[ t ] [ " -3: -003 zero padded"
-        -3 " -3: %04d zero padded" sprintf = ] unit-test
-[ t ] [ " -3: -3   left justif"
-        -3 " -3: %-4d left justif" sprintf = ] unit-test
-[ t ] [ " -3:   -3 right justif"
-        -3 " -3: %4d right justif" sprintf = ] unit-test
-[ t ] [ "There are 10 monkeys in the kitchen" 
-        10 "kitchen" "There are %d monkeys in the %s" sprintf = ] unit-test
-[ f ] [ "%d" 10 "%d" sprintf = ] unit-test
-[ t ] [ "[monkey]" "monkey" "[%s]" sprintf = ] unit-test
-[ t ] [ "[    monkey]" "monkey" "[%10s]" sprintf = ] unit-test
-[ t ] [ "[monkey    ]" "monkey" "[%-10s]" sprintf = ] unit-test
-[ t ] [ "[0000monkey]" "monkey" "[%010s]" sprintf = ] unit-test
-[ t ] [ "[####monkey]" "monkey" "[%'#10s]" sprintf = ] unit-test
-[ t ] [ "[many monke]" "many monkeys" "[%10.10s]" sprintf = ] unit-test
+[ "" ] [ "" sprintf ] unit-test
+[ "asdf" ] [ "asdf" sprintf ] unit-test
+[ "10" ] [ 10 "%d" sprintf ] unit-test
+[ "+10" ] [ 10 "%+d" sprintf ] unit-test
+[ "-10" ] [ -10 "%d" sprintf ] unit-test
+[ "  -10" ] [ -10 "%5d" sprintf ] unit-test
+[ "-0010" ] [ -10 "%05d" sprintf ] unit-test
+[ "+0010" ] [ 10 "%+05d" sprintf ] unit-test
+[ "123.456000" ] [ 123.456 "%f" sprintf ] unit-test
+[ "2.44" ] [ 2.436 "%.2f" sprintf ] unit-test
+[ "8.950" ] [ 8.950179003580072 "%.3f" sprintf ] unit-test
+[ "123.10" ] [ 123.1 "%01.2f" sprintf ] unit-test
+[ "1.2346" ] [ 1.23456789 "%.4f" sprintf ] unit-test
+[ "  1.23" ] [ 1.23456789 "%6.2f" sprintf ] unit-test
 
-[ t ] [ "{ 1, 2, 3 }" { 1 2 3 } "%[%s, %]" sprintf = ] unit-test
-[ t ] [ "{ 1:2, 3:4 }" H{ { 1 2 } { 3 4 } } "%[%s: %s %]" sprintf = ] unit-test
+os windows? [
+    [ "1.234000e+008" ] [ 123400000 "%e" sprintf ] unit-test
+    [ "-1.234000e+008" ] [ -123400000 "%e" sprintf ] unit-test
+    [ "1.234567e+008" ] [ 123456700 "%e" sprintf ] unit-test
+    [ "3.625e+008" ] [ 362525200 "%.3e" sprintf ] unit-test
+    [ "2.500000e-003" ] [ 0.0025 "%e" sprintf ] unit-test
+    [ "2.500000E-003" ] [ 0.0025 "%E" sprintf ] unit-test
+    [ "   1.0E+001" ] [ 10 "%11.1E" sprintf ] unit-test
+    [ "  -1.0E+001" ] [ -10 "%11.1E" sprintf ] unit-test
+    [ "  -1.0E+001" ] [ -10 "%+11.1E" sprintf ] unit-test
+    [ "  +1.0E+001" ] [ 10 "%+11.1E" sprintf ] unit-test
+    [ "-001.0E+001" ] [ -10 "%+011.1E" sprintf ] unit-test
+    [ "+001.0E+001" ] [ 10 "%+011.1E" sprintf ] unit-test
+] [
+    [ "1.234000e+08" ] [ 123400000 "%e" sprintf ] unit-test
+    [ "-1.234000e+08" ] [ -123400000 "%e" sprintf ] unit-test
+    [ "1.234567e+08" ] [ 123456700 "%e" sprintf ] unit-test
+    [ "3.625e+08" ] [ 362525200 "%.3e" sprintf ] unit-test
+    [ "2.500000e-03" ] [ 0.0025 "%e" sprintf ] unit-test
+    [ "2.500000E-03" ] [ 0.0025 "%E" sprintf ] unit-test
+    [ "   1.0E+01" ] [ 10 "%10.1E" sprintf ] unit-test
+    [ "  -1.0E+01" ] [ -10 "%10.1E" sprintf ] unit-test
+    [ "  -1.0E+01" ] [ -10 "%+10.1E" sprintf ] unit-test
+    [ "  +1.0E+01" ] [ 10 "%+10.1E" sprintf ] unit-test
+    [ "-001.0E+01" ] [ -10 "%+010.1E" sprintf ] unit-test
+    [ "+001.0E+01" ] [ 10 "%+010.1E" sprintf ] unit-test
+] if
+
+[ "ff" ] [ HEX: ff "%x" sprintf ] unit-test
+[ "FF" ] [ HEX: ff "%X" sprintf ] unit-test
+[ "0f" ] [ HEX: f "%02x" sprintf ] unit-test
+[ "0F" ] [ HEX: f "%02X" sprintf ] unit-test
+[ "2008-09-10" ] [ 2008 9 10 "%04d-%02d-%02d" sprintf ] unit-test
+[ "Hello, World!" ] [ "Hello, World!" "%s" sprintf ] unit-test
+[ "printf test" ] [ "printf test" sprintf ] unit-test
+[ "char a = 'a'" ] [ CHAR: a "char %c = 'a'" sprintf ] unit-test
+[ "00" ] [ HEX: 0 "%02x" sprintf ] unit-test
+[ "ff" ] [ HEX: ff "%02x" sprintf ] unit-test
+[ "0 message(s)" ] [ 0 "message" "%d %s(s)" sprintf ] unit-test
+[ "0 message(s) with %" ] [ 0 "message" "%d %s(s) with %%" sprintf ] unit-test
+[ "justif: \"left      \"" ] [ "left" "justif: \"%-10s\"" sprintf ] unit-test
+[ "justif: \"     right\"" ] [ "right" "justif: \"%10s\"" sprintf ] unit-test
+[ " 3: 0003 zero padded" ] [ 3 " 3: %04d zero padded" sprintf ] unit-test
+[ " 3: 3    left justif" ] [ 3 " 3: %-4d left justif" sprintf ] unit-test
+[ " 3:    3 right justif" ] [ 3 " 3: %4d right justif" sprintf ] unit-test
+[ " -3: -003 zero padded" ] [ -3 " -3: %04d zero padded" sprintf ] unit-test
+[ " -3: -3   left justif" ] [ -3 " -3: %-4d left justif" sprintf ] unit-test
+[ " -3:   -3 right justif" ] [ -3 " -3: %4d right justif" sprintf ] unit-test
+[ "There are 10 monkeys in the kitchen" ] [ 10 "kitchen" "There are %d monkeys in the %s" sprintf ] unit-test
+[ "10" ] [ 10 "%d" sprintf ] unit-test
+[ "[monkey]" ] [ "monkey" "[%s]" sprintf ] unit-test
+[ "[    monkey]" ] [ "monkey" "[%10s]" sprintf ] unit-test
+[ "[monkey    ]" ] [ "monkey" "[%-10s]" sprintf ] unit-test
+[ "[0000monkey]" ] [ "monkey" "[%010s]" sprintf ] unit-test
+[ "[####monkey]" ] [ "monkey" "[%'#10s]" sprintf ] unit-test
+[ "[many monke]" ] [ "many monkeys" "[%10.10s]" sprintf ] unit-test
+
+[ "{ 1, 2, 3 }" ] [ { 1 2 3 } "%[%s, %]" sprintf ] unit-test
+[ "{ 1:2, 3:4 }" ] [ H{ { 1 2 } { 3 4 } } "%[%s: %s %]" sprintf ] unit-test
 
 
 [ "%H:%M:%S" strftime ] must-infer
@@ -96,5 +98,3 @@ IN: formatting.tests
 [ t ] [ "October" testtime "%B" strftime = ] unit-test
 [ t ] [ "Thu Oct 09 12:03:15 2008" testtime "%c" strftime = ] unit-test
 [ t ] [ "PM" testtime "%p" strftime = ] unit-test
-
-
index 9c6f9fbff3bb6b5f21d56e51a17b99a480c6d847..2eb395b8d1b65cb5d6df813201ff34f0f5b61797 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: unix alien alien.c-types kernel math sequences strings
 io.backend.unix splitting io.encodings.utf8 io.encodings.string
-specialized-arrays ;
+specialized-arrays alien.syntax ;
 SPECIALIZED-ARRAY: char
 IN: system-info.linux
 
index 4b33c37d078411aa80fa21de1266260a6a398688..1e9129af58aefc224671fba0994f5ff33aaa8acf 100644 (file)
@@ -36,8 +36,7 @@ FUNCTION: int execve ( c-string path, c-string* argv, c-string* envp ) ;
     [ [ first ] [ ] bi ] dip exec-with-env ;
 
 : with-fork ( child parent -- )
-    [ [ fork-process dup zero? ] dip '[ drop @ ] ] dip
-    if ; inline
+    [ fork-process ] 2dip if-zero ; inline
 
 CONSTANT: SIGKILL 9
 CONSTANT: SIGTERM 15
index 226287974f836d528e2e2a3643c609748f885d21..8c06716ddb53f524303fd0549565437b179344cb 100644 (file)
@@ -13,7 +13,7 @@ CONSTANT: initial-seed 42
 CONSTANT: line-length 60
 
 : random ( seed -- seed n )
-    >float IA * IC + IM mod dup IM /f ; inline
+    IA * IC + IM mod dup IM /f ; inline
 
 CONSTANT: ALU "GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA"
 
@@ -52,7 +52,7 @@ TYPED: make-cumulative ( freq -- chars: byte-array floats: double-array )
 :: select-random ( seed chars floats -- seed elt )
     seed random floats [ <= ] with find drop chars nth-unsafe ; inline
 
-TYPED: make-random-fasta ( seed: fixnum len: fixnum chars: byte-array floats: double-array -- seed: fixnum )
+TYPED: make-random-fasta ( seed: float len: fixnum chars: byte-array floats: double-array -- seed: float )
     '[ _ _ select-random ] "" replicate-as print ;
 
 : write-description ( desc id -- )
@@ -63,7 +63,7 @@ TYPED: make-random-fasta ( seed: fixnum len: fixnum chars: byte-array floats: do
     [ [ line-length quot call ] times ] dip
     quot unless-zero ; inline
 
-TYPED: write-random-fasta ( seed: fixnum n: fixnum chars: byte-array floats: double-array desc id -- seed: fixnum )
+TYPED: write-random-fasta ( seed: float n: fixnum chars: byte-array floats: double-array desc id -- seed: float )
     write-description
     '[ _ _ make-random-fasta ] split-lines ;
 
index 3d41f1e4c5069bfeeba5a971dc788a43701fbeb3..b7efeff9fb173151092117087ed78a49790e5550 100644 (file)
@@ -1,6 +1,6 @@
 ! (c)2010 Joe Groff bsd license
-USING: alien alien.c-types alien.libraries alien.syntax
-classes.struct combinators system ;
+USING: accessors alien alien.c-types alien.libraries alien.syntax
+classes.struct combinators kernel system ;
 IN: cuda.ffi
 
 <<
@@ -24,6 +24,28 @@ TYPEDEF: void* CUevent
 TYPEDEF: void* CUstream
 TYPEDEF: void* CUgraphicsResource
 
+! versions of double and longlong that always 8-byte align
+
+SYMBOLS: CUdouble CUlonglong CUulonglong ;
+
+: >cuda-param-type ( c-type -- c-type' )
+    {
+        { CUdeviceptr [ void* ] }
+        { double      [ CUdouble ] }
+        { longlong    [ CUlonglong ] }
+        { ulonglong   [ CUulonglong ] }
+        [ ]
+    } case ;
+
+<<
+: always-8-byte-align ( c-type -- c-type )
+    8 >>align 8 >>align-first ;
+
+longlong  c-type clone always-8-byte-align \ CUlonglong  typedef
+ulonglong c-type clone always-8-byte-align \ CUulonglong typedef
+double    c-type clone always-8-byte-align \ CUdouble    typedef
+>>
+
 STRUCT: CUuuid
     { bytes char[16] } ;