Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jason Beetham
wine
Commits
1abdb6f7
Commit
1abdb6f7
authored
24 years ago
by
Ove Kåven
Committed by
Alexandre Julliard
24 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Override fork().
parent
7827254c
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scheduler/pthread.c
+35
-4
35 additions, 4 deletions
scheduler/pthread.c
with
35 additions
and
4 deletions
scheduler/pthread.c
+
35
−
4
View file @
1abdb6f7
...
...
@@ -33,17 +33,32 @@
# define PREFIX
#endif
#define PSTR(str) PREFIX #str
/* adapt as necessary (a construct like this is used in glibc sources) */
#define strong_alias(orig, alias) \
asm(".globl " P
REFIX #
alias "\n\t.set " P
REFIX #
alias "," P
REFIX #
orig)
asm(".globl " P
STR(
alias
)
"\n\t.set " P
STR(
alias
)
"," P
STR(
orig)
)
/* strong_alias does not work on external symbols (.o format limitation?),
* so for those, we need to use the pogo stick */
#ifdef __i386__
#define jump_alias(orig, alias) \
asm(".globl " P
REFIX #
alias "\n\t" P
REFIX #
alias ":\n\tjmp " P
REFIX #
orig)
asm(".globl " P
STR(
alias
)
"\n\t" P
STR(
alias
)
":\n\tjmp " P
STR(
orig)
)
#endif
/* get necessary libc symbols */
#if (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 1)
#define LIBC_FORK __libc_fork
#define PTHREAD_FORK __fork
#define ALIAS_FORK
#else
#define LIBC_FORK __fork
#define PTHREAD_FORK fork
#endif
extern
pid_t
LIBC_FORK
(
void
);
#define LIBC_SIGACTION __sigaction
/* NOTE: This is a truly extremely incredibly ugly hack!
* But it does seem to work... */
...
...
@@ -102,6 +117,21 @@ int __pthread_atfork(void (*prepare)(void),
}
strong_alias
(
__pthread_atfork
,
pthread_atfork
);
pid_t
PTHREAD_FORK
(
void
)
{
pid_t
pid
;
/* call prepare handlers */
pid
=
LIBC_FORK
();
if
(
pid
==
0
)
{
/* call child handlers */
}
else
{
/* call parent handlers */
}
return
pid
;
}
#ifdef ALIAS_FORK
strong_alias
(
PTHREAD_FORK
,
fork
);
#endif
/***** MUTEXES *****/
...
...
@@ -354,6 +384,7 @@ int pthread_equal(pthread_t thread1, pthread_t thread2)
void
pthread_exit
(
void
*
retval
)
{
/* FIXME: pthread cleanup */
ExitThread
((
DWORD
)
retval
);
}
...
...
@@ -367,11 +398,11 @@ int pthread_setcanceltype(int type, int *oldtype)
/* pthreads tries to override these, point them back to libc */
#ifdef jump_alias
jump_alias
(
__sigaction
,
sigaction
);
jump_alias
(
LIBC_SIGACTION
,
sigaction
);
#else
int
sigaction
(
int
signum
,
const
struct
sigaction
*
act
,
struct
sigaction
*
oldact
)
{
return
__sigaction
(
signum
,
act
,
oldact
);
return
LIBC_SIGACTION
(
signum
,
act
,
oldact
);
}
#endif
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment