Can I access symbolic constants from NB FFI?
Hi guys, Say I want to call to waitpid like this: waitpid(childID, &status, WNOHANG); How can I do since I don't have access to WNOHANG int value in order to send it via argument .... ??? Any idea? Thanks in advance, -- Mariano http://marianopeck.wordpress.com
Hello Mariano, WNOHANG is a constant is defined in sys/wait.h, after the compilation is not included in the object file. You will have to duplicate its value in the Smalltalk Code. It's value is 1, in linux is defined in bits/waitflags.h as #define WNOHANG 1 Cheers, Pablo On Tue, Dec 22, 2015 at 5:12 PM, Mariano Martinez Peck < marianopeck@gmail.com> wrote:
Hi guys,
Say I want to call to waitpid like this:
waitpid(childID, &status, WNOHANG);
How can I do since I don't have access to WNOHANG int value in order to send it via argument .... ???
Any idea?
Thanks in advance,
-- Mariano http://marianopeck.wordpress.com
-- Pablo Tesone. tesonep@gmail.com
On Tue, Dec 22, 2015 at 5:24 PM, tesonep@gmail.com <tesonep@gmail.com> wrote:
Hello Mariano, WNOHANG is a constant is defined in sys/wait.h, after the compilation is not included in the object file.
You will have to duplicate its value in the Smalltalk Code. It's value is 1, in linux is defined in bits/waitflags.h as
#define WNOHANG 1
mmmmmm but then I would need to take care about its different values in different OS right? I am reading for example this thread: https://groups.google.com/forum/#!topic/comp.lang.python/_5rCpfYR_ZE sunos 4.1.3 : #define WNOHANG 1 Solaris 2.4 : #define WNOHANG 0100 OSF1 2.0 : #define WNOHANG 0x1 Ultrix 4.4 : #define WNOHANG 1 irix 4.0.5C : #define WNOHANG 0x1 irix 5.2 : #define WNOHANG 0100 irix 6.0.1 : #define WNOHANG 0100 OK..the thread is from 1995... I thought the POSIX standard would standardize that... I am now checking at /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/sys/wait.h and it says: #define WNOHANG 0x00000001 But again..I wonder how portable is to stick to that... Ok...maybe I will need to go with a VM primitive as #primGetChildExitStatus: that way I can do the: self cCode: 'waitpid ( pidToHandle, &exitStatus, WNOHANG )' inSmalltalk: [ exitStatus := -1 ]. pd: que groso Pablito verte por aca!!!!
Cheers, Pablo
On Tue, Dec 22, 2015 at 5:12 PM, Mariano Martinez Peck < marianopeck@gmail.com> wrote:
Hi guys,
Say I want to call to waitpid like this:
waitpid(childID, &status, WNOHANG);
How can I do since I don't have access to WNOHANG int value in order to send it via argument .... ???
Any idea?
Thanks in advance,
-- Mariano http://marianopeck.wordpress.com
-- Pablo Tesone. tesonep@gmail.com
-- Mariano http://marianopeck.wordpress.com
Hi Mariano, it is supossed to be Posix, but Posix.1, it's another revision. Since Solaris 10, it is supposed to supports all extensions of Posix ( http://docs.oracle.com/cd/E19253-01/816-5175/standards-5/index.html) and Irix 6 (is discontinued, and is not Posix.1 compatible) Also I can say that the GHC (Haskell) implementation assumes the value 1 for the constant, you can check the source code in: https://hackage.haskell.org/package/posix-waitpid-0.1/docs/src/System-Posix-... I think is enough safe to have the 1 as a constant, if not you will have to generate a plugin for every platform. The other alternative is to read the constant value from the C Header, but is maybe an overkill. Chers, Pd: hace rato que estoy por aca, pero me cuesta responder, a veces va muy rapido y otras vuelan muy alto :). On Tue, Dec 22, 2015 at 5:36 PM, Mariano Martinez Peck < marianopeck@gmail.com> wrote:
On Tue, Dec 22, 2015 at 5:24 PM, tesonep@gmail.com <tesonep@gmail.com> wrote:
Hello Mariano, WNOHANG is a constant is defined in sys/wait.h, after the compilation is not included in the object file.
You will have to duplicate its value in the Smalltalk Code. It's value is 1, in linux is defined in bits/waitflags.h as
#define WNOHANG 1
mmmmmm but then I would need to take care about its different values in different OS right? I am reading for example this thread: https://groups.google.com/forum/#!topic/comp.lang.python/_5rCpfYR_ZE
sunos 4.1.3 : #define WNOHANG 1 Solaris 2.4 : #define WNOHANG 0100 OSF1 2.0 : #define WNOHANG 0x1 Ultrix 4.4 : #define WNOHANG 1 irix 4.0.5C : #define WNOHANG 0x1 irix 5.2 : #define WNOHANG 0100 irix 6.0.1 : #define WNOHANG 0100
OK..the thread is from 1995... I thought the POSIX standard would standardize that...
I am now checking at /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/sys/wait.h
and it says:
#define WNOHANG 0x00000001 But again..I wonder how portable is to stick to that...
Ok...maybe I will need to go with a VM primitive as #primGetChildExitStatus: that way I can do the:
self cCode: 'waitpid ( pidToHandle, &exitStatus, WNOHANG )' inSmalltalk: [ exitStatus := -1 ].
pd: que groso Pablito verte por aca!!!!
Cheers, Pablo
On Tue, Dec 22, 2015 at 5:12 PM, Mariano Martinez Peck < marianopeck@gmail.com> wrote:
Hi guys,
Say I want to call to waitpid like this:
waitpid(childID, &status, WNOHANG);
How can I do since I don't have access to WNOHANG int value in order to send it via argument .... ???
Any idea?
Thanks in advance,
-- Mariano http://marianopeck.wordpress.com
-- Pablo Tesone. tesonep@gmail.com
-- Mariano http://marianopeck.wordpress.com
-- Pablo Tesone. tesonep@gmail.com
On Tue, Dec 22, 2015 at 5:50 PM, tesonep@gmail.com <tesonep@gmail.com> wrote:
Hi Mariano, it is supossed to be Posix, but Posix.1, it's another revision.
Since Solaris 10, it is supposed to supports all extensions of Posix ( http://docs.oracle.com/cd/E19253-01/816-5175/standards-5/index.html) and Irix 6 (is discontinued, and is not Posix.1 compatible)
Also I can say that the GHC (Haskell) implementation assumes the value 1 for the constant, you can check the source code in:
https://hackage.haskell.org/package/posix-waitpid-0.1/docs/src/System-Posix-...
I think is enough safe to have the 1 as a constant, if not you will have to generate a plugin for every platform.
Thanks Pablito. I assumed 1 for now and in fact it did work for OSX at least :)
The other alternative is to read the constant value from the C Header, but is maybe an overkill.
Yes, I thought the same...but I would need the sources...
Chers,
Pd: hace rato que estoy por aca, pero me cuesta responder, a veces va muy rapido y otras vuelan muy alto :).
jajajajaj groso
On Tue, Dec 22, 2015 at 5:36 PM, Mariano Martinez Peck < marianopeck@gmail.com> wrote:
On Tue, Dec 22, 2015 at 5:24 PM, tesonep@gmail.com <tesonep@gmail.com> wrote:
Hello Mariano, WNOHANG is a constant is defined in sys/wait.h, after the compilation is not included in the object file.
You will have to duplicate its value in the Smalltalk Code. It's value is 1, in linux is defined in bits/waitflags.h as
#define WNOHANG 1
mmmmmm but then I would need to take care about its different values in different OS right? I am reading for example this thread: https://groups.google.com/forum/#!topic/comp.lang.python/_5rCpfYR_ZE
sunos 4.1.3 : #define WNOHANG 1 Solaris 2.4 : #define WNOHANG 0100 OSF1 2.0 : #define WNOHANG 0x1 Ultrix 4.4 : #define WNOHANG 1 irix 4.0.5C : #define WNOHANG 0x1 irix 5.2 : #define WNOHANG 0100 irix 6.0.1 : #define WNOHANG 0100
OK..the thread is from 1995... I thought the POSIX standard would standardize that...
I am now checking at /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/sys/wait.h
and it says:
#define WNOHANG 0x00000001 But again..I wonder how portable is to stick to that...
Ok...maybe I will need to go with a VM primitive as #primGetChildExitStatus: that way I can do the:
self cCode: 'waitpid ( pidToHandle, &exitStatus, WNOHANG )' inSmalltalk: [ exitStatus := -1 ].
pd: que groso Pablito verte por aca!!!!
Cheers, Pablo
On Tue, Dec 22, 2015 at 5:12 PM, Mariano Martinez Peck < marianopeck@gmail.com> wrote:
Hi guys,
Say I want to call to waitpid like this:
waitpid(childID, &status, WNOHANG);
How can I do since I don't have access to WNOHANG int value in order to send it via argument .... ???
Any idea?
Thanks in advance,
-- Mariano http://marianopeck.wordpress.com
-- Pablo Tesone. tesonep@gmail.com
-- Mariano http://marianopeck.wordpress.com
-- Pablo Tesone. tesonep@gmail.com
-- Mariano http://marianopeck.wordpress.com
Hi Mariano,
On Dec 22, 2015, at 8:36 PM, Mariano Martinez Peck <marianopeck@gmail.com> wrote:
On Tue, Dec 22, 2015 at 5:24 PM, tesonep@gmail.com <tesonep@gmail.com> wrote: Hello Mariano, WNOHANG is a constant is defined in sys/wait.h, after the compilation is not included in the object file.
You will have to duplicate its value in the Smalltalk Code. It's value is 1, in linux is defined in bits/waitflags.h as
#define WNOHANG 1
mmmmmm but then I would need to take care about its different values in different OS right? I am reading for example this thread: https://groups.google.com/forum/#!topic/comp.lang.python/_5rCpfYR_ZE
sunos 4.1.3 : #define WNOHANG 1 Solaris 2.4 : #define WNOHANG 0100 OSF1 2.0 : #define WNOHANG 0x1 Ultrix 4.4 : #define WNOHANG 1 irix 4.0.5C : #define WNOHANG 0x1 irix 5.2 : #define WNOHANG 0100 irix 6.0.1 : #define WNOHANG 0100
Exactly. I've discussed this before. Please read http://lists.pharo.org/pipermail/pharo-dev_lists.pharo.org/2012-May/064382.h...
OK..the thread is from 1995... I thought the POSIX standard would standardize that...
I am now checking at /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/sys/wait.h
and it says: #define WNOHANG 0x00000001
But again..I wonder how portable is to stick to that...
Ok...maybe I will need to go with a VM primitive as #primGetChildExitStatus: that way I can do the:
self cCode: 'waitpid ( pidToHandle, &exitStatus, WNOHANG )' inSmalltalk: [ exitStatus := -1 ].
pd: que groso Pablito verte por aca!!!!
Cheers, Pablo
On Tue, Dec 22, 2015 at 5:12 PM, Mariano Martinez Peck <marianopeck@gmail.com> wrote: Hi guys,
Say I want to call to waitpid like this:
waitpid(childID, &status, WNOHANG);
How can I do since I don't have access to WNOHANG int value in order to send it via argument .... ???
Any idea?
Thanks in advance,
Mariano http://marianopeck.wordpress.com
Pablo Tesone. tesonep@gmail.com
Mariano http://marianopeck.wordpress.com
_,,,^..^,,,_ (phone)
as Pablo says, you ask too much :) basically, thatâs a macro who is replaced by the C preprocessor, even before compiling it. So no, you cannot access it because it does not exist :) the âofficialâ recommendation for this is: Do a SharedPool. Also there is TalkFFI (look for it in sthub, my internet connection here is too slow and I cannot enter it). I do not think it will work out of the box but basically, it imports header files :) cheers, Esteban
On 22 Dec 2015, at 20:24, tesonep@gmail.com wrote:
Hello Mariano, WNOHANG is a constant is defined in sys/wait.h, after the compilation is not included in the object file.
You will have to duplicate its value in the Smalltalk Code. It's value is 1, in linux is defined in bits/waitflags.h as
#define WNOHANG 1
Cheers, Pablo
On Tue, Dec 22, 2015 at 5:12 PM, Mariano Martinez Peck <marianopeck@gmail.com <mailto:marianopeck@gmail.com>> wrote: Hi guys,
Say I want to call to waitpid like this:
waitpid(childID, &status, WNOHANG);
How can I do since I don't have access to WNOHANG int value in order to send it via argument .... ???
Any idea?
Thanks in advance,
-- Mariano http://marianopeck.wordpress.com <http://marianopeck.wordpress.com/>
-- Pablo Tesone. tesonep@gmail.com <mailto:tesonep@gmail.com>
Maybe this: https://github.com/ronsaldo/swig/ On Tue, Dec 22, 2015 at 9:24 PM, tesonep@gmail.com <tesonep@gmail.com> wrote:
Hello Mariano, WNOHANG is a constant is defined in sys/wait.h, after the compilation is not included in the object file.
You will have to duplicate its value in the Smalltalk Code. It's value is 1, in linux is defined in bits/waitflags.h as
#define WNOHANG 1
Cheers, Pablo
On Tue, Dec 22, 2015 at 5:12 PM, Mariano Martinez Peck < marianopeck@gmail.com> wrote:
Hi guys,
Say I want to call to waitpid like this:
waitpid(childID, &status, WNOHANG);
How can I do since I don't have access to WNOHANG int value in order to send it via argument .... ???
Any idea?
Thanks in advance,
-- Mariano http://marianopeck.wordpress.com
-- Pablo Tesone. tesonep@gmail.com
I was going to point out SharedPool and defining it as a poolDictionary in the class definition, but you already know that, right? Is what you are pointing out is that once you have all of that setup, that NB doesn't allow you to use it by argument (but only by value)? The former I might help; the later is beyond me. -cbc On Tue, Dec 22, 2015 at 12:12 PM, Mariano Martinez Peck < marianopeck@gmail.com> wrote:
Hi guys,
Say I want to call to waitpid like this:
waitpid(childID, &status, WNOHANG);
How can I do since I don't have access to WNOHANG int value in order to send it via argument .... ???
Any idea?
Thanks in advance,
-- Mariano http://marianopeck.wordpress.com
participants (6)
-
Chris Cunningham -
Eliot Miranda -
Esteban Lorenzano -
Mariano Martinez Peck -
phil@highoctane.be -
tesonep@gmail.com