To protect your data, the CISO officer has suggested users to enable GitLab 2FA as soon as possible.

pypy.patch 9.6 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
diff --git a/pypy/module/_file/readinto.py b/pypy/module/_file/readinto.py
index af1d380..7a5c762 100644
--- a/pypy/module/_file/readinto.py
+++ b/pypy/module/_file/readinto.py
@@ -7,10 +7,10 @@ from pypy.module._file.interp_file import is_wouldblock_error, signal_checker
 _WIN32 = sys.platform.startswith('win')
 UNDERSCORE_ON_WIN32 = '_' if _WIN32 else ''
 
-os_read = rffi.llexternal(UNDERSCORE_ON_WIN32 + 'read',
-                          [rffi.INT, rffi.CCHARP, rffi.SIZE_T],
-                          rffi.SSIZE_T, save_err=rffi.RFFI_SAVE_ERRNO)
-
+# os_read = rffi.llexternal(UNDERSCORE_ON_WIN32 + 'read',
+#                           [rffi.INT, rffi.CCHARP, rffi.SIZE_T],
+#                           rffi.SSIZE_T, save_err=rffi.RFFI_SAVE_ERRNO)
+os_read = rposix.c_read
 
 def direct_readinto(self, w_rwbuffer):
     rwbuffer = self.space.writebuf_w(w_rwbuffer)
@@ -60,7 +60,7 @@ def direct_readinto(self, w_rwbuffer):
         if size > 0:
             stream.flush()
             while True:
-                got = os_read(fd, rffi.ptradd(target_address, target_pos), size)
+                got = os_read(fd, rffi.cast(rffi.VOIDP, rffi.ptradd(target_address, target_pos)), size)
                 got = rffi.cast(lltype.Signed, got)
                 if got > 0:
                     target_pos += got
John Zhang's avatar
John Zhang committed
29
30
31
32
33
34
35
36
37
38
39
40
41
diff --git a/rpython/rlib/jit.py b/rpython/rlib/jit.py
index e973a94..b9752e8 100644
--- a/rpython/rlib/jit.py
+++ b/rpython/rlib/jit.py
@@ -472,7 +472,7 @@ def virtual_ref(x):
 @specialize.argtype(1)
 def virtual_ref_finish(vref, x):
     """See docstring in virtual_ref(x)"""
-    keepalive_until_here(x)   # otherwise the whole function call is removed
+    # keepalive_until_here(x)   # otherwise the whole function call is removed
     _virtual_ref_finish(vref, x)
 
 def non_virtual_ref(x):
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py
index f35e2b7..6aad4b8 100644
--- a/rpython/rlib/rposix.py
+++ b/rpython/rlib/rposix.py
@@ -1778,9 +1778,9 @@ def uname():
         lltype.free(l_utsbuf, flavor='raw')
 
 # These are actually macros on some/most systems
-c_makedev = external('makedev', [rffi.INT, rffi.INT], rffi.INT)
-c_major = external('major', [rffi.INT], rffi.INT)
-c_minor = external('minor', [rffi.INT], rffi.INT)
+c_makedev = external('makedev', [rffi.INT, rffi.INT], rffi.INT, macro=_MACRO_ON_POSIX)
+c_major = external('major', [rffi.INT], rffi.INT, macro=_MACRO_ON_POSIX)
+c_minor = external('minor', [rffi.INT], rffi.INT, macro=_MACRO_ON_POSIX)
 
 @replace_os_function('makedev')
 @jit.dont_look_inside
John Zhang's avatar
John Zhang committed
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
diff --git a/rpython/rlib/rthread.py b/rpython/rlib/rthread.py
index cf9fecf..ca5fa64 100644
--- a/rpython/rlib/rthread.py
+++ b/rpython/rlib/rthread.py
@@ -381,17 +381,18 @@ class ThreadLocalReference(ThreadLocalField):
 
     def __init__(self, Cls, loop_invariant=False):
         "NOT_RPYTHON: must be prebuilt"
+        from rpython.rtyper import rclass
         self.Cls = Cls
         unique_id = ThreadLocalReference._COUNT
         ThreadLocalReference._COUNT += 1
