diff packages/io/fileio/current/src/misc.cxx @ 208:e0c0827131d1 ecos

Merge from eCos master repository on 2002-05-20-20:11:54-BST
author jlarmour
date Mon, 20 May 2002 22:19:26 +0000
parents 678094f34118
children d2c90368aeef
line wrap: on
line diff
--- a/packages/io/fileio/current/src/misc.cxx
+++ b/packages/io/fileio/current/src/misc.cxx
@@ -5,29 +5,38 @@
 //      Fileio miscellaneous functions
 //
 //==========================================================================
-//####COPYRIGHTBEGIN####
-//                                                                          
-// -------------------------------------------                              
-// The contents of this file are subject to the Red Hat eCos Public License 
-// Version 1.1 (the "License"); you may not use this file except in         
-// compliance with the License.  You may obtain a copy of the License at    
-// http://www.redhat.com/                                                   
-//                                                                          
-// Software distributed under the License is distributed on an "AS IS"      
-// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See the 
-// License for the specific language governing rights and limitations under 
-// the License.                                                             
-//                                                                          
-// The Original Code is eCos - Embedded Configurable Operating System,      
-// released September 30, 1998.                                             
-//                                                                          
-// The Initial Developer of the Original Code is Red Hat.                   
-// Portions created by Red Hat are                                          
-// Copyright (C) 1998, 1999, 2000 Red Hat, Inc.                             
-// All Rights Reserved.                                                     
-// -------------------------------------------                              
-//                                                                          
-//####COPYRIGHTEND####
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
 //==========================================================================
 //#####DESCRIPTIONBEGIN####
 //
@@ -45,14 +54,12 @@
 
 #include <pkgconf/system.h>
 #include <pkgconf/hal.h>
-#include <pkgconf/kernel.h>
 #include <pkgconf/io_fileio.h>
 #ifdef CYGPKG_LIBC_TIME
 #include <pkgconf/libc_time.h>
 #endif
 
 
-#include <cyg/kernel/ktypes.h>         // base kernel types
 #include <cyg/infra/cyg_trac.h>        // tracing macros
 #include <cyg/infra/cyg_ass.h>         // assertion macros
 #include <string.h>                    // strcmp()
@@ -62,7 +69,11 @@
 # include <cyg/io/wallclock.hxx>       // Wallclock class
 #endif
 
+#ifdef CYGPKG_KERNEL
+#include <pkgconf/kernel.h>
+#include <cyg/kernel/ktypes.h>         // base kernel types
 #include <cyg/kernel/clock.inl>         // Clock inlines
+#endif
 
 #include "fio.h"                       // Private header
 
@@ -88,8 +99,10 @@ CYG_HAL_TABLE_BEGIN( fstab, fstab );
 __externC cyg_fstab_entry fstab_end;
 CYG_HAL_TABLE_END( fstab_end, fstab );
 
+#ifdef CYGPKG_KERNEL
 // Array of mutexes for locking the fstab entries
-Cyg_Mutex fstab_lock[CYGNUM_FILEIO_FSTAB_MAX];
+Cyg_Mutex fstab_lock[CYGNUM_FILEIO_FSTAB_MAX] CYGBLD_ATTRIB_INIT_PRI(CYG_INIT_IO_FS);
+#endif
 
 // -------------------------------------------------------------------------
 // Mount table.
@@ -105,8 +118,10 @@ cyg_mtab_entry mtab_extra[CYGNUM_FILEIO_
 __externC cyg_mtab_entry mtab_end;
 CYG_HAL_TABLE_END( mtab_end, mtab );
 
+#ifdef CYGPKG_KERNEL
 // Array of mutexes for locking the mtab entries
-Cyg_Mutex mtab_lock[CYGNUM_FILEIO_MTAB_MAX];
+Cyg_Mutex mtab_lock[CYGNUM_FILEIO_MTAB_MAX] CYGBLD_ATTRIB_INIT_PRI(CYG_INIT_IO_FS);
+#endif
 
 //==========================================================================
 // Current directory
@@ -123,7 +138,7 @@ public:
     Cyg_Fileio_Init_Class();
 };
 
-static Cyg_Fileio_Init_Class fileio_initializer CYGBLD_ATTRIB_INIT_PRI(CYG_INIT_IO);
+static Cyg_Fileio_Init_Class fileio_initializer CYGBLD_ATTRIB_INIT_PRI(CYG_INIT_IO_FS);
 
 Cyg_Fileio_Init_Class::Cyg_Fileio_Init_Class()
 {
@@ -366,12 +381,12 @@ void cyg_fs_lock( cyg_mtab_entry *mte, c
 
     if( syncmode & CYG_SYNCMODE_FILE_FILESYSTEM ) {
         CYG_ASSERT(mte->fs-&fstab[0] < CYGNUM_FILEIO_FSTAB_MAX, "Bad file system");
-        fstab_lock[mte->fs-&fstab[0]].lock();
+        FILEIO_MUTEX_LOCK( fstab_lock[mte->fs-&fstab[0]] );
     }
 
     if( syncmode & CYG_SYNCMODE_FILE_MOUNTPOINT ) {
         CYG_ASSERT(mte-&mtab[0] < CYGNUM_FILEIO_MTAB_MAX, "Bad mount point");
-        mtab_lock[mte-&mtab[0]].lock();
+        FILEIO_MUTEX_LOCK( mtab_lock[mte-&mtab[0]] );
     }
 }
 
@@ -381,12 +396,12 @@ void cyg_fs_unlock( cyg_mtab_entry *mte,
 
     if( syncmode & CYG_SYNCMODE_FILE_FILESYSTEM ) {
         CYG_ASSERT(mte->fs-&fstab[0] < CYGNUM_FILEIO_FSTAB_MAX, "Bad file system");
-        fstab_lock[mte->fs-&fstab[0]].unlock();
+        FILEIO_MUTEX_UNLOCK( fstab_lock[mte->fs-&fstab[0]] );
     }
 
     if( syncmode & CYG_SYNCMODE_FILE_MOUNTPOINT ) {
         CYG_ASSERT(mte-&mtab[0] < CYGNUM_FILEIO_MTAB_MAX, "Bad mount point");
-        mtab_lock[mte-&mtab[0]].unlock();
+        FILEIO_MUTEX_UNLOCK( mtab_lock[mte-&mtab[0]] );
     }
 }
 
@@ -415,7 +430,7 @@ void cyg_fs_unlock( cyg_mtab_entry *mte,
 
     return (time_t) tp.tv_sec;
     
-#else    
+#elif defined(CYGPKG_KERNEL) 
 
     // If all else fails, get the current realtime clock value and
     // convert it to seconds ourself.
@@ -433,7 +448,9 @@ void cyg_fs_unlock( cyg_mtab_entry *mte,
     ticks = Cyg_Clock::real_time_clock->current_value();
     
     return (time_t) Cyg_Clock::convert( ticks, &sec_converter );
-        
+#else    
+    /* No clock support at all. */
+    return (time_t) 0;
 #endif    
     
 }