Index: configure
===================================================================
RCS file: /cvs/fastos/glibc/configure,v
retrieving revision 1.1.1.2
retrieving revision 1.9
diff -u -r1.1.1.2 -r1.9
--- configure	11 Jul 2006 21:30:17 -0000	1.1.1.2
+++ configure	26 Jun 2007 15:25:01 -0000	1.9
@@ -2016,6 +2016,8 @@
   base_os=unix/bsd/bsd4.4 ;;
 osf* | sunos* | ultrix* | newsos* | dynix* | *bsd*)
   base_os=unix/bsd ;;
+linux*zoid)
+  base_os=unix/sysv/linux/zoid ;;
 sysv* | isc* | esix* | sco* | minix* | irix4* | linux*)
   base_os=unix/sysv ;;
 irix6*)
@@ -2026,6 +2028,8 @@
   base_os=unix/sysv/hpux/$os ;;
 aix4.3*)
   base_os=unix/sysv/aix/aix4.3 ;;
+blrtszoid*)
+  base_os=blrts/zoid ;;
 blrts*)
   base_os=blrts ;;
 none)
Index: configure.in
===================================================================
RCS file: /cvs/fastos/glibc/configure.in,v
retrieving revision 1.1.1.2
retrieving revision 1.5
diff -u -r1.1.1.2 -r1.5
--- configure.in	11 Jul 2006 21:30:17 -0000	1.1.1.2
+++ configure.in	26 Jun 2007 15:24:52 -0000	1.5
@@ -514,6 +514,8 @@
   base_os=unix/bsd/bsd4.4 ;;
 osf* | sunos* | ultrix* | newsos* | dynix* | *bsd*)
   base_os=unix/bsd ;;
+linux*zoid)
+  base_os=unix/sysv/linux/zoid ;;
 sysv* | isc* | esix* | sco* | minix* | irix4* | linux*)
   base_os=unix/sysv ;;
 irix6*)
@@ -524,6 +526,8 @@
   base_os=unix/sysv/hpux/$os ;;
 aix4.3*)
   base_os=unix/sysv/aix/aix4.3 ;;
+blrtszoid*)
+  base_os=blrts/zoid ;;
 blrts*)
   base_os=blrts ;;
 none)
Index: nis/rpcsvc/yp_prot.h
===================================================================
RCS file: nis/rpcsvc/yp_prot.h
diff -N nis/rpcsvc/yp_prot.h
Index: scripts/config.sub
===================================================================
RCS file: /cvs/fastos/glibc/scripts/config.sub,v
retrieving revision 1.1.1.2
retrieving revision 1.3
diff -u -r1.1.1.2 -r1.3
--- scripts/config.sub	11 Jul 2006 21:30:22 -0000	1.1.1.2
+++ scripts/config.sub	11 Jul 2006 21:57:50 -0000	1.3
@@ -1165,7 +1165,7 @@
 		esac
 		;;
 	-blrts*)
-		os=-blrts
+#		os=-blrts
 		;;
 	-nto-qnx*)
 		;;
