Skip to content

Commit 8dfcad1

Browse files
zfiguraGuy1524
authored andcommitted
ntdll, server: Specify EFD_SEMAPHORE on the server side.
This just makes things cleaner; since we already pass the type to the server there's no reason to pass this as well.
1 parent 49ffbbe commit 8dfcad1

File tree

6 files changed

+17
-25
lines changed

6 files changed

+17
-25
lines changed

dlls/ntdll/esync.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@
3333
#include <stdint.h>
3434
#include <stdlib.h>
3535
#include <stdio.h>
36-
#ifdef HAVE_SYS_EVENTFD_H
37-
# include <sys/eventfd.h>
38-
#endif
3936
#ifdef HAVE_SYS_MMAN_H
4037
# include <sys/mman.h>
4138
#endif
@@ -52,10 +49,6 @@
5249
#include "ntdll_misc.h"
5350
#include "esync.h"
5451

55-
#ifndef EFD_SEMAPHORE
56-
#define EFD_SEMAPHORE 1
57-
#endif
58-
5952
WINE_DEFAULT_DEBUG_CHANNEL(esync);
6053

6154
int do_esync(void)
@@ -116,7 +109,7 @@ static int shm_addrs_size; /* length of the allocated shm_addrs array */
116109
static long pagesize;
117110

118111
static NTSTATUS create_esync( enum esync_type type, HANDLE *handle,
119-
ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr, int initval, int flags );
112+
ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr, int initval );
120113

