(__attribute__): Protect against redefinition.
[gnulib.git] / lib / full-write.c
index aa8cff3..ac27d62 100644 (file)
@@ -1,5 +1,5 @@
 /* full-write.c -- an interface to write that retries after interrupts
-   Copyright (C) 1993, 1994 Free Software Foundation, Inc.
+   Copyright (C) 1993, 1994, 1997, 1998 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
    Copied largely from GNU C's cccp.c.
    */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
+#if HAVE_CONFIG_H
+# include <config.h>
 #endif
 
 #include <sys/types.h>
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
+#if HAVE_UNISTD_H
+# include <unistd.h>
 #endif
 
 #include <errno.h>
@@ -34,16 +34,10 @@ extern int errno;
 #endif
 
 /* Write LEN bytes at PTR to descriptor DESC, retrying if interrupted.
-   Return LEN upon success, write's (negative) error code otherwise.
-   As the name implies, this function writes all LEN bytes and returns
-   LEN or it fails and returns the negative value returned by the (final)
-   failing write.  */
+   Return LEN upon success, write's (negative) error code otherwise.  */
 
 int
-full_write (desc, ptr, len)
-     int desc;
-     char *ptr;
-     size_t len;
+full_write (int desc, const char *ptr, size_t len)
 {
   int total_written;
 
@@ -51,6 +45,10 @@ full_write (desc, ptr, len)
   while (len > 0)
     {
       int written = write (desc, ptr, len);
+      /* FIXME: write on my slackware Linux 1.2.13 returns zero when
+        I try to write more data than there is room on a floppy disk.
+        This puts dd into an infinite loop.  Reproduce with
+        dd if=/dev/zero of=/dev/fd0.  */
       if (written < 0)
        {
 #ifdef EINTR