OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [torture/] [pr44806.c] - Blame information for rev 801

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 689 jeremybenn
/* { dg-do run } */
2
/* { dg-options "-std=c99" } */
3
 
4
#include <stdint.h>
5
 
6
extern void abort (void);
7
 
8
#define N_DEV_BITS_4 5
9
#define N_INO_BITS_4 (32 - N_DEV_BITS_4 - 2 - 1)
10
 
11
#define N_DEV_BITS_8 8
12
#define N_INO_BITS_8 (64 - N_DEV_BITS_8 - 2 - 1)
13
 
14
struct dev_ino_4
15
{
16
  uint32_t mode:2;
17
  uint32_t short_ino:N_INO_BITS_4;
18
  uint32_t mapped_dev:N_DEV_BITS_4;
19
  uint32_t always_set:1;
20
};
21
 
22
struct dev_ino_8
23
{
24
  uint32_t mode:2;
25
  uint64_t short_ino:N_INO_BITS_8;
26
  uint32_t mapped_dev:N_DEV_BITS_8;
27
  uint32_t always_set:1;
28
};
29
 
30
struct dev_ino_full
31
{
32
  uint32_t mode:2;
33
  uint32_t dev;
34
  uint32_t ino;
35
};
36
 
37
enum di_mode
38
{
39
  DI_MODE_4 = 1,
40
  DI_MODE_8 = 2,
41
  DI_MODE_FULL = 3
42
};
43
 
44
struct di_ent
45
{
46
  union
47
  {
48
    struct dev_ino_4 di4;
49
    struct dev_ino_8 di8;
50
    struct dev_ino_full full;
51
    uint32_t u32;
52
    uint64_t u64;
53
    void *ptr;
54
  } u;
55
};
56
 
57
static struct di_ent
58
decode_ptr (struct di_ent const *v)
59
{
60
  struct di_ent di;
61
  di.u.ptr = (void *) v;
62
  return di;
63
}
64
 
65
static int
66
di_ent_equal (void const *x, void const *y)
67
{
68
  struct di_ent a = decode_ptr (x);
69
  struct di_ent b = decode_ptr (y);
70
  if (a.u.di4.mode != b.u.di4.mode)
71
    return 0;
72
 
73
  if (a.u.di4.mode == DI_MODE_4)
74
    return (a.u.di4.short_ino == b.u.di4.short_ino
75
            && a.u.di4.mapped_dev == b.u.di4.mapped_dev);
76
 
77
  if (a.u.di8.mode == DI_MODE_8)
78
    return (a.u.di8.short_ino == b.u.di8.short_ino
79
            && a.u.di8.mapped_dev == b.u.di8.mapped_dev);
80
 
81
  return (a.u.full.ino == b.u.full.ino
82
          && a.u.full.dev == b.u.full.dev);
83
}
84
 
85
int
86
main ()
87
{
88
  if (di_ent_equal ((void *) 0x80143c4d, (void *) 0x80173851) != 0)
89
    abort ();
90
  return 0;
91
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.