-        ThreadLocalField.__init__(self, lltype.Signed, 'tlref%d' % unique_id,
+        ThreadLocalField.__init__(self, rclass.OBJECTPTR, 'tlref%d' % unique_id,
                                   loop_invariant=loop_invariant)
         setraw = self.setraw
         offset = self._offset
 
         def get():
             if we_are_translated():
-                from rpython.rtyper import rclass
+                # from rpython.rtyper import rclass
                 from rpython.rtyper.annlowlevel import cast_base_ptr_to_instance
                 _threadlocalref_seeme(self)
                 ptr = llop.threadlocalref_get(rclass.OBJECTPTR, offset)
@@ -403,9 +404,10 @@ class ThreadLocalReference(ThreadLocalField):
         def set(value):
             assert isinstance(value, Cls) or value is None
             if we_are_translated():
-                from rpython.rtyper.annlowlevel import cast_instance_to_gcref
+                from rpython.rtyper.annlowlevel import cast_instance_to_gcref, cast_instance_to_base_ptr
                 gcref = cast_instance_to_gcref(value)
-                value = lltype.cast_ptr_to_int(gcref)
+                # value = lltype.cast_ptr_to_int(gcref)
+                value = cast_instance_to_base_ptr(value)
                 setraw(value)
                 rgc.register_custom_trace_hook(TRACETLREF, _lambda_trace_tlref)
                 rgc.ll_writebarrier(_tracetlref_obj)
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
diff --git a/rpython/rlib/test/test_rposix.py b/rpython/rlib/test/test_rposix.py
index b3bc6ed..4edfcaa 100644
--- a/rpython/rlib/test/test_rposix.py
+++ b/rpython/rlib/test/test_rposix.py
@@ -281,6 +281,10 @@ class TestPosixFunction:
     def test_isatty(self):
         assert rposix.isatty(-1) is False
 
+    def test_makedev(self):
+        dev = rposix.makedev(24, 7)
+        assert rposix.major(dev) == 24
+        assert rposix.minor(dev) == 7
 
 @py.test.mark.skipif("not hasattr(os, 'ttyname')")
 class TestOsExpect(ExpectTest):
John Zhang's avatar
John Zhang committed
112
113
114
115
116
117
118
119
120
121
122
123
diff --git a/rpython/rtyper/lltypesystem/rffi.py b/rpython/rtyper/lltypesystem/rffi.py
index 1b7a007..48d04d5 100644
--- a/rpython/rtyper/lltypesystem/rffi.py
+++ b/rpython/rtyper/lltypesystem/rffi.py
@@ -234,6 +234,7 @@ def llexternal(name, args, result, _callable=None,
                            }
             exec source.compile() in miniglobals
             call_external_function = miniglobals['call_external_function']
+            call_external_function._annspecialcase_ = 'specialize:ll'   # still specialize when there is no GIL.
             call_external_function = func_with_new_name(call_external_function,
                                                         'ccall_' + name)
             call_external_function = jit.dont_look_inside(
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
diff --git a/rpython/rtyper/lltypesystem/test/test_ll2ctypes.py b/rpython/rtyper/lltypesystem/test/test_ll2ctypes.py
index b1e1f73..b07816b 100644
--- a/rpython/rtyper/lltypesystem/test/test_ll2ctypes.py
+++ b/rpython/rtyper/lltypesystem/test/test_ll2ctypes.py
@@ -1467,9 +1467,6 @@ class TestPlatform(object):
 
     def test_prefix(self):
 
-        if not sys.platform.startswith('linux'):
-            py.test.skip("Not supported")
-
         from rpython.translator.platform import platform
 
         tmpdir = udir.join('lib_on_libppaths_prefix')
@@ -1482,7 +1479,7 @@ class TestPlatform(object):
         eci = ExternalCompilationInfo(include_dirs=[cdir])
         so = platform.compile([c_file], eci, standalone=False)
         sopath = py.path.local(so)
-        sopath.move(sopath.dirpath().join('libc_file.so'))
+        sopath.move(sopath.dirpath().join('libc_file.' + platform.so_ext))
         eci = ExternalCompilationInfo(
             libraries = ['c_file'],
             library_dirs = [str(so.dirpath())]
diff --git a/rpython/translator/platform/__init__.py b/rpython/translator/platform/__init__.py
index 051668b..d44ed79 100644
--- a/rpython/translator/platform/__init__.py
+++ b/rpython/translator/platform/__init__.py
@@ -212,7 +212,10 @@ class Platform(object):
 
     def _finish_linking(self, ofiles, eci, outputfilename, standalone):
         if outputfilename is None:
-            outputfilename = ofiles[0].purebasename
+            if standalone:
+                outputfilename = ofiles[0].purebasename
+            else:
+                outputfilename = self.so_prefixes[0] + ofiles[0].purebasename
         if ofiles:
             dirname = ofiles[0].dirpath()
         else:
diff --git a/rpython/translator/platform/darwin.py b/rpython/translator/platform/darwin.py
John Zhang's avatar
John Zhang committed
164
index 628c26a..3b816a8 100644
165
166
--- a/rpython/translator/platform/darwin.py
+++ b/rpython/translator/platform/darwin.py
John Zhang's avatar
John Zhang committed
167
@@ -30,6 +30,11 @@ class Darwin(posix.BasePosix):
168
169
170
             print 'in get_rpath_flags, rel_libdirs is not fixed up',rel_libdirs
         return self.rpath_flags
 
John Zhang's avatar
John Zhang committed
171
172
+    def _args_for_shared_exec(self, args, target):
+        return (list(self.shared_only)
173
+                + ['-dynamiclib', '-install_name', '@rpath/' + target, '-undefined', 'dynamic_lookup', '-flat_namespace']
John Zhang's avatar
John Zhang committed
174
+                + args)
John Zhang's avatar
John Zhang committed
175
+
John Zhang's avatar
John Zhang committed
176
177
178
     def _args_for_shared(self, args):
         return (list(self.shared_only)
                 + ['-dynamiclib', '-install_name', '@rpath/$(TARGET)', '-undefined', 'dynamic_lookup', '-flat_namespace']
179
diff --git a/rpython/translator/platform/posix.py b/rpython/translator/platform/posix.py
John Zhang's avatar
John Zhang committed
180
index cafc9b1..380db0d 100644
181
182
183
184
185
186
187
188
189
190
--- a/rpython/translator/platform/posix.py
+++ b/rpython/translator/platform/posix.py
@@ -15,6 +15,7 @@ class BasePosix(Platform):
 
     DEFAULT_CC = 'gcc'
     rpath_flags = ['-Wl,-rpath=\'$$ORIGIN/\'']
+    so_prefixes = ('lib', '')
 
     def __init__(self, cc=None):
         self.cc = cc or os.environ.get('CC', self.DEFAULT_CC)
John Zhang's avatar
John Zhang committed
191
@@ -53,7 +54,10 @@ class BasePosix(Platform):
192
193
194
195
         args = [str(ofile) for ofile in ofiles] + link_args
         args += ['-o', str(exe_name)]
         if not standalone:
-            args = self._args_for_shared(args)
John Zhang's avatar
John Zhang committed
196
197
198
+            if hasattr(self, '_args_for_shared_exec'):
+                args = self._args_for_shared_exec(args, exe_name.basename)
+            else:
John Zhang's avatar
John Zhang committed
199
+                args = self._args_for_shared(args)
200
201
202
         self._execute_c_compiler(cc, args, exe_name,
                                  cwd=str(exe_name.dirpath()))
         return exe_name
203
204
205
206
207
208
209
210
211
212
213
214
215
diff --git a/rpython/rtyper/lltypesystem/lltype.py b/rpython/rtyper/lltypesystem/lltype.py
index e6239b4324..64a3490e32 100644
--- a/rpython/rtyper/lltypesystem/lltype.py
+++ b/rpython/rtyper/lltypesystem/lltype.py
@@ -1623,7 +1623,7 @@ class _interior_ptr(_abstract_ptr):
         if ob is None:
             raise RuntimeError
         return InteriorPtr(typeOf(ob), self._T, self._offsets)
-##     _TYPE = property(_get_TYPE)
+    _TYPE = property(_get_TYPE)
 
     def _expose(self, offset, val):
         """XXX A nice docstring here"""