diff --git a/scanner/src/client_gen.rs b/scanner/src/client_gen.rs index 9274393696c..98c354caee4 100644 --- a/scanner/src/client_gen.rs +++ b/scanner/src/client_gen.rs @@ -21,7 +21,7 @@ pub fn generate_client_api(protocol: Protocol, out: &mut O) { writeln!(out, "use std::ptr;").unwrap(); writeln!(out, "use std::sync::Arc;").unwrap(); writeln!(out, "use std::sync::atomic::{{AtomicBool, Ordering}};").unwrap(); - writeln!(out, "use libc::{{c_void, c_char}};").unwrap(); + writeln!(out, "use std::ow::raw::{{c_void, c_char}};").unwrap(); // envent handling diff --git a/scanner/src/interface_gen.rs b/scanner/src/interface_gen.rs index a7cb2ce71c4..666ea261fa6 100644 --- a/scanner/src/interface_gen.rs +++ b/scanner/src/interface_gen.rs @@ -22,7 +22,7 @@ pub fn generate_interfaces(protocol: Protocol, out: &mut O) { } writeln!(out, "use wayland_sys::common::*;\n").unwrap(); - writeln!(out, "use libc::{{c_void, c_char}};\n").unwrap(); + writeln!(out, "use std::os::raw::{{c_void, c_char}};\n").unwrap(); // // null types array @@ -132,4 +132,4 @@ pub fn generate_interfaces(protocol: Protocol, out: &mut O) { writeln!(out, "").unwrap(); } -} \ No newline at end of file +} diff --git a/wayland-client/src/egl.rs b/wayland-client/src/egl.rs index 464125b3d87..01ddfb994ca 100644 --- a/wayland-client/src/egl.rs +++ b/wayland-client/src/egl.rs @@ -1,4 +1,4 @@ -use libc::c_void; +use std::os::raw::c_void; use std::ops::Deref; use wayland_sys::egl::*; diff --git a/wayland-sys/Cargo.toml b/wayland-sys/Cargo.toml index aa0d0d219a9..e154a1f3a21 100644 --- a/wayland-sys/Cargo.toml +++ b/wayland-sys/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT" [dependencies] dlib = "0.2" -libc = "0.2" +libc = { version = "0.2", optional = true } lazy_static = { version = "0.1", optional = true } [features] @@ -16,4 +16,4 @@ dlopen = ["dlib/dlopen", "lazy_static"] client = [] cursor = [] egl = [] -server = [] +server = ["libc"] diff --git a/wayland-sys/src/client.rs b/wayland-sys/src/client.rs index 65ee4a2c579..2c4769f8d24 100644 --- a/wayland-sys/src/client.rs +++ b/wayland-sys/src/client.rs @@ -2,7 +2,7 @@ //! //! The generated handle is named `WAYLAND_CLIENT_HANDLE` -use {c_char, c_void, c_int, size_t, uint32_t}; +use std::os::raw::{c_char, c_void, c_int}; use super::common::*; @@ -26,7 +26,7 @@ external_library!(WaylandClient, "wayland-client", fn wl_display_dispatch_pending(*mut wl_display) -> c_int, // error handling fn wl_display_get_error(*mut wl_display) -> c_int, - fn wl_display_get_protocol_error(*mut wl_display, *mut *mut wl_interface, *mut uint32_t) -> uint32_t, + fn wl_display_get_protocol_error(*mut wl_display, *mut *mut wl_interface, *mut u32) -> u32, // requests handling fn wl_display_flush(*mut wl_display) -> c_int, @@ -44,12 +44,12 @@ external_library!(WaylandClient, "wayland-client", fn wl_proxy_add_listener(*mut wl_proxy, *mut extern fn(), *mut c_void) -> c_int, fn wl_proxy_get_listener(*mut wl_proxy) -> *const c_void, fn wl_proxy_add_dispatcher(*mut wl_proxy, wl_dispatcher_func_t, *const c_void, *mut c_void) -> c_int, - fn wl_proxy_marshal_array_constructor(*mut wl_proxy, uint32_t, *mut wl_argument, *const wl_interface) -> c_int, + fn wl_proxy_marshal_array_constructor(*mut wl_proxy, u32, *mut wl_argument, *const wl_interface) -> c_int, - fn wl_proxy_marshal_array(*mut wl_proxy, uint32_t, *mut wl_argument ) -> (), + fn wl_proxy_marshal_array(*mut wl_proxy, u32, *mut wl_argument ) -> (), fn wl_proxy_set_user_data(*mut wl_proxy, *mut c_void) -> (), fn wl_proxy_get_user_data(*mut wl_proxy) -> *mut c_void, - fn wl_proxy_get_id(*mut wl_proxy) -> uint32_t, + fn wl_proxy_get_id(*mut wl_proxy) -> u32, fn wl_proxy_get_class(*mut wl_proxy) -> *const c_char, fn wl_proxy_set_queue(*mut wl_proxy, *mut wl_event_queue) -> (), @@ -67,12 +67,12 @@ external_library!(WaylandClient, "wayland-client", // arrays fn wl_array_init(*mut wl_array) -> (), fn wl_array_release(*mut wl_array) -> (), - fn wl_array_add(*mut wl_array,size_t) -> (), + fn wl_array_add(*mut wl_array,usize) -> (), fn wl_array_copy(*mut wl_array, *mut wl_array) -> () varargs: - fn wl_proxy_marshal_constructor(*mut wl_proxy, uint32_t, *const wl_interface ...) -> *mut wl_proxy, - fn wl_proxy_marshal(*mut wl_proxy, uint32_t ...) -> () + fn wl_proxy_marshal_constructor(*mut wl_proxy, u32, *const wl_interface ...) -> *mut wl_proxy, + fn wl_proxy_marshal(*mut wl_proxy, u32 ...) -> () ); #[cfg(feature = "dlopen")] diff --git a/wayland-sys/src/common.rs b/wayland-sys/src/common.rs index 148d89f13e1..2fb1a067e6c 100644 --- a/wayland-sys/src/common.rs +++ b/wayland-sys/src/common.rs @@ -1,7 +1,7 @@ //! Various types and functions that are used by both the client and the server //! libraries. -use {c_char, c_void, c_int, size_t}; +use std::os::raw::{c_char, c_void, c_int}; #[repr(C)] pub struct wl_message { @@ -28,8 +28,8 @@ pub struct wl_list { #[repr(C)] pub struct wl_array { - pub size: size_t, - pub alloc: size_t, + pub size: usize, + pub alloc: usize, pub data: *mut c_void } @@ -54,7 +54,7 @@ pub fn wl_fixed_from_int(i: i32) -> wl_fixed_t { // must be the appropriate size // can contain i32, u32 and pointers #[repr(C)] -pub struct wl_argument { _f: size_t } +pub struct wl_argument { _f: usize } pub type wl_dispatcher_func_t = extern "C" fn(*const c_void, *mut c_void, u32, *const wl_message, *const wl_argument); -pub type wl_log_func_t = extern "C" fn(*const c_char, ...); \ No newline at end of file +pub type wl_log_func_t = extern "C" fn(*const c_char, ...); diff --git a/wayland-sys/src/cursor.rs b/wayland-sys/src/cursor.rs index 84d83c8a8d5..8ce0557983b 100644 --- a/wayland-sys/src/cursor.rs +++ b/wayland-sys/src/cursor.rs @@ -2,7 +2,7 @@ //! //! The created handle is named `WAYLAND_CURSOR_HANDLE`. -use {uint32_t, c_uint, c_char, c_int}; +use std::os::raw::{c_uint, c_char, c_int}; use client::wl_proxy; pub enum wl_cursor_theme { } @@ -10,15 +10,15 @@ pub enum wl_cursor_theme { } #[repr(C)] pub struct wl_cursor_image { /// actual width - pub width: uint32_t, + pub width: u32, /// actual height - pub height: uint32_t, + pub height: u32, /// hot spot x (must be inside image) - pub hotspot_x: uint32_t, + pub hotspot_x: u32, /// hot spot y (must be inside image) - pub hotspot_y: uint32_t, + pub hotspot_y: u32, /// animation delay to next frame - pub delay: uint32_t + pub delay: u32 } #[repr(C)] @@ -34,8 +34,8 @@ external_library!(WaylandCursor, "wayland-cursor", fn wl_cursor_theme_destroy(*mut wl_cursor_theme) -> (), fn wl_cursor_theme_get_cursor(*mut wl_cursor_theme, *const c_char) -> *mut wl_cursor, fn wl_cursor_image_get_buffer(*mut wl_cursor_image) -> *mut wl_proxy, - fn wl_cursor_frame(*mut wl_cursor, uint32_t) -> c_int, - fn wl_cursor_frame_and_duration(*mut wl_cursor, uint32_t, *mut uint32_t) -> c_int + fn wl_cursor_frame(*mut wl_cursor, u32) -> c_int, + fn wl_cursor_frame_and_duration(*mut wl_cursor, u32, *mut u32) -> c_int ); #[cfg(feature = "dlopen")] @@ -51,4 +51,4 @@ lazy_static!( #[cfg(not(feature = "dlopen"))] pub fn is_lib_available() -> bool { true } #[cfg(feature = "dlopen")] -pub fn is_lib_available() -> bool { WAYLAND_CURSOR_OPTION.is_some() } \ No newline at end of file +pub fn is_lib_available() -> bool { WAYLAND_CURSOR_OPTION.is_some() } diff --git a/wayland-sys/src/egl.rs b/wayland-sys/src/egl.rs index a1af015efb0..330bc559e80 100644 --- a/wayland-sys/src/egl.rs +++ b/wayland-sys/src/egl.rs @@ -4,7 +4,7 @@ //! //! The created handle is named `WAYLAND_EGl_HANDLE`. -use c_int; +use std::os::raw::c_int; use client::wl_proxy; pub enum wl_egl_window { } @@ -30,4 +30,4 @@ lazy_static!( #[cfg(not(feature = "dlopen"))] pub fn is_lib_available() -> bool { true } #[cfg(feature = "dlopen")] -pub fn is_lib_available() -> bool { WAYLAND_EGL_OPTION.is_some() } \ No newline at end of file +pub fn is_lib_available() -> bool { WAYLAND_EGL_OPTION.is_some() } diff --git a/wayland-sys/src/lib.rs b/wayland-sys/src/lib.rs index 9b927ddeb09..e6d968af2ff 100644 --- a/wayland-sys/src/lib.rs +++ b/wayland-sys/src/lib.rs @@ -39,6 +39,7 @@ extern crate dlib; #[macro_use] extern crate lazy_static; +#[cfg(feature = "server")] extern crate libc; pub mod common; @@ -55,11 +56,8 @@ pub mod egl; #[cfg(all(feature = "cursor", feature = "client"))] pub mod cursor; -pub use libc::{c_char, c_void, c_int, size_t, uint32_t}; #[cfg(feature = "server")] -pub use libc::{pid_t, uid_t, gid_t, int32_t}; -#[cfg(feature = "cursor")] -pub use libc::c_uint; +pub use libc::{pid_t, uid_t, gid_t}; // Small hack while #[macro_reexport] is not stable @@ -77,4 +75,4 @@ macro_rules! ffi_dispatch( ($handle: ident, $func: ident, $($arg: expr),*) => ( $func($($arg),*) ) -); \ No newline at end of file +); diff --git a/wayland-sys/src/server.rs b/wayland-sys/src/server.rs index 8ae68872976..4b9a4b1a1ac 100644 --- a/wayland-sys/src/server.rs +++ b/wayland-sys/src/server.rs @@ -2,7 +2,8 @@ //! //! The generated handle is named `WAYLAND_SERVER_HANDLE` -use {c_char, c_void, c_int, size_t, uint32_t, int32_t, uid_t, pid_t, gid_t}; +use std::os::raw::{c_char, c_void, c_int}; +use libc::{uid_t, pid_t, gid_t}; use super::common::*; @@ -15,11 +16,11 @@ pub enum wl_listener { } pub enum wl_resource { } pub enum wl_shm_buffer { } -pub type wl_event_loop_fd_func_t = extern "C" fn(c_int, uint32_t, *mut c_void) -> c_int; +pub type wl_event_loop_fd_func_t = extern "C" fn(c_int, u32, *mut c_void) -> c_int; pub type wl_event_loop_timer_func_t = extern "C" fn(*mut c_void) -> c_int; pub type wl_event_loop_signal_func_t = extern "C" fn(c_int, *mut c_void) -> c_int; pub type wl_event_loop_idle_func_t = extern "C" fn(*mut c_void) -> (); -pub type wl_global_bind_func_t = extern "C" fn(*mut wl_client, *mut c_void, uint32_t, uint32_t) -> (); +pub type wl_global_bind_func_t = extern "C" fn(*mut wl_client, *mut c_void, u32, u32) -> (); pub type wl_notify_func_t = extern "C" fn(*mut wl_listener, *mut c_void) -> (); pub type wl_resource_destroy_func_t = extern "C" fn(*mut wl_resource) -> (); @@ -30,20 +31,20 @@ external_library!(WaylandServer, "wayland-server", fn wl_client_destroy(*mut wl_client) -> (), fn wl_client_get_display(*mut wl_client) -> *mut wl_display, fn wl_client_get_credentials(*mut wl_client, *mut pid_t, *mut uid_t, *mut gid_t) -> (), - fn wl_client_get_object(*mut wl_client, uint32_t) -> *mut wl_resource, + fn wl_client_get_object(*mut wl_client, u32) -> *mut wl_resource, fn wl_client_add_destroy_listener(*mut wl_client, *mut wl_listener) -> (), fn wl_client_get_destroy_listener(*mut wl_client, wl_notify_func_t) -> *mut wl_listener, fn wl_client_post_no_memory(*mut wl_client) -> (), - fn wl_resource_create(*mut wl_client, *const wl_interface, c_int, uint32_t) -> *mut wl_resource, + fn wl_resource_create(*mut wl_client, *const wl_interface, c_int, u32) -> *mut wl_resource, // wl_display fn wl_client_create(*mut wl_display, c_int) -> *mut wl_client, fn wl_display_create() -> *mut wl_display, fn wl_display_destroy(*mut wl_display) -> (), - fn wl_display_get_serial(*mut wl_display) -> uint32_t, - fn wl_display_next_serial(*mut wl_display) -> uint32_t, + fn wl_display_get_serial(*mut wl_display) -> u32, + fn wl_display_next_serial(*mut wl_display) -> u32, fn wl_display_add_socket(*mut wl_display, *const c_char) -> c_int, fn wl_display_add_socket_auto(*mut wl_display) -> *const c_char, - fn wl_display_add_shm_format(*mut wl_display, uint32_t) -> *mut uint32_t, + fn wl_display_add_shm_format(*mut wl_display, u32) -> *mut u32, fn wl_display_get_additional_shm_formats(*mut wl_display) -> *mut wl_array, fn wl_display_get_event_loop(*mut wl_display) -> *mut wl_event_loop, fn wl_display_terminate(*mut wl_display) -> (), @@ -56,8 +57,8 @@ external_library!(WaylandServer, "wayland-server", // wl_event_loop fn wl_event_loop_create() -> *mut wl_event_loop, fn wl_event_loop_destroy(*mut wl_event_loop) -> (), - fn wl_event_loop_add_fd(*mut wl_event_loop, c_int, uint32_t, wl_event_loop_fd_func_t, *mut c_void) -> *mut wl_event_source, - fn wl_event_loop_fd_update(*mut wl_event_source, uint32_t) -> c_int, + fn wl_event_loop_add_fd(*mut wl_event_loop, c_int, u32, wl_event_loop_fd_func_t, *mut c_void) -> *mut wl_event_source, + fn wl_event_loop_fd_update(*mut wl_event_source, u32) -> c_int, fn wl_event_lopp_add_timer(*mut wl_event_loop, wl_event_loop_timer_func_t, *mut c_void) -> *mut wl_event_source, fn wl_event_loop_add_signal(*mut wl_event_loop, c_int, wl_event_loop_signal_func_t, *mut c_void) -> *mut wl_event_source, fn wl_event_loop_dispatch(*mut wl_event_loop, c_int) -> c_int, @@ -73,13 +74,13 @@ external_library!(WaylandServer, "wayland-server", // wl_global fn wl_global_destroy(*mut wl_global) -> (), // wl_resource - fn wl_resource_post_event_array(*mut wl_resource, uint32_t, *mut wl_argument) -> (), - fn wl_resource_queue_event_array(*mut wl_resource, uint32_t, *mut wl_argument) -> (), + fn wl_resource_post_event_array(*mut wl_resource, u32, *mut wl_argument) -> (), + fn wl_resource_queue_event_array(*mut wl_resource, u32, *mut wl_argument) -> (), fn wl_resource_post_no_memory(*mut wl_resource) -> (), fn wl_resource_set_implementation(*mut wl_resource, *const c_void, *mut c_void, wl_resource_destroy_func_t) -> (), fn wl_resource_set_dispatcher(*mut wl_resource, wl_dispatcher_func_t, *const c_void, *mut c_void, wl_resource_destroy_func_t) -> (), fn wl_resource_destroy(*mut wl_resource) -> (), - fn wl_resource_get_id(*mut wl_resource) -> uint32_t, + fn wl_resource_get_id(*mut wl_resource) -> u32, fn wl_resource_get_link(*mut wl_resource) -> *mut wl_list, fn w_resource_from_link(*mut wl_list) -> *mut wl_resource, fn wl_resource_find_for_client(*mut wl_list, *mut wl_client) -> (), @@ -91,15 +92,15 @@ external_library!(WaylandServer, "wayland-server", fn wl_resource_add_destroy_listener(*mut wl_resource, wl_notify_func_t) -> (), fn wl_resource_get_destroy_listener(*mut wl_resource,wl_notify_func_t) -> *mut wl_listener, // wl_shm - fn wl_shm_buffer_create(*mut wl_client, uint32_t, int32_t, int32_t, int32_t, uint32_t) -> (), + fn wl_shm_buffer_create(*mut wl_client, u32, i32, i32, i32, u32) -> (), fn wl_shm_buffer_begin_access(*mut wl_shm_buffer) -> (), fn wl_shm_buffer_end_access(*mut wl_shm_buffer) -> (), fn wl_shm_buffer_get(*mut wl_resource) -> *mut wl_shm_buffer, fn wl_shm_buffer_get_data(*mut wl_shm_buffer) -> *mut c_void, - fn wl_shm_buffer_get_stride(*mut wl_shm_buffer) -> int32_t, - fn wl_shm_buffer_get_format(*mut wl_shm_buffer) -> uint32_t, - fn wl_shm_buffer_get_width(*mut wl_shm_buffer) -> int32_t, - fn wl_shm_buffer_get_heigth(*mut wl_shm_buffer) -> int32_t, + fn wl_shm_buffer_get_stride(*mut wl_shm_buffer) -> i32, + fn wl_shm_buffer_get_format(*mut wl_shm_buffer) -> u32, + fn wl_shm_buffer_get_width(*mut wl_shm_buffer) -> i32, + fn wl_shm_buffer_get_heigth(*mut wl_shm_buffer) -> i32, // wl_log fn wl_log_set_handler_server(wl_log_func_t) -> (), // wl_list @@ -113,12 +114,12 @@ external_library!(WaylandServer, "wayland-server", // arrays fn wl_array_init(*mut wl_array) -> (), fn wl_array_release(*mut wl_array) -> (), - fn wl_array_add(*mut wl_array,size_t) -> (), + fn wl_array_add(*mut wl_array,usize) -> (), fn wl_array_copy(*mut wl_array, *mut wl_array) -> () varargs: - fn wl_resource_post_event(*mut wl_resource, uint32_t ...) -> (), - fn wl_resource_queue_event(*mut wl_resource, uint32_t ...) -> (), - fn wl_resource_post_error(*mut wl_resource, uint32_t, *const c_char ...) -> () + fn wl_resource_post_event(*mut wl_resource, u32 ...) -> (), + fn wl_resource_queue_event(*mut wl_resource, u32 ...) -> (), + fn wl_resource_post_error(*mut wl_resource, u32, *const c_char ...) -> () ); #[cfg(feature = "dlopen")]