3 //=============================================================================
7 // Fileio private header
9 //=============================================================================
10 //####ECOSGPLCOPYRIGHTBEGIN####
11 // -------------------------------------------
12 // This file is part of eCos, the Embedded Configurable Operating System.
13 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
14 // Copyright (C) 2002 Nick Garnett
16 // eCos is free software; you can redistribute it and/or modify it under
17 // the terms of the GNU General Public License as published by the Free
18 // Software Foundation; either version 2 or (at your option) any later version.
20 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
21 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
22 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
25 // You should have received a copy of the GNU General Public License along
26 // with eCos; if not, write to the Free Software Foundation, Inc.,
27 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
29 // As a special exception, if other files instantiate templates or use macros
30 // or inline functions from this file, or you compile this file and link it
31 // with other works to produce a work based on this file, this file does not
32 // by itself cause the resulting work to be covered by the GNU General Public
33 // License. However the source code for this file must still be made available
34 // in accordance with section (3) of the GNU General Public License.
36 // This exception does not invalidate any other reasons why a work based on
37 // this file might be covered by the GNU General Public License.
39 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
40 // at http://sources.redhat.com/ecos/ecos-license/
41 // -------------------------------------------
42 //####ECOSGPLCOPYRIGHTEND####
43 //=============================================================================
44 //#####DESCRIPTIONBEGIN####
47 // Contributors: nickg
49 // Purpose: Fileio private header
50 // Description: This file contains private definitions for communication
51 // between the parts of the fileio package.
58 //####DESCRIPTIONEND####
60 //=============================================================================
62 #include <pkgconf/hal.h>
63 #include <pkgconf/io_fileio.h>
64 #include <pkgconf/isoinfra.h>
66 #include <cyg/infra/cyg_type.h>
68 #include <stddef.h> // NULL, size_t
71 #include <sys/types.h>
73 #include <cyg/fileio/fileio.h>
74 #include <cyg/fileio/sockio.h>
79 #include <pkgconf/kernel.h>
80 #include <cyg/kernel/mutex.hxx> // mutex definitions
82 #define FILEIO_MUTEX_LOCK(_m_) ((_m_).lock())
83 #define FILEIO_MUTEX_UNLOCK(_m_) ((_m_).unlock())
86 #define FILEIO_MUTEX_LOCK(_m_)
87 #define FILEIO_MUTEX_UNLOCK(_m_)
91 //=============================================================================
95 #include <pkgconf/posix.h>
96 #include <cyg/posix/export.h>
98 #define CYG_FILEIO_FUNCTION_START() CYG_POSIX_FUNCTION_START()
100 #define CYG_FILEIO_FUNCTION_FINISH() CYG_POSIX_FUNCTION_FINISH()
104 #define CYG_FILEIO_FUNCTION_START() CYG_EMPTY_STATEMENT
106 #define CYG_FILEIO_FUNCTION_FINISH() CYG_EMPTY_STATEMENT
110 #ifdef CYGPKG_POSIX_SIGNALS
112 #define CYG_FILEIO_SIGMASK_SET( __set, __oset ) \
113 CYG_PTHREAD_SIGMASK_SET( __set, __oset )
115 #define CYG_FILEIO_SIGPENDING() CYG_POSIX_SIGPENDING()
117 #define CYG_FILEIO_DELIVER_SIGNALS( __mask ) \
118 CYG_POSIX_DELIVER_SIGNALS( __mask )
122 #define CYG_FILEIO_SIGMASK_SET( __set, __oset ) \
124 CYG_UNUSED_PARAM( const sigset_t*, __set ); \
125 CYG_UNUSED_PARAM( const sigset_t*, __oset ); \
128 #define CYG_FILEIO_SIGPENDING() (0)
130 #define CYG_FILEIO_DELIVER_SIGNALS( __mask ) CYG_UNUSED_PARAM( const sigset_t*, __mask )
132 typedef int sigset_t;
136 //=============================================================================
137 // Fileio function entry and return macros.
139 // Handle entry to a fileio package function.
140 #define FILEIO_ENTRY() \
141 CYG_REPORT_FUNCTYPE( "returning %d" ); \
142 CYG_FILEIO_FUNCTION_START(); \
144 // Do a fileio package defined return. This requires the error code
145 // to be placed in errno, and if it is non-zero, -1 returned as the
146 // result of the function. This also gives us a place to put any
147 // generic tidyup handling needed for things like signal delivery and
149 #define FILEIO_RETURN(err) \
152 CYG_FILEIO_FUNCTION_FINISH(); \
153 if( err != 0 ) __retval = -1, errno = err; \
154 CYG_REPORT_RETVAL( __retval ); \
158 #define FILEIO_RETURN_VALUE(val) \
160 CYG_FILEIO_FUNCTION_FINISH(); \
161 CYG_REPORT_RETVAL( val ); \
165 #define FILEIO_RETURN_VOID() \
167 CYG_FILEIO_FUNCTION_FINISH(); \
168 CYG_REPORT_RETURN(); \
172 //=============================================================================
173 // Cancellation support
174 // If the POSIX package is present we want to include cancellation points
175 // in the routines that are defined to contain them.
176 // The macro CYG_CANCELLATION_POINT does this.
178 #ifdef CYGINT_ISO_PTHREAD_IMPL
180 # include <pthread.h>
182 # define CYG_CANCELLATION_POINT pthread_testcancel()
186 # define CYG_CANCELLATION_POINT CYG_EMPTY_STATEMENT
190 //=============================================================================
193 //-----------------------------------------------------------------------------
194 // Exports from misc.cxx
196 // Current directory info
197 __externC cyg_mtab_entry *cyg_cdir_mtab_entry;
198 __externC cyg_dir cyg_cdir_dir;
200 __externC int cyg_mtab_lookup( cyg_dir *dir, const char **name, cyg_mtab_entry **mte);
202 //-----------------------------------------------------------------------------
203 // Exports from fd.cxx
205 __externC void cyg_fd_init();
207 __externC cyg_file *cyg_file_alloc();
209 __externC void cyg_file_free(cyg_file * fp);
211 __externC int cyg_fd_alloc(int low);
213 __externC void cyg_fd_assign(int fd, cyg_file *fp);
215 __externC int cyg_fd_free(int fd);
217 __externC cyg_file *cyg_fp_get( int fd );
219 __externC void cyg_fp_free( cyg_file *fp );
221 __externC void cyg_file_lock( cyg_file *fp, cyg_uint32 syncmode );
223 __externC void cyg_file_unlock( cyg_file *fp, cyg_uint32 syncmode );
225 //-----------------------------------------------------------------------------
226 // Exports from socket.cxx
228 __externC void cyg_nstab_init();
230 //-----------------------------------------------------------------------------
231 #endif // ifndef CYGONCE_FIO_H