: little-endian? ( -- ? ) 1 <int> *char 1 = ; foldable
-GENERIC: heap-size ( name -- size ) foldable
+GENERIC: heap-size ( name -- size )
M: c-type-name heap-size c-type heap-size ;
M: abstract-c-type heap-size size>> ;
-GENERIC: stack-size ( name -- size ) foldable
+GENERIC: stack-size ( name -- size )
M: c-type-name stack-size c-type stack-size ;
! Copyright (C) 2008, 2009 Slava Pestov, Daniel Ehrenberg.
! See http://factorcode.org/license.txt for BSD license.
-USING: kernel sequences words fry generic accessors
+USING: alien.c-types kernel sequences words fry generic accessors
classes.tuple classes classes.algebra definitions
stack-checker.dependencies quotations classes.tuple.private math
math.partial-dispatch math.private math.intervals sets.private
vectors hashtables combinators effects generalizations assocs
sets combinators.short-circuit sequences.private locals growable
stack-checker namespaces compiler.tree.propagation.info ;
+FROM: math => float ;
IN: compiler.tree.propagation.transforms
\ equal? [
in-d>> second value-info class>> growable class<=
[ \ push def>> ] [ f ] if
] "custom-inlining" set-word-prop
+
+! We want to constant-fold calls to heap-size, and recompile those
+! calls when a C type is redefined
+\ heap-size [
+ dup word? [
+ [ inlined-dependency depends-on ] [ heap-size '[ _ ] ] bi
+ ] [ drop f ] if
+] 1 define-partial-eval
__does_not_exist__ specialized-array-vocab forget-vocab
] with-compilation-unit
] unit-test
+
+STRUCT: struct-resize-test { x int } ;
+
+SPECIALIZED-ARRAY: struct-resize-test
+
+[ 40 ] [ 10 <struct-resize-test-array> byte-length ] unit-test
+
+: struct-resize-test-usage ( seq -- seq )
+ [ struct-resize-test <struct> swap >>x ] map
+ >struct-resize-test-array
+ [ x>> ] { } map-as ;
+
+[ { 10 20 30 } ] [ { 10 20 30 } struct-resize-test-usage ] unit-test
+
+[ ] [ "IN: specialized-arrays.tests USE: classes.struct USE: alien.c-types STRUCT: struct-resize-test { x int } { y int } ;" eval( -- ) ] unit-test
+
+[ 80 ] [ 10 <struct-resize-test-array> byte-length ] unit-test
+
+[ { 10 20 30 } ] [ { 10 20 30 } struct-resize-test-usage ] unit-test
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
-USING: alien.syntax classes.struct kernel sequences system ;
+USING: alien.c-types alien.syntax classes.struct kernel
+sequences system ;
IN: io.serial.unix.termios
CONSTANT: NCCS 20
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
-USING: alien.syntax classes.struct kernel system unix ;
+USING: alien.c-types alien.syntax classes.struct kernel system
+unix ;
IN: io.serial.unix.termios
CONSTANT: NCCS 32
! Copyright (C) 2009 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: alien.c-types alien.data fry kernel monotonic-clock
-system windows.errors windows.kernel32 ;
+system windows.errors windows.kernel32 math ;
IN: monotonic-clock.windows
<PRIVATE
PRIVATE>
-M: windows monotonic-count ( -- n )
- \ QueryPerformanceCounter execute-performance-query ;
-
: cpu-frequency ( -- n )
\ QueryPerformanceFrequency execute-performance-query ;
+
+M: windows monotonic-count ( -- n )
+ \ QueryPerformanceCounter execute-performance-query
+ 1000000000 * cpu-frequency /i ;