Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
85423c6a
Commit
85423c6a
authored
Nov 08, 2000
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added new library.h header for libwine definitions.
Added getpagesize() and wine_anon_mmap() portability functions.
parent
8d1462b6
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
95 additions
and
45 deletions
+95
-45
library.h
include/wine/library.h
+30
-0
port.h
include/wine/port.h
+4
-0
port.c
library/port.c
+51
-0
virtual.c
memory/virtual.c
+9
-44
options.c
misc/options.c
+1
-1
No files found.
include/wine/library.h
0 → 100644
View file @
85423c6a
/*
* Definitions for the Wine library
*
* Copyright 2000 Alexandre Julliard
*/
#ifndef __WINE_WINE_LIBRARY_H
#define __WINE_WINE_LIBRARY_H
#include <sys/types.h>
/* dll loading */
struct
_IMAGE_NT_HEADERS
;
typedef
void
(
*
load_dll_callback_t
)(
const
struct
_IMAGE_NT_HEADERS
*
,
const
char
*
);
extern
void
wine_dll_set_callback
(
load_dll_callback_t
load
);
extern
void
*
wine_dll_load
(
const
char
*
filename
);
extern
void
wine_dll_unload
(
void
*
handle
);
/* debugging */
extern
void
wine_dbg_add_option
(
const
char
*
name
,
unsigned
char
set
,
unsigned
char
clear
);
/* portability */
extern
void
*
wine_anon_mmap
(
void
*
start
,
size_t
size
,
int
prot
,
int
flags
);
#endif
/* __WINE_WINE_LIBRARY_H */
include/wine/port.h
View file @
85423c6a
...
...
@@ -77,6 +77,10 @@ int getsockopt(int socket, int level, int option_name, void *option_value, size_
void
*
memmove
(
void
*
dest
,
const
void
*
src
,
unsigned
int
len
);
#endif
/* !defined(HAVE_MEMMOVE) */
#ifndef HAVE_GETPAGESIZE
size_t
getpagesize
(
void
);
#endif
/* HAVE_GETPAGESIZE */
#ifndef HAVE_INET_NETWORK
unsigned
long
inet_network
(
const
char
*
cp
);
#endif
/* !defined(HAVE_INET_NETWORK) */
...
...
library/port.c
View file @
85423c6a
...
...
@@ -23,6 +23,9 @@
#include <errno.h>
#include <fcntl.h>
#include <termios.h>
#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h>
#endif
#ifdef HAVE_LIBIO_H
# include <libio.h>
#endif
...
...
@@ -103,6 +106,22 @@ const char *strerror( int err )
}
#endif
/* HAVE_STRERROR */
/***********************************************************************
* getpagesize
*/
#ifndef HAVE_GETPAGESIZE
size_t
getpagesize
(
void
)
{
# ifdef __svr4__
return
sysconf
(
_SC_PAGESIZE
);
# else
# error Cannot get the page size on this platform
# endif
}
#endif
/* HAVE_GETPAGESIZE */
/***********************************************************************
* clone
*/
...
...
@@ -339,3 +358,35 @@ int statfs(const char *name, struct statfs *info)
#endif
/* defined(__BEOS__) */
}
#endif
/* !defined(HAVE_STATFS) */
/***********************************************************************
* wine_anon_mmap
*
* Portable wrapper for anonymous mmaps
*/
void
*
wine_anon_mmap
(
void
*
start
,
size_t
size
,
int
prot
,
int
flags
)
{
static
int
fdzero
=
-
1
;
#ifdef MAP_ANON
flags
|=
MAP_ANON
;
#else
if
(
fdzero
==
-
1
)
{
if
((
fdzero
=
open
(
"/dev/zero"
,
O_RDONLY
))
==
-
1
)
{
perror
(
"/dev/zero: open"
);
exit
(
1
);
}
}
#endif
/* MAP_ANON */
/* Linux EINVAL's on us if we don't pass MAP_PRIVATE to an anon mmap */
#ifdef MAP_SHARED
flags
&=
~
MAP_SHARED
;
#endif
#ifdef MAP_PRIVATE
flags
|=
MAP_PRIVATE
;
#endif
return
mmap
(
start
,
size
,
prot
,
flags
,
fdzero
,
0
);
}
memory/virtual.c
View file @
85423c6a
...
...
@@ -24,6 +24,8 @@
#include "winbase.h"
#include "wine/exception.h"
#include "wine/unicode.h"
#include "wine/library.h"
#include "wine/port.h"
#include "winerror.h"
#include "file.h"
#include "process.h"
...
...
@@ -433,10 +435,10 @@ static LPVOID map_image( HANDLE hmapping, int fd, char *base, DWORD total_size,
/* zero-map the whole range */
if
((
ptr
=
VIRTUAL_mmap
(
-
1
,
base
,
total_size
,
0
,
if
((
ptr
=
wine_anon_mmap
(
base
,
total_size
,
PROT_READ
|
PROT_WRITE
|
PROT_EXEC
,
0
))
==
(
char
*
)
-
1
)
{
ptr
=
VIRTUAL_mmap
(
-
1
,
NULL
,
total_size
,
0
,
ptr
=
wine_anon_mmap
(
NULL
,
total_size
,
PROT_READ
|
PROT_WRITE
|
PROT_EXEC
,
0
);
if
(
ptr
==
(
char
*
)
-
1
)
{
...
...
@@ -580,15 +582,7 @@ static LPVOID map_image( HANDLE hmapping, int fd, char *base, DWORD total_size,
#ifndef page_mask
DECL_GLOBAL_CONSTRUCTOR
(
VIRTUAL_Init
)
{
# ifdef HAVE_GETPAGESIZE
page_size
=
getpagesize
();
# else
# ifdef __svr4__
page_size
=
sysconf
(
_SC_PAGESIZE
);
# else
# error Cannot get the page size on this platform
# endif
# endif
page_mask
=
page_size
-
1
;
/* Make sure we have a power of 2 */
assert
(
!
(
page_size
&
page_mask
)
);
...
...
@@ -668,39 +662,13 @@ DWORD VIRTUAL_HandleFault( LPCVOID addr )
* Wrapper for mmap() that handles anonymous mappings portably,
* and falls back to read if mmap of a file fails.
*/
LPVOID
VIRTUAL_mmap
(
int
unix_handle
,
LPVOID
start
,
DWORD
size
,
LPVOID
VIRTUAL_mmap
(
int
fd
,
LPVOID
start
,
DWORD
size
,
DWORD
offset
,
int
prot
,
int
flags
)
{
int
fd
=
-
1
;
int
pos
;
LPVOID
ret
;
if
(
unix_handle
==
-
1
)
{
#ifdef MAP_ANON
flags
|=
MAP_ANON
;
#else
static
int
fdzero
=
-
1
;
if
(
fdzero
==
-
1
)
{
if
((
fdzero
=
open
(
"/dev/zero"
,
O_RDONLY
))
==
-
1
)
{
perror
(
"/dev/zero: open"
);
ExitProcess
(
1
);
}
}
fd
=
fdzero
;
#endif
/* MAP_ANON */
/* Linux EINVAL's on us if we don't pass MAP_PRIVATE to an anon mmap */
#ifdef MAP_SHARED
flags
&=
~
MAP_SHARED
;
#endif
#ifdef MAP_PRIVATE
flags
|=
MAP_PRIVATE
;
#endif
}
else
fd
=
unix_handle
;
if
(
fd
==
-
1
)
return
wine_anon_mmap
(
start
,
size
,
prot
,
flags
);
if
((
ret
=
mmap
(
start
,
size
,
prot
,
flags
,
fd
,
offset
))
!=
(
LPVOID
)
-
1
)
return
ret
;
...
...
@@ -709,7 +677,6 @@ LPVOID VIRTUAL_mmap( int unix_handle, LPVOID start, DWORD size,
/* page-aligned (EINVAL), or because the underlying filesystem */
/* does not support mmap() (ENOEXEC,ENODEV), we do it by hand. */
if
(
unix_handle
==
-
1
)
return
ret
;
if
((
errno
!=
ENOEXEC
)
&&
(
errno
!=
EINVAL
)
&&
(
errno
!=
ENODEV
))
return
ret
;
if
(
prot
&
PROT_WRITE
)
{
...
...
@@ -723,7 +690,7 @@ LPVOID VIRTUAL_mmap( int unix_handle, LPVOID start, DWORD size,
}
/* Reserve the memory with an anonymous mmap */
ret
=
VIRTUAL_mmap
(
-
1
,
start
,
size
,
0
,
PROT_READ
|
PROT_WRITE
,
flags
);
ret
=
wine_anon_mmap
(
start
,
size
,
PROT_READ
|
PROT_WRITE
,
flags
);
if
(
ret
==
(
LPVOID
)
-
1
)
return
ret
;
/* Now read in the file */
if
((
pos
=
lseek
(
fd
,
offset
,
SEEK_SET
))
==
-
1
)
...
...
@@ -814,8 +781,7 @@ LPVOID WINAPI VirtualAlloc(
if
(
type
&
MEM_SYSTEM
)
ptr
=
base
;
else
ptr
=
(
UINT
)
VIRTUAL_mmap
(
-
1
,
(
LPVOID
)
base
,
view_size
,
0
,
VIRTUAL_GetUnixProt
(
vprot
),
0
);
ptr
=
(
UINT
)
wine_anon_mmap
(
(
LPVOID
)
base
,
view_size
,
VIRTUAL_GetUnixProt
(
vprot
),
0
);
if
(
ptr
==
(
UINT
)
-
1
)
{
SetLastError
(
ERROR_OUTOFMEMORY
);
...
...
@@ -941,8 +907,7 @@ BOOL WINAPI VirtualFree(
/* Decommit the pages by remapping zero-pages instead */
if
(
VIRTUAL_mmap
(
-
1
,
(
LPVOID
)
base
,
size
,
0
,
VIRTUAL_GetUnixProt
(
0
),
MAP_FIXED
)
!=
(
LPVOID
)
base
)
if
(
wine_anon_mmap
(
(
LPVOID
)
base
,
size
,
VIRTUAL_GetUnixProt
(
0
),
MAP_FIXED
)
!=
(
LPVOID
)
base
)
ERR
(
"Could not remap pages, expect trouble
\n
"
);
return
VIRTUAL_SetProt
(
view
,
base
,
size
,
0
);
}
...
...
misc/options.c
View file @
85423c6a
...
...
@@ -9,6 +9,7 @@
#include <stdlib.h>
#include "winbase.h"
#include "wine/library.h"
#include "main.h"
#include "options.h"
#include "version.h"
...
...
@@ -160,7 +161,6 @@ static void do_config( const char *arg )
static
void
do_debugmsg
(
const
char
*
arg
)
{
extern
void
wine_dbg_add_option
(
const
char
*
name
,
unsigned
char
set
,
unsigned
char
clear
);
static
const
char
*
const
debug_class_names
[
__DBCL_COUNT
]
=
{
"fixme"
,
"err"
,
"warn"
,
"trace"
};
char
*
opt
,
*
options
=
strdup
(
arg
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment