Re: [pypy-dev] Request to make `makedev`, `major` and `minor` macros

2016-12-06 Thread John Zhang
Thanks Armin!
I will keep my eyes open for other cases and let you know. :)

Cheers,
John Zhang
--
John Zhang
Research Assistant
Programming Languages, Design & Implementation Division
Computer Systems Group
ANU College of Engineering & Computer Science
108 North Rd
The Australian National University
Acton ACT 2601
john.zh...@anu.edu.au





On 6 Dec. 2016, at 20:58, Armin Rigo 
> wrote:

Hi John,

On 6 December 2016 at 08:20, John Zhang 
> wrote:
I would like to request making the definitions of
`rpython.rlib.rposix.c_makedev/c_major/c_minor` include explicit macro
functions, i.e., passing `macro=_MACRO_ON_POSIX` to the `rffi.llexternal`
function.

Checked in 08ec669ddab9.  Note that the 'macro' keyword is used inside
PyPy for a single purpose: to teach the JIT that it cannot directly
write a call to the macro.  Instead it writes a call to the wrapper
generated by rffi.py.  In this case this problem was fixed by marking
the functions like "def makedev(..):" with "@jit.dont_look_inside",
which is equivalent from the point of view of the JIT.  But I have now
removed these dont_look_inside and instead added "macro=True"
arguments, as it is more natural---and also indeed more useful to
non-standard backends.  Feel free to ask if you find other similar
cases!


A bientôt,

Armin.

___
pypy-dev mailing list
pypy-dev@python.org
https://mail.python.org/mailman/listinfo/pypy-dev


Re: [pypy-dev] Request to make `makedev`, `major` and `minor` macros

2016-12-06 Thread Armin Rigo
Hi John,

On 6 December 2016 at 08:20, John Zhang  wrote:
> I would like to request making the definitions of
> `rpython.rlib.rposix.c_makedev/c_major/c_minor` include explicit macro
> functions, i.e., passing `macro=_MACRO_ON_POSIX` to the `rffi.llexternal`
> function.

Checked in 08ec669ddab9.  Note that the 'macro' keyword is used inside
PyPy for a single purpose: to teach the JIT that it cannot directly
write a call to the macro.  Instead it writes a call to the wrapper
generated by rffi.py.  In this case this problem was fixed by marking
the functions like "def makedev(..):" with "@jit.dont_look_inside",
which is equivalent from the point of view of the JIT.  But I have now
removed these dont_look_inside and instead added "macro=True"
arguments, as it is more natural---and also indeed more useful to
non-standard backends.  Feel free to ask if you find other similar
cases!


A bientôt,

Armin.
___
pypy-dev mailing list
pypy-dev@python.org
https://mail.python.org/mailman/listinfo/pypy-dev


Re: [pypy-dev] Request to make `makedev`, `major` and `minor` macros

2016-12-06 Thread John Zhang
Forgot the attachment, sorry!

--
John Zhang
Research Assistant
Programming Languages, Design & Implementation Division
Computer Systems Group
ANU College of Engineering & Computer Science
108 North Rd
The Australian National University
Acton ACT 2601
john.zh...@anu.edu.au





On 6 Dec. 2016, at 18:18, John Zhang 
> wrote:

Hi all (Armin?),
I would like to request making the definitions of 
`rpython.rlib.rposix.c_makedev/c_major/c_minor` include explicit macro 
functions, i.e., passing `macro=_MACRO_ON_POSIX` to the `rffi.llexternal` 
function.
These functions are macros on both Linux and macOS (the comment above the code 
acknowledges this fact). Without explicitly saying they are macros, these 
functions can’t be called using rffi. The attached patch also adds another test 
in test_rposix.py, which exposes the problem.
The reason that they don’t currently affect the existing PyPy is because PyPy 
compiles to C anyway. But I’m working on another backend (Mu Micro VM), so I’d 
appreciate the ability to call these external functions from shared libraries 
directly. I think the macro wrapper generation is a great idea and its existing 
work is something that I can try to incorporate in my backend.
I would appreciate someone can patch the change (it’s a bit tricky on my end 
using git-remote-hg. :P ).
Regards,
John Zhang
--
John Zhang
Research Assistant
Programming Languages, Design & Implementation Division
Computer Systems Group
ANU College of Engineering & Computer Science
108 North Rd
The Australian National University
Acton ACT 2601
john.zh...@anu.edu.au








makedev_macro.patch
Description: makedev_macro.patch
___
pypy-dev mailing list
pypy-dev@python.org
https://mail.python.org/mailman/listinfo/pypy-dev


[pypy-dev] Request to make `makedev`, `major` and `minor` macros

2016-12-06 Thread John Zhang
Hi all (Armin?),
I would like to request making the definitions of 
`rpython.rlib.rposix.c_makedev/c_major/c_minor` include explicit macro 
functions, i.e., passing `macro=_MACRO_ON_POSIX` to the `rffi.llexternal` 
function.
These functions are macros on both Linux and macOS (the comment above the code 
acknowledges this fact). Without explicitly saying they are macros, these 
functions can’t be called using rffi. The attached patch also adds another test 
in test_rposix.py, which exposes the problem.
The reason that they don’t currently affect the existing PyPy is because PyPy 
compiles to C anyway. But I’m working on another backend (Mu Micro VM), so I’d 
appreciate the ability to call these external functions from shared libraries 
directly. I think the macro wrapper generation is a great idea and its existing 
work is something that I can try to incorporate in my backend.
I would appreciate someone can patch the change (it’s a bit tricky on my end 
using git-remote-hg. :P ).
Regards,
John Zhang
--
John Zhang
Research Assistant
Programming Languages, Design & Implementation Division
Computer Systems Group
ANU College of Engineering & Computer Science
108 North Rd
The Australian National University
Acton ACT 2601
john.zh...@anu.edu.au





___
pypy-dev mailing list
pypy-dev@python.org
https://mail.python.org/mailman/listinfo/pypy-dev