Add ifdef'd implementation of setvbuf to zeek::util

This commit is contained in:
Tim Wojtulewicz 2023-05-02 09:38:42 -07:00 committed by Tim Wojtulewicz
parent 71731ffcb1
commit f2a3e23dfa
2 changed files with 14 additions and 0 deletions

View file

@ -996,6 +996,18 @@ void set_thread_name(const char* name, pthread_t tid)
#endif #endif
} }
int setvbuf(FILE* stream, char* buf, int type, size_t size)
{
#ifndef _MSC_VER
return ::setvbuf(stream, NULL, type, size);
#else
// TODO: this turns off buffering altogether because Windows wants us to pass a valid
// buffer and length if we're going to pass one of the other modes. We need to
// investigate the performance ramifications of this.
return ::setvbuf(stream, NULL, _IONBF, 0);
#endif
}
} // namespace detail } // namespace detail
TEST_CASE("util get_unescaped_string") TEST_CASE("util get_unescaped_string")

View file

@ -305,6 +305,8 @@ double parse_rotate_base_time(const char* rotate_base_time);
// This function is thread-safe. // This function is thread-safe.
double calc_next_rotate(double current, double rotate_interval, double base); double calc_next_rotate(double current, double rotate_interval, double base);
int setvbuf(FILE* stream, char* buf, int type, size_t size);
} // namespace detail } // namespace detail
template <class T> void delete_each(T* t) template <class T> void delete_each(T* t)