Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
4beda4e5
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4beda4e5
编写于
7月 17, 2013
作者:
B
Brian Anderson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
std::rt: Stop using unstable::global in change_dir_locked
上级
f8c4d99d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
40 addition
and
14 deletion
+40
-14
src/libstd/os.rs
src/libstd/os.rs
+26
-14
src/rt/rust_builtin.cpp
src/rt/rust_builtin.cpp
+12
-0
src/rt/rustrt.def.in
src/rt/rustrt.def.in
+2
-0
未找到文件。
src/libstd/os.rs
浏览文件 @
4beda4e5
...
@@ -869,26 +869,38 @@ fn chdir(p: &Path) -> bool {
...
@@ -869,26 +869,38 @@ fn chdir(p: &Path) -> bool {
/// CWD to what it was before, returning true.
/// CWD to what it was before, returning true.
/// Returns false if the directory doesn't exist or if the directory change
/// Returns false if the directory doesn't exist or if the directory change
/// is otherwise unsuccessful.
/// is otherwise unsuccessful.
/// FIXME #7870 This probably shouldn't be part of the public API
pub
fn
change_dir_locked
(
p
:
&
Path
,
action
:
&
fn
())
->
bool
{
pub
fn
change_dir_locked
(
p
:
&
Path
,
action
:
&
fn
())
->
bool
{
use
unstable
::
global
::
global_data_clone_create
;
use
task
;
use
unstable
::
sync
::{
Exclusive
,
exclusive
};
use
unstable
::
finally
::
Finally
;
fn
key
(
_
:
Exclusive
<
()
>
)
{
}
unsafe
{
unsafe
{
let
result
=
global_data_clone_create
(
key
,
||
{
~
exclusive
(())
});
// This is really sketchy. Using a pthread mutex so descheduling
// in the `action` callback can cause deadlock. Doing it in
do
result
.with_imm
()
|
_
|
{
// `task::atomically` to try to avoid that, but ... I don't know
let
old_dir
=
os
::
getcwd
();
// this is all bogus.
if
change_dir
(
p
)
{
return
do
task
::
atomically
{
action
();
rust_take_change_dir_lock
();
change_dir
(
&
old_dir
)
}
do
(||{
else
{
let
old_dir
=
os
::
getcwd
();
false
if
change_dir
(
p
)
{
action
();
change_dir
(
&
old_dir
)
}
else
{
false
}
})
.finally
{
rust_drop_change_dir_lock
();
}
}
}
}
}
}
extern
{
fn
rust_take_change_dir_lock
();
fn
rust_drop_change_dir_lock
();
}
}
}
/// Copies a file from one location to another
/// Copies a file from one location to another
...
...
src/rt/rust_builtin.cpp
浏览文件 @
4beda4e5
...
@@ -947,6 +947,18 @@ rust_get_exit_status_newrt() {
...
@@ -947,6 +947,18 @@ rust_get_exit_status_newrt() {
return
exit_status
;
return
exit_status
;
}
}
static
lock_and_signal
change_dir_lock
;
extern
"C"
CDECL
void
rust_take_change_dir_lock
()
{
global_args_lock
.
lock
();
}
extern
"C"
CDECL
void
rust_drop_change_dir_lock
()
{
global_args_lock
.
unlock
();
}
//
//
// Local Variables:
// Local Variables:
// mode: C++
// mode: C++
...
...
src/rt/rustrt.def.in
浏览文件 @
4beda4e5
...
@@ -268,3 +268,5 @@ rust_take_global_args_lock
...
@@ -268,3 +268,5 @@ rust_take_global_args_lock
rust_drop_global_args_lock
rust_drop_global_args_lock
rust_set_exit_status_newrt
rust_set_exit_status_newrt
rust_get_exit_status_newrt
rust_get_exit_status_newrt
rust_take_change_dir_lock
rust_drop_change_dir_lock
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录