~ubuntu-branches/ubuntu/utopic/coreutils/utopic-proposed

« back to all changes in this revision

Viewing changes to lib/read.c

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-11-28 03:03:42 UTC
  • mfrom: (8.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20121128030342-21zanj8354gas5gr
Tags: 8.20-3ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Make 'uname -i -p' return the real processor/hardware, instead of
    unknown.
  - Build-depend on gettext:any instead of on gettext, so that apt-get can
    properly resolve build-dependencies on the tool when cross-building.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* POSIX compatible read() function.
2
 
   Copyright (C) 2008-2011 Free Software Foundation, Inc.
 
2
   Copyright (C) 2008-2012 Free Software Foundation, Inc.
3
3
   Written by Bruno Haible <bruno@clisp.org>, 2011.
4
4
 
5
5
   This program is free software: you can redistribute it and/or modify
20
20
/* Specification.  */
21
21
#include <unistd.h>
22
22
 
23
 
/* Replace this function only if module 'nonblocking' is requested.  */
24
 
#if GNULIB_NONBLOCKING
25
 
 
26
 
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
27
 
 
28
 
#  include <errno.h>
29
 
#  include <io.h>
30
 
 
31
 
#  define WIN32_LEAN_AND_MEAN  /* avoid including junk */
32
 
#  include <windows.h>
 
23
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
 
24
 
 
25
# include <errno.h>
 
26
# include <io.h>
 
27
 
 
28
# define WIN32_LEAN_AND_MEAN  /* avoid including junk */
 
29
# include <windows.h>
 
30
 
 
31
# include "msvc-inval.h"
 
32
# include "msvc-nothrow.h"
 
33
 
 
34
# undef read
 
35
 
 
36
# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
 
37
static inline ssize_t
 
38
read_nothrow (int fd, void *buf, size_t count)
 
39
{
 
40
  ssize_t result;
 
41
 
 
42
  TRY_MSVC_INVAL
 
43
    {
 
44
      result = read (fd, buf, count);
 
45
    }
 
46
  CATCH_MSVC_INVAL
 
47
    {
 
48
      result = -1;
 
49
      errno = EBADF;
 
50
    }
 
51
  DONE_MSVC_INVAL;
 
52
 
 
53
  return result;
 
54
}
 
55
# else
 
56
#  define read_nothrow read
 
57
# endif
33
58
 
34
59
ssize_t
35
60
rpl_read (int fd, void *buf, size_t count)
36
 
#undef read
37
61
{
38
 
  ssize_t ret = read (fd, buf, count);
 
62
  ssize_t ret = read_nothrow (fd, buf, count);
39
63
 
 
64
# if GNULIB_NONBLOCKING
40
65
  if (ret < 0
41
66
      && GetLastError () == ERROR_NO_DATA)
42
67
    {
52
77
            errno = EAGAIN;
53
78
        }
54
79
    }
 
80
# endif
 
81
 
55
82
  return ret;
56
83
}
57
84
 
58
 
# endif
59
85
#endif