+++ /dev/null
-/** @file\r
- *\r
- * Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved.<BR>\r
- *\r
- * Redistribution and use in source and binary forms, with or without modification,\r
- * are permitted provided that the following conditions are met:\r
- *\r
- * 1. Redistributions of source code must retain the above copyright notice,\r
- * this list of conditions and the following disclaimer.\r
- *\r
- * 2. Redistributions in binary form must reproduce the above copyright notice,\r
- * this list of conditions and the following disclaimer in the documentation\r
- * and/or other materials provided with the distribution.\r
- *\r
- * 3. All advertising materials mentioning features or use of this software must\r
- * display the following acknowledgement:\r
- *\r
- * This product includes software developed by Intel Corporation and its\r
- * contributors.\r
- *\r
- * 4. Neither the name of Intel Corporation or its contributors may be used to\r
- * endorse or promote products derived from this software without specific\r
- * prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION AND CONTRIBUTORS ``AS IS'' AND\r
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
- * DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION OR CONTRIBUTORS BE LIABLE FOR\r
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
- *\r
- */\r
-\r
-/*++\r
-\r
-Module Name:\r
-\r
- writev.c\r
-\r
-Abstract:\r
-\r
- Functions implementing the standard "writev" system call interface\r
-\r
-\r
-Revision History\r
-\r
---*/\r
-#include <LibConfig.h>\r
-\r
-#ifdef foo\r
-#include <efi_interface.h>\r
-#include <unistd.h>\r
-#include <fcntl.h>\r
-#define KERNEL\r
-#include <errno.h>\r
-#undef KERNEL\r
-#include "./filedesc.h"\r
-\r
-#include <libc_debug.h>\r
-#include <assert.h>\r
-#endif\r
-\r
-#include <stdlib.h>\r
-#include <unistd.h>\r
-#include <sys/uio.h>\r
-#include <string.h>\r
-#ifndef KERNEL\r
-#define KERNEL\r
-#include <errno.h>\r
-#undef KERNEL\r
-#else\r
-#include <errno.h>\r
-#endif\r
-\r
-//\r
-// Name:\r
-// writev\r
-//\r
-// Description:\r
-// BSD writev interface for libc\r
-//\r
-// Arguments:\r
-// File Descriptor (index into file descriptor table)\r
-// iovec pointer\r
-// size of iovec array\r
-//\r
-// Returns:\r
-// number of bytes written\r
-//\r
-\r
-ssize_t\r
-writev(\r
- int fd,\r
- const struct iovec *iov,\r
- int iovcnt\r
- )\r
-{\r
- const struct iovec *pVecTmp;\r
- char *pBuf;\r
- size_t TotalBytes;\r
- size_t i;\r
- size_t ret;\r
-\r
- //\r
- // See how much memory we'll need\r
- //\r
-\r
- for (i = 0, TotalBytes = 0, pVecTmp = iov; i < (size_t)iovcnt; i++, pVecTmp++) {\r
- TotalBytes += pVecTmp->iov_len;\r
- }\r
-\r
- //\r
- // Allocate a contiguous buffer\r
- //\r
-\r
- pBuf = (char*)malloc (TotalBytes);\r
- if (pBuf == NULL) {\r
- errno = ENOMEM;\r
- return -1;\r
- }\r
-\r
- //\r
- // Copy vectors to the buffer\r
- //\r
-\r
- for (; iovcnt; iovcnt--) {\r
- bcopy(iov->iov_base, pBuf, iov->iov_len);\r
- pBuf += iov->iov_len;\r
- iov++;\r
- }\r
-\r
- //\r
- // Use standard write(2) then free buffer\r
- //\r
-\r
- ret = write (fd, pBuf, TotalBytes);\r
- free (pBuf);\r
-\r
- return (ret);\r
-}\r