dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] pnet/support file.c,1.14,1.15


From: Stephen Compall <address@hidden>
Subject: [Dotgnu-pnet-commits] pnet/support file.c,1.14,1.15
Date: Mon, 10 Nov 2003 13:25:06 +0000

Update of /cvsroot/dotgnu-pnet/pnet/support
In directory subversions:/tmp/cvs-serv22599/support

Modified Files:
        file.c 
Log Message:
File locking support, for GNU et al at least.


Index: file.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/support/file.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** file.c      19 Aug 2003 05:09:14 -0000      1.14
--- file.c      10 Nov 2003 13:25:04 -0000      1.15
***************
*** 408,419 ****
  int ILSysIOLock(ILSysIOHandle handle, ILInt64 position, ILInt64 length)
  {
!       /* Locking is not yet supported - TODO */
        return 1;
  }
  
  int ILSysIOUnlock(ILSysIOHandle handle, ILInt64 position, ILInt64 length)
  {
!       /* Locking is not yet supported - TODO */
        return 1;
  }
  
--- 408,449 ----
  int ILSysIOLock(ILSysIOHandle handle, ILInt64 position, ILInt64 length)
  {
! #if defined(HAVE_FCNTL) && defined(HAVE_F_SETLKW)
!       struct flock cntl_data;
!       /* set fields individually...who knows what extras are there? */
!       cntl_data.l_type = F_WRLCK;
!       cntl_data.l_whence = SEEK_SET;
!       /* actually, off_t changes in LFS on 32bit, so be careful */
!       cntl_data.l_start = (off_t)(ILNativeInt) position;
!       cntl_data.l_len = (off_t)(ILNativeInt) length;
!       /* -1 is error, anything else is OK */
!       if (fcntl ((int)(ILNativeInt) handle, F_SETLKW, &cntl_data) != -1)
!               return 1;
!       else
!               return 0;
! #else /* !defined(HAVE_FCNTL) || !defined(HAVE_F_SETLKW) */
!       /* Locking is not supported w/o fcntl - TODO */
        return 1;
+ #endif /* !defined(HAVE_FCNTL) || !defined(HAVE_F_SETLKW) */
  }
  
  int ILSysIOUnlock(ILSysIOHandle handle, ILInt64 position, ILInt64 length)
  {
! #if defined(HAVE_FCNTL) && defined(HAVE_F_SETLKW)
!       struct flock cntl_data;
!       /* set fields individually...who knows what extras are there? */
!       cntl_data.l_type = F_UNLCK;
!       cntl_data.l_whence = SEEK_SET;
!       /* actually, off_t changes in LFS on 32bit, so be careful */
!       cntl_data.l_start = (off_t)(ILNativeInt) position;
!       cntl_data.l_len = (off_t)(ILNativeInt) length;
!       /* -1 is error, anything else is OK */
!       if (fcntl ((int)(ILNativeInt) handle, F_SETLKW, &cntl_data) != -1)
!               return 1;
!       else
!               return 0;
! #else /* !defined(HAVE_FCNTL) || !defined(HAVE_F_SETLKW) */
!       /* Unlocking is not supported w/o fcntl - TODO */
        return 1;
+ #endif /* !defined(HAVE_FCNTL) || !defined(HAVE_F_SETLKW) */
  }
  





reply via email to

[Prev in Thread] Current Thread [Next in Thread]