head 1.1; branch 1.1.1; access; symbols pkgsrc-2026Q1:1.1.1.1.0.118 pkgsrc-2026Q1-base:1.1.1.1 pkgsrc-2025Q4:1.1.1.1.0.116 pkgsrc-2025Q4-base:1.1.1.1 pkgsrc-2025Q3:1.1.1.1.0.114 pkgsrc-2025Q3-base:1.1.1.1 pkgsrc-2025Q2:1.1.1.1.0.112 pkgsrc-2025Q2-base:1.1.1.1 pkgsrc-2025Q1:1.1.1.1.0.110 pkgsrc-2025Q1-base:1.1.1.1 pkgsrc-2024Q4:1.1.1.1.0.108 pkgsrc-2024Q4-base:1.1.1.1 pkgsrc-2024Q3:1.1.1.1.0.106 pkgsrc-2024Q3-base:1.1.1.1 pkgsrc-2024Q2:1.1.1.1.0.104 pkgsrc-2024Q2-base:1.1.1.1 pkgsrc-2024Q1:1.1.1.1.0.102 pkgsrc-2024Q1-base:1.1.1.1 pkgsrc-2023Q4:1.1.1.1.0.100 pkgsrc-2023Q4-base:1.1.1.1 pkgsrc-2023Q3:1.1.1.1.0.98 pkgsrc-2023Q3-base:1.1.1.1 pkgsrc-2023Q2:1.1.1.1.0.96 pkgsrc-2023Q2-base:1.1.1.1 pkgsrc-2023Q1:1.1.1.1.0.94 pkgsrc-2023Q1-base:1.1.1.1 pkgsrc-2022Q4:1.1.1.1.0.92 pkgsrc-2022Q4-base:1.1.1.1 pkgsrc-2022Q3:1.1.1.1.0.90 pkgsrc-2022Q3-base:1.1.1.1 pkgsrc-2022Q2:1.1.1.1.0.88 pkgsrc-2022Q2-base:1.1.1.1 pkgsrc-2022Q1:1.1.1.1.0.86 pkgsrc-2022Q1-base:1.1.1.1 pkgsrc-2021Q4:1.1.1.1.0.84 pkgsrc-2021Q4-base:1.1.1.1 pkgsrc-2021Q3:1.1.1.1.0.82 pkgsrc-2021Q3-base:1.1.1.1 pkgsrc-2021Q2:1.1.1.1.0.80 pkgsrc-2021Q2-base:1.1.1.1 pkgsrc-2021Q1:1.1.1.1.0.78 pkgsrc-2021Q1-base:1.1.1.1 pkgsrc-2020Q4:1.1.1.1.0.76 pkgsrc-2020Q4-base:1.1.1.1 pkgsrc-2020Q3:1.1.1.1.0.74 pkgsrc-2020Q3-base:1.1.1.1 pkgsrc-2020Q2:1.1.1.1.0.70 pkgsrc-2020Q2-base:1.1.1.1 pkgsrc-2020Q1:1.1.1.1.0.50 pkgsrc-2020Q1-base:1.1.1.1 pkgsrc-2019Q4:1.1.1.1.0.72 pkgsrc-2019Q4-base:1.1.1.1 pkgsrc-2019Q3:1.1.1.1.0.68 pkgsrc-2019Q3-base:1.1.1.1 pkgsrc-2019Q2:1.1.1.1.0.66 pkgsrc-2019Q2-base:1.1.1.1 pkgsrc-2019Q1:1.1.1.1.0.64 pkgsrc-2019Q1-base:1.1.1.1 pkgsrc-2018Q4:1.1.1.1.0.62 pkgsrc-2018Q4-base:1.1.1.1 pkgsrc-2018Q3:1.1.1.1.0.60 pkgsrc-2018Q3-base:1.1.1.1 pkgsrc-2018Q2:1.1.1.1.0.58 pkgsrc-2018Q2-base:1.1.1.1 pkgsrc-2018Q1:1.1.1.1.0.56 pkgsrc-2018Q1-base:1.1.1.1 pkgsrc-2017Q4:1.1.1.1.0.54 pkgsrc-2017Q4-base:1.1.1.1 pkgsrc-2017Q3:1.1.1.1.0.52 pkgsrc-2017Q3-base:1.1.1.1 pkgsrc-2017Q2:1.1.1.1.0.48 pkgsrc-2017Q2-base:1.1.1.1 pkgsrc-2017Q1:1.1.1.1.0.46 pkgsrc-2017Q1-base:1.1.1.1 pkgsrc-2016Q4:1.1.1.1.0.44 pkgsrc-2016Q4-base:1.1.1.1 pkgsrc-2016Q3:1.1.1.1.0.42 pkgsrc-2016Q3-base:1.1.1.1 pkgsrc-2016Q2:1.1.1.1.0.40 pkgsrc-2016Q2-base:1.1.1.1 pkgsrc-2016Q1:1.1.1.1.0.38 pkgsrc-2016Q1-base:1.1.1.1 pkgsrc-2015Q4:1.1.1.1.0.36 pkgsrc-2015Q4-base:1.1.1.1 pkgsrc-2015Q3:1.1.1.1.0.34 pkgsrc-2015Q3-base:1.1.1.1 pkgsrc-2015Q2:1.1.1.1.0.32 pkgsrc-2015Q2-base:1.1.1.1 pkgsrc-2015Q1:1.1.1.1.0.30 pkgsrc-2015Q1-base:1.1.1.1 pkgsrc-2014Q4:1.1.1.1.0.28 pkgsrc-2014Q4-base:1.1.1.1 pkgsrc-2014Q3:1.1.1.1.0.26 pkgsrc-2014Q3-base:1.1.1.1 pkgsrc-2014Q2:1.1.1.1.0.24 pkgsrc-2014Q2-base:1.1.1.1 pkgsrc-2014Q1:1.1.1.1.0.22 pkgsrc-2014Q1-base:1.1.1.1 pkgsrc-2013Q4:1.1.1.1.0.20 pkgsrc-2013Q4-base:1.1.1.1 pkgsrc-2013Q3:1.1.1.1.0.18 pkgsrc-2013Q3-base:1.1.1.1 pkgsrc-2013Q2:1.1.1.1.0.16 pkgsrc-2013Q2-base:1.1.1.1 pkgsrc-2013Q1:1.1.1.1.0.14 pkgsrc-2013Q1-base:1.1.1.1 pkgsrc-2012Q4:1.1.1.1.0.12 pkgsrc-2012Q4-base:1.1.1.1 pkgsrc-2012Q3:1.1.1.1.0.10 pkgsrc-2012Q3-base:1.1.1.1 pkgsrc-2012Q2:1.1.1.1.0.8 pkgsrc-2012Q2-base:1.1.1.1 pkgsrc-2012Q1:1.1.1.1.0.6 pkgsrc-2012Q1-base:1.1.1.1 pkgsrc-2011Q4:1.1.1.1.0.4 pkgsrc-2011Q4-base:1.1.1.1 pkgsrc-2011Q3:1.1.1.1.0.2 pkgsrc-2011Q3-base:1.1.1.1 pkgsrc-base:1.1.1.1 TNF:1.1.1; locks; strict; comment @# @; 1.1 date 2011.07.27.10.23.49; author cherry; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 2011.07.27.10.23.49; author cherry; state Exp; branches; next ; desc @@ 1.1 log @Initial revision @ text @$NetBSD$ --- src/netbsd/misc-netbsd.c.orig 2009-12-16 12:47:32.000000000 +0000 +++ src/netbsd/misc-netbsd.c @@@@ -0,0 +1,120 @@@@ +/* + * Copyright (C) 1995-2007, Hewlett-Packard Development Company, L.P. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include +#include +#include +#include +#include +#include + +#include "std.h" +#include "types.h" +#include "state.h" + +#include "netbsd/machdep-netbsd.h" + +int _close(int); +int _open(const char *, int, int); + +CTR prof_insts = ~0ULL; +char *src_root; + +#define SKI_NFDS 20 +int fdlimit; +int fdmap[SKI_NFDS]; + +void setFdmap(int fd1, int fd2) +{ + assert(0); +} + +void profCnt(void) +{ + assert(0); +} + +void saveOpenFiles(FILE *f) +{ +} + +void restoreOpenFile(char *name, unsigned flag, unsigned mode, unsigned offset) +{ +} + +/* + * We use our own implementation of open to force file descriptors + * opened by ski for ski to be larger than what we allow for the + * simulated process. This avoids nasty mappings... + */ +int open(const char *path, int flags, int mode) +{ + int res, fd; + + if (!unixABI) + return (_open(path, flags, mode)); + + if (fdlimit == 0) { + fdlimit = getdtablesize() - SKI_NFDS; + if (fdlimit < 20) { + fprintf(stderr, "FD table size underflow\n"); + abort(); + } + dup2(0, fdlimit); + dup2(1, fdlimit + 1); + dup2(2, fdlimit + 2); + fdmap[0] = fdmap[1] = fdmap[2] = 1; + /* XXX we shouldn't go under the hood */ + stdin->_file += fdlimit; + stdout->_file += fdlimit; + stderr->_file += fdlimit; + } + + res = _open(path, flags, mode); + if (res >= fdlimit) { + _close(res); + errno = EMFILE; + return (-1); + } else if (res == -1) + return (res); + + fd = 0; + while (fd < SKI_NFDS && fdmap[fd]) + fd++; + if (fd == SKI_NFDS) { + _close(res); + errno = EMFILE; + return (-1); + } + if (dup2(res, fd + fdlimit) == -1) { + _close(res); + errno = EMFILE; + return (-1); + } + _close(res); + fdmap[fd] = 1; + return (fd + fdlimit); +} + +int close(int fd) +{ + if (fd >= fdlimit && fdlimit != 0) + fdmap[fd - fdlimit] = 0; + _close(fd); +} @ 1.1.1.1 log @import wip/ski @ text @@