Functions | Variables

pvmgetdsig.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include "utility.h"
Include dependency graph for pvmgetdsig.c:

Go to the source code of this file.

Functions

void printbits (int x)
int ffs (int x)
static int ibol (int o, char *p, int n)
static int fbol (int o, unsigned char *p, int n)
int pvmgetdsig ()

Variables

unsigned char fs1 [] = { 0x3f, 0x80, 0x00, 0x00 }
unsigned char fs2 [] = { 0x3f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
unsigned char fs4 [] = { 0x40, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00 }
unsigned char fs5 [] = { 0x40, 0x80, 0x00, 0x00 }
unsigned char fs6 [] = { 0x40, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
struct floatsig thesigs []

Detailed Description

PVM data signature code. See the original copyright notice below.

Definition in file pvmgetdsig.c.


Function Documentation

static int fbol ( int  o,
unsigned char *  p,
int  n 
) [static]

Definition at line 161 of file pvmgetdsig.c.

{
    int i, j;

    for (i = 0; i < 16; i++) {
        if (thesigs[i].length == n) {
            for (j = 0; j < n; j++)
                if (p[j] != thesigs[i].bytes[j])
                    break;
            if (j == n)
                return ((3 << 4) | i) << o;

            for (j = 0; j < n; j++)
                if (p[n - 1 - j] != thesigs[i].bytes[j])
                    break;
            if (j == n)
                return i << o;
        }
    }
    fprintf(stderr, "can't generate signature for my integer byte order\n");
    abort();
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int ffs ( int  x  ) 

Definition at line 70 of file pvmgetdsig.c.

{
    int n = 1, m = 1;

    if (!x)
        return 0;
    while (!(x & m)) {
        m += m;
        n++;
    }
    return n;
}

Here is the caller graph for this function:

static int ibol ( int  o,
char *  p,
int  n 
) [static]

Definition at line 87 of file pvmgetdsig.c.

{
    int i, j;

    if (p[0] == 0) {
        i = 0;  /* ll */
    } else if (p[0] == n - 1) {
        i = 3;  /* hh */
    } else if (p[0] == n / 2) {
        i = 2;  /* hl */
    } else if (p[0] == n / 2 - 1) {
        i = 1;  /* lh */
    } else {
        fprintf(stderr, "can't generate signature for my integer byte order\n");
        abort();
    }

    j = ffs(n) - 1;
/*
    printf(".%d%d.%d%d%d", (i & 2) ? 1 : 0, (i & 1) ? 1 : 0
            (j & 4) ? 1 : 0, (j & 2) ? 1 : 0, (j & 1) ? 1 : 0);
*/
    return ((i << 3) | j) << o;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void printbits ( int  x  ) 

Definition at line 53 of file pvmgetdsig.c.

{
  int i;

  for(i=31;i>=0;i--) {
    printf("%d", (x>>i)&0x1);
    if(i%4==0) printf(" ");
  }
}

int pvmgetdsig (  ) 

Definition at line 216 of file pvmgetdsig.c.

{
    static int myfmt = -1;

    short i0;
    int i1;
    long i2;
    float f0;
    double f1;
    int i;
    int fmt;

    if (myfmt != -1)
        return myfmt;

    fmt = 0;

    i0 = 0;
    for (i = 0; i < sizeof(i0); i++)
        i0 += (short)i << (i * 8);
    fmt |= ibol(0, (char *) &i0, (int) sizeof(i0));

    i1 = 0;
    for (i = 0; i < sizeof(i1); i++)
        i1 += (int)i << (i * 8);
    fmt |= ibol(5, (char *) &i1, (int) sizeof(i1));

    i2 = 0;
    for (i = 0; i < sizeof(i2); i++)
        i2 += (long)i << (i * 8);
    fmt |= ibol(10, (char *) &i2, (int) sizeof(i2));

    f0 = 1.0;
    fmt |= fbol(15, (unsigned char *) &f0, (int) sizeof(f0));

    f1 = 1.0;
    fmt |= fbol(21, (unsigned char *) &f1, (int) sizeof(f1));

    myfmt = fmt;
    return fmt;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

unsigned char fs1[] = { 0x3f, 0x80, 0x00, 0x00 }

Definition at line 134 of file pvmgetdsig.c.

unsigned char fs2[] = { 0x3f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }

Definition at line 135 of file pvmgetdsig.c.

unsigned char fs4[] = { 0x40, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00 }

Definition at line 136 of file pvmgetdsig.c.

unsigned char fs5[] = { 0x40, 0x80, 0x00, 0x00 }

Definition at line 137 of file pvmgetdsig.c.

unsigned char fs6[] = { 0x40, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }

Definition at line 138 of file pvmgetdsig.c.

struct floatsig thesigs[]
Initial value:
 {
    { 0, 0, "UNKNOWN" },
    { 4, fs1, "IEEE_single" },
    { 8, fs2, "IEEE_double" },
    { 0, 0, "UNDEFINED" },
    { 8, fs4, "Cray" },
    { 4, fs5, "Convex_single" },
    { 8, fs6, "Convex_double" },
    { 0, 0, "UNDEFINED" },
    { 0, 0, "UNDEFINED" },
    { 0, 0, "UNDEFINED" },
    { 0, 0, "UNDEFINED" },
    { 0, 0, "UNDEFINED" },
    { 0, 0, "UNDEFINED" },
    { 0, 0, "UNDEFINED" },
    { 0, 0, "UNDEFINED" },
    { 0, 0, "UNDEFINED" },
}

Definition at line 140 of file pvmgetdsig.c.