Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
cython
Commits
74435af4
Commit
74435af4
authored
Jul 01, 2015
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
align abs(long long) implementation with abs(ssize_t) macro
parent
7e803a0f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
9 deletions
+12
-9
Cython/Utility/Builtins.c
Cython/Utility/Builtins.c
+12
-9
No files found.
Cython/Utility/Builtins.c
View file @
74435af4
...
...
@@ -222,19 +222,22 @@ static CYTHON_INLINE unsigned long __Pyx_abs_long(long x) {
//////////////////// abs_longlong.proto ////////////////////
static
CYTHON_INLINE
unsigned
PY_LONG_LONG
__Pyx_abs_longlong
(
PY_LONG_LONG
x
)
{
#ifndef PY_LLONG_MAX
#ifdef LLONG_MAX
const
PY_LONG_LONG
PY_LLONG_MAX
=
LLONG_MAX
;
#else
// copied from pyport.h in CPython 3.3, missing in 2.4
const
PY_LONG_LONG
PY_LLONG_MAX
=
(
1
+
2
*
((
1LL
<<
(
CHAR_BIT
*
sizeof
(
PY_LONG_LONG
)
-
2
))
-
1
));
#endif
#endif
if
(
unlikely
(
x
==
-
PY_LLONG_MAX
-
1
))
return
((
unsigned
PY_LONG_LONG
)
PY_LLONG_MAX
)
+
1U
;
#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#if defined (__cplusplus) && __cplusplus >= 201103L
return
(
unsigned
PY_LONG_LONG
)
std
::
abs
(
x
);
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
return
(
unsigned
PY_LONG_LONG
)
llabs
(
x
);
#elif defined (_MSC_VER) && defined (_M_X64)
// abs() is defined for long, but 64-bits type on MSVC is long long.
// Use MS-specific _abs64 instead.
return
(
unsigned
PY_LONG_LONG
)
_abs64
(
x
);
#elif defined (__GNUC__)
// gcc or clang on 64 bit windows.
return
(
unsigned
PY_LONG_LONG
)
__builtin_llabs
(
x
);
#else
if
(
sizeof
(
PY_LONG_LONG
)
<=
sizeof
(
Py_ssize_t
))
return
__Pyx_sst_abs
(
x
);
return
(
x
<
0
)
?
(
unsigned
PY_LONG_LONG
)
-
x
:
(
unsigned
PY_LONG_LONG
)
x
;
#endif
}
...
...
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