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
e212c7f5
Commit
e212c7f5
authored
Oct 31, 2012
by
Ian Lance Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
runtime/goc2c: Drop gc support, change int to intgo.
From-SVN: r193046
parent
2455de38
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
171 deletions
+54
-171
libgo/Makefile.am
+8
-8
libgo/Makefile.in
+8
-8
libgo/runtime/goc2c.c
+38
-155
No files found.
libgo/Makefile.am
View file @
e212c7f5
...
...
@@ -536,35 +536,35 @@ goc2c: goc2c.$(OBJEXT)
$(CC_FOR_BUILD)
$(CFLAGS_FOR_BUILD)
$(LDFLAGS_FOR_BUILD)
-o
$@
$<
malloc.c
:
$(srcdir)/runtime/malloc.goc goc2c
./goc2c
--gcc
$<
>
$@
.tmp
./goc2c
$<
>
$@
.tmp
mv
-f
$@
.tmp
$@
mprof.c
:
$(srcdir)/runtime/mprof.goc goc2c
./goc2c
--gcc
$<
>
$@
.tmp
./goc2c
$<
>
$@
.tmp
mv
-f
$@
.tmp
$@
reflect.c
:
$(srcdir)/runtime/reflect.goc goc2c
./goc2c
--gcc
$<
>
$@
.tmp
./goc2c
$<
>
$@
.tmp
mv
-f
$@
.tmp
$@
runtime1.c
:
$(srcdir)/runtime/runtime1.goc goc2c
./goc2c
--gcc
$<
>
$@
.tmp
./goc2c
$<
>
$@
.tmp
mv
-f
$@
.tmp
$@
sema.c
:
$(srcdir)/runtime/sema.goc goc2c
./goc2c
--gcc
$<
>
$@
.tmp
./goc2c
$<
>
$@
.tmp
mv
-f
$@
.tmp
$@
sigqueue.c
:
$(srcdir)/runtime/sigqueue.goc goc2c
./goc2c
--g
cc
--g
o-pkgpath
os_signal
$<
>
$@
.tmp
./goc2c
--go-pkgpath
os_signal
$<
>
$@
.tmp
mv
-f
$@
.tmp
$@
time.c
:
$(srcdir)/runtime/time.goc goc2c
./goc2c
--gcc
$<
>
$@
.tmp
./goc2c
$<
>
$@
.tmp
mv
-f
$@
.tmp
$@
%.c
:
$(srcdir)/runtime/%.goc goc2c
./goc2c
--gcc
$<
>
$@
.tmp
./goc2c
$<
>
$@
.tmp
mv
-f
$@
.tmp
$@
go_bufio_files
=
\
...
...
libgo/Makefile.in
View file @
e212c7f5
...
...
@@ -4310,35 +4310,35 @@ goc2c: goc2c.$(OBJEXT)
$(CC_FOR_BUILD)
$(CFLAGS_FOR_BUILD)
$(LDFLAGS_FOR_BUILD)
-o
$@
$<
malloc.c
:
$(srcdir)/runtime/malloc.goc goc2c
./goc2c
--gcc
$<
>
$@
.tmp
./goc2c
$<
>
$@
.tmp
mv
-f
$@
.tmp
$@
mprof.c
:
$(srcdir)/runtime/mprof.goc goc2c
./goc2c
--gcc
$<
>
$@
.tmp
./goc2c
$<
>
$@
.tmp
mv
-f
$@
.tmp
$@
reflect.c
:
$(srcdir)/runtime/reflect.goc goc2c
./goc2c
--gcc
$<
>
$@
.tmp
./goc2c
$<
>
$@
.tmp
mv
-f
$@
.tmp
$@
runtime1.c
:
$(srcdir)/runtime/runtime1.goc goc2c
./goc2c
--gcc
$<
>
$@
.tmp
./goc2c
$<
>
$@
.tmp
mv
-f
$@
.tmp
$@
sema.c
:
$(srcdir)/runtime/sema.goc goc2c
./goc2c
--gcc
$<
>
$@
.tmp
./goc2c
$<
>
$@
.tmp
mv
-f
$@
.tmp
$@
sigqueue.c
:
$(srcdir)/runtime/sigqueue.goc goc2c
./goc2c
--g
cc
--g
o-pkgpath
os_signal
$<
>
$@
.tmp
./goc2c
--go-pkgpath
os_signal
$<
>
$@
.tmp
mv
-f
$@
.tmp
$@
time.c
:
$(srcdir)/runtime/time.goc goc2c
./goc2c
--gcc
$<
>
$@
.tmp
./goc2c
$<
>
$@
.tmp
mv
-f
$@
.tmp
$@
%.c
:
$(srcdir)/runtime/%.goc goc2c
./goc2c
--gcc
$<
>
$@
.tmp
./goc2c
$<
>
$@
.tmp
mv
-f
$@
.tmp
$@
version.go
:
s-version; @true
...
...
libgo/runtime/goc2c.c
View file @
e212c7f5
...
...
@@ -30,13 +30,10 @@
#include <string.h>
#include <errno.h>
/* Whether we're emitting for gcc */
static
int
gcc
;
/* Package path to use; only meaningful for gcc */
/* Package path to use. */
static
const
char
*
pkgpath
;
/* Package prefix to use
; only meaningful for gcc
*/
/* Package prefix to use
.
*/
static
const
char
*
prefix
;
/* File and line number */
...
...
@@ -50,53 +47,6 @@ struct params {
char
*
type
;
};
/* index into type_table */
enum
{
Bool
,
Float
,
Int
,
Uint
,
Uintptr
,
String
,
Slice
,
Eface
,
};
static
struct
{
char
*
name
;
int
size
;
}
type_table
[]
=
{
/* variable sized first, for easy replacement */
/* order matches enum above */
/* default is 32-bit architecture sizes */
"bool"
,
1
,
"float"
,
4
,
"int"
,
4
,
"uint"
,
4
,
"uintptr"
,
4
,
"String"
,
8
,
"Slice"
,
12
,
"Eface"
,
8
,
/* fixed size */
"float32"
,
4
,
"float64"
,
8
,
"byte"
,
1
,
"int8"
,
1
,
"uint8"
,
1
,
"int16"
,
2
,
"uint16"
,
2
,
"int32"
,
4
,
"uint32"
,
4
,
"int64"
,
8
,
"uint64"
,
8
,
NULL
,
};
/* Fixed structure alignment (non-gcc only) */
int
structround
=
4
;
char
*
argv0
;
static
void
...
...
@@ -147,6 +97,15 @@ xrealloc(void *buf, unsigned int size)
return
ret
;
}
/* Copy a string into memory without fail. */
static
char
*
xstrdup
(
const
char
*
p
)
{
char
*
ret
=
xmalloc
(
strlen
(
p
)
+
1
);
strcpy
(
ret
,
p
);
return
ret
;
}
/* Free a list of parameters. */
static
void
free_params
(
struct
params
*
p
)
...
...
@@ -351,14 +310,29 @@ read_type(void)
unsigned
int
len
;
p
=
read_token_no_eof
();
if
(
*
p
!=
'*'
)
if
(
*
p
!=
'*'
)
{
/* Convert the Go type "int" to the C type "intgo",
and similarly for "uint". */
if
(
strcmp
(
p
,
"int"
)
==
0
)
return
xstrdup
(
"intgo"
);
else
if
(
strcmp
(
p
,
"uint"
)
==
0
)
return
xstrdup
(
"uintgo"
);
return
p
;
}
op
=
p
;
pointer_count
=
0
;
while
(
*
p
==
'*'
)
{
++
pointer_count
;
++
p
;
}
/* Convert the Go type "int" to the C type "intgo", and
similarly for "uint". */
if
(
strcmp
(
p
,
"int"
)
==
0
)
p
=
(
char
*
)
"intgo"
;
else
if
(
strcmp
(
p
,
"uint"
)
==
0
)
p
=
(
char
*
)
"uintgo"
;
len
=
strlen
(
p
);
q
=
xmalloc
(
len
+
pointer_count
+
1
);
memcpy
(
q
,
p
,
len
);
...
...
@@ -372,39 +346,19 @@ read_type(void)
return
q
;
}
/* Return the size of the given type. */
static
int
type_size
(
char
*
p
)
{
int
i
;
if
(
p
[
strlen
(
p
)
-
1
]
==
'*'
)
return
type_table
[
Uintptr
].
size
;
for
(
i
=
0
;
type_table
[
i
].
name
;
i
++
)
if
(
strcmp
(
type_table
[
i
].
name
,
p
)
==
0
)
return
type_table
[
i
].
size
;
if
(
!
gcc
)
{
sysfatal
(
"%s:%ud: unknown type %s
\n
"
,
file
,
lineno
,
p
);
}
return
1
;
}
/*
* Read a list of parameters. Each parameter is a name and a type.
* The list ends with a ')'. We have already read the '('.
*/
static
struct
params
*
read_params
(
int
*
poffset
)
read_params
()
{
char
*
token
;
struct
params
*
ret
,
**
pp
,
*
p
;
int
offset
,
size
,
rnd
;
ret
=
NULL
;
pp
=
&
ret
;
token
=
read_token_no_eof
();
offset
=
0
;
if
(
strcmp
(
token
,
")"
)
!=
0
)
{
while
(
1
)
{
p
=
xmalloc
(
sizeof
(
struct
params
));
...
...
@@ -414,14 +368,6 @@ read_params(int *poffset)
*
pp
=
p
;
pp
=
&
p
->
next
;
size
=
type_size
(
p
->
type
);
rnd
=
size
;
if
(
rnd
>
structround
)
rnd
=
structround
;
if
(
offset
%
rnd
)
offset
+=
rnd
-
offset
%
rnd
;
offset
+=
size
;
token
=
read_token_no_eof
();
if
(
strcmp
(
token
,
","
)
!=
0
)
break
;
...
...
@@ -432,8 +378,6 @@ read_params(int *poffset)
sysfatal
(
"%s:%ud: expected '('
\n
"
,
file
,
lineno
);
}
if
(
poffset
!=
NULL
)
*
poffset
=
offset
;
return
ret
;
}
...
...
@@ -442,7 +386,7 @@ read_params(int *poffset)
* '{' character. Returns 1 if it read a header, 0 at EOF.
*/
static
int
read_func_header
(
char
**
name
,
struct
params
**
params
,
int
*
paramwid
,
struct
params
**
rets
)
read_func_header
(
char
**
name
,
struct
params
**
params
,
struct
params
**
rets
)
{
int
lastline
;
char
*
token
;
...
...
@@ -474,13 +418,13 @@ read_func_header(char **name, struct params **params, int *paramwid, struct para
sysfatal
(
"%s:%ud: expected
\"
(
\"\n
"
,
file
,
lineno
);
}
*
params
=
read_params
(
paramwid
);
*
params
=
read_params
();
token
=
read_token
();
if
(
token
==
NULL
||
strcmp
(
token
,
"("
)
!=
0
)
*
rets
=
NULL
;
else
{
*
rets
=
read_params
(
NULL
);
*
rets
=
read_params
();
token
=
read_token
();
}
if
(
token
==
NULL
||
strcmp
(
token
,
"{"
)
!=
0
)
{
...
...
@@ -505,43 +449,6 @@ write_params(struct params *params, int *first)
}
}
/* Write a 6g function header. */
static
void
write_6g_func_header
(
char
*
package
,
char
*
name
,
struct
params
*
params
,
int
paramwid
,
struct
params
*
rets
)
{
int
first
,
n
;
printf
(
"void
\n
%s·%s("
,
package
,
name
);
first
=
1
;
write_params
(
params
,
&
first
);
/* insert padding to align output struct */
if
(
rets
!=
NULL
&&
paramwid
%
structround
!=
0
)
{
n
=
structround
-
paramwid
%
structround
;
if
(
n
&
1
)
printf
(
", uint8"
);
if
(
n
&
2
)
printf
(
", uint16"
);
if
(
n
&
4
)
printf
(
", uint32"
);
}
write_params
(
rets
,
&
first
);
printf
(
")
\n
{
\n
"
);
}
/* Write a 6g function trailer. */
static
void
write_6g_func_trailer
(
struct
params
*
rets
)
{
struct
params
*
p
;
for
(
p
=
rets
;
p
!=
NULL
;
p
=
p
->
next
)
printf
(
"
\t
FLUSH(&%s);
\n
"
,
p
->
name
);
printf
(
"}
\n
"
);
}
/* Define the gcc function return type if necessary. */
static
void
define_gcc_return_type
(
char
*
package
,
char
*
name
,
struct
params
*
rets
)
...
...
@@ -619,14 +526,10 @@ write_gcc_func_trailer(char *package, char *name, struct params *rets)
/* Write out a function header. */
static
void
write_func_header
(
char
*
package
,
char
*
name
,
struct
params
*
params
,
int
paramwid
,
write_func_header
(
char
*
package
,
char
*
name
,
struct
params
*
params
,
struct
params
*
rets
)
{
if
(
gcc
)
write_gcc_func_header
(
package
,
name
,
params
,
rets
);
else
write_6g_func_header
(
package
,
name
,
params
,
paramwid
,
rets
);
write_gcc_func_header
(
package
,
name
,
params
,
rets
);
printf
(
"#line %d
\"
%s
\"\n
"
,
lineno
,
file
);
}
...
...
@@ -635,10 +538,7 @@ static void
write_func_trailer
(
char
*
package
,
char
*
name
,
struct
params
*
rets
)
{
if
(
gcc
)
write_gcc_func_trailer
(
package
,
name
,
rets
);
else
write_6g_func_trailer
(
rets
);
write_gcc_func_trailer
(
package
,
name
,
rets
);
}
/*
...
...
@@ -713,12 +613,11 @@ process_file(void)
{
char
*
package
,
*
name
;
struct
params
*
params
,
*
rets
;
int
paramwid
;
package
=
read_package
();
read_preprocessor_lines
();
while
(
read_func_header
(
&
name
,
&
params
,
&
paramwid
,
&
rets
))
{
write_func_header
(
package
,
name
,
params
,
paramwid
,
rets
);
while
(
read_func_header
(
&
name
,
&
params
,
&
rets
))
{
write_func_header
(
package
,
name
,
params
,
rets
);
copy_body
();
write_func_trailer
(
package
,
name
,
rets
);
free
(
name
);
...
...
@@ -731,7 +630,7 @@ process_file(void)
static
void
usage
(
void
)
{
sysfatal
(
"Usage: goc2c [--
6g | --gc] [--
go-pkgpath PKGPATH] [--go-prefix PREFIX] [file]
\n
"
);
sysfatal
(
"Usage: goc2c [--go-pkgpath PKGPATH] [--go-prefix PREFIX] [file]
\n
"
);
}
void
...
...
@@ -743,11 +642,7 @@ main(int argc, char **argv)
while
(
argc
>
1
&&
argv
[
1
][
0
]
==
'-'
)
{
if
(
strcmp
(
argv
[
1
],
"-"
)
==
0
)
break
;
if
(
strcmp
(
argv
[
1
],
"--6g"
)
==
0
)
gcc
=
0
;
else
if
(
strcmp
(
argv
[
1
],
"--gcc"
)
==
0
)
gcc
=
1
;
else
if
(
strcmp
(
argv
[
1
],
"--go-pkgpath"
)
==
0
&&
argc
>
2
)
{
if
(
strcmp
(
argv
[
1
],
"--go-pkgpath"
)
==
0
&&
argc
>
2
)
{
pkgpath
=
argv
[
2
];
argc
--
;
argv
++
;
...
...
@@ -775,18 +670,6 @@ main(int argc, char **argv)
sysfatal
(
"open %s: %r
\n
"
,
file
);
}
if
(
!
gcc
)
{
// 6g etc; update size table
goarch
=
getenv
(
"GOARCH"
);
if
(
goarch
!=
NULL
&&
strcmp
(
goarch
,
"amd64"
)
==
0
)
{
type_table
[
Uintptr
].
size
=
8
;
type_table
[
String
].
size
=
16
;
type_table
[
Slice
].
size
=
8
+
4
+
4
;
type_table
[
Eface
].
size
=
8
+
8
;
structround
=
8
;
}
}
printf
(
"// AUTO-GENERATED by autogen.sh; DO NOT EDIT
\n\n
"
);
process_file
();
exit
(
0
);
...
...
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