Moved a bunch of routines to kernel32.dll (with the help of

Dimitrie O. Paun).
This commit is contained in:
Alexandre Julliard 2000-09-29 20:48:04 +00:00
parent ea8795b99c
commit afb49ead82
19 changed files with 865 additions and 874 deletions

View File

@ -7,10 +7,13 @@ SOVERSION = 1.0
ALTNAMES = comm kernel stress system toolhelp windebug win87em wprocs
C_SRCS = \
debugger.c \
format_msg.c \
kernel_main.c \
stress.c \
sync.c \
thunk.c \
time.c \
toolhelp.c \
utthunk.c \
win87em.c \

598
dlls/kernel/sync.c Normal file
View File

@ -0,0 +1,598 @@
/*
* Kernel synchronization objects
*
* Copyright 1998 Alexandre Julliard
*/
#include <string.h>
#include "winerror.h"
#include "winnls.h"
#include "wine/unicode.h"
#include "syslevel.h"
#include "server.h"
#include "debugtools.h"
DEFAULT_DEBUG_CHANNEL(win32);
/*
* Events
*/
/***********************************************************************
* CreateEventA (KERNEL32.156)
*/
HANDLE WINAPI CreateEventA( SECURITY_ATTRIBUTES *sa, BOOL manual_reset,
BOOL initial_state, LPCSTR name )
{
HANDLE ret;
DWORD len = name ? MultiByteToWideChar( CP_ACP, 0, name, strlen(name), NULL, 0 ) : 0;
if (len >= MAX_PATH)
{
SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0;
}
SERVER_START_REQ
{
struct create_event_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->manual_reset = manual_reset;
req->initial_state = initial_state;
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
SetLastError(0);
server_call( REQ_CREATE_EVENT );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
/***********************************************************************
* CreateEventW (KERNEL32.157)
*/
HANDLE WINAPI CreateEventW( SECURITY_ATTRIBUTES *sa, BOOL manual_reset,
BOOL initial_state, LPCWSTR name )
{
HANDLE ret;
DWORD len = name ? strlenW(name) : 0;
if (len >= MAX_PATH)
{
SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0;
}
SERVER_START_REQ
{
struct create_event_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->manual_reset = manual_reset;
req->initial_state = initial_state;
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
SetLastError(0);
server_call( REQ_CREATE_EVENT );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
/***********************************************************************
* WIN16_CreateEvent (KERNEL.457)
*/
HANDLE WINAPI WIN16_CreateEvent( BOOL manual_reset, BOOL initial_state )
{
return CreateEventA( NULL, manual_reset, initial_state, NULL );
}
/***********************************************************************
* OpenEventA (KERNEL32.536)
*/
HANDLE WINAPI OpenEventA( DWORD access, BOOL inherit, LPCSTR name )
{
HANDLE ret;
DWORD len = name ? MultiByteToWideChar( CP_ACP, 0, name, strlen(name), NULL, 0 ) : 0;
if (len >= MAX_PATH)
{
SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0;
}
SERVER_START_REQ
{
struct open_event_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->access = access;
req->inherit = inherit;
if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
server_call( REQ_OPEN_EVENT );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
/***********************************************************************
* OpenEventW (KERNEL32.537)
*/
HANDLE WINAPI OpenEventW( DWORD access, BOOL inherit, LPCWSTR name )
{
HANDLE ret;
DWORD len = name ? strlenW(name) : 0;
if (len >= MAX_PATH)
{
SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0;
}
SERVER_START_REQ
{
struct open_event_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->access = access;
req->inherit = inherit;
memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
server_call( REQ_OPEN_EVENT );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
/***********************************************************************
* EVENT_Operation
*
* Execute an event operation (set,reset,pulse).
*/
static BOOL EVENT_Operation( HANDLE handle, enum event_op op )
{
BOOL ret;
SERVER_START_REQ
{
struct event_op_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = handle;
req->op = op;
ret = !server_call( REQ_EVENT_OP );
}
SERVER_END_REQ;
return ret;
}
/***********************************************************************
* PulseEvent (KERNEL32.557)
*/
BOOL WINAPI PulseEvent( HANDLE handle )
{
return EVENT_Operation( handle, PULSE_EVENT );
}
/***********************************************************************
* SetEvent (KERNEL32.644)
*/
BOOL WINAPI SetEvent( HANDLE handle )
{
return EVENT_Operation( handle, SET_EVENT );
}
/***********************************************************************
* ResetEvent (KERNEL32.586)
*/
BOOL WINAPI ResetEvent( HANDLE handle )
{
return EVENT_Operation( handle, RESET_EVENT );
}
/***********************************************************************
* NOTE: The Win95 VWin32_Event routines given below are really low-level
* routines implemented directly by VWin32. The user-mode libraries
* implement Win32 synchronisation routines on top of these low-level
* primitives. We do it the other way around here :-)
*/
/***********************************************************************
* VWin32_EventCreate (KERNEL.442)
*/
HANDLE WINAPI VWin32_EventCreate(VOID)
{
HANDLE hEvent = CreateEventA( NULL, FALSE, 0, NULL );
return ConvertToGlobalHandle( hEvent );
}
/***********************************************************************
* VWin32_EventDestroy (KERNEL.443)
*/
VOID WINAPI VWin32_EventDestroy(HANDLE event)
{
CloseHandle( event );
}
/***********************************************************************
* VWin32_EventWait (KERNEL.450)
*/
VOID WINAPI VWin32_EventWait(HANDLE event)
{
SYSLEVEL_ReleaseWin16Lock();
WaitForSingleObject( event, INFINITE );
SYSLEVEL_RestoreWin16Lock();
}
/***********************************************************************
* VWin32_EventSet (KERNEL.451)
*/
VOID WINAPI VWin32_EventSet(HANDLE event)
{
SetEvent( event );
}
/***********************************************************************
* CreateMutexA (KERNEL32.166)
*/
HANDLE WINAPI CreateMutexA( SECURITY_ATTRIBUTES *sa, BOOL owner, LPCSTR name )
{
HANDLE ret;
DWORD len = name ? MultiByteToWideChar( CP_ACP, 0, name, strlen(name), NULL, 0 ) : 0;
if (len >= MAX_PATH)
{
SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0;
}
SERVER_START_REQ
{
struct create_mutex_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->owned = owner;
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
SetLastError(0);
server_call( REQ_CREATE_MUTEX );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
/***********************************************************************
* CreateMutexW (KERNEL32.167)
*/
HANDLE WINAPI CreateMutexW( SECURITY_ATTRIBUTES *sa, BOOL owner, LPCWSTR name )
{
HANDLE ret;
DWORD len = name ? strlenW(name) : 0;
if (len >= MAX_PATH)
{
SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0;
}
SERVER_START_REQ
{
struct create_mutex_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->owned = owner;
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
SetLastError(0);
server_call( REQ_CREATE_MUTEX );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
/*
* Mutexes
*/
/***********************************************************************
* OpenMutexA (KERNEL32.541)
*/
HANDLE WINAPI OpenMutexA( DWORD access, BOOL inherit, LPCSTR name )
{
HANDLE ret;
DWORD len = name ? MultiByteToWideChar( CP_ACP, 0, name, strlen(name), NULL, 0 ) : 0;
if (len >= MAX_PATH)
{
SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0;
}
SERVER_START_REQ
{
struct open_mutex_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->access = access;
req->inherit = inherit;
if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
server_call( REQ_OPEN_MUTEX );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
/***********************************************************************
* OpenMutexW (KERNEL32.542)
*/
HANDLE WINAPI OpenMutexW( DWORD access, BOOL inherit, LPCWSTR name )
{
HANDLE ret;
DWORD len = name ? strlenW(name) : 0;
if (len >= MAX_PATH)
{
SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0;
}
SERVER_START_REQ
{
struct open_mutex_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->access = access;
req->inherit = inherit;
memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
server_call( REQ_OPEN_MUTEX );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
/***********************************************************************
* ReleaseMutex (KERNEL32.582)
*/
BOOL WINAPI ReleaseMutex( HANDLE handle )
{
BOOL ret;
SERVER_START_REQ
{
struct release_mutex_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = handle;
ret = !server_call( REQ_RELEASE_MUTEX );
}
SERVER_END_REQ;
return ret;
}
/*
* Semaphores
*/
/***********************************************************************
* CreateSemaphoreA (KERNEL32.174)
*/
HANDLE WINAPI CreateSemaphoreA( SECURITY_ATTRIBUTES *sa, LONG initial, LONG max, LPCSTR name )
{
HANDLE ret;
DWORD len = name ? MultiByteToWideChar( CP_ACP, 0, name, strlen(name), NULL, 0 ) : 0;
/* Check parameters */
if ((max <= 0) || (initial < 0) || (initial > max))
{
SetLastError( ERROR_INVALID_PARAMETER );
return 0;
}
if (len >= MAX_PATH)
{
SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0;
}
SERVER_START_REQ
{
struct create_semaphore_request *req = server_alloc_req( sizeof(*req),
len * sizeof(WCHAR) );
req->initial = (unsigned int)initial;
req->max = (unsigned int)max;
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
SetLastError(0);
server_call( REQ_CREATE_SEMAPHORE );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
/***********************************************************************
* CreateSemaphoreW (KERNEL32.175)
*/
HANDLE WINAPI CreateSemaphoreW( SECURITY_ATTRIBUTES *sa, LONG initial,
LONG max, LPCWSTR name )
{
HANDLE ret;
DWORD len = name ? strlenW(name) : 0;
/* Check parameters */
if ((max <= 0) || (initial < 0) || (initial > max))
{
SetLastError( ERROR_INVALID_PARAMETER );
return 0;
}
if (len >= MAX_PATH)
{
SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0;
}
SERVER_START_REQ
{
struct create_semaphore_request *req = server_alloc_req( sizeof(*req),
len * sizeof(WCHAR) );
req->initial = (unsigned int)initial;
req->max = (unsigned int)max;
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
SetLastError(0);
server_call( REQ_CREATE_SEMAPHORE );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
/***********************************************************************
* OpenSemaphoreA (KERNEL32.545)
*/
HANDLE WINAPI OpenSemaphoreA( DWORD access, BOOL inherit, LPCSTR name )
{
HANDLE ret;
DWORD len = name ? MultiByteToWideChar( CP_ACP, 0, name, strlen(name), NULL, 0 ) : 0;
if (len >= MAX_PATH)
{
SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0;
}
SERVER_START_REQ
{
struct open_semaphore_request *req = server_alloc_req( sizeof(*req),
len * sizeof(WCHAR) );
req->access = access;
req->inherit = inherit;
if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
server_call( REQ_OPEN_SEMAPHORE );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
/***********************************************************************
* OpenSemaphoreW (KERNEL32.546)
*/
HANDLE WINAPI OpenSemaphoreW( DWORD access, BOOL inherit, LPCWSTR name )
{
HANDLE ret;
DWORD len = name ? strlenW(name) : 0;
if (len >= MAX_PATH)
{
SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0;
}
SERVER_START_REQ
{
struct open_semaphore_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->access = access;
req->inherit = inherit;
memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
server_call( REQ_OPEN_SEMAPHORE );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
/***********************************************************************
* ReleaseSemaphore (KERNEL32.583)
*/
BOOL WINAPI ReleaseSemaphore( HANDLE handle, LONG count, LONG *previous )
{
NTSTATUS status = NtReleaseSemaphore( handle, count, previous );
if (status) SetLastError( RtlNtStatusToDosError(status) );
return !status;
}
/*
* Pipes
*/
/***********************************************************************
* CreateNamedPipeA (KERNEL32.168)
*/
HANDLE WINAPI CreateNamedPipeA( LPCSTR name, DWORD dwOpenMode,
DWORD dwPipeMode, DWORD nMaxInstances,
DWORD nOutBufferSize, DWORD nInBufferSize,
DWORD nDefaultTimeOut, LPSECURITY_ATTRIBUTES attr )
{
FIXME("(Name=%s, OpenMode=%#08lx, dwPipeMode=%#08lx, MaxInst=%ld, OutBSize=%ld, InBuffSize=%ld, DefTimeOut=%ld, SecAttr=%p): stub\n",
debugstr_a(name), dwOpenMode, dwPipeMode, nMaxInstances,
nOutBufferSize, nInBufferSize, nDefaultTimeOut, attr );
SetLastError (ERROR_UNKNOWN);
return INVALID_HANDLE_VALUE;
}
/***********************************************************************
* CreateNamedPipeW (KERNEL32.169)
*/
HANDLE WINAPI CreateNamedPipeW( LPCWSTR name, DWORD dwOpenMode,
DWORD dwPipeMode, DWORD nMaxInstances,
DWORD nOutBufferSize, DWORD nInBufferSize,
DWORD nDefaultTimeOut, LPSECURITY_ATTRIBUTES attr )
{
FIXME("(Name=%s, OpenMode=%#08lx, dwPipeMode=%#08lx, MaxInst=%ld, OutBSize=%ld, InBuffSize=%ld, DefTimeOut=%ld, SecAttr=%p): stub\n",
debugstr_w(name), dwOpenMode, dwPipeMode, nMaxInstances,
nOutBufferSize, nInBufferSize, nDefaultTimeOut, attr );
SetLastError (ERROR_UNKNOWN);
return INVALID_HANDLE_VALUE;
}
/***********************************************************************
* PeekNamedPipe (KERNEL32.552)
*/
BOOL WINAPI PeekNamedPipe( HANDLE hPipe, LPVOID lpvBuffer, DWORD cbBuffer,
LPDWORD lpcbRead, LPDWORD lpcbAvail, LPDWORD lpcbMessage )
{
FIXME("(%08x, %p, %08lx, %p, %p, %p): stub\n",
hPipe, lpvBuffer, cbBuffer, lpcbRead, lpcbAvail, lpcbMessage);
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
/***********************************************************************
* WaitNamedPipeA (KERNEL32.@)
*/
BOOL WINAPI WaitNamedPipeA (LPCSTR lpNamedPipeName, DWORD nTimeOut)
{
FIXME("%s 0x%08lx\n",lpNamedPipeName,nTimeOut);
SetLastError(ERROR_PIPE_NOT_CONNECTED);
return FALSE;
}
/***********************************************************************
* WaitNamedPipeW (KERNEL32.@)
*/
BOOL WINAPI WaitNamedPipeW (LPCWSTR lpNamedPipeName, DWORD nTimeOut)
{
FIXME("%s 0x%08lx\n",debugstr_w(lpNamedPipeName),nTimeOut);
SetLastError(ERROR_PIPE_NOT_CONNECTED);
return FALSE;
}

246
dlls/kernel/time.c Normal file
View File

@ -0,0 +1,246 @@
/*
* Win32 kernel functions
*
* Copyright 1995 Martin von Loewis and Cameron Heide
*/
#include <string.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/times.h>
#include "file.h"
#include "winerror.h"
#include "debugtools.h"
DEFAULT_DEBUG_CHANNEL(win32);
/* maximum time adjustment in seconds for SetLocalTime and SetSystemTime */
#define SETTIME_MAX_ADJUST 120
/* TIME_GetBias: helper function calculates delta local time from UTC */
static int TIME_GetBias( time_t utc, int *pdaylight)
{
struct tm *ptm = localtime(&utc);
*pdaylight = ptm->tm_isdst; /* daylight for local timezone */
ptm = gmtime(&utc);
ptm->tm_isdst = *pdaylight; /* use local daylight, not that of Greenwich */
return (int)(utc-mktime(ptm));
}
/***********************************************************************
* SetLocalTime (KERNEL32.655)
*
* FIXME: correct ? Is the timezone param of settimeofday() needed ?
* I don't have any docu about SetLocal/SystemTime(), argl...
*/
BOOL WINAPI SetLocalTime(const SYSTEMTIME *systime)
{
struct timeval tv;
struct tm t;
time_t sec;
time_t oldsec=time(NULL);
int err;
/* get the number of seconds */
t.tm_sec = systime->wSecond;
t.tm_min = systime->wMinute;
t.tm_hour = systime->wHour;
t.tm_mday = systime->wDay;
t.tm_mon = systime->wMonth - 1;
t.tm_year = systime->wYear - 1900;
t.tm_isdst = -1;
sec = mktime (&t);
/* set the new time */
tv.tv_sec = sec;
tv.tv_usec = systime->wMilliseconds * 1000;
/* error and sanity check*/
if( sec == (time_t)-1 || abs((int)(sec-oldsec)) > SETTIME_MAX_ADJUST ){
err = 1;
SetLastError(ERROR_INVALID_PARAMETER);
} else {
err=settimeofday(&tv, NULL); /* 0 is OK, -1 is error */
if(err == 0)
return TRUE;
SetLastError(ERROR_PRIVILEGE_NOT_HELD);
}
ERR("Cannot set time to %d/%d/%d %d:%d:%d Time adjustment %ld %s\n",
systime->wYear, systime->wMonth, systime->wDay, systime->wHour,
systime->wMinute, systime->wSecond,
sec-oldsec, err == -1 ? "No Permission" :
sec==(time_t)-1 ? "" : "is too large." );
return FALSE;
}
/***********************************************************************
* GetSystemTimeAdjustment (KERNEL32.407)
*
*/
DWORD WINAPI GetSystemTimeAdjustment( LPDWORD lpTimeAdjustment,
LPDWORD lpTimeIncrement,
LPBOOL lpTimeAdjustmentDisabled )
{
*lpTimeAdjustment = 0;
*lpTimeIncrement = 0;
*lpTimeAdjustmentDisabled = TRUE;
return TRUE;
}
/***********************************************************************
* SetSystemTime (KERNEL32.507)
*/
BOOL WINAPI SetSystemTime(const SYSTEMTIME *systime)
{
struct timeval tv;
struct timezone tz;
struct tm t;
time_t sec, oldsec;
int dst, bias;
int err;
/* call gettimeofday to get the current timezone */
gettimeofday(&tv, &tz);
oldsec=tv.tv_sec;
/* get delta local time from utc */
bias=TIME_GetBias(oldsec,&dst);
/* get the number of seconds */
t.tm_sec = systime->wSecond;
t.tm_min = systime->wMinute;
t.tm_hour = systime->wHour;
t.tm_mday = systime->wDay;
t.tm_mon = systime->wMonth - 1;
t.tm_year = systime->wYear - 1900;
t.tm_isdst = dst;
sec = mktime (&t);
/* correct for timezone and daylight */
sec += bias;
/* set the new time */
tv.tv_sec = sec;
tv.tv_usec = systime->wMilliseconds * 1000;
/* error and sanity check*/
if( sec == (time_t)-1 || abs((int)(sec-oldsec)) > SETTIME_MAX_ADJUST ){
err = 1;
SetLastError(ERROR_INVALID_PARAMETER);
} else {
err=settimeofday(&tv, NULL); /* 0 is OK, -1 is error */
if(err == 0)
return TRUE;
SetLastError(ERROR_PRIVILEGE_NOT_HELD);
}
ERR("Cannot set time to %d/%d/%d %d:%d:%d Time adjustment %ld %s\n",
systime->wYear, systime->wMonth, systime->wDay, systime->wHour,
systime->wMinute, systime->wSecond,
sec-oldsec, err == -1 ? "No Permission" :
sec==(time_t)-1 ? "" : "is too large." );
return FALSE;
}
/***********************************************************************
* GetTimeZoneInformation (KERNEL32.302)
*/
DWORD WINAPI GetTimeZoneInformation(LPTIME_ZONE_INFORMATION tzinfo)
{
time_t gmt;
int bias, daylight;
memset(tzinfo, 0, sizeof(TIME_ZONE_INFORMATION));
gmt = time(NULL);
bias=TIME_GetBias(gmt,&daylight);
tzinfo->Bias = -bias / 60;
tzinfo->StandardBias = 0;
tzinfo->DaylightBias = -60;
return TIME_ZONE_ID_UNKNOWN;
}
/***********************************************************************
* SetTimeZoneInformation (KERNEL32.515)
*/
BOOL WINAPI SetTimeZoneInformation(const LPTIME_ZONE_INFORMATION tzinfo)
{
struct timezone tz;
tz.tz_minuteswest = tzinfo->Bias;
#ifdef DST_NONE
tz.tz_dsttime = DST_NONE;
#else
tz.tz_dsttime = 0;
#endif
return !settimeofday(NULL, &tz);
}
/***********************************************************************
* SystemTimeToTzSpecificLocalTime (KERNEL32.683)
*/
BOOL WINAPI SystemTimeToTzSpecificLocalTime(
LPTIME_ZONE_INFORMATION lpTimeZoneInformation,
LPSYSTEMTIME lpUniversalTime,
LPSYSTEMTIME lpLocalTime)
{
FIXME(":stub\n");
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
/*********************************************************************
* TIME_ClockTimeToFileTime
* (olorin@fandra.org, 20-Sep-1998)
* Converts clock_t into FILETIME.
* Used by GetProcessTime.
* Differences to UnixTimeToFileTime:
* 1) Divided by CLK_TCK
* 2) Time is relative. There is no 'starting date', so there is
* no need in offset correction, like in UnixTimeToFileTime
* FIXME: This function should be moved to a more appropriate .c file
* FIXME: On floating point operations, it is assumed that
* floating values are truncated on conversion to integer.
*/
static void TIME_ClockTimeToFileTime(clock_t unix_time, LPFILETIME filetime)
{
double td = (unix_time*10000000.0)/CLK_TCK;
/* Yes, double, because long int might overflow here. */
#if SIZEOF_LONG_LONG >= 8
unsigned long long t = td;
filetime->dwLowDateTime = (UINT) t;
filetime->dwHighDateTime = (UINT) (t >> 32);
#else
double divider = 1. * (1 << 16) * (1 << 16);
filetime->dwHighDateTime = (UINT) (td / divider);
filetime->dwLowDateTime = (UINT) (td - filetime->dwHighDateTime*divider);
/* using floor() produces wierd results, better leave this as it is
* ( with (UINT32) convertion )
*/
#endif
}
/*********************************************************************
* GetProcessTimes [KERNEL32.262]
*
* FIXME: lpCreationTime, lpExitTime are NOT INITIALIZED.
* olorin@fandra.org: Would be nice to substract the cpu time,
* used by Wine at startup.
* Also, there is a need to separate times
* used by different applications.
*/
BOOL WINAPI GetProcessTimes( HANDLE hprocess,LPFILETIME lpCreationTime,LPFILETIME lpExitTime,
LPFILETIME lpKernelTime, LPFILETIME lpUserTime )
{
struct tms tms;
times(&tms);
TIME_ClockTimeToFileTime(tms.tms_utime,lpUserTime);
TIME_ClockTimeToFileTime(tms.tms_stime,lpKernelTime);
return TRUE;
}

View File

@ -177,7 +177,9 @@ NTSTATUS WINAPI NtOpenEvent(
NTSTATUS WINAPI NtSetEvent( HANDLE handle, PULONG NumberOfThreadsReleased )
{
NTSTATUS ret;
FIXME("(0x%08x,%p)\n", handle, NumberOfThreadsReleased);
/* FIXME: set NumberOfThreadsReleased */
SERVER_START_REQ
{
struct event_op_request *req = server_alloc_req( sizeof(*req), 0 );

View File

@ -912,11 +912,14 @@ NTSTATUS WINAPI NtClose(
NTSTATUS WINAPI NtTerminateProcess( HANDLE handle, LONG exit_code );
NTSTATUS WINAPI NtTerminateThread( HANDLE handle, LONG exit_code );
NTSTATUS WINAPI NtClearEvent(HANDLE);
NTSTATUS WINAPI NtCreateEvent(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES *,BOOLEAN,BOOLEAN);
NTSTATUS WINAPI NtCreateSemaphore(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES*,ULONG,ULONG);
NTSTATUS WINAPI NtReleaseSemaphore( IN HANDLE SemaphoreHandle,
IN ULONG ReleaseCount,
IN PULONG PreviousCount);
NTSTATUS WINAPI NtOpenEvent(PHANDLE,ACCESS_MASK,const OBJECT_ATTRIBUTES *attr);
NTSTATUS WINAPI NtPulseEvent(HANDLE,PULONG);
NTSTATUS WINAPI NtReleaseSemaphore(HANDLE,ULONG,PULONG);
NTSTATUS WINAPI NtResetEvent(HANDLE,PULONG);
NTSTATUS WINAPI NtSetEvent(HANDLE,PULONG);
NTSTATUS WINAPI RtlInitializeCriticalSection( RTL_CRITICAL_SECTION *crit );
NTSTATUS WINAPI RtlDeleteCriticalSection( RTL_CRITICAL_SECTION *crit );

View File

@ -10,6 +10,7 @@
#include <unistd.h>
#include "wine/winbase16.h"
#include "ntddk.h"
#include "callback.h"
#include "drive.h"
#include "file.h"
@ -327,7 +328,7 @@ BOOL TASK_Create( NE_MODULE *pModule, UINT16 cmdShow, TEB *teb, LPCSTR cmdline,
/* Create scheduler event for 16-bit tasks */
if ( !(pTask->flags & TDBF_WIN32) )
pTask->hEvent = CreateEventA( NULL, TRUE, FALSE, NULL );
NtCreateEvent( &pTask->hEvent, EVENT_ALL_ACCESS, NULL, TRUE, FALSE );
/* Enter task handle into thread and process */
@ -600,7 +601,7 @@ void TASK_Reschedule(void)
pNewTask->priority--;
hCurrentTask = hNewTask;
SetEvent( pNewTask->hEvent );
NtSetEvent( pNewTask->hEvent, NULL );
/* This is set just in case some app reads it ... */
pNewTask->ss_sp = pNewTask->teb->cur_stack;
@ -609,7 +610,7 @@ void TASK_Reschedule(void)
/* If we need to put the current task to sleep, do it ... */
if ( (mode == MODE_YIELD || mode == MODE_SLEEP) && hOldTask != hCurrentTask )
{
ResetEvent( pOldTask->hEvent );
NtResetEvent( pOldTask->hEvent, NULL );
ReleaseThunkLock( &lockCount );
SYSLEVEL_CheckNotLevel( 1 );

View File

@ -8,14 +8,10 @@ MODULE = scheduler
C_SRCS = \
client.c \
critsection.c \
debugger.c \
event.c \
handle.c \
mutex.c \
pipe.c \
process.c \
pthread.c \
semaphore.c \
services.c \
synchro.c \
sysdeps.c \

View File

@ -34,7 +34,7 @@ void WINAPI MakeCriticalSectionGlobal( CRITICAL_SECTION *crit )
{
/* let's assume that only one thread at a time will try to do this */
HANDLE sem = crit->LockSemaphore;
if (!sem) sem = CreateSemaphoreA( NULL, 0, 1, NULL );
if (!sem) NtCreateSemaphore( &sem, SEMAPHORE_ALL_ACCESS, NULL, 0, 1 );
crit->LockSemaphore = ConvertToGlobalHandle( sem );
}

View File

@ -1,230 +0,0 @@
/*
* Win32 events
*
* Copyright 1998 Alexandre Julliard
*/
#include <assert.h>
#include <string.h>
#include "winerror.h"
#include "winnls.h"
#include "wine/unicode.h"
#include "syslevel.h"
#include "server.h"
/***********************************************************************
* CreateEventA (KERNEL32.156)
*/
HANDLE WINAPI CreateEventA( SECURITY_ATTRIBUTES *sa, BOOL manual_reset,
BOOL initial_state, LPCSTR name )
{
HANDLE ret;
DWORD len = name ? MultiByteToWideChar( CP_ACP, 0, name, strlen(name), NULL, 0 ) : 0;
if (len >= MAX_PATH)
{
SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0;
}
SERVER_START_REQ
{
struct create_event_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->manual_reset = manual_reset;
req->initial_state = initial_state;
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
SetLastError(0);
server_call( REQ_CREATE_EVENT );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
/***********************************************************************
* CreateEventW (KERNEL32.157)
*/
HANDLE WINAPI CreateEventW( SECURITY_ATTRIBUTES *sa, BOOL manual_reset,
BOOL initial_state, LPCWSTR name )
{
HANDLE ret;
DWORD len = name ? strlenW(name) : 0;
if (len >= MAX_PATH)
{
SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0;
}
SERVER_START_REQ
{
struct create_event_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->manual_reset = manual_reset;
req->initial_state = initial_state;
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
SetLastError(0);
server_call( REQ_CREATE_EVENT );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
/***********************************************************************
* WIN16_CreateEvent (KERNEL.457)
*/
HANDLE WINAPI WIN16_CreateEvent( BOOL manual_reset, BOOL initial_state )
{
return CreateEventA( NULL, manual_reset, initial_state, NULL );
}
/***********************************************************************
* OpenEventA (KERNEL32.536)
*/
HANDLE WINAPI OpenEventA( DWORD access, BOOL inherit, LPCSTR name )
{
HANDLE ret;
DWORD len = name ? MultiByteToWideChar( CP_ACP, 0, name, strlen(name), NULL, 0 ) : 0;
if (len >= MAX_PATH)
{
SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0;
}
SERVER_START_REQ
{
struct open_event_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->access = access;
req->inherit = inherit;
if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
server_call( REQ_OPEN_EVENT );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
/***********************************************************************
* OpenEventW (KERNEL32.537)
*/
HANDLE WINAPI OpenEventW( DWORD access, BOOL inherit, LPCWSTR name )
{
HANDLE ret;
DWORD len = name ? strlenW(name) : 0;
if (len >= MAX_PATH)
{
SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0;
}
SERVER_START_REQ
{
struct open_event_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->access = access;
req->inherit = inherit;
memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
server_call( REQ_OPEN_EVENT );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
/***********************************************************************
* EVENT_Operation
*
* Execute an event operation (set,reset,pulse).
*/
static BOOL EVENT_Operation( HANDLE handle, enum event_op op )
{
BOOL ret;
SERVER_START_REQ
{
struct event_op_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = handle;
req->op = op;
ret = !server_call( REQ_EVENT_OP );
}
SERVER_END_REQ;
return ret;
}
/***********************************************************************
* PulseEvent (KERNEL32.557)
*/
BOOL WINAPI PulseEvent( HANDLE handle )
{
return EVENT_Operation( handle, PULSE_EVENT );
}
/***********************************************************************
* SetEvent (KERNEL32.644)
*/
BOOL WINAPI SetEvent( HANDLE handle )
{
return EVENT_Operation( handle, SET_EVENT );
}
/***********************************************************************
* ResetEvent (KERNEL32.586)
*/
BOOL WINAPI ResetEvent( HANDLE handle )
{
return EVENT_Operation( handle, RESET_EVENT );
}
/***********************************************************************
* NOTE: The Win95 VWin32_Event routines given below are really low-level
* routines implemented directly by VWin32. The user-mode libraries
* implement Win32 synchronisation routines on top of these low-level
* primitives. We do it the other way around here :-)
*/
/***********************************************************************
* VWin32_EventCreate (KERNEL.442)
*/
HANDLE WINAPI VWin32_EventCreate(VOID)
{
HANDLE hEvent = CreateEventA( NULL, FALSE, 0, NULL );
return ConvertToGlobalHandle( hEvent );
}
/***********************************************************************
* VWin32_EventDestroy (KERNEL.443)
*/
VOID WINAPI VWin32_EventDestroy(HANDLE event)
{
CloseHandle( event );
}
/***********************************************************************
* VWin32_EventWait (KERNEL.450)
*/
VOID WINAPI VWin32_EventWait(HANDLE event)
{
SYSLEVEL_ReleaseWin16Lock();
WaitForSingleObject( event, INFINITE );
SYSLEVEL_RestoreWin16Lock();
}
/***********************************************************************
* VWin32_EventSet (KERNEL.451)
*/
VOID WINAPI VWin32_EventSet(HANDLE event)
{
SetEvent( event );
}

View File

@ -1,143 +0,0 @@
/*
* Win32 mutexes
*
* Copyright 1998 Alexandre Julliard
*/
#include <assert.h>
#include <string.h>
#include "winerror.h"
#include "winnls.h"
#include "wine/unicode.h"
#include "server.h"
/***********************************************************************
* CreateMutexA (KERNEL32.166)
*/
HANDLE WINAPI CreateMutexA( SECURITY_ATTRIBUTES *sa, BOOL owner, LPCSTR name )
{
HANDLE ret;
DWORD len = name ? MultiByteToWideChar( CP_ACP, 0, name, strlen(name), NULL, 0 ) : 0;
if (len >= MAX_PATH)
{
SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0;
}
SERVER_START_REQ
{
struct create_mutex_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->owned = owner;
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
SetLastError(0);
server_call( REQ_CREATE_MUTEX );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
/***********************************************************************
* CreateMutexW (KERNEL32.167)
*/
HANDLE WINAPI CreateMutexW( SECURITY_ATTRIBUTES *sa, BOOL owner, LPCWSTR name )
{
HANDLE ret;
DWORD len = name ? strlenW(name) : 0;
if (len >= MAX_PATH)
{
SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0;
}
SERVER_START_REQ
{
struct create_mutex_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->owned = owner;
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
SetLastError(0);
server_call( REQ_CREATE_MUTEX );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
/***********************************************************************
* OpenMutexA (KERNEL32.541)
*/
HANDLE WINAPI OpenMutexA( DWORD access, BOOL inherit, LPCSTR name )
{
HANDLE ret;
DWORD len = name ? MultiByteToWideChar( CP_ACP, 0, name, strlen(name), NULL, 0 ) : 0;
if (len >= MAX_PATH)
{
SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0;
}
SERVER_START_REQ
{
struct open_mutex_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->access = access;
req->inherit = inherit;
if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
server_call( REQ_OPEN_MUTEX );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
/***********************************************************************
* OpenMutexW (KERNEL32.542)
*/
HANDLE WINAPI OpenMutexW( DWORD access, BOOL inherit, LPCWSTR name )
{
HANDLE ret;
DWORD len = name ? strlenW(name) : 0;
if (len >= MAX_PATH)
{
SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0;
}
SERVER_START_REQ
{
struct open_mutex_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->access = access;
req->inherit = inherit;
memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
server_call( REQ_OPEN_MUTEX );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
/***********************************************************************
* ReleaseMutex (KERNEL32.582)
*/
BOOL WINAPI ReleaseMutex( HANDLE handle )
{
BOOL ret;
SERVER_START_REQ
{
struct release_mutex_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = handle;
ret = !server_call( REQ_RELEASE_MUTEX );
}
SERVER_END_REQ;
return ret;
}

View File

@ -1,159 +0,0 @@
/*
* Win32 semaphores
*
* Copyright 1998 Alexandre Julliard
*/
#include <assert.h>
#include <string.h>
#include "winerror.h"
#include "winnls.h"
#include "wine/unicode.h"
#include "server.h"
/***********************************************************************
* CreateSemaphoreA (KERNEL32.174)
*/
HANDLE WINAPI CreateSemaphoreA( SECURITY_ATTRIBUTES *sa, LONG initial, LONG max, LPCSTR name )
{
HANDLE ret;
DWORD len = name ? MultiByteToWideChar( CP_ACP, 0, name, strlen(name), NULL, 0 ) : 0;
/* Check parameters */
if ((max <= 0) || (initial < 0) || (initial > max))
{
SetLastError( ERROR_INVALID_PARAMETER );
return 0;
}
if (len >= MAX_PATH)
{
SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0;
}
SERVER_START_REQ
{
struct create_semaphore_request *req = server_alloc_req( sizeof(*req),
len * sizeof(WCHAR) );
req->initial = (unsigned int)initial;
req->max = (unsigned int)max;
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
SetLastError(0);
server_call( REQ_CREATE_SEMAPHORE );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
/***********************************************************************
* CreateSemaphoreW (KERNEL32.175)
*/
HANDLE WINAPI CreateSemaphoreW( SECURITY_ATTRIBUTES *sa, LONG initial,
LONG max, LPCWSTR name )
{
HANDLE ret;
DWORD len = name ? strlenW(name) : 0;
/* Check parameters */
if ((max <= 0) || (initial < 0) || (initial > max))
{
SetLastError( ERROR_INVALID_PARAMETER );
return 0;
}
if (len >= MAX_PATH)
{
SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0;
}
SERVER_START_REQ
{
struct create_semaphore_request *req = server_alloc_req( sizeof(*req),
len * sizeof(WCHAR) );
req->initial = (unsigned int)initial;
req->max = (unsigned int)max;
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
SetLastError(0);
server_call( REQ_CREATE_SEMAPHORE );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
/***********************************************************************
* OpenSemaphoreA (KERNEL32.545)
*/
HANDLE WINAPI OpenSemaphoreA( DWORD access, BOOL inherit, LPCSTR name )
{
HANDLE ret;
DWORD len = name ? MultiByteToWideChar( CP_ACP, 0, name, strlen(name), NULL, 0 ) : 0;
if (len >= MAX_PATH)
{
SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0;
}
SERVER_START_REQ
{
struct open_semaphore_request *req = server_alloc_req( sizeof(*req),
len * sizeof(WCHAR) );
req->access = access;
req->inherit = inherit;
if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
server_call( REQ_OPEN_SEMAPHORE );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
/***********************************************************************
* OpenSemaphoreW (KERNEL32.546)
*/
HANDLE WINAPI OpenSemaphoreW( DWORD access, BOOL inherit, LPCWSTR name )
{
HANDLE ret;
DWORD len = name ? strlenW(name) : 0;
if (len >= MAX_PATH)
{
SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0;
}
SERVER_START_REQ
{
struct open_semaphore_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->access = access;
req->inherit = inherit;
memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
server_call( REQ_OPEN_SEMAPHORE );
ret = req->handle;
}
SERVER_END_REQ;
if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
return ret;
}
/***********************************************************************
* ReleaseSemaphore (KERNEL32.583)
*/
BOOL WINAPI ReleaseSemaphore( HANDLE handle, LONG count, LONG *previous )
{
NTSTATUS status = NtReleaseSemaphore( handle, count, previous );
if (status) SetLastError( RtlNtStatusToDosError(status) );
return !status;
}

View File

@ -6,13 +6,14 @@
#include <unistd.h>
#include <sys/types.h>
#include "ntddk.h"
#include "syslevel.h"
#include "heap.h"
#include "selectors.h"
#include "stackframe.h"
#include "debugtools.h"
DEFAULT_DEBUG_CHANNEL(win32)
DEFAULT_DEBUG_CHANNEL(win32);
static SYSLEVEL Win16Mutex;
static SEGPTR segpWin16Mutex;
@ -230,7 +231,7 @@ VOID SYSLEVEL_CheckNotLevel( INT level )
{
ERR("(%d): Holding lock of level %d!\n",
level, i );
DebugBreak();
DbgBreakPoint();
break;
}
}

View File

@ -13,7 +13,6 @@ C_SRCS = \
init.c \
kernel32.c \
newfns.c \
process.c \
time.c
all: $(MODULE).o

View File

@ -154,7 +154,7 @@ DWORD WINAPI UnhandledExceptionFilter(PEXCEPTION_POINTERS epointers)
attr.bInheritHandle = TRUE;
TRACE("Starting debugger (fmt=%s)\n", format);
hEvent = CreateEventA(&attr, FALSE, FALSE, NULL);
NtCreateEvent( &hEvent, EVENT_ALL_ACCESS, NULL, FALSE, FALSE );
sprintf(buffer, format, GetCurrentProcessId(), hEvent);
memset(&startup, 0, sizeof(startup));
startup.cb = sizeof(startup);

View File

@ -49,21 +49,3 @@ BOOL WINAPI UpdateResourceW(
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
/***********************************************************************
* WaitNamedPipeA [KERNEL32.725]
*/
BOOL WINAPI WaitNamedPipeA (LPCSTR lpNamedPipeName, DWORD nTimeOut)
{ FIXME("%s 0x%08lx\n",lpNamedPipeName,nTimeOut);
SetLastError(ERROR_PIPE_NOT_CONNECTED);
return FALSE;
}
/***********************************************************************
* WaitNamedPipeW [KERNEL32.726]
*/
BOOL WINAPI WaitNamedPipeW (LPCWSTR lpNamedPipeName, DWORD nTimeOut)
{ FIXME("%s 0x%08lx\n",debugstr_w(lpNamedPipeName),nTimeOut);
SetLastError(ERROR_PIPE_NOT_CONNECTED);
return FALSE;
}

View File

@ -50,59 +50,6 @@ BOOL WINAPI FlushInstructionCache(DWORD x,DWORD y,DWORD z) {
return TRUE;
}
/***********************************************************************
* CreateNamedPipeA (KERNEL32.168)
*/
HANDLE WINAPI CreateNamedPipeA (LPCSTR lpName, DWORD dwOpenMode,
DWORD dwPipeMode, DWORD nMaxInstances,
DWORD nOutBufferSize, DWORD nInBufferSize,
DWORD nDefaultTimeOut,
LPSECURITY_ATTRIBUTES lpSecurityAttributes)
{
FIXME("(Name=%s, OpenMode=%#08lx, dwPipeMode=%#08lx, MaxInst=%ld, OutBSize=%ld, InBuffSize=%ld, DefTimeOut=%ld, SecAttr=%p): stub\n",
debugstr_a(lpName), dwOpenMode, dwPipeMode, nMaxInstances,
nOutBufferSize, nInBufferSize, nDefaultTimeOut, lpSecurityAttributes);
/* if (nMaxInstances > PIPE_UNLIMITED_INSTANCES) {
SetLastError (ERROR_INVALID_PARAMETER);
return INVALID_HANDLE_VALUE;
} */
SetLastError (ERROR_UNKNOWN);
return INVALID_HANDLE_VALUE;
}
/***********************************************************************
* CreateNamedPipeW (KERNEL32.169)
*/
HANDLE WINAPI CreateNamedPipeW (LPCWSTR lpName, DWORD dwOpenMode,
DWORD dwPipeMode, DWORD nMaxInstances,
DWORD nOutBufferSize, DWORD nInBufferSize,
DWORD nDefaultTimeOut,
LPSECURITY_ATTRIBUTES lpSecurityAttributes)
{
FIXME("(Name=%s, OpenMode=%#08lx, dwPipeMode=%#08lx, MaxInst=%ld, OutBSize=%ld, InBuffSize=%ld, DefTimeOut=%ld, SecAttr=%p): stub\n",
debugstr_w(lpName), dwOpenMode, dwPipeMode, nMaxInstances,
nOutBufferSize, nInBufferSize, nDefaultTimeOut, lpSecurityAttributes);
SetLastError (ERROR_UNKNOWN);
return INVALID_HANDLE_VALUE;
}
/***********************************************************************
* PeekNamedPipe (KERNEL32.552)
*/
BOOL WINAPI PeekNamedPipe (HANDLE hPipe,
LPVOID lpvBuffer, DWORD cbBuffer,
LPDWORD lpcbRead, LPDWORD lpcbAvail, LPDWORD lpcbMessage)
{
FIXME("(%08x, %p, %08lx, %p, %p, %p): stub\n",
hPipe, lpvBuffer, cbBuffer, lpcbRead, lpcbAvail, lpcbMessage);
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
/***********************************************************************
* GetSystemPowerStatus (KERNEL32.621)
*/

View File

@ -1,74 +0,0 @@
/*
* Win32 kernel functions
*
* Copyright 1995 Martin von Loewis
*/
#include <string.h>
#include <unistd.h>
#include <sys/times.h>
#include "winbase.h"
#include "winerror.h"
#include "heap.h"
#include "thread.h"
#include "process.h"
#include "file.h"
#include "task.h"
#include "toolhelp.h"
#include "debugtools.h"
DEFAULT_DEBUG_CHANNEL(win32);
/*********************************************************************
* Process_ClockTimeToFileTime
* (olorin@fandra.org, 20-Sep-1998)
* Converts clock_t into FILETIME.
* Used by GetProcessTime.
* Differences to UnixTimeToFileTime:
* 1) Divided by CLK_TCK
* 2) Time is relative. There is no 'starting date', so there is
* no need in offset correction, like in UnixTimeToFileTime
* FIXME: This function should be moved to a more appropriate .c file
* FIXME: On floating point operations, it is assumed that
* floating values are truncated on conversion to integer.
*/
void Process_ClockTimeToFileTime( clock_t unix_time, LPFILETIME filetime )
{
double td = (unix_time*10000000.0)/CLK_TCK;
/* Yes, double, because long int might overflow here. */
#if SIZEOF_LONG_LONG >= 8
unsigned long long t = td;
filetime->dwLowDateTime = (UINT) t;
filetime->dwHighDateTime = (UINT) (t >> 32);
#else
double divider = 1. * (1 << 16) * (1 << 16);
filetime->dwHighDateTime = (UINT) (td / divider);
filetime->dwLowDateTime = (UINT) (td - filetime->dwHighDateTime*divider);
/* using floor() produces wierd results, better leave this as it is
* ( with (UINT32) convertion )
*/
#endif
}
/*********************************************************************
* GetProcessTimes [KERNEL32.262]
*
* FIXME: lpCreationTime, lpExitTime are NOT INITIALIZED.
* olorin@fandra.org: Would be nice to substract the cpu time,
* used by Wine at startup.
* Also, there is a need to separate times
* used by different applications.
*/
BOOL WINAPI GetProcessTimes(
HANDLE hprocess,LPFILETIME lpCreationTime,LPFILETIME lpExitTime,
LPFILETIME lpKernelTime, LPFILETIME lpUserTime
) {
struct tms tms;
times(&tms);
Process_ClockTimeToFileTime(tms.tms_utime,lpUserTime);
Process_ClockTimeToFileTime(tms.tms_stime,lpKernelTime);
return TRUE;
}

View File

@ -14,20 +14,6 @@
DEFAULT_DEBUG_CHANNEL(win32)
/* maximum time adjustment in seconds for SetLocalTime and SetSystemTime */
#define SETTIME_MAX_ADJUST 120
/* TIME_GetBias: helper function calculates delta local time from UTC */
static int TIME_GetBias( time_t utc, int *pdaylight)
{
struct tm *ptm = localtime(&utc);
*pdaylight = ptm->tm_isdst; /* daylight for local timezone */
ptm = gmtime(&utc);
ptm->tm_isdst = *pdaylight; /* use local daylight, not that of Greenwich */
return (int)(utc-mktime(ptm));
}
/***********************************************************************
* GetLocalTime (KERNEL32.228)
*/
@ -51,69 +37,6 @@ VOID WINAPI GetLocalTime(LPSYSTEMTIME systime)
systime->wMilliseconds = (tv.tv_usec / 1000) % 1000;
}
/***********************************************************************
* SetLocalTime (KERNEL32.655)
*
* FIXME: correct ? Is the timezone param of settimeofday() needed ?
* I don't have any docu about SetLocal/SystemTime(), argl...
*/
BOOL WINAPI SetLocalTime(const SYSTEMTIME *systime)
{
struct timeval tv;
struct tm t;
time_t sec;
time_t oldsec=time(NULL);
int err;
/* get the number of seconds */
t.tm_sec = systime->wSecond;
t.tm_min = systime->wMinute;
t.tm_hour = systime->wHour;
t.tm_mday = systime->wDay;
t.tm_mon = systime->wMonth - 1;
t.tm_year = systime->wYear - 1900;
t.tm_isdst = -1;
sec = mktime (&t);
/* set the new time */
tv.tv_sec = sec;
tv.tv_usec = systime->wMilliseconds * 1000;
/* error and sanity check*/
if( sec == (time_t)-1 || abs((int)(sec-oldsec)) > SETTIME_MAX_ADJUST ){
err = 1;
SetLastError(ERROR_INVALID_PARAMETER);
} else {
err=settimeofday(&tv, NULL); /* 0 is OK, -1 is error */
if(err == 0)
return TRUE;
SetLastError(ERROR_PRIVILEGE_NOT_HELD);
}
ERR("Cannot set time to %d/%d/%d %d:%d:%d Time adjustment %ld %s\n",
systime->wYear, systime->wMonth, systime->wDay, systime->wHour,
systime->wMinute, systime->wSecond,
sec-oldsec, err == -1 ? "No Permission" :
sec==(time_t)-1 ? "" : "is too large." );
return FALSE;
}
/***********************************************************************
* GetSystemTimeAdjustment (KERNEL32.407)
*
*/
DWORD WINAPI GetSystemTimeAdjustment( LPDWORD lpTimeAdjustment,
LPDWORD lpTimeIncrement,
LPBOOL lpTimeAdjustmentDisabled )
{
*lpTimeAdjustment = 0;
*lpTimeIncrement = 0;
*lpTimeAdjustmentDisabled = TRUE;
return TRUE;
}
/***********************************************************************
* GetSystemTime (KERNEL32.285)
*/
@ -138,98 +61,6 @@ VOID WINAPI GetSystemTime(LPSYSTEMTIME systime)
}
/***********************************************************************
* SetSystemTime (KERNEL32.507)
*/
BOOL WINAPI SetSystemTime(const SYSTEMTIME *systime)
{
struct timeval tv;
struct timezone tz;
struct tm t;
time_t sec, oldsec;
int dst, bias;
int err;
/* call gettimeofday to get the current timezone */
gettimeofday(&tv, &tz);
oldsec=tv.tv_sec;
/* get delta local time from utc */
bias=TIME_GetBias(oldsec,&dst);
/* get the number of seconds */
t.tm_sec = systime->wSecond;
t.tm_min = systime->wMinute;
t.tm_hour = systime->wHour;
t.tm_mday = systime->wDay;
t.tm_mon = systime->wMonth - 1;
t.tm_year = systime->wYear - 1900;
t.tm_isdst = dst;
sec = mktime (&t);
/* correct for timezone and daylight */
sec += bias;
/* set the new time */
tv.tv_sec = sec;
tv.tv_usec = systime->wMilliseconds * 1000;
/* error and sanity check*/
if( sec == (time_t)-1 || abs((int)(sec-oldsec)) > SETTIME_MAX_ADJUST ){
err = 1;
SetLastError(ERROR_INVALID_PARAMETER);
} else {
err=settimeofday(&tv, NULL); /* 0 is OK, -1 is error */
if(err == 0)
return TRUE;
SetLastError(ERROR_PRIVILEGE_NOT_HELD);
}
ERR("Cannot set time to %d/%d/%d %d:%d:%d Time adjustment %ld %s\n",
systime->wYear, systime->wMonth, systime->wDay, systime->wHour,
systime->wMinute, systime->wSecond,
sec-oldsec, err == -1 ? "No Permission" :
sec==(time_t)-1 ? "" : "is too large." );
return FALSE;
}
/***********************************************************************
* GetTimeZoneInformation (KERNEL32.302)
*/
DWORD WINAPI GetTimeZoneInformation(LPTIME_ZONE_INFORMATION tzinfo)
{
time_t gmt;
int bias, daylight;
memset(tzinfo, 0, sizeof(TIME_ZONE_INFORMATION));
gmt = time(NULL);
bias=TIME_GetBias(gmt,&daylight);
tzinfo->Bias = -bias / 60;
tzinfo->StandardBias = 0;
tzinfo->DaylightBias = -60;
return TIME_ZONE_ID_UNKNOWN;
}
/***********************************************************************
* SetTimeZoneInformation (KERNEL32.515)
*/
BOOL WINAPI SetTimeZoneInformation(const LPTIME_ZONE_INFORMATION tzinfo)
{
struct timezone tz;
tz.tz_minuteswest = tzinfo->Bias;
#ifdef DST_NONE
tz.tz_dsttime = DST_NONE;
#else
tz.tz_dsttime = 0;
#endif
return !settimeofday(NULL, &tz);
}
/***********************************************************************
* GetSystemTimeAsFileTime (KERNEL32)
*/
@ -241,15 +72,3 @@ VOID WINAPI GetSystemTimeAsFileTime(LPFILETIME systemtimeAsfiletime)
DOSFS_UnixTimeToFileTime( now.tv_sec, systemtimeAsfiletime, now.tv_usec * 10 );
}
/***********************************************************************
* SystemTimeToTzSpecificLocalTime (KERNEL32.683)
*/
BOOL WINAPI SystemTimeToTzSpecificLocalTime(
LPTIME_ZONE_INFORMATION lpTimeZoneInformation,
LPSYSTEMTIME lpUniversalTime,
LPSYSTEMTIME lpLocalTime) {
FIXME(":stub\n");
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}