Skip to content

Commit

Permalink
Merge pull request #105 from mahkoh/jorth/unstable
Browse files Browse the repository at this point in the history
all: remove extern_types feature
  • Loading branch information
mahkoh authored Feb 23, 2024
2 parents c992722 + 5dd097d commit ecc45f0
Show file tree
Hide file tree
Showing 26 changed files with 215 additions and 215 deletions.
1 change: 0 additions & 1 deletion .builds/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ tasks:
rustup toolchain install stable
- build: |
cd jay
export RUSTC_BOOTSTRAP=1
cargo build
1 change: 0 additions & 1 deletion .builds/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ tasks:
sudo chmod o+rw /dev/dri/card*
- build: |
cd jay
export RUSTC_BOOTSTRAP=1
cargo build --features it
- test: |
cd jay
Expand Down
1 change: 0 additions & 1 deletion .builds/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ tasks:
rustup toolchain install stable
- test: |
cd jay
export RUSTC_BOOTSTRAP=1
cargo test
8 changes: 3 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ repc = "0.1.1"
anyhow = "1.0.79"
bstr = { version = "1.9.0", default-features = false, features = ["std"] }
shaderc = "0.8.3"
cc = "1.0.86"

#[profile.dev.build-override]
#opt-level = 3
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ only the latest stable version is supported.

You can now build Jay using this command:
```sh
RUSTC_BOOTSTRAP=1 cargo build --release
cargo build --release
```
The resulting binary will be located at `./target/release/jay`.

