Assorted whitespace cleanup and typo fixes.
[haiku.git] / src / system / runtime_loader / elf_tls.h
blob9e8d859b10fc29595bf9dab8b1f62cfd1f722273
1 /*
2 * Copyright 2014, Paweł Dziepak, pdziepak@quarnos.org.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef ELF_TLS_H
6 #define ELF_TLS_H
9 #include "runtime_loader_private.h"
10 #include "utility.h"
13 class TLSBlock;
15 class TLSBlockTemplate {
16 public:
17 TLSBlockTemplate() { }
18 inline TLSBlockTemplate(void* address, size_t fileSize,
19 size_t memorySize);
21 void SetGeneration(unsigned generation)
22 { fGeneration = generation; }
23 unsigned Generation() const { return fGeneration; }
25 void SetBaseAddress(addr_t baseAddress);
27 TLSBlock CreateBlock();
29 private:
30 unsigned fGeneration;
32 void* fAddress;
33 size_t fFileSize;
34 size_t fMemorySize;
37 class TLSBlockTemplates {
38 public:
39 static TLSBlockTemplates& Get();
41 unsigned Register(const TLSBlockTemplate& block);
42 void Unregister(unsigned dso);
44 void SetBaseAddress(unsigned dso, addr_t baseAddress);
46 unsigned GetGeneration(unsigned dso) const;
48 TLSBlock CreateBlock(unsigned dso);
50 private:
51 inline TLSBlockTemplates();
53 static TLSBlockTemplates* fInstance;
55 unsigned fGeneration;
57 utility::vector<TLSBlockTemplate> fTemplates;
58 utility::vector<unsigned> fFreeDSOs;
62 TLSBlockTemplate::TLSBlockTemplate(void* address, size_t fileSize,
63 size_t memorySize)
65 fAddress(address),
66 fFileSize(fileSize),
67 fMemorySize(memorySize)
72 void* get_tls_address(unsigned dso, addr_t offset);
73 void destroy_thread_tls();
76 #endif // ELF_TLS_H