Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gcc-cobol
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
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
Environments
Terraform modules
Monitor
Incidents
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
COBOLworx
gcc-cobol
Commits
447c11a5
Commit
447c11a5
authored
24 years ago
by
Ovidiu Predescu
Browse files
Options
Downloads
Patches
Plain Diff
Integrated Chris Ball's <cball@fmco.com> changes to improve the Posix
thread support for Objective-C. From-SVN: r35533
parent
137fa4d0
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gcc/gthr-posix.h
+60
-9
60 additions, 9 deletions
gcc/gthr-posix.h
with
60 additions
and
9 deletions
gcc/gthr-posix.h
+
60
−
9
View file @
447c11a5
...
@@ -92,6 +92,7 @@ __gthread_active_p (void)
...
@@ -92,6 +92,7 @@ __gthread_active_p (void)
/* Key structure for maintaining thread specific storage */
/* Key structure for maintaining thread specific storage */
static
pthread_key_t
_objc_thread_storage
;
static
pthread_key_t
_objc_thread_storage
;
static
pthread_attr_t
_objc_thread_attribs
;
/* Thread local storage for a single thread */
/* Thread local storage for a single thread */
static
void
*
thread_local_storage
=
NULL
;
static
void
*
thread_local_storage
=
NULL
;
...
@@ -103,8 +104,19 @@ static inline int
...
@@ -103,8 +104,19 @@ static inline int
__gthread_objc_init_thread_system
(
void
)
__gthread_objc_init_thread_system
(
void
)
{
{
if
(
__gthread_active_p
())
if
(
__gthread_active_p
())
/* Initialize the thread storage key */
{
return
pthread_key_create
(
&
_objc_thread_storage
,
NULL
);
/* Initialize the thread storage key */
if
(
pthread_key_create
(
&
_objc_thread_storage
,
NULL
)
==
0
)
{
/* The normal default detach state for threads is
* PTHREAD_CREATE_JOINABLE which causes threads to not die
* when you think they should. */
if
(
pthread_attr_init
(
&
_objc_thread_attribs
)
==
0
&&
pthread_attr_setdetachstate
(
&
_objc_thread_attribs
,
PTHREAD_CREATE_DETACHED
)
==
0
)
return
0
;
}
}
else
else
return
-
1
;
return
-
1
;
}
}
...
@@ -113,10 +125,12 @@ __gthread_objc_init_thread_system(void)
...
@@ -113,10 +125,12 @@ __gthread_objc_init_thread_system(void)
static
inline
int
static
inline
int
__gthread_objc_close_thread_system
(
void
)
__gthread_objc_close_thread_system
(
void
)
{
{
if
(
__gthread_active_p
())
if
(
__gthread_active_p
()
&&
pthread_key_delete
(
_objc_thread_storage
)
==
0
&&
pthread_attr_destroy
(
&
_objc_thread_attribs
)
==
0
)
return
0
;
return
0
;
else
return
-
1
;
return
-
1
;
}
}
/* Backend thread functions */
/* Backend thread functions */
...
@@ -143,8 +157,38 @@ __gthread_objc_thread_detach(void (*func)(void *), void *arg)
...
@@ -143,8 +157,38 @@ __gthread_objc_thread_detach(void (*func)(void *), void *arg)
static
inline
int
static
inline
int
__gthread_objc_thread_set_priority
(
int
priority
)
__gthread_objc_thread_set_priority
(
int
priority
)
{
{
/* Not implemented yet */
if
(
!
__gthread_active_p
())
return
-
1
;
return
-
1
;
else
{
pthread_t
thread_id
=
pthread_self
();
int
policy
;
struct
sched_param
params
;
int
priority_min
,
priority_max
;
if
(
pthread_getschedparam
(
thread_id
,
&
policy
,
&
params
)
==
0
)
{
if
((
priority_max
=
sched_get_priority_max
(
policy
))
!=
0
)
return
-
1
;
if
((
priority_min
=
sched_get_priority_min
(
policy
))
!=
0
)
return
-
1
;
if
(
priority
>
priority_max
)
priority
=
priority_max
;
else
if
(
priority
<
priority_min
)
priority
=
priority_min
;
params
.
sched_priority
=
priority
;
/*
* The solaris 7 and several other man pages incorrectly state that
* this should be a pointer to policy but pthread.h is universally
* at odds with this.
*/
if
(
pthread_setschedparam
(
thread_id
,
policy
,
&
params
)
==
0
)
return
0
;
}
return
-
1
;
}
}
}
/* Return the current thread's priority. */
/* Return the current thread's priority. */
...
@@ -152,8 +196,15 @@ static inline int
...
@@ -152,8 +196,15 @@ static inline int
__gthread_objc_thread_get_priority
(
void
)
__gthread_objc_thread_get_priority
(
void
)
{
{
if
(
__gthread_active_p
())
if
(
__gthread_active_p
())
/* Not implemented yet */
{
return
-
1
;
int
policy
;
struct
sched_param
params
;
if
(
pthread_getschedparam
(
pthread_self
(),
&
policy
,
&
params
)
==
0
)
return
params
.
sched_priority
;
else
return
-
1
;
}
else
else
return
OBJC_THREAD_INTERACTIVE_PRIORITY
;
return
OBJC_THREAD_INTERACTIVE_PRIORITY
;
}
}
...
...
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