Skip to content

Commit 89efb0b

Browse files
committed
---
yaml --- r: 140461 b: refs/heads/try2 c: 8f2d71a h: refs/heads/master i: 140459: d28672b v: v3
1 parent 5b51fa7 commit 89efb0b

File tree

4 files changed

+7
-47
lines changed

4 files changed

+7
-47
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 29a2a1ecd1fe33260a9390dd05899daf6a2ba69b
8+
refs/heads/try2: 8f2d71ac009e1f93c14266ecebb1c105a0a907e3
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/doc/tutorial-ffi.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,7 @@ wrapping `malloc` and `free`:
150150

151151
~~~~
152152
use core::libc::{c_void, size_t, malloc, free};
153-
154-
#[abi = "rust-intrinsic"]
155-
extern "rust-intrinsic" mod rusti {
156-
fn init<T>() -> T;
157-
}
153+
use core::unstable::intrinsics;
158154
159155
// a wrapper around the handle returned by the foreign code
160156
pub struct Unique<T> {
@@ -166,7 +162,8 @@ pub impl<'self, T: Owned> Unique<T> {
166162
unsafe {
167163
let ptr = malloc(core::sys::size_of::<T>() as size_t) as *mut T;
168164
assert!(!ptr::is_null(ptr));
169-
*ptr = value;
165+
// `*ptr` is uninitialized, and `*ptr = value` would attempt to destroy it
166+
intrinsics::move_val_init(&mut *ptr, value);
170167
Unique{ptr: ptr}
171168
}
172169
}
@@ -186,7 +183,7 @@ pub impl<'self, T: Owned> Unique<T> {
186183
impl<T: Owned> Drop for Unique<T> {
187184
fn finalize(&self) {
188185
unsafe {
189-
let mut x = rusti::init(); // dummy value to swap in
186+
let mut x = intrinsics::init(); // dummy value to swap in
190187
x <-> *self.ptr; // moving the object out is needed to call the destructor
191188
free(self.ptr as *c_void)
192189
}

branches/try2/src/rt/rust_android_dummy.cpp

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
#ifdef __ANDROID__
6-
75
#include "rust_android_dummy.h"
86
#include <math.h>
97
#include <errno.h>
108

9+
#ifdef __ANDROID__
10+
1111
int backtrace(void **array, int size) { return 0; }
1212

1313
char **backtrace_symbols(void *const *array, int size) { return 0; }
@@ -59,21 +59,7 @@ extern "C" void srand()
5959
extern "C" void atof()
6060
{
6161
}
62-
6362
extern "C" void tgammaf()
6463
{
6564
}
66-
67-
extern "C" int glob(const char *pattern,
68-
int flags,
69-
int (*errfunc) (const char *epath, int eerrno),
70-
glob_t *pglob)
71-
{
72-
return 0;
73-
}
74-
75-
extern "C" void globfree(glob_t *pglob)
76-
{
77-
}
78-
7965
#endif

branches/try2/src/rt/rust_android_dummy.h

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,4 @@ char **backtrace_symbols (void *__const *__array, int __size);
1111

1212
void backtrace_symbols_fd (void *__const *__array, int __size, int __fd);
1313

14-
#include <sys/types.h>
15-
16-
struct stat;
17-
typedef struct {
18-
size_t gl_pathc; /* Count of total paths so far. */
19-
size_t gl_matchc; /* Count of paths matching pattern. */
20-
size_t gl_offs; /* Reserved at beginning of gl_pathv. */
21-
int gl_flags; /* Copy of flags parameter to glob. */
22-
char **gl_pathv; /* List of paths matching pattern. */
23-
/* Copy of errfunc parameter to glob. */
24-
int (*gl_errfunc)(const char *, int);
25-
26-
/*
27-
* Alternate filesystem access methods for glob; replacement
28-
* versions of closedir(3), readdir(3), opendir(3), stat(2)
29-
* and lstat(2).
30-
*/
31-
void (*gl_closedir)(void *);
32-
struct dirent *(*gl_readdir)(void *);
33-
void *(*gl_opendir)(const char *);
34-
int (*gl_lstat)(const char *, struct stat *);
35-
} glob_t;
36-
3714
#endif

0 commit comments

Comments
 (0)