Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-07 10:15:27

0001 /*
0002     Copyright (C) 2023 Albin Ahlbäck
0003 
0004     This file is part of FLINT.
0005 
0006     FLINT is free software: you can redistribute it and/or modify it under
0007     the terms of the GNU Lesser General Public License (LGPL) as published
0008     by the Free Software Foundation; either version 3 of the License, or
0009     (at your option) any later version.  See <https://www.gnu.org/licenses/>.
0010 */
0011 
0012 #ifndef LONGLONG_MSC_H
0013 #define LONGLONG_MSC_H
0014 
0015 #include <stdlib.h>
0016 #include <intrin.h>
0017 #include <immintrin.h>
0018 
0019 /* Trailing and leading zeros */
0020 # define flint_clz _CountLeadingZeros64
0021 # define flint_ctz flint_ctz
0022 static inline int flint_ctz(ulong x)
0023 {
0024     unsigned long int index;
0025     _BitScanForward64(&index, x);
0026     return index;
0027 }
0028 
0029 /* Multiplication */
0030 #define umul_ppmm(r1, r0, u, v) \
0031 do \
0032 { \
0033     (r0) = (u) * (v); \
0034     (r1) = __umulh(u, v); \
0035 } while (0)
0036 
0037 #define smul_ppmm(r1, r0, u, v) \
0038 do \
0039 { \
0040     (r0) = (u) * (v); \
0041     (r1) = __mulh(u, v); \
0042 } while (0)
0043 
0044 #endif