Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
BreakStringLiterals: true
ColumnLimit: 80
ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerIndentWidth: 4
Expand Down
624 changes: 261 additions & 363 deletions src/common/bson-dsl.h

Large diffs are not rendered by default.

11 changes: 3 additions & 8 deletions src/common/common-b64-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@

#include <bson/bson.h>

#define mcommon_b64_ntop_calculate_target_size \
COMMON_NAME (b64_ntop_calculate_target_size)
#define mcommon_b64_pton_calculate_target_size \
COMMON_NAME (b64_pton_calculate_target_size)
#define mcommon_b64_ntop_calculate_target_size COMMON_NAME (b64_ntop_calculate_target_size)
#define mcommon_b64_pton_calculate_target_size COMMON_NAME (b64_pton_calculate_target_size)
#define mcommon_b64_ntop COMMON_NAME (b64_ntop)
#define mcommon_b64_pton COMMON_NAME (b64_pton)

Expand All @@ -47,10 +45,7 @@ mcommon_b64_pton_calculate_target_size (size_t base64_encoded_size);
* hence the obscure name "ntop".
*/
int
mcommon_b64_ntop (uint8_t const *src,
size_t srclength,
char *target,
size_t targsize);
mcommon_b64_ntop (uint8_t const *src, size_t srclength, char *target, size_t targsize);

/** If target is not NULL, the number of bytes written to target on success or
* -1 on error. If target is NULL, returns the exact number of bytes that would
Expand Down
11 changes: 3 additions & 8 deletions src/common/common-b64.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@
if (!(Cond)) \
abort ()

static const char Base64[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
static const char Base64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
static const char Pad64 = '=';

/* (From RFC1521 and draft-ietf-dnssec-secext-03.txt)
Expand Down Expand Up @@ -114,10 +113,7 @@ static const char Pad64 = '=';
*/

