diff options
author | Руслан Ижбулатов <lrn1986@gmail.com> | 2015-12-30 18:05:05 +0000 |
---|---|---|
committer | Руслан Ижбулатов <lrn1986@gmail.com> | 2015-12-30 21:57:29 +0000 |
commit | 91bb91dbb9e10691a9f4e3e8f0b1b4dabcd7ee27 (patch) | |
tree | 4a241646ed7bbc17578d3b10a94a48857cc6b1f5 /gtk/gtkimmodule.c | |
parent | f357ef5610ff94af14925ac837b31b63a93f01aa (diff) | |
download | gtk+-91bb91dbb9e10691a9f4e3e8f0b1b4dabcd7ee27.tar.gz |
Fix to compile for C libraries with no flockfile
Also use MS variant of flockfile, if available
(requires MSVCRT compatible with MSVCR90 or newer).
Diffstat (limited to 'gtk/gtkimmodule.c')
-rw-r--r-- | gtk/gtkimmodule.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/gtk/gtkimmodule.c b/gtk/gtkimmodule.c index 405d87626f..47e6348ebe 100644 --- a/gtk/gtkimmodule.c +++ b/gtk/gtkimmodule.c @@ -64,6 +64,23 @@ #include "deprecated/gtkrc.h" +/* We need to call getc() a lot in a loop. This is suboptimal, + * as getc() does thread locking on the FILE it is given. + * To optimize that, lock the file first, then call getc(), + * then unlock. + * If locking functions are not present in libc, fall back + * to the suboptimal getc(). + */ +#if !defined(HAVE_FLOCKFILE) && !defined(HAVE__LOCK_FILE) +# define flockfile(f) (void)1 +# define funlockfile(f) (void)1 +# define getc_unlocked(f) getc(f) +#elif !defined(HAVE_FLOCKFILE) && defined(HAVE__LOCK_FILE) +# define flockfile(f) _lock_file(f) +# define funlockfile(f) _unlock_file(f) +# define getc_unlocked(f) _getc_nolock(f) +#endif + #define SIMPLE_ID "gtk-im-context-simple" #define NONE_ID "gtk-im-context-none" |