[issue23644] g++ module compile fails with ‘_Atomic’ does not name a type

2020-06-25 Thread STINNER Victor


STINNER Victor  added the comment:

Atomic functions are no longer part of the public C API: code was moved to 
pycore_atomic.h internal C API. I close the issue.

--
resolution:  -> fixed
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23644] g++ module compile fails with ‘_Atomic’ does not name a type

2017-11-02 Thread Josh Cullum

Josh Cullum  added the comment:

Interestingly, I get the error with Python 3.6.3 build from source, where I 
include the path to the g++ binary.

Python builds without the g++ option, but then _Tkinter fails to build - see 
issue31817

--
nosy: +jpc2350

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23644] g++ module compile fails with ‘_Atomic’ does not name a type

2017-07-06 Thread STINNER Victor

STINNER Victor added the comment:

I don't think that CPython can be built by g++. If you consider that it
should, please open a new issue since it's a different use case.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23644] g++ module compile fails with ‘_Atomic’ does not name a type

2017-07-06 Thread Melroy van den Berg

Melroy van den Berg added the comment:

Yea I'm building Python 3.6.1 from source, using gcc and 
--with-cxx-main=correct/location/to/g++ flag. So the warning message appears 
during ./configure about that it can't find g++.

I didn't try to patch it using the attachments of this issue. Since I was 
hoping it's fixed in the release itself. I was using gcc/g++ version 4.9.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23644] g++ module compile fails with ‘_Atomic’ does not name a type

2017-07-06 Thread STINNER Victor

STINNER Victor added the comment:

See the following commit of bpo-25150:

commit 6df29ada02d22c43a8d439a70b820cb1ceacca42
Author: Victor Stinner 
Date:   Fri Sep 18 15:06:34 2015 +0200

Issue #25150: Hide the private _Py_atomic_xxx symbols from the public
Python.h header to fix a compilation error with OpenMP. PyThreadState_GET()
becomes an alias to PyThreadState_Get() to avoid ABI incompatibilies.

It is important that the _PyThreadState_Current variable is always accessed
with the same implementation of pyatomic.h. Use the PyThreadState_Get()
function so extension modules will all reuse the same implementation.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23644] g++ module compile fails with ‘_Atomic’ does not name a type

2017-07-06 Thread STINNER Victor

STINNER Victor added the comment:

> ./Include/pyatomic.h:37:5: error: 'atomic_int' does not name a type

I don't understand how you got this error. The line 37 of pyatomic.h is only 
compiled when you build Python itself. At least, since Python 3.5.1 and Python 
3.6.0.

Did you try to build Python? Or did you try to build a C extension?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23644] g++ module compile fails with ‘_Atomic’ does not name a type

2017-07-06 Thread STINNER Victor

STINNER Victor added the comment:

Oh, wait, I read your message backward. You said that the fix doesn't work?

Hum, how can I reproduce the issue? What is your use case?

--
resolution: fixed -> 
status: closed -> open

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23644] g++ module compile fails with ‘_Atomic’ does not name a type

2017-07-06 Thread Melroy van den Berg

Melroy van den Berg added the comment:

Ow sorry, I though it was already fixed in the latest stable version of 3.x. 
Since is issue is from 2015.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23644] g++ module compile fails with ‘_Atomic’ does not name a type

2017-07-06 Thread STINNER Victor

STINNER Victor added the comment:

> I'm using Python 3.6.1. It's not fixed!

Thanks for the confirmation of the fix ;-)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23644] g++ module compile fails with ‘_Atomic’ does not name a type

2017-07-06 Thread Melroy van den Berg

Melroy van den Berg added the comment:

I also got this problem with gcc/g++ version 4.9.3. 

./Include/pyatomic.h:37:5: error: 'atomic_int' does not name a type

I'm using Python 3.6.1. It's not fixed!

--
nosy: +Melroy van den Berg
versions: +Python 3.6 -Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23644] g++ module compile fails with ‘_Atomic’ does not name a type

2016-06-30 Thread Martin Ritter

Martin Ritter added the comment:

For me compiling 3.5.2 on GCC 5.2.0 fails when I supply --with-cxx-main=g++ 
with the same "error: ‘_Atomic’ does not name a type" messages.

I'm guessing that --with-cxx-main is probably outdated(?) but at least it 
worked with 3.5.0

--
nosy: +Martin Ritter

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23644] g++ module compile fails with ‘_Atomic’ does not name a type

2015-03-17 Thread STINNER Victor

STINNER Victor added the comment:

With the pystate_cplusplus.patch I was able to compile both min_example.tar.gz 
and my actual extension.  So I with your patch, it does work.  Thank you.

Cool! I applied this simple patch instead of trying to write an ugly glue in 
pyatomic.h between C and C++.

C and C++ simply look to be incompatible for handling atomic types :-/ The good 
news is that we don't them atomic types for Python extensions, only to compile 
Python core.

Thanks for the report. I prefer to detect such annoying issue before a .0 
release (3.5.0). FYI it's a regression introduced by the issue #22038 which 
started to use stdatomic.h (but it's now fixed).

--
resolution:  - fixed
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23644
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23644] g++ module compile fails with ‘_Atomic’ does not name a type

2015-03-17 Thread Roundup Robot

Roundup Robot added the comment:

New changeset cb05b6d7aacd by Victor Stinner in branch 'default':
Issue #23644: Fix issues with C++ when compiling Python extensions
https://hg.python.org/cpython/rev/cb05b6d7aacd

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23644
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23644] g++ module compile fails with ‘_Atomic’ does not name a type

2015-03-17 Thread Joshua J Cogliati

Joshua J Cogliati added the comment:

Once this is fixed, maybe issue 8027 can be fixed as well in 3.5.0.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23644
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23644] g++ module compile fails with ‘_Atomic’ does not name a type

2015-03-17 Thread Joshua J Cogliati

Joshua J Cogliati added the comment:

 @Joshua: Can you please try to compile your extension with  Py_LIMITED_API 
 defined? Ex: #define Py_LIMITED_API 0x0303 at the top of your C file, 
 or g++ -DPy_LIMITED_API=0x0303.

It fails in that case, because SWIG is using functions that are not part of the 
Py_LIMITED_API.  

 And can you also please try to patch Python with pystate_cplusplus.patch?

With the pystate_cplusplus.patch I was able to compile both min_example.tar.gz 
and my actual extension.  So I with your patch, it does work.  Thank you.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23644
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23644] g++ module compile fails with ‘_Atomic’ does not name a type

2015-03-17 Thread STINNER Victor

STINNER Victor added the comment:

 For third-party code, pyatomic.h is only needed by PyThreadState_GET() in 
 pystate.h. Maybe we should hide completly pyatomic.h. Currently, pyatomic.h 
 is not really used if Py_LIMITED_API is defined.

pystate_cplusplus.patch: disable completly pyatomic.h on C++, and modify 
pystate.h: PyThreadState_GET() is just an alias to PyThreadState_Get() with 
compiled with C++.

IMO pystate_cplusplus.patch makes more sense.

I don't understand the purpose of atomicfix.patch or pyatomic_cpp.patch, 
PyThreadState_GET() will not work with these patches.

--
Added file: http://bugs.python.org/file38519/pystate_cplusplus.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23644
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23644] g++ module compile fails with ‘_Atomic’ does not name a type

2015-03-17 Thread STINNER Victor

STINNER Victor added the comment:

Hum, I'm lost with the problem with C++ :-( What is your use case? Do you want 
to compile CPython with C++? Or compile a third-party extension with C++ and 
this extension includes Python.h which includes pyatomic.h.

For third-party code, pyatomic.h is only needed by PyThreadState_GET() in 
pystate.h. Maybe we should hide completly pyatomic.h. Currently, pyatomic.h is 
not really used if Py_LIMITED_API is defined.

By the way, can you try to compile the extension with Py_LIMITED_API? It should 
just work.


C++ 11 atomic:
---
#include atomic

int main()
{
std::atomic_uintptr_t current;
current.store(0, std::memory_order_relaxed);
return 0;
}
---


C++ 11 atomic used with C functions:
---
#include atomic

int main()
{
std::atomicuintptr_t current(0);
std::atomic_store_explicit(current, (uintptr_t)0, 
std::memory_order_relaxed);
return 0;
}
---

I didn't find how to use std::atomic_store_explicit with std::atomic_uintptr_t, 
so I used std::atomicuintptr_t instead.

std::atomic_store_explicit(current, 0, std::memory_order_relaxed); doesn't 
work: 0 must be explicitly cast to uintptr_t :-(

I tried to hack pyatomic.h to use std::atomic template: see attached 
pyatomic_cpp.patch.

But I don't understand: when PyThreadState_GET() is compiled in C++, should it 
use exactly the same functions of CPython (compiled with C)? It should be 
strange to to use a std::atomic C++ template to access an atomic C variable.

--
Added file: http://bugs.python.org/file38518/pyatomic_cpp.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23644
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23644] g++ module compile fails with ‘_Atomic’ does not name a type

2015-03-17 Thread STINNER Victor

STINNER Victor added the comment:

@Joshua: Can you please try to compile your extension with Py_LIMITED_API 
defined? Ex: #define Py_LIMITED_API 0x0303 at the top of your C file, or 
g++ -DPy_LIMITED_API=0x0303.

And can you also please try to patch Python with pystate_cplusplus.patch?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23644
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23644] g++ module compile fails with ‘_Atomic’ does not name a type

2015-03-17 Thread Joshua J Cogliati

Joshua J Cogliati added the comment:

Hum, I'm lost with the problem with C++ :-( What is your use case? Do you 
want to compile CPython with C++? Or compile a third-party extension with C++ 
and this extension includes Python.h which includes pyatomic.h.

My use case is I have C++ code that I want to use from a extension.  The 
extension includes Python.h, which includes pyatomic.h.  Thank you for looking 
into this.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23644
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23644] g++ module compile fails with ‘_Atomic’ does not name a type

