summaryrefslogtreecommitdiff
path: root/flang/runtime/main.cc
blob: dbfcd2b11d6295430168933b225d4f8d16b9cfb2 (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
//===-- runtime/main.cc -----------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//----------------------------------------------------------------------------//

#include "main.h"
#include "terminator.h"
#include <cfenv>
#include <cstdlib>

namespace Fortran::runtime {
int argc;
const char **argv;
const char **envp;
}

extern "C" {

void __FortranProgram();  // PROGRAM statement

int main(int argc, const char *argv[], const char *envp[]) {
  Fortran::runtime::argc = argc;
  Fortran::runtime::argv = argv;
  Fortran::runtime::envp = envp;
  std::feclearexcept(FE_ALL_EXCEPT);
  std::fesetround(FE_TONEAREST);
  std::atexit(Fortran::runtime::NotifyOtherImagesOfNormalEnd);
  // TODO: Runtime configuration settings from environment
  __FortranProgram();
  return EXIT_SUCCESS;
}
}