ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/BDB/BDB.xs
(Generate patch)

Comparing BDB/BDB.xs (file contents):
Revision 1.70 by root, Wed Jul 15 14:53:52 2009 UTC vs.
Revision 1.73 by root, Tue Dec 8 17:09:06 2009 UTC

58#endif 58#endif
59 59
60typedef char *bdb_filename; 60typedef char *bdb_filename;
61 61
62static SV *prepare_cb; 62static SV *prepare_cb;
63
64static HV
65 *bdb_stash,
66 *bdb_env_stash,
67 *bdb_txn_stash,
68 *bdb_cursor_stash,
69 *bdb_db_stash,
70 *bdb_sequence_stash;
63 71
64#if DB_VERSION_MINOR >= 6 72#if DB_VERSION_MINOR >= 6
65# define c_close close 73# define c_close close
66# define c_count count 74# define c_count count
67# define c_del del 75# define c_del del
1018 (void)0; 1026 (void)0;
1019 1027
1020#define REQ_SEND \ 1028#define REQ_SEND \
1021 req_send (req) 1029 req_send (req)
1022 1030
1023#define SvPTR(var, arg, type, class, nullok) \ 1031#define SvPTR(var, arg, type, stash, class, nullok) \
1024 if (!SvOK (arg)) \ 1032 if (!SvOK (arg)) \
1025 { \ 1033 { \
1026 if (nullok != 1) \ 1034 if (nullok != 1) \
1027 croak (# var " must be a " # class " object, not undef"); \ 1035 croak (# var " must be a " # class " object, not undef"); \
1028 \ 1036 \
1029 (var) = 0; \ 1037 (var) = 0; \
1030 } \ 1038 } \
1031 else if (sv_derived_from ((arg), # class)) \ 1039 else if (SvSTASH (SvRV (arg)) == stash || sv_derived_from ((arg), # class)) \
1032 { \ 1040 { \
1033 IV tmp = SvIV ((SV*) SvRV (arg)); \ 1041 IV tmp = SvIV ((SV*) SvRV (arg)); \
1034 (var) = INT2PTR (type, tmp); \ 1042 (var) = INT2PTR (type, tmp); \
1035 if (!var && nullok != 2) \ 1043 if (!var && nullok != 2) \
1036 croak (# var " is not a valid " # class " object anymore"); \ 1044 croak (# var " is not a valid " # class " object anymore"); \
1039 croak (# var " is not of type " # class); 1047 croak (# var " is not of type " # class);
1040 1048
1041#define ARG_MUTABLE(name) \ 1049#define ARG_MUTABLE(name) \
1042 if (SvREADONLY (name)) \ 1050 if (SvREADONLY (name)) \
1043 croak ("argument " #name " is read-only/constant, but the request requires it to be mutable"); 1051 croak ("argument " #name " is read-only/constant, but the request requires it to be mutable");
1052
1053static SV *
1054newSVptr (void *ptr, HV *stash)
1055{
1056 SV *rv = NEWSV (0, 0);
1057 sv_upgrade (rv, SVt_PVMG);
1058 sv_setiv (rv, PTR2IV (ptr));
1059
1060 return sv_bless (newRV_noinc (rv), stash);
1061}
1044 1062
1045static void 1063static void
1046ptr_nuke (SV *sv) 1064ptr_nuke (SV *sv)
1047{ 1065{
1048 assert (SvROK (sv)); 1066 assert (SvROK (sv));
1170 1188
1171PROTOTYPES: ENABLE 1189PROTOTYPES: ENABLE
1172 1190
1173BOOT: 1191BOOT:
1174{ 1192{
1175 HV *stash = gv_stashpv ("BDB", 1);
1176
1177 static const struct { 1193 static const struct {
1178 const char *name; 1194 const char *name;
1179 IV iv; 1195 IV iv;
1180 } *civ, const_iv[] = { 1196 } *civ, const_iv[] = {
1181#define const_iv(name) { # name, (IV)DB_ ## name }, 1197#define const_iv(name) { # name, (IV)DB_ ## name },
1210 const_iv (TXN_NOT_DURABLE) 1226 const_iv (TXN_NOT_DURABLE)
1211 const_iv (TXN_WRITE_NOSYNC) 1227 const_iv (TXN_WRITE_NOSYNC)
1212 const_iv (WRITECURSOR) 1228 const_iv (WRITECURSOR)
1213 const_iv (YIELDCPU) 1229 const_iv (YIELDCPU)
1214 const_iv (ENCRYPT_AES) 1230 const_iv (ENCRYPT_AES)
1231#if DB_VERSION_MINOR < 8
1215 const_iv (XA_CREATE) 1232 const_iv (XA_CREATE)
1233#endif
1216 const_iv (BTREE) 1234 const_iv (BTREE)
1217 const_iv (HASH) 1235 const_iv (HASH)
1218 const_iv (QUEUE) 1236 const_iv (QUEUE)
1219 const_iv (RECNO) 1237 const_iv (RECNO)
1220 const_iv (UNKNOWN) 1238 const_iv (UNKNOWN)
1284 const_iv (LOCK_OLDEST) 1302 const_iv (LOCK_OLDEST)
1285 const_iv (LOCK_RANDOM) 1303 const_iv (LOCK_RANDOM)
1286 const_iv (LOCK_YOUNGEST) 1304 const_iv (LOCK_YOUNGEST)
1287 1305
1288 const_iv (DONOTINDEX) 1306 const_iv (DONOTINDEX)
1289 const_iv (KEYEMPTY ) 1307 const_iv (KEYEMPTY)
1290 const_iv (KEYEXIST ) 1308 const_iv (KEYEXIST)
1291 const_iv (LOCK_DEADLOCK) 1309 const_iv (LOCK_DEADLOCK)
1292 const_iv (LOCK_NOTGRANTED) 1310 const_iv (LOCK_NOTGRANTED)
1293 const_iv (NOSERVER) 1311 const_iv (NOSERVER)
1294 const_iv (NOSERVER_HOME) 1312 const_iv (NOSERVER_HOME)
1295 const_iv (NOSERVER_ID) 1313 const_iv (NOSERVER_ID)
1324 const_iv (VERB_WAITSFOR) 1342 const_iv (VERB_WAITSFOR)
1325 1343
1326 const_iv (VERSION_MAJOR) 1344 const_iv (VERSION_MAJOR)
1327 const_iv (VERSION_MINOR) 1345 const_iv (VERSION_MINOR)
1328 const_iv (VERSION_PATCH) 1346 const_iv (VERSION_PATCH)
1347 const_iv (LOGVERSION)
1348 const_iv (LOGOLDVER)
1329#if DB_VERSION_MINOR >= 3 1349#if DB_VERSION_MINOR >= 3
1330 const_iv (INORDER) 1350 const_iv (INORDER)
1331 const_iv (LOCK_MAXWRITE) 1351 const_iv (LOCK_MAXWRITE)
1332 const_iv (SEQ_DEC) 1352 const_iv (SEQ_DEC)
1333 const_iv (SEQ_INC) 1353 const_iv (SEQ_INC)
1374 const_iv (LOG_AUTOREMOVE) 1394 const_iv (LOG_AUTOREMOVE)
1375# if DB_VERSION_MINOR >= 3 1395# if DB_VERSION_MINOR >= 3
1376 const_iv (DSYNC_LOG) 1396 const_iv (DSYNC_LOG)
1377 const_iv (LOG_INMEMORY) 1397 const_iv (LOG_INMEMORY)
1378# endif 1398# endif
1399#if DB_VERSION_MINOR >= 8
1400 const_iv (LOGVERSION_LATCHING)
1401#endif
1379#endif 1402#endif
1380 }; 1403 };
1381 1404
1405 bdb_stash = gv_stashpv ("BDB" , 1);
1406 bdb_env_stash = gv_stashpv ("BDB::Env" , 1);
1407 bdb_txn_stash = gv_stashpv ("BDB::Txn" , 1);
1408 bdb_cursor_stash = gv_stashpv ("BDB::Cursor" , 1);
1409 bdb_db_stash = gv_stashpv ("BDB::Db" , 1);
1410 bdb_sequence_stash = gv_stashpv ("BDB::Sequence", 1);
1411
1382 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 1412 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
1383 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 1413 newCONSTSUB (bdb_stash, (char *)civ->name, newSViv (civ->iv));
1384 1414
1385 prepare_cb = &PL_sv_undef; 1415 prepare_cb = &PL_sv_undef;
1386 1416
1387 { 1417 {
1388 /* we currently only allow version, minor-version and patchlevel to go up to 255 */ 1418 /* we currently only allow version, minor-version and patchlevel to go up to 255 */
1389 char vstring[3] = { DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH }; 1419 char vstring[3] = { DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH };
1390 1420
1391 newCONSTSUB (stash, "VERSION_v", newSVpvn (vstring, 3)); 1421 newCONSTSUB (bdb_stash, "VERSION_v", newSVpvn (vstring, 3));
1392 } 1422 }
1393 1423
1394 newCONSTSUB (stash, "VERSION_STRING", newSVpv (DB_VERSION_STRING, 0)); 1424 newCONSTSUB (bdb_stash, "VERSION_STRING", newSVpv (DB_VERSION_STRING, 0));
1395 1425
1396 create_respipe (); 1426 create_respipe ();
1397 1427
1398 X_THREAD_ATFORK (atfork_prepare, atfork_parent, atfork_child); 1428 X_THREAD_ATFORK (atfork_prepare, atfork_parent, atfork_child);
1399 patch_errno (); 1429 patch_errno ();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines