aboutsummaryrefslogtreecommitdiff
path: root/gold/targetsize.h
blob: 61f986d333dba329588a2f094ac0447b71ac806c (plain)
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
// targetsize.h -- representations which change size based on the target

#ifndef GOLD_TARGETSIZE_H
#define GOLD_TARGETSIZE_H

// Tell GNU/Linux inttypes.h that we want the formatting macros.
#define __STDC_FORMAT_MACROS

#include <stdint.h>
#include <inttypes.h>

namespace gold
{

// A template we use to get the right type sizes via specialization.
// We never actually use the default version.

template<int size>
struct Size_types
{
  typedef signed char Signed_type;
  typedef unsigned char Unsigned_type;
  static const char* signed_printf_dec_format();
  static const char* unsigned_printf_dec_format();
  static const char* unsigned_printf_hex_format();
};

template<>
struct Size_types<32>
{
  typedef int32_t Signed_type;
  typedef uint32_t Unsigned_type;
  static const char* signed_printf_dec_format()
  { return PRId32; }
  static const char* unsigned_printf_dec_format()
  { return PRIu32; }
  static const char* unsigned_printf_hex_format()
  { return PRIx32; }
};

template<>
struct Size_types<64>
{
  typedef int64_t Signed_type;
  typedef uint64_t Unsigned_type;
  static const char* signed_printf_dec_format()
  { return PRId64; }
  static const char* unsigned_printf_dec_format()
  { return PRIu64; }
  static const char* unsigned_printf_hex_format()
  { return PRIx64; }
};

} // End namespace gold.

#endif // !defined(GOLD_TARGETSIZE_H)