Commits

Alex Gaynor committed c1f79d7

Change a bunch of sys.platform == 'linux2' to be sys.platform.startswith('linux') to be ready for linux3.

Comments (0)

Files changed (17)

pypy/config/support.py

         return 1    # don't override MAKEFLAGS.  This will call 'make' without any '-j' option
     if sys.platform == 'darwin':
         return darwin_get_cpu_count()
-    elif sys.platform != 'linux2':
+    elif not sys.platform.startswith('linux'):
         return 1    # implement me
     try:
         if isinstance(filename_or_file, str):

pypy/config/test/test_support.py

         return self._value
 
 def test_cpuinfo_linux():
-    if sys.platform != 'linux2':
+    if not sys.platform.startswith('linux'):
         py.test.skip("linux only")
     saved = os.environ
     try:

pypy/jit/backend/llvm/llvm_rffi.py

 from pypy.rpython.lltypesystem import lltype, rffi
 from pypy.translator.tool.cbuild import ExternalCompilationInfo, log
 
-if sys.platform != 'linux2':
+if not sys.platform.startswith('linux'):
     py.test.skip("Linux only for now")
 
 # ____________________________________________________________

pypy/module/cpyext/api.py

     'PyCapsule_SetContext', 'PyCapsule_Import', 'PyCapsule_Type', 'init_capsule',
 
     'PyObject_AsReadBuffer', 'PyObject_AsWriteBuffer', 'PyObject_CheckReadBuffer',
-    
+
     'PyOS_getsig', 'PyOS_setsig',
 
     'PyStructSequence_InitType', 'PyStructSequence_New',
             ctypes.c_void_p)
 
     setup_va_functions(eci)
-   
+
     setup_init_functions(eci)
     return modulename.new(ext='')
 
         export_symbols[:] = renamed_symbols
     else:
         export_symbols[:] = [sym.replace("#", "") for sym in export_symbols]
-    
+
     # Generate defines
     for macro_name, size in [
         ("SIZEOF_LONG_LONG", rffi.LONGLONG),
     ]:
         pypy_macros.append("#define %s %s" % (macro_name, rffi.sizeof(size)))
     pypy_macros.append('')
-    
+
     pypy_macros_h = udir.join('pypy_macros.h')
     pypy_macros_h.write('\n'.join(pypy_macros))
 
             # Sometimes the library is wrapped into another DLL, ensure that
             # the correct bootstrap code is installed
             kwds["link_extra"] = ["msvcrt.lib"]
-        elif sys.platform == 'linux2':
+        elif sys.platform.startswith('linux'):
             compile_extra.append("-Werror=implicit-function-declaration")
         export_symbols_eci.append('pypyAPI')
     else:
     FT = lltype.typeOf(func).TO
     return make_generic_cpy_call(FT, False, False)(space, func, *args)
 
-@specialize.ll()    
+@specialize.ll()
 def generic_cpy_call_expect_null(space, func, *args):
     FT = lltype.typeOf(func).TO
     return make_generic_cpy_call(FT, True, True)(space, func, *args)

pypy/module/cpyext/test/test_cpyext.py

             kwds["compile_extra"] = ["/we4013"]
         else:
             kwds["link_files"] = [str(api_library + '.so')]
-            if sys.platform == 'linux2':
+            if sys.platform.startswith('linux'):
                 kwds["compile_extra"]=["-Werror=implicit-function-declaration"]
         return compile_module(self.space, name, **kwds)
 

pypy/module/imp/importing.py

 
     return SEARCH_ERROR, None, None
 
-if sys.platform == 'linux2' or 'freebsd' in sys.platform:
+if sys.platform.startswith('linux') or 'freebsd' in sys.platform:
     def case_ok(filename):
         return True
 else:

pypy/module/posix/test/test_posix2.py

         assert st.st_size == 14
         assert st.st_nlink == 1
 
-        #if sys.platform.startswith('linux2'):
+        #if sys.platform.startswith('linux'):
         #    # expects non-integer timestamps - it's unlikely that they are
         #    # all three integers
         #    assert ((st.st_atime, st.st_mtime, st.st_ctime) !=
         #            (st[7],       st[8],       st[9]))
         #    assert st.st_blksize * st.st_blocks >= st.st_size
