@@ -148,15 +148,32 @@ macro_rules! impl_fn {
148
148
} ;
149
149
150
150
( @impl_all ( $( $nm: ident : $ty: ident) ,* ) ) => {
151
- impl_fn!( @impl_u_and_s ( $( $nm : $ty) ,* ) ( "Rust" ) fn ( $( $ty) ,* ) -> Ret ) ;
152
- impl_fn!( @impl_u_and_s ( $( $nm : $ty) ,* ) ( "cdecl" ) fn ( $( $ty) ,* ) -> Ret ) ;
153
- impl_fn!( @impl_u_and_s ( $( $nm : $ty) ,* ) ( "stdcall" ) fn ( $( $ty) ,* ) -> Ret ) ;
154
- impl_fn!( @impl_u_and_s ( $( $nm : $ty) ,* ) ( "fastcall" ) fn ( $( $ty) ,* ) -> Ret ) ;
151
+ // Universal conventions
152
+ {
153
+ impl_fn!( @impl_u_and_s ( $( $nm : $ty) ,* ) ( "Rust" ) fn ( $( $ty) ,* ) -> Ret ) ;
154
+ impl_fn!( @impl_u_and_s ( $( $nm : $ty) ,* ) ( "C" ) fn ( $( $ty) ,* ) -> Ret ) ;
155
+ impl_fn!( @impl_u_and_s ( $( $nm : $ty) ,* ) ( "system" ) fn ( $( $ty) ,* ) -> Ret ) ;
156
+ }
157
+
158
+ // x86-specific conventions
159
+ #[ cfg( target_arch = "x86" ) ]
160
+ {
161
+ impl_fn!( @impl_u_and_s ( $( $nm : $ty) ,* ) ( "cdecl" ) fn ( $( $ty) ,* ) -> Ret ) ;
162
+ impl_fn!( @impl_u_and_s ( $( $nm : $ty) ,* ) ( "stdcall" ) fn ( $( $ty) ,* ) -> Ret ) ;
163
+ impl_fn!( @impl_u_and_s ( $( $nm : $ty) ,* ) ( "fastcall" ) fn ( $( $ty) ,* ) -> Ret ) ;
164
+ }
165
+
166
+ // x86_64 Windows
167
+ #[ cfg( all( target_arch = "x86_64" , target_os = "windows" ) ) ]
155
168
impl_fn!( @impl_u_and_s ( $( $nm : $ty) ,* ) ( "win64" ) fn ( $( $ty) ,* ) -> Ret ) ;
169
+
170
+ // x86_64 System V (Linux/macOS)
171
+ #[ cfg( all( target_arch = "x86_64" , not( target_os = "windows" ) ) ) ]
156
172
impl_fn!( @impl_u_and_s ( $( $nm : $ty) ,* ) ( "sysv64" ) fn ( $( $ty) ,* ) -> Ret ) ;
173
+
174
+ // ARM conventions
175
+ #[ cfg( any( target_arch = "arm" , target_arch = "aarch64" ) ) ]
157
176
impl_fn!( @impl_u_and_s ( $( $nm : $ty) ,* ) ( "aapcs" ) fn ( $( $ty) ,* ) -> Ret ) ;
158
- impl_fn!( @impl_u_and_s ( $( $nm : $ty) ,* ) ( "C" ) fn ( $( $ty) ,* ) -> Ret ) ;
159
- impl_fn!( @impl_u_and_s ( $( $nm : $ty) ,* ) ( "system" ) fn ( $( $ty) ,* ) -> Ret ) ;
160
177
} ;
161
178
162
179
( @impl_u_and_s ( $( $nm: ident : $ty: ident) ,* ) ( $call_conv: expr) fn ( $( $param_ty: ident) ,* ) -> $ret: ty) => {
0 commit comments