]> sjero.net Git - wget/blobdiff - src/sysdep.h
[svn] Support human-readable file size printing.
[wget] / src / sysdep.h
index 0d006ecd6b897c5f44eadc15bbe7a8c9bd112cb7..e93f257e78d9bb548c106505764bd9f1bce72fb3 100644 (file)
@@ -108,34 +108,12 @@ so, delete this exception statement from your version.  */
 #endif
 #endif
 
-#ifdef __BEOS__
-# undef READ
-# undef WRITE
-# define READ(fd, buf, cnt) recv((fd), (buf), (cnt), 0)
-# define WRITE(fd, buf, cnt) send((fd), (buf), (cnt), 0)
-#endif
-
-/* mswindows.h defines these.  */
-#ifndef READ
-# define READ(fd, buf, cnt) read ((fd), (buf), (cnt))
-#endif
-#ifndef WRITE
-# define WRITE(fd, buf, cnt) write ((fd), (buf), (cnt))
-#endif
-#ifndef REALCLOSE
-# define REALCLOSE(x) close (x)
-#endif
-
-#define CLOSE(x)                               \
-do {                                           \
-  REALCLOSE (x);                               \
-  DEBUGP (("Closing fd %d\n", x));             \
-} while (0)
-
 /* Define a large integral type useful for storing large sizes that
    exceed sizes of one download, such as when printing the sum of all
    downloads.  Note that this has nothing to do with large file
-   support, yet.
+   support, which determines the wgint type.  This should be as large
+   as possible even on systems where when wgint is 32-bit; also,
+   unlike wgint, this can be a floating point type.
 
    We use a 64-bit integral type where available, `double' otherwise.
    It's hard to print LARGE_INT's portably, but fortunately it's
@@ -151,12 +129,38 @@ typedef long LARGE_INT;
 typedef long long LARGE_INT;
 #  define LARGE_INT_FMT "%lld"
 # else
+#  if _MSC_VER
+/* Use __int64 under Windows. */
+typedef __int64 LARGE_INT;
+#   define LARGE_INT_FMT "%I64"
+#  else
 /* Large integer type unavailable; use `double' instead.  */
 typedef double LARGE_INT;
-#  define LARGE_INT_FMT "%.0f"
+#   define LARGE_INT_FMT "%.0f"
+#  endif
 # endif
 #endif
 
+/* Under Windows we #define struct_stat to struct _stati64. */
+#ifndef struct_stat
+# define struct_stat struct stat
+#endif
+
+#ifdef HAVE_LIMITS_H
+# include <limits.h>
+#endif
+
+#ifndef CHAR_BIT
+# define CHAR_BIT 8
+#endif
+
+#ifndef LONG_MAX
+# define LONG_MAX ((long) ~((unsigned long)1 << (CHAR_BIT * sizeof (long) - 1)))
+#endif
+#ifndef LLONG_MAX
+# define LLONG_MAX ((long long) ~((unsigned long long)1 << (CHAR_BIT * sizeof (long long) - 1)))
+#endif
+
 /* These are defined in cmpt.c if missing, therefore it's generally
    safe to declare their parameters.  */
 #ifndef HAVE_STRERROR
@@ -180,9 +184,6 @@ int snprintf ();
 #ifndef HAVE_VSNPRINTF
 int vsnprintf ();
 #endif
-#ifndef HAVE_USLEEP
-int usleep PARAMS ((unsigned long));
-#endif
 #ifndef HAVE_MEMMOVE
 void *memmove ();
 #endif
@@ -219,16 +220,19 @@ void *memcpy ();
 # define MAP_FAILED ((void *) -1)
 #endif
 
-/* Enable system fnmatch only on systems where we know it works:
-   currently glibc-based systems and Solaris.  One could add more, but
-   fnmatch is not that large, so it might be better to play it
-   safe.  */
-#if defined __GLIBC__ && __GLIBC__ >= 2
-# define SYSTEM_FNMATCH
-#endif
-#ifdef solaris
-# define SYSTEM_FNMATCH
-#endif
+/* Enable system fnmatch only on systems where fnmatch.h is usable and
+   which are known to have a non-broken fnmatch implementation.
+   Currently those include glibc-based systems and Solaris.  One could
+   add more, but fnmatch is not that large, so it might be better to
+   play it safe.  */
+#ifdef HAVE_WORKING_FNMATCH_H
+# if defined __GLIBC__ && __GLIBC__ >= 2
+#  define SYSTEM_FNMATCH
+# endif
+# ifdef solaris
+#  define SYSTEM_FNMATCH
+# endif
+#endif /* HAVE_WORKING_FNMATCH_H */
 
 #ifdef SYSTEM_FNMATCH
 # include <fnmatch.h>
@@ -249,6 +253,11 @@ void *memcpy ();
 int fnmatch ();
 #endif
 
+/* Provide sig_atomic_t if the system doesn't.  */
+#ifndef HAVE_SIG_ATOMIC_T
+typedef int sig_atomic_t;
+#endif
+
 /* Provide uint32_t on the platforms that don't define it.  Although
    most code should be agnostic about integer sizes, some code really
    does need a 32-bit integral type.  Such code should use uint32_t.