aboutsummaryrefslogtreecommitdiff
path: root/src/crt.rs
blob: 1ccd9f4f1accf3ac53efc2c29a2a212814349ac7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//! C runtime library.
//!
//! Functions imported from `ntoskrnl.exe`.

extern "C"
{
	pub fn memcmp(s1: *const u8, s2: *const u8, n: usize) -> i32;
	pub fn memcpy(dest: *mut u8, src: *const u8, n: usize) -> *mut u8;

	pub fn strlen(s: *const u8) -> usize;
	pub fn strcmp(s1: *const u8, s2: *const u8) -> i32;
	pub fn strcpy(dest: *mut u8, src: *const u8) -> *mut u8;
	pub fn strcat(dest: *mut u8, src: *const u8) -> *mut u8;
	pub fn strncpy(dest: *mut u8, src: *const u8, n: usize) -> *mut u8;

	pub fn wcslen(s: *const u16) -> usize;
	pub fn wcscpy(dest: *mut u16, src: *const u16) -> *mut u16;
	pub fn wcsncpy(dest: *mut u16, src: *const u16, n: usize) -> *mut u16;
}


#[no_mangle]
#[allow(non_upper_case_globals)]
#[cfg(target_arch="x86")]
#[doc(hidden)]
pub static __security_cookie: usize = 0xBB40E64E;

#[no_mangle]
#[allow(non_upper_case_globals)]
#[cfg(target_arch="x86_64")]
#[doc(hidden)]
pub static __security_cookie: usize = 0x00002B992DDFA232;


#[doc(hidden)]
pub mod rust_intrinsics
{
	#![allow(unused_variables)]

	// Idk why, but linker cannot find `_memcmp` for llvm intrinsics. So lets make forward one.
	#[no_mangle]
	pub unsafe fn memcmp(s1: *const u8, s2: *const u8, n: usize) -> i32 {
		return ::crt::memcmp(s1, s2, n);
	}

	// ported from compiler-rt
	// pub fn __muldi3(a: u64, b: u64) -> u64 {
	// 	unimplemented!();
	// }

	#[no_mangle]
	pub fn __mulodi4(a: i64, b: i64, overflow: &mut i32) -> i64 {
		unimplemented!();
	}

	#[no_mangle]
	pub extern "C" fn __multi3(a: i128, b: i128) -> i128 {
		unimplemented!();
	}

	#[no_mangle]
	pub extern fn __muloti4(a: i128, b: i128, oflow: &mut i32) -> i128 {
		unimplemented!();
	}

	#[no_mangle]
	pub extern "C" fn __udivti3(n: u128, d: u128) -> u128 {
		unimplemented!();
	}

	#[no_mangle]
	pub extern "C" fn __umodti3(n: u128, d: u128) -> u128 {
		unimplemented!();
	}
}