Skip to content

Commit 37693c6

Browse files
committed
Gate memrchr on Linux
1 parent 71d302c commit 37693c6

4 files changed

Lines changed: 13 additions & 3 deletions

File tree

rules/cstring/ir_unsafe.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,8 @@
739739
"return_type": {
740740
"type": "*mut ::libc::c_void",
741741
"is_unsafe_pointer": true
742-
}
742+
},
743+
"target_os": "linux"
743744
},
744745
"f25": {
745746
"body": [
@@ -789,7 +790,8 @@
789790
"return_type": {
790791
"type": "*const ::libc::c_void",
791792
"is_unsafe_pointer": true
792-
}
793+
},
794+
"target_os": "linux"
793795
},
794796
"f26": {
795797
"body": [
@@ -839,7 +841,8 @@
839841
"return_type": {
840842
"type": "*mut ::libc::c_void",
841843
"is_unsafe_pointer": true
842-
}
844+
},
845+
"target_os": "linux"
843846
},
844847
"f27": {
845848
"body": [

rules/cstring/src.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ char *f18(const char *a0, const char *a1) { return strstr(a0, a1); }
3535

3636
char *f21(const char *a0, const char *a1) { return strpbrk(a0, a1); }
3737

38+
#if defined(__linux__)
3839
void *f24(const void *a0, int a1, size_t a2) { return memrchr(a0, a1, a2); }
40+
#endif
3941

4042
int f27(const char *a0, const char *a1) { return strcasecmp(a0, a1); }

rules/cstring/src.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ const char *f22(const char *a0, const char *a1) { return strpbrk(a0, a1); }
2020

2121
char *f23(char *a0, const char *a1) { return strpbrk(a0, a1); }
2222

23+
#if defined(__linux__)
2324
const void *f25(const void *a0, int a1, size_t a2) { return memrchr(a0, a1, a2); }
2425

2526
void *f26(void *a0, int a1, size_t a2) { return memrchr(a0, a1, a2); }
27+
#endif

rules/cstring/tgt_unsafe.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,17 @@ unsafe fn f23(a0: *mut u8, a1: *const u8) -> *mut u8 {
112112
libc::strpbrk(a0 as *const i8, a1 as *const i8) as *mut u8
113113
}
114114

115+
#[cfg(target_os = "linux")]
115116
unsafe fn f24(a0: *const u8, a1: i32, a2: usize) -> *mut ::libc::c_void {
116117
libc::memrchr(a0 as *const ::libc::c_void, a1, a2 as usize)
117118
}
118119

120+
#[cfg(target_os = "linux")]
119121
unsafe fn f25(a0: *const u8, a1: i32, a2: usize) -> *const ::libc::c_void {
120122
libc::memrchr(a0 as *const ::libc::c_void, a1, a2 as usize) as *const ::libc::c_void
121123
}
122124

125+
#[cfg(target_os = "linux")]
123126
unsafe fn f26(a0: *mut u8, a1: i32, a2: usize) -> *mut ::libc::c_void {
124127
libc::memrchr(a0 as *const ::libc::c_void, a1, a2 as usize)
125128
}

0 commit comments

Comments
 (0)