Commit f5a4c935 authored by scoder's avatar scoder Committed by GitHub

Merge pull request #2016 from jdemeyer/libc_limits

Fix types of values in libc.limits
parents 2fc2cba0 e9126671
...@@ -2074,7 +2074,11 @@ class NameNode(AtomicExprNode): ...@@ -2074,7 +2074,11 @@ class NameNode(AtomicExprNode):
def check_const(self): def check_const(self):
entry = self.entry entry = self.entry
if entry is not None and not (entry.is_const or entry.is_cfunction or entry.is_builtin): if entry is not None and not (
entry.is_const or
entry.is_cfunction or
entry.is_builtin or
entry.type.is_const):
self.not_const() self.not_const()
return False return False
return True return True
......
# 5.2.4.2.1 Sizes of integer types <limits.h> # 5.2.4.2.1 Sizes of integer types <limits.h>
cdef extern from "<limits.h>": cdef extern from "<limits.h>":
const int CHAR_BIT
const int MB_LEN_MAX
enum: CHAR_BIT const char CHAR_MIN
enum: MB_LEN_MAX const char CHAR_MAX
enum: CHAR_MIN const signed char SCHAR_MIN
enum: CHAR_MAX const signed char SCHAR_MAX
const unsigned char UCHAR_MAX
enum: SCHAR_MIN const short SHRT_MIN
enum: SCHAR_MAX const short SHRT_MAX
enum: UCHAR_MAX const unsigned short USHRT_MAX
enum: SHRT_MIN const int INT_MIN
enum: SHRT_MAX const int INT_MAX
enum: USHRT_MAX const unsigned int UINT_MAX
enum: INT_MIN const long LONG_MIN
enum: INT_MAX const long LONG_MAX
enum: UINT_MAX const unsigned long ULONG_MAX
enum: LONG_MIN const long long LLONG_MIN
enum: LONG_MAX const long long LLONG_MAX
enum: ULONG_MAX const unsigned long long ULLONG_MAX
enum: LLONG_MIN
enum: LLONG_MAX
enum: ULLONG_MAX
...@@ -10,10 +10,7 @@ cimport cython ...@@ -10,10 +10,7 @@ cimport cython
import sys import sys
IS_PYPY = hasattr(sys, 'pypy_version_info') IS_PYPY = hasattr(sys, 'pypy_version_info')
cdef extern from *: from libc.limits cimport INT_MAX, LONG_MAX, LONG_MIN
int INT_MAX
long LONG_MAX
long LONG_MIN
max_int = INT_MAX max_int = INT_MAX
max_long = LONG_MAX max_long = LONG_MAX
...@@ -149,6 +146,15 @@ def format_c_numbers_max(int n, long l): ...@@ -149,6 +146,15 @@ def format_c_numbers_max(int n, long l):
return s1, s2 return s1, s2
def format_c_number_const():
"""
>>> s = format_c_number_const()
>>> s == '{0}'.format(max_long) or s
True
"""
return f"{LONG_MAX}"
def format_c_number_range(int n): def format_c_number_range(int n):
""" """
>>> for i in range(-1000, 1000): >>> for i in range(-1000, 1000):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment