on master help sign in
Endianness is redundant for Bits8
commita2332b0b4c98503e148833ad10f4f2ff9ef121a9 authorShea Levy <shea@shealevy.com> dateThu 30 Jan 2014, 17:14 (13 years ago) parentd6418d7
5 files changed+14−58
libs/base/Data/Buffer.idr+9−36 rts/idris_rts.c−16 rts/idris_rts.h−4 src/IRTS/Lang.hs+3 test/buffer001/buffer001.idr+2−2
libs/base/Data/Buffer.idr+9−36
@@ -102,46 +102,19 @@ appendBits { n } prim ( MkBuffer real ) count =
102102-- Read a Bits8 from a Buffer starting at offset
103103%assert_total
104104public
105−peekBits8Native : Buffer ( 1 + n ) ->
106− ( offset : Fin ( S n ) ) ->
107− Bits8
108−peekBits8Native = peekBits { m = 1 } prim__peekB8Native
109−
110−%assert_total
111−public
112−peekBits8LE : Buffer ( 1 + n ) -> ( offset : Fin ( S n ) ) -> Bits8
113−peekBits8LE = peekBits { m = 1 } prim__peekB8LE
114−
115−%assert_total
116−public
117−peekBits8BE : Buffer ( 1 + n ) -> ( offset : Fin ( S n ) ) -> Bits8
118−peekBits8BE = peekBits { m = 1 } prim__peekB8BE
105+peekBits8 : Buffer ( 1 + n ) ->
106+ ( offset : Fin ( S n ) ) ->
107+ Bits8
108+peekBits8 = peekBits { m = 1 } prim__peekB8Native
119109
120110-- Append count repetitions of a Bits8 to a Buffer
121111%assert_total
122112public
123−appendBits8Native : Buffer n ->
124− ( count : Nat ) ->
125− Bits8 ->
126− Buffer ( n + count * 1 )
127−appendBits8Native = appendBits prim__appendB8Native
128−
129−%assert_total
130−public
131−appendBits8LE : Buffer n ->
132− ( count : Nat ) ->
133− Bits8 ->
134− Buffer ( n + count * 1 )
135−appendBits8LE = appendBits prim__appendB8LE
136−
137−%assert_total
138−public
139−appendBits8BE : Buffer n ->
140− ( count : Nat ) ->
141− Bits8 ->
142− Buffer ( n + count * 1 )
143−appendBits8BE = appendBits prim__appendB8BE
144−
113+appendBits8 : Buffer n ->
114+ ( count : Nat ) ->
115+ Bits8 ->
116+ Buffer ( n + count * 1 )
117+appendBits8 = appendBits prim__appendB8Native
145118
146119-- Read a Bits16 in native byte order from a Buffer starting at offset
147120%assert_total
rts/idris_rts.c−16
@@ -623,14 +623,6 @@ VAL idris_appendB8Native(VM* vm, VAL buf, VAL len, VAL cnt, VAL val) {
623623 return cl;
624624}
625625
626−VAL idris_appendB8LE(VM* vm, VAL buf, VAL len, VAL cnt, VAL val) {
627− return idris_appendB8Native(vm, buf, len, cnt, val);
628−}
629−
630−VAL idris_appendB8BE(VM* vm, VAL buf, VAL len, VAL cnt, VAL val) {
631− return idris_appendB8Native(vm, buf, len, cnt, val);
632−}
633−
634626static VAL internal_append_bits(VM* vm, VAL buf, VAL bufLen, VAL cnt, const void* val, size_t val_len) {
635627 size_t len = bufLen->info.bits64;
636628 size_t count = cnt->info.bits64;
@@ -722,14 +714,6 @@ VAL idris_peekB8Native(VM* vm, VAL buf, VAL off) {
722714 return MKB8(vm, *val);
723715}
724716
725−VAL idris_peekB8LE(VM* vm, VAL buf, VAL off) {
726− return idris_peekB8Native(vm, buf, off);
727−}
728−
729−VAL idris_peekB8BE(VM* vm, VAL buf, VAL off) {
730− return idris_peekB8Native(vm, buf, off);
731−}
732−
733717VAL idris_peekB16Native(VM* vm, VAL buf, VAL off) {
734718 size_t offset = off->info.bits64;
735719 uint16_t* val = (uint16_t *) ((GETTY(buf) == BUFOFFSET) ?
rts/idris_rts.h−4
@@ -259,8 +259,6 @@ VAL idris_copy(VM* vm, VAL len, VAL src);
259259VAL idris_appendBuffer(VM* vm, VAL fst, VAL fstLen, VAL count, VAL sndLen, VAL snd);
260260VAL idris_peekBuffer(VM* vm, VAL src, VAL off);
261261VAL idris_appendB8Native(VM* vm, VAL buf, VAL len, VAL cnt, VAL val);
262−VAL idris_appendB8LE(VM* vm, VAL buf, VAL len, VAL cnt, VAL val);
263−VAL idris_appendB8BE(VM* vm, VAL buf, VAL len, VAL cnt, VAL val);
264262VAL idris_appendB16Native(VM* vm, VAL buf, VAL len, VAL cnt, VAL val);
265263VAL idris_appendB16LE(VM* vm, VAL buf, VAL len, VAL cnt, VAL val);
266264VAL idris_appendB16BE(VM* vm, VAL buf, VAL len, VAL cnt, VAL val);
@@ -271,8 +269,6 @@ VAL idris_appendB64Native(VM* vm, VAL buf, VAL len, VAL cnt, VAL val);
271269VAL idris_appendB64LE(VM* vm, VAL buf, VAL len, VAL cnt, VAL val);
272270VAL idris_appendB64BE(VM* vm, VAL buf, VAL len, VAL cnt, VAL val);
273271VAL idris_peekB8Native(VM* vm, VAL buf, VAL off);
274−VAL idris_peekB8LE(VM* vm, VAL buf, VAL off);
275−VAL idris_peekB8BE(VM* vm, VAL buf, VAL off);
276272VAL idris_peekB16Native(VM* vm, VAL buf, VAL off);
277273VAL idris_peekB16LE(VM* vm, VAL buf, VAL off);
278274VAL idris_peekB16BE(VM* vm, VAL buf, VAL off);
src/IRTS/Lang.hs+3
@@ -62,6 +62,9 @@ data PrimFn = LPlus ArithTy | LMinus ArithTy | LTimes ArithTy
6262 | LCopy
6363 | LAppendBuffer
6464 | LPeekBuffer
65+ -- Note that for Bits8 only Native endianness is actually used
66+ -- and the user-exposed interface for Bits8 doesn't mention
67+ -- endianness
6568 | LAppend IntTy Endianness
6669 | LPeek IntTy Endianness
6770
test/buffer001/buffer001.idr+2−2
@@ -15,10 +15,10 @@ firstHalf : Buffer 4
1515firstHalf = appendBits32LE em 1 one
1616
1717full : Buffer 8
18−full = appendBits8LE firstHalf 4 two
18+full = appendBits8 firstHalf 4 two
1919
2020firstByte : Bits8
21−firstByte = peekBits8LE full 0
21+firstByte = peekBits8 full 0
2222
2323firstHalfView : Buffer 4
2424firstHalfView = peekBuffer full 0