-=| Damyan Ivanov, Thu, Sep 10, 2009 at 09:47:12AM +0300 |=-
> The patch needs to go into upstream first, so that the 
> implementation IDs don't change later when they release sh4 support, 
> causing incompatibilities between databases created with Deiban 
> package/upstream and upstream/Debian engine.
> 
> If you want to take this upstream yourself, you need to send 
> a bugreport using their bugtracker[1], attaching a patch to CVS 
> HEAD[2] (sending me the link so that I can track it would be nice). If 
> not, I'll deal with this somwehere in the future.
> 
>     [1] http://tracker.firebirdsql.org/
>     [2] http://sourceforge.net/scm/?type=cvs&group_id=9028

I have prepared a patch to upstream CVS head. The only missing piece 
of information is the alignment rules of sh4. Are there such rules? 
For example, may a long long int pointer reside on odd address or not?

On x86-based hardware unaligned access is ok, but on sparc it is not.

I am attaching a program that I use to check various hardware details, 
like pointer size and such. It is compiled with simple "g++ 
archtests.cpp -o archtests". If it runs fine on sh4, then unaligned 
access is OK. If you get bus error or similar, unaligned access is 
prohibited.

Thanks again.

-- 
dam
#include <stdio.h>
#include <stddef.h>

#define PACK __attribute__((__packed__))

int main(int argc, char** argv)
{
    char c;
    short s;
    int i;
    long l;
    long long ll;
    float f;
    double d;
    long double ld;
    void* p;

    char array[256];

    union endianness_detector {
        char end_uc[sizeof(ll)];
        long long end_ll;
    } end;

    struct PACK pac {
        char byte;
        char data;
        char byte2;
        char data2;
    } pac;
    struct PACK pas {
        char byte;
        short data;
        char byte2;
        short data2;
    } pas;
    struct PACK pai {
        char byte;
        int data;
        char byte2;
        int data2;
    } pai;
    struct PACK pal {
        char byte;
        long data;
        char byte2;
        long data2;
    } pal;
    struct PACK pall {
        char byte;
        long long data;
        char byte2;
        long long data2;
    } pall;
    struct PACK paf {
        char byte;
        float data;
        char byte2;
        float data2;
    } paf;
    struct PACK pad {
        char byte;
        double data;
        char byte2;
        double data2;
    } pad;
    struct PACK pald {
        char byte;
        long double data;
        char byte2;
        long double data2;
    } pald;
    struct PACK pap {
        char byte;
        void* data;
        char byte2;
        void* data2;
    } pap;

    struct ac {
        char byte;
        char data;
    };
    struct as {
        char byte;
        short data;
    };
    struct ai {
        char byte;
        int data;
    };
    struct al {
        char byte;
        long data;
    };
    struct all {
        char byte;
        long long data;
    };
    struct af {
        char byte;
        float data;
    };
    struct ad {
        char byte;
        double data;
    };
    struct ald {
        char byte;
        long double data;
    };
    struct ap {
        char byte;
        void* data;
    };

#define SHOW(type,var,val) \
    fprintf(stdout, "%-11s %4d %9d %6d ", type, (int)sizeof(var), (int)offsetof(struct a##var, data), (int)offsetof(struct pa##var, data) ); \
    fflush(stdout); \
    pa##var.data=val; fprintf(stdout, "%6s", "ok"); fflush(stdout); \
    pa##var.data2=val; fprintf(stdout, "%6s", "ok"); fflush(stdout); \
    *( ( typeof(val)* ) &(array[1]) ) = val; fprintf(stdout, "%6s\n", "ok"); \
    fprintf(stdout, "\n")

    fprintf(stdout, "type        size alignment packed access\n");
    fprintf(stdout, "----------- ---- --------- ------ ------\n");

    SHOW("char", c, 'a');
    SHOW("short", s, (short)1);
    SHOW("int", i, (int)2);
    SHOW("long", l, (long)3);
    SHOW("long long", ll, (long long)4);
    SHOW("float", f, (float)3.14);
    SHOW("double", d, (double)3.14159);
    SHOW("long double", ld, (long double)3.141592653589);
    SHOW("void*", p, (void*)&s);

    fprintf(stdout, "\n");

    end.end_ll = 1;

    if( end.end_uc[0] == 1 )
        fprintf(stdout, "Endianness: LE\n");
    else if( end.end_uc[sizeof(end.end_ll)-1] == 1 )
        fprintf(stdout, "Endianness: BE\n");
    else
        fprintf(stdout, "Endianness: UNKNOWN\n");

    *( signed char *)&c = -1;
    i = (int)c;
    if( i < 0 )
        fprintf(stdout, "char is SIGNED\n");
    else
        fprintf(stdout, "char is UNSIGNED\n");
}

Attachment: signature.asc
Description: Digital signature

Reply via email to