Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions | Variables
gencfg.c File Reference
#include <stdio.h>

Go to the source code of this file.

Classes

struct  align_short
struct  align_int
struct  align_long
struct  align_PRInt64
struct  align_fakelonglong
struct  align_float
struct  align_double
struct  align_pointer
struct  align_fakelonglong.a

Defines

#define INT64   long long
#define ALIGN_OF(type)   (((char*)&(((struct align_##type *)0)->a)) - ((char*)0))

Functions

static int Log2 (int n)
static void do64 (void)
static void do32 (void)
static void BitsPerByte (void)
int main (int argc, char **argv)
 The Xalan testcases app.

Variables

int bpb
FILEstream

Class Documentation

struct align_short

Definition at line 89 of file jscpucfg.c.

Class Members
short a
char c
struct align_int

Definition at line 93 of file jscpucfg.c.

Collaboration diagram for align_int:
Class Members
int a
char c
struct align_long

Definition at line 97 of file jscpucfg.c.

Class Members
long a
char c
struct align_PRInt64

Definition at line 141 of file gencfg.c.

Class Members
INT64 a
char c
struct align_fakelonglong

Definition at line 105 of file jscpucfg.c.

Class Members
struct align_fakelonglong a
struct align_fakelonglong a
char c
struct align_float

Definition at line 111 of file jscpucfg.c.

Class Members
float a
char c
struct align_double

Definition at line 115 of file jscpucfg.c.

Class Members
double a
char c
struct align_pointer

Definition at line 119 of file jscpucfg.c.

Class Members
void * a
char c
struct align_fakelonglong.a

Definition at line 147 of file gencfg.c.

Class Members
long hi
long lo

Define Documentation

#define ALIGN_OF (   type)    (((char*)&(((struct align_##type *)0)->a)) - ((char*)0))

Definition at line 164 of file gencfg.c.

Definition at line 125 of file gencfg.c.


Function Documentation

static void BitsPerByte ( void  ) [static]

Definition at line 231 of file gencfg.c.

{
    bpb = 8;
}

Here is the caller graph for this function:

static void do32 ( void  ) [static]

Definition at line 209 of file gencfg.c.

