     1 over wait-to-write
     buffer>> buffer-write1 ; inline
 
+<PRIVATE
+
 :: port-write ( c-ptr n-remaining port -- )
     port buffer>> :> buffer
     n-remaining buffer size>> min :> n-write


HOOK: (wait-to-write) io-backend ( port -- )

: port-flush ( port -- )
    dup buffer>> buffer-empty?
    [ drop ] [ dup (wait-to-write) port-flush ] if ; inline recursive

M: output-port stream-flush
    [ check-disposed ] [ port-flush ] bi ;

    dup check-disposed
    dup wait-to-read [ drop f ] [ buffer>> buffer-pop ] if ; inline

<PRIVATE

: read-step ( count port -- count ptr/f )
    {
        { [ over 0 = ] [ 2drop 0 f ] }
