This file is indexed.

/usr/include/bobcat/sharedmemory is in libbobcat-dev 3.19.01-1ubuntu1.

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
145
146
147
148
149
150
151
152
153
154
155
156
#ifndef INCLUDED_BOBCAT_SHAREDMEMORY_
#define INCLUDED_BOBCAT_SHAREDMEMORY_

#include <ios>

#include <bobcat/fswap>
#include <bobcat/sharedpos>

namespace FBB
{

class SharedSegment;

struct SharedEnum__
{
    enum SizeUnit
    {
        kB = 10,
        MB = 20,
        GB = 30
    };
};

class SharedMemory: public virtual SharedEnum__
{
    friend std::ostream &operator<<(std::ostream &out, 
                                    SharedMemory const &mem);

    enum { PAGESIZE = 1 << 12 };

        // updated by the non-default constructors.
    int d_id = -1;                      // id of SharedSegment
    SharedSegment *d_sharedSegment = 0; // points to the attached shared
                                        //  memory. This is NOT a pointer
                                        // to dynamically allocated memory
                                        // but a static_cast pointer to
                                        // the attached shared data segment
    SharedPos d_pos;

    size_t d_lockCount = 0;             // # of nested locks
    char *d_data = 0;                   // pointer to shared memory data

    public:
        SharedMemory() = default;

        SharedMemory(SharedMemory const &other) = delete;

        SharedMemory(size_t maxSize, SizeUnit sizeUnit,
                     size_t access = 0600);             // 2: creation mode;

        SharedMemory(int id);                           // 3

        ~SharedMemory();

        SharedMemory &operator=(SharedMemory &&tmp);

        std::streamsize showmanyc();

        std::streamsize nReadable() const;  // beyond last readable byte
        std::streamsize offset() const;     // read/write offset
        std::streamsize maxOffset() const;  


        char *ptr();                        // 0 if at maxOffset

                                        // returns -1 if inaccessible
        std::ios::pos_type seek(std::ios::off_type offset, 
                                std::ios::seekdir way = std::ios::beg);

        int id() const;                 // id of the d_sharedSegment segment

        int put(int ch);                // put char at d_offset (locks),
                                        // ch == EOF immediately returns EOF 

                                        // write len bytes at d_offset
                                        // locks, returns #written or -1
        int write(char const *data, std::streamsize len);
                  
        int get();                      // get char from d_segmentData 
                                        // locks), or EOF

                                        // read len chars, return nRead, locks
        int read(char *data, std::streamsize len);    


        void clear();                   // clear all existing data and reduce
                                        // until only the segment at 
                                        // d_sharedSegment

        void swap(SharedMemory &other);

                // after kill/remove: shared segment is unusable
        void kill();                    // delete all shared segments w/o locks
        void remove();                  // delete all shared segments.

    private:
        std::ostream &insert(std::ostream &out) const;


                                        // lockAll: d_lockCount should be 0.
        void lockAll();                 // lock all block[] mutexes
        void unlockAll();               // unlock all block[] mutexes

        void lock(size_t idx);          // (recursively) lock block idx
        void unlock(size_t idx);        // unlock block idx

        void clearAll();                // clear without locking

        bool blockAvailable(size_t idx);

        void map();                     // 1    maps shared data to d_data
        void map(size_t idx);           // 2    only called by load


        int writeBlock(char const *data, size_t len);   // locks, returns 
                                                        // #written or -1
        int readBlock(char *data, size_t len);          // same, but now reads
                                                        // both update offset

        static size_t computeSegmentSize(
                            size_t *nBlocks, 
                            long long maxMemory, SizeUnit sizeUnit);
};

inline int SharedMemory::id() const
{
    return d_id;
}
inline std::streamsize SharedMemory::maxOffset() const
{
    return d_pos.maxOffset();
}
inline std::streamsize SharedMemory::nReadable() const
{
    return d_sharedSegment->nReadable();
}
inline std::streamsize SharedMemory::offset() const
{
    return d_pos.offset();
}
inline SharedMemory &SharedMemory::operator=(SharedMemory &&tmp)
{
    swap(tmp);
    return *this;
}
inline std::ostream &operator<<(std::ostream &out, SharedMemory const &mem)
{
    return mem.insert(out);
}
inline void SharedMemory::swap(SharedMemory &other)
{
    FBB::fswap(*this, other);
}

} // FBB        
#endif