Index: sysdeps/blrts/zoid/Makefile
===================================================================
RCS file: sysdeps/blrts/zoid/Makefile
diff -N sysdeps/blrts/zoid/Makefile
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/Makefile	27 Jun 2007 15:20:38 -0000	1.5
@@ -0,0 +1,30 @@
+#***************************************************************************
+# ZEPTOOS:zepto-info
+#      This file is part of ZeptoOS: The Small Linux for Big Computers.
+#      See www.mcs.anl.gov/zeptoos for more information.
+# ZEPTOOS:zepto-info
+#
+# ZEPTOOS:zepto-fillin
+#      $Id: Makefile,v 1.5 2007/06/27 15:20:38 iskra Exp $
+#      ZeptoOS_Version: 1.2
+#      ZeptoOS_Heredity: FOSS_ORIG
+#      ZeptoOS_License: GPL
+# ZEPTOOS:zepto-fillin
+#
+# ZEPTOOS:zepto-gpl
+#       Copyright: Argonne National Laboratory, Department of Energy,
+#                  and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+#       ZeptoOS License: GPL
+#  
+#       This software is free.  See the file ZeptoOS/misc/license.GPL
+#       for complete details on your rights to copy, modify, and use this
+#       software.
+# ZEPTOOS:zepto-gpl
+#***************************************************************************
+
+ifeq ($(subdir),misc)
+sysdep_routines += init-zoid rts_coordinatesForRank rts_rankForCoordinates \
+	zoid_mapping
+CFLAGS-init-zoid.c += -I/bgl/BlueLight/ppcfloor/bglsys/include
+CFLAGS-zoid_mapping.c += -I/bgl/BlueLight/ppcfloor/bglsys/include
+endif
Index: sysdeps/blrts/zoid/access.c
===================================================================
RCS file: sysdeps/blrts/zoid/access.c
diff -N sysdeps/blrts/zoid/access.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/access.c	27 Jun 2007 15:20:38 -0000	1.4
@@ -0,0 +1,46 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: access.c,v 1.4 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+
+#include "unix.h"
+
+int
+__access (const char *file, int type)
+{
+  if (file == NULL)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  return unix_decode_result(unix_access(file, type));
+}
+
+weak_alias (__access, access)
Index: sysdeps/blrts/zoid/bgl.h
===================================================================
RCS file: sysdeps/blrts/zoid/bgl.h
diff -N sysdeps/blrts/zoid/bgl.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/bgl.h	27 Jun 2007 15:20:38 -0000	1.7
@@ -0,0 +1,228 @@
+/* Please note that this file is shared between ZOID and GLIBC!  */
+
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: bgl.h,v 1.7 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_ORIG
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#ifndef BGL_H
+#define BGL_H
+
+#include <inttypes.h>
+
+/* Alignment required by the double hammer.  */
+#define QUAD_ALIGN __attribute__((aligned(16)))
+
+/* Double hammer's unit of operation.  */
+typedef struct
+{
+    unsigned int w0;
+    unsigned int w1;
+    unsigned int w2;
+    unsigned int w3;
+}
+BGLQuad QUAD_ALIGN;
+
+#define TREE_PACKET_SIZE 256
+#define TREE_DATA_SIZE 240
+/* Rounds up size to the multiple of *data* size of the packet, i.e. 240 bytes.
+   Used to calculate sizes of buffers, because we always read complete packets
+   from the network.  */
+#define TREE_BUFFER_ROUNDUP(s) (((s) + TREE_DATA_SIZE - 1) / TREE_DATA_SIZE * \
+			   TREE_DATA_SIZE)
+
+/* 4-byte hardware header sent along with the 256-byte packet on the
+   tree/collective network.  */
+
+/* Version for point-to-point communication.  */
+struct BGLTreePacketP2PHardHeader
+{
+    unsigned pclass:4;
+    unsigned p2p:1;
+    unsigned irq:1;
+    unsigned p2paddr:24;
+    unsigned chksum:2;
+};
+
+/* Version for collective communication.  */
+struct BGLTreePacketGlobalHeader
+{
+    unsigned pclass:4;
+    unsigned p2p:1;
+    unsigned irq:1;
+    unsigned opcode:3;
+    unsigned opsize:7;
+    unsigned tag:14;
+    unsigned chksum:2;
+};
+
+typedef union
+{
+    struct BGLTreePacketP2PHardHeader p2p;
+    struct BGLTreePacketGlobalHeader global;
+}
+BGLTreePacketHardHeader;
+
+/* Values of "opcode" field in BGLTreePacketGlobalHeader.  */
+typedef enum
+{
+    BGLTreeCombineOp_NONE = 0,
+    BGLTreeCombineOp_OR = 1,
+    BGLTreeCombineOp_AND = 2,
+    BGLTreeCombineOp_XOR = 3,
+    BGLTreeCombineOp_MAX = 5,
+    BGLTreeCombineOp_ADD = 6
+} BGLTreeCombineOp;
+
+/* Routing class ("pclass" field of hardware headers) encompassing a single
+   pset (an I/O node and its 8-64 compute nodes).  */
+#define PACKET_CLASS_CIO 0
+
+
+/* Tree/collective network hardware status register, for each virtual channel.
+   Allows to find out if there is a message to be received, and also if
+   sending a message is safe (don't send if injection counters are >= 8).  */
+typedef struct
+{
+    unsigned injpktcnt:4;
+    unsigned injquadcnt:4;
+    unsigned dummy0:4;
+    unsigned injhdrcnt:4;
+    unsigned recpktcnt:4;
+    unsigned recquadcnt:4;
+    unsigned dummy1:3;
+    unsigned intheader:1;
+    unsigned rechdrcnt:4;
+} BGLTreeStatusRegister;
+
+/* Structure used as the software header for packets exchanged between the
+   compute node processes and CIOD.  */
+struct CioHeader
+{
+    uint8_t _cpu; /* 0 or 1 */
+    uint8_t _rankInCnodes; /* obtained using BGLPersonality_rankInPset() */
+    uint8_t _reserved;
+    uint8_t _dataSize;
+    uint16_t _treeAddress;
+    uint16_t _messageCode; /* MFC_ or MTC_ constants, e.g. MTC_KILL */
+    uint32_t _packetTotal;
+    uint32_t _packetIndex;
+};
+
+#define PAD(x) char _pad[240 - (x)]
+
+#define MTC_ACK 0xffff
+
+/* A sample packet sent from CIOD to a compute node.  */
+#define MTC_KILL 0xfff0
+struct MTC_Kill
+{
+    struct S_MTC_Kill
+    {
+	unsigned signum;
+    } s;
+    PAD(sizeof(struct S_MTC_Kill));
+} QUAD_ALIGN;
+
+#define MFC_REQUESTEXIT 4
+struct MFC_RequestExit
+{
+    struct S_MFC_RequestExit
+    {
+	enum Reason {EXITED = 0, SIGNALED = 1} reason;
+	int status;
+    } s;
+    PAD(sizeof(struct S_MFC_RequestExit));
+} QUAD_ALIGN;
+
+#define MTC_REPLYEXIT MFC_REQUESTEXIT
+/* No meaningful data is passed in this one.  */
+
+#define MFC_REQUESTRESET 56
+/* No meaningful data is passed in this one.  */
+
+#define MTC_REPLYRESET MFC_REQUESTRESET
+/* No meaningful data is passed in this one.  */
+
+#define MFC_REQUESTWRITECORE 57
+struct MFC_RequestWriteCore
+{
+    struct S_MFC_RequestWriteCore
+    {
+	int size;
+	unsigned int offset;
+    } s;
+    PAD(sizeof(struct S_MFC_RequestWriteCore));
+} QUAD_ALIGN;
+
+#define MFC_REPLYWRITECORE MFC_REQUESTWRITECORE
+struct MTC_ReplyWriteCore
+{
+    struct S_MTC_ReplyWriteCore
+    {
+	int rc;
+	int errnum;
+    } s;
+    PAD(sizeof(struct S_MTC_ReplyWriteCore));
+} QUAD_ALIGN;
+
+/* Header sent with stdout/stderr from ciod to the service node.  */
+struct CiodOutputHeader
+{
+    int fd;
+    int cpu;
+    int node;
+    int rank;
+    int len;
+};
+
+/* Prototypes of low-level communication functions from libdevices.  */
+void BGLTreePacketHardHeader_InitP2P(BGLTreePacketHardHeader* header,
+				     unsigned classroute, int irq, int dst);
+
+void BGLTreePacketHardHeader_InitGlobal(BGLTreePacketHardHeader* header,
+					unsigned classroute, int irq,
+					BGLTreeCombineOp opfunc,
+					int operandsize, int tag);
+
+void BGLTreeFIFO_send(BGLTreePacketHardHeader* hdfifo, BGLQuad* datafifo,
+		      BGLTreePacketHardHeader* hheader, BGLQuad* data);
+
+void BGLTreeFIFO_sendH(BGLTreePacketHardHeader* hdfifo, BGLQuad* datafifo,
+		       BGLTreePacketHardHeader* hheader, BGLQuad* softheader,
+		       BGLQuad* data);
+
+void BGLTreeFIFO_recv(BGLTreePacketHardHeader* hdfifo, BGLQuad* datafifo,
+		      BGLTreePacketHardHeader* hheader, BGLQuad* data);
+
+void BGLTreeFIFO_recvH(BGLTreePacketHardHeader* hdfifo, BGLQuad* datafifo,
+		       BGLTreePacketHardHeader* hheader, BGLQuad* softheader,
+		       BGLQuad* data);
+
+void BGLTreeFIFO_recvF(BGLTreePacketHardHeader* hdfifo, BGLQuad* datafifo,
+		       BGLTreePacketHardHeader* hheader, BGLQuad* softheader,
+		       BGLQuad* (*func)(void* priv, BGLQuad* softheader),
+		       void* priv);
+#endif
Index: sysdeps/blrts/zoid/chdir.c
===================================================================
RCS file: sysdeps/blrts/zoid/chdir.c
diff -N sysdeps/blrts/zoid/chdir.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/chdir.c	27 Jun 2007 15:20:38 -0000	1.4
@@ -0,0 +1,46 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: chdir.c,v 1.4 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+
+#include "unix.h"
+
+int
+__chdir (const char *path)
+{
+  if (path == NULL)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  return unix_decode_result(unix_chdir(path));
+}
+
+weak_alias (__chdir, chdir)
Index: sysdeps/blrts/zoid/chmod.c
===================================================================
RCS file: sysdeps/blrts/zoid/chmod.c
diff -N sysdeps/blrts/zoid/chmod.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/chmod.c	27 Jun 2007 15:20:38 -0000	1.4
@@ -0,0 +1,46 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: chmod.c,v 1.4 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <errno.h>
+#include <stddef.h>
+#include <sys/stat.h>
+
+#include "unix.h"
+
+int
+__chmod (const char *file, mode_t mode)
+{
+  if (file == NULL)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  return unix_decode_result(unix_chmod(file, mode));
+}
+
+weak_alias (__chmod, chmod)
Index: sysdeps/blrts/zoid/chown.c
===================================================================
RCS file: sysdeps/blrts/zoid/chown.c
diff -N sysdeps/blrts/zoid/chown.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/chown.c	27 Jun 2007 15:20:38 -0000	1.4
@@ -0,0 +1,46 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: chown.c,v 1.4 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+
+#include "unix.h"
+
+int
+__chown (const char *file, uid_t owner, gid_t group)
+{
+  if (file == NULL)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  return unix_decode_result(unix_chown(file, owner, group));
+}
+
+weak_alias (__chown, chown)
Index: sysdeps/blrts/zoid/close.c
===================================================================
RCS file: sysdeps/blrts/zoid/close.c
diff -N sysdeps/blrts/zoid/close.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/close.c	27 Jun 2007 15:20:38 -0000	1.5
@@ -0,0 +1,40 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: close.c,v 1.5 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <errno.h>
+#include <unistd.h>
+
+#include "unix.h"
+
+int
+__libc_close (int fd)
+{
+  return unix_decode_result(unix_close(fd));
+}
+
+weak_alias (__libc_close, __close)
+weak_alias (__libc_close, close)
Index: sysdeps/blrts/zoid/connect.c
===================================================================
RCS file: sysdeps/blrts/zoid/connect.c
diff -N sysdeps/blrts/zoid/connect.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/connect.c	27 Jun 2007 15:20:38 -0000	1.4
@@ -0,0 +1,49 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: connect.c,v 1.4 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <errno.h>
+#include <stddef.h>
+#include <sys/socket.h>
+
+#include "unix.h"
+
+/* __CONST_SOCKADDR_ARG is a crappy *union* of pointers, so it can't be
+   directly compared with NULL or cast to a pointer.
+   Who came up with that braindamage?!  */
+int
+__connect (int fd, __CONST_SOCKADDR_ARG addr, socklen_t len)
+{
+  if (addr.__sockaddr__ == NULL)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  return unix_decode_result(unix_connect(fd, (void*)addr.__sockaddr__, len));
+}
+
+weak_alias (__connect, connect)
Index: sysdeps/blrts/zoid/dup.c
===================================================================
RCS file: sysdeps/blrts/zoid/dup.c
diff -N sysdeps/blrts/zoid/dup.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/dup.c	27 Jun 2007 15:20:38 -0000	1.4
@@ -0,0 +1,38 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: dup.c,v 1.4 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <unistd.h>
+
+#include "unix.h"
+
+int
+__dup (int fd)
+{
+    return unix_decode_result(unix_dup(fd));
+}
+
+weak_alias (__dup, dup)
Index: sysdeps/blrts/zoid/dup2.c
===================================================================
RCS file: sysdeps/blrts/zoid/dup2.c
diff -N sysdeps/blrts/zoid/dup2.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/dup2.c	27 Jun 2007 15:20:38 -0000	1.4
@@ -0,0 +1,38 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: dup2.c,v 1.4 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <unistd.h>
+
+#include "unix.h"
+
+int
+__dup2 (int fd, int fd2)
+{
+    return unix_decode_result(unix_dup2(fd, fd2));
+}
+
+weak_alias (__dup2, dup2)
Index: sysdeps/blrts/zoid/fchdir.c
===================================================================
RCS file: sysdeps/blrts/zoid/fchdir.c
diff -N sysdeps/blrts/zoid/fchdir.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/fchdir.c	27 Jun 2007 15:20:38 -0000	1.4
@@ -0,0 +1,38 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: fchdir.c,v 1.4 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <unistd.h>
+
+#include "unix.h"
+
+int
+__fchdir (int fd)
+{
+    return unix_decode_result(unix_fchdir(fd));
+}
+
+weak_alias (__fchdir, fchdir)
Index: sysdeps/blrts/zoid/fchmod.c
===================================================================
RCS file: sysdeps/blrts/zoid/fchmod.c
diff -N sysdeps/blrts/zoid/fchmod.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/fchmod.c	27 Jun 2007 15:20:38 -0000	1.4
@@ -0,0 +1,38 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: fchmod.c,v 1.4 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <sys/stat.h>
+
+#include "unix.h"
+
+int
+__fchmod (int fd, mode_t mode)
+{
+    return unix_decode_result(unix_fchmod(fd, mode));
+}
+
+weak_alias (__fchmod, fchmod)
Index: sysdeps/blrts/zoid/fchown.c
===================================================================
RCS file: sysdeps/blrts/zoid/fchown.c
diff -N sysdeps/blrts/zoid/fchown.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/fchown.c	27 Jun 2007 15:20:38 -0000	1.4
@@ -0,0 +1,38 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: fchown.c,v 1.4 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <unistd.h>
+
+#include "unix.h"
+
+int
+__fchown (int fd, uid_t owner, gid_t group)
+{
+    return unix_decode_result(unix_fchown(fd, owner, group));
+}
+
+weak_alias (__fchown, fchown)
Index: sysdeps/blrts/zoid/fcntl.c
===================================================================
RCS file: sysdeps/blrts/zoid/fcntl.c
diff -N sysdeps/blrts/zoid/fcntl.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/fcntl.c	27 Jun 2007 15:20:38 -0000	1.4
@@ -0,0 +1,83 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: fcntl.c,v 1.4 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <fcntl.h>
+#include <stdarg.h>
+
+#include "unix.h"
+
+int
+__libc_fcntl (int fd, int cmd, ...)
+{
+  va_list ap;
+  void *arg;
+  void *arg_ptr;
+  int arg_len;
+
+  va_start (ap, cmd);
+  arg = va_arg (ap, void *);
+  va_end (ap);
+
+  switch (cmd)
+  {
+      case F_GETFL:
+	  /* Does not take any argument.  */
+	  arg_ptr = NULL;
+	  arg_len = 0;
+	  break;
+
+      case F_SETFL:
+      case F_DUPFD:
+	  /* "arg" is actually a long int, not a pointer.  */
+	  arg_ptr = &arg;
+	  arg_len = sizeof(long);
+	  break;
+
+      case F_GETLK:
+      case F_SETLK:
+      case F_SETLKW:
+	  arg_ptr = arg;
+	  arg_len = sizeof(struct flock);
+	  break;
+
+      case F_GETLK64:
+      case F_SETLK64:
+      case F_SETLKW64:
+	  arg_ptr = arg;
+	  arg_len = sizeof(struct flock64);
+	  break;
+
+      default:
+	  __set_errno(EINVAL);
+	  return -1;
+  }
+
+  return unix_decode_result(unix_fcntl(fd, cmd, arg_ptr, &arg_len));
+}
+
+weak_alias (__libc_fcntl, __fcntl)
+weak_alias (__libc_fcntl, fcntl)
Index: sysdeps/blrts/zoid/fstatfs.c
===================================================================
RCS file: sysdeps/blrts/zoid/fstatfs.c
diff -N sysdeps/blrts/zoid/fstatfs.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/fstatfs.c	27 Jun 2007 15:20:38 -0000	1.2
@@ -0,0 +1,38 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: fstatfs.c,v 1.2 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <sys/statfs.h>
+
+#include "unix.h"
+
+int
+__fstatfs (int fd, struct statfs *buf)
+{
+    return unix_decode_result(unix_fstatfs(fd, buf));
+}
+
+weak_alias (__fstatfs, fstatfs)
Index: sysdeps/blrts/zoid/fstatfs64.c
===================================================================
RCS file: sysdeps/blrts/zoid/fstatfs64.c
diff -N sysdeps/blrts/zoid/fstatfs64.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/fstatfs64.c	27 Jun 2007 15:20:38 -0000	1.2
@@ -0,0 +1,38 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: fstatfs64.c,v 1.2 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <sys/statfs.h>
+
+#include "unix.h"
+
+int
+__fstatfs64 (int fd, struct statfs64 *buf)
+{
+    return unix_decode_result(unix_fstatfs64(fd, buf));
+}
+
+weak_alias (__fstatfs64, fstatfs64)
Index: sysdeps/blrts/zoid/fsync.c
===================================================================
RCS file: sysdeps/blrts/zoid/fsync.c
diff -N sysdeps/blrts/zoid/fsync.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/fsync.c	27 Jun 2007 15:20:38 -0000	1.4
@@ -0,0 +1,38 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: fsync.c,v 1.4 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <unistd.h>
+
+#include "unix.h"
+
+int
+__libc_fsync (int fd)
+{
+    return unix_decode_result(unix_fsync(fd));
+}
+
+weak_alias (__libc_fsync, fsync)
Index: sysdeps/blrts/zoid/ftruncate.c
===================================================================
RCS file: sysdeps/blrts/zoid/ftruncate.c
diff -N sysdeps/blrts/zoid/ftruncate.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/ftruncate.c	27 Jun 2007 15:20:38 -0000	1.4
@@ -0,0 +1,38 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: ftruncate.c,v 1.4 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <unistd.h>
+
+#include "unix.h"
+
+int
+__ftruncate (int fd, off_t length)
+{
+    return unix_decode_result(unix_ftruncate(fd, length));
+}
+
+weak_alias (__ftruncate, ftruncate)
Index: sysdeps/blrts/zoid/ftruncate64.c
===================================================================
RCS file: sysdeps/blrts/zoid/ftruncate64.c
diff -N sysdeps/blrts/zoid/ftruncate64.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/ftruncate64.c	27 Jun 2007 15:20:38 -0000	1.4
@@ -0,0 +1,38 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: ftruncate64.c,v 1.4 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <unistd.h>
+
+#include "unix.h"
+
+int
+__ftruncate64 (int fd, off64_t length)
+{
+    return unix_decode_result(unix_ftruncate64(fd, length));
+}
+
+weak_alias (__ftruncate64, ftruncate64)
Index: sysdeps/blrts/zoid/fxstat.c
===================================================================
RCS file: sysdeps/blrts/zoid/fxstat.c
diff -N sysdeps/blrts/zoid/fxstat.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/fxstat.c	27 Jun 2007 15:20:38 -0000	1.6
@@ -0,0 +1,52 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: fxstat.c,v 1.6 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <errno.h>
+#include <stddef.h>
+#include <sys/stat.h>
+
+#include "unix.h"
+
+int
+__fxstat (int vers, int fd, struct stat *buf)
+{
+  if (vers != 0 || buf == NULL)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  return unix_decode_result(unix_fstat(fd, &buf->st_mode, &buf->st_ino,
+				       &buf->st_dev, &buf->st_nlink,
+				       &buf->st_uid, &buf->st_gid,
+				       &buf->st_size, &buf->st_atime,
+				       &buf->st_mtime, &buf->st_ctime,
+				       &buf->st_rdev, &buf->st_blksize,
+				       &buf->st_blocks));
+}
+
+weak_alias (__fxstat, _fxstat)
Index: sysdeps/blrts/zoid/fxstat64.c
===================================================================
RCS file: sysdeps/blrts/zoid/fxstat64.c
diff -N sysdeps/blrts/zoid/fxstat64.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/fxstat64.c	27 Jun 2007 15:20:38 -0000	1.6
@@ -0,0 +1,50 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: fxstat64.c,v 1.6 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <errno.h>
+#include <stddef.h>
+#include <sys/stat.h>
+
+#include "unix.h"
+
+int
+__fxstat64 (int vers, int fd, struct stat64 *buf)
+{
+  if (vers != 0 || buf == NULL)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  return unix_decode_result(unix_fstat64(fd, &buf->st_mode, &buf->st_ino,
+					 &buf->st_dev, &buf->st_nlink,
+					 &buf->st_uid, &buf->st_gid,
+					 &buf->st_size, &buf->st_atime,
+					 &buf->st_mtime, &buf->st_ctime,
+					 &buf->st_rdev, &buf->st_blksize,
+					 &buf->st_blocks));
+}
Index: sysdeps/blrts/zoid/getcwd.c
===================================================================
RCS file: sysdeps/blrts/zoid/getcwd.c
diff -N sysdeps/blrts/zoid/getcwd.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/getcwd.c	27 Jun 2007 15:20:38 -0000	1.3
@@ -0,0 +1,92 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: getcwd.c,v 1.3 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+/* Copied from sysdeps/blrts/getcwd.c and modified for zoid. */
+
+#include <assert.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "unix.h"
+
+char *
+__getcwd (char *buf, size_t size)
+{
+  char *path;
+  size_t alloc_size = size;
+  int retval;
+
+  if (size == 0)  {
+     if (buf != NULL) {
+        __set_errno (EINVAL);
+        return NULL;
+     }
+
+     alloc_size = PATH_MAX;
+  }
+
+  if (buf != NULL) {
+     path = buf;
+  }
+  else {
+      path = malloc (alloc_size);
+      if (path == NULL) {
+         return NULL;
+      }
+  }
+
+  retval = unix_decode_result(unix_getcwd(path, alloc_size));
+  if (retval >= 0) {
+	  if (buf == NULL && size == 0) {
+        /* Ensure that the buffer is only as large as necessary.  */
+        buf = realloc (path, (size_t) retval);
+     }
+
+     if (buf == NULL) {
+        /* Either buf was NULL all along, or `realloc' failed but
+           we still have the original string.  */
+        buf = path;
+     }
+
+	  return buf;
+  }
+
+  /* It should never happen that the `getcwd' syscall failed because
+     the buffer is too small if we allocated the buffer ourselves
+	  large enough.  */
+  assert (errno != ERANGE || buf != NULL || size != 0);
+
+  if (buf == NULL) {
+     free (path);
+  }
+
+  return NULL;
+}
+
+weak_alias (__getcwd, getcwd)
Index: sysdeps/blrts/zoid/getdents.c
===================================================================
RCS file: sysdeps/blrts/zoid/getdents.c
diff -N sysdeps/blrts/zoid/getdents.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/getdents.c	27 Jun 2007 15:20:38 -0000	1.4
@@ -0,0 +1,43 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: getdents.c,v 1.4 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <dirent.h>
+#include <errno.h>
+
+#include "unix.h"
+
+ssize_t
+__getdents (int fd, char *buf, size_t nbytes)
+{
+    if (!buf)
+    {
+	__set_errno(EINVAL);
+	return -1;
+    }
+
+    return unix_decode_result(unix_getdents(fd, buf, nbytes));
+}
Index: sysdeps/blrts/zoid/getdents64.c
===================================================================
RCS file: sysdeps/blrts/zoid/getdents64.c
diff -N sysdeps/blrts/zoid/getdents64.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/getdents64.c	27 Jun 2007 15:20:38 -0000	1.4
@@ -0,0 +1,43 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: getdents64.c,v 1.4 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <dirent.h>
+#include <errno.h>
+
+#include "unix.h"
+
+ssize_t
+__getdents64 (int fd, char *buf, size_t nbytes)
+{
+    if (!buf)
+    {
+	__set_errno(EINVAL);
+	return -1;
+    }
+
+    return unix_decode_result(unix_getdents64(fd, buf, nbytes));
+}
Index: sysdeps/blrts/zoid/getgid.c
===================================================================
RCS file: sysdeps/blrts/zoid/getgid.c
diff -N sysdeps/blrts/zoid/getgid.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/getgid.c	27 Jun 2007 15:20:38 -0000	1.5
@@ -0,0 +1,54 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: getgid.c,v 1.5 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <unistd.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+
+/* We don't really need to redefine this call, because it's local, but since
+   the overhead of system calls on BLRTS is not insignificant, we might just
+   as well provide a cache...  */
+
+extern gid_t __syscall_getgid(void);
+
+gid_t
+__getgid (void)
+{
+    static gid_t cached;
+    static int cache_initialized;
+
+    if (!cache_initialized)
+    {
+	cached = INLINE_SYSCALL(getgid, 0);
+	cache_initialized = 1;
+    }
+
+    return cached;
+}
+
+weak_alias (__getgid, getgid)
Index: sysdeps/blrts/zoid/getpeername.c
===================================================================
RCS file: sysdeps/blrts/zoid/getpeername.c
diff -N sysdeps/blrts/zoid/getpeername.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/getpeername.c	27 Jun 2007 15:20:38 -0000	1.4
@@ -0,0 +1,46 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: getpeername.c,v 1.4 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <errno.h>
+#include <stddef.h>
+#include <sys/socket.h>
+
+#include "unix.h"
+
+int
+__getpeername (int fd, __SOCKADDR_ARG addr, socklen_t *len)
+{
+  if (addr.__sockaddr__ == NULL)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  return unix_decode_result(unix_getpeername(fd, addr.__sockaddr__, len));
+}
+
+weak_alias (__getpeername, getpeername)
Index: sysdeps/blrts/zoid/getpid.c
===================================================================
RCS file: sysdeps/blrts/zoid/getpid.c
diff -N sysdeps/blrts/zoid/getpid.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/getpid.c	27 Jun 2007 15:20:38 -0000	1.5
@@ -0,0 +1,54 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: getpid.c,v 1.5 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <unistd.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+
+/* We don't really need to redefine this call, because it's local, but since
+   the overhead of system calls on BLRTS is not insignificant, we might just
+   as well provide a cache...  */
+
+extern pid_t __syscall_getpid(void);
+
+pid_t
+__getpid (void)
+{
+    static pid_t cached;
+    static int cache_initialized;
+
+    if (!cache_initialized)
+    {
+	cached = INLINE_SYSCALL(getpid, 0);
+	cache_initialized = 1;
+    }
+
+    return cached;
+}
+
+weak_alias (__getpid, getpid)
Index: sysdeps/blrts/zoid/getsockname.c
===================================================================
RCS file: sysdeps/blrts/zoid/getsockname.c
diff -N sysdeps/blrts/zoid/getsockname.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/getsockname.c	27 Jun 2007 15:20:38 -0000	1.4
@@ -0,0 +1,46 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: getsockname.c,v 1.4 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <errno.h>
+#include <stddef.h>
+#include <sys/socket.h>
+
+#include "unix.h"
+
+int
+__getsockname (int fd, __SOCKADDR_ARG addr, socklen_t *len)
+{
+  if (addr.__sockaddr__ == NULL)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  return unix_decode_result(unix_getsockname(fd, addr.__sockaddr__, len));
+}
+
+weak_alias (__getsockname, getsockname)
Index: sysdeps/blrts/zoid/getsockopt.c
===================================================================
RCS file: sysdeps/blrts/zoid/getsockopt.c
diff -N sysdeps/blrts/zoid/getsockopt.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/getsockopt.c	27 Jun 2007 15:20:38 -0000	1.4
@@ -0,0 +1,37 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: getsockopt.c,v 1.4 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <sys/socket.h>
+
+#include "unix.h"
+
+int
+getsockopt (int fd, int level, int optname, void *optval, socklen_t *optlen)
+{
+  return unix_decode_result(unix_getsockopt(fd, level, optname, optval,
+					    optlen));
+}
Index: sysdeps/blrts/zoid/getuid.c
===================================================================
RCS file: sysdeps/blrts/zoid/getuid.c
diff -N sysdeps/blrts/zoid/getuid.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/getuid.c	27 Jun 2007 15:20:38 -0000	1.5
@@ -0,0 +1,54 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: getuid.c,v 1.5 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <unistd.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+
+/* We don't really need to redefine this call, because it's local, but since
+   the overhead of system calls on BLRTS is not insignificant, we might just
+   as well provide a cache...  */
+
+extern uid_t __syscall_getuid(void);
+
+uid_t
+__getuid (void)
+{
+    static uid_t cached;
+    static int cache_initialized;
+
+    if (!cache_initialized)
+    {
+	cached = INLINE_SYSCALL(getuid, 0);
+	cache_initialized = 1;
+    }
+
+    return cached;
+}
+
+weak_alias (__getuid, getuid)
Index: sysdeps/blrts/zoid/init-zoid.c
===================================================================
RCS file: sysdeps/blrts/zoid/init-zoid.c
diff -N sysdeps/blrts/zoid/init-zoid.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/init-zoid.c	27 Jun 2007 15:20:38 -0000	1.18
@@ -0,0 +1,1091 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: init-zoid.c,v 1.18 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_ORIG
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <errno.h>
+#include <unistd.h>
+
+#include <bgllockbox.h>
+#include <bglmemmap.h>
+#include <rts.h>
+
+#include "bgl.h"
+#include "zoid_api.h"
+#include "zoid_mapping.h"
+#include "zoid_protocol.h"
+
+/* A structure we maintain in scratchpad, to exchange first packets read from
+   the tree that were meant for the other CPU (in VN mode).  */
+struct vn_shared
+{
+    int cpu; /* 0 for primary, 1 for secondary, -1 if not in use */
+    char pad[12]; /* To guarantee quad-alignment for packet.  */
+    struct ZoidSoftHeader softheader;
+    char packet[TREE_DATA_SIZE];
+} QUAD_ALIGN;
+
+static int __zoid_vn_mode;
+int __zoid_process_count;
+
+static const char* mpi_mapping;
+
+static void* stub_buffer = NULL;
+static size_t stub_buffer_size = 0;
+
+static int my_p2p_addr, ion_p2p_addr, my_pset_rank, pset_size;
+
+/* 0 if this is the primary processor (in VN mode).  */
+static int my_cpu_id;
+
+/* Tree access mutexes for VN mode.  Used mainly for VC0, but occassionally
+   (when MPI code is not running) also for VC1.  */
+static struct BGL_Mutex *read_mutex, *write_mutex;
+
+static void* other_process_window;
+static unsigned int other_process_size;
+
+static char packet[TREE_PACKET_SIZE] QUAD_ALIGN;
+
+/* Only accessed if a process holds the read_mutex.  */
+static volatile struct vn_shared* vn_shared;
+
+static int last_errnum, last_excessive_size;
+
+static int max_buffer_size;
+static int ack_threshold;
+
+static void __zoid_test_vc0(void) __attribute__((noinline));
+
+/* Assert replacement.  We can't use ordinary assert here, because it
+   wants to print to stderr, while we die in a middle of handling another
+   command.  */
+static void my_assert_fail(const char *assertion, const char *file,
+			   unsigned int line, const char *function);
+#define my_assert(expr) \
+  ((expr) ? 0 : \
+   (my_assert_fail(#expr, __FILE__, __LINE__, __PRETTY_FUNCTION__), 0))
+
+/*
+ * Zoid initialization function.  Runs before main().  Performs a handshake
+ * with zoid on ION, exchanging information on job size, maximum buffer sizes,
+ * etc.
+ * FIXME: currently could run after other constructors.  We might want to move
+ * it into __init_misc.
+ */
+void __init_zoid(void) __attribute__((constructor));
+void
+__init_zoid(void)
+{
+    BGLTreeStatusRegister status;
+    BGLTreePacketHardHeader hardheader;
+    BGLPersonality personality;
+    const char* env;
+    static int vn_sync;
+
+    if (rts_get_personality(&personality, sizeof(personality)))
+	abort();
+
+    __zoid_vn_mode = BGLPersonality_virtualNodeMode(&personality);
+    my_p2p_addr = BGLPersonality_treeP2PAddr(&personality);
+    ion_p2p_addr = BGLPersonality_treeIONodeP2PAddr(&personality);
+    my_pset_rank = BGLPersonality_rankInPset(&personality);
+    pset_size = BGLPersonality_numNodesInPset(&personality);
+
+    my_cpu_id = rts_get_processor_id();
+
+    if ((env = getenv("BGLMPI_SIZE")))
+    {
+	if (!(__zoid_process_count = strtol(env, NULL, 10)))
+	    abort();
+    }
+    else
+    {
+	/* This happens if invoking mpirun directly, without specifying
+	   -np.  In that case the partition is completely full.  */
+	__zoid_process_count = BGLPersonality_numComputeNodes(&personality)
+	    * (__zoid_vn_mode ? 2 : 1);
+    }
+
+    /* User can specify alternative mapping.  It's a bit of a pain in the
+       neck, as user-supplied data might be erroneous, and we don't really
+       know how IBM code handles such errors...  */
+    if (!(mpi_mapping = getenv("BGLMPI_MAPPING")))
+	mpi_mapping = "XYZT";
+    if (__zoid_mapping_init(mpi_mapping, __zoid_process_count, __zoid_vn_mode,
+			    &personality))
+	abort();
+
+    if (__zoid_vn_mode && my_cpu_id == 0)
+    {
+	/* Check if CPU 1 is active.  If not, pretend that we are not in
+	   VN mode, so as to avoid any overheads.  */
+
+	unsigned rank;
+	if (__zoid_mapping_to_rank(BGLPersonality_xCoord(&personality),
+				   BGLPersonality_yCoord(&personality),
+				   BGLPersonality_zCoord(&personality),
+				   1, &rank) == -1)
+	    __zoid_vn_mode = 0;
+    }
+
+    if (__zoid_vn_mode)
+    {
+	void* scratch_window;
+	unsigned int scratch_size;
+
+	if (rts_get_virtual_process_window(&other_process_window,
+					   &other_process_size) ||
+	    rts_get_scratchpad_window(&scratch_window, &scratch_size))
+	{
+	    abort();
+	}
+
+	/* We allocate from the top of the window, since msglayer seems to
+	   be doing it from the bottom.  We can't use msglayer stuff here,
+	   because msglayer might not be linked in, and would anyway not
+	   yet be initialized at this point.  */
+	vn_shared = scratch_window + scratch_size - sizeof(*vn_shared);
+
+	if (my_cpu_id == 0)
+	{
+	    /* Primary CPU.  */
+	    void* aligned;
+
+	    vn_shared->cpu = -1;
+
+	    if (!(read_mutex = rts_allocate_mutex()) ||
+		!(write_mutex = rts_allocate_mutex()))
+	    {
+		abort();
+	    }
+
+	    aligned = (void*)(((unsigned int)&read_mutex) & ~0x1f);
+	    rts_dcache_store(aligned, aligned + 0x20);
+	    aligned = (void*)(((unsigned int)&write_mutex) & ~0x1f);
+	    rts_dcache_store(aligned, aligned + 0x20);
+	}
+	else
+	{
+	    /* We are reading the address of the allocated mutex directly from
+	       the memory of the primary process.  */
+	    struct BGL_Mutex* volatile * primary_read_mutex_ptr =
+		other_process_window + (unsigned int)&read_mutex;
+	    struct BGL_Mutex* volatile * primary_write_mutex_ptr =
+		other_process_window + (unsigned int)&write_mutex;
+
+	    while (!*primary_read_mutex_ptr)
+		;
+	    read_mutex = *primary_read_mutex_ptr;
+
+	    while (!*primary_write_mutex_ptr)
+		;
+	    write_mutex = *primary_write_mutex_ptr;
+	}
+    }
+
+    __zoid_test_vc0();
+
+    /* Send a wakeup notification to ZOID.  For VN mode, we make both
+       processes send it.  Not sure if that's needed, but it won't hurt.  */
+    BGLTreePacketHardHeader_InitP2P(&hardheader, PACKET_CLASS_CIO, 0,
+				    ion_p2p_addr);
+    /* Since this packet goes over VC1, not VC0, we don't bother with
+       ZoidSoftHeader.  Instead, we put extended information about the
+       process and job, to ease zoid's work.  */
+    ((struct InitMsg*)packet)->pset_cpu_rank = my_pset_rank +
+	my_cpu_id * pset_size;
+    ((struct InitMsg*)packet)->p2p_addr = my_p2p_addr;
+    ((struct InitMsg*)packet)->pid = getpid();
+    ((struct InitMsg*)packet)->pset_rank = my_pset_rank;
+    ((struct InitMsg*)packet)->cpu = my_cpu_id;
+    /* We can't use __zoid_vn_mode below, because we could have reset it
+       above.  */
+    ((struct InitMsg*)packet)->vn_mode =
+	BGLPersonality_virtualNodeMode(&personality);
+    ((struct InitMsg*)packet)->total_proc = __zoid_process_count;
+    strcpy(((struct InitMsg*)packet)->mapping, mpi_mapping);
+
+    if (write_mutex)
+	BGL_Mutex_Acquire(write_mutex);
+    do
+    {
+	status = *(volatile BGLTreeStatusRegister*)BGL_MEM_TREE_VC1_STATUS0;
+    } while (status.injpktcnt > 7);
+    BGLTreeFIFO_send((BGLTreePacketHardHeader*)BGL_MEM_TREE_VC1_HDRIN,
+		     (BGLQuad*)BGL_MEM_TREE_VC1_DATAIN,
+		     &hardheader, (BGLQuad*)packet);
+    if (write_mutex)
+	BGL_Mutex_Release(write_mutex);
+
+    /* Wait until ZOID suspends CIOD and sends us an ACK.  The ACKs are only
+       sent once per each node, so in VN mode we use the primary process to
+       receive them.  */
+    if (my_cpu_id == 0)
+    {
+	/* Mutex not needed here; the other core is spinning.  */
+
+	do
+	{
+	    status = *(volatile BGLTreeStatusRegister*)
+		BGL_MEM_TREE_VC1_STATUS0;
+	} while (status.recpktcnt == 0);
+
+	BGLTreeFIFO_recv((BGLTreePacketHardHeader*)BGL_MEM_TREE_VC1_HDROUT,
+			 (BGLQuad*)BGL_MEM_TREE_VC1_DATAOUT,
+			 &hardheader, (BGLQuad*)packet);
+
+	if (hardheader.p2p.pclass != PACKET_CLASS_CIO)
+	    abort();
+
+	max_buffer_size = ((struct InitMsgReply*)packet)->max_buffer_size;
+	ack_threshold = ((struct InitMsgReply*)packet)->ack_threshold;
+
+	if (__zoid_vn_mode)
+	{
+	    void* aligned;
+
+	    aligned = (void*)(((unsigned int)&max_buffer_size) & ~0x1f);
+	    rts_dcache_store(aligned, aligned + 0x20);
+	    aligned = (void*)(((unsigned int)&ack_threshold) & ~0x1f);
+	    rts_dcache_store(aligned, aligned + 0x20);
+
+	    vn_sync = 1;
+	    aligned = (void*)(((unsigned int)&vn_sync) & ~0x1f);
+	    rts_dcache_store(aligned, aligned + 0x20);
+	}
+    }
+    else
+    {
+	/* Virtual node, co-processor.  */
+	volatile int* vn_sync_ptr = other_process_window +
+	    (unsigned int)&vn_sync;
+	volatile int* max_buffer_size_ptr = other_process_window +
+	    (unsigned int)&max_buffer_size;
+	volatile int* ack_threshold_ptr = other_process_window +
+	    (unsigned int)&ack_threshold;
+
+	/* Wait for primary process to receive an ACK.  */
+	while (!*vn_sync_ptr)
+	    ;
+
+	max_buffer_size = *max_buffer_size_ptr;
+	ack_threshold = *ack_threshold_ptr;
+    }
+
+    /* ZOID initialization is finished.  We can use I/O from this point on.  */
+}
+
+/*
+ * Zoid termination function.  Runs from exit(), after all the atexit
+ * functions.  Performs a final message exchange with zoid daemon to ensure
+ * that there are no zoid packets in the network by the time the control
+ * returns to the kernel.
+ */
+void
+_cleanup(void)
+{
+    struct ZoidSoftHeader softheader, *softheader_p = &softheader;
+    BGLTreeStatusRegister status;
+    BGLTreePacketHardHeader hardheader;
+    int command;
+    static int vn_sync, vn_sync_2;
+
+    /* Normally _IO_cleanup is a weak alias to _cleanup, but since we override
+       _cleanup, we need to invoke the IO cleanup explicitly.  */
+    extern void _IO_cleanup(void);
+    _IO_cleanup();
+
+    /* No more user-level zoid packets to exchange.
+       Send terminating packet.  */
+    BGLTreePacketHardHeader_InitP2P(&hardheader, PACKET_CLASS_CIO, 0,
+				    ion_p2p_addr);
+    softheader.zoid_id = ZOID_ID;
+    softheader.pset_cpu_rank = my_pset_rank + my_cpu_id * pset_size;
+    softheader.flags = ZOID_SOFTHEADER_FIRST_PACKET |
+	ZOID_SOFTHEADER_LAST_PACKET;
+    softheader.msg_length = sizeof(int);
+
+    command = ZOID_TERMINATING_ID;
+    memcpy(packet, &command, sizeof(command));
+
+    if (write_mutex)
+	BGL_Mutex_Acquire(write_mutex);
+    do
+    {
+	status = *(volatile BGLTreeStatusRegister*)BGL_MEM_TREE_VC0_STATUS0;
+    } while (status.injpktcnt > 7);
+    BGLTreeFIFO_sendH((BGLTreePacketHardHeader*)BGL_MEM_TREE_VC0_HDRIN,
+		      (BGLQuad*)BGL_MEM_TREE_VC0_DATAIN,
+		      &hardheader, (BGLQuad*)softheader_p, (BGLQuad*)packet);
+    if (write_mutex)
+	BGL_Mutex_Release(write_mutex);
+
+    if (__zoid_vn_mode)
+    {
+	/* Wait for the other process on the node to terminate.  This way
+	   we avoid the problem of receiving messages which are not for us,
+	   should the other process decide to communicate with zoid for a
+	   little while longer.  */
+	volatile int* vn_sync_ptr = other_process_window +
+	    (unsigned int)&vn_sync;
+	void* aligned;
+
+	/* Change own status to "reached the barrier".  */
+	vn_sync = 1;
+	aligned = (void*)(((unsigned int)&vn_sync) & ~0x1f);
+	rts_dcache_store(aligned, aligned + 0x20);
+
+	/* Wait until the other process does the same on its side.  */
+	while (!*vn_sync_ptr)
+	    ;
+    }
+
+    /* At this point we are guaranteed that there are no packets traveling
+       between this node and zoid, in either direction.  */
+    if (my_cpu_id == 0)
+    {
+	void* aligned;
+	/* Wait for an acknowledgement from zoid.  */
+
+	/* No need to use the mutex anymore.  */
+	do
+	{
+	    status = *(volatile BGLTreeStatusRegister*)
+		BGL_MEM_TREE_VC0_STATUS0;
+	} while (status.recpktcnt == 0);
+
+	BGLTreeFIFO_recv((BGLTreePacketHardHeader*)BGL_MEM_TREE_VC0_HDROUT,
+			 (BGLQuad*)BGL_MEM_TREE_VC0_DATAOUT,
+			 &hardheader, (BGLQuad*)packet);
+	/* Nothing useful is provided in the message.  */
+
+	if (__zoid_vn_mode)
+	{
+	    /* Notify the other process that we are done.  */
+	    vn_sync_2 = 1;
+	    aligned = (void*)(((unsigned int)&vn_sync_2) & ~0x1f);
+	    rts_dcache_store(aligned, aligned + 0x20);
+	}
+    }
+    else
+    {
+	/* Wait for a notification from the primary process.  */
+	volatile int* vn_sync_2_ptr = other_process_window +
+	    (unsigned int)&vn_sync_2;
+
+	while (!*vn_sync_2_ptr)
+	    ;
+    }
+
+    /* Kiss-of-death exchanged; time to terminate.  */
+}
+
+/* This function is invoked from the stubs.  It sends the command over the
+   collective/tree network to the I/O node, waits for a result and returns
+   it.  It does not interpret either the command or the result in any way.
+
+   Support for zero-copy makes things a bit more tricky, as some
+   interpretation of the zero-copy arguments is required.  For example, if
+   2-d array is passed as input, then the 1-d array with sizes is expected to
+   be of size size_t*.  Results are interpreted for zero-copy results, because
+   they contain embedded size information (see zoid_protocol.h for details).
+*/
+int
+__zoid_submit_command(char* buffer, int cmd_len, int max_res_len, int userbuf,
+		      const void* arr2d, const void* arr,
+		      int arr_cnt, int arr_el_size, void* out_arr)
+{
+    BGLTreePacketHardHeader hardheader;
+    struct ZoidSoftHeader softheader, *softheader_p = &softheader;
+    char* in_buf_current;
+    int in_len_remaining;
+    int result_len = 0; /* To shut GCC up.  */
+    int total_in_len;
+    int pkt_count, ack_count;
+    char *result_current = buffer;
+    /* Reply always consists of at least one packet, so setting
+       result_remaining to TREE_DATA_SIZE should be OK.  */
+    int result_remaining = TREE_DATA_SIZE;
+    /* The reason for result_remaining_extra is to adjust the length
+       to be read by sizeof(int) for 2-D arrays, which store the length
+       of the next segment at the end of each zero-copy data block.  Since
+       initial block is not 0c, it is set to 0 for now.  */
+    int result_remaining_extra = 0;
+    /* These index the 2-D zero-copy results.  zeroc_max specifies the
+       number of array lines, or -1 if 1-D result is being passed (a value
+       of -2 indicates that the variable is not initialized yet).  zeroc_idx
+       is simply an index from 0 to zeroc_max - 1. */
+    int zeroc_idx = -1, zeroc_max = -2;
+    int next_chunk_len;
+    char* data_buf = result_current;
+
+    my_assert(((unsigned int)buffer & 0xf) == 0);
+
+    BGLTreePacketHardHeader_InitP2P(&hardheader, PACKET_CLASS_CIO, 0,
+				    ion_p2p_addr);
+
+    /* Calculate total size of zero-copy case.
+       The command buffer always has enough space to round up to the full
+       packet size (__zoid_allocate_buffer takes care of that).
+       The zero-copy data always begins on the packet boundary for simplicity
+       reasons.  In case of arr2d, each segment begins on the packet boundary.
+    */
+    total_in_len = cmd_len;
+    cmd_len = TREE_BUFFER_ROUNDUP(cmd_len);
+    if (!userbuf)
+    {
+	if (arr2d)
+	{
+	    int i;
+
+	    for (i = 0; i < arr_cnt; i++)
+	    {
+		total_in_len = TREE_BUFFER_ROUNDUP(total_in_len);
+		total_in_len += ((size_t*)arr)[i] * arr_el_size;
+	    }
+	}
+	else if (arr)
+	{
+	    total_in_len = TREE_BUFFER_ROUNDUP(total_in_len);
+	    total_in_len += arr_cnt * arr_el_size;
+	}
+    }
+
+    if (total_in_len > max_buffer_size)
+    {
+	last_errnum = E2BIG;
+	last_excessive_size = total_in_len - max_buffer_size;
+	return -1;
+    }
+
+    /* Initialize the softheader for the first packet.  */
+    softheader.zoid_id = ZOID_ID;
+    softheader.pset_cpu_rank = my_pset_rank + my_cpu_id * pset_size;
+    softheader.flags = ZOID_SOFTHEADER_FIRST_PACKET;
+    softheader.msg_length = total_in_len;
+
+    in_buf_current = buffer;
+    in_len_remaining = cmd_len;
+
+    if (userbuf)
+	ack_count = in_len_remaining / TREE_DATA_SIZE - 1;
+    else if (ack_threshold && total_in_len > ack_threshold * TREE_DATA_SIZE)
+	ack_count = 0;
+    else
+	ack_count = -1;
+
+    if (write_mutex)
+	BGL_Mutex_Acquire(write_mutex);
+    /* Send message.  */
+    for (pkt_count = 0; in_len_remaining > 0; pkt_count++)
+    {
+	BGLTreeStatusRegister status;
+	char* send_data_buf = in_buf_current;
+
+	if (in_len_remaining < TREE_DATA_SIZE ||
+	    (((unsigned int)in_buf_current) & 0xf))
+	{
+	    /* This code is only triggered for zero-copy data.  We copy to
+	       an intermediate buffer if the size is less than the full packet,
+	       or if data is not properly aligned.  */
+	    memcpy(packet, in_buf_current, in_len_remaining < TREE_DATA_SIZE ?
+		   in_len_remaining : TREE_DATA_SIZE);
+	    send_data_buf = packet;
+	}
+
+	/* Is this the last packet?  */
+	if (in_len_remaining <= TREE_DATA_SIZE &&
+	    (arr2d ? zeroc_idx == arr_cnt - 1 : (!arr || zeroc_idx != -1)))
+		softheader.flags |= ZOID_SOFTHEADER_LAST_PACKET;
+
+	if (pkt_count == ack_count)
+	    softheader.flags |= (userbuf ?
+				 ZOID_SOFTHEADER_INPUT_USERBUF_PACKET :
+				 ZOID_SOFTHEADER_NEED_ACK_PACKET);
+
+	do
+	{
+	    status = *(volatile BGLTreeStatusRegister*)
+		BGL_MEM_TREE_VC0_STATUS0;
+	} while (status.injpktcnt > 7);
+	BGLTreeFIFO_sendH((BGLTreePacketHardHeader*)BGL_MEM_TREE_VC0_HDRIN,
+			  (BGLQuad*)BGL_MEM_TREE_VC0_DATAIN, &hardheader,
+			  (BGLQuad*)softheader_p, (BGLQuad*)send_data_buf);
+
+	in_len_remaining -= TREE_DATA_SIZE;
+	in_buf_current += TREE_DATA_SIZE;
+
+	if (in_len_remaining <= 0)
+	{
+	    if (arr2d)
+	    {
+		/* We make it a loop to properly handle a case when some
+		   of the array entries would have zero length.  */
+		for (zeroc_idx++; zeroc_idx < arr_cnt; zeroc_idx++)
+		{
+		    in_buf_current = ((void**)arr2d)[zeroc_idx];
+		    in_len_remaining = ((size_t*)arr)[zeroc_idx] * arr_el_size;
+		    if (in_len_remaining)
+			break;
+		}
+	    }
+	    else if (arr)
+	    {
+		if (++zeroc_idx == 0)
+		{
+		    in_buf_current = (char*)arr;
+		    in_len_remaining = arr_cnt * arr_el_size;
+		}
+	    }
+	}
+
+	softheader.flags = 0;
+
+	if (pkt_count == ack_count)
+	{
+	    struct ZoidSoftHeader ack_softheader,
+		*ack_softheader_p = &ack_softheader;
+	    /* We have to wait for an ACK from the server before we can send
+	       the rest of the command.  */
+
+	    if (write_mutex)
+		BGL_Mutex_Release(write_mutex);
+
+	    /* The code below is mostly a copy of part of the standard message
+	       receiving code (further down), so look for explanations
+	       there.  And, keep them in sync!  */
+	    for (;;)
+	    {
+		BGLTreePacketHardHeader ack_hardheader;
+		int cpu;
+
+		if (read_mutex)
+		    BGL_Mutex_Acquire(read_mutex);
+
+		if (__zoid_vn_mode && vn_shared->cpu >= 0)
+		{
+		    if (vn_shared->cpu == my_cpu_id)
+		    {
+			ack_softheader = vn_shared->softheader;
+			memcpy(packet, (void*)vn_shared->packet,
+			       TREE_DATA_SIZE);
+
+			vn_shared->cpu = -1;
+
+			/* We are awaiting a single-packet reply, so we are
+			   basically done.  */
+			if (read_mutex)
+			    BGL_Mutex_Release(read_mutex);
+			break;
+		    }
+		    else
+		    {
+			if (read_mutex)
+			    BGL_Mutex_Release(read_mutex);
+			continue;
+		    }
+		}
+
+		do
+		{
+		    status = *(volatile BGLTreeStatusRegister*)
+			BGL_MEM_TREE_VC0_STATUS0;
+		} while (status.recpktcnt == 0);
+		BGLTreeFIFO_recvH((BGLTreePacketHardHeader*)
+				  BGL_MEM_TREE_VC0_HDROUT,
+				  (BGLQuad*)BGL_MEM_TREE_VC0_DATAOUT,
+				  &ack_hardheader, (BGLQuad*)ack_softheader_p,
+				  (BGLQuad*)packet);
+
+		my_assert(ack_softheader.zoid_id == ZOID_ID);
+
+		cpu = (ack_softheader.pset_cpu_rank - my_pset_rank) /
+		    pset_size;
+		if (cpu != my_cpu_id)
+		{
+		    vn_shared->cpu = cpu;
+		    vn_shared->softheader = ack_softheader;
+		    memcpy((void*)vn_shared->packet, packet, TREE_DATA_SIZE);
+		}
+
+		if (read_mutex)
+		    BGL_Mutex_Release(read_mutex);
+
+		/* Again, we are awaiting a single-packet reply, so if it's
+		   for us, then we are done.  */
+		if (cpu == my_cpu_id)
+		    break;
+	    }
+
+	    /* ack_softheader and packet now contain the packet for us.
+	       Actually, all we care about is the softheader.  */
+	    my_assert(ack_softheader.flags & ZOID_SOFTHEADER_FIRST_PACKET);
+	    my_assert(ack_softheader.flags & ZOID_SOFTHEADER_LAST_PACKET);
+
+	    if (ack_softheader.errnum)
+	    {
+		/* The most likely reason is that user allocation callback
+		   returned NULL.  We don't send anything more and return
+		   prematurely.  */
+		last_errnum = ack_softheader.errnum;
+
+		if (last_errnum == E2BIG)
+		{
+		    my_assert(ack_softheader.msg_length == sizeof(int));
+		    memcpy(&last_excessive_size, packet,
+			   sizeof(last_excessive_size));
+		}
+		return -1;
+	    }
+
+	    my_assert(ack_softheader.flags & ZOID_SOFTHEADER_ACK_PACKET);
+
+	    /* OK, ACK received -- resume sending!  */
+
+	    if (write_mutex)
+		BGL_Mutex_Acquire(write_mutex);
+	} /* if (pkt_count == ack_count) */
+    }
+
+    if (write_mutex)
+	BGL_Mutex_Release(write_mutex);
+
+    /* Message is sent.  Now wait for a reply.
+       There are two loops here.
+       The outer one waits until we can enter the inner loop to receive a
+       packet.  This is important in VN mode, where a packet for us might
+       have been received by the other CPU; it is put in a special one-packet
+       buffer visible from both CPUs then.
+       The inner loop is the one that receives and handles packets.  It
+       normally only terminates when a complete message has been received,
+       or, in VN mode, when a packet for the other CPU has been encountered
+       (see above).
+       This is so complicated because we now allow message interleaving,
+       where a stream of packets to one CPU can be interrupted by a stream of
+       packets to the other CPU.  So we must be able to exit the inner loop,
+       keeping all the state, and resume later.
+       NOTE: part of this code is duplicated above, when waiting for an
+       acknowledgement.  Make sure the codes are kept in synch!  */
+    for (;;)
+    {
+	BGLTreeStatusRegister status;
+	int already_received_1stpkt = 0;
+	int cpu;
+
+	/* We need to acquire and release the mutex in each iteration of the
+	   outer loop, so that the other CPU can access the packet stored for
+	   it in vn_shared.  */
+	if (read_mutex)
+	    BGL_Mutex_Acquire(read_mutex);
+
+	if (__zoid_vn_mode && vn_shared->cpu >= 0)
+	{
+	    if (vn_shared->cpu == my_cpu_id)
+	    {
+		/* The other process has read a packet of a message
+		   that was destined for me.  Copy this message into
+		   appropriate structures.  "data_buf" is always correct
+		   here, either through the initialization at the start
+		   of this function, or through the code at the bottom
+		   of the inner loop.  */
+		softheader = vn_shared->softheader;
+		memcpy(data_buf, (void*)vn_shared->packet, TREE_DATA_SIZE);
+
+		/* Free the interprocess buffer.  */
+		vn_shared->cpu = -1;
+
+		already_received_1stpkt = 1;
+	    }
+	    else
+	    {
+		/* The message is not for me.  I can't read anything from the
+		   tree, since the inter-process buffer is full, so if there
+		   was a message in the network, and it was not for me, there
+		   would be nowhere to store it.  */
+		if (read_mutex)
+		    BGL_Mutex_Release(read_mutex);
+		continue;
+	    }
+	}
+	/* Note: we are still holding the read mutex at this point.  */
+
+	/* Inner loop starts.  */
+	do
+	{
+	    if (!already_received_1stpkt)
+	    {
+		do
+		{
+		    status = *(volatile BGLTreeStatusRegister*)
+			BGL_MEM_TREE_VC0_STATUS0;
+		} while (status.recpktcnt == 0);
+		BGLTreeFIFO_recvH((BGLTreePacketHardHeader*)
+				  BGL_MEM_TREE_VC0_HDROUT,
+				  (BGLQuad*)BGL_MEM_TREE_VC0_DATAOUT,
+				  &hardheader, (BGLQuad*)softheader_p,
+				  (BGLQuad*)data_buf);
+	    }
+	    else
+		already_received_1stpkt = 0;
+
+	    my_assert(softheader.zoid_id == ZOID_ID);
+
+	    cpu = (softheader.pset_cpu_rank - my_pset_rank) / pset_size;
+	    if (cpu != my_cpu_id)
+	    {
+		/* The packet just read is not for this CPU.
+		   Place it in a shared area and break out of this loop
+		   to let the other CPU handle it.  */
+		vn_shared->cpu = cpu;
+		vn_shared->softheader = softheader;
+		memcpy((void*)vn_shared->packet, data_buf, TREE_DATA_SIZE);
+
+		break;
+	    }
+
+	    if (softheader.flags & ZOID_SOFTHEADER_FIRST_PACKET)
+	    {
+		/* We have just received the first packet.  Initialize
+		   everything.  */
+		my_assert(data_buf == buffer);
+
+		result_len = softheader.msg_length;
+		last_errnum = softheader.errnum;
+
+		if (last_errnum)
+		{
+		    /* This is only possible if there was an out-of-memory
+		       condition, if the result would have been too large,
+		       or if the backend was not loaded.  In either case, a
+		       one-packet reply is sent.  */
+		    my_assert(softheader.flags & ZOID_SOFTHEADER_LAST_PACKET);
+
+		    if (last_errnum == E2BIG)
+		    {
+			/* In this case, the reply contains the excess size
+			   value.  */
+			my_assert(result_len == sizeof(int));
+			memcpy(&last_excessive_size, buffer,
+			       sizeof(last_excessive_size));
+		    }
+
+		    if (read_mutex)
+			BGL_Mutex_Release(read_mutex);
+
+		    return -1;
+		}
+
+		my_assert(result_len <= max_res_len);
+
+		/* We always round up the buffer when allocating, so we take
+		   that into consideration here, so as to avoid interim
+		   buffers for the last packet of the main buffer (no such
+		   luck with zero-copy result buffers...).  */
+		result_remaining = TREE_BUFFER_ROUNDUP(result_len);
+	    }
+
+	    my_assert(softheader.msg_length == result_len);
+
+	    if (data_buf != result_current)
+	    {
+		/* Because of buffer size limitations or alignment (that
+		   only occur for 0c data), we had to use an auxiliary
+		   buffer.  Now copy stuff to its intended destination.  */
+		if (result_remaining > 0)
+		    memcpy(result_current, data_buf, result_remaining <
+			   TREE_DATA_SIZE ? result_remaining : TREE_DATA_SIZE);
+
+		if (result_remaining < TREE_DATA_SIZE &&
+		    result_remaining_extra)
+		{
+		    /* The just read packet contains (part of) the length
+		       of the next chunk.  If we are lucky, it contains
+		       the whole length (it's only 4 bytes...).  If we are
+		       unlucky, then the length is split between two
+		       packets.  */
+		    if (result_remaining >= 0)
+		    {
+			if (result_remaining + result_remaining_extra <=
+			    TREE_DATA_SIZE)
+			{
+			    /* A complete length is in this packet.  */
+			    memcpy(&next_chunk_len,
+				   data_buf + result_remaining,
+				   sizeof(next_chunk_len));
+			}
+			else
+			{
+			    /* The beginning of length is in this
+			       packet.  The next packet (handled right
+			       below) will contain the rest.  */
+			    memcpy(&next_chunk_len,
+				   data_buf + result_remaining,
+				   TREE_DATA_SIZE - result_remaining);
+			}
+		    }
+		    else
+		    {
+			/* The end of length is in this packet.  The
+			   beginning has already been read and stored.
+
+			   Proof of correctness by example:
+			   Imagine that when reading the beginning of
+			   length, result_remaining was 237.  That packet
+			   thus contained 240 - 237 = 3 bytes of length.
+			   Thus, current packet contains 4 - 3 = 1
+			   remaining byte, that we need to copy to the
+			   byte starting at offset 3 of next_chunk_len.
+			   result_remaining is now 237 - 240 = -3.  The
+			   code below thus does what it is supposed to.  */
+			memcpy(((char*)&next_chunk_len) - result_remaining,
+			       data_buf,
+			       result_remaining_extra + result_remaining);
+		    }
+		}
+	    }
+
+	    if (!(softheader.flags & ZOID_SOFTHEADER_LAST_PACKET))
+	    {
+		/* Prepare a buffer for the next packet of this message.
+		   Note that that packet might be received outside this loop,
+		   from the other CPU over the vn_shared buffer.  */
+
+		result_current += TREE_DATA_SIZE;
+		result_remaining -= TREE_DATA_SIZE;
+
+		if (out_arr && result_remaining + result_remaining_extra <= 0)
+		{
+		    /* We have a zero-copy result, and have just finished
+		       reading the previous chunk (be it the init chunk or
+		       a 0c one).  */
+
+		    if (zeroc_max == -2)
+		    {
+			/* We have not analyzed the 0c header yet, which means
+			   that the chunk we just finished reading was the
+			   init one.  */
+			memcpy(&zeroc_max, buffer + result_len -
+			       2 * sizeof(int), sizeof(zeroc_max));
+
+			/* Copy the length of the first 0c chunk.  */
+			memcpy(&result_remaining, buffer + result_len -
+			       sizeof(int), sizeof(result_remaining));
+
+			if (zeroc_max == -1)
+			    /* 1-D array.  */
+			    result_current = out_arr;
+			else /* 2-D array.  */
+			{
+			    result_current = ((void**)out_arr)[0];
+			    zeroc_idx = 0;
+
+			    if (zeroc_idx < zeroc_max - 1)
+				/* Account for the integer that specifies the
+				   size of the next chunk.  */
+				result_remaining_extra = sizeof(int);
+			    else
+				result_remaining_extra = 0;
+			}
+		    }
+		    else
+		    {
+			/* The 0c header has already been analyzed.
+			   We should never get here for 1-D arrays, or after
+			   reading the last chunk of 2-D arrays.  */
+			my_assert(zeroc_max != -1 &&
+				  zeroc_idx < zeroc_max - 1);
+
+			/* The length of the next chunk, that is stored at the
+			   end of the just read one, is copied by code later
+			   in the loop to next_chunk_len, because it cannot be
+			   stored in user-supplied buffer (there is no space
+			   there).  */
+			result_remaining = next_chunk_len;
+
+			zeroc_idx++;
+			result_current = ((void**)out_arr)[zeroc_idx];
+
+			if (zeroc_idx < zeroc_max - 1)
+			    /* Account for the integer that specifies the size
+			       of the next chunk.  */
+			    result_remaining_extra = sizeof(int);
+			else
+			    result_remaining_extra = 0;
+		    }
+		}
+
+		my_assert(result_remaining + result_remaining_extra > 0);
+
+		/* Use auxiliary buffer if there is not enough space in the
+		   current one or if it is unaligned.  Either condition is
+		   only possible with 0c data chunks.  */
+		if (result_remaining < TREE_DATA_SIZE ||
+		    (((unsigned int)result_current) & 0xf))
+		{
+		    data_buf = packet;
+		}
+		else
+		    data_buf = result_current;
+	    }
+	} while (!(softheader.flags & ZOID_SOFTHEADER_LAST_PACKET));
+
+	if (read_mutex)
+	    BGL_Mutex_Release(read_mutex);
+
+	if (cpu == my_cpu_id &&
+	    (softheader.flags & ZOID_SOFTHEADER_LAST_PACKET))
+	{
+	    break;
+	}
+    }
+
+    return result_len;
+}
+
+void*
+__zoid_allocate_buffer(size_t size)
+{
+    if (size > max_buffer_size)
+    {
+	/* This simply indicates an error on the caller's side.  We return
+	   a hard error, which is propagated to the caller, who can then
+	   adjust the request size and resubmit.  */
+	last_errnum = E2BIG;
+	last_excessive_size = size - max_buffer_size;
+	return NULL;
+    }
+
+    if (size > stub_buffer_size)
+    {
+	free(stub_buffer);
+
+	/* For efficiency reasons, we allocate no less than 4K, and always
+	   a power-of-two, up to max_buffer_size.  */
+	if (size < 4096)
+	    size = 4096;
+	else
+	{
+	    int i;
+
+	    for (i = 4096; i < size; i <<= 1)
+		;
+
+	    if (i > max_buffer_size)
+		i = max_buffer_size;
+
+	    size = i;
+	}
+
+	if (!(stub_buffer = malloc(size)))
+	{
+	    last_errnum = ENOMEM;
+	    stub_buffer_size = 0;
+	}
+	else
+	    stub_buffer_size = size;
+    }
+
+    return stub_buffer;
+}
+
+void
+__zoid_release_buffer(void* buffer)
+{
+    /* Currently, we don't free the buffer, but re-use it next time, if
+       possible.  */
+}
+
+int
+__zoid_error(void)
+{
+    return last_errnum;
+}
+
+/* If __zoid_error returns E2BIG, __zoid_excessive_size informs by how
+   much the input was too large or the output would have been.  */
+int
+__zoid_excessive_size(void)
+{
+    return last_excessive_size;
+}
+
+static void
+my_assert_fail(const char *assertion, const char *file, unsigned int line,
+	       const char *function)
+{
+    struct ZoidSoftHeader softheader, *softheader_p = &softheader;
+    BGLTreeStatusRegister status;
+    BGLTreePacketHardHeader hardheader;
+    static int *p = NULL;
+    int n;
+
+    /* Send an emergency packet with error description.  */
+    BGLTreePacketHardHeader_InitP2P(&hardheader, PACKET_CLASS_CIO, 0,
+				    ion_p2p_addr);
+    softheader.zoid_id = ZOID_ID;
+    softheader.pset_cpu_rank = my_pset_rank + my_cpu_id * pset_size;
+    softheader.flags = ZOID_SOFTHEADER_FIRST_PACKET |
+	ZOID_SOFTHEADER_LAST_PACKET | ZOID_SOFTHEADER_ASSERT_PACKET;
+
+    n = snprintf(packet, TREE_DATA_SIZE, "%s:%u: %s%sAssertion `%s' failed!",
+		 file, line, function ? function : "", function ? ": " : "",
+		 assertion);
+    if (n > TREE_DATA_SIZE)
+	n = TREE_DATA_SIZE;
+
+    softheader.msg_length = n;
+
+    /* We are *dying* here.  No time to play with mutexes.  */
+    do
+    {
+	status = *(volatile BGLTreeStatusRegister*)BGL_MEM_TREE_VC0_STATUS0;
+    } while (status.injpktcnt > 7);
+    BGLTreeFIFO_sendH((BGLTreePacketHardHeader*)BGL_MEM_TREE_VC0_HDRIN,
+		      (BGLQuad*)BGL_MEM_TREE_VC0_DATAIN,
+		      &hardheader, (BGLQuad*)softheader_p, (BGLQuad*)packet);
+
+    /* Crash.  This has the advantage that control is immediately relinquished
+       to CNK, which arranges for the core file to be generated.  */
+    *p = 0;
+}
+
+/*
+ * The only purpose of this function is to try to access VC0 early on, before
+ * CIOD is suspended.  If a kernel with restricted access to VC0 is used,
+ * this will give us a nice, easy to diagnose crash and a core file.
+ */
+static void
+__zoid_test_vc0(void)
+{
+    BGLTreeStatusRegister status;
+
+    status = *(volatile BGLTreeStatusRegister*)BGL_MEM_TREE_VC0_STATUS0;
+}
Index: sysdeps/blrts/zoid/ioctl_llnl.c
===================================================================
RCS file: sysdeps/blrts/zoid/ioctl_llnl.c
diff -N sysdeps/blrts/zoid/ioctl_llnl.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/ioctl_llnl.c	5 Apr 2006 16:24:59 -0000	1.1
@@ -0,0 +1 @@
+/* Just to prevent ../syscalls.list from generating a syscall we don't need.  */
Index: sysdeps/blrts/zoid/lchown.c
===================================================================
RCS file: sysdeps/blrts/zoid/lchown.c
diff -N sysdeps/blrts/zoid/lchown.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/lchown.c	27 Jun 2007 15:20:38 -0000	1.4
@@ -0,0 +1,46 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: lchown.c,v 1.4 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+
+#include "unix.h"
+
+int
+__lchown (const char *file, uid_t owner, gid_t group)
+{
+  if (file == NULL)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  return unix_decode_result(unix_lchown(file, owner, group));
+}
+
+weak_alias (__lchown, lchown)
Index: sysdeps/blrts/zoid/link.c
===================================================================
RCS file: sysdeps/blrts/zoid/link.c
diff -N sysdeps/blrts/zoid/link.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/link.c	27 Jun 2007 15:20:38 -0000	1.4
@@ -0,0 +1,46 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: link.c,v 1.4 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+
+#include "unix.h"
+
+int
+__link (const char *from, const char *to)
+{
+  if (from == NULL || to == NULL)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  return unix_decode_result(unix_link(from, to));
+}
+
+weak_alias (__link, link)
Index: sysdeps/blrts/zoid/llseek.c
===================================================================
RCS file: sysdeps/blrts/zoid/llseek.c
diff -N sysdeps/blrts/zoid/llseek.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/llseek.c	26 Jun 2007 15:27:01 -0000	1.1
@@ -0,0 +1 @@
+/* We provide the necessary support in lseek64.c.  */
Index: sysdeps/blrts/zoid/lseek.c
===================================================================
RCS file: sysdeps/blrts/zoid/lseek.c
diff -N sysdeps/blrts/zoid/lseek.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/lseek.c	27 Jun 2007 15:20:38 -0000	1.4
@@ -0,0 +1,39 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: lseek.c,v 1.4 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <unistd.h>
+
+#include "unix.h"
+
+off_t
+__libc_lseek (int fd, off_t offset, int whence)
+{
+    return unix_decode_result(unix_lseek(fd, offset, whence));
+}
+
+weak_alias (__libc_lseek, __lseek)
+weak_alias (__libc_lseek, lseek)
Index: sysdeps/blrts/zoid/lseek64.c
===================================================================
RCS file: sysdeps/blrts/zoid/lseek64.c
diff -N sysdeps/blrts/zoid/lseek64.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/lseek64.c	27 Jun 2007 15:20:38 -0000	1.5
@@ -0,0 +1,47 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: lseek64.c,v 1.5 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <unistd.h>
+
+#include "unix.h"
+
+off64_t
+__libc_lseek64 (int fd, off64_t offset, int whence)
+{
+    return unix_decode_result(unix_lseek64(fd, offset, whence));
+}
+
+weak_alias (__libc_lseek64, __lseek64)
+weak_alias (__libc_lseek64, lseek64)
+weak_alias (__libc_lseek64, __llseek)
+weak_alias (__libc_lseek64, llseek)
+
+/* llseek doesn't have a prototype.  Since the second parameter is a
+   64bit type, this results in wrong behaviour if no prototype is
+   provided.  */
+link_warning (llseek, "\
+the `llseek' function may be dangerous; use `lseek64' instead.")
Index: sysdeps/blrts/zoid/lxstat.c
===================================================================
RCS file: sysdeps/blrts/zoid/lxstat.c
diff -N sysdeps/blrts/zoid/lxstat.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/lxstat.c	27 Jun 2007 15:20:38 -0000	1.5
@@ -0,0 +1,52 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: lxstat.c,v 1.5 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <errno.h>
+#include <stddef.h>
+#include <sys/stat.h>
+
+#include "unix.h"
+
+int
+__lxstat (int version, const char *file, struct stat *buf)
+{
+  if (version != 0 || file == NULL || buf == NULL)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  return unix_decode_result(unix_lstat(file, &buf->st_mode, &buf->st_ino,
+				       &buf->st_dev, &buf->st_nlink,
+				       &buf->st_uid, &buf->st_gid,
+				       &buf->st_size, &buf->st_atime,
+				       &buf->st_mtime, &buf->st_ctime,
+				       &buf->st_rdev, &buf->st_blksize,
+				       &buf->st_blocks));
+}
+
+weak_alias (__lxstat, _lxstat);
Index: sysdeps/blrts/zoid/lxstat64.c
===================================================================
RCS file: sysdeps/blrts/zoid/lxstat64.c
diff -N sysdeps/blrts/zoid/lxstat64.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/lxstat64.c	27 Jun 2007 15:20:38 -0000	1.5
@@ -0,0 +1,50 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: lxstat64.c,v 1.5 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <errno.h>
+#include <stddef.h>
+#include <sys/stat.h>
+
+#include "unix.h"
+
+int
+__lxstat64 (int vers, const char *file, struct stat64 *buf)
+{
+  if (vers != 0 || file == NULL || buf == NULL)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  return unix_decode_result(unix_lstat64(file, &buf->st_mode, &buf->st_ino,
+					 &buf->st_dev, &buf->st_nlink,
+					 &buf->st_uid, &buf->st_gid,
+					 &buf->st_size, &buf->st_atime,
+					 &buf->st_mtime, &buf->st_ctime,
+					 &buf->st_rdev, &buf->st_blksize,
+					 &buf->st_blocks));
+}
Index: sysdeps/blrts/zoid/mkdir.c
===================================================================
RCS file: sysdeps/blrts/zoid/mkdir.c
diff -N sysdeps/blrts/zoid/mkdir.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/mkdir.c	27 Jun 2007 15:20:38 -0000	1.4
@@ -0,0 +1,46 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: mkdir.c,v 1.4 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <errno.h>
+#include <stddef.h>
+#include <sys/stat.h>
+
+#include "unix.h"
+
+int
+__mkdir (const char *path, mode_t mode)
+{
+  if (path == NULL)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  return unix_decode_result(unix_mkdir(path, mode));
+}
+
+weak_alias (__mkdir, mkdir)
Index: sysdeps/blrts/zoid/open.c
===================================================================
RCS file: sysdeps/blrts/zoid/open.c
diff -N sysdeps/blrts/zoid/open.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/open.c	27 Jun 2007 15:20:38 -0000	1.5
@@ -0,0 +1,58 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: open.c,v 1.5 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdarg.h>
+#include <stddef.h>
+
+#include "unix.h"
+
+int
+__libc_open (const char *file, int oflag, ...)
+{
+  int mode = 0;
+
+  if (file == NULL)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  if (oflag & O_CREAT)
+    {
+      va_list arg;
+      va_start(arg, oflag);
+      mode = va_arg(arg, int);
+      va_end(arg);
+    }
+
+  return unix_decode_result(unix_open(file, oflag, mode));
+}
+
+weak_alias (__libc_open, __open)
+weak_alias (__libc_open, open)
Index: sysdeps/blrts/zoid/pread.c
===================================================================
RCS file: sysdeps/blrts/zoid/pread.c
diff -N sysdeps/blrts/zoid/pread.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/pread.c	27 Jun 2007 15:20:38 -0000	1.6
@@ -0,0 +1,109 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: pread.c,v 1.6 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+
+#include "unix.h"
+
+/* Note: most of the code below is duplicated in pwrite.c, and plain/p64
+   variants of write and read.  If anything needs to be changed in one of
+   them, it probably also should be changed in all the others!  */
+
+ssize_t
+__libc_pread (int fd, void *buf, size_t nbytes, off_t offset)
+{
+    static ssize_t max_read_nbytes = -1;
+    ssize_t bytes_read;
+
+    if (buf == NULL)
+    {
+	__set_errno (EINVAL);
+	return -1;
+    }
+
+    bytes_read = 0;
+    do
+    {
+	ssize_t toread, justread, toread_cp;
+	int error;
+
+	toread = nbytes - bytes_read;
+
+	if (max_read_nbytes != -1 && toread > max_read_nbytes)
+	{
+#if 0
+	    fprintf(stderr, "Adjusting pread of %d bytes from %d to %d\n",
+		    nbytes, toread, max_read_nbytes);
+#endif
+	    toread = max_read_nbytes;
+	}
+
+	toread_cp = toread;
+	justread = unix_pread(fd, buf + bytes_read, &toread_cp, offset +
+			      bytes_read);
+
+	if ((error = __zoid_error()))
+	{
+	    if (error != E2BIG)
+	    {
+		/* For a generic ZOID error, just bail out.  */
+		__set_errno(error);
+		return -1;
+	    }
+#if 0
+	    fprintf(stderr, "Attempt to pread %d bytes returned excessive "
+		    "size error by %d bytes\n", toread,
+		    __zoid_excessive_size());
+#endif
+	    /* We tried to send a too large read request.  Adjust.  */
+	    max_read_nbytes = toread - __zoid_excessive_size();
+	}
+	else
+	{
+	    if (justread < 0)
+	    {
+		/* For a generic pread() error, just bail out.  */
+		__set_errno(-justread);
+		return -1;
+	    }
+
+	    bytes_read += justread;
+
+	    if (justread != toread)
+		/* pread() as such succeeded, but it read fewer bytes than
+		   expected.  We terminate prematurely then.  */
+		break;
+	}
+    } while (bytes_read < nbytes);
+
+    return bytes_read;
+}
+
+weak_alias (__libc_pread, __pread)
+weak_alias (__libc_pread, pread)
Index: sysdeps/blrts/zoid/pread64.c
===================================================================
RCS file: sysdeps/blrts/zoid/pread64.c
diff -N sysdeps/blrts/zoid/pread64.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/pread64.c	27 Jun 2007 15:20:38 -0000	1.6
@@ -0,0 +1,109 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: pread64.c,v 1.6 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+
+#include "unix.h"
+
+/* Note: most of the code below is duplicated in pwrite64.c, and plain/p
+   variants of write and read.  If anything needs to be changed in one of
+   them, it probably also should be changed in all the others!  */
+
+ssize_t
+__libc_pread64 (int fd, void *buf, size_t nbytes, off64_t offset)
+{
+    static ssize_t max_read_nbytes = -1;
+    ssize_t bytes_read;
+
+    if (buf == NULL)
+    {
+	__set_errno (EINVAL);
+	return -1;
+    }
+
+    bytes_read = 0;
+    do
+    {
+	ssize_t toread, justread, toread_cp;
+	int error;
+
+	toread = nbytes - bytes_read;
+
+	if (max_read_nbytes != -1 && toread > max_read_nbytes)
+	{
+#if 0
+	    fprintf(stderr, "Adjusting pread64 of %d bytes from %d to %d\n",
+		    nbytes, toread, max_read_nbytes);
+#endif
+	    toread = max_read_nbytes;
+	}
+
+	toread_cp = toread;
+	justread = unix_pread64(fd, buf + bytes_read, &toread_cp, offset +
+				bytes_read);
+
+	if ((error = __zoid_error()))
+	{
+	    if (error != E2BIG)
+	    {
+		/* For a generic ZOID error, just bail out.  */
+		__set_errno(error);
+		return -1;
+	    }
+#if 0
+	    fprintf(stderr, "Attempt to pread64 %d bytes returned excessive "
+		    "size error by %d bytes\n", toread,
+		    __zoid_excessive_size());
+#endif
+	    /* We tried to send a too large read request.  Adjust.  */
+	    max_read_nbytes = toread - __zoid_excessive_size();
+	}
+	else
+	{
+	    if (justread < 0)
+	    {
+		/* For a generic pread64() error, just bail out.  */
+		__set_errno(-justread);
+		return -1;
+	    }
+
+	    bytes_read += justread;
+
+	    if (justread != toread)
+		/* pread64() as such succeeded, but it read fewer bytes than
+		   expected.  We terminate prematurely then.  */
+		break;
+	}
+    } while (bytes_read < nbytes);
+
+    return bytes_read;
+}
+
+weak_alias (__libc_pread64, __pread64)
+weak_alias (__libc_pread64, pread64)
Index: sysdeps/blrts/zoid/pwrite.c
===================================================================
RCS file: sysdeps/blrts/zoid/pwrite.c
diff -N sysdeps/blrts/zoid/pwrite.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/pwrite.c	27 Jun 2007 15:20:38 -0000	1.5
@@ -0,0 +1,108 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: pwrite.c,v 1.5 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+
+#include "unix.h"
+
+/* Note: most of the code below is duplicated in pread.c, and plain/p64
+   variants of write and read.  If anything needs to be changed in one of
+   them, it probably also should be changed in all the others!  */
+
+ssize_t
+__libc_pwrite (int fd, const void *buf, size_t nbytes, off_t offset)
+{
+    static ssize_t max_write_nbytes = -1;
+    ssize_t bytes_written;
+
+    if (buf == NULL)
+    {
+	__set_errno (EINVAL);
+	return -1;
+    }
+
+    bytes_written = 0;
+    do
+    {
+	ssize_t towrite, written;
+	int error;
+
+	towrite = nbytes - bytes_written;
+
+	if (max_write_nbytes != -1 && towrite > max_write_nbytes)
+	{
+#if 0
+	    fprintf(stderr, "Adjusting pwrite of %d bytes from %d to %d\n",
+		    nbytes, towrite, max_write_nbytes);
+#endif
+	    towrite = max_write_nbytes;
+	}
+
+	written = unix_pwrite(fd, buf + bytes_written, towrite, offset +
+			      bytes_written);
+
+	if ((error = __zoid_error()))
+	{
+	    if (error != E2BIG)
+	    {
+		/* For a generic ZOID error, just bail out.  */
+		__set_errno(error);
+		return -1;
+	    }
+#if 0
+	    fprintf(stderr, "Attempt to pwrite %d bytes returned excessive "
+		    "size error by %d bytes\n", towrite,
+		    __zoid_excessive_size());
+#endif
+	    /* We tried to send a too large write request.  Adjust.  */
+	    max_write_nbytes = towrite - __zoid_excessive_size();
+	}
+	else
+	{
+	    if (written < 0)
+	    {
+		/* For a generic pwrite() error, just bail out.  */
+		__set_errno(-written);
+		return -1;
+	    }
+
+	    bytes_written += written;
+
+	    if (written != towrite)
+		/* pwrite() as such succeeded, but it wrote fewer bytes than
+		   expected.  We terminate prematurely then.  */
+		break;
+	}
+    } while (bytes_written < nbytes);
+
+    return bytes_written;
+}
+
+weak_alias (__libc_pwrite, __pwrite)
+weak_alias (__libc_pwrite, pwrite)
Index: sysdeps/blrts/zoid/pwrite64.c
===================================================================
RCS file: sysdeps/blrts/zoid/pwrite64.c
diff -N sysdeps/blrts/zoid/pwrite64.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/pwrite64.c	27 Jun 2007 15:20:38 -0000	1.5
@@ -0,0 +1,108 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: pwrite64.c,v 1.5 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+
+#include "unix.h"
+
+/* Note: most of the code below is duplicated in pread64.c, and plain/p
+   variants of write and read.  If anything needs to be changed in one of
+   them, it probably also should be changed in all the others!  */
+
+ssize_t
+__libc_pwrite64 (int fd, const void *buf, size_t nbytes, off64_t offset)
+{
+    static ssize_t max_write_nbytes = -1;
+    ssize_t bytes_written;
+
+    if (buf == NULL)
+    {
+	__set_errno (EINVAL);
+	return -1;
+    }
+
+    bytes_written = 0;
+    do
+    {
+	ssize_t towrite, written;
+	int error;
+
+	towrite = nbytes - bytes_written;
+
+	if (max_write_nbytes != -1 && towrite > max_write_nbytes)
+	{
+#if 0
+	    fprintf(stderr, "Adjusting pwrite64 of %d bytes from %d to %d\n",
+		    nbytes, towrite, max_write_nbytes);
+#endif
+	    towrite = max_write_nbytes;
+	}
+
+	written = unix_pwrite64(fd, buf + bytes_written, towrite, offset +
+				bytes_written);
+
+	if ((error = __zoid_error()))
+	{
+	    if (error != E2BIG)
+	    {
+		/* For a generic ZOID error, just bail out.  */
+		__set_errno(error);
+		return -1;
+	    }
+#if 0
+	    fprintf(stderr, "Attempt to pwrite64 %d bytes returned excessive "
+		    "size error by %d bytes\n", towrite,
+		    __zoid_excessive_size());
+#endif
+	    /* We tried to send a too large write request.  Adjust.  */
+	    max_write_nbytes = towrite - __zoid_excessive_size();
+	}
+	else
+	{
+	    if (written < 0)
+	    {
+		/* For a generic pwrite64() error, just bail out.  */
+		__set_errno(-written);
+		return -1;
+	    }
+
+	    bytes_written += written;
+
+	    if (written != towrite)
+		/* pwrite64() as such succeeded, but it wrote fewer bytes than
+		   expected.  We terminate prematurely then.  */
+		break;
+	}
+    } while (bytes_written < nbytes);
+
+    return bytes_written;
+}
+
+weak_alias (__libc_pwrite64, __pwrite64)
+weak_alias (__libc_pwrite64, pwrite64)
Index: sysdeps/blrts/zoid/read.c
===================================================================
RCS file: sysdeps/blrts/zoid/read.c
diff -N sysdeps/blrts/zoid/read.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/read.c	27 Jun 2007 15:20:38 -0000	1.7
@@ -0,0 +1,116 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: read.c,v 1.7 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+
+#include "unix.h"
+
+//#include <stdio.h>
+
+/* Note: most of the code below is duplicated in write.c, and p/p64 variants
+   of write and read.  If anything needs to be changed in one of them, it
+   probably also should be changed in all the others!  */
+
+ssize_t
+__libc_read (int fd, void *buf, size_t nbytes)
+{
+    static ssize_t max_read_nbytes = -1;
+    ssize_t bytes_read;
+
+    if (buf == NULL)
+    {
+	__set_errno (EINVAL);
+	return -1;
+    }
+
+    //fprintf(stderr, "called __libc_read with nbytes %d\n", nbytes);
+    bytes_read = 0;
+    do
+    {
+	ssize_t toread, justread, toread_cp;
+	int error;
+
+	toread = nbytes - bytes_read;
+
+	if (max_read_nbytes != -1 && toread > max_read_nbytes)
+	{
+#if 0
+	    fprintf(stderr, "Adjusting read of %d bytes from %d to %d\n",
+		    nbytes, toread, max_read_nbytes);
+#endif
+	    toread = max_read_nbytes;
+	}
+
+	//fprintf(stderr, "__libc_read bytes_read %d, toread %d\n", bytes_read,
+	//	toread);
+	toread_cp = toread;
+	justread = unix_read(fd, buf + bytes_read, &toread_cp);
+	//fprintf(stderr, "__libc_read justread %d, toread_cp %d\n", justread,
+	//	toread_cp);
+
+	if ((error = __zoid_error()))
+	{
+	    if (error != E2BIG)
+	    {
+		/* For a generic ZOID error, just bail out.  */
+		__set_errno(error);
+		return -1;
+	    }
+#if 0
+	    fprintf(stderr, "Attempt to read %d bytes returned excessive size "
+		    "error by %d bytes\n", toread, __zoid_excessive_size());
+#endif
+	    /* We tried to send a too large read request.  Adjust.  */
+	    max_read_nbytes = toread - __zoid_excessive_size();
+	}
+	else
+	{
+	    if (justread < 0)
+	    {
+		/* For a generic read() error, just bail out.  */
+		__set_errno(-justread);
+		return -1;
+	    }
+
+	    bytes_read += justread;
+
+	    if (justread != toread)
+		/* read() as such succeeded, but it read fewer bytes than
+		   expected.  We terminate prematurely then.  */
+		break;
+	}
+	//fprintf(stderr, "__libc_read bytes_read %d, nbytes %d\n", bytes_read,
+	//	nbytes);
+    } while (bytes_read < nbytes);
+
+    return bytes_read;
+}
+
+weak_alias (__libc_read, __read)
+weak_alias (__libc_read, read)
Index: sysdeps/blrts/zoid/readlink.c
===================================================================
RCS file: sysdeps/blrts/zoid/readlink.c
diff -N sysdeps/blrts/zoid/readlink.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/readlink.c	27 Jun 2007 15:20:38 -0000	1.5
@@ -0,0 +1,46 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: readlink.c,v 1.5 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+
+#include "unix.h"
+
+int
+__readlink (const char *path, char *buf, size_t len)
+{
+  if (path == NULL || buf == NULL)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  return unix_decode_result(unix_readlink(path, buf, len));
+}
+
+weak_alias (__readlink, readlink)
Index: sysdeps/blrts/zoid/readv.c
===================================================================
RCS file: sysdeps/blrts/zoid/readv.c
diff -N sysdeps/blrts/zoid/readv.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/readv.c	27 Jun 2007 15:20:38 -0000	1.7
@@ -0,0 +1,187 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: readv.c,v 1.7 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <alloca.h>
+#include <assert.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/uio.h>
+
+#include "unix.h"
+
+//#include <stdio.h>
+
+/* Note: most of the code below is duplicated in writev.c.  If anything needs
+   to be changed in one of them, it probably also should be changed in the
+   other!  */
+
+ssize_t
+__readv (int fd, const struct iovec *vector, int count)
+{
+    void** bases;
+    size_t *lens, *lens_cp;
+    int i, min_i;
+    static ssize_t max_readv_nbytes = -1;
+    size_t bytes_total;
+    ssize_t bytes_read;
+
+    if (vector == NULL || count < 1)
+    {
+	__set_errno (EINVAL);
+	return -1;
+    }
+
+    bases = alloca(sizeof(*bases) * count);
+    lens = alloca(sizeof(*lens) * count);
+    lens_cp = alloca(sizeof(*lens) * count);
+
+    bytes_total = 0;
+    for (i = 0; i < count; i++)
+    {
+	bases[i] = vector[i].iov_base;
+	lens[i] = vector[i].iov_len;
+	bytes_total += vector[i].iov_len;
+    }
+
+    bytes_read = 0;
+    min_i = 0;
+    do
+    {
+	ssize_t toread, justread;
+	int error;
+	int max_i;
+	size_t max_i_len;
+
+	toread = 0;
+	for (i = min_i; i < count; i++)
+	    toread += lens[i];
+
+	if (max_readv_nbytes != -1 && toread > max_readv_nbytes)
+	{
+	    ssize_t toread_tmp;
+#if 0
+	    fprintf(stderr, "Adjusting readv of %d bytes from %d to %d\n",
+		    bytes_total, toread, max_readv_nbytes);
+#endif
+	    toread = max_readv_nbytes;
+
+	    toread_tmp = 0;
+	    for (max_i = min_i; max_i < count; max_i++)
+	    {
+		if (toread_tmp + lens[max_i] >= toread)
+		    break;
+		toread_tmp += lens[max_i];
+	    }
+
+	    /* It should always exit the loop with the break.  */
+	    assert(max_i < count);
+
+	    /* max_i now points at the last array index to read with the
+	       next call.  */
+
+	    max_i_len = lens[max_i];
+	    /* Decrease the length of the last element to read, so that
+	       it does not exceed the buffer size.  */
+	    lens[max_i] = toread - toread_tmp;
+	}
+	else
+	{
+	    max_i = count - 1;
+	    max_i_len = lens[max_i];
+	}
+#if 0
+	fprintf(stderr, "readv will be from count %d (offset %d, len %d) "
+		"to %d (len %d)\n", min_i,
+		bases[min_i] - vector[min_i].iov_base, lens[min_i],
+		max_i, lens[max_i]);
+#endif
+	memcpy(&lens_cp[min_i], &lens[min_i],
+	       sizeof(*lens) * (max_i - min_i + 1));
+	justread = unix_readv(fd, &bases[min_i], &lens_cp[min_i],
+			      max_i - min_i + 1);
+
+	/* No matter if we succeeded or not, restore any changes we have
+	   made to lens[max_i].  Also store the length as passed to readv
+	   in max_i_len.  */
+	{
+	    size_t tmp;
+	    tmp = max_i_len;
+	    max_i_len = lens[max_i];
+	    lens[max_i] = tmp;
+	}
+
+	if ((error = __zoid_error()))
+	{
+	    if (error != E2BIG)
+	    {
+		/* For a generic ZOID error, just bail out.  */
+		__set_errno(error);
+		return -1;
+	    }
+#if 0
+	    fprintf(stderr, "Attempt to readv %d bytes returned excessive "
+		    "size error by %d bytes\n", toread,
+		    __zoid_excessive_size());
+#endif
+	    /* We tried to send a too large readv request.  Adjust.
+	       Note: this adjustment cannot be correct for 2-D array types,
+	       because of full-packet alignment of each line.  Here, we don't
+	       take this alignment into consideration.  As a consequence,
+	       we will in some cases send less data than is actually possible,
+	       but that shouldn't be a big deal.  */
+	    max_readv_nbytes = toread - __zoid_excessive_size();
+	}
+	else
+	{
+	    if (justread < 0)
+	    {
+		/* For a generic readv() error, just bail out.  */
+		__set_errno(-justread);
+		return -1;
+	    }
+
+	    bytes_read += justread;
+
+	    if (justread != toread)
+		/* readv() as such succeeded, but it read fewer bytes than
+		   expected.  We terminate prematurely then.  */
+		break;
+
+	    /* We read successfully.  Prepare for the next iteration, should
+	       it be needed.  */
+	    bases[max_i] += max_i_len;
+	    lens[max_i] -= max_i_len;
+	    if (lens[max_i] == 0)
+		max_i++;
+	    min_i = max_i;
+	}
+    } while (bytes_read < bytes_total);
+
+    return bytes_read;
+}
+
+weak_alias (__readv, readv)
Index: sysdeps/blrts/zoid/recv.c
===================================================================
RCS file: sysdeps/blrts/zoid/recv.c
diff -N sysdeps/blrts/zoid/recv.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/recv.c	27 Jun 2007 15:20:38 -0000	1.5
@@ -0,0 +1,104 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: recv.c,v 1.5 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <errno.h>
+#include <stddef.h>
+#include <sys/socket.h>
+
+#include "unix.h"
+
+/* Note: most of this code comes from read.c.  */
+
+ssize_t
+__libc_recv (int fd, void *buf, size_t n, int flags)
+{
+    static ssize_t max_recv_nbytes = -1;
+    ssize_t bytes_recv;
+
+    if (buf == NULL)
+    {
+	__set_errno (EINVAL);
+	return -1;
+    }
+
+    bytes_recv = 0;
+    do
+    {
+	ssize_t torecv, justrecv, torecv_cp;
+	int error;
+
+	torecv = n - bytes_recv;
+
+	if (max_recv_nbytes != -1 && torecv > max_recv_nbytes)
+	{
+#if 0
+	    fprintf(stderr, "Adjusting recv of %d bytes from %d to %d\n",
+		    n, torecv, max_recv_nbytes);
+#endif
+	    torecv = max_recv_nbytes;
+	}
+
+	torecv_cp = torecv;
+	justrecv = unix_recv(fd, buf + bytes_recv, &torecv_cp, flags);
+
+	if ((error = __zoid_error()))
+	{
+	    if (error != E2BIG)
+	    {
+		/* For a generic ZOID error, just bail out.  */
+		__set_errno(error);
+		return -1;
+	    }
+#if 0
+	    fprintf(stderr, "Attempt to recv %d bytes returned excessive size "
+		    "error by %d bytes\n", torecv, __zoid_excessive_size());
+#endif
+	    /* We tried to send a too large recv request.  Adjust.  */
+	    max_recv_nbytes = torecv - __zoid_excessive_size();
+	}
+	else
+	{
+	    if (justrecv < 0)
+	    {
+		/* For a generic recv() error, just bail out.  */
+		__set_errno(-justrecv);
+		return -1;
+	    }
+
+	    bytes_recv += justrecv;
+
+	    if (justrecv != torecv)
+		/* recv() as such succeeded, but it read fewer bytes than
+		   expected.  We terminate prematurely then.  */
+		break;
+	}
+    } while (bytes_recv < n);
+
+    return bytes_recv;
+}
+
+weak_alias (__libc_recv, recv)
Index: sysdeps/blrts/zoid/recvfrom.c
===================================================================
RCS file: sysdeps/blrts/zoid/recvfrom.c
diff -N sysdeps/blrts/zoid/recvfrom.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/recvfrom.c	27 Jun 2007 15:20:38 -0000	1.5
@@ -0,0 +1,104 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: recvfrom.c,v 1.5 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <errno.h>
+#include <stddef.h>
+#include <sys/socket.h>
+
+#include "unix.h"
+
+ssize_t
+__libc_recvfrom (int fd, void *buf, size_t n, int flags, __SOCKADDR_ARG addr,
+		 socklen_t *addr_len)
+{
+    static ssize_t max_recv_nbytes = -1;
+    ssize_t bytes_recv;
+
+    if (buf == NULL)
+    {
+	__set_errno (EINVAL);
+	return -1;
+    }
+
+    bytes_recv = 0;
+    do
+    {
+	ssize_t torecv, justrecv, torecv_cp;
+	int error;
+
+	torecv = n - bytes_recv;
+
+	if (max_recv_nbytes != -1 && torecv > max_recv_nbytes)
+	{
+#if 0
+	    fprintf(stderr, "Adjusting recvfrom of %d bytes from %d to %d\n",
+		    n, torecv, max_recv_nbytes);
+#endif
+	    torecv = max_recv_nbytes;
+	}
+
+	torecv_cp = torecv;
+	justrecv = unix_recvfrom(fd, buf + bytes_recv, &torecv_cp, flags,
+				 addr.__sockaddr__, addr_len);
+	if ((error = __zoid_error()))
+	{
+	    if (error != E2BIG)
+	    {
+		/* For a generic ZOID error, just bail out.  */
+		__set_errno(error);
+		return -1;
+	    }
+#if 0
+	    fprintf(stderr, "Attempt to recvfrom %d bytes returned excessive "
+		    "size error by %d bytes\n", torecv,
+		    __zoid_excessive_size());
+#endif
+	    /* We tried to send a too large recvfrom request.  Adjust.  */
+	    max_recv_nbytes = torecv - __zoid_excessive_size();
+	}
+	else
+	{
+	    if (justrecv < 0)
+	    {
+		/* For a generic recvfrom() error, just bail out.  */
+		__set_errno(-justrecv);
+		return -1;
+	    }
+
+	    bytes_recv += justrecv;
+
+	    if (justrecv != torecv)
+		/* recvfrom() as such succeeded, but it read fewer bytes than
+		   expected.  We terminate prematurely then.  */
+		break;
+	}
+    } while (bytes_recv < n);
+
+    return bytes_recv;
+}
+
+weak_alias (__libc_recvfrom, recvfrom)
Index: sysdeps/blrts/zoid/rename.c
===================================================================
RCS file: sysdeps/blrts/zoid/rename.c
diff -N sysdeps/blrts/zoid/rename.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/rename.c	27 Jun 2007 15:20:38 -0000	1.4
@@ -0,0 +1,43 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: rename.c,v 1.4 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <stdio.h>
+#include <errno.h>
+
+#include "unix.h"
+
+int
+rename (const char *old, const char *new)
+{
+  if (old == NULL || new == NULL)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  return unix_decode_result(unix_rename(old, new));
+}
Index: sysdeps/blrts/zoid/rmdir.c
===================================================================
RCS file: sysdeps/blrts/zoid/rmdir.c
diff -N sysdeps/blrts/zoid/rmdir.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/rmdir.c	27 Jun 2007 15:20:38 -0000	1.4
@@ -0,0 +1,46 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: rmdir.c,v 1.4 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+
+#include "unix.h"
+
+int
+__rmdir (const char *path)
+{
+  if (path == NULL)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  return unix_decode_result(unix_rmdir(path));
+}
+
+weak_alias (__rmdir, rmdir)
Index: sysdeps/blrts/zoid/rts_coordinatesForRank.c
===================================================================
RCS file: sysdeps/blrts/zoid/rts_coordinatesForRank.c
diff -N sysdeps/blrts/zoid/rts_coordinatesForRank.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/rts_coordinatesForRank.c	27 Jun 2007 15:20:38 -0000	1.5
@@ -0,0 +1,44 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: rts_coordinatesForRank.c,v 1.5 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_ORIG
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <errno.h>
+
+#include "zoid_mapping.h"
+
+int
+__rts_coordinatesForRank(unsigned logicalRank,
+			 unsigned *x, unsigned *y, unsigned *z, unsigned *t)
+{
+    int ret;
+
+    if ((ret = __zoid_mapping_to_coord(logicalRank, x, y, z, t)) == -1)
+	__set_errno(EINVAL);
+
+    return ret;
+}
+
+weak_alias (__rts_coordinatesForRank, rts_coordinatesForRank)
Index: sysdeps/blrts/zoid/rts_rankForCoordinates.c
===================================================================
RCS file: sysdeps/blrts/zoid/rts_rankForCoordinates.c
diff -N sysdeps/blrts/zoid/rts_rankForCoordinates.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/rts_rankForCoordinates.c	27 Jun 2007 15:20:38 -0000	1.5
@@ -0,0 +1,49 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: rts_rankForCoordinates.c,v 1.5 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_ORIG
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <errno.h>
+#include <stdlib.h>
+
+#include "zoid_mapping.h"
+
+extern int __zoid_process_count;
+
+int
+__rts_rankForCoordinates(unsigned x, unsigned y, unsigned z, unsigned t,
+			 unsigned *logicalRank, unsigned *numProcs)
+{
+    int ret;
+
+    if ((ret = __zoid_mapping_to_rank(x, y, z, t, logicalRank)) == -1)
+	__set_errno(EINVAL);
+    else
+	*numProcs = __zoid_process_count;
+
+    return ret;
+}
+
+weak_alias (__rts_rankForCoordinates, rts_rankForCoordinates)
Index: sysdeps/blrts/zoid/s_ftruncate64.c
===================================================================
RCS file: sysdeps/blrts/zoid/s_ftruncate64.c
diff -N sysdeps/blrts/zoid/s_ftruncate64.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/s_ftruncate64.c	5 Apr 2006 16:24:59 -0000	1.1
@@ -0,0 +1 @@
+/* Just to prevent ../syscalls.list from generating a syscall we don't need.  */
Index: sysdeps/blrts/zoid/s_getcwd.c
===================================================================
RCS file: sysdeps/blrts/zoid/s_getcwd.c
diff -N sysdeps/blrts/zoid/s_getcwd.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/s_getcwd.c	5 Apr 2006 16:24:59 -0000	1.1
@@ -0,0 +1 @@
+/* Just to prevent ../syscalls.list from generating a syscall we don't need.  */
Index: sysdeps/blrts/zoid/s_getdents.c
===================================================================
RCS file: sysdeps/blrts/zoid/s_getdents.c
diff -N sysdeps/blrts/zoid/s_getdents.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/s_getdents.c	22 May 2006 15:08:00 -0000	1.1
@@ -0,0 +1 @@
+/* Just to prevent ../syscalls.list from generating a syscall we don't need.  */
Index: sysdeps/blrts/zoid/s_getdents64.c
===================================================================
RCS file: sysdeps/blrts/zoid/s_getdents64.c
diff -N sysdeps/blrts/zoid/s_getdents64.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/s_getdents64.c	22 May 2006 15:08:00 -0000	1.1
@@ -0,0 +1 @@
+/* Just to prevent ../syscalls.list from generating a syscall we don't need.  */
Index: sysdeps/blrts/zoid/s_llseek.c
===================================================================
RCS file: sysdeps/blrts/zoid/s_llseek.c
diff -N sysdeps/blrts/zoid/s_llseek.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/s_llseek.c	5 Apr 2006 16:24:59 -0000	1.1
@@ -0,0 +1 @@
+/* Just to prevent ../syscalls.list from generating a syscall we don't need.  */
Index: sysdeps/blrts/zoid/send.c
===================================================================
RCS file: sysdeps/blrts/zoid/send.c
diff -N sysdeps/blrts/zoid/send.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/send.c	27 Jun 2007 15:20:38 -0000	1.4
@@ -0,0 +1,47 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: send.c,v 1.4 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <errno.h>
+#include <stddef.h>
+#include <sys/socket.h>
+
+#include "unix.h"
+
+ssize_t
+__libc_send (int fd, __const __ptr_t buf, size_t n, int flags)
+{
+  if (buf == NULL)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  return unix_decode_result(unix_send(fd, buf, n, flags));
+}
+
+weak_alias (__libc_send, __send)
+weak_alias (__libc_send, send)
Index: sysdeps/blrts/zoid/sendto.c
===================================================================
RCS file: sysdeps/blrts/zoid/sendto.c
diff -N sysdeps/blrts/zoid/sendto.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/sendto.c	27 Jun 2007 15:20:38 -0000	1.4
@@ -0,0 +1,48 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: sendto.c,v 1.4 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <errno.h>
+#include <stddef.h>
+#include <sys/socket.h>
+
+#include "unix.h"
+
+ssize_t
+__libc_sendto (int fd, __const __ptr_t buf, size_t n, int flags,
+	       __CONST_SOCKADDR_ARG addr, socklen_t addr_len)
+{
+  if (buf == NULL)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  return unix_decode_result(unix_sendto(fd, buf, n, flags, addr.__sockaddr__,
+					addr_len));
+}
+
+weak_alias (__libc_sendto, sendto)
Index: sysdeps/blrts/zoid/setsockopt.c
===================================================================
RCS file: sysdeps/blrts/zoid/setsockopt.c
diff -N sysdeps/blrts/zoid/setsockopt.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/setsockopt.c	27 Jun 2007 15:20:38 -0000	1.4
@@ -0,0 +1,40 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: setsockopt.c,v 1.4 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <sys/socket.h>
+
+#include "unix.h"
+
+int
+__setsockopt (int fd, int level, int optname, const __ptr_t optval,
+	    socklen_t optlen)
+{
+  return unix_decode_result(unix_setsockopt(fd, level, optname, optval,
+					    optlen));
+}
+
+weak_alias (__setsockopt, setsockopt)
Index: sysdeps/blrts/zoid/socket.c
===================================================================
RCS file: sysdeps/blrts/zoid/socket.c
diff -N sysdeps/blrts/zoid/socket.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/socket.c	27 Jun 2007 15:20:38 -0000	1.4
@@ -0,0 +1,38 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: socket.c,v 1.4 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <sys/socket.h>
+
+#include "unix.h"
+
+int
+__socket (int domain, int type, int protocol)
+{
+  return unix_decode_result(unix_socket(domain, type, protocol));
+}
+
+weak_alias (__socket, socket)
Index: sysdeps/blrts/zoid/statfs.c
===================================================================
RCS file: sysdeps/blrts/zoid/statfs.c
diff -N sysdeps/blrts/zoid/statfs.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/statfs.c	27 Jun 2007 15:20:38 -0000	1.2
@@ -0,0 +1,38 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: statfs.c,v 1.2 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <sys/statfs.h>
+
+#include "unix.h"
+
+int
+__statfs (const char *file, struct statfs *buf)
+{
+    return unix_decode_result(unix_statfs(file, buf));
+}
+
+weak_alias (__statfs, statfs)
Index: sysdeps/blrts/zoid/statfs64.c
===================================================================
RCS file: sysdeps/blrts/zoid/statfs64.c
diff -N sysdeps/blrts/zoid/statfs64.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/statfs64.c	27 Jun 2007 15:20:38 -0000	1.2
@@ -0,0 +1,38 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: statfs64.c,v 1.2 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <sys/statfs.h>
+
+#include "unix.h"
+
+int
+__statfs64 (const char *file, struct statfs64 *buf)
+{
+    return unix_decode_result(unix_statfs64(file, buf));
+}
+
+weak_alias (__statfs64, statfs64)
Index: sysdeps/blrts/zoid/symlink.c
===================================================================
RCS file: sysdeps/blrts/zoid/symlink.c
diff -N sysdeps/blrts/zoid/symlink.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/symlink.c	27 Jun 2007 15:20:38 -0000	1.4
@@ -0,0 +1,46 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: symlink.c,v 1.4 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+
+#include "unix.h"
+
+int
+__symlink (const char *from, const char *to)
+{
+  if (from == NULL || to == NULL)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  return unix_decode_result(unix_symlink(from, to));
+}
+
+weak_alias (__symlink, symlink)
Index: sysdeps/blrts/zoid/syscalls.list
===================================================================
RCS file: sysdeps/blrts/zoid/syscalls.list
diff -N sysdeps/blrts/zoid/syscalls.list
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/syscalls.list	5 Apr 2006 16:24:59 -0000	1.1
@@ -0,0 +1,5 @@
+# File name	Caller	Syscall name	Args	Strong name	Weak names
+
+s_getgid	getgid	getgid		i:	__syscall_getgid
+s_getpid	getpid	getpid		i:	__syscall_getpid
+s_getuid	getuid	getuid		i:	__syscall_getuid
Index: sysdeps/blrts/zoid/truncate.c
===================================================================
RCS file: sysdeps/blrts/zoid/truncate.c
diff -N sysdeps/blrts/zoid/truncate.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/truncate.c	27 Jun 2007 15:20:38 -0000	1.4
@@ -0,0 +1,46 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: truncate.c,v 1.4 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+
+#include "unix.h"
+
+int
+__truncate (const char *path, off_t length)
+{
+  if (path == NULL)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  return unix_decode_result(unix_truncate(path, length));
+}
+
+weak_alias (__truncate, truncate)
Index: sysdeps/blrts/zoid/truncate64.c
===================================================================
RCS file: sysdeps/blrts/zoid/truncate64.c
diff -N sysdeps/blrts/zoid/truncate64.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/truncate64.c	27 Jun 2007 15:20:38 -0000	1.4
@@ -0,0 +1,46 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: truncate64.c,v 1.4 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+
+#include "unix.h"
+
+/* For some reason, this call doesn't have a __ counterpart.  */
+
+int
+truncate64 (const char *path, off64_t length)
+{
+  if (path == NULL)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  return unix_decode_result(unix_truncate64(path, length));
+}
Index: sysdeps/blrts/zoid/umask.c
===================================================================
RCS file: sysdeps/blrts/zoid/umask.c
diff -N sysdeps/blrts/zoid/umask.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/umask.c	27 Jun 2007 15:20:38 -0000	1.4
@@ -0,0 +1,38 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: umask.c,v 1.4 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <sys/stat.h>
+
+#include "unix.h"
+
+mode_t
+__umask (mode_t mask)
+{
+  return unix_decode_result(unix_umask(mask));
+}
+
+weak_alias (__umask, umask)
Index: sysdeps/blrts/zoid/unix.h
===================================================================
RCS file: sysdeps/blrts/zoid/unix.h
diff -N sysdeps/blrts/zoid/unix.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/unix.h	27 Jun 2007 15:20:38 -0000	1.10
@@ -0,0 +1,371 @@
+/* Please note that this file is shared between ZOID and GLIBC!  */
+
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: unix.h,v 1.10 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_ORIG
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#ifndef UNIX_H
+#define UNIX_H
+
+#ifndef _LARGEFILE64_SOURCE
+#define _LARGEFILE64_SOURCE
+#endif
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/statfs.h>
+#include <sys/time.h>
+#include <sys/uio.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <utime.h>
+
+#include "zoid_api.h"
+
+#ifndef __set_errno
+#define __set_errno(n) errno = (n)
+#endif
+
+#define unix_decode_result(result) \
+({ \
+    typeof (result) _result = (result); \
+    int _n; \
+    if ((_n = __zoid_error()) != 0) \
+    { \
+	__set_errno(_n); \
+	_result = -1; \
+    } \
+    else if (_result < 0) \
+    { \
+	__set_errno(-_result); \
+	_result = -1; \
+    } \
+    _result; \
+})
+
+/* START-ZOID-SCANNER ID=2 INIT=unix__init FINI=unix__fini */
+
+int unix_open(const char *pathname /* in:str */,
+	      int flags /* in:obj */,
+	      mode_t mode /* in:obj */);
+
+int unix_close(int fd /* in:obj */);
+
+int unix_dup(int oldfd /* in:obj */);
+
+int unix_dup2(int oldfd /* in:obj */,
+	      int newfd /* in:obj */);
+
+ssize_t unix_read(int fd /* in:obj */,
+		  void *buf /* out:arr:size=+1:zerocopy */,
+		  size_t *count /* inout:ptr */);
+
+ssize_t unix_write(int fd /* in:obj */,
+		   const void *buf /* in:arr:size=+1:zerocopy */,
+		   size_t count /* in:obj */);
+
+/* Not supported by BLRTS.  */
+ssize_t unix_pread(int fd /* in:obj */,
+		   void *buf /* out:arr:size=+1:zerocopy */,
+		   size_t *count /* inout:ptr */,
+		   off_t offset /* in:obj */);
+
+/* Not supported by BLRTS.  */
+ssize_t unix_pwrite(int fd /* in:obj */,
+		    const void *buf /* in:arr:size=+1:zerocopy */,
+		    size_t count /* in:obj */,
+		    off_t offset /* in:obj */);
+
+/* Not supported by BLRTS.  */
+ssize_t unix_pread64(int fd /* in:obj */,
+		     void *buf /* out:arr:size=+1:zerocopy */,
+		     size_t *count /* inout:ptr */,
+		     off64_t offset /* in:obj */);
+
+/* Not supported by BLRTS.  */
+ssize_t unix_pwrite64(int fd /* in:obj */,
+		      const void *buf /* in:arr:size=+1:zerocopy */,
+		      size_t count /* in:obj */,
+		      off64_t offset /* in:obj */);
+
+ssize_t unix_readv(int fd /* in:obj */,
+		   void** bases /* out:arr2d:size=+1:zerocopy */,
+		   size_t* lens /* inout:arr:size=+1 */,
+		   int count /* in:obj */);
+
+ssize_t unix_writev(int fd /* in:obj */,
+		    const void** bases /* in:arr2d:size=+1:zerocopy */,
+		    size_t* lens /* in:arr:size=+1 */,
+		    int count /* in:obj */);
+
+off_t unix_lseek(int fildes /* in:obj */,
+		 off_t offset /* in:obj */,
+		 int whence /* in:obj */);
+
+off64_t unix_lseek64(int fildes /* in:obj */,
+		     off64_t offset /* in:obj */,
+		     int whence /* in:obj */);
+
+int unix_access(const char *pathname /* in:str */,
+		int mode /* in:obj */);
+
+int unix_chmod(const char *path /* in:str */,
+	       mode_t mode /* in:obj */);
+
+int unix_fchmod(int fildes /* in:obj */,
+		mode_t mode /* in:obj */);
+
+int unix_chown(const char *path /* in:str */,
+	       uid_t owner /* in:obj */,
+	       gid_t group /* in:obj */);
+
+int unix_fchown(int fd /* in:obj */,
+		uid_t owner /* in:obj */,
+		gid_t group /* in:obj */);
+
+int unix_lchown(const char *path /* in:str */,
+		uid_t owner /* in:obj */,
+		gid_t group /* in:obj */);
+
+int unix_stat(const char *path /* in:str */,
+	      mode_t *st_mode /* out:ptr */,
+	      ino_t *st_ino /* out:ptr */,
+	      dev_t *st_dev /* out:ptr */,
+	      nlink_t *st_nlink /* out:ptr */,
+	      uid_t *st_uid /* out:ptr */,
+	      gid_t *st_gid /* out:ptr */,
+	      off_t *st_size /* out:ptr */,
+	      time_t *stat_atime /* out:ptr */,
+	      time_t *stat_mtime /* out:ptr */,
+	      time_t *stat_ctime /* out:ptr */,
+	      dev_t *st_rdev /* out:ptr */,
+	      __blksize_t *st_blksize /* out:ptr */,
+	      blkcnt_t *st_blocks /* out:ptr */);
+
+int unix_fstat(int filedes /* in:obj */,
+	       mode_t *st_mode /* out:ptr */,
+	       ino_t *st_ino /* out:ptr */,
+	       dev_t *st_dev /* out:ptr */,
+	       nlink_t *st_nlink /* out:ptr */,
+	       uid_t *st_uid /* out:ptr */,
+	       gid_t *st_gid /* out:ptr */,
+	       off_t *st_size /* out:ptr */,
+	       time_t *stat_atime /* out:ptr */,
+	       time_t *stat_mtime /* out:ptr */,
+	       time_t *stat_ctime /* out:ptr */,
+	       dev_t *st_rdev /* out:ptr */,
+	       __blksize_t *st_blksize /* out:ptr */,
+	       blkcnt_t *st_blocks /* out:ptr */);
+
+int unix_lstat(const char *path /* in:str */,
+	       mode_t *st_mode /* out:ptr */,
+	       ino_t *st_ino /* out:ptr */,
+	       dev_t *st_dev /* out:ptr */,
+	       nlink_t *st_nlink /* out:ptr */,
+	       uid_t *st_uid /* out:ptr */,
+	       gid_t *st_gid /* out:ptr */,
+	       off_t *st_size /* out:ptr */,
+	       time_t *stat_atime /* out:ptr */,
+	       time_t *stat_mtime /* out:ptr */,
+	       time_t *stat_ctime /* out:ptr */,
+	       dev_t *st_rdev /* out:ptr */,
+	       __blksize_t *st_blksize /* out:ptr */,
+	       blkcnt_t *st_blocks /* out:ptr */);
+
+int unix_stat64(const char *path /* in:str */,
+		mode_t *st_mode /* out:ptr */,
+		ino64_t *st_ino /* out:ptr */,
+		dev_t *st_dev /* out:ptr */,
+		nlink_t *st_nlink /* out:ptr */,
+		uid_t *st_uid /* out:ptr */,
+		gid_t *st_gid /* out:ptr */,
+		off64_t *st_size /* out:ptr */,
+		time_t *stat_atime /* out:ptr */,
+		time_t *stat_mtime /* out:ptr */,
+		time_t *stat_ctime /* out:ptr */,
+		dev_t *st_rdev /* out:ptr */,
+		__blksize_t *st_blksize /* out:ptr */,
+		blkcnt64_t *st_blocks /* out:ptr */);
+
+int unix_fstat64(int filedes /* in:obj */,
+		 mode_t *st_mode /* out:ptr */,
+		 ino64_t *st_ino /* out:ptr */,
+		 dev_t *st_dev /* out:ptr */,
+		 nlink_t *st_nlink /* out:ptr */,
+		 uid_t *st_uid /* out:ptr */,
+		 gid_t *st_gid /* out:ptr */,
+		 off64_t *st_size /* out:ptr */,
+		 time_t *stat_atime /* out:ptr */,
+		 time_t *stat_mtime /* out:ptr */,
+		 time_t *stat_ctime /* out:ptr */,
+		 dev_t *st_rdev /* out:ptr */,
+		 __blksize_t *st_blksize /* out:ptr */,
+		 blkcnt64_t *st_blocks /* out:ptr */);
+
+int unix_lstat64(const char *path /* in:str */,
+		 mode_t *st_mode /* out:ptr */,
+		 ino64_t *st_ino /* out:ptr */,
+		 dev_t *st_dev /* out:ptr */,
+		 nlink_t *st_nlink /* out:ptr */,
+		 uid_t *st_uid /* out:ptr */,
+		 gid_t *st_gid /* out:ptr */,
+		 off64_t *st_size /* out:ptr */,
+		 time_t *stat_atime /* out:ptr */,
+		 time_t *stat_mtime /* out:ptr */,
+		 time_t *stat_ctime /* out:ptr */,
+		 dev_t *st_rdev /* out:ptr */,
+		 __blksize_t *st_blksize /* out:ptr */,
+		 blkcnt64_t *st_blocks /* out:ptr */);
+
+int unix_utime(const char *filename /* in:str */,
+	       const struct utimbuf *buf /* in:ptr:nullok */);
+
+ssize_t unix_getdents(int fd /* in:obj */,
+		      char *buf /* out:arr:size=+1 */,
+		      size_t nbytes /* in:obj */);
+
+ssize_t unix_getdents64(int fd /* in:obj */,
+			char *buf /* out:arr:size=+1 */,
+			size_t nbytes /* in:obj */);
+
+int unix_chdir(const char *path /* in:str */);
+
+/* Not supported by BLRTS.  */
+int unix_fchdir(int fd /* in:obj */);
+
+int unix_mkdir(const char *pathname /* in:str */,
+	       mode_t mode /* in:obj */);
+
+int unix_rmdir(const char *pathname /* in:str */);
+
+int unix_getcwd(char *buf /* out:arr:size=+1 */,
+		size_t size /* in:obj */);
+
+mode_t unix_umask(mode_t mask /* in:obj */);
+
+int unix_fsync(int fd /* in:obj */);
+
+int unix_fcntl(int fd /* in:obj */,
+	       int cmd /* in:obj */,
+	       void *arg /* inout:arr:size=+1:nullok */,
+	       int *arglen /* inout:ptr */);
+
+int unix_truncate(const char *path /* in:str */,
+		  off_t length /* in:obj */);
+
+/* Not supported by BLRTS.  */
+int unix_truncate64(const char *path /* in:str */,
+		    off64_t length /* in:obj */);
+
+int unix_ftruncate(int fd /* in:obj */,
+		   off_t length /* in:obj */);
+
+int unix_ftruncate64(int fd /* in:obj */,
+		     off64_t length /* in:obj */);
+
+int unix_link(const char *oldpath /* in:str */,
+	      const char *newpath /* in:str */);
+
+int unix_symlink(const char *oldpath /* in:str */,
+		 const char *newpath /* in:str */);
+
+int unix_unlink(const char *pathname /* in:str */);
+
+int unix_readlink(const char *path /* in:str */,
+		  char *buf /* out:arr:size=+1 */,
+		  size_t bufsiz /* in:obj */);
+
+int unix_rename(const char *oldpath /* in:str */,
+		const char *newpath /* in:str */);
+
+int unix_socket(int domain /* in:obj */,
+		int type /* in:obj */,
+		int protocol /* in:obj */);
+
+int unix_connect(int sockfd /* in:obj */,
+		 void *serv_addr /* in:arr:size=+1 */,
+		 socklen_t addrlen /* in:obj */);
+
+ssize_t unix_send(int s /* in:obj */,
+		  const void *buf /* in:arr:size=+1:zerocopy */,
+		  size_t len /* in:obj */,
+		  int flags /* in:obj */);
+
+ssize_t unix_recv(int s /* in:obj */,
+		  void *buf /* out:arr:size=+1:zerocopy */,
+		  size_t *len /* inout:ptr */,
+		  int flags /* in:obj */);
+
+ssize_t unix_sendto(int s /* in:obj */,
+		    const void *buf /* in:arr:size=+1:zerocopy */,
+		    size_t len /* in:obj */,
+		    int flags /* in:obj */,
+		    const void *to /* in:arr:size=+1:nullok */,
+		    socklen_t tolen /* in:obj */);
+
+ssize_t unix_recvfrom(int s /* in:obj */,
+		      void *buf /* out:arr:size=+1:zerocopy */,
+		      size_t *len /* inout:ptr */,
+		      int flags /* in:obj */,
+		      void *from /* out:arr:size=+1:nullok */,
+		      socklen_t *fromlen /* inout:ptr */);
+
+int unix_getsockname(int s /* in:obj */,
+		     void *name /* out:arr:size=+1 */,
+		     socklen_t *namelen /* inout:ptr */);
+
+int unix_getpeername(int s /* in:obj */,
+		     void *name /* out:arr:size=+1 */,
+		     socklen_t *namelen /* inout:ptr */);
+
+/* Not supported by BLRTS.  */
+int unix_getsockopt(int s /* in:obj */,
+		    int level /* in:obj */,
+		    int optname /* in:obj */,
+		    void *optval /* out:arr:size=+1:nullok */,
+		    socklen_t *optlen /* inout:ptr */);
+
+/* Not supported by BLRTS.  */
+int unix_setsockopt(int s /* in:obj */,
+		    int level /* in:obj */,
+		    int optname /* in:obj */,
+		    const void *optval /* in:arr:size=+1:nullok */,
+		    socklen_t optlen /* in:obj */);
+
+/* The below were added in V1R3M1.  */
+int unix_statfs(const char *file /* in:str */,
+		struct statfs *buf /* out:ptr */);
+
+int unix_fstatfs(int fd /* in:obj */,
+		 struct statfs *buf /* out:ptr */);
+
+int unix_statfs64(const char *file /* in:str */,
+		  struct statfs64 *buf /* out:ptr */);
+
+int unix_fstatfs64(int fd /* in:obj */,
+		   struct statfs64 *buf /* out:ptr */);
+
+#endif /* UNIX_H */
Index: sysdeps/blrts/zoid/unlink.c
===================================================================
RCS file: sysdeps/blrts/zoid/unlink.c
diff -N sysdeps/blrts/zoid/unlink.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/unlink.c	27 Jun 2007 15:20:38 -0000	1.4
@@ -0,0 +1,46 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: unlink.c,v 1.4 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+
+#include "unix.h"
+
+int
+__unlink (const char *name)
+{
+  if (name == NULL)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  return unix_decode_result(unix_unlink(name));
+}
+
+weak_alias (__unlink, unlink)
Index: sysdeps/blrts/zoid/utime.c
===================================================================
RCS file: sysdeps/blrts/zoid/utime.c
diff -N sysdeps/blrts/zoid/utime.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/utime.c	27 Jun 2007 15:20:38 -0000	1.4
@@ -0,0 +1,44 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: utime.c,v 1.4 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <errno.h>
+#include <stddef.h>
+#include <utime.h>
+
+#include "unix.h"
+
+int
+utime (const char *file, const struct utimbuf *times)
+{
+  if (file == NULL)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  return unix_decode_result(unix_utime(file, times));
+}
Index: sysdeps/blrts/zoid/write.c
===================================================================
RCS file: sysdeps/blrts/zoid/write.c
diff -N sysdeps/blrts/zoid/write.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/write.c	27 Jun 2007 15:20:38 -0000	1.6
@@ -0,0 +1,109 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: write.c,v 1.6 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <errno.h>
+#include <stddef.h>
+#include <unistd.h>
+
+#include "unix.h"
+
+//#include <stdio.h>
+
+/* Note: most of the code below is duplicated in read.c, and p/p64 variants
+   of write and read.  If anything needs to be changed in one of them, it
+   probably also should be changed in all the others!  */
+
+ssize_t
+__libc_write (int fd, const void *buf, size_t nbytes)
+{
+    static ssize_t max_write_nbytes = -1;
+    ssize_t bytes_written;
+
+    if (buf == NULL)
+    {
+	__set_errno (EINVAL);
+	return -1;
+    }
+
+    bytes_written = 0;
+    do
+    {
+	ssize_t towrite, written;
+	int error;
+
+	towrite = nbytes - bytes_written;
+
+	if (max_write_nbytes != -1 && towrite > max_write_nbytes)
+	{
+#if 0
+	    fprintf(stderr, "Adjusting write of %d bytes from %d to %d\n",
+		    nbytes, towrite, max_write_nbytes);
+#endif
+	    towrite = max_write_nbytes;
+	}
+
+	written = unix_write(fd, buf + bytes_written, towrite);
+
+	if ((error = __zoid_error()))
+	{
+	    if (error != E2BIG)
+	    {
+		/* For a generic ZOID error, just bail out.  */
+		__set_errno(error);
+		return -1;
+	    }
+#if 0
+	    fprintf(stderr, "Attempt to write %d bytes returned excessive "
+		    "size error by %d bytes\n", towrite,
+		    __zoid_excessive_size());
+#endif
+	    /* We tried to send a too large write request.  Adjust.  */
+	    max_write_nbytes = towrite - __zoid_excessive_size();
+	}
+	else
+	{
+	    if (written < 0)
+	    {
+		/* For a generic write() error, just bail out.  */
+		__set_errno(-written);
+		return -1;
+	    }
+
+	    bytes_written += written;
+
+	    if (written != towrite)
+		/* write() as such succeeded, but it wrote fewer bytes than
+		   expected.  We terminate prematurely then.  */
+		break;
+	}
+    } while (bytes_written < nbytes);
+
+    return bytes_written;
+}
+
+weak_alias (__libc_write, __write)
+weak_alias (__libc_write, write)
Index: sysdeps/blrts/zoid/writev.c
===================================================================
RCS file: sysdeps/blrts/zoid/writev.c
diff -N sysdeps/blrts/zoid/writev.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/writev.c	27 Jun 2007 15:20:38 -0000	1.6
@@ -0,0 +1,184 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: writev.c,v 1.6 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <alloca.h>
+#include <assert.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/uio.h>
+
+#include "unix.h"
+
+//#include <stdio.h>
+
+/* Note: most of the code below is duplicated in readv.c.  If anything needs
+   to be changed in one of them, it probably also should be changed in the
+   other!  */
+
+ssize_t
+__writev (int fd, const struct iovec *vector, int count)
+{
+    void** bases;
+    size_t* lens;
+    int i, min_i;
+    static ssize_t max_writev_nbytes = -1;
+    size_t bytes_total;
+    ssize_t bytes_written;
+
+    if (vector == NULL || count < 1)
+    {
+	__set_errno (EINVAL);
+	return -1;
+    }
+
+    bases = alloca(sizeof(*bases) * count);
+    lens = alloca(sizeof(*lens) * count);
+
+    bytes_total = 0;
+    for (i = 0; i < count; i++)
+    {
+	bases[i] = vector[i].iov_base;
+	lens[i] = vector[i].iov_len;
+	bytes_total += vector[i].iov_len;
+    }
+
+    bytes_written = 0;
+    min_i = 0;
+    do
+    {
+	ssize_t towrite, written;
+	int error;
+	int max_i;
+	size_t max_i_len;
+
+	towrite = 0;
+	for (i = min_i; i < count; i++)
+	    towrite += lens[i];
+
+	if (max_writev_nbytes != -1 && towrite > max_writev_nbytes)
+	{
+	    ssize_t towrite_tmp;
+#if 0
+	    fprintf(stderr, "Adjusting writev of %d bytes from %d to %d\n",
+		    bytes_total, towrite, max_writev_nbytes);
+#endif
+	    towrite = max_writev_nbytes;
+
+	    towrite_tmp = 0;
+	    for (max_i = min_i; max_i < count; max_i++)
+	    {
+		if (towrite_tmp + lens[max_i] >= towrite)
+		    break;
+		towrite_tmp += lens[max_i];
+	    }
+
+	    /* It should always exit the loop with the break.  */
+	    assert(max_i < count);
+
+	    /* max_i now points at the last array index to write with the
+	       next call.  */
+
+	    max_i_len = lens[max_i];
+	    /* Decrease the length of the last element to write, so that
+	       it does not exceed the buffer size.  */
+	    lens[max_i] = towrite - towrite_tmp;
+	}
+	else
+	{
+	    max_i = count - 1;
+	    max_i_len = lens[max_i];
+	}
+#if 0
+	fprintf(stderr, "writev will be from count %d (offset %d, len %d) "
+		"to %d (len %d)\n", min_i,
+		bases[min_i] - vector[min_i].iov_base, lens[min_i],
+		max_i, lens[max_i]);
+#endif
+	written = unix_writev(fd, (const void**)&bases[min_i], &lens[min_i],
+			      max_i - min_i + 1);
+
+	/* No matter if we succeeded or not, restore any changes we have
+	   made to lens[max_i].  Also store the length as passed to writev
+	   in max_i_len.  */
+	{
+	    size_t tmp;
+	    tmp = max_i_len;
+	    max_i_len = lens[max_i];
+	    lens[max_i] = tmp;
+	}
+
+	if ((error = __zoid_error()))
+	{
+	    if (error != E2BIG)
+	    {
+		/* For a generic ZOID error, just bail out.  */
+		__set_errno(error);
+		return -1;
+	    }
+#if 0
+	    fprintf(stderr, "Attempt to writev %d bytes returned excessive "
+		    "size error by %d bytes\n", towrite,
+		    __zoid_excessive_size());
+#endif
+	    /* We tried to send a too large writev request.  Adjust.
+	       Note: this adjustment cannot be correct for 2-D array types,
+	       because of full-packet alignment of each line.  Here, we don't
+	       take this alignment into consideration.  As a consequence,
+	       we will in some cases send less data than is actually possible,
+	       but that shouldn't be a big deal.  */
+	    max_writev_nbytes = towrite - __zoid_excessive_size();
+	}
+	else
+	{
+	    if (written < 0)
+	    {
+		/* For a generic writev() error, just bail out.  */
+		__set_errno(-written);
+		return -1;
+	    }
+
+	    bytes_written += written;
+
+	    if (written != towrite)
+		/* writev() as such succeeded, but it wrote fewer bytes than
+		   expected.  We terminate prematurely then.  */
+		break;
+
+	    /* We wrote successfully.  Prepare for the next iteration, should
+	       it be needed.  */
+	    bases[max_i] += max_i_len;
+	    lens[max_i] -= max_i_len;
+	    if (lens[max_i] == 0)
+		max_i++;
+	    min_i = max_i;
+	}
+    } while (bytes_written < bytes_total);
+
+    return bytes_written;
+}
+
+weak_alias (__writev, writev)
Index: sysdeps/blrts/zoid/xstat.c
===================================================================
RCS file: sysdeps/blrts/zoid/xstat.c
diff -N sysdeps/blrts/zoid/xstat.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/xstat.c	27 Jun 2007 15:20:38 -0000	1.5
@@ -0,0 +1,52 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: xstat.c,v 1.5 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <errno.h>
+#include <stddef.h>
+#include <sys/stat.h>
+
+#include "unix.h"
+
+int
+__xstat (int vers, const char *file, struct stat *buf)
+{
+  if (vers != 0 || file == NULL || buf == NULL)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  return unix_decode_result(unix_stat(file, &buf->st_mode, &buf->st_ino,
+				      &buf->st_dev, &buf->st_nlink,
+				      &buf->st_uid, &buf->st_gid,
+				      &buf->st_size, &buf->st_atime,
+				      &buf->st_mtime, &buf->st_ctime,
+				      &buf->st_rdev, &buf->st_blksize,
+				      &buf->st_blocks));
+}
+
+weak_alias (__xstat, _xstat)
Index: sysdeps/blrts/zoid/xstat64.c
===================================================================
RCS file: sysdeps/blrts/zoid/xstat64.c
diff -N sysdeps/blrts/zoid/xstat64.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/xstat64.c	27 Jun 2007 15:20:38 -0000	1.5
@@ -0,0 +1,50 @@
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: xstat64.c,v 1.5 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_MOD
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <errno.h>
+#include <stddef.h>
+#include <sys/stat.h>
+
+#include "unix.h"
+
+int
+__xstat64 (int vers, const char *file, struct stat64 *buf)
+{
+  if (vers != 0 || file == NULL || buf == NULL)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  return unix_decode_result(unix_stat64(file, &buf->st_mode, &buf->st_ino,
+					&buf->st_dev, &buf->st_nlink,
+					&buf->st_uid, &buf->st_gid,
+					&buf->st_size, &buf->st_atime,
+					&buf->st_mtime, &buf->st_ctime,
+					&buf->st_rdev, &buf->st_blksize,
+					&buf->st_blocks));
+}
Index: sysdeps/blrts/zoid/zoid_api.h
===================================================================
RCS file: sysdeps/blrts/zoid/zoid_api.h
diff -N sysdeps/blrts/zoid/zoid_api.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/zoid_api.h	27 Jun 2007 15:20:38 -0000	1.10
@@ -0,0 +1,76 @@
+/* Please note that this file is shared between ZOID and GLIBC!  */
+
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: zoid_api.h,v 1.10 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_ORIG
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#ifndef ZOID_API_H
+#define ZOID_API_H
+
+#include <stdlib.h>
+
+struct dispatch_array
+{
+    void* function_ptr;
+    void* (*userbuf_allocate_cb)(int len);
+};
+
+#define __zoid_0c_in_buf(start, current) \
+    ((start) - sizeof(int) + \
+        ((current) - ((start) - sizeof(int)) + 239) / 240 * 240)
+
+#define __zoid_0c_buf_align(size) \
+    (((size) + 239) / 240 * 240)
+
+#define __zoid_0c_out_buf_hdr1 sizeof(int)
+
+#define __zoid_0c_out_buf_hdr2 (2 * sizeof(int))
+
+#define __zoid_0c_out_buf_ftr(_i, _cnt) ((_i) < (_cnt) - 1 ? sizeof(int) : 0)
+
+/* CNK-side calls.  */
+int __zoid_submit_command(char* buffer, int cmd_len, int max_res_len,
+			  int userbuf, const void* arr2d, const void* arr,
+			  int arr_cnt, int arr_el_size, void* out_arr);
+int __zoid_error(void);
+int __zoid_excessive_size(void);
+
+/* Daemon-side calls.  */
+void __zoid_register_functions(int header_id,
+			       struct dispatch_array* dispatch_array,
+			       int array_size, void (*init_func)(int),
+			       void (*fini_func)(void));
+int __zoid_calling_process_id(void);
+void __zoid_register_userbuf(void* userbuf,
+			     void (*callback)(void* userbuf, void* priv),
+			     void* priv);
+int __zoid_send_output(int pid, int fd, const char* buffer, int len);
+
+/* Both CNK- and daemon-side calls.  */
+void* __zoid_allocate_buffer(size_t size);
+void __zoid_release_buffer(void* buffer);
+
+#endif
Index: sysdeps/blrts/zoid/zoid_mapping.c
===================================================================
RCS file: sysdeps/blrts/zoid/zoid_mapping.c
diff -N sysdeps/blrts/zoid/zoid_mapping.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/zoid_mapping.c	27 Jun 2007 15:20:38 -0000	1.3
@@ -0,0 +1,221 @@
+/* Please note that this file is shared between ZOID and GLIBC!  */
+
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: zoid_mapping.c,v 1.3 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_ORIG
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#include <ctype.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <bglpersonality.h>
+
+struct zoid_mapping
+{
+    char coord; /* 'x', 'y', 'z', or 't' (or '\0', if not in use).  */
+    int size;
+};
+
+static struct zoid_mapping zoid_mapping[4];
+static int proc_count;
+static int vn_mode;
+
+/*
+ * Initialize mapping between x/y/z/t coordinates and MPI rank.
+ * FIXME!  We don't support mappings provided by the user to mpirun using
+ * -mapfile argument.
+ */
+int
+__zoid_mapping_init(const char* mapping, int arg_proc_count, int arg_vn_mode,
+		    const BGLPersonality* personality)
+{
+    int x_used = 0, y_used = 0, z_used = 0, t_used = 0;
+    int i;
+
+    proc_count = arg_proc_count;
+    vn_mode = arg_vn_mode;
+
+    /* We allow this to be larger, so that "XYZT" works in coprocessor
+       mode.  */
+    if (strlen(mapping) < 3 + vn_mode)
+    {
+	//fprintf(stderr, "Invalid BGLMPI_MAPPING\n");
+	return 1;
+    }
+
+    /* Fill in the "mapping" array in the order specified by the user.  */
+    for (i = 0; i < 3 + vn_mode && *mapping; i++)
+    {
+	switch (tolower(*mapping))
+	{
+	    case 'x':
+		zoid_mapping[i].size = personality->xSize;
+		x_used++;
+		break;
+
+	    case 'y':
+		zoid_mapping[i].size = personality->ySize;
+		y_used++;
+		break;
+
+	    case 'z':
+		zoid_mapping[i].size = personality->zSize;
+		z_used++;
+		break;
+
+	    case 't':
+		if (!vn_mode)
+		{
+		    /* If we are not in VN mode, we should ignore T.
+		       We don't flag it as an error, to support "TXYZ" in
+		       coprocessor mode.
+		       This is a bit of a hack...  */
+		    mapping++;
+		    i--;
+		    continue;
+		}
+		zoid_mapping[i].size = 2;
+		t_used++;
+		break;
+
+	    default:
+		//fprintf(stderr, "Invalid BGLMPI_MAPPING\n");
+		return 1;
+	}
+
+	zoid_mapping[i].coord = tolower(*mapping++);
+    }
+
+    if (x_used != 1 || y_used !=1 || z_used !=1 ||
+	(vn_mode && t_used != 1))
+    {
+	//fprintf(stderr, "Invalid BGLMPI_MAPPING\n");
+	return 1;
+    }
+
+    if (i == 3)
+    {
+	/* Make sure to mark unused as such (required if switching from VN
+	   to CO mode).  */
+	zoid_mapping[3].coord = '\0';
+	zoid_mapping[3].size = 0;
+    }
+
+    return 0;
+}
+
+int
+__zoid_mapping_to_coord(unsigned mpi_rank,
+			unsigned *x, unsigned *y, unsigned *z, unsigned *t)
+{
+    int rank;
+    int i;
+
+    if (mpi_rank < 0 || mpi_rank >= proc_count)
+	return -1;
+
+    rank = 0;
+    for (i = 0; i < sizeof(zoid_mapping) / sizeof(zoid_mapping[0]) &&
+		zoid_mapping[i].coord; i++)
+    {
+	int new_coord;
+
+	new_coord = mpi_rank % zoid_mapping[i].size;
+	mpi_rank /= zoid_mapping[i].size;
+
+	switch (zoid_mapping[i].coord)
+	{
+	    case 'x':
+		*x = new_coord;
+		break;
+	    case 'y':
+		*y = new_coord;
+		break;
+	    case 'z':
+		*z = new_coord;
+		break;
+	    case 't':
+		*t = new_coord;
+		break;
+	}
+    }
+
+    if (!vn_mode)
+	*t = 0;
+
+    return 0;
+}
+
+int
+__zoid_mapping_to_rank(unsigned x, unsigned y, unsigned z, unsigned t,
+		       unsigned *mpi_rank)
+{
+    int rank;
+    int i, multiplier;
+
+    if (!vn_mode && t != 0)
+	return -1;
+
+    rank = 0;
+    multiplier = 1;
+    for (i = 0; i < sizeof(zoid_mapping) / sizeof(zoid_mapping[0]) &&
+		zoid_mapping[i].coord; i++)
+    {
+	int new_coord;
+
+	switch (zoid_mapping[i].coord)
+	{
+	    case 'x':
+		new_coord = x;
+		break;
+	    case 'y':
+		new_coord = y;
+		break;
+	    case 'z':
+		new_coord = z;
+		break;
+	    case 't':
+		new_coord = t;
+		break;
+	    default:
+		/* This is just to shut down a compiler warning.  */
+		new_coord = 0;
+	}
+
+	if (new_coord < 0 || new_coord >= zoid_mapping[i].size)
+	    return -1;
+
+	rank += new_coord * multiplier;
+	multiplier *= zoid_mapping[i].size;
+
+	if (rank >= proc_count)
+	    return -1;
+    }
+
+    *mpi_rank = rank;
+
+    return 0;
+}
Index: sysdeps/blrts/zoid/zoid_mapping.h
===================================================================
RCS file: sysdeps/blrts/zoid/zoid_mapping.h
diff -N sysdeps/blrts/zoid/zoid_mapping.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/zoid_mapping.h	27 Jun 2007 15:20:38 -0000	1.5
@@ -0,0 +1,42 @@
+/* Please note that this file is shared between ZOID and GLIBC!  */
+
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: zoid_mapping.h,v 1.5 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_ORIG
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#ifndef ZOID_MAPPING_H
+#define ZOID_MAPPING_H
+
+#ifdef __bglpersonality_h__
+int __zoid_mapping_init(const char* mapping, int arg_proc_count,
+			int arg_vn_mode, const BGLPersonality* personality);
+#endif
+int __zoid_mapping_to_coord(unsigned mpi_rank, unsigned *x, unsigned *y,
+			    unsigned *z, unsigned *t);
+
+int __zoid_mapping_to_rank(unsigned x, unsigned y, unsigned z, unsigned t,
+			   unsigned *mpi_rank);
+#endif
Index: sysdeps/blrts/zoid/zoid_protocol.h
===================================================================
RCS file: sysdeps/blrts/zoid/zoid_protocol.h
diff -N sysdeps/blrts/zoid/zoid_protocol.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/blrts/zoid/zoid_protocol.h	27 Jun 2007 15:20:38 -0000	1.11
@@ -0,0 +1,157 @@
+/* Please note that this file is shared between ZOID and GLIBC!  */
+
+/****************************************************************************/
+/* ZEPTOOS:zepto-info */
+/*     This file is part of ZeptoOS: The Small Linux for Big Computers.
+ *     See www.mcs.anl.gov/zeptoos for more information.
+ */
+/* ZEPTOOS:zepto-info */
+/* */
+/* ZEPTOOS:zepto-fillin */
+/*     $Id: zoid_protocol.h,v 1.11 2007/06/27 15:20:38 iskra Exp $
+ *     ZeptoOS_Version: 1.2
+ *     ZeptoOS_Heredity: FOSS_ORIG
+ *     ZeptoOS_License: GPL
+ */
+/* ZEPTOOS:zepto-fillin */
+/* */
+/* ZEPTOOS:zepto-gpl */
+/*      Copyright: Argonne National Laboratory, Department of Energy,
+ *                 and UChicago Argonne, LLC.  2004, 2005, 2006, 2007
+ *      ZeptoOS License: GPL
+ * 
+ *      This software is free.  See the file ZeptoOS/misc/license.GPL
+ *      for complete details on your rights to copy, modify, and use this
+ *      software.
+ */
+/* ZEPTOOS:zepto-gpl */
+/****************************************************************************/
+
+#ifndef ZOID_PROTOCOL_H
+#define ZOID_PROTOCOL_H
+
+/*
+  Description of the ZOID protocol:
+
+  The protocol over the tree network is based on packets of 256 bytes.
+  Each packet contains a 16-byte soft header of type "ZoidSoftHeader", leaving
+  240 bytes for effective data.
+
+  There are differences between commands and replies, and zero-copy support
+  introduces additional complications.
+
+  Commands have a simpler structure than replies.  Each command begins with
+  a mixed control-data packet.  That packet starts with a 32-bit command id,
+  filled in by the automatically generated command stub.  The ID is followed
+  by command-specific arguments (data).  The arguments are unaligned.
+
+  If there is a zero-copy input, it is passed in separate data packets, after
+  the main command-data packets.  There is no control data for zero-copy input,
+  because all necessary information is provided in the preceding command-data.
+  Each chunk of zero-copy data (i.e. each line of 2-D array) begins at a new
+  packet, to ease the copying from user buffers.
+  The soft header "msg_length" field includes the input zero-copy data.
+
+  Plain replies (those with no zero-copy results) are even simpler than
+  commands.  They contain no command ID, only the data filled in by the
+  automatically generated command stub.
+
+  Replies with zero-copy results have the most complex structure.  They start
+  with a 32-bit integer specifying offset where the zero-copy data starts.
+  The offset is followed by standard stub-generated data.  Zero-copy data
+  contains all control information necessary to fill in the provided target
+  buffer.  The offset points at a 32-bit integer specifying the size along
+  the major dimension.  If he array is 1-D, that size will be "-1".  The size
+  is normally attached to the last reply-data packet, since it does not need
+  to be aligned.  The major dimension size is followed by the size of the
+  first minor dimension (or simply the array size for 1-D arrays).  That size
+  is always in bytes.  User data lines are passed aligned to full packet
+  boundary, like with zero-copy input.  However, each line, with the exception
+  of the last one, is followed by a 32-bit integer specifying the byte size of
+  the next line.  For replies, the soft header "msg_length" field does *not*
+  include the zero-copy data; it only includes the two 32-bit integers
+  following the reply-data.
+
+  Why are zero-copy replies so much different from zero-copy commands?
+  Because for commands, a single buffer can be allocated on the server for the
+  whole command, including the zero-copy data.  For replies, on the other hand,
+  multiple buffers must be used on the client: one provided by the ZOID
+  infrastructure and one for user data.
+
+  There is an optional support for rendezvous (for commands).  If a command
+  packet contains the NEED_ACK_PACKET flag, the server must reply with
+  ACK_PACKET before the rest of the command is sent.  This improves fairness,
+  as nodes closer to the I/O node in the collective topology lose that
+  advantage then.  If message acknowledgements are enabled, the NEED_ACK flag
+  is normally set for the first packet of a long (larger than 8 packets)
+  command, and the server sends out the acknowledgements one at a time, so
+  that the nodes don't need to share the bandwidth.
+
+  The "userbuf" flag introduces some comparatively minor changes to the
+  protocol.  There are *no* changes for output userbuf.  For input userbuf,
+  the order of packing of function arguments changes so that the argument
+  specifying the array length is always the first one, right after the
+  command id.  Putting it at this predictable place makes it easy to obtain
+  the size of the buffer to be allocated by the callback.  In addition to that,
+  the zero-copy part is not included in the softheader's msg_length field.
+  Also, input userbuf commands *always* require message acknowledgements.
+  Instead of NEED_ACK_PACKET, a separate INPUT_USERBUF_PACKET flag is used,
+  and it is set not on the first packet of a message, but on the last packet
+  of the non-userbuf portion of the message.
+ */
+
+/* Structure of the initial messages sent from compute node processes to zoid
+   on VC1.  These do not have a soft header.  */
+struct InitMsg
+{
+    int pset_cpu_rank;
+    int p2p_addr;
+    int pid;
+    int pset_rank;
+    int cpu;
+    int vn_mode;
+    int total_proc;
+    char mapping[5];
+};
+
+/* Structure sent back from ION to CNs.  Again, no soft header.  */
+struct InitMsgReply
+{
+    int max_buffer_size;
+    int ack_threshold;
+};
+
+/* The tree/collective network soft header.  To preserve optimal alignment,
+   it needs to be 16 bytes.  We might add more fields in the future, if we
+   add async/collective support.  */
+struct ZoidSoftHeader
+{
+    uint32_t zoid_id;
+    uint16_t pset_cpu_rank;
+    uint16_t flags;
+    uint32_t msg_length;
+    uint32_t errnum; /* Used in replies from zoid ION daemon only.  */
+} QUAD_ALIGN;
+
+/* Bits in "flags" above.  */
+#define ZOID_SOFTHEADER_FIRST_PACKET (1 << 0)
+#define ZOID_SOFTHEADER_LAST_PACKET  (1 << 1)
+/* Indicates a special one-packet emergency message that can occur even
+   in the middle of another message.  */
+#define ZOID_SOFTHEADER_ASSERT_PACKET (1 << 2)
+/* Indicates that the client will only send the rest of the message after
+   the server sends it an ACK_PACKET.  */
+#define ZOID_SOFTHEADER_NEED_ACK_PACKET (1 << 3)
+#define ZOID_SOFTHEADER_ACK_PACKET (1 << 4)
+/* Sent in the middle of input userbuf message, indicates the last packet
+   of the non-userbuf part of the message.  Implies NEED_ACK_PACKET.  */
+#define ZOID_SOFTHEADER_INPUT_USERBUF_PACKET (1 << 5)
+
+/* Special-purpose command to inform the zoid daemon that a process is
+   about to terminate.  */
+#define ZOID_TERMINATING_ID ~0
+
+/* Unique ZOID identifier.  */
+#define ZOID_ID ('Z' << 24 | 'O' << 16 | 'I' << 8 | 'D')
+
+#endif

