Skip to content

Commit

Permalink
[src/cheats/setup-io.pm] implement $*PID and make the source code eve…
Browse files Browse the repository at this point in the history
…n more cheaty. Parrot TT#1564 requests a less cheaty feature.
  • Loading branch information
Martin Berends committed Apr 20, 2010
1 parent 1f9b1dd commit b05155e
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions src/cheats/setup-io.pm
Expand Up @@ -20,21 +20,35 @@ INIT {
$P0 = IO.'new'('PIO'=>$P0)
set_hll_global ['PROCESS'], '$ERR', $P0

## Parrot doesn't give us the PID for now. Well, this file *is*
## in the cheats directory... :-)
$P0 = box 0
set_hll_global ['PROCESS'], '$PID', $P0

## set up $*OS, $*OSVER $*EXECUTABLE_NAME
.include 'sysinfo.pasm'
.local string info
info = sysinfo .SYSINFO_PARROT_OS
$P0 = new ['Str']
$P0 = info
set_hll_global ['PROCESS'], '$OS', $P0
info = sysinfo .SYSINFO_PARROT_OS_VERSION
$P0 = new ['Str']
$P0 = info
set_hll_global ['PROCESS'], '$OSVER', $P0
## do the OS last so that the PID workaround can use info
info = sysinfo .SYSINFO_PARROT_OS
$P0 = new ['Str']
$P0 = info
set_hll_global ['PROCESS'], '$OS', $P0

## Set up $*PID. Parrot doesn't give us the PID for now.
## idea: http://irclog.perlgeek.de/parrot/2010-04-19#i_2242900
## Well, this file *is* in the cheats directory... :-)
.local pmc library
.local string getpid_func
null library
getpid_func = 'getpid'
if info != 'MSWin32' goto setup_io_non_MSWin32
## Do it differently on Windows
library = loadlib 'kernel32'
getpid_func = 'GetCurrentProcessId'
setup_io_non_MSWin32:
$P0 = dlfunc library, getpid_func, 'i'
$I0 = $P0()
$P0 = box $I0
set_hll_global ['PROCESS'], '$PID', $P0
## Parrot request: http://trac.parrot.org/parrot/ticket/1564
}
}

0 comments on commit b05155e

Please sign in to comment.