lock_log (); if (!logfp) logfp = fopen (logfile, "a+"); unlock_log ();
if ( !lock_log ()) { if (!logfp) logfp = fopen (logfile, "a+"); unlock_log (); }
do_log (const char *fmt, va_list a){  if (enable_logging == false || !logfile)    return;  if (!logfp)    {      lock_log ();      if (!logfp)        logfp = fopen (logfile, "a+");      unlock_log ();    }  if (!logfp)    return;  fprintf (logfp, "%lu/", (unsigned long)GetCurrentThreadId ());  vfprintf (logfp, fmt, a);  fflush (logfp);}