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
b699150b
Commit
b699150b
authored
Jun 01, 2007
by
Mike Stump
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixup whitespacing
From-SVN: r125255
parent
46a9e521
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
39 deletions
+39
-39
libcpp/pch.c
+39
-39
No files found.
libcpp/pch.c
View file @
b699150b
...
@@ -35,14 +35,14 @@ static int write_defs (cpp_reader *, cpp_hashnode *, void *);
...
@@ -35,14 +35,14 @@ static int write_defs (cpp_reader *, cpp_hashnode *, void *);
static
int
save_macros
(
cpp_reader
*
,
cpp_hashnode
*
,
void
*
);
static
int
save_macros
(
cpp_reader
*
,
cpp_hashnode
*
,
void
*
);
/* This structure represents a macro definition on disk. */
/* This structure represents a macro definition on disk. */
struct
macrodef_struct
struct
macrodef_struct
{
{
unsigned
int
definition_length
;
unsigned
int
definition_length
;
unsigned
short
name_length
;
unsigned
short
name_length
;
unsigned
short
flags
;
unsigned
short
flags
;
};
};
/* This is how we write out a macro definition.
/* This is how we write out a macro definition.
Suitable for being called by cpp_forall_identifiers. */
Suitable for being called by cpp_forall_identifiers. */
static
int
static
int
...
@@ -54,7 +54,7 @@ write_macdef (cpp_reader *pfile, cpp_hashnode *hn, void *file_p)
...
@@ -54,7 +54,7 @@ write_macdef (cpp_reader *pfile, cpp_hashnode *hn, void *file_p)
case
NT_VOID
:
case
NT_VOID
:
if
(
!
(
hn
->
flags
&
NODE_POISONED
))
if
(
!
(
hn
->
flags
&
NODE_POISONED
))
return
1
;
return
1
;
case
NT_MACRO
:
case
NT_MACRO
:
if
((
hn
->
flags
&
NODE_BUILTIN
))
if
((
hn
->
flags
&
NODE_BUILTIN
))
return
1
;
return
1
;
...
@@ -76,7 +76,7 @@ write_macdef (cpp_reader *pfile, cpp_hashnode *hn, void *file_p)
...
@@ -76,7 +76,7 @@ write_macdef (cpp_reader *pfile, cpp_hashnode *hn, void *file_p)
defn
=
NODE_NAME
(
hn
);
defn
=
NODE_NAME
(
hn
);
s
.
definition_length
=
s
.
name_length
;
s
.
definition_length
=
s
.
name_length
;
}
}
if
(
fwrite
(
&
s
,
sizeof
(
s
),
1
,
f
)
!=
1
if
(
fwrite
(
&
s
,
sizeof
(
s
),
1
,
f
)
!=
1
||
fwrite
(
defn
,
1
,
s
.
definition_length
,
f
)
!=
s
.
definition_length
)
||
fwrite
(
defn
,
1
,
s
.
definition_length
,
f
)
!=
s
.
definition_length
)
{
{
...
@@ -86,7 +86,7 @@ write_macdef (cpp_reader *pfile, cpp_hashnode *hn, void *file_p)
...
@@ -86,7 +86,7 @@ write_macdef (cpp_reader *pfile, cpp_hashnode *hn, void *file_p)
}
}
}
}
return
1
;
return
1
;
case
NT_ASSERTION
:
case
NT_ASSERTION
:
/* Not currently implemented. */
/* Not currently implemented. */
return
1
;
return
1
;
...
@@ -123,7 +123,7 @@ static int
...
@@ -123,7 +123,7 @@ static int
save_idents
(
cpp_reader
*
pfile
ATTRIBUTE_UNUSED
,
cpp_hashnode
*
hn
,
void
*
ss_p
)
save_idents
(
cpp_reader
*
pfile
ATTRIBUTE_UNUSED
,
cpp_hashnode
*
hn
,
void
*
ss_p
)
{
{
struct
cpp_savedstate
*
const
ss
=
(
struct
cpp_savedstate
*
)
ss_p
;
struct
cpp_savedstate
*
const
ss
=
(
struct
cpp_savedstate
*
)
ss_p
;
if
(
hn
->
type
!=
NT_VOID
)
if
(
hn
->
type
!=
NT_VOID
)
{
{
struct
cpp_string
news
;
struct
cpp_string
news
;
...
@@ -136,7 +136,7 @@ save_idents (cpp_reader *pfile ATTRIBUTE_UNUSED, cpp_hashnode *hn, void *ss_p)
...
@@ -136,7 +136,7 @@ save_idents (cpp_reader *pfile ATTRIBUTE_UNUSED, cpp_hashnode *hn, void *ss_p)
{
{
struct
cpp_string
*
sp
;
struct
cpp_string
*
sp
;
unsigned
char
*
text
;
unsigned
char
*
text
;
sp
=
XNEW
(
struct
cpp_string
);
sp
=
XNEW
(
struct
cpp_string
);
*
slot
=
sp
;
*
slot
=
sp
;
...
@@ -157,7 +157,7 @@ hashmem (const void *p_p, size_t sz)
...
@@ -157,7 +157,7 @@ hashmem (const void *p_p, size_t sz)
const
unsigned
char
*
p
=
(
const
unsigned
char
*
)
p_p
;
const
unsigned
char
*
p
=
(
const
unsigned
char
*
)
p_p
;
size_t
i
;
size_t
i
;
hashval_t
h
;
hashval_t
h
;
h
=
0
;
h
=
0
;
for
(
i
=
0
;
i
<
sz
;
i
++
)
for
(
i
=
0
;
i
<
sz
;
i
++
)
h
=
h
*
67
-
(
*
p
++
-
113
);
h
=
h
*
67
-
(
*
p
++
-
113
);
...
@@ -194,10 +194,10 @@ cpp_save_state (cpp_reader *r, FILE *f)
...
@@ -194,10 +194,10 @@ cpp_save_state (cpp_reader *r, FILE *f)
{
{
/* Save the list of non-void identifiers for the dependency checking. */
/* Save the list of non-void identifiers for the dependency checking. */
r
->
savedstate
=
XNEW
(
struct
cpp_savedstate
);
r
->
savedstate
=
XNEW
(
struct
cpp_savedstate
);
r
->
savedstate
->
definedhash
=
htab_create
(
100
,
cpp_string_hash
,
r
->
savedstate
->
definedhash
=
htab_create
(
100
,
cpp_string_hash
,
cpp_string_eq
,
NULL
);
cpp_string_eq
,
NULL
);
cpp_forall_identifiers
(
r
,
save_idents
,
r
->
savedstate
);
cpp_forall_identifiers
(
r
,
save_idents
,
r
->
savedstate
);
/* Write out the list of defined identifiers. */
/* Write out the list of defined identifiers. */
cpp_forall_identifiers
(
r
,
write_macdef
,
f
);
cpp_forall_identifiers
(
r
,
write_macdef
,
f
);
...
@@ -210,20 +210,20 @@ static int
...
@@ -210,20 +210,20 @@ static int
count_defs
(
cpp_reader
*
pfile
ATTRIBUTE_UNUSED
,
cpp_hashnode
*
hn
,
void
*
ss_p
)
count_defs
(
cpp_reader
*
pfile
ATTRIBUTE_UNUSED
,
cpp_hashnode
*
hn
,
void
*
ss_p
)
{
{
struct
cpp_savedstate
*
const
ss
=
(
struct
cpp_savedstate
*
)
ss_p
;
struct
cpp_savedstate
*
const
ss
=
(
struct
cpp_savedstate
*
)
ss_p
;
switch
(
hn
->
type
)
switch
(
hn
->
type
)
{
{
case
NT_MACRO
:
case
NT_MACRO
:
if
(
hn
->
flags
&
NODE_BUILTIN
)
if
(
hn
->
flags
&
NODE_BUILTIN
)
return
1
;
return
1
;
/* else fall through. */
/* else fall through. */
case
NT_VOID
:
case
NT_VOID
:
{
{
struct
cpp_string
news
;
struct
cpp_string
news
;
void
**
slot
;
void
**
slot
;
news
.
len
=
NODE_LEN
(
hn
);
news
.
len
=
NODE_LEN
(
hn
);
news
.
text
=
NODE_NAME
(
hn
);
news
.
text
=
NODE_NAME
(
hn
);
slot
=
(
void
**
)
htab_find
(
ss
->
definedhash
,
&
news
);
slot
=
(
void
**
)
htab_find
(
ss
->
definedhash
,
&
news
);
...
@@ -249,20 +249,20 @@ static int
...
@@ -249,20 +249,20 @@ static int
write_defs
(
cpp_reader
*
pfile
ATTRIBUTE_UNUSED
,
cpp_hashnode
*
hn
,
void
*
ss_p
)
write_defs
(
cpp_reader
*
pfile
ATTRIBUTE_UNUSED
,
cpp_hashnode
*
hn
,
void
*
ss_p
)
{
{
struct
cpp_savedstate
*
const
ss
=
(
struct
cpp_savedstate
*
)
ss_p
;
struct
cpp_savedstate
*
const
ss
=
(
struct
cpp_savedstate
*
)
ss_p
;
switch
(
hn
->
type
)
switch
(
hn
->
type
)
{
{
case
NT_MACRO
:
case
NT_MACRO
:
if
(
hn
->
flags
&
NODE_BUILTIN
)
if
(
hn
->
flags
&
NODE_BUILTIN
)
return
1
;
return
1
;
/* else fall through. */
/* else fall through. */
case
NT_VOID
:
case
NT_VOID
:
{
{
struct
cpp_string
news
;
struct
cpp_string
news
;
void
**
slot
;
void
**
slot
;
news
.
len
=
NODE_LEN
(
hn
);
news
.
len
=
NODE_LEN
(
hn
);
news
.
text
=
NODE_NAME
(
hn
);
news
.
text
=
NODE_NAME
(
hn
);
slot
=
(
void
**
)
htab_find
(
ss
->
definedhash
,
&
news
);
slot
=
(
void
**
)
htab_find
(
ss
->
definedhash
,
&
news
);
...
@@ -303,7 +303,7 @@ cpp_write_pch_deps (cpp_reader *r, FILE *f)
...
@@ -303,7 +303,7 @@ cpp_write_pch_deps (cpp_reader *r, FILE *f)
struct
cpp_savedstate
*
const
ss
=
r
->
savedstate
;
struct
cpp_savedstate
*
const
ss
=
r
->
savedstate
;
unsigned
char
*
definedstrs
;
unsigned
char
*
definedstrs
;
size_t
i
;
size_t
i
;
/* Collect the list of identifiers which have been seen and
/* Collect the list of identifiers which have been seen and
weren't defined to anything previously. */
weren't defined to anything previously. */
ss
->
hashsize
=
0
;
ss
->
hashsize
=
0
;
...
@@ -421,7 +421,7 @@ collect_ht_nodes (cpp_reader *pfile ATTRIBUTE_UNUSED, cpp_hashnode *hn,
...
@@ -421,7 +421,7 @@ collect_ht_nodes (cpp_reader *pfile ATTRIBUTE_UNUSED, cpp_hashnode *hn,
with the preprocessor's current definitions. It will be consistent
with the preprocessor's current definitions. It will be consistent
when:
when:
- anything that was defined just before the PCH was generated
- anything that was defined just before the PCH was generated
is defined the same way now; and
is defined the same way now; and
- anything that was not defined then, but is defined now, was not
- anything that was not defined then, but is defined now, was not
used by the PCH.
used by the PCH.
...
@@ -441,17 +441,17 @@ cpp_valid_state (cpp_reader *r, const char *name, int fd)
...
@@ -441,17 +441,17 @@ cpp_valid_state (cpp_reader *r, const char *name, int fd)
unsigned
char
*
first
,
*
last
;
unsigned
char
*
first
,
*
last
;
unsigned
int
i
;
unsigned
int
i
;
unsigned
int
counter
;
unsigned
int
counter
;
/* Read in the list of identifiers that must be defined
/* Read in the list of identifiers that must be defined
Check that they are defined in the same way. */
Check that they are defined in the same way. */
for
(;;)
for
(;;)
{
{
cpp_hashnode
*
h
;
cpp_hashnode
*
h
;
const
unsigned
char
*
newdefn
;
const
unsigned
char
*
newdefn
;
if
(
read
(
fd
,
&
m
,
sizeof
(
m
))
!=
sizeof
(
m
))
if
(
read
(
fd
,
&
m
,
sizeof
(
m
))
!=
sizeof
(
m
))
goto
error
;
goto
error
;
if
(
m
.
name_length
==
0
)
if
(
m
.
name_length
==
0
)
break
;
break
;
...
@@ -471,10 +471,10 @@ cpp_valid_state (cpp_reader *r, const char *name, int fd)
...
@@ -471,10 +471,10 @@ cpp_valid_state (cpp_reader *r, const char *name, int fd)
namebuf
=
XNEWVEC
(
unsigned
char
,
namebufsz
);
namebuf
=
XNEWVEC
(
unsigned
char
,
namebufsz
);
}
}
if
((
size_t
)
read
(
fd
,
namebuf
,
m
.
definition_length
)
if
((
size_t
)
read
(
fd
,
namebuf
,
m
.
definition_length
)
!=
m
.
definition_length
)
!=
m
.
definition_length
)
goto
error
;
goto
error
;
h
=
cpp_lookup
(
r
,
namebuf
,
m
.
name_length
);
h
=
cpp_lookup
(
r
,
namebuf
,
m
.
name_length
);
if
(
m
.
flags
&
NODE_POISONED
if
(
m
.
flags
&
NODE_POISONED
||
h
->
type
!=
NT_MACRO
||
h
->
type
!=
NT_MACRO
...
@@ -488,7 +488,7 @@ cpp_valid_state (cpp_reader *r, const char *name, int fd)
...
@@ -488,7 +488,7 @@ cpp_valid_state (cpp_reader *r, const char *name, int fd)
}
}
newdefn
=
cpp_macro_definition
(
r
,
h
);
newdefn
=
cpp_macro_definition
(
r
,
h
);
if
(
m
.
definition_length
!=
ustrlen
(
newdefn
)
if
(
m
.
definition_length
!=
ustrlen
(
newdefn
)
||
memcmp
(
namebuf
,
newdefn
,
m
.
definition_length
)
!=
0
)
||
memcmp
(
namebuf
,
newdefn
,
m
.
definition_length
)
!=
0
)
{
{
...
@@ -516,17 +516,17 @@ cpp_valid_state (cpp_reader *r, const char *name, int fd)
...
@@ -516,17 +516,17 @@ cpp_valid_state (cpp_reader *r, const char *name, int fd)
nl
.
defs
=
XNEWVEC
(
cpp_hashnode
*
,
nl
.
asize
);
nl
.
defs
=
XNEWVEC
(
cpp_hashnode
*
,
nl
.
asize
);
cpp_forall_identifiers
(
r
,
&
collect_ht_nodes
,
&
nl
);
cpp_forall_identifiers
(
r
,
&
collect_ht_nodes
,
&
nl
);
qsort
(
nl
.
defs
,
nl
.
n_defs
,
sizeof
(
cpp_hashnode
*
),
&
comp_hashnodes
);
qsort
(
nl
.
defs
,
nl
.
n_defs
,
sizeof
(
cpp_hashnode
*
),
&
comp_hashnodes
);
/* Loop through nl.defs and undeftab, both of which are sorted lists.
/* Loop through nl.defs and undeftab, both of which are sorted lists.
There should be no matches. */
There should be no matches. */
first
=
undeftab
;
first
=
undeftab
;
last
=
undeftab
+
m
.
definition_length
;
last
=
undeftab
+
m
.
definition_length
;
i
=
0
;
i
=
0
;
while
(
first
<
last
&&
i
<
nl
.
n_defs
)
while
(
first
<
last
&&
i
<
nl
.
n_defs
)
{
{
int
cmp
=
ustrcmp
(
first
,
NODE_NAME
(
nl
.
defs
[
i
]));
int
cmp
=
ustrcmp
(
first
,
NODE_NAME
(
nl
.
defs
[
i
]));
if
(
cmp
<
0
)
if
(
cmp
<
0
)
first
+=
ustrlen
(
first
)
+
1
;
first
+=
ustrlen
(
first
)
+
1
;
else
if
(
cmp
>
0
)
else
if
(
cmp
>
0
)
...
@@ -534,13 +534,13 @@ cpp_valid_state (cpp_reader *r, const char *name, int fd)
...
@@ -534,13 +534,13 @@ cpp_valid_state (cpp_reader *r, const char *name, int fd)
else
else
{
{
if
(
CPP_OPTION
(
r
,
warn_invalid_pch
))
if
(
CPP_OPTION
(
r
,
warn_invalid_pch
))
cpp_error
(
r
,
CPP_DL_WARNING_SYSHDR
,
cpp_error
(
r
,
CPP_DL_WARNING_SYSHDR
,
"%s: not used because `%s' is defined"
,
"%s: not used because `%s' is defined"
,
name
,
first
);
name
,
first
);
goto
fail
;
goto
fail
;
}
}
}
}
free
(
nl
.
defs
);
free
(
nl
.
defs
);
nl
.
defs
=
NULL
;
nl
.
defs
=
NULL
;
free
(
undeftab
);
free
(
undeftab
);
...
@@ -554,7 +554,7 @@ cpp_valid_state (cpp_reader *r, const char *name, int fd)
...
@@ -554,7 +554,7 @@ cpp_valid_state (cpp_reader *r, const char *name, int fd)
if
(
counter
&&
r
->
counter
)
if
(
counter
&&
r
->
counter
)
{
{
if
(
CPP_OPTION
(
r
,
warn_invalid_pch
))
if
(
CPP_OPTION
(
r
,
warn_invalid_pch
))
cpp_error
(
r
,
CPP_DL_WARNING_SYSHDR
,
cpp_error
(
r
,
CPP_DL_WARNING_SYSHDR
,
"%s: not used because `__COUNTER__' is invalid"
,
"%s: not used because `__COUNTER__' is invalid"
,
name
);
name
);
goto
fail
;
goto
fail
;
...
@@ -579,7 +579,7 @@ cpp_valid_state (cpp_reader *r, const char *name, int fd)
...
@@ -579,7 +579,7 @@ cpp_valid_state (cpp_reader *r, const char *name, int fd)
/* Save all the existing macros. */
/* Save all the existing macros. */
struct
save_macro_data
struct
save_macro_data
{
{
uchar
**
defns
;
uchar
**
defns
;
size_t
count
;
size_t
count
;
...
@@ -601,7 +601,7 @@ struct save_macro_data
...
@@ -601,7 +601,7 @@ struct save_macro_data
file were not saved in this way, but this is not done (yet), except
file were not saved in this way, but this is not done (yet), except
for builtins, and for #assert by default. */
for builtins, and for #assert by default. */
static
int
static
int
save_macros
(
cpp_reader
*
r
,
cpp_hashnode
*
h
,
void
*
data_p
)
save_macros
(
cpp_reader
*
r
,
cpp_hashnode
*
h
,
void
*
data_p
)
{
{
struct
save_macro_data
*
data
=
(
struct
save_macro_data
*
)
data_p
;
struct
save_macro_data
*
data
=
(
struct
save_macro_data
*
)
data_p
;
...
@@ -611,9 +611,9 @@ save_macros (cpp_reader *r, cpp_hashnode *h, void *data_p)
...
@@ -611,9 +611,9 @@ save_macros (cpp_reader *r, cpp_hashnode *h, void *data_p)
if
(
data
->
count
==
data
->
array_size
)
if
(
data
->
count
==
data
->
array_size
)
{
{
data
->
array_size
*=
2
;
data
->
array_size
*=
2
;
data
->
defns
=
XRESIZEVEC
(
uchar
*
,
data
->
defns
,
(
data
->
array_size
));
data
->
defns
=
XRESIZEVEC
(
uchar
*
,
data
->
defns
,
(
data
->
array_size
));
}
}
switch
(
h
->
type
)
switch
(
h
->
type
)
{
{
case
NT_ASSERTION
:
case
NT_ASSERTION
:
...
@@ -630,7 +630,7 @@ save_macros (cpp_reader *r, cpp_hashnode *h, void *data_p)
...
@@ -630,7 +630,7 @@ save_macros (cpp_reader *r, cpp_hashnode *h, void *data_p)
data
->
defns
[
data
->
count
][
defnlen
]
=
'\n'
;
data
->
defns
[
data
->
count
][
defnlen
]
=
'\n'
;
}
}
break
;
break
;
default:
default:
abort
();
abort
();
}
}
...
@@ -646,7 +646,7 @@ void
...
@@ -646,7 +646,7 @@ void
cpp_prepare_state
(
cpp_reader
*
r
,
struct
save_macro_data
**
data
)
cpp_prepare_state
(
cpp_reader
*
r
,
struct
save_macro_data
**
data
)
{
{
struct
save_macro_data
*
d
=
XNEW
(
struct
save_macro_data
);
struct
save_macro_data
*
d
=
XNEW
(
struct
save_macro_data
);
d
->
array_size
=
512
;
d
->
array_size
=
512
;
d
->
defns
=
XNEWVEC
(
uchar
*
,
d
->
array_size
);
d
->
defns
=
XNEWVEC
(
uchar
*
,
d
->
array_size
);
d
->
count
=
0
;
d
->
count
=
0
;
...
@@ -656,7 +656,7 @@ cpp_prepare_state (cpp_reader *r, struct save_macro_data **data)
...
@@ -656,7 +656,7 @@ cpp_prepare_state (cpp_reader *r, struct save_macro_data **data)
}
}
/* Given a precompiled header that was previously determined to be valid,
/* Given a precompiled header that was previously determined to be valid,
apply all its definitions (and undefinitions) to the current state.
apply all its definitions (and undefinitions) to the current state.
DEPNAME is passed to deps_restore. */
DEPNAME is passed to deps_restore. */
int
int
...
@@ -667,7 +667,7 @@ cpp_read_state (cpp_reader *r, const char *name, FILE *f,
...
@@ -667,7 +667,7 @@ cpp_read_state (cpp_reader *r, const char *name, FILE *f,
struct
lexer_state
old_state
;
struct
lexer_state
old_state
;
unsigned
int
counter
;
unsigned
int
counter
;
/* Restore spec_nodes, which will be full of references to the old
/* Restore spec_nodes, which will be full of references to the old
hashtable entries and so will now be invalid. */
hashtable entries and so will now be invalid. */
{
{
struct
spec_nodes
*
s
=
&
r
->
spec_nodes
;
struct
spec_nodes
*
s
=
&
r
->
spec_nodes
;
...
@@ -732,7 +732,7 @@ cpp_read_state (cpp_reader *r, const char *name, FILE *f,
...
@@ -732,7 +732,7 @@ cpp_read_state (cpp_reader *r, const char *name, FILE *f,
r
->
counter
=
counter
;
r
->
counter
=
counter
;
return
0
;
return
0
;
error:
error:
cpp_errno
(
r
,
CPP_DL_ERROR
,
"while reading precompiled header"
);
cpp_errno
(
r
,
CPP_DL_ERROR
,
"while reading precompiled header"
);
return
-
1
;
return
-
1
;
...
...
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