translator/c/test/test_lltyped.py::TestLowLevelType::()::test_structarray_nolength
self = <rpython.translator.c.test.test_lltyped.TestLowLevelType object at 0x000000000f80adb0>
def test_structarray_nolength(self):
S = Struct('S', ('x', Signed))
A = Array(S, hints={'nolength': True})
a1 = malloc(A, 3, immortal=True)
a1[0].x = 30
a1[1].x = 300
a1[2].x = 3000
a1dummy = malloc(A, 2, immortal=True)
def f(n):
if n & 1:
src = a1dummy
else:
src = a1
a2 = malloc(A, n, flavor='raw')
for i in range(n):
a2[i].x = src[i % 3].x + i
res = a2[n // 2].x
free(a2, flavor='raw')
return res
> fn = self.getcompiled(f, [int])
translator/c/test/test_lltyped.py:379:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
translator/c/test/test_lltyped.py:10: in getcompiled
return compile(func, argtypes, backendopt=False)
translator/c/test/test_genc.py:124: in compile
t.compile_c()
translator/interactive.py:123: in compile_c
self.driver.compile_c()
translator/driver.py:108: in proc
return self.proceed(backend_goal)
translator/driver.py:569: in proceed
result = self._execute(goals, task_skip = self._maybe_skip())
translator/tool/taskengine.py:114: in _execute
res = self._do(goal, taskcallable, *args, **kwds)
translator/driver.py:278: in _do
res = func()
translator/driver.py:455: in task_source_c
exe_name=exe_name)
translator/c/genc.py:214: in generate_source
self.eci, defines=defines, split=self.split)
translator/c/genc.py:879: in gen_source
sg.gen_readable_parts_of_source(f)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <rpython.translator.c.genc.SourceGenerator instance at 0x0000000010b98620>
f = <open file '/tmp/pytest/usession-main-3869/testing_21/testing_21.c', mode 'w' at 0x000000000fe0f720>
def gen_readable_parts_of_source(self, f):
split_criteria_big = SPLIT_CRITERIA
if py.std.sys.platform != "win32":
if self.database.gcpolicy.need_no_typeptr():
pass # XXX gcc uses toooooons of memory???
else:
split_criteria_big = SPLIT_CRITERIA * 4
#
# All declarations
#
with self.write_on_included_file(f, 'structdef.h') as fi:
gen_structdef(fi, self.database)
with self.write_on_included_file(f, 'forwarddecl.h') as fi:
gen_forwarddecl(fi, self.database)
with self.write_on_included_file(f, 'preimpl.h') as fi:
gen_preimpl(fi, self.database)
#
# Implementation of functions and global structures and arrays
#
print(file=f)
print('/***********************************************************/', file=f)
print('/*** Implementations ***/', file=f)
print(file=f)
print('#define PYPY_FILE_NAME "%s"' % os.path.basename(f.name), file=f)
print('#include "src/g_include.h"', file=f)
if self.database.reverse_debugger:
print('#include "revdb_def.h"', file=f)
print(file=f)
nextralines = 11 + 1
for name, nodeiter in self.splitnodesimpl('nonfuncnodes.c',
self.othernodes,
nextralines, 1):
with self.write_on_maybe_separate_source(f, name) as fc:
if fc is not f:
print('/***********************************************************/', file=fc)
print('/*** Non-function Implementations ***/', file=fc)
print(file=fc)
print('#include "singleheader.h"', file=fc)
print('#include "src/g_include.h"', file=fc)
print(file=fc)
print(MARKER, file=fc)
for node, impl in nodeiter:
print('\n'.join(impl), file=fc)
print(MARKER, file=fc)
print('/***********************************************************/', file=fc)
nextralines = 12
for name, nodeiter in self.splitnodesimpl('implement.c',
self.funcnodes,
nextralines, 1,
split_criteria_big):
with self.write_on_maybe_separate_source(f, name) as fc:
if fc is not f:
print('/***********************************************************/', file=fc)
print('/*** Implementations * (somefailed=True in translator/c/test/test_lltyped.py)
builder: rpython-linux-aarch64 build #572+
test: translator/c/test/test_lltyped.py::TestLowLevelType::()::test_structarray_nolength