Skip to content

Commit b27c1c4

Browse files
committed
build: work around atomic<bool> absence on riscv64
riscv64 only has instructions for atomic<int32_t> (amoswap.w.aq) and atomic<long> (amoswap.d.aq), requiring library support for 8/16-bit quantities, which usually involves a mutex. Just pick a larger memory cell than waiting on such a mutex.
1 parent d282467 commit b27c1c4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+116
-107
lines changed

exch/exchange_emsmdb/asyncemsmdb_interface.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// SPDX-License-Identifier: GPL-2.0-only WITH linking exception
2-
#include <atomic>
32
#include <condition_variable>
43
#include <csignal>
54
#include <cstring>
65
#include <mutex>
76
#include <libHX/defs.h>
87
#include <libHX/string.h>
8+
#include <gromox/atomic.hpp>
99
#include <gromox/defs.h>
1010
#include "asyncemsmdb_interface.h"
1111
#include "emsmdb_interface.h"
@@ -43,7 +43,7 @@ static constexpr size_t TAG_SIZE = UADDR_SIZE + 1 + HXSIZEOF_Z32;
4343
static int g_threads_num;
4444
static pthread_t g_scan_id;
4545
static pthread_t *g_thread_ids;
46-
static std::atomic<bool> g_notify_stop{true};
46+
static gromox::atomic_bool g_notify_stop{true};
4747
static DOUBLE_LIST g_wakeup_list;
4848
static STR_HASH_TABLE *g_tag_hash;
4949
static std::mutex g_list_lock, g_async_lock;

exch/exchange_emsmdb/emsmdb_interface.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// SPDX-License-Identifier: GPL-2.0-only WITH linking exception
2-
#include <atomic>
32
#include <csignal>
43
#include <cstdint>
54
#include <mutex>
65
#include <libHX/string.h>
6+
#include <gromox/atomic.hpp>
77
#include <gromox/defs.h>
88
#include "asyncemsmdb_interface.h"
99
#include "emsmdb_interface.h"
@@ -76,7 +76,7 @@ static constexpr size_t TAG_SIZE = 256;
7676
static time_t g_start_time;
7777
static pthread_t g_scan_id;
7878
static std::mutex g_lock, g_notify_lock;
79-
static std::atomic<bool> g_notify_stop{true};
79+
static gromox::atomic_bool g_notify_stop{true};
8080
static pthread_key_t g_handle_key;
8181
static STR_HASH_TABLE *g_user_hash;
8282
static STR_HASH_TABLE *g_handle_hash;

exch/exchange_emsmdb/rop_processor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// SPDX-License-Identifier: GPL-2.0-only WITH linking exception
2-
#include <atomic>
32
#include <csignal>
43
#include <cstdint>
54
#include <cstring>
65
#include <mutex>
6+
#include <gromox/atomic.hpp>
77
#include <gromox/defs.h>
88
#include "subscription_object.h"
99
#include "fastdownctx_object.h"
@@ -64,7 +64,7 @@ struct OBJECT_NODE {
6464
static int g_scan_interval;
6565
static pthread_t g_scan_id;
6666
static int g_average_handles;
67-
static std::atomic<bool> g_notify_stop{true};
67+
static gromox::atomic_bool g_notify_stop{true};
6868
static std::mutex g_hash_lock;
6969
static STR_HASH_TABLE *g_logon_hash;
7070
static LIB_BUFFER *g_logmap_allocator;

exch/exchange_nsp/ab_tree.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0-only WITH linking exception
22
// SPDX-FileCopyrightText: 2021 grommunio GmbH
33
// This file is part of Gromox.
4-
#include <atomic>
54
#include <cstdint>
65
#include <memory>
76
#include <mutex>
@@ -11,6 +10,7 @@
1110
#include <utility>
1211
#include <vector>
1312
#include <libHX/string.h>
13+
#include <gromox/atomic.hpp>
1414
#include <gromox/defs.h>
1515
#include <gromox/fileio.h>
1616
#include <gromox/util.hpp>
@@ -82,7 +82,7 @@ struct ab_sort_item {
8282

8383
static size_t g_base_size;
8484
static int g_file_blocks, g_ab_cache_interval;
85-
static std::atomic<bool> g_notify_stop{false};
85+
static gromox::atomic_bool g_notify_stop{false};
8686
static pthread_t g_scan_id;
8787
static char g_nsp_org_name[256];
8888
static std::unordered_map<int, AB_BASE> g_base_hash;

exch/exmdb_provider/db_engine.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// SPDX-License-Identifier: GPL-2.0-only WITH linking exception
2-
#include <atomic>
32
#include <chrono>
43
#include <csignal>
54
#include <cstdint>
@@ -8,6 +7,7 @@
87
#include <string>
98
#include <unordered_map>
109
#include <vector>
10+
#include <gromox/atomic.hpp>
1111
#include <gromox/database.h>
1212
#include <gromox/exmdb_rpc.hpp>
1313
#include <gromox/mapidefs.h>
@@ -95,7 +95,7 @@ static BOOL g_wal;
9595
static BOOL g_async;
9696
static size_t g_table_size; /* hash table size */
9797
static int g_threads_num;
98-
static std::atomic<bool> g_notify_stop{false}; /* stop signal for scaning thread */
98+
static gromox::atomic_bool g_notify_stop{false}; /* stop signal for scaning thread */
9999
static pthread_t g_scan_tid;
100100
static uint64_t g_mmap_size;
101101
static int g_cache_interval; /* maximum living interval in table */

exch/exmdb_provider/exmdb_client.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// SPDX-FileCopyrightText: 2021 grommunio GmbH
33
// This file is part of Gromox.
44
#include <algorithm>
5-
#include <atomic>
65
#include <list>
76
#include <cstdint>
87
#include <list>
@@ -11,6 +10,7 @@
1110
#include <utility>
1211
#include <vector>
1312
#include <libHX/string.h>
13+
#include <gromox/atomic.hpp>
1414
#include <gromox/defs.h>
1515
#include <gromox/exmdb_rpc.hpp>
1616
#include <gromox/socket.h>
@@ -73,7 +73,7 @@ static int cl_wr_sock(int fd, const BINARY *b) { return exmdb_client_write_socke
7373

7474
static int g_conn_num;
7575
static int g_threads_num;
76-
static std::atomic<bool> g_notify_stop{false};
76+
static gromox::atomic_bool g_notify_stop{false};
7777
static pthread_t g_scan_id;
7878
static std::list<REMOTE_CONN> g_lost_list;
7979
static std::list<AGENT_THREAD> g_agent_list;

exch/exmdb_provider/exmdb_listener.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// SPDX-License-Identifier: GPL-2.0-only WITH linking exception
22
#include <algorithm>
3-
#include <atomic>
43
#include <cerrno>
54
#include <csignal>
65
#include <cstdint>
76
#include <string>
87
#include <utility>
98
#include <vector>
109
#include <libHX/string.h>
10+
#include <gromox/atomic.hpp>
1111
#include <gromox/defs.h>
1212
#include <gromox/exmdb_rpc.hpp>
1313
#include <gromox/socket.h>
@@ -29,7 +29,7 @@ using namespace gromox;
2929

3030
static uint16_t g_listen_port;
3131
static int g_listen_sockd;
32-
static std::atomic<bool> g_notify_stop{false};
32+
static gromox::atomic_bool g_notify_stop{false};
3333
static char g_listen_ip[40];
3434
static std::vector<std::string> g_acl_list;
3535
static pthread_t g_listener_id;

exch/exmdb_provider/exmdb_parser.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#pragma once
2-
#include <atomic>
32
#include <condition_variable>
43
#include <memory>
54
#include <mutex>
65
#include <string>
6+
#include <gromox/atomic.hpp>
77
#include <gromox/common_types.hpp>
88
#include <gromox/double_list.hpp>
99
#include <pthread.h>
@@ -19,7 +19,7 @@ class EXMDB_CONNECTION : public std::enable_shared_from_this<EXMDB_CONNECTION> {
1919
~EXMDB_CONNECTION();
2020
void operator=(EXMDB_CONNECTION &&) = delete;
2121

22-
std::atomic<bool> b_stop{false};
22+
gromox::atomic_bool b_stop{false};
2323
pthread_t thr_id{};
2424
std::string remote_id;
2525
int sockd = -1;
@@ -31,7 +31,7 @@ struct ROUTER_CONNECTION {
3131
~ROUTER_CONNECTION();
3232
void operator=(ROUTER_CONNECTION &&) = delete;
3333

34-
std::atomic<bool> b_stop{false};
34+
gromox::atomic_bool b_stop{false};
3535
pthread_t thr_id{};
3636
std::string remote_id;
3737
int sockd = -1;

exch/http/http_parser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
/* http parser is a module, which first read data from socket, parses rpc over http and
55
relay the stream to pdu processor. it also process other http request
66
*/
7-
#include <atomic>
87
#include <cassert>
98
#include <cerrno>
109
#include <mutex>
@@ -13,6 +12,7 @@
1312
#include <utility>
1413
#include <vector>
1514
#include <libHX/string.h>
15+
#include <gromox/atomic.hpp>
1616
#include <gromox/defs.h>
1717
#include <gromox/fileio.h>
1818
#include <gromox/util.hpp>
@@ -81,7 +81,7 @@ class VCONN_REF {
8181
}
8282

8383
static size_t g_context_num;
84-
static std::atomic<bool> g_async_stop{false};
84+
static gromox::atomic_bool g_async_stop{false};
8585
static BOOL g_support_ssl;
8686
static SSL_CTX *g_ssl_ctx;
8787
static int g_max_auth_times;

exch/http/listener.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
* connection is legal, construct a context to represent the connection and
66
* throw it into contexts pool, or close the connection
77
*/
8-
#include <atomic>
98
#include <cerrno>
109
#include <csignal>
1110
#include <cstdint>
1211
#include <libHX/string.h>
12+
#include <gromox/atomic.hpp>
1313
#include <gromox/fileio.h>
1414
#include <gromox/socket.h>
1515
#include "listener.h"
@@ -33,7 +33,7 @@ static void *htls_thrwork(void *);
3333
static void *htls_thrworkssl(void *);
3434

3535
static int g_mss_size;
36-
static std::atomic<bool> g_stop_accept{false};
36+
static gromox::atomic_bool g_stop_accept{false};
3737
static pthread_t g_thr_id;
3838
static int g_listener_sock;
3939
static uint16_t g_listener_port, g_listener_ssl_port;

0 commit comments

Comments
 (0)