madf: (Default)
[personal profile] madf
Пару днів тому, начитавшись відгуків про новий графічний рушій Qt raster вирішив спробувати. Зі стандартним рушієм у мене у Konqueror підторможувала прокрутка (особливо на великих сторінках). Коли запустив з --graphicssystem raster - прокручувати стало плавно і без ривків. Круто, що тут скажеш...

Вчора ввечері вирішив перезібрати x11-libs/qt-gui з raster за замовчуванням. Перезібрав. Запустив. Тепер прокрутка взагалі зламалась - перемальовується лише вузька полоска зверху або знизу (в залежності від напрямку прокручування).
Вирішив відкотитись назад. Знову запустив компіляцію. І помітив краєм ока (дуже швидко промайнуло) знайомі слова: endiantest. Поліз дивитись у джерельні коди і знайшов немало цікавого!
Qt3 (config.tests/unix/endian/endiantest.cpp):
int main(int, char **)
{
    unsigned char bytes[] = { 0x01, 0x02, 0x03, 0x04 };
    unsigned int *integer = (unsigned int *) bytes;
    return (*integer == 0x01020304 ?
            0 : // big endian
            1);  // little endian
}

Qt4 (config.tests/unix/endian/endiantest.cpp):
// "MostSignificantByteFirst"
short msb_bigendian[] = { 0x0000, 0x4d6f, 0x7374, 0x5369, 0x676e, 0x6966, 0x6963, 0x616e, 0x7442, 0x7974, 0x6546, 0x6972, 0x7374, 0x0000 };

// "LeastSignificantByteFirst"
short lsb_littleendian[] = { 0x0000, 0x654c, 0x7361, 0x5374, 0x6769, 0x696e, 0x6966, 0x6163, 0x746e, 0x7942, 0x6574, 0x6946, 0x7372, 0x0074, 0x0000 };

int main(int, char **)
{
    // make sure the linker doesn't throw away the arrays
    char *msb_bigendian_string = (char *) msb_bigendian;
    char *lsb_littleendian_string = (char *) lsb_littleendian;
    (void) msb_bigendian_string;
    (void) lsb_littleendian_string;
    return msb_bigendian[1] == lsb_littleendian[1];
}

(config.tests/unix/endian.test)
...

if strings $binary | grep LeastSignificantByteFirst >/dev/null 2>&1; then
    [ "$VERBOSE" = "yes" ] && echo "    Found 'LeastSignificantByteFirst' in binary"
    ENDIAN="LITTLE"
elif strings $binary | grep MostSignificantByteFirst >/dev/null 2>&1; then
    [ "$VERBOSE" = "yes" ] && echo "    Found 'MostSignificantByteFirst' in binary"
    ENDIAN="BIG"
fi

...


Цікаве рішення! А я до цього часу не знав про існування strings (входить до binutils). "strings - print the strings of printable characters in files."

Profile

madf: (Default)
madf

April 2018

S M T W T F S
1234567
891011121314
15161718192021
22232425262728
2930     

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jun. 7th, 2026 04:21 am
Powered by Dreamwidth Studios