Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jacobsa-fuse
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
jacobsa-fuse
Commits
c0e60edb
Commit
c0e60edb
authored
Jul 28, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Defined the new OutMessage API.
parent
3371ab70
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
33 deletions
+25
-33
internal/buffer/out_message.go
internal/buffer/out_message.go
+25
-33
No files found.
internal/buffer/out_message.go
View file @
c0e60edb
...
...
@@ -15,7 +15,6 @@
package
buffer
import
(
"reflect"
"unsafe"
"github.com/jacobsa/fuse/internal/fusekernel"
...
...
@@ -35,54 +34,47 @@ type OutMessage struct {
storage
[
outMessageSize
]
byte
}
// Create a new buffer whose initial contents are a zeroed fusekernel.OutHeader
// message, and with room enough to grow by extra bytes.
func
NewOutMessage
(
extra
uintptr
)
(
b
OutMessage
)
{
const
headerSize
=
unsafe
.
Sizeof
(
fusekernel
.
OutHeader
{})
b
.
slice
=
make
([]
byte
,
headerSize
,
headerSize
+
extra
)
return
// Reset the message so that it is ready to be used again. Afterward, the
// contents are solely a zeroed header.
func
(
m
*
OutMessage
)
Reset
()
{
panic
(
"TODO"
)
}
// Return a pointer to the header at the start of the
buffer
.
// Return a pointer to the header at the start of the
message
.
func
(
b
*
OutMessage
)
OutHeader
()
(
h
*
fusekernel
.
OutHeader
)
{
sh
:=
(
*
reflect
.
SliceHeader
)(
unsafe
.
Pointer
(
&
b
.
slice
))
h
=
(
*
fusekernel
.
OutHeader
)(
unsafe
.
Pointer
(
sh
.
Data
))
return
panic
(
"TODO"
)
}
// Grow the buffer by the supplied number of bytes, returning a pointer to the
// start of the new segment
. The sum of the arguments given to Grow must not
//
exceed the argument given to New when creating the buff
er.
// start of the new segment
, which is zeroed. If there is no space left, return
//
the nil point
er.
func
(
b
*
OutMessage
)
Grow
(
size
uintptr
)
(
p
unsafe
.
Pointer
)
{
sh
:=
(
*
reflect
.
SliceHeader
)(
unsafe
.
Pointer
(
&
b
.
slice
))
p
=
unsafe
.
Pointer
(
sh
.
Data
+
uintptr
(
sh
.
Len
))
b
.
slice
=
b
.
slice
[
:
len
(
b
.
slice
)
+
int
(
size
)]
return
panic
(
"TODO"
)
}
// Equivalent to growing by the length of p, then copying p into the new segment.
func
(
b
*
OutMessage
)
Append
(
p
[]
byte
)
{
sh
:=
reflect
.
SliceHeader
{
Data
:
uintptr
(
b
.
Grow
(
uintptr
(
len
(
p
)))),
Len
:
len
(
p
),
Cap
:
len
(
p
),
}
// Equivalent to Grow, except the new segment is not zeroed. Use with caution!
func
(
b
*
OutMessage
)
GrowNoZero
(
size
uintptr
)
(
p
unsafe
.
Pointer
)
{
panic
(
"TODO"
)
}
copy
(
*
(
*
[]
byte
)(
unsafe
.
Pointer
(
&
sh
)),
p
)
// Equivalent to growing by the length of p, then copying p over the new
// segment.
func
(
b
*
OutMessage
)
Append
(
p
[]
byte
)
{
panic
(
"TODO"
)
}
// Equivalent to growing by the length of s, then copying s into the new segment.
// Equivalent to growing by the length of s, then copying s over the new
// segment.
func
(
b
*
OutMessage
)
AppendString
(
s
string
)
{
sh
:=
reflect
.
SliceHeader
{
Data
:
uintptr
(
b
.
Grow
(
uintptr
(
len
(
s
)))),
Len
:
len
(
s
),
Cap
:
len
(
s
),
}
panic
(
"TODO"
)
}
copy
(
*
(
*
[]
byte
)(
unsafe
.
Pointer
(
&
sh
)),
s
)
// Return the current size of the buffer.
func
(
b
*
OutMessage
)
Len
()
int
{
panic
(
"TODO"
)
}
// Return a reference to the current contents of the buffer.
func
(
b
*
OutMessage
)
Bytes
()
[]
byte
{
return
b
.
slice
panic
(
"TODO"
)
}
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