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

Comparing BDB/BDB.xs (file contents):
Revision 1.33 by root, Sun Mar 30 04:57:55 2008 UTC vs.
Revision 1.36 by root, Sun Mar 30 08:01:58 2008 UTC

60# define c_dup dup 60# define c_dup dup
61# define c_get get 61# define c_get get
62# define c_pget pget 62# define c_pget pget
63# define c_put put 63# define c_put put
64#endif 64#endif
65
66static char *
67get_bdb_filename (SV *sv)
68{
69 if (!SvOK (sv))
70 return 0;
71
72#if _WIN32
73 /* win32 madness + win32 perl absolutely brokenness make for horrible hacks */
74 {
75 STRLEN len;
76 char *src = SvPVbyte (sv, len);
77 SV *t1 = sv_newmortal ();
78 SV *t2 = sv_newmortal ();
79
80 sv_upgrade (t1, SVt_PV); SvPOK_only (t1); SvGROW (t1, len * 16 + 1);
81 sv_upgrade (t2, SVt_PV); SvPOK_only (t2); SvGROW (t2, len * 16 + 1);
82
83 len = MultiByteToWideChar (CP_ACP, 0, src, len, (WCHAR *)SvPVX (t1), SvLEN (t1) / sizeof (WCHAR));
84 len = WideCharToMultiByte (CP_UTF8, 0, (WCHAR *)SvPVX (t1), len, SvPVX (t2), SvLEN (t2), 0, 0);
85 SvPOK_only (t2);
86 SvPVX (t2)[len] = 0;
87 SvCUR_set (t2, len);
88
89 return SvPVX (t2);
90 }
91#else
92 return SvPVbyte_nolen (sv);
93#endif
94}
65 95
66static void 96static void
67debug_errcall (const DB_ENV *dbenv, const char *errpfx, const char *msg) 97debug_errcall (const DB_ENV *dbenv, const char *errpfx, const char *msg)
68{ 98{
69 printf ("err[%s]\n", msg); 99 printf ("err[%s]\n", msg);
205static mutex_t reqlock = X_MUTEX_INIT; 235static mutex_t reqlock = X_MUTEX_INIT;
206static cond_t reqwait = X_COND_INIT; 236static cond_t reqwait = X_COND_INIT;
207 237
208#if WORDACCESS_UNSAFE 238#if WORDACCESS_UNSAFE
209 239
210static unsigned int get_nready () 240static unsigned int get_nready (void)
211{ 241{
212 unsigned int retval; 242 unsigned int retval;
213 243
214 X_LOCK (reqlock); 244 X_LOCK (reqlock);
215 retval = nready; 245 retval = nready;
216 X_UNLOCK (reqlock); 246 X_UNLOCK (reqlock);
217 247
218 return retval; 248 return retval;
219} 249}
220 250
221static unsigned int get_npending () 251static unsigned int get_npending (void)
222{ 252{
223 unsigned int retval; 253 unsigned int retval;
224 254
225 X_LOCK (reslock); 255 X_LOCK (reslock);
226 retval = npending; 256 retval = npending;
227 X_UNLOCK (reslock); 257 X_UNLOCK (reslock);
228 258
229 return retval; 259 return retval;
230} 260}
231 261
232static unsigned int get_nthreads () 262static unsigned int get_nthreads (void)
233{ 263{
234 unsigned int retval; 264 unsigned int retval;
235 265
236 X_LOCK (wrklock); 266 X_LOCK (wrklock);
237 retval = started; 267 retval = started;
300 } 330 }
301 331
302 abort (); 332 abort ();
303} 333}
304 334
305static int poll_cb (); 335static int poll_cb (void);
306static void req_free (bdb_req req); 336static void req_free (bdb_req req);
307static void req_cancel (bdb_req req); 337static void req_cancel (bdb_req req);
308 338
309static int req_invoke (bdb_req req) 339static int req_invoke (bdb_req req)
310{ 340{
391#else 421#else
392# define TO_SOCKET(x) (x) 422# define TO_SOCKET(x) (x)
393#endif 423#endif
394 424
395static void 425static void
396create_respipe () 426create_respipe (void)
397{ 427{
398#ifdef _WIN32 428#ifdef _WIN32
399 int arg; /* argg */ 429 int arg; /* argg */
400#endif 430#endif
401 int old_readfd = respipe [0]; 431 int old_readfd = respipe [0];
455 free (wrk); 485 free (wrk);
456 486
457 X_UNLOCK (wrklock); 487 X_UNLOCK (wrklock);
458} 488}
459 489
460static void maybe_start_thread () 490static void maybe_start_thread (void)
461{ 491{
462 if (get_nthreads () >= wanted) 492 if (get_nthreads () >= wanted)
463 return; 493 return;
464 494
465 /* todo: maybe use idle here, but might be less exact */ 495 /* todo: maybe use idle here, but might be less exact */
550 580
551 while (started > wanted) 581 while (started > wanted)
552 end_thread (); 582 end_thread ();
553} 583}
554 584
555static void poll_wait () 585static void poll_wait (void)
556{ 586{
557 fd_set rfd; 587 fd_set rfd;
558 588
559 while (nreqs) 589 while (nreqs)
560 { 590 {
573 603
574 PerlSock_select (respipe [0] + 1, &rfd, 0, 0, 0); 604 PerlSock_select (respipe [0] + 1, &rfd, 0, 0, 0);
575 } 605 }
576} 606}
577 607
578static int poll_cb () 608static int poll_cb (void)
579{ 609{
580 dSP; 610 dSP;
581 int count = 0; 611 int count = 0;
582 int maxreqs = max_poll_reqs; 612 int maxreqs = max_poll_reqs;
583 int do_croak = 0; 613 int do_croak = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines