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
084996f1
Commit
084996f1
authored
Feb 04, 2011
by
Ian Lance Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement __sync_fetch_and_add_4 if necessary.
From-SVN: r169820
parent
6dc54618
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
0 deletions
+79
-0
libgo/config.h.in
+4
-0
libgo/configure
+29
-0
libgo/configure.ac
+14
-0
libgo/runtime/go-semacquire.c
+32
-0
No files found.
libgo/config.h.in
View file @
084996f1
...
@@ -43,6 +43,10 @@
...
@@ -43,6 +43,10 @@
function for uint32 */
function for uint32 */
#undef HAVE_SYNC_BOOL_COMPARE_AND_SWAP_4
#undef HAVE_SYNC_BOOL_COMPARE_AND_SWAP_4
/* Define to 1 if the compiler provides the __sync_fetch_and_add function for
uint32 */
#undef HAVE_SYNC_FETCH_AND_ADD_4
/* Define to 1 if you have the <syscall.h> header file. */
/* Define to 1 if you have the <syscall.h> header file. */
#undef HAVE_SYSCALL_H
#undef HAVE_SYSCALL_H
...
...
libgo/configure
View file @
084996f1
...
@@ -14206,6 +14206,35 @@ $as_echo "#define HAVE_SYNC_BOOL_COMPARE_AND_SWAP_4 1" >>confdefs.h
...
@@ -14206,6 +14206,35 @@ $as_echo "#define HAVE_SYNC_BOOL_COMPARE_AND_SWAP_4 1" >>confdefs.h
fi
fi
{
$as_echo
"
$as_me
:
${
as_lineno
-
$LINENO
}
: checking for __sync_fetch_and_add_4"
>
&5
$as_echo_n
"checking for __sync_fetch_and_add_4... "
>
&6
;
}
if
test
"
${
libgo_cv_func___sync_fetch_and_add_4
+set
}
"
=
set
;
then
:
$as_echo_n
"(cached) "
>
&6
else
cat
confdefs.h -
<<
_ACEOF
>conftest.
$ac_ext
/* end confdefs.h. */
typedef unsigned int uint32 __attribute__ ((mode (SI)));
uint32 i;
int main() { return __sync_fetch_and_add (&i, 1); }
_ACEOF
if
ac_fn_c_try_link
"
$LINENO
"
;
then
:
libgo_cv_func___sync_fetch_and_add_4
=
yes
else
libgo_cv_func___sync_fetch_and_add_4
=
no
fi
rm
-f
core conftest.err conftest.
$ac_objext
\
conftest
$ac_exeext
conftest.
$ac_ext
fi
{
$as_echo
"
$as_me
:
${
as_lineno
-
$LINENO
}
: result:
$libgo_cv_func___sync_fetch_and_add_4
"
>
&5
$as_echo
"
$libgo_cv_func___sync_fetch_and_add_4
"
>
&6
;
}
if
test
"
$libgo_cv_func___sync_fetch_and_add_4
"
=
"yes"
;
then
$as_echo
"#define HAVE_SYNC_FETCH_AND_ADD_4 1"
>>
confdefs.h
fi
{
$as_echo
"
$as_me
:
${
as_lineno
-
$LINENO
}
: checking whether compiler supports -minline-all-stringops"
>
&5
{
$as_echo
"
$as_me
:
${
as_lineno
-
$LINENO
}
: checking whether compiler supports -minline-all-stringops"
>
&5
$as_echo_n
"checking whether compiler supports -minline-all-stringops... "
>
&6
;
}
$as_echo_n
"checking whether compiler supports -minline-all-stringops... "
>
&6
;
}
if
test
"
${
libgo_cv_c_stringops
+set
}
"
=
set
;
then
:
if
test
"
${
libgo_cv_c_stringops
+set
}
"
=
set
;
then
:
...
...
libgo/configure.ac
View file @
084996f1
...
@@ -396,6 +396,20 @@ if test "$libgo_cv_func___sync_bool_compare_and_swap_4" = "yes"; then
...
@@ -396,6 +396,20 @@ if test "$libgo_cv_func___sync_bool_compare_and_swap_4" = "yes"; then
[Define to 1 if the compiler provides the __sync_bool_compare_and_swap function for uint32])
[Define to 1 if the compiler provides the __sync_bool_compare_and_swap function for uint32])
fi
fi
AC_CACHE_CHECK([for __sync_fetch_and_add_4],
[libgo_cv_func___sync_fetch_and_add_4],
[AC_LINK_IFELSE([
typedef unsigned int uint32 __attribute__ ((mode (SI)));
uint32 i;
int main() { return __sync_fetch_and_add (&i, 1); }
],
[libgo_cv_func___sync_fetch_and_add_4=yes],
[libgo_cv_func___sync_fetch_and_add_4=no])])
if test "$libgo_cv_func___sync_fetch_and_add_4" = "yes"; then
AC_DEFINE(HAVE_SYNC_FETCH_AND_ADD_4, 1,
[Define to 1 if the compiler provides the __sync_fetch_and_add function for uint32])
fi
dnl For x86 we want to use the -minline-all-stringops option to avoid
dnl For x86 we want to use the -minline-all-stringops option to avoid
dnl forcing a stack split when calling memcpy and friends.
dnl forcing a stack split when calling memcpy and friends.
AC_CACHE_CHECK([whether compiler supports -minline-all-stringops],
AC_CACHE_CHECK([whether compiler supports -minline-all-stringops],
...
...
libgo/runtime/go-semacquire.c
View file @
084996f1
...
@@ -117,3 +117,35 @@ semrelease (uint32 *addr)
...
@@ -117,3 +117,35 @@ semrelease (uint32 *addr)
__go_assert
(
i
==
0
);
__go_assert
(
i
==
0
);
}
}
}
}
#ifndef HAVE_SYNC_FETCH_AND_ADD_4
/* For targets which don't have the required sync support. Really
this should be provided by gcc itself. FIXME. */
static
pthread_mutex_t
sync_lock
=
PTHREAD_MUTEX_INITIALIZER
;
uint32
__sync_fetch_and_add_4
(
uint32
*
,
uint32
)
__attribute__
((
visibility
(
"hidden"
)));
uint32
__sync_fetch_and_add_4
(
uint32
*
ptr
,
uint32
add
)
{
int
i
;
uint32
ret
;
i
=
pthread_mutex_lock
(
&
sync_lock
);
__go_assert
(
i
==
0
);
ret
=
*
ptr
;
*
ptr
+=
add
;
i
=
pthread_mutex_unlock
(
&
sync_lock
);
__go_assert
(
i
==
0
);
return
ret
;
}
#endif
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