121114
void esync_init(void)
122115
{
@@ -128,7 +121,7 @@ void esync_init(void)
128121
HANDLE handle;
129122
NTSTATUS ret;
130123

131-
ret = create_esync( 0, &handle, 0, NULL, 0, 0 );
124+
ret = create_esync( 0, &handle, 0, NULL, 0 );
132125
if (ret != STATUS_NOT_IMPLEMENTED)
133126
{
134127
ERR("Server is running with WINEESYNC but this process is not, please enable WINEESYNC or restart wineserver.\n");
@@ -327,7 +320,7 @@ NTSTATUS esync_close( HANDLE handle )
327320
}
328321

329322
static NTSTATUS create_esync( enum esync_type type, HANDLE *handle,
330-
ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr, int initval, int flags )
323+
ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr, int initval )
331324
{
332325
NTSTATUS ret;
333326
data_size_t len;
@@ -346,7 +339,6 @@ static NTSTATUS create_esync( enum esync_type type, HANDLE *handle,
346339
{
347340
req->access = access;
348341
req->initval = initval;
349-
req->flags = flags;
350342
req->type = type;
351343
wine_server_add_data( req, objattr, len );
352344
ret = wine_server_call( req );
@@ -438,7 +430,7 @@ NTSTATUS esync_create_semaphore(HANDLE *handle, ACCESS_MASK access,
438430
* before anyone else can open the object. */
439431
RtlEnterCriticalSection( &shm_init_section );
440432

441-
ret = create_esync( ESYNC_SEMAPHORE, handle, access, attr, initial, EFD_SEMAPHORE );
433+
ret = create_esync( ESYNC_SEMAPHORE, handle, access, attr, initial );
442434
if (!ret)
443435
{
444436
/* Initialize the shared memory portion.
@@ -539,7 +531,7 @@ NTSTATUS esync_create_event( HANDLE *handle, ACCESS_MASK access,
539531

540532
RtlEnterCriticalSection( &shm_init_section );
541533

542-
ret = create_esync( type, handle, access, attr, initial, 0 );
534+
ret = create_esync( type, handle, access, attr, initial );
543535

544536
if (!ret)
545537
{
@@ -755,7 +747,7 @@ NTSTATUS esync_create_mutex( HANDLE *handle, ACCESS_MASK access,
755747

756748
RtlEnterCriticalSection( &shm_init_section );
757749

758-
ret = create_esync( ESYNC_MUTEX, handle, access, attr, initial ? 0 : 1, 0 );
750+
ret = create_esync( ESYNC_MUTEX, handle, access, attr, initial ? 0 : 1 );
759751
if (!ret)
760752
{
761753
/* Initialize the shared memory portion. */

include/wine/server_protocol.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5943,10 +5943,8 @@ struct create_esync_request
59435943
struct request_header __header;
59445944
unsigned int access;
59455945
int initval;
5946-
int flags;
59475946
int type;
59485947
/* VARARG(objattr,object_attributes); */
5949-
char __pad_28[4];
59505948
};
59515949
struct create_esync_reply
59525950
{
@@ -6961,7 +6959,7 @@ union generic_reply
69616959

69626960
/* ### protocol_version begin ### */
69636961

6964-
#define SERVER_PROTOCOL_VERSION 624
6962+
#define SERVER_PROTOCOL_VERSION 625
69656963

69666964
/* ### protocol_version end ### */
69676965

server/esync.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ static int type_matches( enum esync_type type1, enum esync_type type2 )
179179
}
180180

181181
static struct esync *create_esync( struct object *root, const struct unicode_str *name,
182-
unsigned int attr, int initval, int flags, enum esync_type type,
182+
unsigned int attr, int initval, enum esync_type type,
183183
const struct security_descriptor *sd )
184184
{
185185
#ifdef HAVE_SYS_EVENTFD_H
@@ -189,8 +189,13 @@ static struct esync *create_esync( struct object *root, const struct unicode_str
189189
{
190190
if (get_error() != STATUS_OBJECT_NAME_EXISTS)
191191
{
192+
int flags = EFD_CLOEXEC | EFD_NONBLOCK;
193+
194+
if (type == ESYNC_SEMAPHORE)
195+
flags |= EFD_SEMAPHORE;
196+
192197
/* initialize it if it didn't already exist */
193-
esync->fd = eventfd( initval, flags | EFD_CLOEXEC | EFD_NONBLOCK );
198+
esync->fd = eventfd( initval, flags );
194199
if (esync->fd == -1)
195200
{
196201
perror( "eventfd" );
@@ -408,7 +413,7 @@ DECL_HANDLER(create_esync)
408413

409414
if (!objattr) return;
410415

411-
if ((esync = create_esync( root, &name, objattr->attributes, req->initval, req->flags, req->type, sd )))
416+
if ((esync = create_esync( root, &name, objattr->attributes, req->initval, req->type, sd )))
412417
{
413418
if (get_error() == STATUS_OBJECT_NAME_EXISTS)
414419
reply->handle = alloc_handle( current->process, esync, req->access, objattr->attributes );

server/protocol.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4045,7 +4045,6 @@ struct handle_info
40454045
@REQ(create_esync)
40464046
unsigned int access; /* wanted access rights */
40474047
int initval; /* initial value */
4048-
int flags; /* flags (EFD_SEMAPHORE or 0) */
40494048
int type; /* type of esync object (see below) */
40504049
VARARG(objattr,object_attributes); /* object attributes */
40514050
@REPLY

server/request.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2512,9 +2512,8 @@ C_ASSERT( FIELD_OFFSET(struct get_system_info_reply, handles) == 16 );
25122512
C_ASSERT( sizeof(struct get_system_info_reply) == 24 );
25132513
C_ASSERT( FIELD_OFFSET(struct create_esync_request, access) == 12 );
25142514
C_ASSERT( FIELD_OFFSET(struct create_esync_request, initval) == 16 );
2515-
C_ASSERT( FIELD_OFFSET(struct create_esync_request, flags) == 20 );
2516-
C_ASSERT( FIELD_OFFSET(struct create_esync_request, type) == 24 );
2517-
C_ASSERT( sizeof(struct create_esync_request) == 32 );
2515+
C_ASSERT( FIELD_OFFSET(struct create_esync_request, type) == 20 );
2516+
C_ASSERT( sizeof(struct create_esync_request) == 24 );
25182517
C_ASSERT( FIELD_OFFSET(struct create_esync_reply, handle) == 8 );
25192518
C_ASSERT( FIELD_OFFSET(struct create_esync_reply, type) == 12 );
25202519
C_ASSERT( FIELD_OFFSET(struct create_esync_reply, shm_idx) == 16 );

server/trace.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4698,7 +4698,6 @@ static void dump_create_esync_request( const struct create_esync_request *req )
46984698
{
46994699
fprintf( stderr, " access=%08x", req->access );
47004700
fprintf( stderr, ", initval=%d", req->initval );
4701-
fprintf( stderr, ", flags=%d", req->flags );
47024701
fprintf( stderr, ", type=%d", req->type );
47034702
dump_varargs_object_attributes( ", objattr=", cur_size );
47044703
}

0 commit comments

Comments
 (0)