Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
riscv-gcc-1
Commits
61e8b354
Commit
61e8b354
authored
Oct 19, 1999
by
Mumit Khan
Committed by
Nick Clifton
Oct 19, 1999
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Applied Mumit Khan's patch to fix #pragma push/pop handling.
From-SVN: r30084
parent
f099b1c9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
65 deletions
+29
-65
gcc/ChangeLog
+12
-0
gcc/c-pragma.c
+17
-62
gcc/c-pragma.h
+0
-3
No files found.
gcc/ChangeLog
View file @
61e8b354
Tue
Oct
19
11
:
41
:
12
1999
Mumit
Khan
<
khan
@xraylith
.
wisc
.
edu
>
*
c
-
pragma
.
h
(
PRAGMA_INSERT_ATTRIBUTES
)
:
Delete
macro
.
(
insert_pack_attributes
)
:
Delete
prototype
.
*
c
-
pragma
.
c
(
default_alignment
)
:
New
static
variable
.
(
push_alignment
)
:
Initialize
to
current
effective
alignment
.
(
pop_alignment
)
:
Use
to
set
new
alignment
.
(
insert_pack_attributes
)
:
Delete
function
.
(
handle_pragma_token
)
:
Set
default_alignment
as
well
each
time
a
#
pragma
pack
(
<
n
>
)
is
encountered
.
Tue
Oct
19
02
:
03
:
00
1999
Jeffrey
A
Law
(
law
@cygnus
.
com
)
Tue
Oct
19
02
:
03
:
00
1999
Jeffrey
A
Law
(
law
@cygnus
.
com
)
*
reg
-
stack
.
c
(
stack_result
)
:
Aggregates
are
not
returned
in
*
reg
-
stack
.
c
(
stack_result
)
:
Aggregates
are
not
returned
in
...
...
gcc/c-pragma.c
View file @
61e8b354
...
@@ -51,6 +51,13 @@ typedef struct align_stack
...
@@ -51,6 +51,13 @@ typedef struct align_stack
static
struct
align_stack
*
alignment_stack
=
NULL
;
static
struct
align_stack
*
alignment_stack
=
NULL
;
/* If we have a "global" #pragma pack(<n>) if effect when the first
#pragma push(pack,<n>) is encountered, this stores the the value of
maximum_field_alignment in effect. When the final pop_alignment()
happens, we restore the value to this, not to a value of 0 for
maximum_field_alignment. Value is in bits. */
static
int
default_alignment
;
static
int
push_alignment
PROTO
((
int
,
tree
));
static
int
push_alignment
PROTO
((
int
,
tree
));
static
int
pop_alignment
PROTO
((
tree
));
static
int
pop_alignment
PROTO
((
tree
));
...
@@ -95,6 +102,12 @@ Alignment must be a small power of two, not %d, in #pragma pack",
...
@@ -95,6 +102,12 @@ Alignment must be a small power of two, not %d, in #pragma pack",
entry
->
id
=
id
;
entry
->
id
=
id
;
entry
->
prev
=
alignment_stack
;
entry
->
prev
=
alignment_stack
;
/* The current value of maximum_field_alignment is not necessarily
0 since there may be a #pragma pack(<n>) in effect; remember it
so that we can restore it after the final #pragma pop(). */
if
(
alignment_stack
==
NULL
)
default_alignment
=
maximum_field_alignment
;
alignment_stack
=
entry
;
alignment_stack
=
entry
;
maximum_field_alignment
=
alignment
*
8
;
maximum_field_alignment
=
alignment
*
8
;
...
@@ -142,7 +155,7 @@ pop_alignment (id)
...
@@ -142,7 +155,7 @@ pop_alignment (id)
entry
=
alignment_stack
->
prev
;
entry
=
alignment_stack
->
prev
;
if
(
entry
==
NULL
)
if
(
entry
==
NULL
)
maximum_field_alignment
=
0
;
maximum_field_alignment
=
default_alignment
;
else
else
maximum_field_alignment
=
entry
->
alignment
*
8
;
maximum_field_alignment
=
entry
->
alignment
*
8
;
...
@@ -153,67 +166,6 @@ pop_alignment (id)
...
@@ -153,67 +166,6 @@ pop_alignment (id)
return
1
;
return
1
;
}
}
/* Generate 'packed' and 'aligned' attributes for decls whilst a
#pragma pack(push... is in effect. */
void
insert_pack_attributes
(
node
,
attributes
,
prefix
)
tree
node
;
tree
*
attributes
;
tree
*
prefix
;
{
tree
a
;
int
field_alignment
;
/* If we are not packing, then there is nothing to do. */
if
(
maximum_field_alignment
==
0
||
alignment_stack
==
NULL
)
return
;
/* We are only interested in fields. */
if
(
TREE_CODE_CLASS
(
TREE_CODE
(
node
))
!=
'd'
||
TREE_CODE
(
node
)
!=
FIELD_DECL
)
return
;
field_alignment
=
TYPE_ALIGN
(
TREE_TYPE
(
node
));
if
(
field_alignment
<=
0
||
field_alignment
>
maximum_field_alignment
)
field_alignment
=
maximum_field_alignment
;
/* Add a 'packed' attribute. */
*
attributes
=
tree_cons
(
get_identifier
(
"packed"
),
NULL
,
*
attributes
);
/* If the alignment is > 8 then add an alignment attribute as well. */
if
(
field_alignment
>
8
)
{
/* If the aligned attribute is already present then do not override it. */
for
(
a
=
*
attributes
;
a
;
a
=
TREE_CHAIN
(
a
))
{
tree
name
=
TREE_PURPOSE
(
a
);
if
(
strcmp
(
IDENTIFIER_POINTER
(
name
),
"aligned"
)
==
0
)
break
;
}
if
(
a
==
NULL
)
for
(
a
=
*
prefix
;
a
;
a
=
TREE_CHAIN
(
a
))
{
tree
name
=
TREE_PURPOSE
(
a
);
if
(
strcmp
(
IDENTIFIER_POINTER
(
name
),
"aligned"
)
==
0
)
break
;
}
if
(
a
==
NULL
)
{
*
attributes
=
tree_cons
(
get_identifier
(
"aligned"
),
tree_cons
(
NULL
,
build_int_2
(
field_alignment
/
8
,
0
),
NULL
),
*
attributes
);
}
}
return
;
}
#endif
/* HANDLE_PRAGMA_PACK_PUSH_POP */
#endif
/* HANDLE_PRAGMA_PACK_PUSH_POP */
/* Handle one token of a pragma directive. TOKEN is the current token, and
/* Handle one token of a pragma directive. TOKEN is the current token, and
...
@@ -267,6 +219,9 @@ handle_pragma_token (string, token)
...
@@ -267,6 +219,9 @@ handle_pragma_token (string, token)
if
(
state
==
ps_right
)
if
(
state
==
ps_right
)
{
{
maximum_field_alignment
=
align
*
8
;
maximum_field_alignment
=
align
*
8
;
#ifdef HANDLE_PRAGMA_PACK_PUSH_POP
default_alignment
=
maximum_field_alignment
;
#endif
ret_val
=
1
;
ret_val
=
1
;
}
}
else
else
...
...
gcc/c-pragma.h
View file @
61e8b354
...
@@ -39,9 +39,6 @@ Boston, MA 02111-1307, USA. */
...
@@ -39,9 +39,6 @@ Boston, MA 02111-1307, USA. */
/* If we are supporting #pragma pack(push... then we automatically
/* If we are supporting #pragma pack(push... then we automatically
support #pragma pack(<n>) */
support #pragma pack(<n>) */
#define HANDLE_PRAGMA_PACK 1
#define HANDLE_PRAGMA_PACK 1
#define PRAGMA_INSERT_ATTRIBUTES(node, pattr, prefix_attr) \
insert_pack_attributes (node, pattr, prefix_attr)
extern
void
insert_pack_attributes
PROTO
((
tree
,
tree
*
,
tree
*
));
#endif
/* HANDLE_PRAGMA_PACK_PUSH_POP */
#endif
/* HANDLE_PRAGMA_PACK_PUSH_POP */
...
...
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