Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
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
go
Commits
651972b3
Commit
651972b3
authored
Feb 10, 2009
by
Ian Lance Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement unsafe.Alignof.
R=ken DELTA=20 (19 added, 0 deleted, 1 changed) OCL=24719 CL=24771
parent
d94c5aba
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
1 deletion
+20
-1
src/cmd/gc/dcl.c
src/cmd/gc/dcl.c
+18
-1
src/cmd/gc/sysimport.c
src/cmd/gc/sysimport.c
+1
-0
src/cmd/gc/unsafe.go
src/cmd/gc/unsafe.go
+1
-0
No files found.
src/cmd/gc/dcl.c
View file @
651972b3
...
...
@@ -1495,6 +1495,7 @@ unsafenmagic(Node *l, Node *r)
{
Node
*
n
;
Sym
*
s
;
Type
*
t
;
long
v
;
Val
val
;
...
...
@@ -1519,7 +1520,23 @@ unsafenmagic(Node *l, Node *r)
if
(
r
->
op
!=
ODOT
&&
r
->
op
!=
ODOTPTR
)
goto
no
;
walktype
(
r
,
Erv
);
v
=
n
->
xoffset
;
v
=
r
->
xoffset
;
goto
yes
;
}
if
(
strcmp
(
s
->
name
,
"Alignof"
)
==
0
)
{
walktype
(
r
,
Erv
);
if
(
r
->
type
==
T
)
goto
no
;
// make struct { byte; T; }
t
=
typ
(
TSTRUCT
);
t
->
type
=
typ
(
TFIELD
);
t
->
type
->
type
=
types
[
TUINT8
];
t
->
type
->
down
=
typ
(
TFIELD
);
t
->
type
->
down
->
type
=
r
->
type
;
// compute struct widths
dowidth
(
t
);
// the offset of T is its required alignment
v
=
t
->
type
->
down
->
width
;
goto
yes
;
}
...
...
src/cmd/gc/sysimport.c
View file @
651972b3
...
...
@@ -67,5 +67,6 @@ char *unsafeimport =
"type unsafe.Pointer *any
\n
"
"func unsafe.Offsetof (? any) (? int)
\n
"
"func unsafe.Sizeof (? any) (? int)
\n
"
"func unsafe.Alignof (? any) (? int)
\n
"
"
\n
"
"$$
\n
"
;
src/cmd/gc/unsafe.go
View file @
651972b3
...
...
@@ -8,3 +8,4 @@ package PACKAGE
type
Pointer
*
any
;
func
Offsetof
(
any
)
int
;
func
Sizeof
(
any
)
int
;
func
Alignof
(
any
)
int
;
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