Connect the msvcrt file byte locking up to ntdll.
This commit is contained in:
parent
f12f4d7d0c
commit
716ffc5bef
|
@ -32,6 +32,7 @@
|
|||
#include "msvcrt/direct.h"
|
||||
#include "msvcrt/fcntl.h"
|
||||
#include "msvcrt/io.h"
|
||||
#include "msvcrt/sys/locking.h"
|
||||
#include "msvcrt/stdio.h"
|
||||
#include "msvcrt/stdlib.h"
|
||||
#include "msvcrt/string.h"
|
||||
|
@ -507,6 +508,60 @@ LONG _lseek(int fd, LONG offset, int whence)
|
|||
return -1;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* _locking (MSVCRT.@)
|
||||
*
|
||||
* This is untested; the underlying LockFile doesn't work yet.
|
||||
*/
|
||||
int _locking(int fd, int mode, LONG nbytes)
|
||||
{
|
||||
BOOL ret;
|
||||
DWORD cur_locn;
|
||||
HANDLE hand = msvcrt_fdtoh(fd);
|
||||
|
||||
TRACE(":fd (%d) handle (%d)\n",fd,hand);
|
||||
if (hand == INVALID_HANDLE_VALUE)
|
||||
return -1;
|
||||
|
||||
if (mode < 0 || mode > 4)
|
||||
{
|
||||
SET_THREAD_VAR(errno,MSVCRT_EINVAL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
TRACE(":fd (%d) by 0x%08lx mode %s\n",
|
||||
fd,nbytes,(mode==_LK_UNLCK)?"_LK_UNLCK":
|
||||
(mode==_LK_LOCK)?"_LK_LOCK":
|
||||
(mode==_LK_NBLCK)?"_LK_NBLCK":
|
||||
(mode==_LK_RLCK)?"_LK_RLCK":
|
||||
(mode==_LK_NBRLCK)?"_LK_NBRLCK":
|
||||
"UNKNOWN");
|
||||
|
||||
if ((cur_locn = SetFilePointer(hand, 0L, NULL, SEEK_CUR)) == 0xffffffff)
|
||||
{
|
||||
FIXME ("Seek failed\n");
|
||||
SET_THREAD_VAR(errno,MSVCRT_EINVAL); /* FIXME */
|
||||
return -1;
|
||||
}
|
||||
if (mode == _LK_LOCK || mode == _LK_RLCK)
|
||||
{
|
||||
int nretry = 10;
|
||||
ret = 1; /* just to satisfy gcc */
|
||||
while (nretry--)
|
||||
{
|
||||
ret = LockFile(hand, cur_locn, 0L, nbytes, 0L);
|
||||
if (ret) break;
|
||||
sleep (1);
|
||||
}
|
||||
}
|
||||
else if (mode == _LK_UNLCK)
|
||||
ret = UnlockFile(hand, cur_locn, 0L, nbytes, 0L);
|
||||
else
|
||||
ret = LockFile(hand, cur_locn, 0L, nbytes, 0L);
|
||||
/* FIXME - what about error settings? */
|
||||
return ret ? 0 : -1;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* rewind (MSVCRT.@)
|
||||
*/
|
||||
|
|
|
@ -326,7 +326,7 @@ debug_channels (msvcrt)
|
|||
@ cdecl _loaddll(str) _loaddll
|
||||
@ cdecl _local_unwind2(ptr long) _local_unwind2
|
||||
@ cdecl _lock(long) _lock
|
||||
@ stub _locking #(long long long)
|
||||
@ cdecl _locking(long long long) _locking
|
||||
@ cdecl _logb( double ) _logb
|
||||
@ stub _longjmpex
|
||||
@ cdecl _lrotl(long long) _lrotl
|
||||
|
|
|
@ -78,6 +78,7 @@ INSTALLED_INCLUDES = \
|
|||
msvcrt/stdio.h \
|
||||
msvcrt/stdlib.h \
|
||||
msvcrt/string.h \
|
||||
msvcrt/sys/locking.h \
|
||||
msvcrt/sys/stat.h \
|
||||
msvcrt/sys/timeb.h \
|
||||
msvcrt/sys/types.h \
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* _locking constants
|
||||
*
|
||||
* Copyright 2002 Bill Medland
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef __WINE_SYS_LOCKING_H__
|
||||
#define __WINE_SYS_LOCKING_H__
|
||||
#define __WINE_USE_MSVCRT
|
||||
|
||||
#define _LK_UNLCK 0
|
||||
#define _LK_LOCK 1
|
||||
#define _LK_NBLCK 2
|
||||
#define _LK_RLCK 3
|
||||
#define _LK_NBRLCK 4
|
||||
|
||||
#endif /* __WINE_SYS_LOCKING_H__ : Do not place anything after this #endif */
|
Loading…
Reference in New Issue