diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/config.in | 12 | ||||
-rwxr-xr-x | gcc/configure | 43 | ||||
-rw-r--r-- | gcc/configure.ac | 15 | ||||
-rw-r--r-- | gcc/gcov-io.c | 30 | ||||
-rw-r--r-- | gcc/gcov-io.h | 6 | ||||
-rw-r--r-- | gcc/system.h | 4 |
6 files changed, 106 insertions, 4 deletions
diff --git a/gcc/config.in b/gcc/config.in index fb88acb..e54f59c 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -1919,6 +1919,12 @@ #endif +/* Define to 1 if you have the <sys/locking.h> header file. */ +#ifndef USED_FOR_TARGET +#undef HAVE_SYS_LOCKING_H +#endif + + /* Define to 1 if you have the <sys/mman.h> header file. */ #ifndef USED_FOR_TARGET #undef HAVE_SYS_MMAN_H @@ -2092,6 +2098,12 @@ #endif +/* Define if _LK_LOC supported by _locking. */ +#ifndef USED_FOR_TARGET +#undef HOST_HAS_LK_LOCK +#endif + + /* Define if O_CLOEXEC supported by fcntl. */ #ifndef USED_FOR_TARGET #undef HOST_HAS_O_CLOEXEC diff --git a/gcc/configure b/gcc/configure index f5bef76..d9c9cca 100755 --- a/gcc/configure +++ b/gcc/configure @@ -9075,7 +9075,7 @@ fi for ac_header in limits.h stddef.h string.h strings.h stdlib.h time.h iconv.h \ fcntl.h ftw.h unistd.h sys/file.h sys/time.h sys/mman.h \ - sys/resource.h sys/param.h sys/times.h sys/stat.h \ + sys/resource.h sys/param.h sys/times.h sys/stat.h sys/locking.h \ direct.h malloc.h langinfo.h ldfcn.h locale.h wchar.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` @@ -12308,6 +12308,43 @@ $as_echo "#define HAVE_AF_INET6 1" >>confdefs.h fi +# Check if _LK_LOCK is supported by _locking +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LK_LOCK" >&5 +$as_echo_n "checking for _LK_LOCK... " >&6; } +if ${ac_cv_lk_lock+:} false; then : + $as_echo_n "(cached) " >&6 +else + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include <io.h> +#include <sys/locking.h> +int +main () +{ + + int fd; + return _locking (fd, _LK_LOCK, 0); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_lk_lock=yes +else + ac_cv_lk_lock=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lk_lock" >&5 +$as_echo "$ac_cv_lk_lock" >&6; } +if test $ac_cv_lk_lock = yes; then + +$as_echo "#define HOST_HAS_LK_LOCK 1" >>confdefs.h + +fi + # Restore CFLAGS, CXXFLAGS from before the gcc_AC_NEED_DECLARATIONS tests. CFLAGS="$saved_CFLAGS" CXXFLAGS="$saved_CXXFLAGS" @@ -19398,7 +19435,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 19401 "configure" +#line 19438 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -19504,7 +19541,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 19507 "configure" +#line 19544 "configure" #include "confdefs.h" #if HAVE_DLFCN_H diff --git a/gcc/configure.ac b/gcc/configure.ac index 22305e3..e9ba2af 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -1257,7 +1257,7 @@ AC_HEADER_SYS_WAIT AC_HEADER_TIOCGWINSZ AC_CHECK_HEADERS(limits.h stddef.h string.h strings.h stdlib.h time.h iconv.h \ fcntl.h ftw.h unistd.h sys/file.h sys/time.h sys/mman.h \ - sys/resource.h sys/param.h sys/times.h sys/stat.h \ + sys/resource.h sys/param.h sys/times.h sys/stat.h sys/locking.h \ direct.h malloc.h langinfo.h ldfcn.h locale.h wchar.h) # Check for thread headers. @@ -1711,6 +1711,19 @@ if test $ac_cv_af_inet6 = yes; then [Define if AF_INET6 supported.]) fi +# Check if _LK_LOCK is supported by _locking +AC_CACHE_CHECK(for _LK_LOCK, ac_cv_lk_lock, [ +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include <io.h> +#include <sys/locking.h>]], [[ + int fd; + return _locking (fd, _LK_LOCK, 0);]])], +[ac_cv_lk_lock=yes],[ac_cv_lk_lock=no])]) +if test $ac_cv_lk_lock = yes; then + AC_DEFINE(HOST_HAS_LK_LOCK, 1, + [Define if _LK_LOC supported by _locking.]) +fi + # Restore CFLAGS, CXXFLAGS from before the gcc_AC_NEED_DECLARATIONS tests. CFLAGS="$saved_CFLAGS" CXXFLAGS="$saved_CXXFLAGS" diff --git a/gcc/gcov-io.c b/gcc/gcov-io.c index 80c9082..21ca394 100644 --- a/gcc/gcov-io.c +++ b/gcc/gcov-io.c @@ -137,6 +137,8 @@ gcov_open (const char *name, int mode) s_flock.l_start = 0; s_flock.l_len = 0; /* Until EOF. */ s_flock.l_pid = getpid (); +#elif GCOV_LOCKED_WITH_LOCKING + int fd; #endif gcov_nonruntime_assert (!gcov_var.file); @@ -175,6 +177,34 @@ gcov_open (const char *name, int mode) close (fd); return 0; } +#elif GCOV_LOCKED_WITH_LOCKING + if (mode > 0) + { + /* pass mode (ignored) for compatibility */ + fd = open (name, O_RDONLY | O_BINARY, S_IRUSR | S_IWUSR); + } + else + { + /* Truncate if force new mode. */ + fd = open (name, O_RDWR | O_BINARY | O_CREAT | (mode < 0 ? O_TRUNC : 0), + 0666); + } + if (fd < 0) + return 0; + + if (_locking (fd, _LK_LOCK, LONG_MAX) < 0) + { + close (fd); + return 0; + } + + gcov_var.file = fdopen (fd, (mode > 0) ? "rb" : "r+b"); + + if (!gcov_var.file) + { + close (fd); + return 0; + } #else if (mode >= 0) /* Open an existing file. */ diff --git a/gcc/gcov-io.h b/gcc/gcov-io.h index 75f16a2..c9958f4 100644 --- a/gcc/gcov-io.h +++ b/gcc/gcov-io.h @@ -202,6 +202,12 @@ typedef uint64_t gcov_type_unsigned; #define GCOV_LOCKED 0 #endif +#if defined (HOST_HAS_LK_LOCK) +#define GCOV_LOCKED_WITH_LOCKING 1 +#else +#define GCOV_LOCKED_WITH_LOCKING 0 +#endif + #define ATTRIBUTE_HIDDEN #endif /* !IN_LIBGCOV */ diff --git a/gcc/system.h b/gcc/system.h index a3f5948..6416c4e 100644 --- a/gcc/system.h +++ b/gcc/system.h @@ -360,6 +360,10 @@ extern int errno; # endif #endif +#ifdef HAVE_SYS_LOCKING_H +# include <sys/locking.h> +#endif + #ifndef SEEK_SET # define SEEK_SET 0 # define SEEK_CUR 1 |