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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libgfortran/] [intrinsics/] [link.c] - Blame information for rev 14

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 jlechner
/* Implementation of the LINK intrinsic.
2
   Copyright (C) 2005 Free Software Foundation, Inc.
3
   Contributed by François-Xavier Coudert <coudert@clipper.ens.fr>
4
 
5
This file is part of the GNU Fortran 95 runtime library (libgfortran).
6
 
7
Libgfortran is free software; you can redistribute it and/or
8
modify it under the terms of the GNU General Public
9
License as published by the Free Software Foundation; either
10
version 2 of the License, or (at your option) any later version.
11
 
12
In addition to the permissions in the GNU General Public License, the
13
Free Software Foundation gives you unlimited permission to link the
14
compiled version of this file into combinations with other programs,
15
and to distribute those combinations without any restriction coming
16
from the use of this file.  (The General Public License restrictions
17
do apply in other respects; for example, they cover modification of
18
the file, and distribution when not linked into a combine
19
executable.)
20
 
21
Libgfortran is distributed in the hope that it will be useful,
22
but WITHOUT ANY WARRANTY; without even the implied warranty of
23
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
GNU General Public License for more details.
25
 
26
You should have received a copy of the GNU General Public
27
License along with libgfortran; see the file COPYING.  If not,
28
write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
29
Boston, MA 02110-1301, USA.  */
30
 
31
#include "config.h"
32
#include "libgfortran.h"
33
 
34
#include <errno.h>
35
 
36
#include "../io/io.h"
37
 
38
#ifdef HAVE_STRING_H
39
#include <string.h>
40
#endif
41
#ifdef HAVE_UNISTD_H
42
#include <unistd.h>
43
#endif
44
 
45
/* SUBROUTINE LINK(PATH1, PATH2, STATUS)
46
   CHARACTER(len=*), INTENT(IN) :: PATH1, PATH2
47
   INTEGER, INTENT(OUT), OPTIONAL :: STATUS  */
48
 
49
#ifdef HAVE_LINK
50
extern void link_i4_sub (char *, char *, GFC_INTEGER_4 *, gfc_charlen_type,
51
                         gfc_charlen_type);
52
iexport_proto(link_i4_sub);
53
 
54
void
55
link_i4_sub (char *path1, char *path2, GFC_INTEGER_4 *status,
56
             gfc_charlen_type path1_len, gfc_charlen_type path2_len)
57
{
58
  int val;
59
  char *str1, *str2;
60
 
61
  /* Trim trailing spaces from paths.  */
62
  while (path1_len > 0 && path1[path1_len - 1] == ' ')
63
    path1_len--;
64
  while (path2_len > 0 && path2[path2_len - 1] == ' ')
65
    path2_len--;
66
 
67
  /* Make a null terminated copy of the strings.  */
68
  str1 = gfc_alloca (path1_len + 1);
69
  memcpy (str1, path1, path1_len);
70
  str1[path1_len] = '\0';
71
 
72
  str2 = gfc_alloca (path2_len + 1);
73
  memcpy (str2, path2, path2_len);
74
  str2[path2_len] = '\0';
75
 
76
  val = link (str1, str2);
77
 
78
  if (status != NULL)
79
    *status = (val == 0) ? 0 : errno;
80
}
81
iexport(link_i4_sub);
82
 
83
extern void link_i8_sub (char *, char *, GFC_INTEGER_8 *, gfc_charlen_type,
84
                         gfc_charlen_type);
85
iexport_proto(link_i8_sub);
86
 
87
void
88
link_i8_sub (char *path1, char *path2, GFC_INTEGER_8 *status,
89
             gfc_charlen_type path1_len, gfc_charlen_type path2_len)
90
{
91
  int val;
92
  char *str1, *str2;
93
 
94
  /* Trim trailing spaces from paths.  */
95
  while (path1_len > 0 && path1[path1_len - 1] == ' ')
96
    path1_len--;
97
  while (path2_len > 0 && path2[path2_len - 1] == ' ')
98
    path2_len--;
99
 
100
  /* Make a null terminated copy of the strings.  */
101
  str1 = gfc_alloca (path1_len + 1);
102
  memcpy (str1, path1, path1_len);
103
  str1[path1_len] = '\0';
104
 
105
  str2 = gfc_alloca (path2_len + 1);
106
  memcpy (str2, path2, path2_len);
107
  str2[path2_len] = '\0';
108
 
109
  val = link (str1, str2);
110
 
111
  if (status != NULL)
112
    *status = (val == 0) ? 0 : errno;
113
}
114
iexport(link_i8_sub);
115
 
116
extern GFC_INTEGER_4 link_i4 (char *, char *, gfc_charlen_type,
117
                              gfc_charlen_type);
118
export_proto(link_i4);
119
 
120
GFC_INTEGER_4
121
link_i4 (char *path1, char *path2, gfc_charlen_type path1_len,
122
         gfc_charlen_type path2_len)
123
{
124
  GFC_INTEGER_4 val;
125
  link_i4_sub (path1, path2, &val, path1_len, path2_len);
126
  return val;
127
}
128
 
129
extern GFC_INTEGER_8 link_i8 (char *, char *, gfc_charlen_type,
130
                              gfc_charlen_type);
131
export_proto(link_i8);
132
 
133
GFC_INTEGER_8
134
link_i8 (char *path1, char *path2, gfc_charlen_type path1_len,
135
         gfc_charlen_type path2_len)
136
{
137
  GFC_INTEGER_8 val;
138
  link_i8_sub (path1, path2, &val, path1_len, path2_len);
139
  return val;
140
}
141
#endif

powered by: WebSVN 2.1.0

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