LCOV - code coverage report
Current view: top level - progs - hwtest.cxx (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 60 0
Test Date: 2025-11-11 10:26:08 Functions: 0.0 % 1 0

            Line data    Source code
       1              : /********************************************************************\
       2              : 
       3              :   Name:         hwtest.c
       4              :   Created by:   Stefan Ritt
       5              : 
       6              :   Contents:     Program which tests the architecture of the HW/OS
       7              : 
       8              :   $Id:$
       9              : 
      10              : \********************************************************************/
      11              : 
      12              : #include <stdio.h>
      13              : #include <string.h>
      14              : 
      15              : struct {
      16              :    char c;
      17              :    double d;
      18              : } test_align;
      19              : 
      20              : #ifdef vxw
      21              : int hwtest()
      22              : #else
      23            0 : int main()
      24              : #endif
      25              : {
      26              :    unsigned long dummy;
      27              :    unsigned char *p;
      28              :    float f;
      29              :    double d;
      30              : 
      31            0 :    printf("Data sizes:\n");
      32            0 :    printf("sizeof(int)    = %d\n", (int)sizeof(int));
      33            0 :    printf("sizeof(float)  = %d\n", (int)sizeof(float));
      34            0 :    printf("sizeof(double) = %d\n", (int)sizeof(double));
      35            0 :    printf("sizeof(long int) = %d\n", (int)sizeof(long int));
      36            0 :    printf("sizeof(long double) = %d\n", (int)sizeof(long double));
      37            0 :    printf("sizeof(char *) = %d\n", (int)sizeof(p));
      38              :    if (sizeof(p) == 2)
      39              :       printf("...this looks like a 16-bit OS\n\n");
      40              :    else if (sizeof(p) == 4)
      41              :       printf("...this looks like a 32-bit OS\n\n");
      42              :    else if (sizeof(p) == 8)
      43            0 :       printf("...this looks like a 64-bit OS\n\n");
      44              : 
      45            0 :    printf("Byte order:\n");
      46            0 :    dummy = 0x12345678;
      47            0 :    p = (unsigned char *) &dummy;
      48            0 :    printf("0x12345678     = %02X %02X %02X %02X\n", p[0], p[1], p[2], p[3]);
      49            0 :    if (*((unsigned char *) &dummy) == 0x78)
      50            0 :       printf("...this looks like a LITTLE ENDIAN machine\n\n");
      51              :    else
      52            0 :       printf("...this looks like a BIG ENDIAN machine\n\n");
      53              : 
      54            0 :    printf("Floating point coding:\n");
      55            0 :    f = (float) 1.2345;
      56            0 :    p = (unsigned char *) &f;
      57            0 :    printf("1.2345f        = ");
      58            0 :    for (unsigned i = 0; i < sizeof(float); i++)
      59            0 :       printf("%02X ", p[i]);
      60            0 :    printf("\n");
      61            0 :    d = 1.2345;
      62            0 :    p = (unsigned char *) &d;
      63            0 :    printf("1.2345d        = ");
      64            0 :    for (unsigned i = 0; i < sizeof(double); i++)
      65            0 :       printf("%02X ", p[i]);
      66            0 :    printf("\n");
      67              : 
      68            0 :    dummy = 0;
      69            0 :    memcpy(&dummy, &f, sizeof(f));
      70            0 :    if ((dummy & 0xFF) == 0x19 &&
      71            0 :        ((dummy >> 8) & 0xFF) == 0x04 &&
      72            0 :        ((dummy >> 16) & 0xFF) == 0x9E && ((dummy >> 24) & 0xFF) == 0x3F)
      73            0 :       printf("...this looks like IEEE float format\n");
      74            0 :    else if ((dummy & 0xFF) == 0x9E &&
      75            0 :             ((dummy >> 8) & 0xFF) == 0x40 &&
      76            0 :             ((dummy >> 16) & 0xFF) == 0x19 && ((dummy >> 24) & 0xFF) == 0x04)
      77            0 :       printf("...this looks like VAX float format\n");
      78              : 
      79            0 :    dummy = 0;
      80            0 :    memcpy(&dummy, &d, sizeof(f));
      81            0 :    if ((dummy & 0xFF) == 0x8D &&
      82            0 :        ((dummy >> 8) & 0xFF) == 0x97 &&
      83            0 :        ((dummy >> 16) & 0xFF) == 0x6E && ((dummy >> 24) & 0xFF) == 0x12)
      84            0 :       printf("...this looks like IEEE double float format (little endian)\n\n");
      85            0 :    else if ((dummy & 0xFF) == 0x83 &&
      86            0 :             ((dummy >> 8) & 0xFF) == 0xC0 &&
      87            0 :             ((dummy >> 16) & 0xFF) == 0xF3 && ((dummy >> 24) & 0xFF) == 0x3F)
      88            0 :       printf("...this looks like IEEE double float format (big endian)\n\n");
      89            0 :    else if ((dummy & 0xFF) == 0x13 &&
      90            0 :             ((dummy >> 8) & 0xFF) == 0x40 &&
      91            0 :             ((dummy >> 16) & 0xFF) == 0x83 && ((dummy >> 24) & 0xFF) == 0xC0)
      92            0 :       printf("...this looks like VAX G double format\n\n");
      93            0 :    else if ((dummy & 0xFF) == 0x9E &&
      94            0 :             ((dummy >> 8) & 0xFF) == 0x40 &&
      95            0 :             ((dummy >> 16) & 0xFF) == 0x18 && ((dummy >> 24) & 0xFF) == 0x04)
      96            0 :       printf("...this looks like VAX D double format\n\n");
      97              : 
      98              : 
      99            0 :    int i = (char*) (&test_align.d) - (char*) &test_align.c;
     100            0 :    printf("Structure members are %d-byte aligned\n\n", i);
     101              : 
     102            0 :    return 1;
     103              : }
        

Generated by: LCOV version 2.0-1