stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Farid Zaripov" <Far...@kyiv.vdiweb.com>
Subject RE: [PATCH] bitset.cc (STDCXX-297)
Date Wed, 11 Oct 2006 12:58:01 GMT
> -----Original Message-----
> From: Martin Sebor [mailto:sebor@roguewave.com] 
> Sent: Tuesday, October 10, 2006 9:30 PM
> To: stdcxx-dev@incubator.apache.org
> Subject: Re: [PATCH] bitset.cc (STDCXX-297)
> 
> >   5 is log2(sizeof (*bits) * CHAR_BIT)
> >   2 is log2(sizeof (*bits))
> 
[...]
> I would just hardcode it based on the size of the type. 
> Something simple like this (the same code is at the top of 
> bitset.cpp) will
> work:
> 
>    enum {
>    #if 4 == _RWSTD_ULONG_SIZE
>        log2_long_size = 2,
>        log2_long_bits = 5

  "log2_long_bits = 5" is correct only for CHAR_BIT == 8

  More correct to define log2_long_bits = log2_long_size +
log2_char_bits, but
how we can define log2_char_bits?

enum {
#if 8 == _RWSTD_CHAR_BIT
    log2_char_bits = 3
#else if 16 == _RWSTD_CHAR_BIT
    log2_char_bits = 4
#else if 32 == _RWSTD_CHAR_BIT
    log2_char_bits = 5
#else // assume 64 == _RWSTD_CHAR_BIT
    log2_char_bits = 6
#endif
};

  That will be enough?

  Maybe better to extend etc/src/LIMITS.cpp to calculate and define
macro _RWSTD_LOG2_CHAR_BIT?

Farid.

Mime
View raw message