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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [io/] [fileio/] [current/] [src/] [fio.h] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
#ifndef CYGONCE_FIO_H
2
#define CYGONCE_FIO_H
3
//=============================================================================
4
//
5
//      fio.h
6
//
7
//      Fileio private header
8
//
9
//=============================================================================
10
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
11
// -------------------------------------------                              
12
// This file is part of eCos, the Embedded Configurable Operating System.   
13
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
14
//
15
// eCos is free software; you can redistribute it and/or modify it under    
16
// the terms of the GNU General Public License as published by the Free     
17
// Software Foundation; either version 2 or (at your option) any later      
18
// version.                                                                 
19
//
20
// eCos is distributed in the hope that it will be useful, but WITHOUT      
21
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
22
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
23
// for more details.                                                        
24
//
25
// You should have received a copy of the GNU General Public License        
26
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
27
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
28
//
29
// As a special exception, if other files instantiate templates or use      
30
// macros or inline functions from this file, or you compile this file      
31
// and link it with other works to produce a work based on this file,       
32
// this file does not by itself cause the resulting work to be covered by   
33
// the GNU General Public License. However the source code for this file    
34
// must still be made available in accordance with section (3) of the GNU   
35
// General Public License v2.                                               
36
//
37
// This exception does not invalidate any other reasons why a work based    
38
// on this file might be covered by the GNU General Public License.         
39
// -------------------------------------------                              
40
// ####ECOSGPLCOPYRIGHTEND####                                              
41
//=============================================================================
42
//#####DESCRIPTIONBEGIN####
43
//
44
// Author(s):     nickg
45
// Contributors:  nickg
46
// Date:          2000-05-25
47
// Purpose:       Fileio private header
48
// Description:   This file contains private definitions for communication
49
//                between the parts of the fileio package.
50
//              
51
// Usage:
52
//              #include "fio.h"
53
//              ...
54
//              
55
//
56
//####DESCRIPTIONEND####
57
//
58
//=============================================================================
59
 
60
#include <pkgconf/hal.h>
61
#include <pkgconf/io_fileio.h>
62
#include <pkgconf/isoinfra.h>
63
 
64
#include <cyg/infra/cyg_type.h>
65
 
66
#include <stddef.h>             // NULL, size_t
67
#include <unistd.h>
68
#include <limits.h>
69
#include <sys/types.h>
70
 
71
#include <cyg/fileio/fileio.h>
72
#include <cyg/fileio/sockio.h>
73
 
74
#include <errno.h>
75
 
76
#ifdef CYGPKG_KERNEL
77
#include <pkgconf/kernel.h>
78
#include <cyg/kernel/mutex.hxx>        // mutex definitions
79
 
80
#define FILEIO_MUTEX_LOCK(_m_)   ((_m_).lock())
81
#define FILEIO_MUTEX_UNLOCK(_m_) ((_m_).unlock())
82
 
83
#else
84
#define FILEIO_MUTEX_LOCK(_m_) 
85
#define FILEIO_MUTEX_UNLOCK(_m_)
86
#endif
87
 
88
 
89
//=============================================================================
90
// POSIX API support
91
 
92
#ifdef CYGPKG_POSIX
93
#include <pkgconf/posix.h>
94
#include <cyg/posix/export.h>
95
 
96
#define CYG_FILEIO_FUNCTION_START() CYG_POSIX_FUNCTION_START()
97
 
98
#define CYG_FILEIO_FUNCTION_FINISH() CYG_POSIX_FUNCTION_FINISH()
99
 
100
#else
101
 
102
#define CYG_FILEIO_FUNCTION_START() CYG_EMPTY_STATEMENT
103
 
104
#define CYG_FILEIO_FUNCTION_FINISH() CYG_EMPTY_STATEMENT
105
 
106
#endif
107
 
108
#ifdef CYGPKG_POSIX_SIGNALS
109
 
110
#define CYG_FILEIO_SIGMASK_SET( __set, __oset ) \
111
        CYG_PTHREAD_SIGMASK_SET( __set, __oset )
112
 
113
#define CYG_FILEIO_SIGPENDING() CYG_POSIX_SIGPENDING()
114
 
115
#define CYG_FILEIO_DELIVER_SIGNALS( __mask ) \
116
        CYG_POSIX_DELIVER_SIGNALS( __mask )
117
 
118
#else
119
 