int
mcommon_b64_ntop (uint8_t const *src,
size_t srclength,
char *target,
size_t targsize)
mcommon_b64_ntop (uint8_t const *src, size_t srclength, char *target, size_t targsize)
{
size_t datalength = 0;
uint8_t input[3];
Expand Down Expand Up @@ -275,8 +271,7 @@ static const uint8_t mongoc_b64rmap_invalid = 0xff;
#define mongoc_common_once_t INIT_ONCE
#define MONGOC_COMMON_ONCE_INIT INIT_ONCE_STATIC_INIT
#define mongoc_common_once(o, c) InitOnceExecuteOnce (o, c, NULL, NULL)
#define MONGOC_COMMON_ONCE_FUN(n) \
BOOL CALLBACK n (PINIT_ONCE _ignored_a, PVOID _ignored_b, PVOID *_ignored_c)
#define MONGOC_COMMON_ONCE_FUN(n) BOOL CALLBACK n (PINIT_ONCE _ignored_a, PVOID _ignored_b, PVOID *_ignored_c)
#define MONGOC_COMMON_ONCE_RETURN return true
#endif

Expand Down
7 changes: 3 additions & 4 deletions src/common/common-md5.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,9 @@ mcommon_md5_append (bson_md5_t *pms, const uint8_t *data, uint32_t nbytes)
void
mcommon_md5_finish (bson_md5_t *pms, uint8_t digest[16])
{
static const uint8_t pad[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
static const uint8_t pad[64] = {0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
uint8_t data[8];
int i;

Expand Down
3 changes: 1 addition & 2 deletions src/common/common-prelude.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
* limitations under the License.
*/

#if !defined(MONGOC_INSIDE) && !defined(MONGOC_COMPILATION) && \
!defined(BSON_COMPILATION) && !defined(BSON_INSIDE)
#if !defined(MONGOC_INSIDE) && !defined(MONGOC_COMPILATION) && !defined(BSON_COMPILATION) && !defined(BSON_INSIDE)
#error "Only <mongoc/mongoc.h> or <bson/bson.h> can be included directly."
#endif

Expand Down
16 changes: 5 additions & 11 deletions src/common/common-thread-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ BSON_BEGIN_DECLS
} while (0)
#define bson_once_t pthread_once_t
#define bson_thread_t pthread_t
#define BSON_THREAD_FUN(_function_name, _arg_name) \
void *(_function_name) (void *(_arg_name))
#define BSON_THREAD_FUN(_function_name, _arg_name) void *(_function_name) (void *(_arg_name))
#define BSON_THREAD_FUN_TYPE(_function_name) void *(*(_function_name)) (void *)
#define BSON_THREAD_RETURN return NULL

Expand Down Expand Up @@ -114,8 +113,7 @@ typedef struct {

#else
#include <process.h>
#define BSON_ONCE_FUN(n) \
BOOL CALLBACK n (PINIT_ONCE _ignored_a, PVOID _ignored_b, PVOID *_ignored_c)
#define BSON_ONCE_FUN(n) BOOL CALLBACK n (PINIT_ONCE _ignored_a, PVOID _ignored_b, PVOID *_ignored_c)
#define BSON_ONCE_INIT INIT_ONCE_STATIC_INIT
#define BSON_ONCE_RETURN return true
#define bson_mutex_destroy DeleteCriticalSection
Expand All @@ -129,10 +127,8 @@ typedef struct {
} while (0)
#define bson_once_t INIT_ONCE
#define bson_thread_t HANDLE
#define BSON_THREAD_FUN(_function_name, _arg_name) \
unsigned (__stdcall _function_name) (void *(_arg_name))
#define BSON_THREAD_FUN_TYPE(_function_name) \
unsigned (__stdcall * _function_name) (void *)
#define BSON_THREAD_FUN(_function_name, _arg_name) unsigned (__stdcall _function_name) (void *(_arg_name))
#define BSON_THREAD_FUN_TYPE(_function_name) unsigned (__stdcall * _function_name) (void *)
#define BSON_THREAD_RETURN return 0
#endif

Expand All @@ -145,9 +141,7 @@ mcommon_thread_join (bson_thread_t thread);
// error. Callers may use `bson_strerror_r` to get an error message from the
// returned error code.
int
mcommon_thread_create (bson_thread_t *thread,
BSON_THREAD_FUN_TYPE (func),
void *arg);
mcommon_thread_create (bson_thread_t *thread, BSON_THREAD_FUN_TYPE (func), void *arg);

#if defined(MONGOC_ENABLE_DEBUG_ASSERTIONS) && defined(BSON_OS_UNIX)
#define mcommon_mutex_is_locked COMMON_NAME (mutex_is_locked)
Expand Down
11 changes: 3 additions & 8 deletions src/common/common-thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@

#if defined(BSON_OS_UNIX)
int
mcommon_thread_create (bson_thread_t *thread,
BSON_THREAD_FUN_TYPE (func),
void *arg)
mcommon_thread_create (bson_thread_t *thread, BSON_THREAD_FUN_TYPE (func), void *arg)
{
BSON_ASSERT_PARAM (thread);
BSON_ASSERT_PARAM (func);
Expand All @@ -39,16 +37,13 @@ mcommon_thread_join (bson_thread_t thread)
bool
mcommon_mutex_is_locked (bson_mutex_t *mutex)
{
return mutex->valid_tid &&
pthread_equal (pthread_self (), mutex->lock_owner);
return mutex->valid_tid && pthread_equal (pthread_self (), mutex->lock_owner);
}
#endif

#else
int
mcommon_thread_create (bson_thread_t *thread,
BSON_THREAD_FUN_TYPE (func),
void *arg)
mcommon_thread_create (bson_thread_t *thread, BSON_THREAD_FUN_TYPE (func), void *arg)
{
BSON_ASSERT_PARAM (thread);
BSON_ASSERT_PARAM (func);
Expand Down
3 changes: 1 addition & 2 deletions src/libbson/examples/bcon-col-view.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ main (void)
bson_t *bson;
char *json;

bson = COL_VIEW_CREATE (
SORT ("a", BCON_INT32 (1)), QUERY ("hello", "world"), LIMIT (10));
bson = COL_VIEW_CREATE (SORT ("a", BCON_INT32 (1)), QUERY ("hello", "world"), LIMIT (10));

json = bson_as_canonical_extended_json (bson, NULL);
printf ("%s\n", json);
Expand Down
15 changes: 2 additions & 13 deletions src/libbson/examples/bcon-speed.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,8 @@ main (int argc, char *argv[])

for (i = 0; i < n; i++) {
if (bcon) {
BCON_APPEND (&bson,
"foo",
"{",
"bar",
"{",
"baz",
"[",
BCON_INT32 (1),
BCON_INT32 (2),
BCON_INT32 (3),
"]",
"}",
"}");
BCON_APPEND (
&bson, "foo", "{", "bar", "{", "baz", "[", BCON_INT32 (1), BCON_INT32 (2), BCON_INT32 (3), "]", "}", "}");
} else {
bson_append_document_begin (&bson, "foo", -1, &foo);
bson_append_document_begin (&foo, "bar", -1, &bar);
Expand Down
13 changes: 3 additions & 10 deletions src/libbson/examples/bson-check-depth.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ typedef struct {
} check_depth_t;

bool
_check_depth_document (const bson_iter_t *iter,
const char *key,
const bson_t *v_document,
void *data);
_check_depth_document (const bson_iter_t *iter, const char *key, const bson_t *v_document, void *data);

static const bson_visitor_t check_depth_funcs = {
NULL,
Expand All @@ -47,10 +44,7 @@ static const bson_visitor_t check_depth_funcs = {
};

bool
_check_depth_document (const bson_iter_t *iter,
const char *key,
const bson_t *v_document,
void *data)
_check_depth_document (const bson_iter_t *iter, const char *key, const bson_t *v_document, void *data)
{
check_depth_t *state = (check_depth_t *) data;
bson_iter_t child;
Expand Down Expand Up @@ -88,8 +82,7 @@ check_depth (const bson_t *bson, uint32_t max_depth)
state.max_depth = max_depth;
_check_depth_document (&iter, NULL, bson, &state);
if (!state.valid) {
printf ("document exceeds maximum depth of %" PRIu32 "\n",
state.max_depth);
printf ("document exceeds maximum depth of %" PRIu32 "\n", state.max_depth);
} else {
char *as_json = bson_as_canonical_extended_json (bson, NULL);
printf ("document %s ", as_json);
Expand Down
Loading