Skip to content

Commit 08a8e75

Browse files
authored
Merge pull request #3662 from BernardXiong/fix_pthreads
Fix pthreads
2 parents 64ac492 + be43008 commit 08a8e75

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

components/libc/compilers/newlib/syscalls.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717
#include <dfs_posix.h>
1818
#endif
1919

20-
#ifdef RT_USING_PTHREADS
21-
#include <pthread.h>
22-
#endif
23-
2420
#ifdef RT_USING_MODULE
2521
#include <dlmodule.h>
2622
#endif
Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
from building import *
2+
from utils import VersionCmp
23

3-
cwd = GetCurrentDir()
4-
src = Glob('*.c')
5-
CPPPATH = [cwd]
4+
cwd = GetCurrentDir()
5+
src = Glob('*.c')
6+
CPPPATH = [cwd]
7+
CPPDEFINES = []
8+
9+
# only enable POSIX.1b-1993 Real-time extensions
10+
libc_ver = GetDepend('LIBC_VERSION')
11+
try:
12+
ver = libc_ver.split(' ')
13+
ver = ver[1]
14+
if VersionCmp(ver, "2.5.0") == 1:
15+
CPPDEFINES = ['_POSIX_C_SOURCE=199309L']
16+
except :
17+
pass
618

719
group = DefineGroup('pthreads', src,
8-
depend = ['RT_USING_PTHREADS', 'RT_USING_LIBC'], CPPPATH = CPPPATH)
20+
depend = ['RT_USING_PTHREADS', 'RT_USING_LIBC'], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES)
921

1022
Return('group')

components/libc/pthreads/pthread.c

100755100644
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ int pthread_create(pthread_t *pid,
277277

278278
/* set pthread cleanup function and ptd data */
279279
ptd->tid->cleanup = _pthread_cleanup;
280-
ptd->tid->user_data = (rt_uint32_t)ptd;
280+
ptd->tid->user_data = (rt_ubase_t)ptd;
281281

282282
/* start thread */
283283
if (rt_thread_startup(ptd->tid) == RT_EOK)

include/rtdef.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ struct rt_thread
623623
void *lwp;
624624
#endif
625625

626-
rt_uint32_t user_data; /**< private user data beyond this thread */
626+
rt_ubase_t user_data; /**< private user data beyond this thread */
627627
};
628628
typedef struct rt_thread *rt_thread_t;
629629

0 commit comments

Comments
 (0)