Alternatively, cargo can also install the binary for you:
```sh
RUSTC_BOOTSTRAP=1 cargo install --path .
cargo install --path .
```
This will install the binary at `$HOME/.cargo/bin/jay`. If you have not already
done so, you can add `$HOME/.cargo/bin` to your path.
Expand Down
2 changes: 2 additions & 0 deletions build/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use std::{

mod egl;
mod enums;
mod logging;
mod tokens;
mod vulkan;
mod wire;
Expand All @@ -49,6 +50,7 @@ fn main() -> anyhow::Result<()> {
enums::main()?;
egl::main()?;
vulkan::main()?;
logging::main()?;

println!("cargo:rerun-if-changed=build/build.rs");
Ok(())
Expand Down
5 changes: 5 additions & 0 deletions build/logging.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pub fn main() -> anyhow::Result<()> {
println!("cargo:rerun-if-changed=src/bridge.c");
cc::Build::new().file("src/bridge.c").compile("bridge");
Ok(())
}
2 changes: 1 addition & 1 deletion jay-config/src/_private/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl Drop for Client {
}

thread_local! {
pub(crate) static CLIENT: std::cell::Cell<*const Client> = const { std::cell::Cell::new(ptr::null()) };
pub(crate) static CLIENT: Cell<*const Client> = const { Cell::new(ptr::null()) };
}

unsafe fn with_client<T, F: FnOnce(&Client) -> T>(data: *const u8, f: F) -> T {
Expand Down
49 changes: 49 additions & 0 deletions src/bridge.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#define _GNU_SOURCE

#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>

static char *fmt(const char *format, va_list args) {
char *line;
int ret = vasprintf(&line, format, args);
if (ret < 0) {
return 0;
} else {
return line;
}
}

void jay_libinput_log_handler(
void *libinput,
int priority,
const char *line
);

void jay_libinput_log_handler_bridge(
void *libinput,
int priority,
const char *format,
va_list args
) {
char *line = fmt(format, args);
jay_libinput_log_handler(libinput, priority, line);
free(line);
}

void jay_xkbcommon_log_handler(
void *ctx,
int xkb_log_level,
const char *line
);

void jay_xkbcommon_log_handler_bridge(
void *ctx,
int xkb_log_level,
const char *format,
va_list args
) {
char *line = fmt(format, args);
jay_xkbcommon_log_handler(ctx, xkb_log_level, line);
free(line);
}
13 changes: 7 additions & 6 deletions src/clientmem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ impl ClientMemOffset {
}
let mref = MemRef {
mem: &*self.mem,
outer: MEM,
outer: MEM.get(),
};
MEM = &mref;
MEM.set(&mref);
compiler_fence(Ordering::SeqCst);
let res = f(&*self.data);
MEM = mref.outer;
MEM.set(mref.outer);
compiler_fence(Ordering::SeqCst);
match self.mem.failed.get() {
true => Err(ClientMemError::Sigbus),
Expand All @@ -116,8 +116,9 @@ struct MemRef {
outer: *const MemRef,
}

#[thread_local]
static mut MEM: *const MemRef = ptr::null();
thread_local! {
static MEM: Cell<*const MemRef> = const { Cell::new(ptr::null()) };
}

unsafe fn kill() -> ! {
c::signal(c::SIGBUS, c::SIG_DFL);
Expand All @@ -127,7 +128,7 @@ unsafe fn kill() -> ! {

unsafe extern "C" fn sigbus(sig: i32, info: &c::siginfo_t, _ucontext: *mut c::c_void) {
assert_eq!(sig, c::SIGBUS);
let mut memr_ptr = MEM;
let mut memr_ptr = MEM.get();
while !memr_ptr.is_null() {
let memr = &*memr_ptr;
let mem = &*memr.mem;
Expand Down
15 changes: 8 additions & 7 deletions src/gfx_apis/gl/egl/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use {
},
},
ahash::AHashMap,
std::rc::Rc,
std::{cell::Cell, rc::Rc},
};

#[derive(Debug, Clone)]
Expand All @@ -36,8 +36,9 @@ impl Drop for EglContext {
}
}

#[thread_local]
static mut CURRENT: EGLContext = EGLContext::none();
thread_local! {
static CURRENT: Cell<EGLContext> = const { Cell::new(EGLContext::none()) };
}

impl EglContext {
pub fn reset_status(&self) -> Option<ResetStatus> {
Expand All @@ -63,7 +64,7 @@ impl EglContext {
f: F,
) -> Result<T, RenderError> {
unsafe {
if CURRENT == self.ctx {
if CURRENT.get() == self.ctx {
return f();
}
self.with_current_slow(f)
Expand All @@ -84,15 +85,15 @@ impl EglContext {
{
return Err(RenderError::MakeCurrent);
}
let prev = CURRENT;
CURRENT = self.ctx;
let prev = CURRENT.get();
CURRENT.set(self.ctx);
let res = f();
if (self.dpy.egl.eglMakeCurrent)(self.dpy.dpy, EGLSurface::none(), EGLSurface::none(), prev)
== EGL_FALSE
{
panic!("Could not restore EGLContext");
}
CURRENT = prev;
CURRENT.set(prev);
res
}
}
3 changes: 2 additions & 1 deletion src/gfx_apis/vulkan/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ impl Drop for VulkanInstance {

const REQUIRED_INSTANCE_EXTENSIONS: &[&CStr] = &[ExtDebugUtilsFn::name()];

const VALIDATION_LAYER: &CStr = c"VK_LAYER_KHRONOS_validation";
const VALIDATION_LAYER: &CStr =
unsafe { CStr::from_bytes_with_nul_unchecked(b"VK_LAYER_KHRONOS_validation\0") };

pub type Extensions = AHashMap<CString, u32>;

Expand Down
31 changes: 15 additions & 16 deletions src/it/test_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,25 @@ pub static TEST_CONFIG_ENTRY: ConfigEntry = ConfigEntry {
handle_msg,
};

#[thread_local]
static mut CONFIG: *const TestConfig = ptr::null();
thread_local! {
static CONFIG: Cell<*const TestConfig> = const { Cell::new(ptr::null()) };
}

pub fn with_test_config<T, F>(f: F) -> T
where
F: FnOnce(Rc<TestConfig>) -> T,
{
unsafe {
let tc = Rc::new(TestConfig {
srv: Cell::new(None),
responses: Default::default(),
invoked_shortcuts: Default::default(),
graphics_initialized: Cell::new(false),
});
let old = CONFIG;
CONFIG = tc.deref();
let res = f(tc.clone());
CONFIG = old;
res
}
let tc = Rc::new(TestConfig {
srv: Cell::new(None),
responses: Default::default(),
invoked_shortcuts: Default::default(),
graphics_initialized: Cell::new(false),
});
let old = CONFIG.get();
CONFIG.set(tc.deref());
let res = f(tc.clone());
CONFIG.set(old);
res
}

unsafe extern "C" fn init(
Expand All @@ -56,7 +55,7 @@ unsafe extern "C" fn init(
_msg: *const u8,
_size: usize,
) -> *const u8 {
let tc = CONFIG;
let tc = CONFIG.get();
assert!(tc.is_not_null());
Rc::increment_strong_count(tc);
{
Expand Down
11 changes: 6 additions & 5 deletions src/it/test_logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ use {

static LEVEL: AtomicUsize = AtomicUsize::new(Level::Info as usize);

#[thread_local]
static FILE: CloneCell<Option<Rc<OwnedFd>>> = CloneCell::new(None);
thread_local! {
static FILE: CloneCell<Option<Rc<OwnedFd>>> = CloneCell::new(None);
}

pub fn install() {
log::set_logger(&Logger).unwrap();
Expand All @@ -27,11 +28,11 @@ pub fn set_level(level: Level) {
}

pub fn set_file(file: Rc<OwnedFd>) {
FILE.set(Some(file));
FILE.with(|f| f.set(Some(file)));
}

pub fn unset_file() {
FILE.set(None);
FILE.with(|f| f.set(None));
}

struct Logger;
Expand Down Expand Up @@ -65,7 +66,7 @@ impl Log for Logger {
record.args(),
)
};
let mut fd = match FILE.get() {
let mut fd = match FILE.with(|f| f.get()) {
Some(f) => f.borrow(),
_ => Fd::new(2),
};
Expand Down
Loading

0 comments on commit ecc45f0

Please sign in to comment.