This file is indexed.

/usr/include/stxxl/bits/common/mutex.h is in libstxxl-dev 1.4.1-2build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/***************************************************************************
 *  include/stxxl/bits/common/mutex.h
 *
 *  Part of the STXXL. See http://stxxl.sourceforge.net
 *
 *  Copyright (C) 2002 Roman Dementiev <dementiev@mpi-sb.mpg.de>
 *  Copyright (C) 2008 Andreas Beckmann <beckmann@cs.uni-frankfurt.de>
 *  Copyright (C) 2013 Timo Bingmann <tb@panthema.net>
 *
 *  Distributed under the Boost Software License, Version 1.0.
 *  (See accompanying file LICENSE_1_0.txt or copy at
 *  http://www.boost.org/LICENSE_1_0.txt)
 **************************************************************************/

#ifndef STXXL_COMMON_MUTEX_HEADER
#define STXXL_COMMON_MUTEX_HEADER

#include <stxxl/bits/config.h>
#include <stxxl/bits/namespace.h>

#if STXXL_STD_THREADS
 #include <mutex>
#elif STXXL_BOOST_THREADS
 #include <boost/thread/mutex.hpp>
#elif STXXL_POSIX_THREADS
 #include <pthread.h>

 #include <stxxl/bits/noncopyable.h>
 #include <stxxl/bits/common/error_handling.h>
#else
 #error "Thread implementation not detected."
#endif

STXXL_BEGIN_NAMESPACE

#if STXXL_STD_THREADS

typedef std::mutex mutex;

#elif STXXL_BOOST_THREADS

typedef boost::mutex mutex;

#elif STXXL_POSIX_THREADS

class mutex : private noncopyable
{
    //! mutex handle
    pthread_mutex_t m_mutex;

public:
    //! construct unlocked mutex
    mutex()
    {
        STXXL_CHECK_PTHREAD_CALL(pthread_mutex_init(&m_mutex, NULL));
    }
    //! destroy mutex handle
    ~mutex()
    {
        // try simple delete first
        int res = pthread_mutex_destroy(&m_mutex);
        if (res == 0) return;

        // try to lock and unlock mutex
        res = pthread_mutex_trylock(&m_mutex);

        if (res == 0 || res == EBUSY) {
            STXXL_CHECK_PTHREAD_CALL(pthread_mutex_unlock(&m_mutex));
        } else {
            STXXL_THROW_ERRNO2(resource_error, "pthread_mutex_trylock() failed", res);
        }

        STXXL_CHECK_PTHREAD_CALL(pthread_mutex_destroy(&m_mutex));
    }
    //! lock mutex, may block
    void lock()
    {
        STXXL_CHECK_PTHREAD_CALL(pthread_mutex_lock(&m_mutex));
    }
    //! unlock mutex
    void unlock()
    {
        STXXL_CHECK_PTHREAD_CALL(pthread_mutex_unlock(&m_mutex));
    }
    //! return platform specific handle
    pthread_mutex_t & native_handle()
    {
        return m_mutex;
    }
};

#endif

#if STXXL_STD_THREADS

typedef std::unique_lock<std::mutex> scoped_mutex_lock;

#elif STXXL_BOOST_THREADS

typedef boost::mutex::scoped_lock scoped_mutex_lock;

#else

//! Aquire a lock that's valid until the end of scope.
class scoped_mutex_lock
{
    //! mutex reference
    mutex& m_mutex;

    //! marker if already unlocked by this thread (needs no synchronization)
    bool is_locked;

public:
    //! lock mutex
    scoped_mutex_lock(mutex& m)
        : m_mutex(m), is_locked(true)
    {
        m_mutex.lock();
    }
    //! unlock mutex hold when object goes out of scope.
    ~scoped_mutex_lock()
    {
        unlock();
    }
    //! unlock mutex hold prematurely
    void unlock()
    {
        if (is_locked) {
            is_locked = false;
            m_mutex.unlock();
        }
    }
    //! return platform specific handle
    pthread_mutex_t & native_handle()
    {
        return m_mutex.native_handle();
    }
};

#endif

STXXL_END_NAMESPACE

#endif // !STXXL_COMMON_MUTEX_HEADER