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 +#include +#include + +#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 + +/* 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 +#include +#include + +#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 +#include +#include + +#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 +#include +#include + +#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 +#include + +#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 +#include +#include + +#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 + +#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 + +#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 + +#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 + +#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 + +#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 +#include + +#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 + +#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 + +#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 + +#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 + +#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 + +#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 +#include +#include + +#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 +#include +#include + +#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 +#include +#include +#include +#include + +#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 +#include + +#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 +#include + +#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 + +#include +#include + +/* 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 +#include +#include + +#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 + +#include +#include + +/* 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 +#include +#include + +#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 + +#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 + +#include +#include + +/* 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 +#include +#include +#include + +#include +#include + +#include +#include +#include + +#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 +#include +#include + +#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 +#include +#include + +#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 + +#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 + +#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 +#include +#include + +#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 +#include +#include + +#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 +#include +#include + +#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 +#include +#include +#include + +#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 +#include +#include + +#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 +#include +#include + +#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 +#include +#include + +#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 +#include +#include + +#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 +#include +#include + +#include "unix.h" + +//#include + +/* 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 +#include +#include + +#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 +#include +#include +#include +#include + +#include "unix.h" + +//#include + +/* 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 +#include +#include + +#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) + {