Commit 2051acb1 authored by Zebediah Figura's avatar Zebediah Figura Committed by Vitaly Lipatov

ntdll, server: Implement NtCreateMutant().

parent bdbdf5dd
......@@ -84,6 +84,13 @@ struct semaphore
};
C_ASSERT(sizeof(struct semaphore) == 8);
struct mutex
{
DWORD tid;
int count; /* recursion count */
};
C_ASSERT(sizeof(struct mutex) == 8);
struct event
{
int signaled;
......@@ -408,6 +415,15 @@ NTSTATUS esync_reset_event( HANDLE handle )
return STATUS_SUCCESS;
}
NTSTATUS esync_create_mutex( HANDLE *handle, ACCESS_MASK access,
const OBJECT_ATTRIBUTES *attr, BOOLEAN initial )
{
TRACE("name %s, initial %d.\n",
attr ? debugstr_us(attr->ObjectName) : "<no name>", initial);
return create_esync( ESYNC_MUTEX, handle, access, attr, initial ? 0 : 1, 0 );
}
#define TICKSPERSEC 10000000
#define TICKSPERMSEC 10000
......
......@@ -31,6 +31,9 @@ extern NTSTATUS esync_create_event( HANDLE *handle, ACCESS_MASK access,
extern NTSTATUS esync_reset_event( HANDLE handle ) DECLSPEC_HIDDEN;
extern NTSTATUS esync_set_event( HANDLE handle ) DECLSPEC_HIDDEN;
extern NTSTATUS esync_create_mutex( HANDLE *handle, ACCESS_MASK access,
const OBJECT_ATTRIBUTES *attr, 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;
......
......@@ -556,6 +556,10 @@ NTSTATUS WINAPI NtCreateMutant( HANDLE *handle, ACCESS_MASK access, const OBJECT
struct object_attributes *objattr;
*handle = 0;
if (do_esync())
return esync_create_mutex( handle, access, attr, owned );
if ((ret = alloc_object_attributes( attr, &objattr, &len ))) return ret;
SERVER_START_REQ( create_mutex )
......
......@@ -202,6 +202,13 @@ struct semaphore
};
C_ASSERT(sizeof(struct semaphore) == 8);
struct mutex
{
DWORD tid;
int count; /* recursion count */
};
C_ASSERT(sizeof(struct mutex) == 8);
struct event
{
int signaled;
......@@ -272,6 +279,13 @@ struct esync *create_esync( struct object *root, const struct unicode_str *name,
event->locked = 0;
break;
}
case ESYNC_MUTEX:
{
struct mutex *mutex = get_shm( esync->shm_idx );
mutex->tid = initval ? 0 : current->id;
mutex->count = initval ? 0 : 1;
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