{
    union {
       long i;
       char c[4];
    } u;

    u.i = 0x01020304;
    if (u.c[0] == 0x01) {
       fprintf(stream, "#undef  IS_LITTLE_ENDIAN\n");
       fprintf(stream, "#define IS_BIG_ENDIAN 1\n\n");
    } else {
       fprintf(stream, "#define IS_LITTLE_ENDIAN 1\n");
       fprintf(stream, "#undef  IS_BIG_ENDIAN\n\n");
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void do64 ( void  ) [static]

Definition at line 192 of file gencfg.c.

{
    union {
       int i;
       char c[4];
    } u;

    u.i = 0x01020304;
    if (u.c[0] == 0x01) {
       fprintf(stream, "#undef  IS_LITTLE_ENDIAN\n");
       fprintf(stream, "#define IS_BIG_ENDIAN 1\n\n");
    } else {
       fprintf(stream, "#define IS_LITTLE_ENDIAN 1\n");
       fprintf(stream, "#undef  IS_BIG_ENDIAN\n\n");
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int Log2 ( int  n) [static]

Definition at line 172 of file gencfg.c.

{
    int log2 = 0;

    if (n & (n-1))
       log2++;
    if (n >> 16)
       log2 += 16, n >>= 16;
    if (n >> 8)
       log2 += 8, n >>= 8;
    if (n >> 4)
       log2 += 4, n >>= 4;
    if (n >> 2)
       log2 += 2, n >>= 2;
    if (n >> 1)
       log2++;
    return log2;
}

Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)

The Xalan testcases app.

Definition at line 236 of file gencfg.c.

{
    BitsPerByte();

    /* If we got a command line argument, try to use it as the stream. */
    ++argv;
    if(*argv) {
        if(!(stream = fopen ( *argv, "wt" ))) {
            fprintf(stderr, "Could not write to output file %s.\n", *argv);
            return 1;
        }
    } else {
              stream = stdout;
       }

    fprintf(stream, "#ifndef nspr_cpucfg___\n");
    fprintf(stream, "#define nspr_cpucfg___\n\n");

    fprintf(stream, "/* AUTOMATICALLY GENERATED - DO NOT EDIT */\n\n");

    if (sizeof(long) == 8) {
       do64();
    } else {
       do32();
    }
    fprintf(stream, "#define PR_BYTES_PER_BYTE   %d\n", sizeof(char));
    fprintf(stream, "#define PR_BYTES_PER_SHORT  %d\n", sizeof(short));
    fprintf(stream, "#define PR_BYTES_PER_INT    %d\n", sizeof(int));
    fprintf(stream, "#define PR_BYTES_PER_INT64  %d\n", 8);
    fprintf(stream, "#define PR_BYTES_PER_LONG   %d\n", sizeof(long));
    fprintf(stream, "#define PR_BYTES_PER_FLOAT  %d\n", sizeof(float));
    fprintf(stream, "#define PR_BYTES_PER_DOUBLE %d\n\n", sizeof(double));

    fprintf(stream, "#define PR_BITS_PER_BYTE    %d\n", bpb);
    fprintf(stream, "#define PR_BITS_PER_SHORT   %d\n", bpb * sizeof(short));
    fprintf(stream, "#define PR_BITS_PER_INT     %d\n", bpb * sizeof(int));
    fprintf(stream, "#define PR_BITS_PER_INT64   %d\n", bpb * 8);
    fprintf(stream, "#define PR_BITS_PER_LONG    %d\n", bpb * sizeof(long));
    fprintf(stream, "#define PR_BITS_PER_FLOAT   %d\n", bpb * sizeof(float));
    fprintf(stream, "#define PR_BITS_PER_DOUBLE  %d\n\n", 
            bpb * sizeof(double));

    fprintf(stream, "#define PR_BITS_PER_BYTE_LOG2   %d\n", Log2(bpb));
    fprintf(stream, "#define PR_BITS_PER_SHORT_LOG2  %d\n", 
            Log2(bpb * sizeof(short)));
    fprintf(stream, "#define PR_BITS_PER_INT_LOG2    %d\n", 
            Log2(bpb * sizeof(int)));
    fprintf(stream, "#define PR_BITS_PER_INT64_LOG2  %d\n", 6);
    fprintf(stream, "#define PR_BITS_PER_LONG_LOG2   %d\n", 
            Log2(bpb * sizeof(long)));
    fprintf(stream, "#define PR_BITS_PER_FLOAT_LOG2  %d\n", 
            Log2(bpb * sizeof(float)));
    fprintf(stream, "#define PR_BITS_PER_DOUBLE_LOG2 %d\n\n", 
            Log2(bpb * sizeof(double)));

    fprintf(stream, "#define PR_ALIGN_OF_SHORT   %d\n", ALIGN_OF(short));
    fprintf(stream, "#define PR_ALIGN_OF_INT     %d\n", ALIGN_OF(int));
    fprintf(stream, "#define PR_ALIGN_OF_LONG    %d\n", ALIGN_OF(long));
    if (sizeof(INT64) < 8) {
       /* this machine doesn't actually support PRInt64's */
       fprintf(stream, "#define PR_ALIGN_OF_INT64   %d\n", 
                ALIGN_OF(fakelonglong));
    } else {
       fprintf(stream, "#define PR_ALIGN_OF_INT64   %d\n", ALIGN_OF(PRInt64));
    }
    fprintf(stream, "#define PR_ALIGN_OF_FLOAT   %d\n", ALIGN_OF(float));
    fprintf(stream, "#define PR_ALIGN_OF_DOUBLE  %d\n", ALIGN_OF(double));
    fprintf(stream, "#define PR_ALIGN_OF_POINTER %d\n\n", ALIGN_OF(pointer));

    fprintf(stream, "#endif /* nspr_cpucfg___ */\n");
    fclose(stream);

    return 0;
}

Here is the call graph for this function:


Variable Documentation

Definition at line 167 of file gencfg.c.

Definition at line 170 of file gencfg.c.