Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
1d0e0f99
Commit
1d0e0f99
authored
Dec 11, 2016
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
ca4dac39
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
21 deletions
+17
-21
t/neo/packed.go
t/neo/packed.go
+17
-21
No files found.
t/neo/packed.go
View file @
1d0e0f99
...
...
@@ -28,31 +28,21 @@ import (
// https://github.com/golang/go/issues/15925
//
// so in the end we use hand-crafted array-like byte-structs.
type
be16
struct
{
_0
byte
_1
byte
}
type
be32
struct
{
_0
byte
_1
byte
_2
byte
_3
byte
}
type
be64
struct
{
_0
byte
_1
byte
_2
byte
_3
byte
_4
byte
_5
byte
_6
byte
_7
byte
}
type
be16
struct
{
_0
,
_1
byte
}
type
be32
struct
{
_0
,
_1
,
_2
,
_3
byte
}
type
be64
struct
{
_0
,
_1
,
_2
,
_3
,
_4
,
_5
,
_6
,
_7
byte
}
// XXX naming ntoh{s,l,q} ?
// good
func
ntoh16
(
v
be16
)
uint16
{
return
_ntoh16_0
(
v
)
// XXX becomes bad - why?
}
// ----------------------------------------
// good
func
_ntoh16_0
(
v
be16
)
uint16
{
b
:=
(
*
[
2
]
byte
)(
unsafe
.
Pointer
(
&
v
))
return
binary
.
BigEndian
.
Uint16
(
b
[
:
])
}
...
...
@@ -126,6 +116,12 @@ func ntoh64(v be64) uint64 {
return
binary
.
BigEndian
.
Uint64
(
b
[
:
])
}
// good (XXX why vs _ntoh32_1 ?)
func
_ntoh64_1
(
v
be64
)
uint64
{
return
uint64
(
v
.
_7
)
|
uint64
(
v
.
_6
)
<<
8
|
uint64
(
v
.
_5
)
<<
16
|
uint64
(
v
.
_4
)
<<
24
|
uint64
(
v
.
_3
)
<<
32
|
uint64
(
v
.
_2
)
<<
40
|
uint64
(
v
.
_1
)
<<
48
|
uint64
(
v
.
_0
)
<<
56
}
// baad (+local temp; r = temp)
func
hton64
(
v
uint64
)
be64
{
return
be64
{
byte
(
v
>>
56
),
byte
(
v
>>
48
),
byte
(
v
>>
40
),
byte
(
v
>>
32
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment