Navigation Menu

Skip to content

Commit

Permalink
windows: always use _read() on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Apr 16, 2015
1 parent 55befa1 commit e76d983
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 18 deletions.
1 change: 0 additions & 1 deletion build/ac_macros/check_functions.m4
Expand Up @@ -10,7 +10,6 @@ AC_CHECK_FUNCS(gmtime_r)
AC_CHECK_FUNCS(localtime_r)
AC_CHECK_FUNCS(mkostemp)
AC_CHECK_FUNCS(open)
AC_CHECK_FUNCS(read)
AC_CHECK_FUNCS(strcasecmp)
AC_CHECK_FUNCS(strncasecmp)
AC_CHECK_FUNCS(strtoull)
1 change: 0 additions & 1 deletion config.h.cmake
Expand Up @@ -150,7 +150,6 @@
#cmakedefine HAVE_LOCALTIME_R
#cmakedefine HAVE_MKOSTEMP
#cmakedefine HAVE_OPEN
#cmakedefine HAVE_READ
#cmakedefine HAVE_STRCASECMP
#cmakedefine HAVE_STRNCASECMP
#cmakedefine HAVE_STRTOULL
Expand Down
6 changes: 6 additions & 0 deletions include/groonga/portability.h
Expand Up @@ -115,4 +115,10 @@
# define grn_write(fd, buf, count) write((fd), (buf), (count))
#endif /* WIN32 */

#ifdef WIN32
# define grn_read(fd, buf, count) _read((fd), (buf), (count))
#else
# define grn_read(fd, buf, count) read((fd), (buf), (count))
#endif /* WIN32 */

#endif /* GROONGA_PORTABILITY_H */
12 changes: 0 additions & 12 deletions lib/grn.h
Expand Up @@ -79,18 +79,6 @@
# define GRN_CLOSE(fd) _close(fd)
#endif /* HAVE_CLOSE */

#ifdef HAVE_READ
# define GRN_READ(fd, buf, count) read(fd, buf, count)
#else
# define GRN_READ(fd, buf, count) _read(fd, buf, count)
#endif /* HAVE_READ */

#ifdef HAVE_WRITE
# define GRN_WRITE(fd, buf, count) write(fd, buf, count)
#else
# define GRN_WRITE(fd, buf, count) _write(fd, buf, count)
#endif /* HAVE_WRITE */

#ifdef WIN32

# if defined(__GNUC__) && !defined(WINVER)
Expand Down
2 changes: 1 addition & 1 deletion lib/ii.c
Expand Up @@ -7405,7 +7405,7 @@ grn_ii_buffer_fetch(grn_ctx *ctx, grn_ii_buffer *ii_buffer,
ERRNO_ERR("grn_lseek");
return;
}
if (read(ii_buffer->tmpfd, block->buffer, bytesize) != bytesize) {
if (grn_read(ii_buffer->tmpfd, block->buffer, bytesize) != bytesize) {
SERR("read");
return;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/io.c
Expand Up @@ -481,7 +481,7 @@ grn_io_detect_type(grn_ctx *ctx, const char *path)
if (fd != -1) {
struct stat s;
if (fstat(fd, &s) != -1 && s.st_size >= sizeof(struct _grn_io_header)) {
if (read(fd, &h, sizeof(struct _grn_io_header)) == sizeof(struct _grn_io_header)) {
if (grn_read(fd, &h, sizeof(struct _grn_io_header)) == sizeof(struct _grn_io_header)) {
if (!memcmp(h.idstr, GRN_IO_IDSTR, 16)) {
res = h.type;
} else {
Expand Down Expand Up @@ -515,7 +515,7 @@ grn_io_open(grn_ctx *ctx, const char *path, grn_io_mode mode)
int fd = GRN_OPEN(path, O_RDWR | O_BINARY);
if (fd == -1) { SERR(path); return NULL; }
if (fstat(fd, &s) != -1 && s.st_size >= sizeof(struct _grn_io_header)) {
if (read(fd, &h, sizeof(struct _grn_io_header)) == sizeof(struct _grn_io_header)) {
if (grn_read(fd, &h, sizeof(struct _grn_io_header)) == sizeof(struct _grn_io_header)) {
if (!memcmp(h.idstr, GRN_IO_IDSTR, 16)) {
header_size = h.header_size;
segment_size = h.segment_size;
Expand Down
2 changes: 1 addition & 1 deletion lib/proc.c
Expand Up @@ -90,7 +90,7 @@ grn_bulk_put_from_file(grn_ctx *ctx, grn_obj *bulk, const char *path)
if ((buf = GRN_MALLOC(rest))) {
ssize_t ss;
for (bp = buf; rest; rest -= ss, bp += ss) {
if ((ss = GRN_READ(fd, bp, rest)) == -1) { goto exit; }
if ((ss = grn_read(fd, bp, rest)) == -1) { goto exit; }
}
GRN_TEXT_PUT(ctx, bulk, buf, stat.st_size);
ret = 1;
Expand Down

0 comments on commit e76d983

Please sign in to comment.