Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with std::mutex (c++11) #34

Closed
capehill opened this issue Jul 9, 2017 · 12 comments
Closed

Issue with std::mutex (c++11) #34

capehill opened this issue Jul 9, 2017 · 12 comments

Comments

@capehill
Copy link

capehill commented Jul 9, 2017

I can't compile code with std::mutex. Should it be supported?

2.Code:test> which g++
Code:adtools-os4-20170623-404/bin/g++

2.Code:test> g++ -c -std=c++11 mutex.cpp
mutex.cpp: In function 'int main()':
mutex.cpp:5:2: error: 'mutex' is not a member of 'std'
std::mutex m;
^

#include <mutex>

int main(void)
{
	std::mutex m;

	return 0;
}
@sba1
Copy link
Owner

sba1 commented Jul 10, 2017

You are probably the first one trying it. I haven't looked in to the implementation of std::mutex, but I guess it is based on pthreads and is best used with the pthread threading model, which is currently not enabled (in theory it could be enabled but it has quite some implications for the .so files because it is basically switching to another ABI).

An alternative would be to implement the C++ threading via native threads.

@sba1
Copy link
Owner

sba1 commented Jul 10, 2017

Please also have a look at #12. It contains some instructions how to build the compiler with enabled pthreads support.

@capehill
Copy link
Author

I built a native compiler with posix threads (proven by gcc -v). But it doesn't seem to be enough because most of the mutex header is ignored due to missing definitions. -U__STRICT_ANSI__ helps with _GLIBCXX_USE_C99_STDINT_TR1, but the next issue is with _GLIBCXX_HAS_GTHREADS.

@afxgroup
Copy link

same with std::once_flag

error: 'once_flag' in namespace 'std' does not name a type

And it is in the same file wrapped around "#ifdef GLIBCXX_HAS_GTHREADS"

@afxgroup
Copy link

afxgroup commented Dec 31, 2017

I've changed some include files on my local installation to use gthr-posix.h instead of gthr.h and i've compiled my test project using -U__STRICT_ANSI__ -D_GLIBCXX_HAS_GTHREADS.
Now i can compile some examples using mutex and pthreads.

@afxgroup
Copy link

I can confirm that it works correctly.
I've compiled https://github.com/pockethook/player without any problems. The only thing to take care of is to update the newlib to the latest one otherwise the compiled file didn't work

@afxgroup
Copy link

afxgroup commented Jan 4, 2018

@sba1
Copy link
Owner

sba1 commented May 10, 2018

As part of Issue #12, mutex support should be functional as well (apart from bugs of course). Note that it is implemented only for gcc 8 for now (and you have to choose the amigaos threading implementation).

@capehill
Copy link
Author

Fantastic news! Is there a prebuilt gcc 8 binary available for testing, yet?

@sba1
Copy link
Owner

sba1 commented May 10, 2018

Not yet, but you can easily compile one yourself on a Linux machine.

@sba1
Copy link
Owner

sba1 commented May 10, 2018

The standard procedure now enables the amigaos threading automatically, if gcc 8 is compiled.

@sba1
Copy link
Owner

sba1 commented May 19, 2018

Regularly built versions for AmigaOS can be obtained from https://dl.bintray.com/sba1/adtools-native/. If there are any problems (which is likely), please file a new Issue.

@sba1 sba1 closed this as completed May 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants