Skip to content

Commit

Permalink
Reorganize top-level headers in libnetdata. (netdata#18643)
Browse files Browse the repository at this point in the history
Move top-level libnetdata headers (simple hashtable,
bitmap, linked list, xxHash) into more
specific subdirectories and update the
corresponding include paths throughout the
project to reflect these changes.
  • Loading branch information
vkalintiris authored Oct 23, 2024
1 parent 44e7fc6 commit 281b298
Show file tree
Hide file tree
Showing 23 changed files with 33 additions and 32 deletions.
8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,7 @@ set(LIBNETDATA_FILES
src/libnetdata/aral/aral.h
src/libnetdata/avl/avl.c
src/libnetdata/avl/avl.h
src/libnetdata/bitmap/bitmap64.h
src/libnetdata/buffer/buffer.c
src/libnetdata/buffer/buffer.h
src/libnetdata/ringbuffer/ringbuffer.c
Expand Down Expand Up @@ -674,6 +675,7 @@ set(LIBNETDATA_FILES
src/libnetdata/line_splitter/line_splitter.c
src/libnetdata/line_splitter/line_splitter.h
src/libnetdata/libnetdata.h
src/libnetdata/linked_lists/linked_lists.h
src/libnetdata/locks/locks.c
src/libnetdata/locks/locks.h
src/libnetdata/log/systemd-journal-helpers.c
Expand All @@ -682,7 +684,6 @@ set(LIBNETDATA_FILES
src/libnetdata/log/nd_log.h
src/libnetdata/os/os.c
src/libnetdata/os/os.h
src/libnetdata/simple_hashtable.h
src/libnetdata/os/byteorder.h
src/libnetdata/onewayalloc/onewayalloc.c
src/libnetdata/onewayalloc/onewayalloc.h
Expand All @@ -693,6 +694,8 @@ set(LIBNETDATA_FILES
src/libnetdata/required_dummies.h
src/libnetdata/socket/security.c
src/libnetdata/socket/security.h
src/libnetdata/simple_hashtable/simple_hashtable.h
src/libnetdata/simple_hashtable/simple_hashtable_undef.h
src/libnetdata/simple_pattern/simple_pattern.c
src/libnetdata/simple_pattern/simple_pattern.h
src/libnetdata/socket/socket.c
Expand Down Expand Up @@ -733,11 +736,9 @@ set(LIBNETDATA_FILES
src/libnetdata/dictionary/dictionary-hashtable.h
src/libnetdata/dictionary/dictionary-item.h
src/libnetdata/dictionary/dictionary-callbacks.h
src/libnetdata/linked-lists.h
src/libnetdata/storage-point.h
src/libnetdata/parsers/parsers.h
src/libnetdata/parsers/duration.c
src/libnetdata/bitmap64.h
src/libnetdata/os/gettid.c
src/libnetdata/os/gettid.h
src/libnetdata/os/adjtimex.c
Expand Down Expand Up @@ -860,6 +861,7 @@ set(LIBNETDATA_FILES
src/libnetdata/log/nd_log-common.h
src/libnetdata/log/nd_log-to-windows-common.h
src/libnetdata/common.h
src/libnetdata/xxHash/xxhash.h
)

if(ENABLE_PLUGIN_EBPF)
Expand Down
2 changes: 1 addition & 1 deletion src/collectors/apps.plugin/apps_pid.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ static inline void link_pid_to_its_parent(struct pid_stat *p);
#define SIMPLE_HASHTABLE_VALUE2KEY_FUNCTION pid_stat_to_pid_ptr
#define SIMPLE_HASHTABLE_COMPARE_KEYS_FUNCTION pid_ptr_eq
#define SIMPLE_HASHTABLE_SAMPLE_IMPLEMENTATION 0
#include "libnetdata/simple_hashtable.h"
#include "libnetdata/simple_hashtable/simple_hashtable.h"

static inline int32_t *pid_stat_to_pid_ptr(struct pid_stat *p) {
return &p->pid;
Expand Down
6 changes: 3 additions & 3 deletions src/collectors/log2journal/log2journal.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ static inline void freez(void *ptr) {
// ----------------------------------------------------------------------------

#define XXH_INLINE_ALL
#include "libnetdata/xxhash.h"
#include "libnetdata/xxHash/xxhash.h"

#define PCRE2_CODE_UNIT_WIDTH 8
#include <pcre2.h>
Expand All @@ -122,14 +122,14 @@ static inline void freez(void *ptr) {
// hashtable for HASHED_KEY

// cleanup hashtable defines
#include "libnetdata/simple_hashtable_undef.h"
#include "libnetdata/simple_hashtable/simple_hashtable_undef.h"

struct hashed_key;
static inline int compare_keys(struct hashed_key *k1, struct hashed_key *k2);
#define SIMPLE_HASHTABLE_SORT_FUNCTION compare_keys
#define SIMPLE_HASHTABLE_VALUE_TYPE struct hashed_key
#define SIMPLE_HASHTABLE_NAME _KEY
#include "libnetdata/simple_hashtable.h"
#include "libnetdata/simple_hashtable/simple_hashtable.h"

// ----------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion src/collectors/network-viewer.plugin/network-viewer.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static SPAWN_SERVER *spawn_srv = NULL;

#define SIMPLE_HASHTABLE_VALUE_TYPE LOCAL_SOCKET
#define SIMPLE_HASHTABLE_NAME _AGGREGATED_SOCKETS
#include "libnetdata/simple_hashtable.h"
#include "libnetdata/simple_hashtable/simple_hashtable.h"

netdata_mutex_t stdout_mutex = NETDATA_MUTEX_INITIALIZER;
static bool plugin_should_exit = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ typedef struct field_value {
#define SIMPLE_HASHTABLE_VALUE2KEY_FUNCTION field_cache_value_to_key
#define SIMPLE_HASHTABLE_COMPARE_KEYS_FUNCTION field_cache_cache_compar
#define SIMPLE_HASHTABLE_SAMPLE_IMPLEMENTATION 1
#include "libnetdata/simple_hashtable.h"
#include "libnetdata/simple_hashtable/simple_hashtable.h"

static inline WEVT_FIELD_KEY *field_cache_value_to_key(WEVT_FIELD_VALUE *p) {
return &p->key;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ typedef struct provider {
#define SIMPLE_HASHTABLE_VALUE2KEY_FUNCTION provider_value_to_key
#define SIMPLE_HASHTABLE_COMPARE_KEYS_FUNCTION provider_cache_compar
#define SIMPLE_HASHTABLE_SAMPLE_IMPLEMENTATION 1
#include "libnetdata/simple_hashtable.h"
#include "libnetdata/simple_hashtable/simple_hashtable.h"

static struct {
SPINLOCK spinlock;
Expand Down
1 change: 0 additions & 1 deletion src/database/engine/journalfile.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// SPDX-License-Identifier: GPL-3.0-or-later
#include "libnetdata/bitmap64.h"
#include "rrdengine.h"

static void after_extent_write_journalfile_v1_io(uv_fs_t* req)
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/libnetdata/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ typedef uint32_t uid_t;
#endif

#define XXH_INLINE_ALL
#include "xxhash.h"
#include "xxHash/xxhash.h"

// --------------------------------------------------------------------------------------------------------------------
// OpenSSL
Expand Down Expand Up @@ -378,7 +378,7 @@ typedef uint32_t uid_t;
// --------------------------------------------------------------------------------------------------------------------
// Macro-only includes

#include "linked-lists.h"
#include "linked_lists/linked_lists.h"

// --------------------------------------------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion src/libnetdata/config/dyncfg.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-or-later

#include "../../libnetdata/libnetdata.h"
#include "../libnetdata.h"

// ----------------------------------------------------------------------------

Expand Down
8 changes: 4 additions & 4 deletions src/libnetdata/facets/facets.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,25 +102,25 @@ static inline bool is_valid_string_hash(const char *s) {
// hashtable for FACET_VALUE

// cleanup hashtable defines
#include "../../libnetdata/simple_hashtable_undef.h"
#include "../simple_hashtable/simple_hashtable_undef.h"

struct facet_value;
// #define SIMPLE_HASHTABLE_SORT_FUNCTION compare_facet_value
#define SIMPLE_HASHTABLE_VALUE_TYPE struct facet_value
#define SIMPLE_HASHTABLE_NAME _VALUE
#include "../simple_hashtable.h"
#include "../simple_hashtable/simple_hashtable.h"

// ----------------------------------------------------------------------------
// hashtable for FACET_KEY

// cleanup hashtable defines
#include "../../libnetdata/simple_hashtable_undef.h"
#include "../simple_hashtable/simple_hashtable_undef.h"

struct facet_key;
// #define SIMPLE_HASHTABLE_SORT_FUNCTION compare_facet_key
#define SIMPLE_HASHTABLE_VALUE_TYPE struct facet_key
#define SIMPLE_HASHTABLE_NAME _KEY
#include "../simple_hashtable.h"
#include "../simple_hashtable/simple_hashtable.h"

// ----------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion src/libnetdata/libnetdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ char *find_and_replace(const char *src, const char *find, const char *replace, c

#define error_report(x, args...) do { errno_clear(); netdata_log_error(x, ##args); } while(0)

#include "bitmap64.h"
#include "bitmap/bitmap64.h"

#define COMPRESSION_MAX_CHUNK 0x4000
#define COMPRESSION_MAX_OVERHEAD 128
Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions src/libnetdata/local-sockets/local-sockets.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

#define SIMPLE_HASHTABLE_VALUE_TYPE uint64_t
#define SIMPLE_HASHTABLE_NAME _NET_NS
#include "libnetdata/simple_hashtable.h"
#include "libnetdata/simple_hashtable/simple_hashtable.h"

// --------------------------------------------------------------------------------------------------------------------
// hashtable for keeping the sockets of PIDs
Expand All @@ -38,7 +38,7 @@
struct pid_socket;
#define SIMPLE_HASHTABLE_VALUE_TYPE struct pid_socket
#define SIMPLE_HASHTABLE_NAME _PID_SOCKET
#include "libnetdata/simple_hashtable.h"
#include "libnetdata/simple_hashtable/simple_hashtable.h"

// --------------------------------------------------------------------------------------------------------------------
// hashtable for keeping all the sockets
Expand All @@ -47,7 +47,7 @@ struct pid_socket;
struct local_socket;
#define SIMPLE_HASHTABLE_VALUE_TYPE struct local_socket
#define SIMPLE_HASHTABLE_NAME _LOCAL_SOCKET
#include "libnetdata/simple_hashtable.h"
#include "libnetdata/simple_hashtable/simple_hashtable.h"

// --------------------------------------------------------------------------------------------------------------------
// hashtable for keeping all local IPs
Expand All @@ -56,7 +56,7 @@ struct local_socket;
union ipv46;
#define SIMPLE_HASHTABLE_VALUE_TYPE union ipv46
#define SIMPLE_HASHTABLE_NAME _LOCAL_IP
#include "libnetdata/simple_hashtable.h"
#include "libnetdata/simple_hashtable/simple_hashtable.h"

// --------------------------------------------------------------------------------------------------------------------
// hashtable for keeping all listening ports
Expand All @@ -65,7 +65,7 @@ union ipv46;
struct local_port;
#define SIMPLE_HASHTABLE_VALUE_TYPE struct local_port
#define SIMPLE_HASHTABLE_NAME _LISTENING_PORT
#include "libnetdata/simple_hashtable.h"
#include "libnetdata/simple_hashtable/simple_hashtable.h"

// --------------------------------------------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion src/libnetdata/os/system-maps/cached-gid-groupname.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define SIMPLE_HASHTABLE_VALUE2KEY_FUNCTION cached_groupname_to_gid_ptr
#define SIMPLE_HASHTABLE_COMPARE_KEYS_FUNCTION compar_gid_ptr
#define SIMPLE_HASHTABLE_NAME _GROUPNAMES_CACHE
#include "libnetdata/simple_hashtable.h"
#include "libnetdata/simple_hashtable/simple_hashtable.h"

static struct {
bool initialized;
Expand Down
2 changes: 1 addition & 1 deletion src/libnetdata/os/system-maps/cached-sid-username.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ typedef struct {
#define SIMPLE_HASHTABLE_VALUE2KEY_FUNCTION sid_value_to_key
#define SIMPLE_HASHTABLE_COMPARE_KEYS_FUNCTION sid_cache_compar
#define SIMPLE_HASHTABLE_SAMPLE_IMPLEMENTATION 1
#include "libnetdata/simple_hashtable.h"
#include "libnetdata/simple_hashtable/simple_hashtable.h"

static struct {
SPINLOCK spinlock;
Expand Down
2 changes: 1 addition & 1 deletion src/libnetdata/os/system-maps/cached-uid-username.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define SIMPLE_HASHTABLE_VALUE2KEY_FUNCTION cached_username_to_uid_ptr
#define SIMPLE_HASHTABLE_COMPARE_KEYS_FUNCTION compar_uid_ptr
#define SIMPLE_HASHTABLE_NAME _USERNAMES_CACHE
#include "libnetdata/simple_hashtable.h"
#include "libnetdata/simple_hashtable/simple_hashtable.h"

static struct {
uint32_t version;
Expand Down
2 changes: 1 addition & 1 deletion src/libnetdata/os/system-maps/system-services.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#define SIMPLE_HASHTABLE_VALUE_TYPE STRING
#define SIMPLE_HASHTABLE_NAME _SERVICENAMES_CACHE
#include "libnetdata/simple_hashtable.h"
#include "libnetdata/simple_hashtable/simple_hashtable.h"

typedef struct servicenames_cache {
SPINLOCK spinlock;
Expand Down
2 changes: 1 addition & 1 deletion src/libnetdata/os/windows-perflib/perflib-names.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static inline const char *value2key_perfLibRegistryEntry(perfLibRegistryEntry *e
#define SIMPLE_HASHTABLE_KEY_TYPE const char
#define SIMPLE_HASHTABLE_VALUE_TYPE perfLibRegistryEntry
#define SIMPLE_HASHTABLE_NAME _PERFLIB
#include "libnetdata/simple_hashtable.h"
#include "libnetdata/simple_hashtable/simple_hashtable.h"

static struct {
SPINLOCK spinlock;
Expand Down
4 changes: 2 additions & 2 deletions src/libnetdata/query_progress/progress.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
// hashtable for HASHED_KEY

// cleanup hashtable defines
#include "../simple_hashtable_undef.h"
#include "../simple_hashtable/simple_hashtable_undef.h"

struct query;
#define SIMPLE_HASHTABLE_VALUE_TYPE struct query
#define SIMPLE_HASHTABLE_KEY_TYPE nd_uuid_t
#define SIMPLE_HASHTABLE_NAME _QUERY
#define SIMPLE_HASHTABLE_VALUE2KEY_FUNCTION query_transaction
#define SIMPLE_HASHTABLE_COMPARE_KEYS_FUNCTION query_compare_keys
#include "../simple_hashtable.h"
#include "../simple_hashtable/simple_hashtable.h"

// ----------------------------------------------------------------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ static inline SIMPLE_HASHTABLE_SLOT_NAMED *simple_hashtable_next_read_only_named
#ifndef XXH_INLINE_ALL
#define XXH_INLINE_ALL
#endif
#include "xxhash.h"
#include "../xxHash/xxhash.h"

#define simple_hashtable_set_named CONCAT(simple_hashtable_set, SIMPLE_HASHTABLE_NAME)
#define simple_hashtable_get_named CONCAT(simple_hashtable_get, SIMPLE_HASHTABLE_NAME)
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 281b298

Please sign in to comment.