Subject: | MongoDB 0.26 and Perl 5.8.7, Newx(z) with 3 args |
Hello and thank you for MongoDB 0.26,
I'm running Perl 5.8.7 (on x86_64-linux)
Running make produces:
cc -c -I. -fno-strict-aliasing -pipe -I/usr/local/include
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2
-DVERSION=\"0.26\" -DXS_VERSION=\"0.26\" -o xs/Connection.o -fpic
"-I<removed>perl-5.8.7/lib/5.8.7/x86_64-linux/CORE" xs/Connection.c
xs/Connection.xs: In function `XS_MongoDB__Connection_connect':
xs/Connection.xs:52: error: syntax error before "mongo_link"
xs/Connection.xs:63: error: syntax error before "char"
xs/Connection.xs:68: error: syntax error before "char"
xs/Connection.xs:75: error: syntax error before "char"
xs/Connection.xs: In function `XS_MongoDB__Connection__insert':
xs/Connection.xs:118: error: syntax error before "char"
xs/Connection.xs: In function `XS_MongoDB__Connection__remove':
xs/Connection.xs:147: error: syntax error before "char"
xs/Connection.xs: In function `XS_MongoDB__Connection__update':
xs/Connection.xs:170: error: syntax error before "char"
make: *** [xs/Connection.o] Error 1
Line 52 of xs/Connection.xs is:
Newx(link, 1, mongo_link);
I'm using version 2.21 of ExtUtils::ParseXS
Line 122 of xs/Connection.c is:
Newx(link, 1, mongo_link);
According to http://perldoc.perl.org/perlapi.html In 5.9.3, Newx() and
friends replace the older New() API, and drops the first parameter, x, a
debug aid which allowed callers to identify themselves. Looking at
perlapi for 5.8.7
(http://search.cpan.org/~nwclark/perl-5.8.7/pod/perlapi.pod) I see:
New
The XSUB-writer's interface to the C malloc function.
void New(int id, void* ptr, int nitems, type)
No mention of Newx, so I changed line 52 of xs/Connection.xs to:
New(0, link, 1, mongo_link);
and this seemed to work, I also made the following changes:
MongoDB-0.26/mongo_link.c
245c245
Show quoted text
> New(0, cursor->buf.start, cursor->header.length, char);
---
< Newx(cursor->buf.start, cursor->header.length, char);
MongoDB-0.26/mongo_link.h
88c88
Show quoted text> New(0, buf.start, size, char); \
---
< Newx(buf.start, size, char); \
MongoDB-0.26/xs/Connection.xs
52c52
Show quoted text> New(0, link, 1, mongo_link);
---
< Newx(link, 1, mongo_link);
63c63
Show quoted text> Newz(0, link->server.pair.left_host, llen+1, char);
---
< Newxz(link->server.pair.left_host, llen+1, char);
68c68
Show quoted text> Newz(0, link->server.pair.right_host, rlen+1, char);
---
< Newxz(link->server.pair.right_host, rlen+1, char);
75c75
Show quoted text> Newz(0, link->server.single.host, len+1, char);
---
< Newxz(link->server.single.host, len+1, char);
MongoDB-0.26/xs/Cursor.xs
115,116c115
Show quoted text> New(0, buf.start, size, char);
---
< Newx(buf.start, size, char);
190c189
Show quoted text> New(0, cursor, 1, mongo_cursor);
---
< Newx(cursor, 1, mongo_cursor);
make now completes without error and make test when running against the
stable version of mongod just fails 4 tests in t/collection.t (I have
not looked into these failures yet)
not ok 74
# Failed test at t/collection.t line 256.
# got: '1'
# expected: '2'
ok 75
not ok 76
# Failed test at t/collection.t line 263.
# got: undef
# expected: '4'
not ok 77
# Failed test at t/collection.t line 267.
# got: '1'
# expected: '2'
ok 78
not ok 79
# Failed test at t/collection.t line 274.
# got: undef
# expected: '4'
I've not tested the change with any other version of perl.
Hope this is of some use.
Cheers,
Peter (Stig) Edwards