OSDN Git Service

* public snapshot of sid simulator
[pf3gnuchains/pf3gnuchains3x.git] / sid / component / gloss / hostops.h
1 // hostops.h - Wrapper class around host OS calls.  -*- C++ -*-
2
3 // Copyright (C) 1999, 2000 Red Hat.
4 // This file is part of SID and is licensed under the GPL.
5 // See the file COPYING.SID for conditions for redistribution.
6
7 #ifndef HOSTOPS_H
8 #define HOSTOPS_H
9
10 // ??? better place?
11 typedef sid::host_int_4 uint32;
12 typedef sid::signed_host_int_4 int32;
13 typedef sid::host_int_8 uint64;
14 typedef sid::signed_host_int_8 int64;
15
16 typedef uint32 address32;
17 typedef uint32 size32;
18 typedef int32 offset32;
19
20 typedef uint64 address64;
21 typedef uint64 size64;
22 typedef int64 offset64;
23
24 class hostops
25 {
26 public:
27
28   hostops () {}
29
30   // `flags' argument to open.
31   enum open_flags
32   {
33     open_read_only = 1,
34     open_write_only = 2,
35     open_read_write = 3,
36     // mask of previous 3 values
37     open_acc_mode = 3,
38     open_text = 4,
39     open_create = 8,
40     open_trunc = 16,
41     open_append = 32,
42     open_nonblock = 64
43   };
44
45   // `how' argument to lseek.
46   enum seek_type { seek_set = 0, seek_cur = 1, seek_end = 2 };
47
48   // Separate 32 bit and 64 bit support.
49   // We want correct semantics for 32/64 target on 32/64 host.
50   // ??? May also be useful for large file support on 32 bit hosts.
51   int open_flags_to_host (int flags);
52   bool open (const char* filename, int flags,
53              int& result_fd, int& errcode);
54   bool open (const char* filename, int flags, int mode,
55              int& result_fd, int& errcode);
56   bool close (int fd, int& errcode);
57   bool read32 (int fd, char* buf, size32 len,
58                size32& len_read, int& errcode);
59   bool write32 (int fd, const char* buf, size32 len,
60                 size32& len_written, int& errcode);
61   bool remove (const char* filename, int& errcode);
62   bool rename (const char* oldname, const char* newname, int& errcode);
63   bool lseek32 (int fd, offset32 offset, seek_type how,
64                 size32& result, int& errcode);
65   bool getsize32 (int fd, size32& size, int& errcode);
66   bool tmpnam (char* filename, int& errcode);
67 };
68
69 #endif // HOSTOPS_H