vendredi 14 août 2015

What does this code mean

I found a code segment. I do not understand it. It seems that the variable __rem is useless at all. The line below does not do any useful work yet:

(void)(((typeof((n)) *)0) == ((uint64_t *)0));   \

The whole code segment is as below:

#define do_div(n,base)  do{             \
    uint32_t __base = (base);           \
    uint32_t __rem;                 \
    (void)(((typeof((n)) *)0) == ((uint64_t *)0));   \
    if (((n) >> 32) == 0) {         \
        __rem = (uint32_t)(n) % __base;     \
        (n) = (uint32_t)(n) / __base;       \
    } else                      \
        __rem = __div64_32(&(n), __base);   \
    __rem;                      \
 }while(0)
/* Wrapper for do_div(). Doesn't modify dividend and returns
 * the result, not reminder.
 */
static inline uint64_t lldiv(uint64_t dividend, uint32_t divisor)
{
    uint64_t __res = dividend;
    do_div(__res, divisor);
    return(__res);
}

Why is the useless code here?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire