atomics.h may not be included from frontend code - Mailing list pgsql-hackers

From Aleksander Alekseev
Subject atomics.h may not be included from frontend code
Date
Msg-id 20180227134859.GD4023@e733.localdomain
Whole thread Raw
Responses Re: atomics.h may not be included from frontend code
List pgsql-hackers
Hello hackers,

My colleague Anastasia Lubennikova and I were discussing a weird piece
of code in src/include/port/atomics.h:

```
#ifdef FRONTEND
#error "atomics.h may not be included from frontend code"
#endif
```

We tried to follow commit messages [1] and discussions [2]. However no matter
how you try to look on this code it's weird.

Basically it says that atomics are written the way that they can be used
from one code and can't be used from another. So if you want to write a
cross-platform parallel incremental backup tool (what Anastasia is
currently working on) you have to use C++ and std::atomic (since MS
doesn't develops C anymore) or write something like:

```
#undef FRONTEND
#include <atomics.h>
#define FRONTEND
```

We would like to know whether you share this concern and whether it
would be a good idea to try to refactor the code so that atomics could
be used not only from the backend.

[1]: https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=4eda0a64705
[2]: https://postgr.es/m/20150806070902.GE12214@awork2.anarazel.de

--
Best regards,
Aleksander Alekseev

Attachment

pgsql-hackers by date:

Previous
From: Victor Wagner
Date:
Subject: Re: MSVC builld of 9.5.12 is broken?
Next
From: Tom Lane
Date:
Subject: Re: TODO item for broken \s with libedit seems fixed