120
#define CYG_FILEIO_SIGMASK_SET( __set, __oset ) \
121
CYG_MACRO_START \
122
CYG_UNUSED_PARAM( const sigset_t*, __set ); \
123
CYG_UNUSED_PARAM( const sigset_t*, __oset ); \
124
CYG_MACRO_END
125
 
126
#define CYG_FILEIO_SIGPENDING() (0)
127
 
128
#define CYG_FILEIO_DELIVER_SIGNALS( __mask ) CYG_UNUSED_PARAM( const sigset_t*, __mask )
129
 
130
typedef int sigset_t;
131
 
132
#endif
133
 
134
//=============================================================================
135
// Fileio function entry and return macros.
136
 
137
// Handle entry to a fileio package function. 
138
#define FILEIO_ENTRY()                          \
139
    CYG_REPORT_FUNCTYPE( "returning %d" );      \
140
    CYG_FILEIO_FUNCTION_START();                \
141
 
142
#define FILEIO_ENTRY_VOID()                     \
143
    CYG_REPORT_FUNCTION();                      \
144
    CYG_FILEIO_FUNCTION_START();                \
145
 
146
 
147
// Do a fileio package defined return. This requires the error code
148
// to be placed in errno, and if it is non-zero, -1 returned as the
149
// result of the function. This also gives us a place to put any
150
// generic tidyup handling needed for things like signal delivery and
151
// cancellation.
152
#define FILEIO_RETURN(err)                      \
153
CYG_MACRO_START                                 \
154
    int __retval = 0;                           \
155
    CYG_FILEIO_FUNCTION_FINISH();               \
156
    if( err != 0 ) __retval = -1, errno = err;  \
157
    CYG_REPORT_RETVAL( __retval );              \
158
    return __retval;                            \
159
CYG_MACRO_END
160
 
161
#define FILEIO_RETURN_VALUE(val)                \
162
CYG_MACRO_START                                 \
163
    CYG_FILEIO_FUNCTION_FINISH();               \
164
    CYG_REPORT_RETVAL( val );                   \
165
    return val;                                 \
166
CYG_MACRO_END
167
 
168
#define FILEIO_RETURN_VOID()                    \
169
CYG_MACRO_START                                 \
170
    CYG_FILEIO_FUNCTION_FINISH();               \
171
    CYG_REPORT_RETURN();                        \
172
    return;                                     \
173
CYG_MACRO_END
174
 
175
//=============================================================================
176
// Cancellation support
177
// If the POSIX package is present we want to include cancellation points
178
// in the routines that are defined to contain them.
179
// The macro CYG_CANCELLATION_POINT does this.
180
 
181
#ifdef CYGINT_ISO_PTHREAD_IMPL
182
 
183
# include <pthread.h>
184
 
185
# define CYG_CANCELLATION_POINT pthread_testcancel()
186
 
187
#else
188
 
189
# define CYG_CANCELLATION_POINT CYG_EMPTY_STATEMENT
190
 
191
#endif
192
 
193
//=============================================================================
194
// Internal exports
195
 
196
//-----------------------------------------------------------------------------
197
// Exports from misc.cxx
198
 
199
// Current directory info
200
__externC cyg_mtab_entry *cyg_cdir_mtab_entry;
201
__externC cyg_dir cyg_cdir_dir;
202
 
203
__externC int cyg_mtab_lookup( cyg_dir *dir, const char **name, cyg_mtab_entry **mte);
204
 
205
//-----------------------------------------------------------------------------
206
// Exports from fd.cxx
207
 
208
__externC void cyg_fd_init();
209
 
210
__externC cyg_file *cyg_file_alloc();
211
 
212
__externC void cyg_file_free(cyg_file * fp);
213
 
214
__externC int cyg_fd_alloc(int low);
215
 
216
__externC void cyg_fd_assign(int fd, cyg_file *fp);
217
 
218
__externC int cyg_fd_free(int fd);
219
 
220
__externC cyg_file *cyg_fp_get( int fd );
221
 
222
__externC void cyg_fp_free( cyg_file *fp );
223
 
224
__externC void cyg_file_lock( cyg_file *fp, cyg_uint32 syncmode );
225
 
226
__externC void cyg_file_unlock( cyg_file *fp, cyg_uint32 syncmode );
227
 
228
//-----------------------------------------------------------------------------
229
// Exports from socket.cxx
230
 
231
__externC void cyg_nstab_init();
232
 
233
//-----------------------------------------------------------------------------
234
#endif // ifndef CYGONCE_FIO_H
235
// End of fio.h

powered by: WebSVN 2.1.0

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