atomics.h may not be included from frontend code

From: Aleksander Alekseev <a(dot)alekseev(at)postgrespro(dot)ru>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: Anastasia Lubennikova <a(dot)lubennikova(at)postgrespro(dot)ru>
Subject: atomics.h may not be included from frontend code
Date: 2018-02-27 13:49:00
Message-ID: 20180227134859.GD4023@e733.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2018-02-27 14:25:38 Re: TODO item for broken \s with libedit seems fixed
Previous Message Victor Wagner 2018-02-27 13:36:01 Re: MSVC builld of 9.5.12 is broken?