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
d5695a84
Unverified
Commit
d5695a84
authored
Aug 03, 2019
by
Yukihiro "Matz" Matsumoto
Committed by
GitHub
Aug 03, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4610 from dearblue/time-warnings
Suppress compiler warnings for mruby-time; fix #4600
parents
c883f4e3
07308a2f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
27 deletions
+15
-27
mrbgems/mruby-time/src/time.c
mrbgems/mruby-time/src/time.c
+15
-27
No files found.
mrbgems/mruby-time/src/time.c
View file @
d5695a84
...
...
@@ -213,6 +213,16 @@ typedef mrb_int mrb_sec;
#define mrb_sec_value(mrb, sec) mrb_fixnum_value(sec)
#endif
#ifdef MRB_TIME_T_UINT
typedef
uint64_t
mrb_time_int
;
# define MRB_TIME_MIN 0
# define MRB_TIME_MAX (sizeof(time_t) <= 4 ? UINT32_MAX : UINT64_MAX)
#else
typedef
int64_t
mrb_time_int
;
# define MRB_TIME_MIN (sizeof(time_t) <= 4 ? INT32_MIN : INT64_MIN)
# define MRB_TIME_MAX (sizeof(time_t) <= 4 ? INT32_MAX : INT64_MAX)
#endif
static
time_t
mrb_to_time_t
(
mrb_state
*
mrb
,
mrb_value
obj
,
time_t
*
usec
)
{
...
...
@@ -225,21 +235,9 @@ mrb_to_time_t(mrb_state *mrb, mrb_value obj, time_t *usec)
mrb_float
f
=
mrb_float
(
obj
);
mrb_check_num_exact
(
mrb
,
f
);
# ifndef MRB_TIME_T_UINT
if
(
sizeof
(
time_t
)
==
4
&&
(
f
>
(
mrb_float
)
INT32_MAX
||
(
mrb_float
)
INT32_MIN
>
f
))
{
goto
out_of_range
;
}
if
(
sizeof
(
time_t
)
==
8
&&
(
f
>
(
mrb_float
)
INT64_MAX
||
(
mrb_float
)
INT64_MIN
>
f
))
{
goto
out_of_range
;
}
# else
if
(
sizeof
(
time_t
)
==
4
&&
(
f
>
(
mrb_float
)
UINT32_MAX
||
(
mrb_float
)
0
>
f
))
{
goto
out_of_range
;
}
if
(
sizeof
(
time_t
)
==
8
&&
(
f
>
(
mrb_float
)
UINT64_MAX
||
(
mrb_float
)
0
>
f
))
{
if
(
f
>
(
mrb_float
)
MRB_TIME_MAX
||
(
mrb_float
)
MRB_TIME_MIN
>
f
)
{
goto
out_of_range
;
}
# endif
if
(
usec
)
{
t
=
(
time_t
)
f
;
...
...
@@ -256,21 +254,9 @@ mrb_to_time_t(mrb_state *mrb, mrb_value obj, time_t *usec)
{
mrb_int
i
=
mrb_int
(
mrb
,
obj
);
#ifndef MRB_TIME_T_UINT
if
(
sizeof
(
time_t
)
==
4
&&
(
i
>
INT32_MAX
||
INT32_MIN
>
i
))
{
goto
out_of_range
;
}
if
(
sizeof
(
time_t
)
==
8
&&
(
i
>
INT64_MAX
||
INT64_MIN
>
i
))
{
goto
out_of_range
;
}
#else
if
(
sizeof
(
time_t
)
==
4
&&
(
i
>
UINT32_MAX
||
0
>
i
))
{
goto
out_of_range
;
}
if
(
sizeof
(
time_t
)
==
8
&&
(
i
>
UINT64_MAX
||
0
>
i
))
{
if
((
mrb_time_int
)
i
>
MRB_TIME_MAX
||
MRB_TIME_MIN
>
i
)
{
goto
out_of_range
;
}
#endif
t
=
(
time_t
)
i
;
if
(
usec
)
{
*
usec
=
0
;
}
...
...
@@ -283,7 +269,9 @@ mrb_to_time_t(mrb_state *mrb, mrb_value obj, time_t *usec)
out_of_range:
mrb_raisef
(
mrb
,
E_ARGUMENT_ERROR
,
"%S out of Time range"
,
obj
);
return
0
;
/* suppress compiler warnings */
/* not reached */
if
(
usec
)
{
*
usec
=
0
;
}
return
0
;
}
/** Updates the datetime of a mrb_time based on it's timezone and
...
...
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