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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [libgloss/] [m68k/] [io-gdb.c] - Blame information for rev 822

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

Line No. Rev Author Line
1 148 jeremybenn
/*
2
 * hosted io support for GDB's remote fileio protocol
3
 *
4
 * Copyright (c) 2006 CodeSourcery Inc
5
 *
6
 * The authors hereby grant permission to use, copy, modify, distribute,
7
 * and license this software and its documentation for any purpose, provided
8
 * that existing copyright notices are retained in all copies and that this
9
 * notice is included verbatim in any distributions. No written agreement,
10
 * license, or royalty fee is required for any of the authorized uses.
11
 * Modifications to this software may be copyrighted by their authors
12
 * and need not follow the licensing terms described here, provided that
13
 * the new terms are clearly indicated on the first page of each file where
14
 * they apply.
15
 */
16
 
17
#include "io.h"
18
#include <fcntl.h>
19
#include <unistd.h>
20
#include <errno.h>
21
 
22
gdb_mode_t
23
__hosted_to_gdb_mode_t (mode_t m)
24
{
25
  gdb_mode_t result = 0;
26
  if (m & S_IFREG)
27
    result |= GDB_S_IFREG;
28
  if (m & S_IFDIR)
29
    result |= GDB_S_IFDIR;
30
  if (m & S_IRUSR)
31
    result |= GDB_S_IRUSR;
32
  if (m & S_IWUSR)
33
    result |= GDB_S_IWUSR;
34
  if (m & S_IXUSR)
35
    result |= GDB_S_IXUSR;
36
  if (m & S_IRGRP)
37
    result |= GDB_S_IRGRP;
38
  if (m & S_IWGRP)
39
    result |= GDB_S_IWGRP;
40
  if (m & S_IXGRP)
41
    result |= GDB_S_IXGRP;
42
  if (m & S_IROTH)
43
    result |= GDB_S_IROTH;
44
  if (m & S_IWOTH)
45
    result |= GDB_S_IWOTH;
46
  if (m & S_IXOTH)
47
    result |= GDB_S_IXOTH;
48
  return result;
49
}
50
 
51
int32_t
52
__hosted_to_gdb_open_flags (int f)
53
{
54
  int32_t result = 0;
55
  if (f & O_RDONLY)
56
    result |= GDB_O_RDONLY;
57
  if (f & O_WRONLY)
58
    result |= GDB_O_WRONLY;
59
  if (f & O_RDWR)
60
    result |= GDB_O_RDWR;
61
  if (f & O_APPEND)
62
    result |= GDB_O_APPEND;
63
  if (f & O_CREAT)
64
    result |= GDB_O_CREAT;
65
  if (f & O_TRUNC)
66
    result |= GDB_O_TRUNC;
67
  if (f & O_EXCL)
68
    result |= GDB_O_EXCL;
69
  return result;
70
}
71
 
72
int32_t
73
__hosted_to_gdb_lseek_flags (int f)
74
{
75
  if (f == SEEK_CUR)
76
    return GDB_SEEK_CUR;
77
  else if (f == SEEK_END)
78
    return GDB_SEEK_END;
79
  else
80
    return GDB_SEEK_SET;
81
}
82
 
83
void
84
__hosted_from_gdb_stat (const struct gdb_stat *gs,
85
                        struct stat *s)
86
{
87
  s->st_dev = gs->st_dev;
88
  s->st_ino = gs->st_ino;
89
  s->st_mode = gs->st_mode;
90
  s->st_nlink = gs->st_nlink;
91
  s->st_uid = gs->st_uid;
92
  s->st_gid = gs->st_gid;
93
  s->st_rdev = gs->st_rdev;
94
  s->st_size = gs->st_size;
95
  s->st_blksize = gs->st_blksize;
96
  s->st_blocks = gs->st_blocks;
97
  s->st_atime = gs->st_atime;
98
  s->st_mtime = gs->st_mtime;
99
  s->st_ctime = gs->st_ctime;
100
}
101
 
102
void
103
__hosted_from_gdb_timeval (const struct gdb_timeval *gt,
104
                           struct timeval *t)
105
{
106
  t->tv_sec = gt->tv_sec;
107
  t->tv_usec = gt->tv_usec;
108
}
109
 
110
int
111
__hosted_from_gdb_errno (int32_t err)
112
{
113
  switch (err)
114
    {
115
    case 0:              return 0;
116
    case GDB_EPERM:     return EPERM;
117
    case GDB_ENOENT:    return ENOENT;
118
    case GDB_EINTR:     return EINTR;
119
    case GDB_EBADF:     return EBADF;
120
    case GDB_EACCES:    return EACCES;
121
    case GDB_EFAULT:    return EFAULT;
122
    case GDB_EBUSY:     return EBUSY;
123
    case GDB_EEXIST:    return EEXIST;
124
    case GDB_ENODEV:    return ENODEV;
125
    case GDB_ENOTDIR:   return ENOTDIR;
126
    case GDB_EISDIR:    return EISDIR;
127
    case GDB_EINVAL:    return EINVAL;
128
    case GDB_ENFILE:    return ENFILE;
129
    case GDB_EMFILE:    return EMFILE;
130
    case GDB_EFBIG:     return EFBIG;
131
    case GDB_ENOSPC:    return ENOSPC;
132
    case GDB_ESPIPE:    return ESPIPE;
133
    case GDB_EROFS:     return EROFS;
134
    case GDB_ENAMETOOLONG:      return ENAMETOOLONG;
135
    case GDB_EUNKNOWN:
136
    default:
137
      return EIO;
138
    }
139
}
140
 

powered by: WebSVN 2.1.0

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