Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
2f0a9576
Unverified
Commit
2f0a9576
authored
Jul 27, 2019
by
Yukihiro "Matz" Matsumoto
Committed by
GitHub
Jul 27, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4598 from dearblue/time-without-float
Fix mruby-time with `MRB_WITHOUT_FLOAT`; ref
d7435506
parents
b58f769c
1467c14a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
+11
-2
mrbgems/mruby-time/src/time.c
mrbgems/mruby-time/src/time.c
+11
-2
No files found.
mrbgems/mruby-time/src/time.c
View file @
2f0a9576
...
...
@@ -4,7 +4,10 @@
** See Copyright Notice in mruby.h
*/
#ifndef MRB_WITHOUT_FLOAT
#include <math.h>
#endif
#include <time.h>
#include <mruby.h>
#include <mruby/class.h>
...
...
@@ -26,8 +29,10 @@ double round(double x) {
}
#endif
#if !defined(__MINGW64__) && defined(_WIN32)
# define llround(x) round(x)
#ifdef MRB_WITHOUT_FLOAT
# if !defined(__MINGW64__) && defined(_WIN32)
# define llround(x) round(x)
# endif
#endif
#if defined(__MINGW64__) || defined(__MINGW32__)
...
...
@@ -276,7 +281,11 @@ time_alloc(mrb_state *mrb, mrb_sec sec, mrb_int usec, enum mrb_timezone timezone
}
tm
=
(
struct
mrb_time
*
)
mrb_malloc
(
mrb
,
sizeof
(
struct
mrb_time
));
tm
->
sec
=
tsec
;
#ifdef MRB_WITHOUT_FLOAT
tm
->
usec
=
(
time_t
)
usec
;
#else
tm
->
usec
=
(
time_t
)
llround
((
sec
-
tm
->
sec
)
*
1.0e6
+
usec
);
#endif
if
(
tm
->
usec
<
0
)
{
long
sec2
=
(
long
)
NDIV
(
tm
->
usec
,
1000000
);
/* negative div */
tm
->
usec
-=
sec2
*
1000000
;
...
...
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