aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/AsmStream.cpp
blob: 8a9ded7ee5d89474578f5b25bc6c1e1664234c6a (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
//===-- llvm/CodeGen/AsmStream.cpp - AsmStream Framework --------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file contains instantiations of "standard" AsmOStreams.
//
//===----------------------------------------------------------------------===//

#include "llvm/CodeGen/AsmStream.h"

#include <unistd.h>

namespace llvm {
  AsmStreambuf asmoutbuf(STDOUT_FILENO);
  AsmStreambuf asmerrbuf(STDERR_FILENO);

  //===----------------------------------------------------------------------===//
  //  raw_asm_ostream
  //===----------------------------------------------------------------------===//

  raw_asm_ostream::~raw_asm_ostream() {
    flush();
  }

  /// flush_impl - The is the piece of the class that is implemented by
  /// subclasses.  This outputs the currently buffered data and resets the
  /// buffer to empty.
  void raw_asm_ostream::flush_impl() {
    if (OutBufCur-OutBufStart)
      OS.write(OutBufStart, OutBufCur-OutBufStart);

    HandleFlush();
  }

  namespace {
    AsmOStream AsmOut(&asmoutbuf);
    AsmOStream AsmErr(&asmerrbuf);
  }

  raw_asm_ostream asmout(AsmOut);
  raw_asm_ostream asmerr(AsmErr);
}