Last change
on this file since 514 was
444,
checked in by satin@…, 7 years ago
|
add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc
|
File size:
1.5 KB
|
Rev | Line | |
---|
[444] | 1 | /* |
---|
| 2 | * io-open.c -- |
---|
| 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 <sys/types.h> |
---|
| 18 | #include <sys/stat.h> |
---|
| 19 | #include <fcntl.h> |
---|
| 20 | #include <stdarg.h> |
---|
| 21 | #include <string.h> |
---|
| 22 | #include <errno.h> |
---|
| 23 | #define IO open |
---|
| 24 | #include "io.h" |
---|
| 25 | |
---|
| 26 | /* |
---|
| 27 | * open -- Open a file. |
---|
| 28 | * input parameters: |
---|
| 29 | * 0 : fname ptr |
---|
| 30 | * 1 : fname length |
---|
| 31 | * 2 : flags |
---|
| 32 | * 3 : mode |
---|
| 33 | * output parameters: |
---|
| 34 | * 0 : result |
---|
| 35 | * 1 : errno |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | int open (const char *fname, int flags, ...) |
---|
| 39 | { |
---|
| 40 | #if HOSTED |
---|
| 41 | gdb_parambuf_t parameters; |
---|
| 42 | parameters[0] = (uint32_t) fname; |
---|
| 43 | parameters[1] = strlen (fname) + 1; |
---|
| 44 | parameters[2] = __hosted_to_gdb_open_flags (flags); |
---|
| 45 | if (flags & O_CREAT) |
---|
| 46 | { |
---|
| 47 | va_list ap; |
---|
| 48 | va_start (ap, flags); |
---|
| 49 | parameters[3] = __hosted_to_gdb_mode_t (va_arg (ap, mode_t)); |
---|
| 50 | va_end (ap); |
---|
| 51 | } |
---|
| 52 | else |
---|
| 53 | parameters[3] = 0; |
---|
| 54 | __hosted (HOSTED_OPEN, parameters); |
---|
| 55 | errno = __hosted_from_gdb_errno (parameters[1]); |
---|
| 56 | return parameters[0]; |
---|
| 57 | #else |
---|
| 58 | errno = ENOSYS; |
---|
| 59 | return -1; |
---|
| 60 | #endif |
---|
| 61 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.