OSDN Git Service

* doc/extend.texi: Document optional priority argument to
[pf3gnuchains/gcc-fork.git] / libgfortran / intrinsics / umask.c
1 /* Implementation of the UMASK intrinsic.
2    Copyright (C) 2004 Free Software Foundation, Inc.
3    Contributed by Steven G. Kargl <kargls@comcast.net>.
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
32 #include "config.h"
33 #include "libgfortran.h"
34
35 #ifdef HAVE_STDLIB_H
36 #include <stdlib.h>
37 #endif
38
39 #ifdef HAVE_SYS_STAT_H
40 #include <sys/stat.h>
41 #endif
42
43 /* SUBROUTINE UMASK(MASK, OLD)
44    INTEGER, INTENT(IN) :: MASK
45    INTEGER, INTENT(OUT), OPTIONAL :: OLD  */
46
47 extern void umask_i4_sub (GFC_INTEGER_4 *, GFC_INTEGER_4 *);
48 iexport_proto(umask_i4_sub);
49
50 void
51 umask_i4_sub (GFC_INTEGER_4 *mask, GFC_INTEGER_4 *old)
52 {
53   mode_t val = umask((mode_t) *mask);
54   if (old != NULL)
55     *old = (GFC_INTEGER_4) val;
56 }
57 iexport(umask_i4_sub);
58
59 extern void umask_i8_sub (GFC_INTEGER_8 *, GFC_INTEGER_8 *);
60 iexport_proto(umask_i8_sub);
61
62 void
63 umask_i8_sub (GFC_INTEGER_8 *mask, GFC_INTEGER_8 *old)
64 {
65   mode_t val = umask((mode_t) *mask);
66   if (old != NULL)
67     *old = (GFC_INTEGER_8) val;
68 }
69 iexport(umask_i8_sub);
70
71 /* INTEGER FUNCTION UMASK(MASK)
72    INTEGER, INTENT(IN) :: MASK  */
73
74 extern GFC_INTEGER_4 umask_i4 (GFC_INTEGER_4 *);
75 export_proto(umask_i4);
76
77 GFC_INTEGER_4
78 umask_i4 (GFC_INTEGER_4 *mask)
79 {
80   GFC_INTEGER_4 old;
81   umask_i4_sub (mask, &old);
82   return old;
83 }
84
85 extern GFC_INTEGER_8 umask_i8 (GFC_INTEGER_8 *);
86 export_proto(umask_i8);
87
88 GFC_INTEGER_8
89 umask_i8 (GFC_INTEGER_8 *mask)
90 {
91   GFC_INTEGER_8 old;
92   umask_i8_sub (mask, &old);
93   return old;
94 }