OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgfortran/] [intrinsics/] [system.c] - Blame information for rev 733

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 733 jeremybenn
/* Implementation of the SYSTEM intrinsic.
2
   Copyright (C) 2004, 2007, 2009, 2011 Free Software Foundation, Inc.
3
   Contributed by Tobias Schlüter.
4
 
5
This file is part of the GNU Fortran runtime library (libgfortran).
6
 
7
Libgfortran is free software; you can redistribute it and/or modify it under
8
the terms of the GNU General Public License as published by the Free
9
Software Foundation; either version 3, or (at your option) any later
10
version.
11
 
12
Libgfortran is distributed in the hope that it will be useful, but WITHOUT
13
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15
for more details.
16
 
17
Under Section 7 of GPL version 3, you are granted additional
18
permissions described in the GCC Runtime Library Exception, version
19
3.1, as published by the Free Software Foundation.
20
 
21
You should have received a copy of the GNU General Public License and
22
a copy of the GCC Runtime Library Exception along with this program;
23
see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
24
<http://www.gnu.org/licenses/>.  */
25
 
26
#include "libgfortran.h"
27
#include <string.h>
28
#include <stdlib.h>
29
 
30
extern void system_sub (const char *fcmd, GFC_INTEGER_4 * status,
31
                        gfc_charlen_type cmd_len);
32
iexport_proto(system_sub);
33
 
34
void
35
system_sub (const char *fcmd, GFC_INTEGER_4 *status, gfc_charlen_type cmd_len)
36
{
37
  char cmd[cmd_len + 1];
38
  int stat;
39
 
40
  /* Flush all I/O units before executing the command.  */
41
  flush_all_units();
42
 
43
  memcpy (cmd, fcmd, cmd_len);
44
  cmd[cmd_len] = '\0';
45
 
46
  stat = system (cmd);
47
  if (status)
48
    *status = stat;
49
}
50
iexport(system_sub);
51
 
52
extern GFC_INTEGER_4 PREFIX(system) (const char *, gfc_charlen_type);
53
export_proto_np(PREFIX(system));
54
 
55
GFC_INTEGER_4
56
PREFIX(system) (const char *fcmd, gfc_charlen_type cmd_len)
57
{
58
  GFC_INTEGER_4 stat;
59
  system_sub (fcmd, &stat, cmd_len);
60
  return stat;
61
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.