-        if sys.platform.startswith('linux2'):
+        if sys.platform.startswith('linux'):
             assert hasattr(st, 'st_rdev')
 
     def test_stat_float_times(self):

pypy/rlib/test/test_rlocale.py

     assert isinstance(grouping, str)
 
 def test_libintl():
-    if sys.platform not in ("linux2", "darwin"):
+    if sys.platform != "darwin" or not sys.platform.startswith("linux"):
         py.test.skip("there is (maybe) no libintl here")
     _gettext = external('gettext', [rffi.CCHARP], rffi.CCHARP)
     res = _gettext("1234")

pypy/rpython/lltypesystem/ll2ctypes.py

                 return _items
             _items.append(nextitem)
             i += 1
-        
+
     items = property(getitems)
 
 class _array_of_known_length(_array_of_unknown_length):
             return clibname+'.dll'
         else:
             return ctypes.util.find_library('c')
-        
+
     libc_name = get_libc_name()     # Make sure the name is determined during import, not at runtime
     # XXX is this always correct???
     standard_c_lib = ctypes.CDLL(get_libc_name(), **load_library_kwargs)
             return lib[elem]
         except AttributeError:
             pass
-    
+
     old_eci = funcptr._obj.compilation_info
     funcname = funcptr._obj._name
     if hasattr(old_eci, '_with_ctypes'):
             def _where_is_errno():
                 return standard_c_lib._errno()
 
-        elif sys.platform in ('linux2', 'freebsd6'):
+        elif sys.platform.startswith('linux') or sys.platform == 'freebsd6':
             standard_c_lib.__errno_location.restype = ctypes.POINTER(ctypes.c_int)
             def _where_is_errno():
                 return standard_c_lib.__errno_location()

pypy/rpython/lltypesystem/llarena.py

 from pypy.rpython.extfunc import register_external
 from pypy.rlib.objectmodel import CDefinedIntSymbolic
 
-if sys.platform == 'linux2':
+if sys.platform.startswith('linux'):
     # This only works with linux's madvise(), which is really not a memory
     # usage hint but a real command.  It guarantees that after MADV_DONTNEED
     # the pages are cleared again.

pypy/rpython/lltypesystem/test/test_ll2ctypes.py

         assert not hasattr(sc.contents, 'length')
         lltype.free(s, flavor='raw')
         assert not ALLOCATED
