* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#include "defs.h"
+#define _GNU_SOURCE
+#include <stdio.h>
+
#include <glib.h>
#include <glib/gi18n.h>
#include <sys/mman.h>
#include "codeconv.h"
#include "timing.h"
+#ifdef HAVE_FWRITE_UNLOCKED
+#define SC_FWRITE fwrite_unlocked
+#else
+#define SC_FWRITE fwrite
+#endif
+
#if G_BYTE_ORDER == G_BIG_ENDIAN
#define bswap_32(x) \
((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
guint32 idata; \
\
idata = (guint32)bswap_32(n); \
- if (fwrite_unlocked(&idata, sizeof(idata), 1, fp) != 1) \
+ if (SC_FWRITE(&idata, sizeof(idata), 1, fp) != 1) \
w_err = 1; \
wrote += 4; \
}
len = strlen(data); \
WRITE_CACHE_DATA_INT(len, fp); \
if (w_err == 0 && len > 0) { \
- if (fwrite_unlocked(data, 1, len, fp) != len) \
+ if (SC_FWRITE(data, 1, len, fp) != len) \
w_err = 1; \
wrote += len; \
} \
ftruncate(fileno(write_fps.cache_fp), write_fps.cache_size);
ftruncate(fileno(write_fps.mark_fp), write_fps.mark_size);
} else {
+#ifdef HAVE_FWRITE_UNLOCKED
flockfile(write_fps.cache_fp);
flockfile(write_fps.mark_fp);
+#endif
g_hash_table_foreach(cache->msgnum_table, msgcache_write_func, (gpointer)&write_fps);
+#ifdef HAVE_FWRITE_UNLOCKED
funlockfile(write_fps.mark_fp);
funlockfile(write_fps.cache_fp);
+#endif
}
fflush(write_fps.cache_fp);