Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
8a87c682
Commit
8a87c682
authored
Feb 04, 2015
by
Marius Wachtler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replace our time module with the cpython implementation
parent
e6e72e86
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
23 additions
and
98 deletions
+23
-98
Makefile
Makefile
+1
-1
from_cpython/CMakeLists.txt
from_cpython/CMakeLists.txt
+1
-1
from_cpython/Include/pyconfig.h
from_cpython/Include/pyconfig.h
+2
-1
from_cpython/Include/pyport.h
from_cpython/Include/pyport.h
+14
-0
src/core/options.cpp
src/core/options.cpp
+2
-0
src/runtime/builtin_modules/time.cpp
src/runtime/builtin_modules/time.cpp
+0
-93
src/runtime/types.cpp
src/runtime/types.cpp
+2
-1
src/runtime/types.h
src/runtime/types.h
+0
-1
test/tests/time_test.py
test/tests/time_test.py
+1
-0
No files found.
Makefile
View file @
8a87c682
...
...
@@ -290,7 +290,7 @@ SRCS := $(MAIN_SRCS) $(STDLIB_SRCS)
STDLIB_OBJS
:=
stdlib.bc.o stdlib.stripped.bc.o
STDLIB_RELEASE_OBJS
:=
stdlib.release.bc.o
STDMODULE_SRCS
:=
errnomodule.c shamodule.c sha256module.c sha512module.c _math.c mathmodule.c md5.c md5module.c _randommodule.c _sre.c operator.c binascii.c pwdmodule.c posixmodule.c _struct.c datetimemodule.c _functoolsmodule.c _collectionsmodule.c itertoolsmodule.c resource.c signalmodule.c selectmodule.c fcntlmodule.c
$(EXTRA_STDMODULE_SRCS)
STDMODULE_SRCS
:=
errnomodule.c shamodule.c sha256module.c sha512module.c _math.c mathmodule.c md5.c md5module.c _randommodule.c _sre.c operator.c binascii.c pwdmodule.c posixmodule.c _struct.c datetimemodule.c _functoolsmodule.c _collectionsmodule.c itertoolsmodule.c resource.c signalmodule.c selectmodule.c fcntlmodule.c
timemodule.c
$(EXTRA_STDMODULE_SRCS)
STDOBJECT_SRCS
:=
structseq.c capsule.c stringobject.c
$(EXTRA_STDOBJECT_SRCS)
STDPYTHON_SRCS
:=
pyctype.c getargs.c formatter_string.c pystrtod.c dtoa.c
$(EXTRA_STDPYTHON_SRCS)
FROM_CPYTHON_SRCS
:=
$(
addprefix
from_cpython/Modules/,
$(STDMODULE_SRCS)
)
$(
addprefix
from_cpython/Objects/,
$(STDOBJECT_SRCS)
)
$(
addprefix
from_cpython/Python/,
$(STDPYTHON_SRCS)
)
...
...
from_cpython/CMakeLists.txt
View file @
8a87c682
...
...
@@ -15,7 +15,7 @@ endforeach(STDLIB_FILE)
add_custom_target
(
copy_stdlib ALL DEPENDS
${
STDLIB_TARGETS
}
)
# compile specified files in from_cpython/Modules
file
(
GLOB_RECURSE STDMODULE_SRCS Modules errnomodule.c shamodule.c sha256module.c sha512module.c _math.c mathmodule.c md5.c md5module.c _randommodule.c _sre.c operator.c binascii.c pwdmodule.c posixmodule.c _struct.c datetimemodule.c _functoolsmodule.c _collectionsmodule.c itertoolsmodule.c resource.c signalmodule.c selectmodule.c fcntlmodule.c
)
file
(
GLOB_RECURSE STDMODULE_SRCS Modules errnomodule.c shamodule.c sha256module.c sha512module.c _math.c mathmodule.c md5.c md5module.c _randommodule.c _sre.c operator.c binascii.c pwdmodule.c posixmodule.c _struct.c datetimemodule.c _functoolsmodule.c _collectionsmodule.c itertoolsmodule.c resource.c signalmodule.c selectmodule.c fcntlmodule.c
timemodule.c
)
# compile specified files in from_cpython/Objects
file
(
GLOB_RECURSE STDOBJECT_SRCS Objects structseq.c capsule.c stringobject.c
)
...
...
from_cpython/Include/pyconfig.h
View file @
8a87c682
...
...
@@ -62,11 +62,13 @@
#define HAVE_ALLOCA_H 1
#define HAVE_ASM_TYPES_H 1
#define HAVE_CLOCK 1
#define HAVE_CURSES_H 1
#define HAVE_DIRENT_H 1
#define HAVE_DLFCN_H 1
#define HAVE_ERRNO_H 1
#define HAVE_FCNTL_H 1
#define HAVE_FTIME 1
#define HAVE_GRP_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_LANGINFO_H 1
...
...
@@ -99,7 +101,6 @@
#define HAVE_SYS_STATVFS_H 1
#define HAVE_SYS_STAT_H 1
#define HAVE_SYS_TIMES_H 1
#define HAVE_SYS_TIME_H 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_SYS_UN_H 1
#define HAVE_SYS_UTSNAME_H 1
...
...
from_cpython/Include/pyport.h
View file @
8a87c682
...
...
@@ -292,6 +292,20 @@ typedef ssize_t Py_ssize_t;
#define Py_MEMCPY memcpy
#endif
/********************************************
* WRAPPER FOR <time.h> and/or <sys/time.h> *
********************************************/
#ifdef TIME_WITH_SYS_TIME
#include <sys/time.h>
#include <time.h>
#else
/* !TIME_WITH_SYS_TIME */
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#else
/* !HAVE_SYS_TIME_H */
#include <time.h>
#endif
/* !HAVE_SYS_TIME_H */
#endif
/* !TIME_WITH_SYS_TIME */
#endif
/* Py_PYPORT_H */
src/core/options.cpp
View file @
8a87c682
...
...
@@ -63,4 +63,6 @@ bool ENABLE_RUNTIME_ICS = 1 && _GLOBAL_ENABLE;
bool
ENABLE_FRAME_INTROSPECTION
=
1
;
bool
BOOLS_AS_I64
=
ENABLE_FRAME_INTROSPECTION
;
extern
"C"
int
Py_IgnoreEnvironmentFlag
=
1
;
}
src/runtime/builtin_modules/time.cpp
deleted
100644 → 0
View file @
e6e72e86
// Copyright (c) 2014-2015 Dropbox, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <cmath>
#include <ctime>
#include <err.h>
#include <sys/time.h>
#include "core/threading.h"
#include "core/types.h"
#include "runtime/objmodel.h"
#include "runtime/types.h"
namespace
pyston
{
BoxedModule
*
time_module
;
/* Exposed in timefuncs.h. */
extern
"C"
time_t
_PyTime_DoubleToTimet
(
double
x
)
noexcept
{
time_t
result
;
double
diff
;
result
=
(
time_t
)
x
;
/* How much info did we lose? time_t may be an integral or
* floating type, and we don't know which. If it's integral,
* we don't know whether C truncates, rounds, returns the floor,
* etc. If we lost a second or more, the C rounding is
* unreasonable, or the input just doesn't fit in a time_t;
* call it an error regardless. Note that the original cast to
* time_t can cause a C error too, but nothing we can do to
* worm around that.
*/
diff
=
x
-
(
double
)
result
;
if
(
diff
<=
-
1.0
||
diff
>=
1.0
)
{
PyErr_SetString
(
PyExc_ValueError
,
"timestamp out of range for platform time_t"
);
result
=
(
time_t
)
-
1
;
}
return
result
;
}
Box
*
timeTime
()
{
struct
timeval
now
;
gettimeofday
(
&
now
,
NULL
);
double
t
=
now
.
tv_sec
+
.000001
*
now
.
tv_usec
;
return
boxFloat
(
t
);
}
Box
*
timeSleep
(
Box
*
arg
)
{
double
secs
;
if
(
isSubclass
(
arg
->
cls
,
int_cls
))
secs
=
static_cast
<
BoxedInt
*>
(
arg
)
->
n
;
else
if
(
arg
->
cls
==
float_cls
)
secs
=
static_cast
<
BoxedFloat
*>
(
arg
)
->
d
;
else
{
raiseExcHelper
(
TypeError
,
"a float is required"
);
}
double
fullsecs
;
double
nanosecs
=
modf
(
secs
,
&
fullsecs
);
struct
timespec
req
;
req
.
tv_sec
=
(
int
)(
fullsecs
+
0.01
);
req
.
tv_nsec
=
(
int
)(
nanosecs
*
1000000000
);
{
threading
::
GLAllowThreadsReadRegion
_allow_threads
;
int
code
=
nanosleep
(
&
req
,
NULL
);
if
(
code
)
err
(
1
,
NULL
);
}
return
None
;
}
void
setupTime
()
{
time_module
=
createModule
(
"time"
,
"__builtin__"
);
time_module
->
giveAttr
(
"time"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
timeTime
,
BOXED_FLOAT
,
0
)));
time_module
->
giveAttr
(
"sleep"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
timeSleep
,
NONE
,
1
)));
}
}
src/runtime/types.cpp
View file @
8a87c682
...
...
@@ -56,6 +56,7 @@ extern "C" void initresource();
extern
"C"
void
initsignal
();
extern
"C"
void
initselect
();
extern
"C"
void
initfcntl
();
extern
"C"
void
inittime
();
namespace
pyston
{
...
...
@@ -1162,7 +1163,6 @@ void setupRuntime() {
setupSys
();
setupBuiltins
();
setupTime
();
setupThread
();
setupGC
();
...
...
@@ -1191,6 +1191,7 @@ void setupRuntime() {
initsignal
();
initselect
();
initfcntl
();
inittime
();
setupSysEnd
();
...
...
src/runtime/types.h
View file @
8a87c682
...
...
@@ -68,7 +68,6 @@ void teardownDescr();
void
setupSys
();
void
setupBuiltins
();
void
setupTime
();
void
setupThread
();
void
setupSysEnd
();
...
...
test/tests/time_test.py
View file @
8a87c682
...
...
@@ -3,3 +3,4 @@ print type(time)
time
.
sleep
(
0
)
time
.
sleep
(
False
)
time
.
clock
()
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