-        
+
     def test_strlen(self):
         eci = ExternalCompilationInfo(includes=['string.h'])
         strlen = rffi.llexternal('strlen', [rffi.CCHARP], rffi.SIZE_T,
         assert f() == 'z'
         res = interpret(f, [])
         assert res == 'z'
-    
+
     def test_funcptr1(self):
         def dummy(n):
             return n+1
         eci = ExternalCompilationInfo(
             post_include_bits = ["#define fn(x) (42 + x)"],
         )
-        fn1 = rffi.llexternal('fn', [rffi.INT], rffi.INT, 
+        fn1 = rffi.llexternal('fn', [rffi.INT], rffi.INT,
                               compilation_info=eci, macro=True)
-        fn2 = rffi.llexternal('fn2', [rffi.DOUBLE], rffi.DOUBLE, 
+        fn2 = rffi.llexternal('fn2', [rffi.DOUBLE], rffi.DOUBLE,
                               compilation_info=eci, macro='fn')
         res = fn1(10)
         assert res == 52
         header = py.code.Source("""
         #ifndef _SOME_H
         #define _SOME_H
-        
+
         #include <stdlib.h>
-        
+
         static long x = 3;
         static int y = 5;
         char **z = NULL;
         """)
         h_file = udir.join("some_h.h")
         h_file.write(header)
-        
+
         eci = ExternalCompilationInfo(includes=['stdio.h', str(h_file.basename)],
                                       include_dirs=[str(udir)])
-        
+
         get_x, set_x = rffi.CExternVariable(rffi.LONG, 'x', eci, c_type='long')
         get_y, set_y = rffi.CExternVariable(rffi.INT, 'y', eci, c_type='int')
         get_z, set_z = rffi.CExternVariable(rffi.CCHARPP, 'z', eci)
         assert not ref0
 
         p1234 = ctypes.c_void_p(1234)
-        ref1234 = ctypes2lltype(llmemory.GCREF, p1234)        
+        ref1234 = ctypes2lltype(llmemory.GCREF, p1234)
         assert p1234
 
     def test_gcref_casts(self):
         ref2 = ctypes2lltype(llmemory.GCREF, intval1)
 
         assert lltype.cast_opaque_ptr(lltype.Ptr(NODE), ref2) == node
-        
+
         #addr = llmemory.cast_ptr_to_adr(ref1)
         #assert llmemory.cast_adr_to_int(addr) == intval
 
         A = lltype.GcArray(lltype.Signed)
         a = lltype.malloc(A, 20)
         inside = lltype.direct_ptradd(lltype.direct_arrayitems(a), 3)
- 
+
         lltype2ctypes(inside)
 
         start = rffi.cast(lltype.Signed, lltype.direct_arrayitems(a))
 
         n1 = lltype.malloc(NODE)
         i1 = rffi.cast(lltype.Signed, n1)
-        ref1 = rffi.cast(llmemory.GCREF, i1)        
+        ref1 = rffi.cast(llmemory.GCREF, i1)
         adr1 = llmemory.cast_ptr_to_adr(ref1)
 
         assert adr1 != adr0
         from pypy.rpython.annlowlevel import cast_base_ptr_to_instance
         from pypy.rpython.annlowlevel import cast_instance_to_base_ptr
         from pypy.rpython.lltypesystem import rclass
-        
+
         class Opaque(object):
             llopaque = True
 
 
     def test_prefix(self):
 
-        if sys.platform != 'linux2':
+        if not sys.platform.startswith('linux'):
             py.test.skip("Not supported")
 
         from pypy.translator.platform import platform

pypy/rpython/memory/gc/env.py

 # will be huge on 64-bit systems.
 
 if sys.maxint == 2147483647:    # 32-bit
-    if sys.platform == 'linux2':
+    if sys.platform.startswith('linux'):
         addressable_size = float(2**32)     # 4GB
     elif sys.platform == 'win32':
         addressable_size = float(2**31)     # 2GB
     addressable_size = float(2**63)    # 64-bit
 
 
-def get_total_memory_linux2(filename):
+def get_total_memory_linux(filename):
     debug_start("gc-hardware")
     result = -1.0
     try:
             result = addressable_size
     debug_stop("gc-hardware")
     return result
-
+get_total_memory_linux2 = get_total_memory_linux3 = get_total_memory_linux
 
 def get_total_memory_darwin(result):
     debug_start("gc-hardware")
     return result
 
 
-if sys.platform == 'linux2':
+if sys.platform.startswith('linux'):
     def get_total_memory():
         return get_total_memory_linux2('/proc/meminfo')
 

pypy/rpython/module/ll_os_stat.py

 #   sub-second timestamps.
 # - TIMESPEC is defined when the "struct stat" contains st_atim field.
 
-if sys.platform == 'linux2':
+if sys.platform.startswith('linux'):
     TIMESPEC = platform.Struct('struct timespec',
                                [('tv_sec', rffi.TIME_T),
                                 ('tv_nsec', rffi.LONG)])
 if sys.platform != 'win32':
 
     LL_STAT_FIELDS = STAT_FIELDS[:]
-    
+
     if TIMESPEC is not None:
         class CConfig_for_timespec:
             _compilation_info_ = compilation_info
     assert traits.str is str
 
     if sys.platform.startswith('linux'):
-        # because we always use _FILE_OFFSET_BITS 64 - this helps things work that are not a c compiler 
+        # because we always use _FILE_OFFSET_BITS 64 - this helps things work that are not a c compiler
         _functions = {'stat':  'stat64',
                       'fstat': 'fstat64',
                       'lstat': 'lstat64'}

pypy/translator/c/gc.py

     def OP_GC_CALL_RTTI_DESTRUCTOR(self, funcgen, op):
         args = [funcgen.expr(v) for v in op.args]
         line = '%s(%s);' % (args[0], ', '.join(args[1:]))
-        return line     
-    
+        return line
+
     def OP_GC_FREE(self, funcgen, op):
         args = [funcgen.expr(v) for v in op.args]
-        return 'OP_FREE(%s);' % (args[0], )    
+        return 'OP_FREE(%s);' % (args[0], )
 
     def OP_GC__COLLECT(self, funcgen, op):
         return ''
         eci = eci.merge(configure_boehm())
 
         pre_include_bits = []
-        if sys.platform == "linux2":
+        if sys.platform.startswith('linux'):
             pre_include_bits += ["#define _REENTRANT 1",
                                  "#define GC_LINUX_THREADS 1"]
         if sys.platform != "win32":

pypy/translator/platform/__init__.py

             extra = self.shared_only
         cflags = list(self.cflags) + list(extra)
         return (cflags + list(eci.compile_extra) + args)
-    
+
     def preprocess_library_dirs(self, library_dirs):
         if 'PYPY_LOCALBASE' in os.environ:
             dirs = list(self._preprocess_library_dirs(library_dirs))
         raise NotImplementedError("Needs to be overwritten")
 
     def _library_dirs_for_libffi(self):
-        raise NotImplementedError("Needs to be overwritten")        
+        raise NotImplementedError("Needs to be overwritten")
 
     def check___thread(self):
         return True
 
-    
-if sys.platform == 'linux2':
+
+if sys.platform.startswith('linux'):
     from pypy.translator.platform.linux import Linux, Linux64
     import platform
     if platform.architecture()[0] == '32bit':

pypy/translator/sandbox/sandlib.py

     def handle_until_return(self):
         child_stdin  = self.popen.stdin
         child_stdout = self.popen.stdout
-        if self.os_level_sandboxing and sys.platform.startswith('linux2'):
+        if self.os_level_sandboxing and sys.platform.startswith('linux'):
             # rationale: we wait until the child process started completely,
             # letting the C library do any system calls it wants for
             # initialization.  When the RPython code starts up, it quickly
                   self._input.isatty()):
                 # don't wait for all 'size' chars if reading from a tty,
                 # to avoid blocking.  Instead, stop after reading a line.
-                
+
                 # For now, waiting at the interactive console is the
                 # only time that counts as idle.
                 self.enter_idle()
     def __init__(self, *args, **kwds):
         super(VirtualizedSocketProc, self).__init__(*args, **kwds)
         self.sockets = {}
-    
+
     def do_ll_os__ll_os_open(self, name, flags, mode):
         if not name.startswith("tcp://"):
             return super(VirtualizedSocketProc, self).do_ll_os__ll_os_open(
             return self.open_fds[fd].send(data)
         return super(VirtualizedSocketProc, self).do_ll_os__ll_os_write(
             fd, data)
-            
+

pypy/translator/sandbox/test/test_sandbox.py

     g = pipe.stdin
     f = pipe.stdout
     expect(f, g, "ll_os.ll_os_getenv", ("PYPY_GENERATIONGC_NURSERY",), None)
-    if sys.platform == 'linux2':  # on Mac, uses another (sandboxsafe) approach
+    if sys.platform.startswith('linux'):  # on Mac, uses another (sandboxsafe) approach
         expect(f, g, "ll_os.ll_os_open", ("/proc/cpuinfo", 0, 420),
                OSError(5232, "xyz"))
     expect(f, g, "ll_os.ll_os_getenv", ("PYPY_GC_DEBUG",), None)
 
 def test_safe_alloc():
     from pypy.rlib.rmmap import alloc, free
-    
+
     def entry_point(argv):
         one = alloc(1024)
         free(one, 1024)
     py.test.skip("Since this stuff is unimplemented, it won't work anyway "
                  "however, the day it starts working, it should pass test")
     from pypy.rlib.rmmap import mmap
-    
+
     def entry_point(argv):
         try:
             res = mmap(0, 1024)