Skip to content
This repository has been archived by the owner on Jun 3, 2023. It is now read-only.

This is broken #2

Open
AbhishekUoR opened this issue Mar 8, 2019 · 5 comments
Open

This is broken #2

AbhishekUoR opened this issue Mar 8, 2019 · 5 comments

Comments

@AbhishekUoR
Copy link

I can not make this m5threads using gcc-7.3.
I tried using gcc-4.8 and gcc-5 but the error is same.
Also, there is no proper README to instruct how it works

@farabimahmud
Copy link

I am getting following errors while trying to build using gcc-7.3.0

pthread.c: In function ‘pthread_create’:
pthread.c:256:3: warning: implicit declaration of function ‘clone’; did you mean ‘close’? [-Wimplicit-function-declaration]
clone(__pthread_trampoline, tcb->stack_start_addr, CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD, tcb);
^~~~~
close
In file included from pthread.c:49:0:
pthread.c: In function ‘pthread_rwlock_init’:
pthread_defs.h:102:73: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__lock’
#define PTHREAD_RWLOCK_T_LOCK(rwlock) ((volatile int)(&rwlock->__data.__lock))
^
pthread.c:380:5: note: in expansion of macro ‘PTHREAD_RWLOCK_T_LOCK’
PTHREAD_RWLOCK_T_LOCK(lock) = 0; // used only with spin_lock, so we know to initilize to zero
^~~~~~~~~~~~~~~~~~~~~
pthread_defs.h:103:77: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__nr_readers’; did you mean ‘__readers’?
#define PTHREAD_RWLOCK_T_READERS(rwlock) ((volatile int)(&rwlock->__data.__nr_readers))
^
pthread.c:381:5: note: in expansion of macro ‘PTHREAD_RWLOCK_T_READERS’
PTHREAD_RWLOCK_T_READERS(lock) = 0;
^~~~~~~~~~~~~~~~~~~~~~~~
pthread_defs.h:104:76: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__writer’; did you mean ‘__writers’?
#define PTHREAD_RWLOCK_T_WRITER(rwlock) ((volatile int)(&rwlock->__data.__writer))
^
pthread.c:382:5: note: in expansion of macro ‘PTHREAD_RWLOCK_T_WRITER’
PTHREAD_RWLOCK_T_WRITER(lock) = -1; // -1 means no one owns the write lock
^~~~~~~~~~~~~~~~~~~~~~~
pthread.c: In function ‘pthread_rwlock_rdlock’:
pthread_defs.h:104:76: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__writer’; did you mean ‘__writers’?
#define PTHREAD_RWLOCK_T_WRITER(rwlock) ((volatile int)(&rwlock->__data.__writer))
^
pthread.c:398:32: note: in expansion of macro ‘PTHREAD_RWLOCK_T_WRITER’
pthread_t writer = PTHREAD_RWLOCK_T_WRITER(lock);
^~~~~~~~~~~~~~~~~~~~~~~
pthread_defs.h:102:73: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__lock’
#define PTHREAD_RWLOCK_T_LOCK(rwlock) ((volatile int)(&rwlock->__data.__lock))
^
pthread.c:404:27: note: in expansion of macro ‘PTHREAD_RWLOCK_T_LOCK’
spin_lock((int*)&(PTHREAD_RWLOCK_T_LOCK(lock)));
^~~~~~~~~~~~~~~~~~~~~
pthread_defs.h:104:76: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__writer’; did you mean ‘__writers’?
#define PTHREAD_RWLOCK_T_WRITER(rwlock) ((volatile int)(&rwlock->__data.__writer))
^
pthread.c:405:24: note: in expansion of macro ‘PTHREAD_RWLOCK_T_WRITER’
if ((pthread_t)PTHREAD_RWLOCK_T_WRITER(lock) == -1) {
^~~~~~~~~~~~~~~~~~~~~~~
pthread_defs.h:103:77: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__nr_readers’; did you mean ‘__readers’?
#define PTHREAD_RWLOCK_T_READERS(rwlock) ((volatile int)(&rwlock->__data.__nr_readers))
^
pthread.c:406:13: note: in expansion of macro ‘PTHREAD_RWLOCK_T_READERS’
PTHREAD_RWLOCK_T_READERS(lock)++;
^~~~~~~~~~~~~~~~~~~~~~~~
pthread_defs.h:102:73: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__lock’
#define PTHREAD_RWLOCK_T_LOCK(rwlock) ((volatile int)(&rwlock->__data.__lock))
^
pthread.c:407:33: note: in expansion of macro ‘PTHREAD_RWLOCK_T_LOCK’
spin_unlock((int*)&(PTHREAD_RWLOCK_T_LOCK(lock)));
^~~~~~~~~~~~~~~~~~~~~
pthread_defs.h:102:73: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__lock’
#define PTHREAD_RWLOCK_T_LOCK(rwlock) ((volatile int)(&rwlock->__data.__lock))
^
pthread.c:411:29: note: in expansion of macro ‘PTHREAD_RWLOCK_T_LOCK’
spin_unlock((int*)&(PTHREAD_RWLOCK_T_LOCK(lock)));
^~~~~~~~~~~~~~~~~~~~~
pthread.c: In function ‘pthread_rwlock_wrlock’:
pthread_defs.h:104:76: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__writer’; did you mean ‘__writers’?
#define PTHREAD_RWLOCK_T_WRITER(rwlock) ((volatile int)(&rwlock->__data.__writer))
^
pthread.c:422:32: note: in expansion of macro ‘PTHREAD_RWLOCK_T_WRITER’
pthread_t writer = PTHREAD_RWLOCK_T_WRITER(lock);
^~~~~~~~~~~~~~~~~~~~~~~
pthread_defs.h:103:77: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__nr_readers’; did you mean ‘__readers’?
#define PTHREAD_RWLOCK_T_READERS(rwlock) ((volatile int)(&rwlock->__data.__nr_readers))
^
pthread.c:426:31: note: in expansion of macro ‘PTHREAD_RWLOCK_T_READERS’
int num_readers = PTHREAD_RWLOCK_T_READERS(lock);
^~~~~~~~~~~~~~~~~~~~~~~~
pthread_defs.h:102:73: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__lock’
#define PTHREAD_RWLOCK_T_LOCK(rwlock) ((volatile int)(&rwlock->__data.__lock))
^
pthread.c:432:27: note: in expansion of macro ‘PTHREAD_RWLOCK_T_LOCK’
spin_lock((int*)&(PTHREAD_RWLOCK_T_LOCK(lock)));
^~~~~~~~~~~~~~~~~~~~~
pthread_defs.h:104:76: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__writer’; did you mean ‘__writers’?
#define PTHREAD_RWLOCK_T_WRITER(rwlock) ((volatile int)(&rwlock->__data.__writer))
^
pthread.c:433:24: note: in expansion of macro ‘PTHREAD_RWLOCK_T_WRITER’
if ((pthread_t)PTHREAD_RWLOCK_T_WRITER(lock) == -1 && PTHREAD_RWLOCK_T_READERS(lock) == 0) {
^~~~~~~~~~~~~~~~~~~~~~~
pthread_defs.h:103:77: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__nr_readers’; did you mean ‘__readers’?
#define PTHREAD_RWLOCK_T_READERS(rwlock) ((volatile int)(&rwlock->__data.__nr_readers))
^
pthread.c:433:63: note: in expansion of macro ‘PTHREAD_RWLOCK_T_READERS’
if ((pthread_t)PTHREAD_RWLOCK_T_WRITER(lock) == -1 && PTHREAD_RWLOCK_T_READERS(lock) == 0) {
^~~~~~~~~~~~~~~~~~~~~~~~
pthread_defs.h:104:76: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__writer’; did you mean ‘__writers’?
#define PTHREAD_RWLOCK_T_WRITER(rwlock) ((volatile int)(&rwlock->__data.__writer))
^
pthread.c:434:13: note: in expansion of macro ‘PTHREAD_RWLOCK_T_WRITER’
PTHREAD_RWLOCK_T_WRITER(lock) = pthread_self();
^~~~~~~~~~~~~~~~~~~~~~~
pthread_defs.h:102:73: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__lock’
#define PTHREAD_RWLOCK_T_LOCK(rwlock) ((volatile int)(&rwlock->__data.__lock))
^
pthread.c:435:33: note: in expansion of macro ‘PTHREAD_RWLOCK_T_LOCK’
spin_unlock((int*)&(PTHREAD_RWLOCK_T_LOCK(lock)));
^~~~~~~~~~~~~~~~~~~~~
pthread_defs.h:102:73: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__lock’
#define PTHREAD_RWLOCK_T_LOCK(rwlock) ((volatile int)(&rwlock->__data.__lock))
^
pthread.c:439:29: note: in expansion of macro ‘PTHREAD_RWLOCK_T_LOCK’
spin_unlock((int*)&(PTHREAD_RWLOCK_T_LOCK(lock)));
^~~~~~~~~~~~~~~~~~~~~
pthread.c: In function ‘pthread_rwlock_unlock’:
pthread_defs.h:102:73: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__lock’
#define PTHREAD_RWLOCK_T_LOCK(rwlock) ((volatile int)(&rwlock->__data.__lock))
^
pthread.c:448:23: note: in expansion of macro ‘PTHREAD_RWLOCK_T_LOCK’
spin_lock((int*)&(PTHREAD_RWLOCK_T_LOCK(lock)));
^~~~~~~~~~~~~~~~~~~~~
pthread_defs.h:104:76: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__writer’; did you mean ‘__writers’?
#define PTHREAD_RWLOCK_T_WRITER(rwlock) ((volatile int)(&rwlock->__data.__writer))
^
pthread.c:449:27: note: in expansion of macro ‘PTHREAD_RWLOCK_T_WRITER’
if (pthread_self() == PTHREAD_RWLOCK_T_WRITER(lock)) {
^~~~~~~~~~~~~~~~~~~~~~~
pthread_defs.h:104:76: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__writer’; did you mean ‘__writers’?
#define PTHREAD_RWLOCK_T_WRITER(rwlock) ((volatile int)(&rwlock->__data.__writer))
^
pthread.c:451:9: note: in expansion of macro ‘PTHREAD_RWLOCK_T_WRITER’
PTHREAD_RWLOCK_T_WRITER(lock) = -1;
^~~~~~~~~~~~~~~~~~~~~~~
pthread_defs.h:103:77: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__nr_readers’; did you mean ‘__readers’?
#define PTHREAD_RWLOCK_T_READERS(rwlock) ((volatile int)(&rwlock->__data.__nr_readers))
^
pthread.c:454:9: note: in expansion of macro ‘PTHREAD_RWLOCK_T_READERS’
PTHREAD_RWLOCK_T_READERS(lock) = PTHREAD_RWLOCK_T_READERS(lock) - 1;
^~~~~~~~~~~~~~~~~~~~~~~~
pthread_defs.h:103:77: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__nr_readers’; did you mean ‘__readers’?
#define PTHREAD_RWLOCK_T_READERS(rwlock) ((volatile int)(&rwlock->__data.__nr_readers))
^
pthread.c:454:42: note: in expansion of macro ‘PTHREAD_RWLOCK_T_READERS’
PTHREAD_RWLOCK_T_READERS(lock) = PTHREAD_RWLOCK_T_READERS(lock) - 1;
^~~~~~~~~~~~~~~~~~~~~~~~
pthread_defs.h:102:73: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__lock’
#define PTHREAD_RWLOCK_T_LOCK(rwlock) ((volatile int)(&rwlock->__data.__lock))
^
pthread.c:456:25: note: in expansion of macro ‘PTHREAD_RWLOCK_T_LOCK’
spin_unlock((int*)&(PTHREAD_RWLOCK_T_LOCK(lock)));
^~~~~~~~~~~~~~~~~~~~~
pthread.c: In function ‘pthread_cond_init’:
pthread_defs.h:107:67: error: ‘struct __pthread_cond_s’ has no member named ‘__lock’
#define PTHREAD_COND_T_FLAG(cond) ((volatile int)(&(cond->__data.__lock)))
^
pthread.c:536:5: note: in expansion of macro ‘PTHREAD_COND_T_FLAG’
PTHREAD_COND_T_FLAG(cond) = 0;
^~~~~~~~~~~~~~~~~~~
pthread_defs.h:108:76: error: ‘struct __pthread_cond_s’ has no member named ‘__futex’
#define PTHREAD_COND_T_THREAD_COUNT(cond) ((volatile int)(&(cond-> __data.__futex)))
^
pthread.c:537:5: note: in expansion of macro ‘PTHREAD_COND_T_THREAD_COUNT’
PTHREAD_COND_T_THREAD_COUNT(cond) = 0;
^~~~~~~~~~~~~~~~~~~~~~~~~~~
pthread_defs.h:109:74: error: ‘struct __pthread_cond_s’ has no member named ‘__nwaiters’; did you mean ‘__wrefs’?
#define PTHREAD_COND_T_COUNT_LOCK(cond) ((volatile int)(&(cond->__data.__nwaiters)))
^
pthread.c:538:5: note: in expansion of macro ‘PTHREAD_COND_T_COUNT_LOCK’
PTHREAD_COND_T_COUNT_LOCK(cond) = 0;
^~~~~~~~~~~~~~~~~~~~~~~~~
pthread.c: In function ‘pthread_cond_broadcast’:
pthread_defs.h:107:67: error: ‘struct __pthread_cond_s’ has no member named ‘__lock’
#define PTHREAD_COND_T_FLAG(cond) ((volatile int)(&(cond->__data.__lock)))
^
pthread.c:549:5: note: in expansion of macro ‘PTHREAD_COND_T_FLAG’
PTHREAD_COND_T_FLAG(cond) = 1;
^~~~~~~~~~~~~~~~~~~
pthread.c: In function ‘pthread_cond_wait’:
pthread_defs.h:108:76: error: ‘struct __pthread_cond_s’ has no member named ‘__futex’
#define PTHREAD_COND_T_THREAD_COUNT(cond) ((volatile int)(&(cond-> __data.__futex)))
^
pthread.c:556:37: note: in expansion of macro ‘PTHREAD_COND_T_THREAD_COUNT’
volatile int* thread_count = &(PTHREAD_COND_T_THREAD_COUNT(cond));
^~~~~~~~~~~~~~~~~~~~~~~~~~~
pthread_defs.h:107:67: error: ‘struct __pthread_cond_s’ has no member named ‘__lock’
#define PTHREAD_COND_T_FLAG(cond) ((volatile int)(&(cond->__data.__lock)))
^
pthread.c:557:28: note: in expansion of macro ‘PTHREAD_COND_T_FLAG’
volatile int* flag = &(PTHREAD_COND_T_FLAG(cond));
^~~~~~~~~~~~~~~~~~~
pthread_defs.h:109:74: error: ‘struct __pthread_cond_s’ has no member named ‘__nwaiters’; did you mean ‘__wrefs’?
#define PTHREAD_COND_T_COUNT_LOCK(cond) ((volatile int)(&(cond->__data.__nwaiters)))
^
pthread.c:558:37: note: in expansion of macro ‘PTHREAD_COND_T_COUNT_LOCK’
volatile int* count_lock = &(PTHREAD_COND_T_COUNT_LOCK(cond));
^~~~~~~~~~~~~~~~~~~~~~~~~
make: *** [pthread.o] Error 1

@febinpsunny
Copy link

I am getting the same issue; though the issue with clone() can be resolved with proper includes, the rest of the issue with missing members of structures couldnot be solved; Should I be editing pthreads.h to make this run or should I be using a different version of gcc (using 7.4.0).

Please provide a resolution.

@hosseingolestani
Copy link

This issue may have to do with the Linux kernel version.
I got the same errors on a system with Linux kernel 4.15 (gcc 7.4). However, on an older system with Linux kernel 3.19 (gcc 4.8), the code compiled without any problem.
I didn't spend time digging in the m5thread code to make it work with newer kernel versions.

@nyejd
Copy link

nyejd commented Aug 18, 2021

This issue may have to do with the Linux kernel version.
I got the same errors on a system with Linux kernel 4.15 (gcc 7.4). However, on an older system with Linux kernel 3.19 (gcc 4.8), the code compiled without any problem.
I didn't spend time digging in the m5thread code to make it work with newer kernel versions.

Was there any additional modifications you made other than changing the compiler to gcc-4.8? I still get the following errors with the most recent m5threads commit using gcc-4.4 (I get the original poster's errors with gcc-4.8):

gcc-4.4 -O3 -static -c -o pthread.o pthread.c
pthread.c: In function ‘pthread_rwlock_init’:
pthread.c:380: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__lock’
pthread.c:381: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__nr_readers’
pthread.c:382: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__writer’
pthread.c: In function ‘pthread_rwlock_rdlock’:
pthread.c:398: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__writer’
pthread.c:404: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__lock’
pthread.c:405: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__writer’
pthread.c:406: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__nr_readers’
pthread.c:407: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__lock’
pthread.c:411: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__lock’
pthread.c: In function ‘pthread_rwlock_wrlock’:
pthread.c:422: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__writer’
pthread.c:426: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__nr_readers’
pthread.c:432: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__lock’
pthread.c:433: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__writer’
pthread.c:433: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__nr_readers’
pthread.c:434: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__writer’
pthread.c:435: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__lock’
pthread.c:439: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__lock’
pthread.c: In function ‘pthread_rwlock_unlock’:
pthread.c:448: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__lock’
pthread.c:449: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__writer’
pthread.c:451: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__writer’
pthread.c:454: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__nr_readers’
pthread.c:454: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__nr_readers’
pthread.c:456: error: ‘struct __pthread_rwlock_arch_t’ has no member named ‘__lock’
pthread.c: In function ‘pthread_cond_init’:
pthread.c:536: error: ‘struct __pthread_cond_s’ has no member named ‘__lock’
pthread.c:537: error: ‘struct __pthread_cond_s’ has no member named ‘__futex’
pthread.c:538: error: ‘struct __pthread_cond_s’ has no member named ‘__nwaiters’
pthread.c: In function ‘pthread_cond_broadcast’:
pthread.c:549: error: ‘struct __pthread_cond_s’ has no member named ‘__lock’
pthread.c: In function ‘pthread_cond_wait’:
pthread.c:556: error: ‘struct __pthread_cond_s’ has no member named ‘__futex’
pthread.c:557: error: ‘struct __pthread_cond_s’ has no member named ‘__lock’
pthread.c:558: error: ‘struct __pthread_cond_s’ has no member named ‘__nwaiters’
: recipe for target 'pthread.o' failed
make: *** [pthread.o] Error 1

@hosseingolestani
Copy link

@jared-nye If I remember correctly, I didn't make any other modification. Just switched to older gcc and kernel. (Based on the errors, I think the code is compatible with older glibc versions.)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants