diff options
-rw-r--r-- | config.mak.in | 2 | ||||
-rw-r--r-- | configure.ac | 26 | ||||
-rw-r--r-- | gs/Makefile.in | 2 | ||||
-rw-r--r-- | gs/base/gp_unifs.c | 34 | ||||
-rw-r--r-- | gs/configure.ac | 13 |
5 files changed, 69 insertions, 8 deletions
diff --git a/config.mak.in b/config.mak.in index 9c2428472..ccb84aee8 100644 --- a/config.mak.in +++ b/config.mak.in | |||
@@ -17,7 +17,7 @@ CC=@CC@ | |||
17 | CCAUX=@CC@ | 17 | CCAUX=@CC@ |
18 | 18 | ||
19 | CONFDEFS?=@HAVE_MKSTEMP@ @HAVE_SSE2@ @HAVE_BSWAP32@ @HAVE_BYTESWAP_H@ @HAVE_SYS_TIME_H@ @HAVE_FSEEKO@ @HAVE_INTTYPES@ @HAVE_MKSTEMP64@ \ | 19 | CONFDEFS?=@HAVE_MKSTEMP@ @HAVE_SSE2@ @HAVE_BSWAP32@ @HAVE_BYTESWAP_H@ @HAVE_SYS_TIME_H@ @HAVE_FSEEKO@ @HAVE_INTTYPES@ @HAVE_MKSTEMP64@ \ |
20 | @HAVE_FILE64@ | 20 | @HAVE_FILE64@ @HAVE_PREAD_PWRITE@ |
21 | 21 | ||
22 | ACCFLAGS?=@GCFLAGS@ | 22 | ACCFLAGS?=@GCFLAGS@ |
23 | 23 | ||
diff --git a/configure.ac b/configure.ac index 07e0bba93..44b725256 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -453,12 +453,30 @@ dnl -------------------------------------------------- | |||
453 | dnl Check for libraries and x11 includes/libraries | 453 | dnl Check for libraries and x11 includes/libraries |
454 | dnl -------------------------------------------------- | 454 | dnl -------------------------------------------------- |
455 | 455 | ||
456 | AC_CHECK_FUNCS([pread pwrite], [HAVE_PREAD_PWRITE="-DHAVE_PREAD_PWRITE=1"], [HAVE_PREAD_PWRITE=]) | ||
457 | |||
458 | AC_SUBST(HAVE_PREAD_PWRITE) | ||
459 | |||
456 | SYNC="nosync" | 460 | SYNC="nosync" |
457 | PTHREAD_LIBS="" | 461 | PTHREAD_LIBS="" |
458 | AC_CHECK_LIB(pthread, pthread_create, [ | 462 | |
459 | SYNC=posync; | 463 | # if you haven't got pread/pwrite, we can't use multithreading |
460 | PTHREAD_LIBS="-lpthread" | 464 | if test "x$HAVE_PREAD_PWRITE" != "x"; then |
461 | ]) | 465 | |
466 | case `uname` in | ||
467 | MINGW*) | ||
468 | AC_MSG_WARN([disabling support for pthreads......]) | ||
469 | ;; | ||
470 | *) | ||
471 | AC_CHECK_LIB(pthread, pthread_create, [ | ||
472 | SYNC=posync; | ||
473 | PTHREAD_LIBS="-lpthread" | ||
474 | ]) | ||
475 | ;; | ||
476 | esac | ||
477 | |||
478 | fi | ||
479 | |||
462 | AC_SUBST(SYNC) | 480 | AC_SUBST(SYNC) |
463 | AC_SUBST(PTHREAD_LIBS) | 481 | AC_SUBST(PTHREAD_LIBS) |
464 | 482 | ||
diff --git a/gs/Makefile.in b/gs/Makefile.in index 9212fde3e..c13462266 100644 --- a/gs/Makefile.in +++ b/gs/Makefile.in | |||
@@ -142,7 +142,7 @@ GENOPT= | |||
142 | # -DHAVE_SSE2 | 142 | # -DHAVE_SSE2 |
143 | # use sse2 intrinsics | 143 | # use sse2 intrinsics |
144 | 144 | ||
145 | CAPOPT= @HAVE_MKSTEMP@ @HAVE_FILE64@ @HAVE_FSEEKO@ @HAVE_MKSTEMP64@ @HAVE_FONTCONFIG@ @HAVE_LIBIDN@ @HAVE_SETLOCALE@ @HAVE_SSE2@ @HAVE_DBUS@ @HAVE_BSWAP32@ @HAVE_BYTESWAP_H@ @HAVE_STRERROR@ | 145 | CAPOPT= @HAVE_MKSTEMP@ @HAVE_FILE64@ @HAVE_FSEEKO@ @HAVE_MKSTEMP64@ @HAVE_FONTCONFIG@ @HAVE_LIBIDN@ @HAVE_SETLOCALE@ @HAVE_SSE2@ @HAVE_DBUS@ @HAVE_BSWAP32@ @HAVE_BYTESWAP_H@ @HAVE_STRERROR@ @HAVE_PREAD_PWRITE@ |
146 | 146 | ||
147 | # Define the name of the executable file. | 147 | # Define the name of the executable file. |
148 | 148 | ||
diff --git a/gs/base/gp_unifs.c b/gs/base/gp_unifs.c index 59fc86c3d..2bf9b1413 100644 --- a/gs/base/gp_unifs.c +++ b/gs/base/gp_unifs.c | |||
@@ -183,12 +183,46 @@ FILE *gp_fdup(FILE *f, const char *mode) | |||
183 | 183 | ||
184 | int gp_fpread(char *buf, uint count, int64_t offset, FILE *f) | 184 | int gp_fpread(char *buf, uint count, int64_t offset, FILE *f) |
185 | { | 185 | { |
186 | #if defined(HAVE_PREAD_PWRITE) && HAVE_PREAD_PWRITE == 1 | ||
186 | return pread(fileno(f), buf, count, offset); | 187 | return pread(fileno(f), buf, count, offset); |
188 | #else | ||
189 | uint c; | ||
190 | int64_t os, curroff = gp_ftell_64(f); | ||
191 | if (curroff < 0) return curroff; | ||
192 | |||
193 | os = gp_fseek_64(f, offset, 0); | ||
194 | if (os < 0) return os; | ||
195 | |||
196 | c = fread(buf, 1, count, f); | ||
197 | if (c < 0) return c; | ||
198 | |||
199 | os = gp_fseek_64(f, curroff, 0); | ||
200 | if (os < 0) return os; | ||
201 | |||
202 | return c; | ||
203 | #endif | ||
187 | } | 204 | } |
188 | 205 | ||
189 | int gp_fpwrite(char *buf, uint count, int64_t offset, FILE *f) | 206 | int gp_fpwrite(char *buf, uint count, int64_t offset, FILE *f) |
190 | { | 207 | { |
208 | #if defined(HAVE_PREAD_PWRITE) && HAVE_PREAD_PWRITE == 1 | ||
191 | return pwrite(fileno(f), buf, count, offset); | 209 | return pwrite(fileno(f), buf, count, offset); |
210 | #else | ||
211 | uint c; | ||
212 | int64_t os, curroff = gp_ftell_64(f); | ||
213 | if (curroff < 0) return curroff; | ||
214 | |||
215 | os = gp_fseek_64(f, offset, 0); | ||
216 | if (os < 0) return os; | ||
217 | |||
218 | c = fwrite(buf, 1, count, f); | ||
219 | if (c < 0) return c; | ||
220 | |||
221 | os = gp_fseek_64(f, curroff, 0); | ||
222 | if (os < 0) return os; | ||
223 | |||
224 | return c; | ||
225 | #endif | ||
192 | } | 226 | } |
193 | 227 | ||
194 | /* Set a file into binary or text mode. */ | 228 | /* Set a file into binary or text mode. */ |
diff --git a/gs/configure.ac b/gs/configure.ac index 718d49b09..5f64dd221 100644 --- a/gs/configure.ac +++ b/gs/configure.ac | |||
@@ -492,10 +492,17 @@ dnl -------------------------------------------------- | |||
492 | 492 | ||
493 | AC_CHECK_LIB(m, cos) | 493 | AC_CHECK_LIB(m, cos) |
494 | 494 | ||
495 | AC_CHECK_FUNCS([pread pwrite], [HAVE_PREAD_PWRITE="-DHAVE_PREAD_PWRITE=1"], [HAVE_PREAD_PWRITE=]) | ||
496 | |||
497 | AC_SUBST(HAVE_PREAD_PWRITE) | ||
498 | |||
495 | SYNC="nosync" | 499 | SYNC="nosync" |
496 | PTHREAD_LIBS="" | 500 | PTHREAD_LIBS="" |
497 | 501 | ||
498 | case `uname` in | 502 | # if you haven't got pread/pwrite, we can't use multithreading |
503 | if test "x$HAVE_PREAD_PWRITE" != "x"; then | ||
504 | |||
505 | case `uname` in | ||
499 | MINGW*) | 506 | MINGW*) |
500 | AC_MSG_WARN([disabling support for pthreads......]) | 507 | AC_MSG_WARN([disabling support for pthreads......]) |
501 | ;; | 508 | ;; |
@@ -505,7 +512,9 @@ case `uname` in | |||
505 | PTHREAD_LIBS="-lpthread" | 512 | PTHREAD_LIBS="-lpthread" |
506 | ]) | 513 | ]) |
507 | ;; | 514 | ;; |
508 | esac | 515 | esac |
516 | |||
517 | fi | ||
509 | 518 | ||
510 | AC_SUBST(SYNC) | 519 | AC_SUBST(SYNC) |
511 | AC_SUBST(PTHREAD_LIBS) | 520 | AC_SUBST(PTHREAD_LIBS) |