-#define Sbitset__nbytes(NBITS) (((NBITS)+7)/8)
-#define Sbitset__byteAddress(SELF, INDEX) (((SELF) + (INDEX)/8))
-#define Sbitset__bit_mask(INDEX) (0x1 << (7 - (INDEX)%8))
-#define Sbitset__last_byte_mask(NBITS) (0xff << (7 - ((NBITS)-1)%8))
+#define Sbitset__nbytes(NBITS) \
+ (((NBITS) + CHAR_BIT - 1) / CHAR_BIT)
+#define Sbitset__byteAddress(SELF, INDEX) \
+ (((SELF) + (INDEX) / CHAR_BIT))
+#define Sbitset__bit_mask(INDEX) \
+ (1 << (CHAR_BIT - 1 - (INDEX) % CHAR_BIT))
+#define Sbitset__last_byte_mask(NBITS) \
+ (UCHAR_MAX << (CHAR_BIT - 1 - ((NBITS) - 1) % CHAR_BIT))