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
e499b5ee
Commit
e499b5ee
authored
Feb 01, 2011
by
Ian Lance Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add __sync_bool_compare_and_swap_4 for targets which don't have it.
From-SVN: r169502
parent
22843acd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
0 deletions
+36
-0
libgo/runtime/thread.c
+36
-0
No files found.
libgo/runtime/thread.c
View file @
e499b5ee
...
...
@@ -3,6 +3,7 @@
// license that can be found in the LICENSE file.
#include "runtime.h"
#include "go-assert.h"
void
runtime_initlock
(
Lock
*
l
)
...
...
@@ -75,3 +76,38 @@ runtime_destroylock(Lock *l)
{
sem_destroy
(
&
l
->
sem
);
}
#ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_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
;
_Bool
__sync_bool_compare_and_swap_4
(
uint32
*
,
uint32
,
uint32
)
__attribute__
((
visibility
(
"hidden"
)));
_Bool
__sync_bool_compare_and_swap_4
(
uint32
*
ptr
,
uint32
old
,
uint32
new
)
{
int
i
;
_Bool
ret
;
i
=
pthread_mutex_lock
(
&
sync_lock
);
__go_assert
(
i
==
0
);
if
(
*
ptr
!=
old
)
{
ret
=
0
;
}
else
{
*
ptr
=
new
;
ret
=
1
;
}
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