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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [pr44328.C] - Blame information for rev 774

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

Line No. Rev Author Line
1 693 jeremybenn
/* { dg-do compile } */
2
/* { dg-options "-c -O2 -Wextra" } */
3
#define O_RDONLY     (1<<0)
4
#define O_WRONLY     (1<<1)
5
#define O_RDWR       (O_RDONLY|O_WRONLY)
6
#define O_CREAT      (1<<3)
7
#define O_TRUNC      (1<<6)
8
 
9
typedef enum {
10
    OM_READ = 0,
11
    OM_WRITE,
12
    OM_READWRITE_NOCREATE,
13
    OM_READWRITE_CREATE
14
} OpenMode;
15
 
16
extern int open(const char *name, int mode);
17
 
18
void open_file(const char *filename, const OpenMode rw)
19
{
20
    int mode = 0;
21
 
22
    switch( rw )
23
    {
24
    case OM_WRITE:
25
        mode = O_WRONLY|O_CREAT|O_TRUNC;
26
        break;
27
    case OM_READ:
28
        mode = O_RDONLY;
29
        break;
30
    case OM_READWRITE_NOCREATE:
31
        mode = O_RDWR;
32
        break;
33
    case OM_READWRITE_CREATE:
34
        mode = O_RDWR|O_CREAT|O_TRUNC;
35
        break;
36
    }
37
 
38
    open( filename, mode );
39
}

powered by: WebSVN 2.1.0

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