defined MIO_BITS_PER_BYTE
This commit is contained in:
parent
10be482d97
commit
8ed151abb6
@ -42,7 +42,7 @@ floting-point conversion implementation*/
|
|||||||
|
|
||||||
/* Max number conversion buffer length:
|
/* Max number conversion buffer length:
|
||||||
* mio_intmax_t in base 2, plus NUL byte. */
|
* mio_intmax_t in base 2, plus NUL byte. */
|
||||||
#define MAXNBUF (MIO_SIZEOF(mio_intmax_t) * 8 + 1)
|
#define MAXNBUF (MIO_SIZEOF(mio_intmax_t) * MIO_BITS_PER_BYTE + 1)
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -994,7 +994,7 @@ static int fmtoutv (mio_t* mio, const fmtchar_t* fmt, mio_fmtout_data_t* data, v
|
|||||||
#else
|
#else
|
||||||
register int shift = i * MIO_SIZEOF(mio_oow_t);
|
register int shift = i * MIO_SIZEOF(mio_oow_t);
|
||||||
mio_oow_t x = va_arg (ap, mio_oow_t);
|
mio_oow_t x = va_arg (ap, mio_oow_t);
|
||||||
num |= (mio_uintmax_t)x << (shift * 8);
|
num |= (mio_uintmax_t)x << (shift * MIO_BITS_PER_BYTE);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -1038,7 +1038,7 @@ static int fmtoutv (mio_t* mio, const fmtchar_t* fmt, mio_fmtout_data_t* data, v
|
|||||||
#else
|
#else
|
||||||
register int shift = i * MIO_SIZEOF(mio_oow_t);
|
register int shift = i * MIO_SIZEOF(mio_oow_t);
|
||||||
mio_oow_t x = va_arg (ap, mio_oow_t);
|
mio_oow_t x = va_arg (ap, mio_oow_t);
|
||||||
num |= (mio_uintmax_t)x << (shift * 8);
|
num |= (mio_uintmax_t)x << (shift * MIO_BITS_PER_BYTE);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -45,6 +45,10 @@
|
|||||||
# error UNSUPPORTED SYSTEM
|
# error UNSUPPORTED SYSTEM
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* =========================================================================
|
||||||
|
* ARCHITECTURE/COMPILER TWEAKS
|
||||||
|
* ========================================================================= */
|
||||||
|
|
||||||
#if defined(EMSCRIPTEN)
|
#if defined(EMSCRIPTEN)
|
||||||
# if defined(MIO_SIZEOF___INT128)
|
# if defined(MIO_SIZEOF___INT128)
|
||||||
# undef MIO_SIZEOF___INT128
|
# undef MIO_SIZEOF___INT128
|
||||||
@ -57,6 +61,20 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__GNUC__) && defined(__arm__) && !defined(__ARM_ARCH)
|
||||||
|
# if defined(__ARM_ARCH_8__)
|
||||||
|
# define __ARM_ARCH 8
|
||||||
|
# elif defined(__ARM_ARCH_7__)
|
||||||
|
# define __ARM_ARCH 7
|
||||||
|
# elif defined(__ARM_ARCH_6__)
|
||||||
|
# define __ARM_ARCH 6
|
||||||
|
# elif defined(__ARM_ARCH_5__)
|
||||||
|
# define __ARM_ARCH 5
|
||||||
|
# elif defined(__ARM_ARCH_4__)
|
||||||
|
# define __ARM_ARCH 4
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
* PRIMITIVE TYPE DEFINTIONS
|
* PRIMITIVE TYPE DEFINTIONS
|
||||||
* ========================================================================= */
|
* ========================================================================= */
|
||||||
@ -318,6 +336,13 @@
|
|||||||
# error UNKNOWN INTMAX SIZE
|
# error UNKNOWN INTMAX SIZE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* =========================================================================
|
||||||
|
* BASIC HARD-CODED DEFINES
|
||||||
|
* ========================================================================= */
|
||||||
|
#define MIO_BITS_PER_BYTE (8)
|
||||||
|
/* the maximum number of bch charaters to represent a single uch character */
|
||||||
|
#define MIO_BCSIZE_MAX 6
|
||||||
|
|
||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
* BASIC MIO TYPES
|
* BASIC MIO TYPES
|
||||||
* =========================================================================*/
|
* =========================================================================*/
|
||||||
@ -356,11 +381,15 @@ typedef mio_uintptr_t mio_oow_t;
|
|||||||
typedef mio_intptr_t mio_ooi_t;
|
typedef mio_intptr_t mio_ooi_t;
|
||||||
#define MIO_SIZEOF_OOW_T MIO_SIZEOF_UINTPTR_T
|
#define MIO_SIZEOF_OOW_T MIO_SIZEOF_UINTPTR_T
|
||||||
#define MIO_SIZEOF_OOI_T MIO_SIZEOF_INTPTR_T
|
#define MIO_SIZEOF_OOI_T MIO_SIZEOF_INTPTR_T
|
||||||
|
#define MIO_OOW_BITS (MIO_SIZEOF_OOW_T * MIO_BITS_PER_BYTE)
|
||||||
|
#define MIO_OOI_BITS (MIO_SIZEOF_OOI_T * MIO_BITS_PER_BYTE)
|
||||||
|
|
||||||
typedef mio_ushortptr_t mio_oohw_t; /* half word - half word */
|
typedef mio_ushortptr_t mio_oohw_t; /* half word - half word */
|
||||||
typedef mio_shortptr_t mio_oohi_t; /* signed half word */
|
typedef mio_shortptr_t mio_oohi_t; /* signed half word */
|
||||||
#define MIO_SIZEOF_OOHW_T MIO_SIZEOF_USHORTPTR_T
|
#define MIO_SIZEOF_OOHW_T MIO_SIZEOF_USHORTPTR_T
|
||||||
#define MIO_SIZEOF_OOHI_T MIO_SIZEOF_SHORTPTR_T
|
#define MIO_SIZEOF_OOHI_T MIO_SIZEOF_SHORTPTR_T
|
||||||
|
#define MIO_OOHW_BITS (MIO_SIZEOF_OOHW_T * MIO_BITS_PER_BYTE)
|
||||||
|
#define MIO_OOHI_BITS (MIO_SIZEOF_OOHI_T * MIO_BITS_PER_BYTE)
|
||||||
|
|
||||||
struct mio_ucs_t
|
struct mio_ucs_t
|
||||||
{
|
{
|
||||||
@ -519,11 +548,11 @@ struct mio_ntime_t
|
|||||||
|
|
||||||
/* make a bit mask that can mask off low n bits */
|
/* make a bit mask that can mask off low n bits */
|
||||||
#define MIO_LBMASK(type,n) (~(~((type)0) << (n)))
|
#define MIO_LBMASK(type,n) (~(~((type)0) << (n)))
|
||||||
#define MIO_LBMASK_SAFE(type,n) (((n) < MIO_SIZEOF(type) * 8)? MIO_LBMASK(type,n): ~(type)0)
|
#define MIO_LBMASK_SAFE(type,n) (((n) < MIO_SIZEOF(type) * MIO_BITS_PER_BYTE)? MIO_LBMASK(type,n): ~(type)0)
|
||||||
|
|
||||||
/* make a bit mask that can mask off hig n bits */
|
/* make a bit mask that can mask off hig n bits */
|
||||||
#define MIO_HBMASK(type,n) (~(~((type)0) >> (n)))
|
#define MIO_HBMASK(type,n) (~(~((type)0) >> (n)))
|
||||||
#define MIO_HBMASK_SAFE(type,n) (((n) < MIO_SIZEOF(type) * 8)? MIO_HBMASK(type,n): ~(type)0)
|
#define MIO_HBMASK_SAFE(type,n) (((n) < MIO_SIZEOF(type) * MIO_BITS_PER_BYTE)? MIO_HBMASK(type,n): ~(type)0)
|
||||||
|
|
||||||
/* get 'length' bits starting from the bit at the 'offset' */
|
/* get 'length' bits starting from the bit at the 'offset' */
|
||||||
#define MIO_GETBITS(type,value,offset,length) \
|
#define MIO_GETBITS(type,value,offset,length) \
|
||||||
@ -550,7 +579,7 @@ struct mio_ntime_t
|
|||||||
* \endcode
|
* \endcode
|
||||||
*/
|
*/
|
||||||
/*#define MIO_BITS_MAX(type,nbits) ((((type)1) << (nbits)) - 1)*/
|
/*#define MIO_BITS_MAX(type,nbits) ((((type)1) << (nbits)) - 1)*/
|
||||||
#define MIO_BITS_MAX(type,nbits) ((~(type)0) >> (MIO_SIZEOF(type) * 8 - (nbits)))
|
#define MIO_BITS_MAX(type,nbits) ((~(type)0) >> (MIO_SIZEOF(type) * MIO_BITS_PER_BYTE - (nbits)))
|
||||||
|
|
||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
* MMGR
|
* MMGR
|
||||||
@ -691,11 +720,11 @@ struct mio_cmgr_t
|
|||||||
#define MIO_TYPE_IS_UNSIGNED(type) (((type)0) < ((type)-1))
|
#define MIO_TYPE_IS_UNSIGNED(type) (((type)0) < ((type)-1))
|
||||||
|
|
||||||
#define MIO_TYPE_SIGNED_MAX(type) \
|
#define MIO_TYPE_SIGNED_MAX(type) \
|
||||||
((type)~((type)1 << ((type)MIO_SIZEOF(type) * 8 - 1)))
|
((type)~((type)1 << ((type)MIO_SIZEOF(type) * MIO_BITS_PER_BYTE - 1)))
|
||||||
#define MIO_TYPE_UNSIGNED_MAX(type) ((type)(~(type)0))
|
#define MIO_TYPE_UNSIGNED_MAX(type) ((type)(~(type)0))
|
||||||
|
|
||||||
#define MIO_TYPE_SIGNED_MIN(type) \
|
#define MIO_TYPE_SIGNED_MIN(type) \
|
||||||
((type)((type)1 << ((type)MIO_SIZEOF(type) * 8 - 1)))
|
((type)((type)1 << ((type)MIO_SIZEOF(type) * MIO_BITS_PER_BYTE - 1)))
|
||||||
#define MIO_TYPE_UNSIGNED_MIN(type) ((type)0)
|
#define MIO_TYPE_UNSIGNED_MIN(type) ((type)0)
|
||||||
|
|
||||||
#define MIO_TYPE_MAX(type) \
|
#define MIO_TYPE_MAX(type) \
|
||||||
|
@ -658,7 +658,7 @@ mio_bch_t* mio_find_bchar_in_bcstr (const mio_bch_t* ptr, mio_bch_t c)
|
|||||||
|
|
||||||
mio_oow_t mio_byte_to_bcstr (mio_uint8_t byte, mio_bch_t* buf, mio_oow_t size, int flagged_radix, mio_bch_t fill)
|
mio_oow_t mio_byte_to_bcstr (mio_uint8_t byte, mio_bch_t* buf, mio_oow_t size, int flagged_radix, mio_bch_t fill)
|
||||||
{
|
{
|
||||||
mio_bch_t tmp[(MIO_SIZEOF(mio_uint8_t) * 8)];
|
mio_bch_t tmp[(MIO_SIZEOF(mio_uint8_t) * MIO_BITS_PER_BYTE)];
|
||||||
mio_bch_t* p = tmp, * bp = buf, * be = buf + size - 1;
|
mio_bch_t* p = tmp, * bp = buf, * be = buf + size - 1;
|
||||||
int radix;
|
int radix;
|
||||||
mio_bch_t radix_char;
|
mio_bch_t radix_char;
|
||||||
|
Loading…
Reference in New Issue
Block a user