Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
96d60c41
Commit
96d60c41
authored
Dec 03, 1993
by
Sjoerd Mullender
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port to Solaris 2.3.
parent
77ca7c6b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
203 additions
and
45 deletions
+203
-45
Modules/md5module.c
Modules/md5module.c
+1
-3
Modules/sunaudiodev.c
Modules/sunaudiodev.c
+37
-2
Modules/threadmodule.c
Modules/threadmodule.c
+1
-1
Python/thread.c
Python/thread.c
+164
-39
No files found.
Modules/md5module.c
View file @
96d60c41
...
@@ -41,8 +41,6 @@ extern typeobject MD5type; /* Really static, forward */
...
@@ -41,8 +41,6 @@ extern typeobject MD5type; /* Really static, forward */
#define is_md5object(v) ((v)->ob_type == &MD5type)
#define is_md5object(v) ((v)->ob_type == &MD5type)
static
const
char
initialiser_name
[]
=
"md5"
;
/* #define MD5_DEBUG */
/* #define MD5_DEBUG */
static
md5object
*
static
md5object
*
...
@@ -207,7 +205,7 @@ typeobject MD5type = {
...
@@ -207,7 +205,7 @@ typeobject MD5type = {
/* List of functions exported by this module */
/* List of functions exported by this module */
static
struct
methodlist
md5_functions
[]
=
{
static
struct
methodlist
md5_functions
[]
=
{
{
initialiser_name
,
MD5_md5
},
{
"md5"
,
MD5_md5
},
{
NULL
,
NULL
}
/* Sentinel */
{
NULL
,
NULL
}
/* Sentinel */
};
};
...
...
Modules/sunaudiodev.c
View file @
96d60c41
...
@@ -30,7 +30,11 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
...
@@ -30,7 +30,11 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <stropts.h>
#include <stropts.h>
#include <sys/ioctl.h>
#include <sys/ioctl.h>
#ifdef SOLARIS
#include <multimedia/libaudio.h>
#else
#include <sun/audioio.h>
#include <sun/audioio.h>
#endif
/* #define offsetof(str,mem) ((int)(((str *)0)->mem)) */
/* #define offsetof(str,mem) ((int)(((str *)0)->mem)) */
...
@@ -50,7 +54,7 @@ typedef struct {
...
@@ -50,7 +54,7 @@ typedef struct {
extern
typeobject
Sadtype
;
/* Really static, forward */
extern
typeobject
Sadtype
;
/* Really static, forward */
extern
typeobject
Sadstatustype
;
/* Really static, forward */
extern
typeobject
Sadstatustype
;
/* Really static, forward */
extern
sadstatusobject
*
sads_alloc
();
/* Forward */
static
sadstatusobject
*
sads_alloc
();
/* Forward */
static
object
*
SunAudioError
;
static
object
*
SunAudioError
;
...
@@ -256,6 +260,24 @@ sad_drain(self, args)
...
@@ -256,6 +260,24 @@ sad_drain(self, args)
return
None
;
return
None
;
}
}
#ifdef SOLARIS
static
object
*
sad_getdev
(
self
,
args
)
sadobject
*
self
;
object
*
args
;
{
struct
audio_device
ad
;
if
(
!
getargs
(
args
,
""
)
)
return
0
;
if
(
ioctl
(
self
->
x_fd
,
AUDIO_GETDEV
,
&
ad
)
<
0
)
{
err_errno
(
SunAudioError
);
return
NULL
;
}
return
mkvalue
(
"(sss)"
,
ad
.
name
,
ad
.
version
,
ad
.
config
);
}
#endif
static
object
*
static
object
*
sad_flush
(
self
,
args
)
sad_flush
(
self
,
args
)
sadobject
*
self
;
sadobject
*
self
;
...
@@ -298,6 +320,9 @@ static struct methodlist sad_methods[] = {
...
@@ -298,6 +320,9 @@ static struct methodlist sad_methods[] = {
{
"setinfo"
,
sad_setinfo
},
{
"setinfo"
,
sad_setinfo
},
{
"drain"
,
sad_drain
},
{
"drain"
,
sad_drain
},
{
"flush"
,
sad_flush
},
{
"flush"
,
sad_flush
},
#ifdef SOLARIS
{
"getdev"
,
sad_getdev
},
#endif
{
"close"
,
sad_close
},
{
"close"
,
sad_close
},
{
NULL
,
NULL
}
/* sentinel */
{
NULL
,
NULL
}
/* sentinel */
};
};
...
@@ -345,6 +370,11 @@ static struct memberlist sads_ml[] = {
...
@@ -345,6 +370,11 @@ static struct memberlist sads_ml[] = {
{
"i_waiting"
,
T_UBYTE
,
OFF
(
record
.
waiting
)
},
{
"i_waiting"
,
T_UBYTE
,
OFF
(
record
.
waiting
)
},
{
"i_open"
,
T_UBYTE
,
OFF
(
record
.
open
)
,
RO
},
{
"i_open"
,
T_UBYTE
,
OFF
(
record
.
open
)
,
RO
},
{
"i_active"
,
T_UBYTE
,
OFF
(
record
.
active
)
,
RO
},
{
"i_active"
,
T_UBYTE
,
OFF
(
record
.
active
)
,
RO
},
#ifdef SOLARIS
{
"i_buffer_size"
,
T_UINT
,
OFF
(
record
.
buffer_size
)
},
{
"i_balance"
,
T_UBYTE
,
OFF
(
record
.
balance
)
},
{
"i_avail_ports"
,
T_UINT
,
OFF
(
record
.
avail_ports
)
},
#endif
{
"o_sample_rate"
,
T_UINT
,
OFF
(
play
.
sample_rate
)
},
{
"o_sample_rate"
,
T_UINT
,
OFF
(
play
.
sample_rate
)
},
{
"o_channels"
,
T_UINT
,
OFF
(
play
.
channels
)
},
{
"o_channels"
,
T_UINT
,
OFF
(
play
.
channels
)
},
...
@@ -359,6 +389,11 @@ static struct memberlist sads_ml[] = {
...
@@ -359,6 +389,11 @@ static struct memberlist sads_ml[] = {
{
"o_waiting"
,
T_UBYTE
,
OFF
(
play
.
waiting
)
},
{
"o_waiting"
,
T_UBYTE
,
OFF
(
play
.
waiting
)
},
{
"o_open"
,
T_UBYTE
,
OFF
(
play
.
open
)
,
RO
},
{
"o_open"
,
T_UBYTE
,
OFF
(
play
.
open
)
,
RO
},
{
"o_active"
,
T_UBYTE
,
OFF
(
play
.
active
)
,
RO
},
{
"o_active"
,
T_UBYTE
,
OFF
(
play
.
active
)
,
RO
},
#ifdef SOLARIS
{
"o_buffer_size"
,
T_UINT
,
OFF
(
play
.
buffer_size
)
},
{
"o_balance"
,
T_UBYTE
,
OFF
(
play
.
balance
)
},
{
"o_avail_ports"
,
T_UINT
,
OFF
(
play
.
avail_ports
)
},
#endif
{
"monitor_gain"
,
T_UINT
,
OFF
(
monitor_gain
)
},
{
"monitor_gain"
,
T_UINT
,
OFF
(
monitor_gain
)
},
{
NULL
,
0
,
0
},
{
NULL
,
0
,
0
},
...
@@ -382,7 +417,7 @@ sads_setattr(xp, name, v)
...
@@ -382,7 +417,7 @@ sads_setattr(xp, name, v)
if
(
v
==
NULL
)
{
if
(
v
==
NULL
)
{
err_setstr
(
TypeError
,
err_setstr
(
TypeError
,
"can't delete sun audio status attributes"
);
"can't delete sun audio status attributes"
);
return
NULL
;
return
0
;
}
}
return
setmember
((
char
*
)
&
xp
->
ai
,
sads_ml
,
name
,
v
);
return
setmember
((
char
*
)
&
xp
->
ai
,
sads_ml
,
name
,
v
);
}
}
...
...
Modules/threadmodule.c
View file @
96d60c41
...
@@ -195,7 +195,7 @@ t_bootstrap(args_raw)
...
@@ -195,7 +195,7 @@ t_bootstrap(args_raw)
func
=
gettupleitem
(
args
,
0
);
func
=
gettupleitem
(
args
,
0
);
arg
=
gettupleitem
(
args
,
1
);
arg
=
gettupleitem
(
args
,
1
);
res
=
call_object
(
func
,
arg
);
res
=
call_object
(
func
,
arg
);
DECREF
(
arg
);
/* Matches the INCREF(arg
) in thread_start_new_thread */
DECREF
(
arg
s
);
/* Matches the INCREF(args
) in thread_start_new_thread */
if
(
res
==
NULL
)
{
if
(
res
==
NULL
)
{
fprintf
(
stderr
,
"Unhandled exception in thread:
\n
"
);
fprintf
(
stderr
,
"Unhandled exception in thread:
\n
"
);
print_error
();
/* From pythonmain.c */
print_error
();
/* From pythonmain.c */
...
...
Python/thread.c
View file @
96d60c41
...
@@ -26,9 +26,11 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
...
@@ -26,9 +26,11 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifdef DEBUG
#ifdef DEBUG
static
int
thread_debug
=
0
;
static
int
thread_debug
=
0
;
#define dprintf(args) (thread_debug && printf args)
#define dprintf(args) ((thread_debug & 1) && printf args)
#define d2printf(args) ((thread_debug & 8) && printf args)
#else
#else
#define dprintf(args)
#define dprintf(args)
#define d2printf(args)
#endif
#endif
#ifdef __sgi
#ifdef __sgi
...
@@ -43,7 +45,7 @@ static int thread_debug = 0;
...
@@ -43,7 +45,7 @@ static int thread_debug = 0;
#define HDR_SIZE 2680
/* sizeof(ushdr_t) */
#define HDR_SIZE 2680
/* sizeof(ushdr_t) */
#define MAXPROC 100
/* max # of threads that can be started */
#define MAXPROC 100
/* max # of threads that can be started */
/*static*/
usptr_t
*
shared_arena
;
static
usptr_t
*
shared_arena
;
static
ulock_t
count_lock
;
/* protection for some variables */
static
ulock_t
count_lock
;
/* protection for some variables */
static
ulock_t
wait_lock
;
/* lock used to wait for other threads */
static
ulock_t
wait_lock
;
/* lock used to wait for other threads */
static
int
waiting_for_threads
;
/* protected by count_lock */
static
int
waiting_for_threads
;
/* protected by count_lock */
...
@@ -54,6 +56,13 @@ static int exiting; /* we're already exiting (for maybe_exit) */
...
@@ -54,6 +56,13 @@ static int exiting; /* we're already exiting (for maybe_exit) */
static
pid_t
my_pid
;
/* PID of main thread */
static
pid_t
my_pid
;
/* PID of main thread */
static
pid_t
pidlist
[
MAXPROC
];
/* PIDs of other threads */
static
pid_t
pidlist
[
MAXPROC
];
/* PIDs of other threads */
static
int
maxpidindex
;
/* # of PIDs in pidlist */
static
int
maxpidindex
;
/* # of PIDs in pidlist */
#endif
/* __sgi */
#ifdef SOLARIS
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include </usr/include/thread.h>
#undef sun
#endif
#endif
#ifdef sun
#ifdef sun
#include <lwp/lwp.h>
#include <lwp/lwp.h>
...
@@ -67,10 +76,13 @@ struct lock {
...
@@ -67,10 +76,13 @@ struct lock {
cv_t
lock_condvar
;
cv_t
lock_condvar
;
mon_t
lock_monitor
;
mon_t
lock_monitor
;
};
};
#endif
#endif
/* sun */
#ifdef C_THREADS
#ifdef C_THREADS
#include <cthreads.h>
#include <cthreads.h>
#endif
#endif
/* C_THREADS */
#ifdef _POSIX_THREADS
#include <pthread.h>
#endif
/* _POSIX_THREADS */
#ifdef __STDC__
#ifdef __STDC__
#define _P(args) args
#define _P(args) args
...
@@ -82,7 +94,7 @@ struct lock {
...
@@ -82,7 +94,7 @@ struct lock {
#define _P0() ()
#define _P0() ()
#define _P1(v,t) (v) t;
#define _P1(v,t) (v) t;
#define _P2(v1,t1,v2,t2) (v1,v2) t1; t2;
#define _P2(v1,t1,v2,t2) (v1,v2) t1; t2;
#endif
#endif
/* __STDC__ */
static
int
initialized
;
static
int
initialized
;
...
@@ -94,13 +106,17 @@ static int initialized;
...
@@ -94,13 +106,17 @@ static int initialized;
*/
*/
static
void
exit_sig
_P0
()
static
void
exit_sig
_P0
()
{
{
dprintf
((
"exit_sig called
\n
"
));
d
2
printf
((
"exit_sig called
\n
"
));
if
(
exiting
&&
getpid
()
==
my_pid
)
{
if
(
exiting
&&
getpid
()
==
my_pid
)
{
dprintf
((
"already exiting
\n
"
));
d
2
printf
((
"already exiting
\n
"
));
return
;
return
;
}
}
if
(
do_exit
)
{
if
(
do_exit
)
{
dprintf
((
"exiting in exit_sig
\n
"
));
d2printf
((
"exiting in exit_sig
\n
"
));
#ifdef DEBUG
if
((
thread_debug
&
8
)
==
0
)
thread_debug
&=
~
1
;
/* don't produce debug messages */
#endif
exit_thread
();
exit_thread
();
}
}
}
}
...
@@ -118,7 +134,7 @@ static void maybe_exit _P0()
...
@@ -118,7 +134,7 @@ static void maybe_exit _P0()
}
}
exit_prog
(
0
);
exit_prog
(
0
);
}
}
#endif
#endif
/* __sgi */
/*
/*
* Initialization.
* Initialization.
...
@@ -129,12 +145,19 @@ void init_thread _P0()
...
@@ -129,12 +145,19 @@ void init_thread _P0()
struct
sigaction
s
;
struct
sigaction
s
;
#ifdef USE_DL
#ifdef USE_DL
long
addr
,
size
;
long
addr
,
size
;
#endif
#endif
/* USE_DL */
#endif
#endif
/* __sgi */
#ifdef DEBUG
#ifdef DEBUG
thread_debug
=
getenv
(
"THREADDEBUG"
)
!=
0
;
char
*
p
=
getenv
(
"THREADDEBUG"
);
#endif
if
(
p
)
{
if
(
*
p
)
thread_debug
=
atoi
(
p
);
else
thread_debug
=
1
;
}
#endif
/* DEBUG */
if
(
initialized
)
if
(
initialized
)
return
;
return
;
initialized
=
1
;
initialized
=
1
;
...
@@ -151,7 +174,7 @@ void init_thread _P0()
...
@@ -151,7 +174,7 @@ void init_thread _P0()
errno
=
0
;
errno
=
0
;
if
((
addr
=
usconfig
(
CONF_ATTACHADDR
,
addr
))
<
0
&&
errno
!=
0
)
if
((
addr
=
usconfig
(
CONF_ATTACHADDR
,
addr
))
<
0
&&
errno
!=
0
)
perror
(
"usconfig - CONF_ATTACHADDR (set)"
);
perror
(
"usconfig - CONF_ATTACHADDR (set)"
);
#endif
#endif
/* USE_DL */
if
(
usconfig
(
CONF_INITUSERS
,
16
)
<
0
)
if
(
usconfig
(
CONF_INITUSERS
,
16
)
<
0
)
perror
(
"usconfig - CONF_INITUSERS"
);
perror
(
"usconfig - CONF_INITUSERS"
);
my_pid
=
getpid
();
/* so that we know which is the main thread */
my_pid
=
getpid
();
/* so that we know which is the main thread */
...
@@ -165,39 +188,72 @@ void init_thread _P0()
...
@@ -165,39 +188,72 @@ void init_thread _P0()
perror
(
"prctl - PR_SETEXITSIG"
);
perror
(
"prctl - PR_SETEXITSIG"
);
if
(
usconfig
(
CONF_ARENATYPE
,
US_SHAREDONLY
)
<
0
)
if
(
usconfig
(
CONF_ARENATYPE
,
US_SHAREDONLY
)
<
0
)
perror
(
"usconfig - CONF_ARENATYPE"
);
perror
(
"usconfig - CONF_ARENATYPE"
);
/*usconfig(CONF_LOCKTYPE, US_DEBUGPLUS);*/
#ifdef DEBUG
if
(
thread_debug
&
4
)
usconfig
(
CONF_LOCKTYPE
,
US_DEBUGPLUS
);
else
if
(
thread_debug
&
2
)
usconfig
(
CONF_LOCKTYPE
,
US_DEBUG
);
#endif
/* DEBUG */
if
((
shared_arena
=
usinit
(
tmpnam
(
0
)))
==
0
)
if
((
shared_arena
=
usinit
(
tmpnam
(
0
)))
==
0
)
perror
(
"usinit"
);
perror
(
"usinit"
);
#ifdef USE_DL
#ifdef USE_DL
if
(
usconfig
(
CONF_ATTACHADDR
,
addr
)
<
0
)
/* reset address */
if
(
usconfig
(
CONF_ATTACHADDR
,
addr
)
<
0
)
/* reset address */
perror
(
"usconfig - CONF_ATTACHADDR (reset)"
);
perror
(
"usconfig - CONF_ATTACHADDR (reset)"
);
#endif
#endif
/* USE_DL */
if
((
count_lock
=
usnewlock
(
shared_arena
))
==
NULL
)
if
((
count_lock
=
usnewlock
(
shared_arena
))
==
NULL
)
perror
(
"usnewlock (count_lock)"
);
perror
(
"usnewlock (count_lock)"
);
(
void
)
usinitlock
(
count_lock
);
(
void
)
usinitlock
(
count_lock
);
if
((
wait_lock
=
usnewlock
(
shared_arena
))
==
NULL
)
if
((
wait_lock
=
usnewlock
(
shared_arena
))
==
NULL
)
perror
(
"usnewlock (wait_lock)"
);
perror
(
"usnewlock (wait_lock)"
);
dprintf
((
"arena start: %lx, arena size: %ld
\n
"
,
(
long
)
shared_arena
,
(
long
)
usconfig
(
CONF_GETSIZE
,
shared_arena
)));
dprintf
((
"arena start: %lx, arena size: %ld
\n
"
,
(
long
)
shared_arena
,
(
long
)
usconfig
(
CONF_GETSIZE
,
shared_arena
)));
#endif
/* __sgi */
#ifdef SOLARIS
/* nothing */
#endif
#endif
#ifdef sun
#ifdef sun
lwp_setstkcache
(
STACKSIZE
,
NSTACKS
);
lwp_setstkcache
(
STACKSIZE
,
NSTACKS
);
#endif
#endif
/* sun */
#ifdef C_THREADS
#ifdef C_THREADS
cthread_init
();
cthread_init
();
#endif
#endif
/* C_THREADS */
}
}
/*
/*
* Thread support.
* Thread support.
*/
*/
#ifdef SOLARIS
struct
func_arg
{
void
(
*
func
)
_P
((
void
*
));
void
*
arg
;
};
static
void
*
new_func
_P1
(
funcarg
,
void
*
funcarg
)
{
void
(
*
func
)
_P
((
void
*
));
void
*
arg
;
func
=
((
struct
func_arg
*
)
funcarg
)
->
func
;
arg
=
((
struct
func_arg
*
)
funcarg
)
->
arg
;
free
(
funcarg
);
(
*
func
)(
arg
);
return
0
;
}
#endif
/* SOLARIS */
int
start_new_thread
_P2
(
func
,
void
(
*
func
)
_P
((
void
*
)),
arg
,
void
*
arg
)
int
start_new_thread
_P2
(
func
,
void
(
*
func
)
_P
((
void
*
)),
arg
,
void
*
arg
)
{
{
#ifdef SOLARIS
struct
func_arg
*
funcarg
;
#endif
#ifdef sun
#ifdef sun
thread_t
tid
;
thread_t
tid
;
#endif
#endif
/* sun */
#if defined(__sgi) && defined(USE_DL)
#if defined(__sgi) && defined(USE_DL)
long
addr
,
size
;
long
addr
,
size
;
static
int
local_initialized
=
0
;
static
int
local_initialized
=
0
;
#endif
/* __sgi and USE_DL */
#ifdef _POSIX_THREADS
pthread_t
th
;
#endif
#endif
int
success
=
0
;
/* init not needed when SOLARIS and */
int
success
=
0
;
/* init not needed when SOLARIS and */
/* C_THREADS implemented properly */
/* C_THREADS implemented properly */
...
@@ -225,7 +281,7 @@ int start_new_thread _P2(func, void (*func) _P((void *)), arg, void *arg)
...
@@ -225,7 +281,7 @@ int start_new_thread _P2(func, void (*func) _P((void *)), arg, void *arg)
if
((
addr
=
usconfig
(
CONF_ATTACHADDR
,
addr
))
<
0
&&
errno
!=
0
)
if
((
addr
=
usconfig
(
CONF_ATTACHADDR
,
addr
))
<
0
&&
errno
!=
0
)
perror
(
"usconfig - CONF_ATTACHADDR (set)"
);
perror
(
"usconfig - CONF_ATTACHADDR (set)"
);
}
}
#endif
#endif
/* USE_DL */
if
((
success
=
sproc
(
func
,
PR_SALL
,
arg
))
<
0
)
if
((
success
=
sproc
(
func
,
PR_SALL
,
arg
))
<
0
)
perror
(
"sproc"
);
perror
(
"sproc"
);
#ifdef USE_DL
#ifdef USE_DL
...
@@ -234,7 +290,7 @@ int start_new_thread _P2(func, void (*func) _P((void *)), arg, void *arg)
...
@@ -234,7 +290,7 @@ int start_new_thread _P2(func, void (*func) _P((void *)), arg, void *arg)
perror
(
"usconfig - CONF_ATTACHADDR (reset)"
);
perror
(
"usconfig - CONF_ATTACHADDR (reset)"
);
local_initialized
=
1
;
local_initialized
=
1
;
}
}
#endif
#endif
/* USE_DL */
if
(
success
>=
0
)
{
if
(
success
>=
0
)
{
nthreads
++
;
nthreads
++
;
pidlist
[
maxpidindex
++
]
=
success
;
pidlist
[
maxpidindex
++
]
=
success
;
...
@@ -242,15 +298,25 @@ int start_new_thread _P2(func, void (*func) _P((void *)), arg, void *arg)
...
@@ -242,15 +298,25 @@ int start_new_thread _P2(func, void (*func) _P((void *)), arg, void *arg)
}
}
if
(
usunsetlock
(
count_lock
)
<
0
)
if
(
usunsetlock
(
count_lock
)
<
0
)
perror
(
"usunsetlock (count_lock)"
);
perror
(
"usunsetlock (count_lock)"
);
#endif
#endif
/* __sgi */
#ifdef SOLARIS
#ifdef SOLARIS
(
void
)
thread_create
(
0
,
0
,
func
,
arg
,
THREAD_NEW_LWP
);
funcarg
=
(
struct
func_arg
*
)
malloc
(
sizeof
(
struct
func_arg
));
#endif
funcarg
->
func
=
func
;
funcarg
->
arg
=
arg
;
if
(
thr_create
(
0
,
0
,
new_func
,
funcarg
,
THR_NEW_LWP
,
0
))
{
perror
(
"thr_create"
);
free
((
void
*
)
funcarg
);
success
=
-
1
;
}
#endif
/* SOLARIS */
#ifdef sun
#ifdef sun
success
=
lwp_create
(
&
tid
,
func
,
MINPRIO
,
0
,
lwp_newstk
(),
1
,
arg
);
success
=
lwp_create
(
&
tid
,
func
,
MINPRIO
,
0
,
lwp_newstk
(),
1
,
arg
);
#endif
#endif
/* sun */
#ifdef C_THREADS
#ifdef C_THREADS
(
void
)
cthread_fork
(
func
,
arg
);
(
void
)
cthread_fork
(
func
,
arg
);
#endif
/* C_THREADS */
#ifdef _POSIX_THREADS
pthread_create
(
&
th
,
NULL
,
func
,
arg
);
#endif
#endif
return
success
<
0
?
0
:
1
;
return
success
<
0
?
0
:
1
;
}
}
...
@@ -311,16 +377,16 @@ static void do_exit_thread _P1(no_cleanup, int no_cleanup)
...
@@ -311,16 +377,16 @@ static void do_exit_thread _P1(no_cleanup, int no_cleanup)
if
(
usunsetlock
(
count_lock
)
<
0
)
if
(
usunsetlock
(
count_lock
)
<
0
)
perror
(
"usunsetlock (count_lock)"
);
perror
(
"usunsetlock (count_lock)"
);
_exit
(
0
);
_exit
(
0
);
#endif
#endif
/* __sgi */
#ifdef SOLARIS
#ifdef SOLARIS
thr
ead_exit
(
);
thr
_exit
(
0
);
#endif
#endif
/* SOLARIS */
#ifdef sun
#ifdef sun
lwp_destroy
(
SELF
);
lwp_destroy
(
SELF
);
#endif
#endif
/* sun */
#ifdef C_THREADS
#ifdef C_THREADS
cthread_exit
(
0
);
cthread_exit
(
0
);
#endif
#endif
/* C_THREADS */
}
}
void
exit_thread
_P0
()
void
exit_thread
_P0
()
...
@@ -346,6 +412,12 @@ static void do_exit_prog _P2(status, int status, no_cleanup, int no_cleanup)
...
@@ -346,6 +412,12 @@ static void do_exit_prog _P2(status, int status, no_cleanup, int no_cleanup)
exit_status
=
status
;
exit_status
=
status
;
do_exit_thread
(
no_cleanup
);
do_exit_thread
(
no_cleanup
);
#endif
#endif
#ifdef SOLARIS
if
(
no_cleanup
)
_exit
(
status
);
else
exit
(
status
);
#endif
#ifdef sun
#ifdef sun
pod_exit
(
status
);
pod_exit
(
status
);
#endif
#endif
...
@@ -369,6 +441,9 @@ type_lock allocate_lock _P0()
...
@@ -369,6 +441,9 @@ type_lock allocate_lock _P0()
#ifdef __sgi
#ifdef __sgi
ulock_t
lock
;
ulock_t
lock
;
#endif
#endif
#ifdef SOLARIS
mutex_t
*
lock
;
#endif
#ifdef sun
#ifdef sun
struct
lock
*
lock
;
struct
lock
*
lock
;
extern
char
*
malloc
();
extern
char
*
malloc
();
...
@@ -382,13 +457,21 @@ type_lock allocate_lock _P0()
...
@@ -382,13 +457,21 @@ type_lock allocate_lock _P0()
if
((
lock
=
usnewlock
(
shared_arena
))
==
NULL
)
if
((
lock
=
usnewlock
(
shared_arena
))
==
NULL
)
perror
(
"usnewlock"
);
perror
(
"usnewlock"
);
(
void
)
usinitlock
(
lock
);
(
void
)
usinitlock
(
lock
);
#endif
#endif
/* __sgi */
#ifdef SOLARIS
lock
=
(
mutex_t
*
)
malloc
(
sizeof
(
mutex_t
));
if
(
mutex_init
(
lock
,
USYNC_THREAD
,
0
))
{
perror
(
"mutex_init"
);
free
((
void
*
)
lock
);
lock
=
0
;
}
#endif
/* SOLARIS */
#ifdef sun
#ifdef sun
lock
=
(
struct
lock
*
)
malloc
(
sizeof
(
struct
lock
));
lock
=
(
struct
lock
*
)
malloc
(
sizeof
(
struct
lock
));
lock
->
lock_locked
=
0
;
lock
->
lock_locked
=
0
;
(
void
)
mon_create
(
&
lock
->
lock_monitor
);
(
void
)
mon_create
(
&
lock
->
lock_monitor
);
(
void
)
cv_create
(
&
lock
->
lock_condvar
,
lock
->
lock_monitor
);
(
void
)
cv_create
(
&
lock
->
lock_condvar
,
lock
->
lock_monitor
);
#endif
#endif
/* sun */
dprintf
((
"allocate_lock() -> %lx
\n
"
,
(
long
)
lock
));
dprintf
((
"allocate_lock() -> %lx
\n
"
,
(
long
)
lock
));
return
(
type_lock
)
lock
;
return
(
type_lock
)
lock
;
}
}
...
@@ -398,11 +481,15 @@ void free_lock _P1(lock, type_lock lock)
...
@@ -398,11 +481,15 @@ void free_lock _P1(lock, type_lock lock)
dprintf
((
"free_lock(%lx) called
\n
"
,
(
long
)
lock
));
dprintf
((
"free_lock(%lx) called
\n
"
,
(
long
)
lock
));
#ifdef __sgi
#ifdef __sgi
usfreelock
((
ulock_t
)
lock
,
shared_arena
);
usfreelock
((
ulock_t
)
lock
,
shared_arena
);
#endif
/* __sgi */
#ifdef SOLARIS
mutex_destroy
((
mutex_t
*
)
lock
);
free
((
void
*
)
lock
);
#endif
#endif
#ifdef sun
#ifdef sun
mon_destroy
(((
struct
lock
*
)
lock
)
->
lock_monitor
);
mon_destroy
(((
struct
lock
*
)
lock
)
->
lock_monitor
);
free
((
char
*
)
lock
);
free
((
char
*
)
lock
);
#endif
#endif
/* sun */
}
}
int
acquire_lock
_P2
(
lock
,
type_lock
lock
,
waitflag
,
int
waitflag
)
int
acquire_lock
_P2
(
lock
,
type_lock
lock
,
waitflag
,
int
waitflag
)
...
@@ -418,7 +505,17 @@ int acquire_lock _P2(lock, type_lock lock, waitflag, int waitflag)
...
@@ -418,7 +505,17 @@ int acquire_lock _P2(lock, type_lock lock, waitflag, int waitflag)
success
=
uscsetlock
((
ulock_t
)
lock
,
1
);
/* Try it once */
success
=
uscsetlock
((
ulock_t
)
lock
,
1
);
/* Try it once */
if
(
success
<
0
)
if
(
success
<
0
)
perror
(
waitflag
?
"ussetlock"
:
"uscsetlock"
);
perror
(
waitflag
?
"ussetlock"
:
"uscsetlock"
);
#endif
#endif
/* __sgi */
#ifdef SOLARIS
if
(
waitflag
)
success
=
mutex_lock
((
mutex_t
*
)
lock
);
else
success
=
mutex_trylock
((
mutex_t
*
)
lock
);
if
(
success
<
0
)
perror
(
waitflag
?
"mutex_lock"
:
"mutex_trylock"
);
else
success
=
!
success
;
/* solaris does it the other way round */
#endif
/* SOLARIS */
#ifdef sun
#ifdef sun
success
=
0
;
success
=
0
;
...
@@ -432,7 +529,7 @@ int acquire_lock _P2(lock, type_lock lock, waitflag, int waitflag)
...
@@ -432,7 +529,7 @@ int acquire_lock _P2(lock, type_lock lock, waitflag, int waitflag)
}
}
cv_broadcast
(((
struct
lock
*
)
lock
)
->
lock_condvar
);
cv_broadcast
(((
struct
lock
*
)
lock
)
->
lock_condvar
);
mon_exit
(((
struct
lock
*
)
lock
)
->
lock_monitor
);
mon_exit
(((
struct
lock
*
)
lock
)
->
lock_monitor
);
#endif
#endif
/* sun */
dprintf
((
"acquire_lock(%lx, %d) -> %d
\n
"
,
(
long
)
lock
,
waitflag
,
success
));
dprintf
((
"acquire_lock(%lx, %d) -> %d
\n
"
,
(
long
)
lock
,
waitflag
,
success
));
return
success
;
return
success
;
}
}
...
@@ -443,13 +540,17 @@ void release_lock _P1(lock, type_lock lock)
...
@@ -443,13 +540,17 @@ void release_lock _P1(lock, type_lock lock)
#ifdef __sgi
#ifdef __sgi
if
(
usunsetlock
((
ulock_t
)
lock
)
<
0
)
if
(
usunsetlock
((
ulock_t
)
lock
)
<
0
)
perror
(
"usunsetlock"
);
perror
(
"usunsetlock"
);
#endif
#endif
/* __sgi */
#ifdef SOLARIS
if
(
mutex_unlock
((
mutex_t
*
)
lock
))
perror
(
"mutex_unlock"
);
#endif
/* SOLARIS */
#ifdef sun
#ifdef sun
(
void
)
mon_enter
(((
struct
lock
*
)
lock
)
->
lock_monitor
);
(
void
)
mon_enter
(((
struct
lock
*
)
lock
)
->
lock_monitor
);
((
struct
lock
*
)
lock
)
->
lock_locked
=
0
;
((
struct
lock
*
)
lock
)
->
lock_locked
=
0
;
cv_broadcast
(((
struct
lock
*
)
lock
)
->
lock_condvar
);
cv_broadcast
(((
struct
lock
*
)
lock
)
->
lock_condvar
);
mon_exit
(((
struct
lock
*
)
lock
)
->
lock_monitor
);
mon_exit
(((
struct
lock
*
)
lock
)
->
lock_monitor
);
#endif
#endif
/* sun */
}
}
/*
/*
...
@@ -459,6 +560,9 @@ type_sema allocate_sema _P1(value, int value)
...
@@ -459,6 +560,9 @@ type_sema allocate_sema _P1(value, int value)
{
{
#ifdef __sgi
#ifdef __sgi
usema_t
*
sema
;
usema_t
*
sema
;
#endif
/* __sgi */
#ifdef SOLARIS
sema_t
*
sema
;
#endif
#endif
dprintf
((
"allocate_sema called
\n
"
));
dprintf
((
"allocate_sema called
\n
"
));
...
@@ -468,9 +572,17 @@ type_sema allocate_sema _P1(value, int value)
...
@@ -468,9 +572,17 @@ type_sema allocate_sema _P1(value, int value)
#ifdef __sgi
#ifdef __sgi
if
((
sema
=
usnewsema
(
shared_arena
,
value
))
==
NULL
)
if
((
sema
=
usnewsema
(
shared_arena
,
value
))
==
NULL
)
perror
(
"usnewsema"
);
perror
(
"usnewsema"
);
#endif
/* __sgi */
#ifdef SOLARIS
sema
=
(
sema_t
*
)
malloc
(
sizeof
(
sema_t
));
if
(
sema_init
(
sema
,
value
,
USYNC_THREAD
,
0
))
{
perror
(
"sema_init"
);
free
((
void
*
)
sema
);
sema
=
0
;
}
#endif
/* SOLARIS */
dprintf
((
"allocate_sema() -> %lx
\n
"
,
(
long
)
sema
));
dprintf
((
"allocate_sema() -> %lx
\n
"
,
(
long
)
sema
));
return
(
type_sema
)
sema
;
return
(
type_sema
)
sema
;
#endif
}
}
void
free_sema
_P1
(
sema
,
type_sema
sema
)
void
free_sema
_P1
(
sema
,
type_sema
sema
)
...
@@ -478,7 +590,12 @@ void free_sema _P1(sema, type_sema sema)
...
@@ -478,7 +590,12 @@ void free_sema _P1(sema, type_sema sema)
dprintf
((
"free_sema(%lx) called
\n
"
,
(
long
)
sema
));
dprintf
((
"free_sema(%lx) called
\n
"
,
(
long
)
sema
));
#ifdef __sgi
#ifdef __sgi
usfreesema
((
usema_t
*
)
sema
,
shared_arena
);
usfreesema
((
usema_t
*
)
sema
,
shared_arena
);
#endif
#endif
/* __sgi */
#ifdef SOLARIS
if
(
sema_destroy
((
sema_t
*
)
sema
))
perror
(
"sema_destroy"
);
free
((
void
*
)
sema
);
#endif
/* SOLARIS */
}
}
void
down_sema
_P1
(
sema
,
type_sema
sema
)
void
down_sema
_P1
(
sema
,
type_sema
sema
)
...
@@ -487,6 +604,10 @@ void down_sema _P1(sema, type_sema sema)
...
@@ -487,6 +604,10 @@ void down_sema _P1(sema, type_sema sema)
#ifdef __sgi
#ifdef __sgi
if
(
uspsema
((
usema_t
*
)
sema
)
<
0
)
if
(
uspsema
((
usema_t
*
)
sema
)
<
0
)
perror
(
"uspsema"
);
perror
(
"uspsema"
);
#endif
#ifdef SOLARIS
if
(
sema_wait
((
sema_t
*
)
sema
))
perror
(
"sema_wait"
);
#endif
#endif
dprintf
((
"down_sema(%lx) return
\n
"
,
(
long
)
sema
));
dprintf
((
"down_sema(%lx) return
\n
"
,
(
long
)
sema
));
}
}
...
@@ -497,5 +618,9 @@ void up_sema _P1(sema, type_sema sema)
...
@@ -497,5 +618,9 @@ void up_sema _P1(sema, type_sema sema)
#ifdef __sgi
#ifdef __sgi
if
(
usvsema
((
usema_t
*
)
sema
)
<
0
)
if
(
usvsema
((
usema_t
*
)
sema
)
<
0
)
perror
(
"usvsema"
);
perror
(
"usvsema"
);
#endif
/* __sgi */
#ifdef SOLARIS
if
(
sema_post
((
sema_t
*
)
sema
))
perror
(
"sema_post"
);
#endif
#endif
}
}
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