@@ -54,18 +54,20 @@ pub(crate) unsafe fn update(state: u64, bytes: &[u8], params: CrcParams) -> u64
5454#[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
5555#[ target_feature( enable = "sse2,sse4.1,pclmulqdq" ) ]
5656pub ( crate ) unsafe fn update ( state : u64 , bytes : & [ u8 ] , params : CrcParams ) -> u64 {
57- let ops = X86Ops ;
57+ update_x86_sse ( state, bytes, params)
58+ }
5859
59- match params. width {
60- 64 => algorithm:: update :: < X86Ops , Width64 > ( state, bytes, params, & ops) ,
61- 32 => algorithm:: update :: < X86Ops , Width32 > ( state as u32 , bytes, params, & ops) as u64 ,
62- _ => panic ! ( "Unsupported CRC width: {}" , params. width) ,
63- }
60+ #[ rustversion:: since( 1.89 ) ]
61+ #[ inline]
62+ #[ cfg( target_arch = "x86" ) ]
63+ #[ target_feature( enable = "sse2,sse4.1,pclmulqdq" ) ]
64+ pub ( crate ) unsafe fn update ( state : u64 , bytes : & [ u8 ] , params : CrcParams ) -> u64 {
65+ update_x86_sse ( state, bytes, params)
6466}
6567
6668#[ rustversion:: since( 1.89 ) ]
6769#[ inline]
68- #[ cfg( any ( target_arch = "x86" , target_arch = " x86_64") ) ]
70+ #[ cfg( target_arch = "x86_64" ) ]
6971#[ target_feature( enable = "sse2,sse4.1,pclmulqdq" ) ]
7072pub ( crate ) unsafe fn update ( state : u64 , bytes : & [ u8 ] , params : CrcParams ) -> u64 {
7173 use std:: arch:: is_x86_feature_detected;
@@ -106,6 +108,19 @@ pub(crate) unsafe fn update(state: u64, bytes: &[u8], params: CrcParams) -> u64
106108 software:: update ( state, bytes, params)
107109}
108110
111+ #[ inline]
112+ #[ cfg( target_arch = "x86" ) ]
113+ #[ target_feature( enable = "sse2,sse4.1,pclmulqdq" ) ]
114+ unsafe fn update_x86_sse ( state : u64 , bytes : & [ u8 ] , params : CrcParams ) -> u64 {
115+ let ops = X86Ops ;
116+
117+ match params. width {
118+ 64 => algorithm:: update :: < X86Ops , Width64 > ( state, bytes, params, & ops) ,
119+ 32 => algorithm:: update :: < X86Ops , Width32 > ( state as u32 , bytes, params, & ops) as u64 ,
120+ _ => panic ! ( "Unsupported CRC width: {}" , params. width) ,
121+ }
122+ }
123+
109124#[ rustversion:: before( 1.89 ) ]
110125pub fn get_target ( ) -> String {
111126 #[ cfg( target_arch = "aarch64" ) ]
0 commit comments