Author: Richard Plangger <planri...@gmail.com> Branch: ppc-vsx-support Changeset: r87239:d0e4fba9c670 Date: 2016-09-20 09:06 +0200 http://bitbucket.org/pypy/pypy/changeset/d0e4fba9c670/
Log: use os.open instead of open() to read from /proc files at runtime diff --git a/rpython/jit/backend/ppc/detect_feature.py b/rpython/jit/backend/ppc/detect_feature.py --- a/rpython/jit/backend/ppc/detect_feature.py +++ b/rpython/jit/backend/ppc/detect_feature.py @@ -1,3 +1,4 @@ +import os import sys import struct import platform @@ -13,19 +14,25 @@ SYSTEM = platform.system() def detect_vsx_linux(): - with open('/proc/self/auxv', 'rb') as fd: - while True: - buf = fd.read(8) - buf2 = fd.read(8) - if not buf or not buf2: - break - key = runpack("L", buf) - value = runpack("L", buf2) - if key == AT_HWCAP: - if value & PPC_FEATURE_HAS_ALTIVEC: - return True - if key == AT_NULL: - return False + try: + fd = os.open("/proc/self/auxv", os.O_RDONLY, 0644) + try: + while True: + buf = os.read(fd, 8) + buf2 = os.read(fd, 8) + if not buf or not buf2: + break + key = runpack("L", buf) + value = runpack("L", buf2) + if key == AT_HWCAP: + if value & PPC_FEATURE_HAS_ALTIVEC: + return True + if key == AT_NULL: + return False + finally: + os.close(fd) + except OSError: + pass return False def detect_vsx(): diff --git a/rpython/jit/backend/x86/assembler.py b/rpython/jit/backend/x86/assembler.py --- a/rpython/jit/backend/x86/assembler.py +++ b/rpython/jit/backend/x86/assembler.py @@ -693,7 +693,7 @@ assert len(guard_locs) == len(bridge_locs) for i,src_loc in enumerate(guard_locs): dst_loc = bridge_locs[i] - if not src_loc.is_fp_reg(): + if not src_loc.is_float(): src_locations1.append(src_loc) dst_locations1.append(dst_loc) else: diff --git a/rpython/jit/metainterp/optimizeopt/schedule.py b/rpython/jit/metainterp/optimizeopt/schedule.py --- a/rpython/jit/metainterp/optimizeopt/schedule.py +++ b/rpython/jit/metainterp/optimizeopt/schedule.py @@ -128,7 +128,7 @@ self.delay_emit(node) return # emit a now! - self.pre_emit(node) + self.pre_emit(node, True) self.mark_emitted(node) if not node.is_imaginary(): op = node.getoperation() diff --git a/rpython/translator/platform/arch/s390x.py b/rpython/translator/platform/arch/s390x.py --- a/rpython/translator/platform/arch/s390x.py +++ b/rpython/translator/platform/arch/s390x.py @@ -1,4 +1,5 @@ import re +import os def extract_s390x_cpu_ids(lines): ids = [] @@ -39,20 +40,31 @@ return ids def s390x_detect_vx(): - contentlist = [] - with open("/proc/cpuinfo", "rb") as fd: - content = fd.read() - start = content.find("features", 0) - if start >= 0: - after_colon = content.find(":", start) - if after_colon < 0: - return False - newline = content.find("\n", after_colon) - if newline < 0: - return False - split = content[after_colon+1:newline].strip().split(' ') - if 'vx' in split: - return True + chunks = [] + try: + fd = os.open("/proc/self/auxv", os.O_RDONLY, 0644) + try: + while True: + chunk = os.read(fd, 4096) + if not chunk: + break + chunks.append(chunk) + finally: + os.close(fd) + except OSError: + pass + content = ''.join(chunks) + start = content.find("features", 0) + if start >= 0: + after_colon = content.find(":", start) + if after_colon < 0: + return False + newline = content.find("\n", after_colon) + if newline < 0: + return False + split = content[after_colon+1:newline].strip().split(' ') + if 'vx' in split: + return True return False def s390x_cpu_revision(): _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit