Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
riscv-gcc-1
Commits
8f17e00c
Commit
8f17e00c
authored
Feb 24, 2011
by
Janne Blomqvist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PR 47802 Use strftime for CTIME and FDATE intrinsics
From-SVN: r170478
parent
ef795fc2
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
91 additions
and
127 deletions
+91
-127
libgfortran/ChangeLog
+18
-0
libgfortran/config.h.in
+3
-6
libgfortran/configure
+8
-6
libgfortran/configure.ac
+3
-3
libgfortran/intrinsics/ctime.c
+35
-94
libgfortran/intrinsics/date_and_time.c
+4
-18
libgfortran/intrinsics/time_1.h
+20
-0
No files found.
libgfortran/ChangeLog
View file @
8f17e00c
2011-02-24 Janne Blomqvist <jb@gcc.gnu.org>
PR libfortran/47802
* config.h.in: Regenerated.
* configure: Regenerated.
* configure.ac: Remove checks for ctime and ctime_r, add check for
strftime.
* intrinsics/date_and_time.c (localtime_r): Move fallback
implementation to time_1.h.
* intrinsics/time_1.h (localtime_r): Fallback implementation.
* intrinsics/ctime.c: Include time_1.h.
(ctime_r): Remove fallback implementation.
(strctime): New function.
(fdate): Use strctime instead of ctime_r.
(fdate_sub): Likewise.
(ctime): Likewise.
(ctime_sub): Likewise.
2011-02-24 Jakub Jelinek <jakub@redhat.com>
2011-02-24 Jakub Jelinek <jakub@redhat.com>
PR fortran/47878
PR fortran/47878
...
...
libgfortran/config.h.in
View file @
8f17e00c
...
@@ -318,12 +318,6 @@
...
@@ -318,12 +318,6 @@
/* libm includes ctanl */
/* libm includes ctanl */
#undef HAVE_CTANL
#undef HAVE_CTANL
/* Define to 1 if you have the `ctime' function. */
#undef HAVE_CTIME
/* Define to 1 if you have the `ctime_r' function. */
#undef HAVE_CTIME_R
/* Define to 1 if you have the <dlfcn.h> header file. */
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
#undef HAVE_DLFCN_H
...
@@ -723,6 +717,9 @@
...
@@ -723,6 +717,9 @@
/* Define to 1 if you have the `strerror_r' function. */
/* Define to 1 if you have the `strerror_r' function. */
#undef HAVE_STRERROR_R
#undef HAVE_STRERROR_R
/* Define to 1 if you have the `strftime' function. */
#undef HAVE_STRFTIME
/* Define to 1 if you have the <strings.h> header file. */
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
#undef HAVE_STRINGS_H
...
...
libgfortran/configure
View file @
8f17e00c
...
@@ -16312,7 +16312,7 @@ _ACEOF
...
@@ -16312,7 +16312,7 @@ _ACEOF
fi
fi
done
done
for
ac_func
in
sleep
time
ttyname signal alarm c
time c
lock access fork execl
for
ac_func
in
sleep
time
ttyname signal alarm clock access fork execl
do
:
do
:
as_ac_var
=
`
$as_echo
"ac_cv_func_
$ac_func
"
|
$as_tr_sh
`
as_ac_var
=
`
$as_echo
"ac_cv_func_
$ac_func
"
|
$as_tr_sh
`
ac_fn_c_check_func
"
$LINENO
"
"
$ac_func
"
"
$as_ac_var
"
ac_fn_c_check_func
"
$LINENO
"
"
$ac_func
"
"
$as_ac_var
"
...
@@ -16351,7 +16351,7 @@ _ACEOF
...
@@ -16351,7 +16351,7 @@ _ACEOF
fi
fi
done
done
for
ac_func
in
localtime_r gmtime_r strerror_r getpwuid_r ttyname_r
ctime_r
for
ac_func
in
localtime_r gmtime_r strerror_r getpwuid_r ttyname_r
do
:
do
:
as_ac_var
=
`
$as_echo
"ac_cv_func_
$ac_func
"
|
$as_tr_sh
`
as_ac_var
=
`
$as_echo
"ac_cv_func_
$ac_func
"
|
$as_tr_sh
`
ac_fn_c_check_func
"
$LINENO
"
"
$ac_func
"
"
$as_ac_var
"
ac_fn_c_check_func
"
$LINENO
"
"
$ac_func
"
"
$as_ac_var
"
...
@@ -16364,12 +16364,14 @@ _ACEOF
...
@@ -16364,12 +16364,14 @@ _ACEOF
fi
fi
done
done
for
ac_func
in
clock_gettime
for
ac_func
in
clock_gettime
strftime
do
:
do
:
ac_fn_c_check_func
"
$LINENO
"
"clock_gettime"
"ac_cv_func_clock_gettime"
as_ac_var
=
`
$as_echo
"ac_cv_func_
$ac_func
"
|
$as_tr_sh
`
if
test
"x
$ac_cv_func_clock_gettime
"
=
x
""
yes
;
then
:
ac_fn_c_check_func
"
$LINENO
"
"
$ac_func
"
"
$as_ac_var
"
eval
as_val
=
\$
$as_ac_var
if
test
"x
$as_val
"
=
x
""
yes
;
then
:
cat
>>
confdefs.h
<<
_ACEOF
cat
>>
confdefs.h
<<
_ACEOF
#define
HAVE_CLOCK_GETTIME
1
#define
`
$as_echo
"HAVE_
$ac_func
" |
$as_tr_cpp
`
1
_ACEOF
_ACEOF
fi
fi
...
...
libgfortran/configure.ac
View file @
8f17e00c
...
@@ -248,11 +248,11 @@ AC_CHECK_MEMBERS([struct stat.st_rdev])
...
@@ -248,11 +248,11 @@ AC_CHECK_MEMBERS([struct stat.st_rdev])
# Check for library functions.
# Check for library functions.
AC_CHECK_FUNCS(getrusage times mkstemp strtof strtold snprintf ftruncate chsize)
AC_CHECK_FUNCS(getrusage times mkstemp strtof strtold snprintf ftruncate chsize)
AC_CHECK_FUNCS(chdir strerror getlogin gethostname kill link symlink perror)
AC_CHECK_FUNCS(chdir strerror getlogin gethostname kill link symlink perror)
AC_CHECK_FUNCS(sleep time ttyname signal alarm c
time c
lock access fork execl)
AC_CHECK_FUNCS(sleep time ttyname signal alarm clock access fork execl)
AC_CHECK_FUNCS(wait setmode execvp pipe dup2 close fdopen strcasestr getrlimit)
AC_CHECK_FUNCS(wait setmode execvp pipe dup2 close fdopen strcasestr getrlimit)
AC_CHECK_FUNCS(gettimeofday stat fstat lstat getpwuid vsnprintf dup getcwd)
AC_CHECK_FUNCS(gettimeofday stat fstat lstat getpwuid vsnprintf dup getcwd)
AC_CHECK_FUNCS(localtime_r gmtime_r strerror_r getpwuid_r ttyname_r
ctime_r
)
AC_CHECK_FUNCS(localtime_r gmtime_r strerror_r getpwuid_r ttyname_r)
AC_CHECK_FUNCS(clock_gettime)
AC_CHECK_FUNCS(clock_gettime
strftime
)
# Check for glibc backtrace functions
# Check for glibc backtrace functions
AC_CHECK_FUNCS(backtrace backtrace_symbols)
AC_CHECK_FUNCS(backtrace backtrace_symbols)
...
...
libgfortran/intrinsics/ctime.c
View file @
8f17e00c
...
@@ -25,42 +25,31 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
...
@@ -25,42 +25,31 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#include "libgfortran.h"
#include "libgfortran.h"
#ifdef TIME_WITH_SYS_TIME
#include "time_1.h"
# include <sys/time.h>
# include <time.h>
#else
# if HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# ifdef HAVE_TIME_H
# include <time.h>
# endif
# endif
#endif
#include <string.h>
#include <string.h>
#ifndef HAVE_CTIME_R
/* strftime-like function that fills a C string with %c format which
/* Make sure we don't see here a macro. */
is identical to ctime in the default locale. As ctime and ctime_r
#undef ctime_r
are poorly specified and their usage not recommended, the
implementation instead uses strftime. */
static
char
*
static
size_t
ctime_r
(
const
time_t
*
timep
,
char
*
buf
__attribute__
((
unused
))
)
strctime
(
char
*
s
,
size_t
max
,
const
time_t
*
timep
)
{
{
#ifdef HAVE_CTIME
#ifdef HAVE_STRFTIME
char
*
tmp
=
ctime
(
timep
);
struct
tm
res
;
if
(
tmp
)
struct
tm
*
ltm
=
localtime_r
(
timep
,
&
res
);
tmp
=
strcpy
(
buf
,
tmp
);
return
strftime
(
s
,
max
,
"%c"
,
ltm
);
return
tmp
;
#else
#else
return
NULL
;
return
0
;
#endif
#endif
}
}
#endif
/* ctime_r() buffer size needs to be at least 26 bytes. */
/* In the default locale, the date and time representation fits in 26
#define CSZ 26
bytes. However, other locales might need more space. */
#define CSZ 100
extern
void
fdate
(
char
**
,
gfc_charlen_type
*
);
extern
void
fdate
(
char
**
,
gfc_charlen_type
*
);
export_proto
(
fdate
);
export_proto
(
fdate
);
...
@@ -68,29 +57,15 @@ export_proto(fdate);
...
@@ -68,29 +57,15 @@ export_proto(fdate);
void
void
fdate
(
char
**
date
,
gfc_charlen_type
*
date_len
)
fdate
(
char
**
date
,
gfc_charlen_type
*
date_len
)
{
{
#if defined(HAVE_TIME) && defined(HAVE_CTIME)
#if defined(HAVE_TIME)
char
cbuf
[
CSZ
];
int
i
;
time_t
now
=
time
(
NULL
);
time_t
now
=
time
(
NULL
);
*
date
=
ctime_r
(
&
now
,
cbuf
);
*
date
=
get_mem
(
CSZ
);
if
(
*
date
!=
NULL
)
*
date_len
=
strctime
(
*
date
,
CSZ
,
&
now
);
{
#else
*
date
=
strdup
(
*
date
);
*
date_len
=
strlen
(
*
date
);
i
=
0
;
while
((
*
date
)[
i
])
{
if
((
*
date
)[
i
]
==
'\n'
)
(
*
date
)[
i
]
=
' '
;
i
++
;
}
return
;
}
#endif
*
date
=
NULL
;
*
date
=
NULL
;
*
date_len
=
0
;
*
date_len
=
0
;
#endif
}
}
...
@@ -100,22 +75,14 @@ export_proto(fdate_sub);
...
@@ -100,22 +75,14 @@ export_proto(fdate_sub);
void
void
fdate_sub
(
char
*
date
,
gfc_charlen_type
date_len
)
fdate_sub
(
char
*
date
,
gfc_charlen_type
date_len
)
{
{
#if defined(HAVE_TIME) && defined(HAVE_CTIME)
#if defined(HAVE_TIME)
char
cbuf
[
CSZ
];
int
i
;
char
*
d
;
time_t
now
=
time
(
NULL
);
time_t
now
=
time
(
NULL
);
#endif
char
*
s
=
get_mem
(
date_len
+
1
);
size_t
n
=
strctime
(
s
,
date_len
+
1
,
&
now
);
fstrcpy
(
date
,
date_len
,
s
,
n
);
free
(
s
);
#else
memset
(
date
,
' '
,
date_len
);
memset
(
date
,
' '
,
date_len
);
#if defined(HAVE_TIME) && defined(HAVE_CTIME)
d
=
ctime_r
(
&
now
,
cbuf
);
if
(
d
!=
NULL
)
{
i
=
0
;
while
(
*
d
&&
*
d
!=
'\n'
&&
i
<
date_len
)
date
[
i
++
]
=
*
(
d
++
);
}
#endif
#endif
}
}
...
@@ -127,29 +94,15 @@ export_proto_np(PREFIX(ctime));
...
@@ -127,29 +94,15 @@ export_proto_np(PREFIX(ctime));
void
void
PREFIX
(
ctime
)
(
char
**
date
,
gfc_charlen_type
*
date_len
,
GFC_INTEGER_8
t
)
PREFIX
(
ctime
)
(
char
**
date
,
gfc_charlen_type
*
date_len
,
GFC_INTEGER_8
t
)
{
{
#if defined(HAVE_CTIME)
#if defined(HAVE_TIME)
char
cbuf
[
CSZ
];
time_t
now
=
t
;
time_t
now
=
t
;
int
i
;
*
date
=
get_mem
(
CSZ
);
*
date
=
ctime_r
(
&
now
,
cbuf
);
*
date_len
=
strctime
(
*
date
,
CSZ
,
&
now
);
if
(
*
date
!=
NULL
)
#else
{
*
date
=
strdup
(
*
date
);
*
date_len
=
strlen
(
*
date
);
i
=
0
;
while
((
*
date
)[
i
])
{
if
((
*
date
)[
i
]
==
'\n'
)
(
*
date
)[
i
]
=
' '
;
i
++
;
}
return
;
}
#endif
*
date
=
NULL
;
*
date
=
NULL
;
*
date_len
=
0
;
*
date_len
=
0
;
#endif
}
}
...
@@ -159,21 +112,9 @@ export_proto(ctime_sub);
...
@@ -159,21 +112,9 @@ export_proto(ctime_sub);
void
void
ctime_sub
(
GFC_INTEGER_8
*
t
,
char
*
date
,
gfc_charlen_type
date_len
)
ctime_sub
(
GFC_INTEGER_8
*
t
,
char
*
date
,
gfc_charlen_type
date_len
)
{
{
#if defined(HAVE_CTIME)
char
cbuf
[
CSZ
];
int
i
;
char
*
d
;
time_t
now
=
*
t
;
time_t
now
=
*
t
;
#endif
char
*
s
=
get_mem
(
date_len
+
1
);
size_t
n
=
strctime
(
s
,
date_len
+
1
,
&
now
);
memset
(
date
,
' '
,
date_len
);
fstrcpy
(
date
,
date_len
,
s
,
n
);
#if defined(HAVE_CTIME)
free
(
s
);
d
=
ctime_r
(
&
now
,
cbuf
);
if
(
d
!=
NULL
)
{
i
=
0
;
while
(
*
d
&&
*
d
!=
'\n'
&&
i
<
date_len
)
date
[
i
++
]
=
*
(
d
++
);
}
#endif
}
}
libgfortran/intrinsics/date_and_time.c
View file @
8f17e00c
...
@@ -36,24 +36,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
...
@@ -36,24 +36,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#endif
#endif
/* If the re-entrant versions of localtime and gmtime are not
/* If the re-entrant version of gmtime is not available, provide a
available, provide fallback implementations. On some targets where
fallback implementation. On some targets where the _r version is
the _r versions are not available, localtime and gmtime use
not available, gmtime uses thread-local storage so it's
thread-local storage so they are threadsafe. */
threadsafe. */
#ifndef HAVE_LOCALTIME_R
/* If _POSIX is defined localtime_r gets defined by mingw-w64 headers. */
#ifdef localtime_r
#undef localtime_r
#endif
static
struct
tm
*
localtime_r
(
const
time_t
*
timep
,
struct
tm
*
result
)
{
*
result
=
*
localtime
(
timep
);
return
result
;
}
#endif
#ifndef HAVE_GMTIME_R
#ifndef HAVE_GMTIME_R
/* If _POSIX is defined gmtime_r gets defined by mingw-w64 headers. */
/* If _POSIX is defined gmtime_r gets defined by mingw-w64 headers. */
...
...
libgfortran/intrinsics/time_1.h
View file @
8f17e00c
...
@@ -84,6 +84,26 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
...
@@ -84,6 +84,26 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#endif
/* !HAVE_GETRUSAGE || !HAVE_SYS_RESOURCE_H */
#endif
/* !HAVE_GETRUSAGE || !HAVE_SYS_RESOURCE_H */
/* If the re-entrant version of localtime is not available, provide a
fallback implementation. On some targets where the _r version is
not available, localtime uses thread-local storage so it's
threadsafe. */
#ifndef HAVE_LOCALTIME_R
/* If _POSIX is defined localtime_r gets defined by mingw-w64 headers. */
#ifdef localtime_r
#undef localtime_r
#endif
static
inline
struct
tm
*
localtime_r
(
const
time_t
*
timep
,
struct
tm
*
result
)
{
*
result
=
*
localtime
(
timep
);
return
result
;
}
#endif
#if defined (__GNUC__) && (__GNUC__ >= 3)
#if defined (__GNUC__) && (__GNUC__ >= 3)
# define ATTRIBUTE_ALWAYS_INLINE __attribute__ ((__always_inline__))
# define ATTRIBUTE_ALWAYS_INLINE __attribute__ ((__always_inline__))
#else
#else
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment