Commit 767970a0 authored by Zebediah Figura's avatar Zebediah Figura Committed by Vitaly Lipatov

ntdll, server: Implement NtCreateEvent().

parent 803cee46
......@@ -89,6 +89,13 @@ struct semaphore
};
C_ASSERT(sizeof(struct semaphore) == 8);
struct event
{
int signaled;
int locked;
};
C_ASSERT(sizeof(struct event) == 8);
static char shm_name[29];
static int shm_fd;
static void **shm_addrs;
......@@ -295,6 +302,18 @@ NTSTATUS esync_release_semaphore( HANDLE handle, ULONG count, ULONG *prev )
return STATUS_SUCCESS;
}
NTSTATUS esync_create_event( HANDLE *handle, ACCESS_MASK access,
const OBJECT_ATTRIBUTES *attr, EVENT_TYPE event_type, BOOLEAN initial )
{
enum esync_type type = (event_type == SynchronizationEvent ? ESYNC_AUTO_EVENT : ESYNC_MANUAL_EVENT);
TRACE("name %s, %s-reset, initial %d.\n",
attr ? debugstr_us(attr->ObjectName) : "<no name>",
event_type == NotificationEvent ? "manual" : "auto", initial);
return create_esync( type, handle, access, attr, initial, 0 );
}
#define TICKSPERSEC 10000000
#define TICKSPERMSEC 10000
......@@ -340,6 +359,14 @@ static void update_grabbed_object( struct esync *obj )
* etc. */
InterlockedExchangeAdd( &semaphore->count, -1 );
}
else if (obj->type == ESYNC_AUTO_EVENT)
{
struct event *event = obj->shm;
/* We don't have to worry about a race between this and read(), since
* this is just a hint, and the real state is in the kernel object.
* This might already be 0, but that's okay! */
event->signaled = 0;
}
}
/* A value of STATUS_NOT_IMPLEMENTED returned from this function means that we
......
......@@ -26,6 +26,9 @@ extern NTSTATUS esync_create_semaphore(HANDLE *handle, ACCESS_MASK access,
const OBJECT_ATTRIBUTES *attr, LONG initial, LONG max) DECLSPEC_HIDDEN;
extern NTSTATUS esync_release_semaphore( HANDLE handle, ULONG count, ULONG *prev ) DECLSPEC_HIDDEN;
extern NTSTATUS esync_create_event( HANDLE *handle, ACCESS_MASK access,
const OBJECT_ATTRIBUTES *attr, EVENT_TYPE type, BOOLEAN initial ) DECLSPEC_HIDDEN;
extern NTSTATUS esync_wait_objects( DWORD count, const HANDLE *handles, BOOLEAN wait_any,
BOOLEAN alertable, const LARGE_INTEGER *timeout ) DECLSPEC_HIDDEN;
......
......@@ -388,6 +388,10 @@ NTSTATUS WINAPI NtCreateEvent( HANDLE *handle, ACCESS_MASK access, const OBJECT_
*handle = 0;
if (type != NotificationEvent && type != SynchronizationEvent) return STATUS_INVALID_PARAMETER;
if (do_esync())
return esync_create_event( handle, access, attr, type, state );
if ((ret = alloc_object_attributes( attr, &objattr, &len ))) return ret;
SERVER_START_REQ( create_event )
......
......@@ -201,6 +201,13 @@ struct semaphore
};
C_ASSERT(sizeof(struct semaphore) == 8);
struct event
{
int signaled;
int locked;
};
C_ASSERT(sizeof(struct event) == 8);
struct esync *create_esync( struct object *root, const struct unicode_str *name,
unsigned int attr, int initval, int max, enum esync_type type,
const struct security_descriptor *sd )
......@@ -256,6 +263,14 @@ struct esync *create_esync( struct object *root, const struct unicode_str *name,
semaphore->count = initval;
break;
}
case ESYNC_AUTO_EVENT:
case ESYNC_MANUAL_EVENT:
{
struct event *event = get_shm( esync->shm_idx );
event->signaled = initval ? 1 : 0;
event->locked = 0;
break;
}
default:
assert( 0 );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment