Skip to content

Commit 02c4305

Browse files
committed
Remove all warning abi.
1 parent 3c48fdd commit 02c4305

File tree

9 files changed

+747
-57
lines changed

9 files changed

+747
-57
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ Cargo.lock
55
.vscode
66
/.cargo
77
/vendor
8+
/trail-extension

phper-sys/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "phper-sys"
3-
version = "0.0.0"
3+
version = "0.1.0"
44
authors = ["__JM_Joy__ <[email protected]>"]
55
edition = "2018"
66
description = "PHP binding."

phper-sys/build.rs

Lines changed: 713 additions & 33 deletions
Large diffs are not rendered by default.

phper-sys/php_wrapper.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//
2+
// Created by jmjoy on 19-12-12.
3+
//
4+
5+
#ifndef PHPER_PHP_WRAPPER_H
6+
#define PHPER_PHP_WRAPPER_H
7+
8+
#include <php.h>
9+
10+
#endif //PHPER_PHP_WRAPPER_H

phper-sys/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
#![allow(non_camel_case_types)]
33
#![allow(non_snake_case)]
44

5-
//include!(concat!(env!("OUT_DIR"), "/php_bindings.rs"));
5+
include!(concat!(env!("OUT_DIR"), "/php_bindings.rs"));
66

77
mod r#macro;

phper-sys/src/macro.rs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,13 @@
11
#[macro_export]
22
macro_rules! emalloc {
33
( $( $x:expr ),* ) => {
4-
crate::_emalloc( $( $x, )* )
4+
$crate::_emalloc( $( $x, )* )
55
};
66
}
77

88
#[macro_export]
99
macro_rules! efree {
1010
( $( $x:expr ),* ) => {
11-
crate::_efree( $( $x, )* )
11+
$crate::_efree( $( $x, )* )
1212
};
1313
}
14-
15-
#[cfg(test)]
16-
mod tests {
17-
use super::*;
18-
19-
#[test]
20-
fn test_emalloc_efree() {
21-
unsafe {
22-
let ptr = emalloc!(1);
23-
efree!(ptr);
24-
}
25-
}
26-
}

phper/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ keywords = ["php", "binding"]
1111
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1212

1313
[dependencies]
14+
phper-sys = {path = "../phper-sys"}

phper/src/alloc.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use core::alloc::{GlobalAlloc, Layout};
2+
use core::ffi::c_void;
3+
4+
use phper_sys::efree;
5+
use phper_sys::emalloc;
6+
7+
pub struct EAllocator;
8+
9+
unsafe impl GlobalAlloc for EAllocator {
10+
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
11+
emalloc!(layout.size()) as *mut u8
12+
}
13+
14+
unsafe fn dealloc(&self, ptr: *mut u8, _layout: Layout) {
15+
efree!(ptr as *mut c_void);
16+
}
17+
}

phper/src/lib.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1 @@
1-
#[cfg(test)]
2-
mod tests {
3-
#[test]
4-
fn it_works() {
5-
assert_eq!(2 + 2, 4);
6-
}
7-
}
1+
pub mod alloc;

0 commit comments

Comments
 (0)