File tree Expand file tree Collapse file tree 5 files changed +32
-1
lines changed
pk/asn1/der/object_identifier Expand file tree Collapse file tree 5 files changed +32
-1
lines changed Original file line number Diff line number Diff line change 1717*/
1818int ocb_ntz (unsigned long x )
1919{
20+ #if defined(LTC_HAVE_CTZL_BUILTIN )
21+ if (x == 0 )
22+ return sizeof (unsigned long ) * CHAR_BIT ;
23+ return __builtin_ctzl (x );
24+ #else
2025 int c ;
2126 x &= 0xFFFFFFFFUL ;
2227 c = 0 ;
@@ -25,6 +30,7 @@ int ocb_ntz(unsigned long x)
2530 x >>= 1 ;
2631 }
2732 return c ;
33+ #endif
2834}
2935
3036#endif
Original file line number Diff line number Diff line change 1616*/
1717int ocb3_int_ntz (unsigned long x )
1818{
19+ #if defined(LTC_HAVE_CTZL_BUILTIN )
20+ if (x == 0 )
21+ return sizeof (unsigned long ) * CHAR_BIT ;
22+ return __builtin_ctzl (x );
23+ #else
1924 int c ;
2025 x &= 0xFFFFFFFFUL ;
2126 c = 0 ;
@@ -24,6 +29,7 @@ int ocb3_int_ntz(unsigned long x)
2429 x >>= 1 ;
2530 }
2631 return c ;
32+ #endif
2733}
2834
2935#endif
Original file line number Diff line number Diff line change @@ -295,6 +295,14 @@ typedef unsigned long ltc_mp_digit;
295295 #define LTC_HAVE_ROTATE_BUILTIN
296296#endif
297297
298+ #if __has_builtin (__builtin_clzl )
299+ #define LTC_HAVE_CLZL_BUILTIN
300+ #endif
301+
302+ #if __has_builtin (__builtin_ctzl )
303+ #define LTC_HAVE_CTZL_BUILTIN
304+ #endif
305+
298306#if defined(__GNUC__ )
299307 #define LTC_ALIGN (n ) __attribute__((aligned(n)))
300308#else
Original file line number Diff line number Diff line change 1414*/
1515int pmac_ntz (unsigned long x )
1616{
17+ #if defined(LTC_HAVE_CTZL_BUILTIN )
18+ if (x == 0 )
19+ return sizeof (unsigned long ) * CHAR_BIT ;
20+ return __builtin_ctzl (x );
21+ #else
1722 int c ;
1823 x &= 0xFFFFFFFFUL ;
1924 c = 0 ;
@@ -22,6 +27,7 @@ int pmac_ntz(unsigned long x)
2227 x >>= 1 ;
2328 }
2429 return c ;
30+ #endif
2531}
2632
2733#endif
Original file line number Diff line number Diff line change 1111
1212unsigned long der_object_identifier_bits (unsigned long x )
1313{
14+ #if defined(LTC_HAVE_CLZL_BUILTIN )
15+ if (x == 0 )
16+ return 0 ;
17+ return sizeof (unsigned long ) * CHAR_BIT - __builtin_clzl (x );
18+ #else
1419 unsigned long c ;
1520 x &= (unsigned long )-1 ;
1621 c = 0 ;
@@ -19,9 +24,9 @@ unsigned long der_object_identifier_bits(unsigned long x)
1924 x >>= 1 ;
2025 }
2126 return c ;
27+ #endif
2228}
2329
24-
2530/**
2631 Gets length of DER encoding of Object Identifier
2732 @param nwords The number of OID words
You can’t perform that action at this time.
0 commit comments