Select Git revision
-
Fredrik Hübinette (Hubbe) authored
Rev: src/ChangeLog:1.34 Rev: src/callback.c:1.5 Rev: src/gc.c:1.6
Fredrik Hübinette (Hubbe) authoredRev: src/ChangeLog:1.34 Rev: src/callback.c:1.5 Rev: src/gc.c:1.6
fdlib.c 45.78 KiB
/*
|| This file is part of Pike. For copyright information see COPYRIGHT.
|| Pike is distributed under GPL, LGPL and MPL. See the file COPYING
|| for more information.
*/
#include "global.h"
#include "fdlib.h"
#include "pike_error.h"
#include <math.h>
#include <ctype.h>
#ifdef HAVE_DIRECT_H
#include <direct.h>
#endif
#if defined(HAVE_WINSOCK_H)
#include <time.h>
/* Old versions of the headerfiles don't have this constant... */
#ifndef INVALID_SET_FILE_POINTER
#define INVALID_SET_FILE_POINTER ((DWORD)-1)
#endif
#include "threads.h"
static MUTEX_T fd_mutex;
HANDLE da_handle[MAX_OPEN_FILEDESCRIPTORS];
int fd_type[MAX_OPEN_FILEDESCRIPTORS];
int first_free_handle;
/* #define FD_DEBUG */
/* #define FD_STAT_DEBUG */
#ifdef FD_DEBUG
#define FDDEBUG(X) X
#else
#define FDDEBUG(X)
#endif
#ifdef FD_STAT_DEBUG
#define STATDEBUG(X) X
#else
#define STATDEBUG(X) do {} while (0)
#endif
/* _dosmaperr is internal but still exported in the dll interface. */
__declspec(dllimport) void __cdecl _dosmaperr(unsigned long);
PMOD_EXPORT void set_errno_from_win32_error (unsigned long err)
{
/* _dosmaperr handles the common I/O errors from GetLastError, but
* not the winsock codes. */
_dosmaperr (err);
/* Let through any error that _dosmaperr didn't map, and which
* doesn't conflict with the errno range in msvcrt. */
if (errno == EINVAL && err > STRUNCATE /* 80 */) {
switch (err) {
/* Special cases for the error codes above STRUNCATE that
* _dosmaperr actively map to EINVAL. */
case ERROR_INVALID_PARAMETER: /* 87 */
case ERROR_INVALID_HANDLE: /* 124 */
case ERROR_NEGATIVE_SEEK: /* 131 */
return;
}
/* FIXME: This lets most winsock codes through as-is, e.g.