Refactor locks use in support

This commit is contained in:
Andrea Mazzoleni 2016-01-05 16:37:29 +01:00
parent ec5b383c1d
commit c870b04b66
4 changed files with 129 additions and 58 deletions

View file

@ -18,6 +18,40 @@
#ifndef __SUPPORT_H
#define __SUPPORT_H
/****************************************************************************/
/* lock */
/**
* Initialize and destroy the locks.
*/
void lock_init(void);
void lock_done(void);
/**
* Lock used for printf.
*
* In Windows printf() is not atomic, and multiple threads
* will have output interleaved.
*
* Note that even defining __USE_MINGW_ANSI_STDIO the problem persists.
*
* See for example:
*
* Weird output when I use pthread and printf.
* http://stackoverflow.com/questions/13190254/weird-output-when-i-use-pthread-and-printf
*
* This is also required in other OS because we split output in stdlog in
* two fprintf calls.
*/
void lock_msg(void);
void unlock_msg(void);
/**
* Lock used for memory counter.
*/
void lock_memory(void);
void unlock_memory(void);
/****************************************************************************/
/* log */