summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/src/os_posix/os_setvbuf.c
blob: b54d4a59536a513882e4b288bb25718b806c86df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*-
 * Copyright (c) 2014-2020 MongoDB, Inc.
 * Copyright (c) 2008-2014 WiredTiger, Inc.
 *	All rights reserved.
 *
 * See the file LICENSE for redistribution information.
 */

#include "wt_internal.h"

/*
 * __wt_stream_set_line_buffer --
 *     Set line buffering on a stream.
 */
void
__wt_stream_set_line_buffer(FILE *fp) WT_GCC_FUNC_ATTRIBUTE((visibility("default")))
{
    /*
     * This function exists because MSVC doesn't support buffer sizes of 0 to the setvbuf call. To
     * avoid re-introducing the bug, we have helper functions and disallow calling setvbuf directly
     * in WiredTiger code.
     */
    (void)setvbuf(fp, NULL, _IOLBF, 1024);
}

/*
 * __wt_stream_set_no_buffer --
 *     Turn off buffering on a stream.
 */
void
__wt_stream_set_no_buffer(FILE *fp) WT_GCC_FUNC_ATTRIBUTE((visibility("default")))
{
    (void)setvbuf(fp, NULL, _IONBF, 0);
}