blob: 77d2d5481bc2cb17223aa18315f756305f0294f6 [file] [log] [blame]
Reid Spencer362cbf02004-11-06 08:51:45 +00001//===-- lib/Bytecode/ArchiveInternals.h -------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by Reid Spencer and is distributed under the
6// University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// Internal implementation header for LLVM Archive files.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LIB_BYTECODE_ARCHIVEINTERNALS_H
15#define LIB_BYTECODE_ARCHIVEINTERNALS_H
16
17#include "llvm/Bytecode/Archive.h"
18#include "llvm/System/TimeValue.h"
Reid Spencerbc9fc842004-11-14 21:57:46 +000019#include "llvm/ADT/StringExtras.h"
Reid Spencer362cbf02004-11-06 08:51:45 +000020
21#define ARFILE_MAGIC "!<arch>\n" ///< magic string
22#define ARFILE_MAGIC_LEN (sizeof(ARFILE_MAGIC)-1) ///< length of magic string
Reid Spencerbc9fc842004-11-14 21:57:46 +000023#define ARFILE_SYMTAB_NAME "/ " ///< regular symtab entry
24#define ARFILE_STRTAB_NAME "// " ///< Name of string table
25#define ARFILE_LLVM_SYMTAB_NAME "#_LLVM_SYM_TAB_#" ///< LLVM's symtab entry
26#define ARFILE_PAD "\n" ///< inter-file align padding
27#define ARFILE_MEMBER_MAGIC "`\n" ///< fmag field magic #
Reid Spencer362cbf02004-11-06 08:51:45 +000028
29namespace llvm {
30
Reid Spencerbc9fc842004-11-14 21:57:46 +000031 /// The ArchiveMemberHeader structure is used internally for bytecode
32 /// archives.
Reid Spencer362cbf02004-11-06 08:51:45 +000033 /// The header precedes each file member in the archive. This structure is
34 /// defined using character arrays for direct and correct interpretation
35 /// regardless of the endianess of the machine that produced it.
36 /// @brief Archive File Member Header
37 class ArchiveMemberHeader {
Reid Spencerbc9fc842004-11-14 21:57:46 +000038 /// @name Data
39 /// @{
40 public:
41 char name[16];///< Name of the file member.
42 char date[12]; ///< File date, decimal seconds since Epoch
43 char uid[6]; ///< user id in ASCII decimal
44 char gid[6]; ///< group id in ASCII decimal
45 char mode[8]; ///< file mode in ASCII octal
46 char size[10]; ///< file size in ASCII decimal
47 char fmag[2]; ///< Always contains ARFILE_MAGIC_TERMINATOR
48
49 /// @}
50 /// @name Methods
51 /// @{
Reid Spencer362cbf02004-11-06 08:51:45 +000052 public:
53 void init() {
54 memset(name,' ',16);
55 memset(date,' ',12);
56 memset(uid,' ',6);
57 memset(gid,' ',6);
58 memset(mode,' ',8);
59 memset(size,' ',10);
60 fmag[0] = '`';
61 fmag[1] = '\n';
62 }
Reid Spencer362cbf02004-11-06 08:51:45 +000063
Reid Spencerbc9fc842004-11-14 21:57:46 +000064 bool checkSignature() {
65 return 0 == memcmp(fmag, ARFILE_MEMBER_MAGIC,2);
Reid Spencer362cbf02004-11-06 08:51:45 +000066 }
67
Reid Spencer362cbf02004-11-06 08:51:45 +000068 };
69
Reid Spencer362cbf02004-11-06 08:51:45 +000070}
71
72#endif
73
74// vim: sw=2 ai