-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Import raft sources; get dqlite tests passing
Signed-off-by: Cole Miller <cole.miller@canonical.com>
- Loading branch information
1 parent
94938c8
commit 2961582
Showing
111 changed files
with
21,269 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#include <raft.h> | ||
#include "../raft.h" | ||
|
||
#include "../../include/dqlite.h" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#ifndef LOGGER_H_ | ||
#define LOGGER_H_ | ||
|
||
#include <raft.h> | ||
#include "raft.h" | ||
|
||
#include "../include/dqlite.h" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* Macros to manipulate contiguous arrays. */ | ||
|
||
#ifndef ARRAY_H_ | ||
#define ARRAY_H_ | ||
|
||
#include "../raft.h" | ||
|
||
/* Append item I of type T to array A which currently has N items. | ||
* | ||
* A and N must both by pointers. Set RV to -1 in case of failure. */ | ||
#define ARRAY__APPEND(T, I, A, N, RV) \ | ||
{ \ | ||
T *tmp_array; \ | ||
tmp_array = raft_realloc(*A, (*N + 1) * sizeof **A); \ | ||
if (tmp_array != NULL) { \ | ||
(*N)++; \ | ||
*A = tmp_array; \ | ||
(*A)[(*N) - 1] = I; \ | ||
RV = 0; \ | ||
} else { \ | ||
RV = -1; \ | ||
} \ | ||
} | ||
|
||
#endif /* ARRAY_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* Define the assert() macro, either as the standard one or the test one. */ | ||
|
||
#ifndef ASSERT_H_ | ||
#define ASSERT_H_ | ||
|
||
#if defined(RAFT_TEST) | ||
extern void munit_errorf_ex(const char *filename, | ||
int line, | ||
const char *format, | ||
...); | ||
#define assert(expr) \ | ||
do { \ | ||
if (!expr) { \ | ||
munit_errorf_ex(__FILE__, __LINE__, "assertion failed: ", #expr); \ | ||
} \ | ||
} while (0) | ||
#elif defined(NDEBUG) | ||
#define assert(x) \ | ||
do { \ | ||
(void)sizeof(x); \ | ||
} while (0) | ||
#elif defined(RAFT_ASSERT_WITH_BACKTRACE) | ||
#include <assert.h> /* for __assert_fail */ | ||
#include <backtrace.h> | ||
#include <stdio.h> | ||
#undef assert | ||
#define assert(x) \ | ||
do { \ | ||
struct backtrace_state *state_; \ | ||
if (!(x)) { \ | ||
state_ = backtrace_create_state(NULL, 0, NULL, NULL); \ | ||
backtrace_print(state_, 0, stderr); \ | ||
__assert_fail(#x, __FILE__, __LINE__, __func__); \ | ||
} \ | ||
} while (0) | ||
#else | ||
#include <assert.h> | ||
#endif | ||
|
||
#endif /* ASSERT_H_ */ |
Oops, something went wrong.