Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
a3dc8357
Commit
a3dc8357
authored
Jul 06, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
574554e2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
7 deletions
+6
-7
go/internal/packed/packed.go
go/internal/packed/packed.go
+6
-7
No files found.
go/internal/packed/packed.go
View file @
a3dc8357
...
@@ -29,26 +29,25 @@ package packed
...
@@ -29,26 +29,25 @@ package packed
// https://github.com/golang/go/issues/15925
// https://github.com/golang/go/issues/15925
//
//
// so in the end we use hand-crafted array-like byte-structs.
// so in the end we use hand-crafted array-like byte-structs.
type
BE16
struct
{
_0
,
_1
byte
}
type
BE16
struct
{
_0
,
_1
byte
}
type
BE32
struct
{
_0
,
_1
,
_2
,
_3
byte
}
type
BE32
struct
{
_0
,
_1
,
_2
,
_3
byte
}
func
Ntoh16
(
v
BE16
)
uint16
{
func
Ntoh16
(
v
BE16
)
uint16
{
// XXX not as good as BigEndian.Uint16
// XXX not as good as BigEndian.Uint16
// (unnecessary MOVBLZX AL, AX + shifts not combined into ROLW $8)
// (unnecessary MOVBLZX AL, AX + shifts not combined into ROLW $8)
return
uint16
(
v
.
_1
)
|
uint16
(
v
.
_0
)
<<
8
return
uint16
(
v
.
_1
)
|
uint16
(
v
.
_0
)
<<
8
}
}
func
Hton16
(
v
uint16
)
BE16
{
func
Hton16
(
v
uint16
)
BE16
{
return
BE16
{
byte
(
v
>>
8
),
byte
(
v
)}
return
BE16
{
byte
(
v
>>
8
),
byte
(
v
)}
}
}
func
Ntoh32
(
v
BE32
)
uint32
{
func
Ntoh32
(
v
BE32
)
uint32
{
// XXX not as good as BigEndian.Uint32
// XXX not as good as BigEndian.Uint32
// (unnecessary MOVBLZX AL, AX + shifts not combined into BSWAPL)
// (unnecessary MOVBLZX AL, AX + shifts not combined into BSWAPL)
return
uint32
(
v
.
_3
)
|
uint32
(
v
.
_2
)
<<
8
|
uint32
(
v
.
_1
)
<<
16
|
uint32
(
v
.
_0
)
<<
24
return
uint32
(
v
.
_3
)
|
uint32
(
v
.
_2
)
<<
8
|
uint32
(
v
.
_1
)
<<
16
|
uint32
(
v
.
_0
)
<<
24
}
}
func
Hton32
(
v
uint32
)
BE32
{
func
Hton32
(
v
uint32
)
BE32
{
return
BE32
{
byte
(
v
>>
24
),
byte
(
v
>>
16
),
byte
(
v
>>
8
),
byte
(
v
)}
return
BE32
{
byte
(
v
>>
24
),
byte
(
v
>>
16
),
byte
(
v
>>
8
),
byte
(
v
)}
}
}
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