2008-07-29 01:47:00 -07:00
|
|
|
/***********************************************************************/
|
|
|
|
/* */
|
2011-07-27 07:17:02 -07:00
|
|
|
/* OCaml */
|
2008-07-29 01:47:00 -07:00
|
|
|
/* */
|
2008-07-31 05:09:18 -07:00
|
|
|
/* Contributed by Sylvain Le Gall for Lexifi */
|
2008-07-29 01:47:00 -07:00
|
|
|
/* */
|
2008-07-31 05:09:18 -07:00
|
|
|
/* Copyright 2008 Institut National de Recherche en Informatique et */
|
2008-07-29 01:47:00 -07:00
|
|
|
/* en Automatique. All rights reserved. This file is distributed */
|
|
|
|
/* under the terms of the GNU Library General Public License, with */
|
|
|
|
/* the special exception on linking described in file ../../LICENSE. */
|
|
|
|
/* */
|
|
|
|
/***********************************************************************/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
Patch provided by Sylvain Le Gall:
- Fix #4894: Windows (mingw): Unix.select and non-blocking sockets,
add a filedescr.flags_fd in win32unix/unixsupport.h. It contains the
non-blocking status of the associated filedescr and helps to restore
this status after a select.
- Fix #4789: Windows: Unix.select failing with EPIPE error,
Apply patch provided by J. Vouillon
- Fix #4973: Failure "Unknown handle",
Be consistent between Windows and Linux, raise an EBADF Unix_error
for a closed pipe handle.
- Fix #4844: Unix.select bug (triggered if linked against threads),
Apply patch by C. Bauer, replace lpOrig by lpOrigIdx which can survive
a GC collection
For otherlibs/win32unix/{select|windbug}.c:
- Remove Heap* fucntions to allocate/free memory and replace it by
caml_stat_* function, which are more OCaml compliant
- Rework DBUG message, use DEBUG_PRINT rather than #ifdef DBUG... #endif
and use DEBUG variable (more OCaml compliant), also remove dbug_init
functions and use a static variable to replace it (subject to race
condition but this not really important, because every path lead to
same initialization)
- Use a fast start scheme for pipe polling, rather than always waiting
10ms, start by 1, 2, 4, 8 and then 10ms. The 4 first times give select
a chance to a fast answer.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@10467 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2010-05-25 06:01:06 -07:00
|
|
|
#ifdef DEBUG
|
2008-07-29 01:47:00 -07:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <windows.h>
|
|
|
|
|
Patch provided by Sylvain Le Gall:
- Fix #4894: Windows (mingw): Unix.select and non-blocking sockets,
add a filedescr.flags_fd in win32unix/unixsupport.h. It contains the
non-blocking status of the associated filedescr and helps to restore
this status after a select.
- Fix #4789: Windows: Unix.select failing with EPIPE error,
Apply patch provided by J. Vouillon
- Fix #4973: Failure "Unknown handle",
Be consistent between Windows and Linux, raise an EBADF Unix_error
for a closed pipe handle.
- Fix #4844: Unix.select bug (triggered if linked against threads),
Apply patch by C. Bauer, replace lpOrig by lpOrigIdx which can survive
a GC collection
For otherlibs/win32unix/{select|windbug}.c:
- Remove Heap* fucntions to allocate/free memory and replace it by
caml_stat_* function, which are more OCaml compliant
- Rework DBUG message, use DEBUG_PRINT rather than #ifdef DBUG... #endif
and use DEBUG variable (more OCaml compliant), also remove dbug_init
functions and use a static variable to replace it (subject to race
condition but this not really important, because every path lead to
same initialization)
- Use a fast start scheme for pipe polling, rather than always waiting
10ms, start by 1, 2, 4, 8 and then 10ms. The 4 first times give select
a chance to a fast answer.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@10467 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2010-05-25 06:01:06 -07:00
|
|
|
#define DEBUG_PRINT(fmt, ...) \
|
2008-07-29 01:47:00 -07:00
|
|
|
do \
|
|
|
|
{ \
|
Patch provided by Sylvain Le Gall:
- Fix #4894: Windows (mingw): Unix.select and non-blocking sockets,
add a filedescr.flags_fd in win32unix/unixsupport.h. It contains the
non-blocking status of the associated filedescr and helps to restore
this status after a select.
- Fix #4789: Windows: Unix.select failing with EPIPE error,
Apply patch provided by J. Vouillon
- Fix #4973: Failure "Unknown handle",
Be consistent between Windows and Linux, raise an EBADF Unix_error
for a closed pipe handle.
- Fix #4844: Unix.select bug (triggered if linked against threads),
Apply patch by C. Bauer, replace lpOrig by lpOrigIdx which can survive
a GC collection
For otherlibs/win32unix/{select|windbug}.c:
- Remove Heap* fucntions to allocate/free memory and replace it by
caml_stat_* function, which are more OCaml compliant
- Rework DBUG message, use DEBUG_PRINT rather than #ifdef DBUG... #endif
and use DEBUG variable (more OCaml compliant), also remove dbug_init
functions and use a static variable to replace it (subject to race
condition but this not really important, because every path lead to
same initialization)
- Use a fast start scheme for pipe polling, rather than always waiting
10ms, start by 1, 2, 4, 8 and then 10ms. The 4 first times give select
a chance to a fast answer.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@10467 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2010-05-25 06:01:06 -07:00
|
|
|
if (debug_test()) \
|
2008-07-29 01:47:00 -07:00
|
|
|
{ \
|
|
|
|
fprintf(stderr, "DBUG (pid:%d, tid: %d): ", GetCurrentProcessId(), GetCurrentThreadId()); \
|
|
|
|
fprintf(stderr, fmt, __VA_ARGS__); \
|
|
|
|
fprintf(stderr, "\n"); \
|
|
|
|
fflush(stderr); \
|
|
|
|
}; \
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
/* Test if we are in dbug mode */
|
Patch provided by Sylvain Le Gall:
- Fix #4894: Windows (mingw): Unix.select and non-blocking sockets,
add a filedescr.flags_fd in win32unix/unixsupport.h. It contains the
non-blocking status of the associated filedescr and helps to restore
this status after a select.
- Fix #4789: Windows: Unix.select failing with EPIPE error,
Apply patch provided by J. Vouillon
- Fix #4973: Failure "Unknown handle",
Be consistent between Windows and Linux, raise an EBADF Unix_error
for a closed pipe handle.
- Fix #4844: Unix.select bug (triggered if linked against threads),
Apply patch by C. Bauer, replace lpOrig by lpOrigIdx which can survive
a GC collection
For otherlibs/win32unix/{select|windbug}.c:
- Remove Heap* fucntions to allocate/free memory and replace it by
caml_stat_* function, which are more OCaml compliant
- Rework DBUG message, use DEBUG_PRINT rather than #ifdef DBUG... #endif
and use DEBUG variable (more OCaml compliant), also remove dbug_init
functions and use a static variable to replace it (subject to race
condition but this not really important, because every path lead to
same initialization)
- Use a fast start scheme for pipe polling, rather than always waiting
10ms, start by 1, 2, 4, 8 and then 10ms. The 4 first times give select
a chance to a fast answer.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@10467 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2010-05-25 06:01:06 -07:00
|
|
|
int debug_test (void);
|
2008-07-29 01:47:00 -07:00
|
|
|
|
|
|
|
#else
|
Patch provided by Sylvain Le Gall:
- Fix #4894: Windows (mingw): Unix.select and non-blocking sockets,
add a filedescr.flags_fd in win32unix/unixsupport.h. It contains the
non-blocking status of the associated filedescr and helps to restore
this status after a select.
- Fix #4789: Windows: Unix.select failing with EPIPE error,
Apply patch provided by J. Vouillon
- Fix #4973: Failure "Unknown handle",
Be consistent between Windows and Linux, raise an EBADF Unix_error
for a closed pipe handle.
- Fix #4844: Unix.select bug (triggered if linked against threads),
Apply patch by C. Bauer, replace lpOrig by lpOrigIdx which can survive
a GC collection
For otherlibs/win32unix/{select|windbug}.c:
- Remove Heap* fucntions to allocate/free memory and replace it by
caml_stat_* function, which are more OCaml compliant
- Rework DBUG message, use DEBUG_PRINT rather than #ifdef DBUG... #endif
and use DEBUG variable (more OCaml compliant), also remove dbug_init
functions and use a static variable to replace it (subject to race
condition but this not really important, because every path lead to
same initialization)
- Use a fast start scheme for pipe polling, rather than always waiting
10ms, start by 1, 2, 4, 8 and then 10ms. The 4 first times give select
a chance to a fast answer.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@10467 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2010-05-25 06:01:06 -07:00
|
|
|
#define DEBUG_PRINT(fmt, ...)
|
2008-07-29 01:47:00 -07:00
|
|
|
#endif
|