Re: Submission: Inline_C
| From: | Stig S. Bakken | Date: | Sat, 28 Sep 2002 09:07:38 +0000 |
| Subject: | Re: Submission: Inline_C | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-9629@lists.php.net to get a copy of this message | ||
Wow. Awe. +1!
- Stig
On Thu, 2002-09-26 at 05:03, George Schlossnagle wrote:
> Inline_C is a class that allows you to write critical function code in
> C, from within userland php. Basically it provides 'glue' and a build
> system for taking PHP_FUNCTION definitions, and wrapping the build and
> dl() process. The interface is like:
>
> <?
>
> require_once("Inline_C.php");
> $function1 = <<<EOF
> PHP_FUNCTION(times)
> {
> long i,j;
> if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll",
> &i,&j) == FAILURE) {
> WRONG_PARAM_COUNT;
> }
> RETURN_LONG(i*j);
> }
>
> EOF;
>
> $inline = new Inline_C;
> $inline->add_code($function1);
> // To link against libfoo
> //$inline->library("foo","/usr/local/lib");
> $inline->compile();
> for($i=0;$i<10;$i++) {
> for($j=0; $j<10; $j++) {
> print "$i * $j = ".times($i,$j)."\n";
> }
> }
>
> ?>
>
> Code is available at
> http://www.omniti.com/~george/Inline.tar.gz. Basic
> testing has been done on 4.2.3 and HEAD.
>
>
>
> // George Schlossnagle
> // Principal Consultant
> // OmniTI, Inc http://www.omniti.com
> // (c) 240.460.5234 (e) george@omniti.com
> // 1024D/1100A5A0 1370 F70A 9365 96C9 2F5E 56C2 B2B9 262F 1100 A5A0
>
>
> --
> PEAR Development Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--
Stig Sæther Bakken, Fast Search & Transfer ASA, Trondheim, Norway
http://pear.php.net/wishlist.php/ssb