Skip to content

Commit 221ee44

Browse files
Add a test to ensure no empty thread_locals are being generated
1 parent 007ac77 commit 221ee44

3 files changed

Lines changed: 38 additions & 0 deletions

File tree

‎tests/unit/extern_global.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
extern int x;
2+
int x;
3+
4+
int main(void) { return x; }
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
extern crate libcc2rs;
2+
use libcc2rs::*;
3+
use std::cell::RefCell;
4+
use std::collections::BTreeMap;
5+
use std::io::prelude::*;
6+
use std::io::{Read, Seek, Write};
7+
use std::os::fd::AsFd;
8+
use std::rc::{Rc, Weak};
9+
thread_local!(
10+
pub static x_0: Value<i32> = <Value<i32>>::default();
11+
);
12+
pub fn main() {
13+
std::process::exit(main_0());
14+
}
15+
fn main_0() -> i32 {
16+
return (*x_0.with(Value::clone).borrow());
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
extern crate libc;
2+
use libc::*;
3+
extern crate libcc2rs;
4+
use libcc2rs::*;
5+
use std::collections::BTreeMap;
6+
use std::io::{Read, Seek, Write};
7+
use std::os::fd::{AsFd, FromRawFd, IntoRawFd};
8+
use std::rc::Rc;
9+
pub static mut x_0: i32 = unsafe { 0_i32 };
10+
pub fn main() {
11+
unsafe {
12+
std::process::exit(main_0() as i32);
13+
}
14+
}
15+
unsafe fn main_0() -> i32 {
16+
return x_0;
17+
}

0 commit comments

Comments
 (0)