2015-03-16 Thread STINNER Victor

STINNER Victor added the comment:

 using namespace std;

Doing this in a header is ugly.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23644
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23644] g++ module compile fails with ‘_Atomic’ does not name a type

2015-03-16 Thread STINNER Victor

STINNER Victor added the comment:

 #define _Atomic(T) std::atomicT

This looks better to me :-) Can you please write a patch?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23644
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23644] g++ module compile fails with ‘_Atomic’ does not name a type

2015-03-16 Thread Joshua J Cogliati

Joshua J Cogliati added the comment:

 using namespace std;

Doing this in a header is ugly.

If you put it in the:
#ifdef __cplusplus
extern C {
#endif

then it would only apply till the end of the pyatomic header, and not to 
anything that includes it.  Something like:

#ifdef __cplusplus
extern C {
#if defined(HAVE_STD_ATOMIC)
using namespace std;
#endif
#endif

But if you are already defining:
#define _Atomic(T) atomicT
maybe it should be:
#define _Atomic(T) std::atomicT

(I haven't checked any of this code, but they would get around the namespace 
std being changed in code that includes pyatomic.h problem. )

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23644
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23644] g++ module compile fails with ‘_Atomic’ does not name a type

2015-03-16 Thread Leonardo Bianconi

Leonardo Bianconi added the comment:

@haypo

For adding compatibility for atomics based on @Joshua.J.Cogliati change, I 
propose:

#ifndef Py_LIMITED_API
#ifndef Py_ATOMIC_H
#define Py_ATOMIC_H

#include dynamic_annotations.h

#include pyconfig.h

#if defined(HAVE_STD_ATOMIC)
#ifdef __cplusplus
#include atomic
#define _Atomic(T) atomicT
using namespace std;
#else
#include stdatomic.h
#endif
#endif

#ifdef __cplusplus
extern C {
#endif


/* This is modeled after the atomics interface from C1x, according to
 * the draft at
 * http://www.open-std.org/JTC1/SC22/wg14/www/docs/n1425.pdf.
 * Operations and types are named the same except with a _Py_ prefix
 * and have the same semantics.
 *
 * Beware, the implementations here are deep magic.
 */

#if defined(HAVE_STD_ATOMIC)

typedef enum _Py_memory_order {
_Py_memory_order_relaxed = memory_order_relaxed,
_Py_memory_order_acquire = memory_order_acquire,
_Py_memory_order_release = memory_order_release,
_Py_memory_order_acq_rel = memory_order_acq_rel,
_Py_memory_order_seq_cst = memory_order_seq_cst
} _Py_memory_order;

typedef struct _Py_atomic_address {
_Atomic (void) *_value;
} _Py_atomic_address;

typedef struct _Py_atomic_int {
atomic_int _value;
} _Py_atomic_int;


... (rest same)

--
keywords: +patch
Added file: http://bugs.python.org/file38508/atomicfix.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23644
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23644] g++ module compile fails with ‘_Atomic’ does not name a type

2015-03-16 Thread Leonardo Bianconi

Leonardo Bianconi added the comment:

 #define _Atomic(T) std::atomicT
Does not work, since there are definitions like memory_order_relaxed that are 
in std.

I tested the other one, and it works fine:
#ifdef __cplusplus
extern C {
#if defined(HAVE_STD_ATOMIC)
using namespace std;
#endif
#endif

@haypo, what do you think?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23644
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23644] g++ module compile fails with ‘_Atomic’ does not name a type

2015-03-16 Thread Arfrever Frehtes Taifersar Arahesis

Arfrever Frehtes Taifersar Arahesis added the comment:

So use std::memory_order_relaxed, std::memory_order_acquire etc.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23644
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23644] g++ module compile fails with ‘_Atomic’ does not name a type

2015-03-12 Thread Joshua J Cogliati

Joshua J Cogliati added the comment:

If I change the header to:
#ifndef Py_LIMITED_API
#ifndef Py_ATOMIC_H
#define Py_ATOMIC_H

#include dynamic_annotations.h

#include pyconfig.h

#ifdef __cplusplus
extern C {
#endif

#if defined(HAVE_STD_ATOMIC)
#ifdef __cplusplus
#include atomic
using namespace std;
#else
#include stdatomic.h
#endif
#endif

... (rest same)

AND use -std=c++11
Then the error changes to:
In file included from /local/python_fix/include/python3.5m/Python.h:53:0,
 from example_wrap.cxx:154:
/local/python_fix/include/python3.5m/pyatomic.h:42:5: error: ‘_Atomic’ does not 
name a type
 _Atomic void *_value;
 ^


Basically, atomic does define std::atomic_int, but it does not define 
_Atomic, so the line:
_Atomic void *_value;
will also need to be changed.

--
title: swig compile fails with ‘_Atomic’ does not name a type - g++ module 
compile fails with ‘_Atomic’ does not name a type

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23644
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23644] g++ module compile fails with ‘_Atomic’ does not name a type

2015-03-12 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:


--
nosy: +Arfrever

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23644
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com