├── .gitignore ├── Makefile ├── README.md ├── contrib └── parallel_build ├── doc ├── APACHE-LICENSE.TXT ├── COPYING ├── ChangeLog ├── IVME.xls ├── IVME04 Submission Report.pdf ├── IVME2.xls ├── acmconf.cls ├── chart1.pdf ├── chart2.pdf ├── chart3.pdf ├── chart4.pdf ├── chart5.pdf ├── chart6.pdf ├── chart7.pdf ├── charts │ ├── boxfill.pl │ ├── chart1.dat │ ├── chart1.gnuplot │ ├── chart10.dat │ ├── chart10.gnuplot │ ├── chart11.dat │ ├── chart11.gnuplot │ ├── chart2.dat │ ├── chart2.gnuplot │ ├── chart3.dat │ ├── chart3.gnuplot │ ├── chart4.dat │ ├── chart4.gnuplot │ ├── chart5.dat │ ├── chart5.gnuplot │ ├── chart6.dat │ ├── chart6.gnuplot │ ├── chart7.dat │ ├── chart7.gnuplot │ ├── chart8.dat │ ├── chart8.gnuplot │ ├── chart9.dat │ └── chart9.gnuplot ├── ivme-slides.tex ├── ivme04.bib ├── ivme04.tex ├── max_per_method.pdf ├── nestedvm.ivme04.bbl ├── pdftricks.sty ├── pst2pdf ├── reviewer.comments.txt ├── runtimenotes.txt └── tmp.inputs ├── docker └── debian │ └── Dockerfile ├── src ├── org │ └── ibex │ │ └── nestedvm │ │ ├── ClassFileCompiler.java │ │ ├── Compiler.java │ │ ├── Interpreter.java │ │ ├── JavaSourceCompiler.java │ │ ├── Registers.java │ │ ├── Runtime.java │ │ ├── RuntimeCompiler.java │ │ ├── UnixRuntime.java │ │ ├── UsermodeConstants.java │ │ ├── crt0.c │ │ ├── linker.ld │ │ ├── support.s │ │ ├── support_aux.c │ │ ├── syscalls.h │ │ └── util │ │ ├── ELF.java │ │ ├── InodeCache.java │ │ ├── Platform.java │ │ ├── Seekable.java │ │ ├── Sort.java │ │ └── UnixRuntimeJavaBridge.java └── tests │ ├── CXXTest.cc │ ├── CallTest.java │ ├── Echo.java │ ├── EchoHelper.c │ ├── Env.java │ ├── FTBench.c │ ├── Fork.c │ ├── FreeTypeDemo.java │ ├── FreeTypeDemoHelper.c │ ├── GenericSpeedTest.java │ ├── Hello.c │ ├── MSPack.java │ ├── MSPackBench.c │ ├── MSPackHelper.c │ ├── Paranoia.c │ ├── PascalHello.pas │ ├── Simple.c │ ├── SpeedTest.java │ ├── Test.c │ └── check.sh └── upstream ├── Makefile ├── build └── .gitignore ├── download ├── gc6.3alpha2.tar.gz ├── gpc-20030830.tar.gz ├── openbsdglob.tar.gz └── regex3.8a.tar.gz ├── img └── 25331-night4.jpg ├── misc ├── crt0-override.spec ├── extraheaders.sh └── tex.ch ├── patches ├── binutils-2.24.patch ├── binutils-2.25.patch ├── binutils-2.26.patch ├── binutils-2.27.patch ├── binutils-no64.patch ├── binutils-nocompilein.patch ├── binutils.patch ├── boehm-gc.patch ├── busybox.patch ├── freetype.patch ├── ft-nostdio.patch ├── gcc-64bitclean.patch ├── gcc-fdata-sections-bss.patch ├── gcc-fixes.patch ├── gcc-with-newer-version.patch ├── gcc.patch ├── gpc-noutils.patch ├── gpc-with-3.3.3.patch ├── libmspack.patch ├── newlib-malloc.patch ├── newlib-mips.patch ├── newlib-nestedvm-define.patch ├── newlib-new.patch ├── newlib-nomemcpy.patch ├── newlib-sdata.patch ├── newlib-texinfo.patch ├── newlib-tzset.patch ├── newlib-unistd.patch ├── newlib-unix.patch ├── newlib.patch └── samba.patch └── tasks ├── .gitignore ├── download_boehmgc ├── download_gpc ├── download_openbsdglob └── download_regex /.gitignore: -------------------------------------------------------------------------------- 1 | upstream/tasks/* 2 | upstream/build/* 3 | upstream/download 4 | upstream/install 5 | build 6 | env.sh 7 | *.jar 8 | .manifest 9 | .project 10 | .classpath 11 | .settings 12 | tmp 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Updated NestedVM toolchain 2 | ========================== 3 | 4 | This repository contains an updated [NestedVM][1] toolchain that is suitable 5 | for building modern C/C++ applications to pure Java bytecode. The official 6 | NestedVM project hosted at [nestedvm.ibex.org][1] only supports an old version 7 | of GCC (3.3.6). Fortunately, [Henry Wertz][2] has made available to use GCC 8 | 4.8 and an updated newlib, and this repository includes those patches. 9 | 10 | This repo also has some bug fixes by [David Ehrmann][3] to NestedVM's 11 | `UnixRuntime` and the parsing of ELF files generated by GCC 4.8. 12 | 13 | Also incorporated in this repo are [John Stroy's][4] updates to 14 | the NestedVM runtime. 15 | 16 | ## Installation 17 | 18 | The NestedVM toolchain consists mainly of the following components: 19 | 20 | * Lightly patched GCC+binutils+newlib toolchain for compiling C/C++ programs 21 | to MIPS binaries 22 | * A compiler written in Java that is capable of translating MIPS binaries 23 | into both Java source code and Java bytecode (Java bytecode is the 24 | recommended target format) 25 | * A runtime support library that comes in 2 flavors, "standard" and "Unix". 26 | The standard runtime is a minimal runtime, just enough to support programs 27 | that only read and write from streams and memory. The "Unix" runtime on the 28 | other hand provides a significant amount of functionality that should allow 29 | many posix programs to compile and run. 30 | 31 | To build NestedVM, clone this repository and run `make dist`. This might take 32 | a while, but when finished you will have all of the above components available 33 | in `upstream/install`. The toolchain can be used from that location, or the 34 | directory can be copied to some other location if you wish. You can use 35 | `make install` to achieve this (will install to `/usr/local/nestedvm` by 36 | default). If you want to install to some location other than the default, 37 | specify the `prefix` environment variable. For example, to install to 38 | `/tmp/nestedvm`, you can run `make install prefix=/tmp`. 39 | 40 | *Known issue: the version of binutils being used does not build properly with 41 | GCC 4.9... please try GCC 4.8 or clang* 42 | 43 | Below are some system-specific build instructions for this repository; pull 44 | requests with steps for other environments are certainly welcome. 45 | 46 | ### Debian 8 etc: 47 | 48 | apt-get -y update && apt-get -y upgrade 49 | apt-get -y install build-essential libgmp-dev libmpc-dev libmpfr-dev git curl openjdk-7-jdk gcc-4.8 g++-4.8 50 | cd /usr/local/src 51 | git clone https://github.com/bgould/nestedvm 52 | cd /usr/local/src/nestedvm 53 | make dist CC=gcc-4.8 CXX=g++-4.8 54 | 55 | ### CentOS 7: 56 | 57 | yum -y update 58 | yum install -y java-1.7.0-openjdk-devel git gmp-devel libmpc-devel mpfr-devel 59 | yum -y groupinstall "Development Tools" 60 | cd /usr/local/src 61 | git clone https://github.com/bgould/nestedvm 62 | cd /usr/local/src/nestedvm 63 | make dist 64 | 65 | [1]: http://nestedvm.ibex.org/ 66 | [2]: http://article.gmane.org/gmane.comp.java.nestedvm/185 67 | [3]: https://github.com/ehrmann/nestedvm 68 | [4]: https://github.com/jdstroy/nestedvm 69 | -------------------------------------------------------------------------------- /contrib/parallel_build: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # contributed by reddtape@gmail.com 5 | # 6 | 7 | pushd upstream 8 | make -j4 tasks/download_binutils tasks/download_busybox 9 | tasks/download_gcc tasks/download_gcc-c++ tasks/download_gcc-core 10 | tasks/download_gcc-g77 tasks/download_newlib tasks/download_zlib 11 | make -j4 tasks/extract_binutils tasks/extract_gcc tasks/extract_newlib 12 | make -j4 tasks/patch_binutils tasks/patch_gcc tasks/patch_newlib 13 | make -j2 tasks/extract_darcs_classgen tasks/extract_darcs_gcclass 14 | make -j2 tasks/build_darcs_classgen tasks/build_darcs_gcclass 15 | make -j8 tasks/build_gcc 16 | popd 17 | make 18 | -------------------------------------------------------------------------------- /doc/APACHE-LICENSE.TXT: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /doc/ChangeLog: -------------------------------------------------------------------------------- 1 | January 11, 2003 2 | * [brian] Added Unistd.h as an interface so we can use its constants in 3 | Runtime 4 | * [brian] -o lessconstants option to compiler to emit all constants as 5 | an addition of a field value and a small constant. This 6 | prevents the classfile constant pool from overflowing on large 7 | applications. This has a small performance impact. 8 | * [brian] Added stubs for the rmdir syscall and a minimal implementation 9 | of sysconf 10 | * [brian] Emit data segments as a series of <32k strings to avoid 11 | hitting classfile limits 12 | January 10, 2003 13 | * [brian] The compiler now outputs data segments as Strings rather than 14 | huge int arrays. 15 | * [brian] Cleaned up Makefile and upstream/Makefile to separate the 16 | required mips2java stuff from the tests. Ideally the tests 17 | should be completelly separate from the main makefile but 18 | keeping them integrated allows for better dependency checking 19 | and faster builds. 20 | January 8, 2003 21 | * Much thanks goes to Mohan Embar for discovering and fixing most 22 | of the issues below. 23 | * [brian] Updated Makefile to allow bulding with gcj 24 | (make JAVAC="gcj -C" JAVA="gij") 25 | * [brian] Updated Runtime.java to silently ignore SecurityExceptions 26 | thrown from System.getProperty() 27 | * [brian] Compiler now uses a PrintWriter for output rather than 28 | PrintStream and properly closes the file on exit 29 | * [brian] Made the htojava script a bourne shell script rather than a 30 | perl script to remove the dependency on perl. 31 | December 29, 2003 32 | * [brian] Changed build process to use -ffunction-sections, 33 | -fdata-sections, and --gc-sections 34 | * [brian] Update support.s to use function sections 35 | * [brian] Make the interpreter report the pc/sourceline of 36 | exceptions. 37 | * [brian] Remove stdio calls from FreeTypeHelper 38 | * [brian] Added gcc patch to fix -fdata-sections bug 39 | * [brian] Added freetype patch to avoid stdio 40 | December 2, 2003 41 | * [brian] Cleaned up a bunch of //FEATUREs and //FIXMEs. No major 42 | changes, just cleanup. 43 | November 30, 2003 44 | * [brian] Added crude support for O_APPEND and O_TRUNC 45 | 46 | November 29, 2003 47 | * [brian] Moved all sources under org/xwt/mips - modified Makefiles 48 | accordingly. 49 | * [brian] Added org.xwt.mips.util tree containing SeekableData, 50 | SeekableByteArray, SeekableFile, and SeekableInputStream. 51 | * [brian] Made ELF.java use SeekableData rather than RandomAccessFile 52 | * [brian] Made Runtime.java use org.xwt.mips.util.Seekable* for most 53 | file operations. 54 | * [brian] Added construtors to Interpreter.java that accept an InputStream 55 | or SeekableData. 56 | * [brian] Added support for the /dev/fd/n namespace and /dev/{null,zero} 57 | * [brian] Added test/FDTest.java example and updated tests/Test.c 58 | * [brian] Fixed absolute pathame bug on Win32 59 | -------------------------------------------------------------------------------- /doc/IVME.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bgould/nestedvm/e0a5f7bedd8555bef78822f43fa2510810e2fe0c/doc/IVME.xls -------------------------------------------------------------------------------- /doc/IVME04 Submission Report.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bgould/nestedvm/e0a5f7bedd8555bef78822f43fa2510810e2fe0c/doc/IVME04 Submission Report.pdf -------------------------------------------------------------------------------- /doc/IVME2.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bgould/nestedvm/e0a5f7bedd8555bef78822f43fa2510810e2fe0c/doc/IVME2.xls -------------------------------------------------------------------------------- /doc/chart1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bgould/nestedvm/e0a5f7bedd8555bef78822f43fa2510810e2fe0c/doc/chart1.pdf -------------------------------------------------------------------------------- /doc/chart2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bgould/nestedvm/e0a5f7bedd8555bef78822f43fa2510810e2fe0c/doc/chart2.pdf -------------------------------------------------------------------------------- /doc/chart3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bgould/nestedvm/e0a5f7bedd8555bef78822f43fa2510810e2fe0c/doc/chart3.pdf -------------------------------------------------------------------------------- /doc/chart4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bgould/nestedvm/e0a5f7bedd8555bef78822f43fa2510810e2fe0c/doc/chart4.pdf -------------------------------------------------------------------------------- /doc/chart5.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bgould/nestedvm/e0a5f7bedd8555bef78822f43fa2510810e2fe0c/doc/chart5.pdf -------------------------------------------------------------------------------- /doc/chart6.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bgould/nestedvm/e0a5f7bedd8555bef78822f43fa2510810e2fe0c/doc/chart6.pdf -------------------------------------------------------------------------------- /doc/chart7.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bgould/nestedvm/e0a5f7bedd8555bef78822f43fa2510810e2fe0c/doc/chart7.pdf -------------------------------------------------------------------------------- /doc/charts/boxfill.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | 3 | # Copyright 2001, Felix Ritter (Felix.Ritter@gmx.de) 4 | # 5 | # Original script (color mode) Copyright 2000, 6 | # Andreas Widmann (widmann@rz.uni-leipzig.de) 7 | # 8 | # This script is free software; permission to use, copy, modify, and 9 | # distribute this software and its documentation for any purpose without 10 | # fee is hereby granted, provided that both the above copyright notice 11 | # and this permission notice appear in all copies and in supporting 12 | # documentation. 13 | # 14 | # This software is provided "as is" without express or implied warranty 15 | # of any kind. 16 | 17 | #introstuff 18 | sub usage_info() { 19 | print "gnuplot-boxfill.pl\n"; 20 | print " fills (and outlines) boxes in gnuplot 3.7.1 postscript files\n"; 21 | print "usage:\n"; 22 | print " gnuplot-boxfill.pl [-c | -g | -p] [-o] [-r] [-z] \n"; 23 | print "options:\n"; 24 | print " -c color fill (default)\n"; 25 | print " -g gray fill\n"; 26 | print " -p pattern fill\n"; 27 | print " -o draw outline\n"; 28 | print " -r remove \"currentpoint stroke M\" (experimental!)\n"; 29 | print " -z outline zero height boxes (experimental!)\n"; 30 | print "arguments:\n"; 31 | print " postscript input file\n"; 32 | print " postscript output file\n"; 33 | } 34 | if ($#ARGV < 1) { 35 | &usage_info(); 36 | exit(0); 37 | } 38 | 39 | $prolog = '/graymode true def 40 | 41 | /BfDict 400 dict def 42 | 43 | /dpiranges [ 2540 2400 1693 1270 1200 635 600 0 ] def 44 | /PatFreq [ 10.5833 10.0 9.4055 10.5833 10.0 10.5833 10.0 9.375 ] def 45 | 46 | /dpi 72 0 matrix defaultmatrix dtransform dup mul exch dup mul add sqrt def 47 | 48 | /screenIndex { 49 | 0 1 dpiranges length 1 sub { dup dpiranges exch get 1 sub dpi le {exit} {pop} ifelse } for 50 | } bind def 51 | 52 | /CurColors [ 0 0 0 1 0 0 0 1] def 53 | 54 | /RealSetgray /setgray load def 55 | /RealSetrgbcolor /setrgbcolor load def 56 | /RealSetcmykcolor { 57 | 4 1 roll 58 | 3 { 3 index add 0 max 1 min 1 exch sub 3 1 roll} repeat 59 | RealSetrgbcolor pop 60 | } bind def 61 | 62 | /tintCMYK { 63 | 1 tintGray sub CurColors 0 4 getinterval aload pop 64 | 4 index mul 5 1 roll 65 | 3 index mul 5 1 roll 66 | 2 index mul 5 1 roll 67 | mul 4 1 roll 68 | }bind def 69 | /tintRGB { 70 | 1 tintGray sub CurColors 4 3 getinterval aload pop 71 | 1 exch sub 3 index mul 1 exch sub 4 1 roll 72 | 1 exch sub 2 index mul 1 exch sub 4 1 roll 73 | 1 exch sub mul 1 exch sub 3 1 roll 74 | }bind def 75 | /combineColor { 76 | /tintGray 1 1 CurGray sub CurColors 7 get mul sub def 77 | graymode not { 78 | [/Pattern [/DeviceCMYK]] setcolorspace 79 | tintCMYK CurPat setcolor 80 | } { 81 | CurColors 3 get 1.0 ge { 82 | tintGray RealSetgray 83 | } { 84 | graymode { 85 | tintCMYK 86 | RealSetcmykcolor 87 | } { 88 | tintRGB 89 | RealSetrgbcolor 90 | } ifelse 91 | } ifelse 92 | } ifelse 93 | } bind def 94 | 95 | /patProcDict 5 dict dup begin 96 | <0f1e3c78f0e1c387> { 3 setlinewidth -1 -1 moveto 9 9 lineto stroke 97 | 4 -4 moveto 12 4 lineto stroke 98 | -4 4 moveto 4 12 lineto stroke} bind def 99 | <0f87c3e1f0783c1e> { 3 setlinewidth -1 9 moveto 9 -1 lineto stroke 100 | -4 4 moveto 4 -4 lineto stroke 101 | 4 12 moveto 12 4 lineto stroke} bind def 102 | <8142241818244281> { 1 setlinewidth -1 9 moveto 9 -1 lineto stroke 103 | -1 -1 moveto 9 9 lineto stroke } bind def 104 | <03060c183060c081> { 1 setlinewidth -1 -1 moveto 9 9 lineto stroke 105 | 4 -4 moveto 12 4 lineto stroke 106 | -4 4 moveto 4 12 lineto stroke} bind def 107 | <8040201008040201> { 1 setlinewidth -1 9 moveto 9 -1 lineto stroke 108 | -4 4 moveto 4 -4 lineto stroke 109 | 4 12 moveto 12 4 lineto stroke} bind def 110 | end def 111 | /patDict 15 dict dup begin 112 | /PatternType 1 def 113 | /PaintType 2 def 114 | /TilingType 3 def 115 | /BBox [ 0 0 8 8 ] def 116 | /XStep 8 def 117 | /YStep 8 def 118 | /PaintProc { 119 | begin 120 | patProcDict bstring known { 121 | patProcDict bstring get exec 122 | } { 123 | 8 8 true [1 0 0 -1 0 8] bstring imagemask 124 | } ifelse 125 | end 126 | } bind def 127 | end def 128 | 129 | /setPatternMode { 130 | pop pop 131 | dup patCache exch known { 132 | patCache exch get 133 | } { 134 | dup 135 | patDict /bstring 3 -1 roll put 136 | patDict 137 | 65 PatFreq screenIndex get div dup matrix scale 138 | makepattern 139 | dup 140 | patCache 4 -1 roll 3 -1 roll put 141 | } ifelse 142 | /CurGray 0 def 143 | /CurPat exch def 144 | /graymode false def 145 | combineColor 146 | } bind def 147 | /setGrayScaleMode { 148 | graymode not { 149 | /graymode true def 150 | } if 151 | /CurGray exch def 152 | combineColor 153 | } bind def 154 | 155 | BfDict begin [ 156 | /fillvals 157 | ] { 0 def } forall 158 | 159 | /SetPattern { 160 | fillvals exch get 161 | dup type /stringtype eq 162 | {8 1 setPatternMode} 163 | {setGrayScaleMode} 164 | ifelse 165 | } bind def 166 | 167 | /InitPattern { 168 | BfDict begin dup 169 | array /fillvals exch def 170 | dict /patCache exch def 171 | end 172 | } def 173 | /DefPattern { 174 | BfDict begin 175 | fillvals 3 1 roll put 176 | end 177 | } def 178 | 179 | 7 InitPattern 180 | 0 <03060c183060c081> DefPattern 181 | 1 <8040201008040201> DefPattern 182 | 2 <0f1e3c78f0e1c387> DefPattern 183 | 3 <0f87c3e1f0783c1e> DefPattern 184 | 4 <8142241818244281> DefPattern 185 | 5 <111111ff111111ff> DefPattern 186 | 6 0 DefPattern'; 187 | 188 | $outlinestyle = 'LTb'; 189 | if(grep(/^-o$/, @ARGV) == 1) { $outline = "\ngsave\ncurrentpoint $outlinestyle M redo stroke\ngrestore" } 190 | else { $outline = '' } 191 | 192 | #read input file 193 | open(IN, $ARGV[$#ARGV - 1]) || die "Cannot open $ARGV[$#ARGV - 1]\n"; 194 | $content = join('', ); 195 | close(IN); 196 | 197 | #search patterns 198 | $key = '(-*\d+ -*\d+ M\n)(-*\d+)( -*\d+ V\n)(-*\d+ -*\d+ [RM]\n-*\d+ -*\d+ V\n-*\d+ -*\d+ V\n-*\d+ -*\d+ V\n-*\d+ -*\d+ V\n)'; 199 | #$key = '(-*\d+ -*\d+ M\n)(-*\d+)( -*\d+ V\n)(-*\d+ -*\d+ [RM]\n-*\d+ -*\d+ V\n-*\d+ -*\d+ V\n)'; #experimental 200 | $box = '(?$ARGV[$#ARGV]") || die "Cannot open $ARGV[$#ARGV]\n"; 258 | print OUT "$content"; 259 | close(OUT); 260 | -------------------------------------------------------------------------------- /doc/charts/chart1.dat: -------------------------------------------------------------------------------- 1 | 2.2 2.6117501 2.0316665 4.8741665 2 | 3.8 2.509 1.8595 4.228667 3 | 5.4 2.7128334 1.7885 3.9496663 4 | 7.0 2.9118335 1.8961667 4.846833 5 | -------------------------------------------------------------------------------- /doc/charts/chart1.gnuplot: -------------------------------------------------------------------------------- 1 | # don't touch this 2 | set terminal postscript landscape color "Helvetica" 19 3 | set output 'unfilled.eps' 4 | 5 | set yrange [0:6] 6 | set xrange [1:7.4] 7 | set data style boxes 8 | set boxwidth 0.4 9 | set xtics ("256" 1.8, "128" 3.4, "64" 5.0, "32" 6.6) 10 | set xlabel "Max Instructions Per Method" 11 | set ylabel "Seconds" 12 | set title "Optimal Max Instructions Per Method" 13 | set grid 14 | 15 | plot \ 16 | 'chart1.dat' using ($1-0.8):($2) title "libjpeg", \ 17 | 'chart1.dat' using ($1-0.4):($3) title "libfreetype", \ 18 | 'chart1.dat' using ($1):($4) title "libmspack" 19 | 20 | -------------------------------------------------------------------------------- /doc/charts/chart10.dat: -------------------------------------------------------------------------------- 1 | 1.6 4.8102503 2 | 2.8 4.517 3 | 4.0 3.58 4 | 5.2 3.12157 5 | 6.4 2.5037498 6 | 7.6 1.8256665 7 | 8 | -------------------------------------------------------------------------------- /doc/charts/chart10.gnuplot: -------------------------------------------------------------------------------- 1 | # don't touch this 2 | set terminal postscript landscape color "Helvetica" 19 3 | set output 'unfilled.eps' 4 | 5 | set yrange [0:5] 6 | set xrange [1:8.4] 7 | set data style boxes 8 | set boxwidth 0.8 9 | set xtics (\ 10 | "None" 1.6, "Prune Cases" 2.8, "GCC\nOptimizations" 4.0, \ 11 | "TABLE\nSWITCH" 5.2, "Combined" 6.4, \ 12 | "Binary\n-to-\nBinary" 7.6) 13 | 14 | set title "Effects of Optimizations on Binary-to-Souce and Binary-to-Binary Compilers" 15 | set ylabel "Seconds" 16 | set grid 17 | #set label "59" at 2.15, 69 18 | #set label "97" at 2.55, 107 19 | #set label "159" at 2.95, 169 20 | #set label "256" at 3.35, 266 21 | plot \ 22 | 'chart10.dat' using ($1):($2) title "" 23 | -------------------------------------------------------------------------------- /doc/charts/chart11.dat: -------------------------------------------------------------------------------- 1 | 1.6 6.368 2 | 3.4 87.946 3 | 5.2 39.44 4 | -------------------------------------------------------------------------------- /doc/charts/chart11.gnuplot: -------------------------------------------------------------------------------- 1 | # don't touch this 2 | set terminal postscript landscape color "Helvetica" 19 3 | set output 'unfilled.eps' 4 | 5 | set yrange [0:90] 6 | set xrange [1:5.8] 7 | set data style boxes 8 | set boxwidth 0.8 9 | set xtics ("Native" 1.6, "NestedVM -> GCJ" 3.4, "NestedVM" 5.2) 10 | #set xlabel "" 11 | set title "Native/GCJ/Hotspot Linpack" 12 | set ylabel "Seconds" 13 | set grid 14 | plot \ 15 | 'chart11.dat' using ($1):($2) title "" 16 | -------------------------------------------------------------------------------- /doc/charts/chart2.dat: -------------------------------------------------------------------------------- 1 | 2.2 16.883 6.720167 54.59083 2 | 3.8 2.509 1.8595 4.228667 3 | -------------------------------------------------------------------------------- /doc/charts/chart2.gnuplot: -------------------------------------------------------------------------------- 1 | # don't touch this 2 | set terminal postscript landscape color "Helvetica" 19 3 | set output 'unfilled.eps' 4 | 5 | set yrange [0:60] 6 | set xrange [1:4.2] 7 | set data style boxes 8 | set boxwidth 0.4 9 | set xtics ("512" 1.8, "128" 3.4) 10 | set xlabel "Max Instructions Per Method" 11 | set ylabel "Seconds" 12 | set title "JIT Doensn't Handle Largs Methods Well" 13 | set grid 14 | 15 | plot \ 16 | 'chart2.dat' using ($1-0.8):($2) title "libjpeg", \ 17 | 'chart2.dat' using ($1-0.4):($3) title "libfreetype", \ 18 | 'chart2.dat' using ($1):($4) title "libmspack" 19 | 20 | -------------------------------------------------------------------------------- /doc/charts/chart3.dat: -------------------------------------------------------------------------------- 1 | 2.4 2.509 1.8256665 2 | 4.0 1.8595 1.4573334 3 | 5.6 4.228667 3.7278335 4 | -------------------------------------------------------------------------------- /doc/charts/chart3.gnuplot: -------------------------------------------------------------------------------- 1 | # don't touch this 2 | set terminal postscript landscape color "Helvetica" 19 3 | set output 'unfilled.eps' 4 | 5 | set yrange [0:5.0] 6 | set xrange [1:5.8] 7 | set data style boxes 8 | set boxwidth 0.4 9 | set xtics ("Libjpeg" 1.8, "libfreetype" 3.4, "libmspack" 5.0) 10 | set xlabel "Application" 11 | set ylabel "Seconds" 12 | set title "JavaSource vs Classfile" 13 | set grid 14 | 15 | plot \ 16 | 'chart3.dat' using ($1-0.8):($2) title "JavaSource", \ 17 | 'chart3.dat' using ($1-0.4):($3) title "ClassFile" 18 | -------------------------------------------------------------------------------- /doc/charts/chart4.dat: -------------------------------------------------------------------------------- 1 | 2.2 2.3438332 1.7511667 1.9061666 2 | 3.8 1.5780001 1.4573334 1.7093334 3 | 5.4 4.2496667 3.7278335 3.9231665 4 | -------------------------------------------------------------------------------- /doc/charts/chart4.gnuplot: -------------------------------------------------------------------------------- 1 | # don't touch this 2 | set terminal postscript landscape color "Helvetica" 19 3 | set output 'unfilled.eps' 4 | 5 | set yrange [0:5.5] 6 | set xrange [1:5.8] 7 | set data style boxes 8 | set boxwidth 0.4 9 | set xtics ("libjpeg" 1.8, "libfreetype" 3.4, "libmspack" 5.0) 10 | set xlabel "Application" 11 | set ylabel "Seconds" 12 | set title "Fields vs Local Variables" 13 | set grid 14 | plot \ 15 | 'chart4.dat' using ($1-0.8):($2) title "Fields Only", \ 16 | 'chart4.dat' using ($1-0.4):($3) title "Some Local Vars", \ 17 | 'chart4.dat' using ($1):($4) title "All Local Vars" 18 | -------------------------------------------------------------------------------- /doc/charts/chart5.dat: -------------------------------------------------------------------------------- 1 | 2.4 1.8256665 1.3853334 2 | 4.0 1.4573334 1.1044999 3 | 5.6 3.7278335 2.1845002 4 | -------------------------------------------------------------------------------- /doc/charts/chart5.gnuplot: -------------------------------------------------------------------------------- 1 | # don't touch this 2 | set terminal postscript landscape color "Helvetica" 19 3 | set output 'unfilled.eps' 4 | 5 | set yrange [0:4.5] 6 | set xrange [1:5.8] 7 | set data style boxes 8 | set boxwidth 0.4 9 | set xtics ("Libjpeg" 1.8, "libfreetype" 3.4, "libmspack" 5.0) 10 | set xlabel "Application" 11 | set ylabel "Seconds" 12 | set title "Paged vs Flat Memory Access" 13 | set grid 14 | 15 | plot \ 16 | 'chart5.dat' using ($1-0.8):($2) title "Paged", \ 17 | 'chart5.dat' using ($1-0.4):($3) title "Flat" 18 | -------------------------------------------------------------------------------- /doc/charts/chart6.dat: -------------------------------------------------------------------------------- 1 | 1.6 0.808 2 | 3.4 1.99 3 | -------------------------------------------------------------------------------- /doc/charts/chart6.gnuplot: -------------------------------------------------------------------------------- 1 | # don't touch this 2 | set terminal postscript landscape color "Helvetica" 19 3 | set output 'unfilled.eps' 4 | 5 | set yrange [0:2.5] 6 | set xrange [1:4.0] 7 | set data style boxes 8 | set boxwidth 0.8 9 | set xtics ("Native" 1.6, "NestedVM" 3.4) 10 | #set xlabel "" 11 | set title "IO Performance (Copy 100mb of Data)" 12 | set ylabel "Seconds" 13 | set grid 14 | plot \ 15 | 'chart6.dat' using ($1):($2) title "" 16 | -------------------------------------------------------------------------------- /doc/charts/chart7.dat: -------------------------------------------------------------------------------- 1 | 2.2 0.15 0.236 0.5 2 | 3.8 0.9576667 1.0161667 1.518 3 | 5.4 1.1044999 1.3853334 2.1845002 4 | -------------------------------------------------------------------------------- /doc/charts/chart7.gnuplot: -------------------------------------------------------------------------------- 1 | # don't touch this 2 | set terminal postscript landscape color "Helvetica" 19 3 | set output 'unfilled.eps' 4 | 5 | set yrange [0:2.8] 6 | set xrange [1:5.8] 7 | set data style boxes 8 | set boxwidth 0.4 9 | set xtics ("Native" 1.8, "NestedVM -> GCJ" 3.4, "Hotspot" 5.0) 10 | #set xlabel "" 11 | set title "Native vs GCJ vs Hotspot" 12 | set ylabel "Seconds" 13 | set grid 14 | 15 | plot \ 16 | 'chart7.dat' using ($1-0.8):($2) title "libjpeg", \ 17 | 'chart7.dat' using ($1-0.4):($3) title "libfreetype", \ 18 | 'chart7.dat' using ($1):($4) title "libmspack" 19 | 20 | -------------------------------------------------------------------------------- /doc/charts/chart8.dat: -------------------------------------------------------------------------------- 1 | 1.6 0.952 2 | 3.4 6.381 3 | 5.2 7.872 4 | -------------------------------------------------------------------------------- /doc/charts/chart8.gnuplot: -------------------------------------------------------------------------------- 1 | # don't touch this 2 | set terminal postscript landscape color "Helvetica" 19 3 | set output 'unfilled.eps' 4 | 5 | set yrange [0:9.0] 6 | set xrange [1:5.8] 7 | set data style boxes 8 | set boxwidth 0.8 9 | set xtics ("Native" 1.6, "NestedVM -> GCJ" 3.4, "NestedVM" 5.2) 10 | #set xlabel "" 11 | set title "Native/GCJ/Hotspot Boehm-GC (gctest)" 12 | set ylabel "Seconds" 13 | set grid 14 | plot \ 15 | 'chart8.dat' using ($1):($2) title "" 16 | -------------------------------------------------------------------------------- /doc/charts/chart9.dat: -------------------------------------------------------------------------------- 1 | 2.6 484 256 164 72 2 | 4.6 452 252 160 72 3 | 6.6 332 200 120 56 4 | 8.6 216 116 76 32 5 | -------------------------------------------------------------------------------- /doc/charts/chart9.gnuplot: -------------------------------------------------------------------------------- 1 | # don't touch this 2 | set terminal postscript landscape color "Helvetica" 19 3 | set output 'unfilled.eps' 4 | 5 | set yrange [0:500] 6 | set xrange [1:9.0] 7 | set data style boxes 8 | set boxwidth 0.4 9 | set xtics ("DJpeg" 2.0, "Freetype" 4.0, "Boehm-GC" 6.0, "LibMSPack" 8.0) 10 | set xlabel "Application" 11 | set ylabel "Size (kilobytes)" 12 | set title "Size of MIPS Binary vs Java Bytecode" 13 | set grid 14 | #set label "59" at 2.15, 69 15 | #set label "97" at 2.55, 107 16 | #set label "159" at 2.95, 169 17 | #set label "256" at 3.35, 266 18 | plot \ 19 | 'chart9.dat' using ($1-1.2):($2) title "Class", \ 20 | 'chart9.dat' using ($1-0.8):($3) title "MIPS Binary", \ 21 | 'chart9.dat' using ($1-0.4):($4) title "Compressed Class", \ 22 | 'chart9.dat' using ($1):($5) title "Compressed MIPS" 23 | 24 | -------------------------------------------------------------------------------- /doc/ivme04.bib: -------------------------------------------------------------------------------- 1 | @article{ibex, 2 | author = "Adam Megacz", 3 | title = "The Ibex Reference", 4 | note = "\url{http://www.ibex.org/reference.pdf}" } 5 | 6 | @article{jmm, 7 | author = "William Pugh", 8 | title = "The Java memory model is fatally flawed", 9 | journal = "Concurrency: Practice and Experience", 10 | pages = "1-11", 11 | year = "2000" } 12 | 13 | @techreport{lcc, 14 | author = "C. W. Fraser and D. R. Hanson", 15 | title = "A Retargetable Compiler for {ANSI} {C}", 16 | number = "CS--TR--303--91", 17 | address = "Princeton, N.J.", 18 | year = "1991", 19 | note = "\url{citeseer.ist.psu.edu/fraser91retargetable.html}" } 20 | 21 | 22 | @inproceedings{mohca, 23 | author = "Scott Malabarba and Premkumar T. Devanbu and Aaron Stearns", 24 | title = "MoHCA-Java: A Tool for C++ to Java Conversion Support", 25 | booktitle = "International Conference on Software Engineering", 26 | pages = "650-653", 27 | year = "1999" } 28 | 29 | @book{java, 30 | author = "James Gosling and others", 31 | title = "The {Java} Language Specification", 32 | publisher = "GOTOP Information Inc.", 33 | year = "1996", 34 | address = "5F, No.7, Lane 50, Sec.3 Nan Kang Road Taipei, Taiwan; Unit 1905, Metro Plaza Tower 2, No. 223 Hing Fong Road, Kwai Chung, N.T., Hong Kong", 35 | } 36 | 37 | @article{capp, 38 | title = "Cappuccino -- A C++ To Java Translator", 39 | author = "Frank Buddrus and Jorg Schodel", 40 | journal = "Proceedings of the 1998 ACM symposium on Applied Computing", 41 | year = "1998" } 42 | 43 | @misc{hotspot, 44 | title = "The Java Hotspot performance engine architecture", 45 | note = "\url{http://java.sun.com/products/hotspot/whitepaper.html}", 46 | year = "1999" } 47 | 48 | @article{KR, 49 | author = "Kernighan, B. W. and Ritchie, D. M.", 50 | year = "1979", 51 | title = "The C Programming Language", 52 | publisher = "Englewood Cliffs, NJ: Prentice-Hall" } 53 | 54 | @article{soustroup, 55 | author = "B. Stroustrup.", 56 | title = "The C++ Programming Language", 57 | publisher = "Addison-Wesley", 58 | year = "1997" } 59 | 60 | @misc{csharp, 61 | title = "The C\# Programming Language", 62 | note = "\url{http://download.microsoft.com/download/0/a/c/0acb3585-3f3f-4169-ad61-efc9f0176788/CSharp.zip}" } 63 | 64 | @book{jni, 65 | title = "The Java Native Interface: Programmer's Guide and Specification", 66 | author = "Sheng Liang", 67 | publisher = "Addison Wesley Longman, Inc.", 68 | year = "1999" } 69 | 70 | @misc{cni, 71 | title = "The Cygnus Native Interface for C++/Java Integration", 72 | note = "\url{http://gcc.gnu.org/java/papers/cni/t1.html}" } 73 | 74 | @misc{j2me, 75 | note = "\url{http://java.sun.com/j2me/docs/index.html}" } 76 | 77 | @misc{parrot, 78 | note = "\url{http://www.parrotcode.org}" } 79 | 80 | @misc{python, 81 | note = "\url{http://www.python.org}" } 82 | 83 | @misc{jazillian, 84 | note = "\url{http://www.jazillian.com/}" } 85 | 86 | @article{c2j, 87 | note = "C2J: a C to Java translator", 88 | year = "September 2001", 89 | author = "Novosoft" } 90 | 91 | @inproceedings{ephedra, 92 | author = "Johannes Martin and Hausi Muller", 93 | title = "Strategies for Migration from C to Java", 94 | publisher = "5th European Conference for Software Maintenance and Reengineering", 95 | month = "March", 96 | year = "2001" 97 | } 98 | 99 | @article{egcsjvm, 100 | author = "T. Waddington", 101 | title = "Java Backend for GCC", 102 | note = "\url{http://archive.csee.uq.edu.au/\~csmweb/uqbt.html\#gccjvm}", 103 | year = "November 2000" } 104 | 105 | @misc{gcc, 106 | note = "\url{http://gcc.gnu.org/}" } 107 | 108 | @misc{jikes, 109 | note = "\url{http://www-124.ibm.com/developerworks/oss/jikes/}" } 110 | 111 | @misc{msil, 112 | note = "\url{http://research.microsoft.com/~emeijer/Papers/CLR.pdf}" } 113 | 114 | 115 | -------------------------------------------------------------------------------- /doc/max_per_method.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bgould/nestedvm/e0a5f7bedd8555bef78822f43fa2510810e2fe0c/doc/max_per_method.pdf -------------------------------------------------------------------------------- /doc/nestedvm.ivme04.bbl: -------------------------------------------------------------------------------- 1 | \providecommand{\bysame}{\leavevmode\hbox to3em{\hrulefill}\thinspace} 2 | \providecommand{\MR}{\relax\ifhmode\unskip\space\fi MR } 3 | % \MRhref is called by the amsart/book/proc definition of \MR. 4 | \providecommand{\MRhref}[2]{% 5 | \href{http://www.ams.org/mathscinet-getitem?mr=#1}{#2} 6 | } 7 | \providecommand{\href}[2]{#2} 8 | \begin{thebibliography}{10} 9 | 10 | \bibitem{j2me} 11 | http://java.sun.com/j2me/docs/index.html. 12 | 13 | \bibitem{msil} 14 | http://research.microsoft.com/~emeijer/Papers/CLR.pdf. 15 | 16 | \bibitem{parrot} 17 | http://www.parrotcode.org. 18 | 19 | \bibitem{python} 20 | http://www.python.org. 21 | 22 | \bibitem{jazillian} 23 | http://www.jazillian.com/. 24 | 25 | \bibitem{c2j} 26 | http://www.soften.ktu.lt/~stonis/c2java/. 27 | 28 | \bibitem{gcc} 29 | http://gcc.gnu.org/. 30 | 31 | \bibitem{jikes} 32 | http://www-124.ibm.com/developerworks/oss/jikes/. 33 | 34 | \bibitem{csharp} 35 | \emph{The c\# programming language}, 36 | http://download.microsoft.com/download/0/a/c/0acb3585-3f3f-4169-ad61-efc9f01% 37 | 76788/CSharp.zip. 38 | 39 | \bibitem{cni} 40 | \emph{The cygnus native interface for c++/java integration}, 41 | http://gcc.gnu.org/java/papers/cni/t1.html. 42 | 43 | \bibitem{hotspot} 44 | \emph{The java hotspot performance engine architecture}, 1999, 45 | http://java.sun.com/products/hotspot/whitepaper.html. 46 | 47 | \bibitem{capp} 48 | Frank Buddrus and Jorg Schodel, \emph{Cappuccino -- a c++ to java translator}, 49 | Proceedings of the 1998 ACM symposium on Applied Computing (1998). 50 | 51 | \bibitem{java} 52 | James Gosling et~al., \emph{The {Java} language specification}, GOTOP 53 | Information Inc., 5F, No.7, Lane 50, Sec.3 Nan Kang Road Taipei, Taiwan; Unit 54 | 1905, Metro Plaza Tower 2, No. 223 Hing Fong Road, Kwai Chung, N.T., Hong 55 | Kong, 1996, citeseer.ist.psu.edu/gosling96java.html. 56 | 57 | \bibitem{KR} 58 | B.~W. Kernighan and D.~M. Ritchie, \emph{The c programming language}, (1979). 59 | 60 | \bibitem{jni} 61 | Sheng Liang, \emph{The javatm native interface: Programmer's guide and 62 | specification}, (1999). 63 | 64 | \bibitem{mohca} 65 | Scott Malabarba, Premkumar~T. Devanbu, and Aaron Stearns, \emph{Mohca-java: A 66 | tool for c++ to java conversion support}, International Conference on 67 | Software Engineering, 1999, citeseer.ist.psu.edu/malabarba99mohcajava.html, 68 | pp.~650--653. 69 | 70 | \bibitem{ephedra} 71 | J.~Martin, \emph{Ephedra: A c to java migration environment}, (2002), 72 | http://www.rigi.csc.uvic.ca/?jmartin/Ephedra. 73 | 74 | \bibitem{c2jpp} 75 | Novosoft, (September 2001), C2J ?C to Java translator. 76 | 77 | \bibitem{soustroup} 78 | B.~Stroustrup., \emph{The c++ programming language}, (1997). 79 | 80 | \bibitem{egcsjvm} 81 | T.~Waddington, \emph{Java backend for gcc}, (November 2000), 82 | http://archive.csee.uq.edu.au/?csmweb/uqbt.html\#gccjvm. 83 | 84 | \end{thebibliography} 85 | -------------------------------------------------------------------------------- /doc/pst2pdf: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | # pst2pdf 3 | # PSTricks 2 PDF converter : 4 | # Usage: "pst2pdf" produces PDF files for all files of the form *-fig*.tex 5 | # "pst2pdf " only considers FILE-fig.tex 6 | # It removes intermediary files at the end. 7 | 8 | FILE=$1 9 | if test -z $FILE; then 10 | FIGURES=`ls *-fig*.tex`; 11 | else 12 | FIGURES=`ls -- $FILE-fig*.tex`; 13 | fi 14 | 15 | for f in $FIGURES ; do 16 | fig=`basename $f .tex` 17 | latex $fig 18 | dvips -Ppdf -E -o $fig.eps $fig 19 | epstopdf $fig.eps 20 | rm $fig.eps $fig.dvi $fig.log $fig.aux 21 | done 22 | 23 | -------------------------------------------------------------------------------- /doc/reviewer.comments.txt: -------------------------------------------------------------------------------- 1 | From: Etienne Gagnon 2 | Subject: IVME 04 Author Notification 3 | To: Adam Megacz 4 | Date: Thu, 22 Apr 2004 13:00:54 -0400 5 | Organization: UQAM 6 | Resent-From: nobody@nowhere.com 7 | 8 | Dear Adam Megacz, 9 | 10 | I am pleased to inform you that your paper (#17): 11 | 12 | "Complete Translation of Unsafe Native Code to Safe Bytecode" 13 | 14 | has been selected for publication and presentation at IVME 04. This 15 | year a total of 15 papers were submitted and of these 6 were selected 16 | for publication. 17 | 18 | Below please find the reviewers' comments. Please incorporate any 19 | suggestions made by the reviewers and prepare the final version of your 20 | paper according to the ACM SIG Proceedings Templates at 21 | http://www.acm.org/sigs/pubs/proceed/template.html 22 | Please follow the SIGS style carefully. 23 | 24 | Please note that papers should normally be limited to 8 pages, including 25 | figures, bibliography, possible appendixes, etc. Please ask for permission 26 | by email (gagnon.etienne_m@uqam.ca) if you need more than one or two 27 | additional pages. 28 | 29 | IMPORTANT TASKS TO DO 30 | ===================== 31 | 32 | ** The electronic final camera-ready version is due on (strict deadline) 33 | Monday May 10th, 2004. You must send your paper as attachment to an email 34 | message to gagnon.etienne_m@uqam , in a compressed .zip or .tar.gz archive 35 | which should include both of the following: 36 | - A PostScript or a PDF version of your camera-ready paper. 37 | - The source version of your document (LaTeX, Microsoft Word), suitable 38 | for modification (to add heading/footing information such as line numbers). 39 | *** If you used another software, please inform us of this fact by replying 40 | to this message as soon as possible. 41 | 42 | ** You must also print, fill and sign the copyright form attached to this message 43 | and send it by mail to: 44 | 45 | Prof. Etienne M. Gagnon 46 | Departement d'informatique 47 | Universite du Quebec a Montreal 48 | Case postale 8888, succursale Centre-ville 49 | Montreal (Quebec) 50 | Canada H3C 3P8 51 | 52 | 53 | Do not hesistate to communicate with me as soon as possible if you have any 54 | problem with formating your paper according the the ACM SIGS style. 55 | 56 | Regards, 57 | 58 | Etienne Gagnon 59 | Program Chair 60 | IVME 04 61 | 62 | ------------------------------- 63 | 64 | Legend 65 | 66 | 1 Strong Reject 67 | 2 Weak Reject 68 | 3 Undecided 69 | 4 Weak Accept 70 | 5 Strong Accept 71 | 72 | ------------------------------- 73 | 74 | Appropriateness to the Conference: 4 75 | Originality: 4 76 | Technical Strength: 4 77 | Presentation: 4 78 | Overall Evaluation: 4 79 | Comments 80 | 81 | An interesting paper demonstrating the translation of MIPS R2000 binaries to safe JVM bytecodes. 82 | 83 | The paper has some novelty value, since everybody knows that in theory an arbitrary native code binary could be emulated in this way, but nobody seems to have done a complete job. Thus the paper answers the existence question, and provides some implementation details. Of course a remaining problem is the issue of emulating the runtime/sys-call interface of the native binary. 84 | 85 | The discussion of the techniques by which the quality of the bytecode representation of the program may be improved was helpful. 86 | 87 | However, a wider range of measurements of performance would have improved the paper. Some discussion of the theoretical limits to performance using such a compilation path would have been of interest also. 88 | 89 | There are a number of typos in the paper as presented. A careful proof reading would be in order before final submission. 90 | 91 | Finally, there are a host of unanswered questions regarding the practical use of such techniques. Unsafe code is, well, unsafe. Users of managed frameworks expect a certain degree of safety. It seems that there are several levels of insecurity here. Type violations in the native code should be bug for bug equivalent in this framework. Stray pointers presumably lead to array bounds violations in the JVM (?). So what happens with unsafe use of the system call interface? Is this trapped in the NestedVM runtime? Is it trapped inside the Java sandbox, or does it require high privilege setting and wreak its damage anyhow? 92 | 93 | ------------------------------- 94 | 95 | Appropriateness to the Conference: 4 96 | Originality: 2 97 | Technical Strength: 4 98 | Presentation: 4 99 | Overall Evaluation: 4 100 | Comments 101 | 102 | Interesting paper to read. There are some typos which should be fixed, many of which a spell-checker should catch (my favorite is "highlym odular" on page 2). 103 | 104 | I'm not convinced that the MIPS ISA and the JVM have a "close similarity" (Section 4.1), but one could argue that they have "similarities" as they go on to explain. 105 | 106 | The citation to the JLS needs fixing, as does capitalization in a number of references. 107 | 108 | Some data needs to be shown on the size of translated binaries. 109 | 110 | What about code that uses non-libc libraries? 111 | 112 | A C to Java translator was done in 1996 which bears a lot of similarity to this work (including the big array to represent memory). See C. W. Fraser and D. R. Hanson's "A Lean Retargetable C Compiler," 1996, at http://www.cs.princetom.edu/software/lcc/doc/lean.pdf. The work by Fraser and Huelsberger is the C to Java translation. 113 | 114 | ------------------------------- 115 | 116 | Appropriateness to the Conference: 5 117 | Originality: 5 118 | Technical Strength: 5 119 | Presentation: 4 120 | Overall Evaluation: 5 121 | Comments 122 | 123 | I really liked this paper (the best one in my batch). However, I would have preferred to see more technical detail instead of the blurb in Sections 2 and 3, which wastes almost 1 1/2 pages. This space could be spent much better on a deeper technical discussion. 124 | 125 | Also, I am a bit sceptical of the results, which look almost too good. I cannot imagine that translating MIPS instructions into Java of the sort shown really only has 10x worst case overhead. I would have expected more like 1000x overhead... A further discussion would be welcome. 126 | 127 | But overall, this is very interesting and novel. 128 | 129 | ------------------------------- 130 | 131 | Appropriateness to the Conference: 5 132 | Originality: 4 133 | Technical Strength: 4 134 | Presentation: 4 135 | Overall Evaluation: 4 136 | Comments 137 | 138 | Nice paper, well-presented, but a little light on details. 139 | 140 | You chose MIPS because it was likely to be the easiest. Have you thought 141 | much about x86, Power, etc.? How much harder would it be to do 142 | this for other ISAs? 143 | 144 | Were there any peculiarities of the JVM that were gratuitously 145 | difficult to deal with? I would have expected the lack of 146 | unsigned int types to be a pain. 147 | 148 | I'm guessing that NestedVM can't handle multi-threaded apps; 149 | please mention this. (I note that bug-for-bug compiler 150 | compatibility is very hard, perhaps impossible to achieve 151 | for multi-threaded apps, because the memory models of the 152 | original machine and the JVM are unlikely to be the same). 153 | 154 | There is no mention of the work on binary translation to bytecode 155 | done by Cifuentes et al, (see, e.g., the paper in Computer, Mar 2000, 156 | or the paper in the Workshop on Binary Translation (1999)). 157 | 158 | You should make 159 | a pass with a spell checker. 160 | 161 | 162 | [2. application/octet-stream; copyright_form.pdf]... 163 | 164 | -------------------------------------------------------------------------------- /doc/runtimenotes.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bgould/nestedvm/e0a5f7bedd8555bef78822f43fa2510810e2fe0c/doc/runtimenotes.txt -------------------------------------------------------------------------------- /doc/tmp.inputs: -------------------------------------------------------------------------------- 1 | \usepackage{pstricks} 2 | \usepackage{pst-node} 3 | -------------------------------------------------------------------------------- /docker/debian/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:jessie 2 | MAINTAINER BCG, bgould@users.noreply.github.com 3 | 4 | ENV DEBIAN_FRONTEND noninteractive 5 | 6 | # RUN echo 'deb http://http.debian.net/debian jessie-backports main' >> /etc/apt/sources.list && \ 7 | # echo 'deb-src http://http.debian.net/debian jessie-backports main' >> /etc/apt/sources.list && \ 8 | # apt-get update 9 | 10 | RUN apt-get update && apt-get install -y \ 11 | build-essential gcc-4.8 g++-4.8 libgmp-dev libmpc-dev libmpfr-dev \ 12 | git curl openjdk-7-jdk \ 13 | --no-install-recommends && \ 14 | apt-get clean all 15 | 16 | RUN cd /usr/local/src && \ 17 | git clone https://github.com/bgould/nestedvm && \ 18 | cd nestedvm && \ 19 | make install CC=gcc-4.8 CXX=g++-4.8 && \ 20 | cd /usr/local/src && rm -rf nestedvm 21 | 22 | WORKDIR /usr/local/src 23 | -------------------------------------------------------------------------------- /src/org/ibex/nestedvm/Registers.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2005 the Contributors, as shown in the revision logs. 2 | // Licensed under the Apache License 2.0 ("the License"). 3 | // You may not use this file except in compliance with the License. 4 | 5 | package org.ibex.nestedvm; 6 | 7 | interface Registers { 8 | // Register Names 9 | public final static int ZERO = 0; // Immutable, hardwired to 0 10 | public final static int AT = 1; // Reserved for assembler 11 | public final static int K0 = 26; // Reserved for kernel 12 | public final static int K1 = 27; // Reserved for kernel 13 | public final static int GP = 28; // Global pointer (the middle of .sdata/.sbss) 14 | public final static int SP = 29; // Stack pointer 15 | public final static int FP = 30; // Frame Pointer 16 | public final static int RA = 31; // Return Address 17 | 18 | // Return values (caller saved) 19 | public final static int V0 = 2; 20 | public final static int V1 = 3; 21 | // Argument Registers (caller saved) 22 | public final static int A0 = 4; 23 | public final static int A1 = 5; 24 | public final static int A2 = 6; 25 | public final static int A3 = 7; 26 | // Temporaries (caller saved) 27 | public final static int T0 = 8; 28 | public final static int T1 = 9; 29 | public final static int T2 = 10; 30 | public final static int T3 = 11; 31 | public final static int T4 = 12; 32 | public final static int T5 = 13; 33 | public final static int T6 = 14; 34 | public final static int T7 = 15; 35 | public final static int T8 = 24; 36 | public final static int T9 = 25; 37 | // Saved (callee saved) 38 | public final static int S0 = 16; 39 | public final static int S1 = 17; 40 | public final static int S2 = 18; 41 | public final static int S3 = 19; 42 | public final static int S4 = 20; 43 | public final static int S5 = 21; 44 | public final static int S6 = 22; 45 | public final static int S7 = 23; 46 | } 47 | -------------------------------------------------------------------------------- /src/org/ibex/nestedvm/RuntimeCompiler.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2005 the Contributors, as shown in the revision logs. 2 | // Licensed under the Apache License 2.0 ("the License"). 3 | // You may not use this file except in compliance with the License. 4 | 5 | package org.ibex.nestedvm; 6 | 7 | import java.io.*; 8 | 9 | import org.ibex.nestedvm.util.*; 10 | 11 | // This need a lot of work to support binaries spanned across many classes 12 | public class RuntimeCompiler { 13 | public static Class compile(Seekable data) throws IOException, Compiler.Exn { return compile(data,null); } 14 | public static Class compile(Seekable data, String extraoptions) throws IOException, Compiler.Exn { return compile(data,extraoptions,null); } 15 | 16 | public static Class compile(Seekable data, String extraoptions, String sourceName) throws IOException, Compiler.Exn { 17 | String className = "nestedvm.runtimecompiled"; 18 | byte[] bytecode; 19 | try { 20 | bytecode = runCompiler(data,className,extraoptions,sourceName,null); 21 | } catch(Compiler.Exn e) { 22 | if(e.getMessage() != null || e.getMessage().indexOf("constant pool full") != -1) 23 | bytecode = runCompiler(data,className,extraoptions,sourceName,"lessconstants"); 24 | else 25 | throw e; 26 | } 27 | return new SingleClassLoader().fromBytes(className,bytecode); 28 | } 29 | 30 | private static byte[] runCompiler(Seekable data, String name, String options, String sourceName, String moreOptions) throws IOException, Compiler.Exn { 31 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); 32 | 33 | try { 34 | ClassFileCompiler c = new ClassFileCompiler(data,name,baos); 35 | c.parseOptions("nosupportcall,maxinsnpermethod=256"); 36 | c.setSource(sourceName); 37 | if(options != null) c.parseOptions(options); 38 | if(moreOptions != null) c.parseOptions(moreOptions); 39 | c.go(); 40 | } finally { 41 | data.seek(0); 42 | } 43 | 44 | baos.close(); 45 | return baos.toByteArray(); 46 | } 47 | 48 | private static class SingleClassLoader extends ClassLoader { 49 | @Override 50 | public Class loadClass(String name, boolean resolve) throws ClassNotFoundException { 51 | //System.err.println(this + ": loadClass(\"" + name + "," + resolve + ");"); 52 | return super.loadClass(name,resolve); 53 | } 54 | public Class fromBytes(String name, byte[] b) { return fromBytes(name,b,0,b.length); } 55 | public Class fromBytes(String name, byte[] b, int off, int len) { 56 | Class c = super.defineClass(name,b,off,len); 57 | resolveClass(c); 58 | return c; 59 | } 60 | } 61 | 62 | public static void main(String[] args) throws Exception { 63 | if(args.length == 0) { 64 | System.err.println("Usage: RuntimeCompiler mipsbinary"); 65 | System.exit(1); 66 | } 67 | UnixRuntime r = (UnixRuntime) compile(new Seekable.File(args[0]),"unixruntime").newInstance(); 68 | System.err.println("Instansiated: "+ r); 69 | System.exit(UnixRuntime.runAndExec(r,args)); 70 | } 71 | 72 | private RuntimeCompiler() { } 73 | } 74 | -------------------------------------------------------------------------------- /src/org/ibex/nestedvm/crt0.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern int main(int argc, char **argv, char **envp); 4 | extern void exit(int status); 5 | extern int atexit(void (*f)()); 6 | 7 | /* For constuctors/destructors */ 8 | extern void _init(); 9 | extern void _fini(); 10 | 11 | extern char _gp[]; 12 | register char *gp asm("$28"); 13 | 14 | char **environ; 15 | 16 | void _start(char **argv, char **environ_) { 17 | int argc; 18 | 19 | if(!gp) gp = _gp; 20 | 21 | environ = environ_; 22 | 23 | /* Call global constructors */ 24 | _init(); 25 | 26 | /* Register _fini() to be called on exit */ 27 | atexit(_fini); 28 | 29 | /* Count the arguments */ 30 | for(argc=0;argv[argc];argc++); 31 | 32 | /* Call main and exit */ 33 | exit(main(argc,argv,environ)); 34 | } 35 | -------------------------------------------------------------------------------- /src/org/ibex/nestedvm/linker.ld: -------------------------------------------------------------------------------- 1 | ENTRY(_start) 2 | GROUP(-lc -lgcc) 3 | 4 | __DYNAMIC = 0; 5 | 6 | SECTIONS { 7 | . = 0x10000; 8 | .text : { 9 | KEEP(*(.init)) 10 | KEEP(*(.fini)) 11 | KEEP(*(.text)) 12 | *(.text.*) 13 | *(.gnu.linkonce.t*) 14 | } 15 | 16 | _etext = .; 17 | 18 | .ctors : 19 | { 20 | KEEP (*crtbegin.o(.ctors)) 21 | KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) 22 | KEEP (*(SORT(.ctors.*))) 23 | KEEP (*(.ctors)) 24 | } 25 | 26 | .dtors : 27 | { 28 | KEEP (*crtbegin.o(.dtors)) 29 | KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) 30 | KEEP (*(SORT(.dtors.*))) 31 | KEEP (*(.dtors)) 32 | } 33 | 34 | . = ALIGN(4k); 35 | 36 | .rodata : { 37 | *(.rodata*) *(.gnu.linkonce.r*) 38 | *(.gcc_except_table) 39 | KEEP(*(.eh_frame)) KEEP(*(.jcr)) 40 | } 41 | 42 | .data : { 43 | *(.data*) *(.gnu.linkonce.d*) 44 | } 45 | 46 | . = ALIGN(16); 47 | _gp = . + 0x8000; 48 | .sdata : { 49 | *(.rosdata*) *(.sdata*) *(.gnu.linkonce.s) *(.gnu.linkonce.s.*) 50 | } 51 | .sbss : { 52 | *(.sbss*) *(.scommon*) *(.gnu.linkonce.sb*) 53 | } 54 | 55 | .bss : { 56 | *(.bss*) *(.gnu.linkonce.b*) *(COMMON) 57 | } 58 | 59 | _end = .; 60 | } 61 | -------------------------------------------------------------------------------- /src/org/ibex/nestedvm/support.s: -------------------------------------------------------------------------------- 1 | #include "syscalls.h" 2 | 3 | #define zero $0 4 | #define v0 $2 5 | #define v1 $3 6 | #define a0 $4 7 | #define a1 $5 8 | #define a2 $6 9 | #define a3 $7 10 | #define t0 $8 11 | #define t1 $9 12 | #define t2 $10 13 | #define t3 $11 14 | #define sp $29 15 | #define ra $31 16 | 17 | /* We intentionally don't take advantage of delay slots because 18 | the compiler removes them anyway */ 19 | 20 | .set noreorder; 21 | 22 | #define SYSCALL(name) SYSCALL2(name,SYS_##name) 23 | #define SYSCALL2(name,number) \ 24 | .section .text.name,"ax",@progbits; \ 25 | .align 2; \ 26 | .globl name; \ 27 | .ent name; \ 28 | name: \ 29 | li v0, number; \ 30 | syscall; \ 31 | j ra; \ 32 | nop; \ 33 | .end name; 34 | 35 | #define SYSCALL_R(name) SYSCALL_R2(_##name##_r,SYS_##name) 36 | #define SYSCALL_R_LONG(name) SYSCALL_R2_LONG(_##name##_r,SYS_##name) 37 | 38 | #define SYSCALL_R2(name,number) \ 39 | SYSCALL_R2_BEG(name,number) \ 40 | SYSCALL_R2_END(name) 41 | 42 | 43 | #define SYSCALL_R2_LONG(name,number) \ 44 | SYSCALL_R2_BEG(name,number) \ 45 | lw a3,16(sp); \ 46 | lw t0,20(sp); \ 47 | lw t1,24(sp); \ 48 | SYSCALL_R2_END(name) 49 | 50 | #define SYSCALL_R2_BEG(name,number) \ 51 | .section .text.name,"ax",@progbits; \ 52 | .align 2; \ 53 | .globl name; \ 54 | .ent name; \ 55 | name: \ 56 | li v0, number; \ 57 | move t2, a0; \ 58 | move a0, a1; \ 59 | move a1, a2; \ 60 | move a2, a3; \ 61 | 62 | #define SYSCALL_R2_END(name) \ 63 | syscall; \ 64 | addu t3,v0,255; \ 65 | sltu t3,t3,255; \ 66 | bne t3,zero,$L##name##_errno;\ 67 | nop; \ 68 | j ra; \ 69 | nop; \ 70 | $L##name##_errno: \ 71 | move a0, t2; \ 72 | move a1, v0; \ 73 | j _syscall_set_errno; \ 74 | nop; \ 75 | .end name; 76 | 77 | 78 | .align 2 79 | .globl _call_helper 80 | .ent _call_helper 81 | _call_helper: 82 | subu sp,sp,32 83 | 84 | /* addr */ 85 | move $2,$4 86 | 87 | /* args 1-4 */ 88 | move $4,$5 89 | move $5,$6 90 | move $6,$7 91 | move $7,$16 92 | 93 | /* args 5 and 6 */ 94 | sw $17,16(sp) 95 | sw $18,20(sp) 96 | 97 | /* call the func */ 98 | jal $31,$2 99 | nop 100 | 101 | move $3,$2 102 | li $2,SYS_pause 103 | syscall 104 | 105 | /* shouldn't get here */ 106 | li $2,SYS_exit 107 | li $3,1 108 | syscall 109 | 110 | .end _call_helper 111 | 112 | SYSCALL2(_exit,SYS_exit) 113 | SYSCALL2(_pause,SYS_pause) 114 | SYSCALL_R(open) 115 | SYSCALL_R(close) 116 | SYSCALL_R(read) 117 | SYSCALL_R(write) 118 | SYSCALL_R(sbrk) 119 | SYSCALL_R(fstat) 120 | SYSCALL_R(lseek) 121 | SYSCALL_R(kill) 122 | SYSCALL_R(getpid) 123 | SYSCALL2(_call_java,SYS_calljava) 124 | SYSCALL_R(stat) 125 | SYSCALL_R(gettimeofday) 126 | SYSCALL(sleep) 127 | SYSCALL_R(times) 128 | SYSCALL_R(mkdir) 129 | SYSCALL(getpagesize) 130 | SYSCALL_R(unlink) 131 | SYSCALL_R(utime) 132 | SYSCALL_R(chdir) 133 | SYSCALL_R(pipe) 134 | SYSCALL_R(dup2) 135 | SYSCALL_R(fork) 136 | SYSCALL_R(waitpid) 137 | SYSCALL_R2(__getcwd_r,SYS_getcwd) 138 | SYSCALL_R2(__execve_r,SYS_exec) 139 | SYSCALL_R(fcntl) 140 | SYSCALL_R(rmdir) 141 | SYSCALL_R(sysconf) 142 | SYSCALL_R(readlink) 143 | SYSCALL_R(lstat) 144 | SYSCALL_R(symlink) 145 | SYSCALL_R(link) 146 | SYSCALL_R_LONG(getdents) 147 | SYSCALL(memcpy) 148 | SYSCALL(memset) 149 | SYSCALL_R(dup) 150 | SYSCALL_R(vfork) 151 | SYSCALL_R(chroot) 152 | SYSCALL_R(mknod) 153 | SYSCALL_R(lchown) 154 | SYSCALL_R(ftruncate) 155 | SYSCALL_R(usleep) 156 | SYSCALL(getppid) 157 | SYSCALL_R(mkfifo) 158 | SYSCALL_R(klogctl) 159 | SYSCALL_R(realpath) 160 | SYSCALL_R2_LONG(__sysctl_r,SYS_sysctl) 161 | SYSCALL_R(getpriority) 162 | SYSCALL_R(setpriority) 163 | SYSCALL_R(socket) 164 | SYSCALL_R(connect) 165 | SYSCALL_R2(__resolve_hostname_r,SYS_resolve_hostname) 166 | SYSCALL_R(accept) 167 | SYSCALL_R_LONG(setsockopt) 168 | SYSCALL_R_LONG(getsockopt) 169 | SYSCALL_R(listen) 170 | SYSCALL_R(bind) 171 | SYSCALL_R(shutdown) 172 | SYSCALL_R_LONG(sendto) 173 | SYSCALL_R_LONG(recvfrom) 174 | SYSCALL_R_LONG(select) 175 | SYSCALL(umask) 176 | SYSCALL(getuid) 177 | SYSCALL(geteuid) 178 | SYSCALL(getgid) 179 | SYSCALL(getegid) 180 | SYSCALL_R(send) 181 | SYSCALL_R(recv) 182 | SYSCALL_R(getsockname) 183 | SYSCALL_R(getpeername) 184 | SYSCALL_R(setuid) 185 | SYSCALL_R(seteuid) 186 | SYSCALL_R(setgid) 187 | SYSCALL_R(setegid) 188 | SYSCALL_R(setgroups) 189 | SYSCALL_R(access) 190 | SYSCALL_R(chown) 191 | SYSCALL_R(fchown) 192 | SYSCALL_R(chmod) 193 | SYSCALL_R(fchmod) 194 | SYSCALL(alarm) 195 | SYSCALL_R(getgroups) 196 | SYSCALL_R(setsid) 197 | SYSCALL_R2(__resolve_ip_r,SYS_resolve_ip) 198 | SYSCALL_R(fsync) 199 | -------------------------------------------------------------------------------- /src/org/ibex/nestedvm/syscalls.h: -------------------------------------------------------------------------------- 1 | #define SYS_null 0 2 | #define SYS_exit 1 3 | #define SYS_pause 2 4 | #define SYS_open 3 5 | #define SYS_close 4 6 | #define SYS_read 5 7 | #define SYS_write 6 8 | #define SYS_sbrk 7 9 | #define SYS_fstat 8 10 | #define SYS_lseek 10 11 | #define SYS_kill 11 12 | #define SYS_getpid 12 13 | #define SYS_calljava 13 14 | #define SYS_stat 14 15 | #define SYS_gettimeofday 15 16 | #define SYS_sleep 16 17 | #define SYS_times 17 18 | #define SYS_mkdir 18 19 | #define SYS_getpagesize 19 20 | #define SYS_unlink 20 21 | #define SYS_utime 21 22 | #define SYS_chdir 22 23 | #define SYS_pipe 23 24 | #define SYS_dup2 24 25 | #define SYS_fork 25 26 | #define SYS_waitpid 26 27 | #define SYS_getcwd 27 28 | #define SYS_exec 28 29 | #define SYS_fcntl 29 30 | #define SYS_rmdir 30 31 | #define SYS_sysconf 31 32 | #define SYS_readlink 32 33 | #define SYS_lstat 33 34 | #define SYS_symlink 34 35 | #define SYS_link 35 36 | #define SYS_getdents 36 37 | #define SYS_memcpy 37 38 | #define SYS_memset 38 39 | #define SYS_dup 39 40 | #define SYS_vfork 40 41 | #define SYS_chroot 41 42 | #define SYS_mknod 42 43 | #define SYS_lchown 43 44 | #define SYS_ftruncate 44 45 | #define SYS_usleep 45 46 | #define SYS_getppid 46 47 | #define SYS_mkfifo 47 48 | #define SYS_klogctl 51 49 | #define SYS_realpath 52 50 | #define SYS_sysctl 53 51 | #define SYS_setpriority 54 52 | #define SYS_getpriority 55 53 | #define SYS_socket 56 54 | #define SYS_connect 57 55 | #define SYS_resolve_hostname 58 56 | #define SYS_accept 59 57 | #define SYS_setsockopt 60 58 | #define SYS_getsockopt 61 59 | #define SYS_listen 62 60 | #define SYS_bind 63 61 | #define SYS_shutdown 64 62 | #define SYS_sendto 65 63 | #define SYS_recvfrom 66 64 | #define SYS_select 67 65 | #define SYS_getuid 68 66 | #define SYS_getgid 69 67 | #define SYS_geteuid 70 68 | #define SYS_getegid 71 69 | #define SYS_getgroups 72 70 | #define SYS_umask 73 71 | #define SYS_chmod 74 72 | #define SYS_fchmod 75 73 | #define SYS_chown 76 74 | #define SYS_fchown 77 75 | #define SYS_access 78 76 | #define SYS_alarm 79 77 | #define SYS_setuid 80 78 | #define SYS_setgid 81 79 | #define SYS_send 82 80 | #define SYS_recv 83 81 | #define SYS_getsockname 84 82 | #define SYS_getpeername 85 83 | #define SYS_seteuid 86 84 | #define SYS_setegid 87 85 | #define SYS_setgroups 88 86 | #define SYS_resolve_ip 89 87 | #define SYS_setsid 90 88 | #define SYS_fsync 91 89 | -------------------------------------------------------------------------------- /src/org/ibex/nestedvm/util/InodeCache.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2005 the Contributors, as shown in the revision logs. 2 | // Licensed under the Apache License 2.0 ("the License"). 3 | // You may not use this file except in compliance with the License. 4 | 5 | package org.ibex.nestedvm.util; 6 | 7 | // Based on the various org.xwt.util.* classes by Adam Megacz 8 | 9 | public class InodeCache { 10 | private static final Object PLACEHOLDER = new Object(); 11 | private static final short SHORT_PLACEHOLDER = -2; 12 | private static final short SHORT_NULL = -1; 13 | private static final int LOAD_FACTOR = 2; 14 | 15 | private final int maxSize; 16 | private final int totalSlots; 17 | private final int maxUsedSlots; 18 | 19 | private final Object[] keys; 20 | private final short[] next; 21 | private final short[] prev; 22 | private final short[] inodes; 23 | private final short[] reverse; 24 | 25 | private int size, usedSlots; 26 | private short mru, lru; 27 | 28 | public InodeCache() { this(1024); } 29 | public InodeCache(int maxSize) { 30 | this.maxSize = maxSize; 31 | totalSlots = maxSize*LOAD_FACTOR*2 + 3; 32 | maxUsedSlots = totalSlots / LOAD_FACTOR; 33 | if(totalSlots > Short.MAX_VALUE) throw new IllegalArgumentException("cache size too large"); 34 | keys = new Object[totalSlots]; 35 | next = new short[totalSlots]; 36 | prev = new short[totalSlots]; 37 | inodes = new short[totalSlots]; 38 | reverse = new short[totalSlots]; 39 | clear(); 40 | } 41 | 42 | private static void fill(Object[] a,Object o) { for(int i=0;i " + inodes[i] + "(prev: " + prev[i] + " next: " + next[i] + ")"); 167 | if(i == lru) break; 168 | } 169 | } 170 | 171 | private void stats() { 172 | int freeKeys = 0; 173 | int freeReverse = 0; 174 | int placeholderKeys = 0; 175 | int placeholderReverse = 0; 176 | for(int i=0;i " + c.reverse(n)); 195 | } else { 196 | //System.err.println("Adding " + s); 197 | short n = c.get(s); 198 | System.err.println("Added " + s + " -> " + n); 199 | //c.dump(); 200 | } 201 | } 202 | good = true; 203 | } finally { 204 | if(!good) c.stats(); 205 | } 206 | }*/ 207 | } 208 | -------------------------------------------------------------------------------- /src/org/ibex/nestedvm/util/Platform.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2005 the Contributors, as shown in the revision logs. 2 | // Licensed under the Apache License 2.0 ("the License"). 3 | // You may not use this file except in compliance with the License. 4 | 5 | package org.ibex.nestedvm.util; 6 | 7 | import java.io.*; 8 | import java.nio.channels.*; 9 | import java.net.*; 10 | import java.util.*; 11 | 12 | import java.text.DateFormatSymbols; 13 | 14 | /* 15 | GCCLASS_HINT: org.ibex.nestedvm.util.Platform. org.ibex.nestedvm.util.Platform$Jdk11. 16 | GCCLASS_HINT: org.ibex.nestedvm.util.Platform. org.ibex.nestedvm.util.Platform$Jdk12. 17 | GCCLASS_HINT: org.ibex.nestedvm.util.Platform. org.ibex.nestedvm.util.Platform$Jdk13. 18 | GCCLASS_HINT: org.ibex.nestedvm.util.Platform. org.ibex.nestedvm.util.Platform$Jdk14. 19 | */ 20 | 21 | public abstract class Platform { 22 | Platform() { } 23 | private static final Platform p; 24 | 25 | static { 26 | float version; 27 | try { 28 | if(getProperty("java.vm.name").equals("SableVM")) 29 | version = 1.2f; 30 | else 31 | version = Float.valueOf(getProperty("java.specification.version")).floatValue(); 32 | } catch(Exception e) { 33 | System.err.println("WARNING: " + e + " while trying to find jvm version - assuming 1.1"); 34 | version = 1.1f; 35 | } 36 | String platformClass; 37 | if(version >= 1.4f) platformClass = "Jdk14"; 38 | else if(version >= 1.3f) platformClass = "Jdk13"; 39 | else if(version >= 1.2f) platformClass = "Jdk12"; 40 | else if(version >= 1.1f) platformClass = "Jdk11"; 41 | else throw new Error("JVM Specification version: " + version + " is too old. (see org.ibex.util.Platform to add support)"); 42 | 43 | try { 44 | p = (Platform) Class.forName(Platform.class.getName() + "$" + platformClass).newInstance(); 45 | } catch(Exception e) { 46 | e.printStackTrace(); 47 | throw new Error("Error instansiating platform class"); 48 | } 49 | } 50 | 51 | public static String getProperty(String key) { 52 | try { 53 | return System.getProperty(key); 54 | } catch(SecurityException e) { 55 | return null; 56 | } 57 | } 58 | 59 | 60 | abstract boolean _atomicCreateFile(File f) throws IOException; 61 | public static boolean atomicCreateFile(File f) throws IOException { return p._atomicCreateFile(f); } 62 | 63 | abstract Seekable.Lock _lockFile(Seekable s, RandomAccessFile raf, long pos, long size, boolean shared) throws IOException; 64 | public static Seekable.Lock lockFile(Seekable s, RandomAccessFile raf, long pos, long size, boolean shared) throws IOException { 65 | return p._lockFile(s, raf, pos, size, shared); } 66 | 67 | abstract void _socketHalfClose(Socket s, boolean output) throws IOException; 68 | public static void socketHalfClose(Socket s, boolean output) throws IOException { p._socketHalfClose(s,output); } 69 | 70 | abstract void _socketSetKeepAlive(Socket s, boolean on) throws SocketException; 71 | public static void socketSetKeepAlive(Socket s, boolean on) throws SocketException { p._socketSetKeepAlive(s,on); } 72 | 73 | abstract InetAddress _inetAddressFromBytes(byte[] a) throws UnknownHostException; 74 | public static InetAddress inetAddressFromBytes(byte[] a) throws UnknownHostException { return p._inetAddressFromBytes(a); } 75 | 76 | abstract String _timeZoneGetDisplayName(TimeZone tz, boolean dst, boolean showlong, Locale l); 77 | public static String timeZoneGetDisplayName(TimeZone tz, boolean dst, boolean showlong, Locale l) { return p._timeZoneGetDisplayName(tz,dst,showlong,l); } 78 | public static String timeZoneGetDisplayName(TimeZone tz, boolean dst, boolean showlong) { return timeZoneGetDisplayName(tz,dst,showlong,Locale.getDefault()); } 79 | 80 | abstract void _setFileLength(RandomAccessFile f, int length) 81 | throws IOException; 82 | public static void setFileLength(RandomAccessFile f, int length) 83 | throws IOException { p._setFileLength(f, length); } 84 | 85 | abstract File[] _listRoots(); 86 | public static File[] listRoots() { return p._listRoots(); } 87 | 88 | abstract File _getRoot(File f); 89 | public static File getRoot(File f) { return p._getRoot(f); } 90 | 91 | static class Jdk11 extends Platform { 92 | @Override 93 | boolean _atomicCreateFile(File f) throws IOException { 94 | // This is not atomic, but its the best we can do on jdk 1.1 95 | if(f.exists()) return false; 96 | new FileOutputStream(f).close(); 97 | return true; 98 | } 99 | @Override 100 | Seekable.Lock _lockFile(Seekable s, RandomAccessFile raf, long p, long size, boolean shared) throws IOException { 101 | throw new IOException("file locking requires jdk 1.4+"); 102 | } 103 | @Override 104 | void _socketHalfClose(Socket s, boolean output) throws IOException { 105 | throw new IOException("half closing sockets not supported"); 106 | } 107 | @Override 108 | InetAddress _inetAddressFromBytes(byte[] a) throws UnknownHostException { 109 | if(a.length != 4) throw new UnknownHostException("only ipv4 addrs supported"); 110 | return InetAddress.getByName(""+(a[0]&0xff)+"."+(a[1]&0xff)+"."+(a[2]&0xff)+"."+(a[3]&0xff)); 111 | } 112 | @Override 113 | void _socketSetKeepAlive(Socket s, boolean on) throws SocketException { 114 | if(on) throw new SocketException("keepalive not supported"); 115 | } 116 | @Override 117 | String _timeZoneGetDisplayName(TimeZone tz, boolean dst, boolean showlong, Locale l) { 118 | String[][] zs = new DateFormatSymbols(l).getZoneStrings(); 119 | String id = tz.getID(); 120 | for(int i=0;i 0) sb.append(":").append(off/60); off=off%60; 129 | if(off > 0) sb.append(":").append(off); 130 | return sb.toString(); 131 | } 132 | 133 | @Override 134 | void _setFileLength(RandomAccessFile f, int length) throws IOException{ 135 | try (InputStream in = new FileInputStream(f.getFD())) { 136 | try (OutputStream out = new FileOutputStream(f.getFD())) { 137 | byte[] buf = new byte[1024]; 138 | for (int len; length > 0; length -= len) { 139 | len = in.read(buf, 0, Math.min(length, buf.length)); 140 | if (len == -1) break; 141 | out.write(buf, 0, len); 142 | } 143 | if (length == 0) return; 144 | 145 | // fill the rest of the space with zeros 146 | for (int i=0; i < buf.length; i++) buf[i] = 0; 147 | while (length > 0) { 148 | out.write(buf, 0, Math.min(length, buf.length)); 149 | length -= buf.length; 150 | } 151 | } 152 | } 153 | } 154 | 155 | RandomAccessFile _truncatedRandomAccessFile(File f, String mode) throws IOException { 156 | new FileOutputStream(f).close(); 157 | return new RandomAccessFile(f,mode); 158 | } 159 | 160 | @Override 161 | File[] _listRoots() { 162 | String[] rootProps = new String[]{"java.home","java.class.path","java.library.path","java.io.tmpdir","java.ext.dirs","user.home","user.dir" }; 163 | Hashtable known = new Hashtable<>(); 164 | for(int i=0;i " + root); 176 | known.put(root,Boolean.TRUE); 177 | if(p == -1) break; 178 | } 179 | } 180 | File[] ret = new File[known.size()]; 181 | int i=0; 182 | for(Enumeration e = known.keys();e.hasMoreElements();) 183 | ret[i++] = e.nextElement(); 184 | return ret; 185 | } 186 | 187 | @Override 188 | File _getRoot(File f) { 189 | if(!f.isAbsolute()) f = new File(f.getAbsolutePath()); 190 | String p; 191 | while((p = f.getParent()) != null) f = new File(p); 192 | if(f.getPath().length() == 0) f = new File("/"); // work around a classpath bug 193 | return f; 194 | } 195 | } 196 | 197 | static class Jdk12 extends Jdk11 { 198 | @Override 199 | boolean _atomicCreateFile(File f) throws IOException { 200 | return f.createNewFile(); 201 | } 202 | 203 | @Override 204 | String _timeZoneGetDisplayName(TimeZone tz, boolean dst, boolean showlong, Locale l) { 205 | return tz.getDisplayName(dst,showlong ? TimeZone.LONG : TimeZone.SHORT, l); 206 | } 207 | 208 | @Override 209 | void _setFileLength(RandomAccessFile f, int length) throws IOException { 210 | f.setLength(length); 211 | } 212 | 213 | @Override 214 | File[] _listRoots() { return File.listRoots(); } 215 | } 216 | 217 | static class Jdk13 extends Jdk12 { 218 | @Override 219 | void _socketHalfClose(Socket s, boolean output) throws IOException { 220 | if(output) s.shutdownOutput(); 221 | else s.shutdownInput(); 222 | } 223 | 224 | @Override 225 | void _socketSetKeepAlive(Socket s, boolean on) throws SocketException { 226 | s.setKeepAlive(on); 227 | } 228 | } 229 | 230 | static class Jdk14 extends Jdk13 { 231 | @Override 232 | InetAddress _inetAddressFromBytes(byte[] a) throws UnknownHostException { return InetAddress.getByAddress(a); } 233 | 234 | @Override 235 | Seekable.Lock _lockFile(Seekable s, RandomAccessFile r, long pos, long size, boolean shared) throws IOException { 236 | FileLock flock; 237 | try { 238 | flock = pos == 0 && size == 0 ? r.getChannel().lock() : 239 | r.getChannel().tryLock(pos, size, shared); 240 | } catch (OverlappingFileLockException e) { flock = null; } 241 | if (flock == null) return null; // region already locked 242 | return new Jdk14FileLock(s, flock); 243 | } 244 | } 245 | 246 | private static final class Jdk14FileLock extends Seekable.Lock { 247 | private final Seekable s; 248 | private final FileLock l; 249 | 250 | Jdk14FileLock(Seekable sk, FileLock flock) { s = sk; l = flock; } 251 | @Override 252 | public Seekable seekable() { return s; } 253 | @Override 254 | public boolean isShared() { return l.isShared(); } 255 | @Override 256 | public boolean isValid() { return l.isValid(); } 257 | @Override 258 | public void release() throws IOException { l.release(); } 259 | @Override 260 | public long position() { return l.position(); } 261 | @Override 262 | public long size() { return l.size(); } 263 | @Override 264 | public String toString() { return l.toString(); } 265 | } 266 | } 267 | -------------------------------------------------------------------------------- /src/org/ibex/nestedvm/util/Seekable.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2005 the Contributors, as shown in the revision logs. 2 | // Licensed under the Apache License 2.0 ("the License"). 3 | // You may not use this file except in compliance with the License. 4 | 5 | package org.ibex.nestedvm.util; 6 | 7 | import java.io.*; 8 | 9 | public abstract class Seekable { 10 | public abstract int read(byte[] buf, int offset, int length) throws IOException; 11 | public abstract int write(byte[] buf, int offset, int length) throws IOException; 12 | public abstract int length() throws IOException; 13 | public abstract void seek(int pos) throws IOException; 14 | public abstract void close() throws IOException; 15 | public abstract int pos() throws IOException; 16 | 17 | public void sync() throws IOException { 18 | throw new IOException("sync not implemented for " + getClass()); 19 | } 20 | public void resize(long length) throws IOException { 21 | throw new IOException("resize not implemented for " + getClass()); 22 | } 23 | /** If pos == 0 and size == 0 lock covers whole file. */ 24 | public Lock lock(long pos, long size, boolean shared) throws IOException { 25 | throw new IOException("lock not implemented for " + getClass()); 26 | } 27 | 28 | public int read() throws IOException { 29 | byte[] buf = new byte[1]; 30 | int n = read(buf,0,1); 31 | return n == -1 ? -1 : buf[0]&0xff; 32 | } 33 | 34 | public int tryReadFully(byte[] buf, int off, int len) throws IOException { 35 | int total = 0; 36 | while(len > 0) { 37 | int n = read(buf,off,len); 38 | if(n == -1) break; 39 | off += n; 40 | len -= n; 41 | total += n; 42 | } 43 | return total == 0 ? -1 : total; 44 | } 45 | 46 | public static class ByteArray extends Seekable { 47 | protected byte[] data; 48 | protected int pos; 49 | private final boolean writable; 50 | 51 | public ByteArray(byte[] data, boolean writable) { 52 | this.data = data; 53 | this.pos = 0; 54 | this.writable = writable; 55 | } 56 | 57 | public int read(byte[] buf, int off, int len) { 58 | len = Math.min(len,data.length-pos); 59 | if(len <= 0) return -1; 60 | System.arraycopy(data,pos,buf,off,len); 61 | pos += len; 62 | return len; 63 | } 64 | 65 | public int write(byte[] buf, int off, int len) throws IOException { 66 | if(!writable) throw new IOException("read-only data"); 67 | len = Math.min(len,data.length-pos); 68 | if(len <= 0) throw new IOException("no space"); 69 | System.arraycopy(buf,off,data,pos,len); 70 | pos += len; 71 | return len; 72 | } 73 | 74 | public int length() { return data.length; } 75 | public int pos() { return pos; } 76 | public void seek(int pos) { this.pos = pos; } 77 | public void close() { /*noop*/ } 78 | } 79 | 80 | public static class File extends Seekable { 81 | private final java.io.File file; 82 | private final RandomAccessFile raf; 83 | 84 | public File(String fileName) throws IOException { this(fileName,false); } 85 | public File(String fileName, boolean writable) throws IOException { this(new java.io.File(fileName),writable,false); } 86 | 87 | public File(java.io.File file, boolean writable, boolean truncate) throws IOException { 88 | this.file = file; 89 | String mode = writable ? "rw" : "r"; 90 | raf = new RandomAccessFile(file,mode); 91 | if (truncate) Platform.setFileLength(raf, 0); 92 | } 93 | 94 | public int read(byte[] buf, int offset, int length) throws IOException { return raf.read(buf,offset,length); } 95 | public int write(byte[] buf, int offset, int length) throws IOException { raf.write(buf,offset,length); return length; } 96 | public void sync() throws IOException { raf.getFD().sync(); } 97 | public void seek(int pos) throws IOException{ raf.seek(pos); } 98 | public int pos() throws IOException { return (int) raf.getFilePointer(); } 99 | public int length() throws IOException { return (int)raf.length(); } 100 | public void close() throws IOException { raf.close(); } 101 | public void resize(long length) throws IOException { Platform.setFileLength(raf, (int)length); } 102 | public boolean equals(Object o) { 103 | return o != null && o instanceof File 104 | && file.equals(((File)o).file); 105 | } 106 | public int hashCode() { 107 | return file.hashCode(); 108 | } 109 | public Lock lock(long pos, long size, boolean shared) 110 | throws IOException { 111 | return Platform.lockFile(this, raf, pos, size, shared); 112 | } 113 | } 114 | 115 | public static class InputStream extends Seekable { 116 | private byte[] buffer = new byte[4096]; 117 | private int bytesRead = 0; 118 | private boolean eof = false; 119 | private int pos; 120 | private java.io.InputStream is; 121 | 122 | public InputStream(java.io.InputStream is) { this.is = is; } 123 | 124 | public int read(byte[] outbuf, int off, int len) throws IOException { 125 | if(pos >= bytesRead && !eof) readTo(pos + 1); 126 | len = Math.min(len,bytesRead-pos); 127 | if(len <= 0) return -1; 128 | System.arraycopy(buffer,pos,outbuf,off,len); 129 | pos += len; 130 | return len; 131 | } 132 | 133 | private void readTo(int target) throws IOException { 134 | if(target >= buffer.length) { 135 | byte[] buf2 = new byte[Math.max(buffer.length+Math.min(buffer.length,65536),target)]; 136 | System.arraycopy(buffer,0,buf2,0,bytesRead); 137 | buffer = buf2; 138 | } 139 | while(bytesRead < target) { 140 | int n = is.read(buffer,bytesRead,buffer.length-bytesRead); 141 | if(n == -1) { 142 | eof = true; 143 | break; 144 | } 145 | bytesRead += n; 146 | } 147 | } 148 | 149 | public int length() throws IOException { 150 | while(!eof) readTo(bytesRead+4096); 151 | return bytesRead; 152 | } 153 | 154 | public int write(byte[] buf, int off, int len) throws IOException { throw new IOException("read-only"); } 155 | public void seek(int pos) { this.pos = pos; } 156 | public int pos() { return pos; } 157 | public void close() throws IOException { is.close(); } 158 | } 159 | 160 | public abstract static class Lock { 161 | private Object owner = null; 162 | 163 | public abstract Seekable seekable(); 164 | public abstract boolean isShared(); 165 | public abstract boolean isValid(); 166 | public abstract void release() throws IOException; 167 | public abstract long position(); 168 | public abstract long size(); 169 | 170 | public void setOwner(Object o) { owner = o; } 171 | public Object getOwner() { return owner; } 172 | 173 | public final boolean contains(int start, int len) { 174 | return start >= position() && position() + size() >= start + len; 175 | } 176 | 177 | public final boolean contained(int start, int len) { 178 | return start < position() && position() + size() < start + len; 179 | } 180 | 181 | public final boolean overlaps(int start, int len) { 182 | return contains(start, len) || contained(start, len); 183 | } 184 | } 185 | } 186 | -------------------------------------------------------------------------------- /src/org/ibex/nestedvm/util/Sort.java: -------------------------------------------------------------------------------- 1 | package org.ibex.nestedvm.util; 2 | 3 | public final class Sort { 4 | private Sort() { } 5 | 6 | public interface Comparable { public int compareTo(Object o); } 7 | public interface CompareFunc { public int compare(Object a, Object b); } 8 | 9 | private static final CompareFunc comparableCompareFunc = new CompareFunc() { 10 | public int compare(Object a,Object b) { return ((Comparable)a).compareTo(b); } 11 | }; 12 | 13 | public static void sort(Comparable[] a) { sort(a,comparableCompareFunc); } 14 | public static void sort(Object[] a, CompareFunc c) { sort(a,c,0,a.length-1); } 15 | 16 | private static void sort(Object[] a, CompareFunc c, int start, int end) { 17 | Object tmp; 18 | if(start >= end) return; 19 | if(end-start <= 6) { 20 | for(int i=start+1;i<=end;i++) { 21 | tmp = a[i]; 22 | int j; 23 | for(j=i-1;j>=start;j--) { 24 | if(c.compare(a[j],tmp) <= 0) break; 25 | a[j+1] = a[j]; 26 | } 27 | a[j+1] = tmp; 28 | } 29 | return; 30 | } 31 | 32 | Object pivot = a[end]; 33 | int lo = start - 1; 34 | int hi = end; 35 | 36 | do { 37 | while((lo < hi) && c.compare(a[++lo],pivot) < 0) { } 38 | while((hi > lo) && c.compare(a[--hi],pivot) > 0) { } 39 | tmp = a[lo]; a[lo] = a[hi]; a[hi] = tmp; 40 | } while(lo < hi); 41 | 42 | tmp = a[lo]; a[lo] = a[end]; a[end] = tmp; 43 | 44 | sort(a, c, start, lo-1); 45 | sort(a, c, lo+1, end); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/org/ibex/nestedvm/util/UnixRuntimeJavaBridge.java: -------------------------------------------------------------------------------- 1 | // Copyright 2014 the Contributors, as shown in the revision logs. 2 | // Licensed under the Apache License 2.0 ("the License"). 3 | // You may not use this file except in compliance with the License. 4 | 5 | package org.ibex.nestedvm.util; 6 | 7 | import org.ibex.nestedvm.Runtime; 8 | import org.ibex.nestedvm.UnixRuntime; 9 | 10 | import java.io.InputStream; 11 | import java.io.OutputStream; 12 | 13 | public class UnixRuntimeJavaBridge { 14 | public static boolean setStdin(UnixRuntime runtime, InputStream in) { 15 | int fd = runtime.addFD(new Runtime.InputOutputStreamFD(in)); 16 | return runtime.sys_dup2(fd, 0) == 0; 17 | } 18 | 19 | public static boolean setStdout(UnixRuntime runtime, OutputStream out) { 20 | int fd = runtime.addFD(new Runtime.InputOutputStreamFD(out)); 21 | return runtime.sys_dup2(fd, 1) == 0; 22 | } 23 | 24 | public static boolean setStderr(UnixRuntime runtime, OutputStream out) { 25 | int fd = runtime.addFD(new Runtime.InputOutputStreamFD(out)); 26 | return runtime.sys_dup2(fd, 2) == 0; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/tests/CXXTest.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | class Test { 8 | public: 9 | Test(); 10 | ~Test(); 11 | void sayhi(); 12 | }; 13 | 14 | class Exn { 15 | public: 16 | Exn() { } 17 | }; 18 | 19 | 20 | Test test; 21 | 22 | int main(int argc,char *argv[]) { 23 | printf("Name: %p\n",typeid(const char*).name()); 24 | printf("Name: %s\n",typeid(const char*).name()); 25 | printf("Is pointer: %d\n",typeid(const char*).__is_pointer_p ()); 26 | printf("Name: %p\n",typeid(int).name()); 27 | printf("Name: %s\n",typeid(int).name()); 28 | printf("Is pointer: %d\n",typeid(int).__is_pointer_p ()); 29 | 30 | try { 31 | test.sayhi(); 32 | } catch(char *e) { 33 | printf("sayhi threw: %s\n",e); 34 | } catch(const char *e) { 35 | printf("sayhi threw: const char *:%s\n",e); 36 | } catch(int n) { 37 | printf("sayhi threw: %d\n",n); 38 | } 39 | return 0; 40 | } 41 | 42 | Test::Test() { 43 | cout << "Test's constructor" << endl; 44 | } 45 | 46 | Test::~Test() { 47 | cout << "Test's destructor" << endl; 48 | } 49 | 50 | void Test::sayhi() { 51 | static char exn[] = "Non-const!"; 52 | cout << "Hello, World from Test" << endl; 53 | cout << "Now throwing an exception" << endl; 54 | throw "Hello, Exception Handling!"; 55 | //throw exn; 56 | } 57 | -------------------------------------------------------------------------------- /src/tests/CallTest.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2005 the Contributors, as shown in the revision logs. 2 | // Licensed under the Apache License 2.0 ("the License"). 3 | // You may not use this file except in compliance with the License. 4 | 5 | package tests; 6 | 7 | import org.ibex.nestedvm.Runtime; 8 | import java.io.*; 9 | import java.util.Date; 10 | 11 | public class CallTest { 12 | public static void main(String[] args) throws Exception { 13 | int a1 = args.length > 0 ? Integer.parseInt(args[0]) : 0; 14 | int a2 = args.length > 1 ? Integer.parseInt(args[1]) : 0; 15 | int a3 = args.length > 2 ? Integer.parseInt(args[2]) : 0; 16 | int a4 = args.length > 3 ? Integer.parseInt(args[3]) : 0; 17 | int a5 = args.length > 4 ? Integer.parseInt(args[4]) : 0; 18 | int a6 = args.length > 5 ? Integer.parseInt(args[5]) : 0; 19 | 20 | System.out.println("Version is: " + System.getProperty("os.version")); 21 | final Runtime rt; 22 | if(a1 == 99) // yeah.. this is ugly 23 | rt = new org.ibex.nestedvm.Interpreter("build/tests/Test.mips"); 24 | else 25 | rt = (Runtime) Class.forName("tests.Test").newInstance(); 26 | 27 | rt.setCallJavaCB(new Runtime.CallJavaCB() { 28 | public int call(int a, int b, int c, int d) { 29 | switch(a) { 30 | case 1: return rt.strdup("OS: " + System.getProperty("os.name")); 31 | case 2: return rt.strdup(System.getProperty("os.version")); 32 | case 3: return rt.strdup(new Date().toString()); 33 | case 4: return rt.addFD(new Runtime.InputOutputStreamFD(null,new CustomOS())); 34 | case 5: 35 | System.out.println("In callJava() in Java"); 36 | try { rt.call("backinmips"); } catch(Runtime.CallException e) { } 37 | System.out.println("Back in callJava() in Java"); 38 | return 0; 39 | default: return 0; 40 | } 41 | } 42 | }); 43 | System.out.println("Runtime: " + rt); 44 | 45 | rt.start(new String[]{"Test","calltest"}); 46 | rt.execute(); 47 | 48 | System.out.println("== Start of CallTest =="); 49 | System.out.println("Back in java... calling callme()"); 50 | int ret = rt.call("callme",new int[]{a1,a2,a3,a4,a5,a6}); 51 | System.out.println("callme returned: " + ret); 52 | 53 | int addr = rt.strdup("Hello, World from java"); 54 | rt.call("echo",addr,4); 55 | rt.free(addr); 56 | rt.call("echo",new Object[]{"Hello, World, from the Object[] call method",new Integer(2)}); 57 | System.out.println("== End of CallTest =="); 58 | 59 | rt.execute(); 60 | System.exit(rt.exitStatus()); 61 | } 62 | 63 | private static class CustomOS extends OutputStream { 64 | public CustomOS() { } 65 | public void write(int b) { byte[] a = new byte[1]; a[0] = (byte)(b&0xff); write(a,0,1); } 66 | public void write(byte[] b, int off, int len) { 67 | int len2 = len; 68 | while(b[len2-1]=='\n') len2--; 69 | System.out.println("This just in from MIPS: " + new String(b,off,len2)); 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/tests/Echo.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2005 the Contributors, as shown in the revision logs. 2 | // Licensed under the Apache License 2.0 ("the License"). 3 | // You may not use this file except in compliance with the License. 4 | 5 | package tests; 6 | 7 | import java.net.*; 8 | 9 | import org.ibex.nestedvm.Runtime; 10 | 11 | public class Echo { 12 | private static final int PORT = 2000; 13 | public static void main(String[] args) throws Exception { 14 | ServerSocket sock = new ServerSocket(PORT); 15 | System.err.println("Listening on " + PORT); 16 | for(;;) new Client(sock.accept()).go(); 17 | } 18 | 19 | private static class Client implements Runnable { 20 | private Socket sock; 21 | public Client(Socket sock) { this.sock = sock; } 22 | public void go() { new Thread(this).start(); } 23 | public void run() { 24 | try { 25 | Runtime task = (Runtime) Class.forName("tests.EchoHelper").newInstance(); 26 | task.closeFD(0); 27 | task.closeFD(1); 28 | //task.closeFD(2); 29 | task.addFD(new Runtime.InputOutputStreamFD(sock.getInputStream())); 30 | task.addFD(new Runtime.InputOutputStreamFD(sock.getOutputStream())); 31 | //task.dupFD(1); 32 | 33 | int status = task.run(new String[]{"EchoHelper"} ); 34 | System.err.println("Exit status: " + status); 35 | } catch(Exception e) { 36 | System.err.println(e); 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/tests/EchoHelper.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() { 5 | char buf[1024]; 6 | char *p; 7 | printf("Hello! Welcome to EchoHelper.c\n"); 8 | while(fgets(buf,sizeof(buf),stdin) != NULL) { 9 | for(p=buf;*p && *p!='\n' && *p!='\r';p++); 10 | *p = '\0'; 11 | fprintf(stdout,"You said: %s\n",buf); 12 | fflush(stdout); 13 | fprintf(stderr,"They said: %s\n",buf); 14 | if(strcmp(buf,"exit")==0) break; 15 | } 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /src/tests/Env.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2005 the Contributors, as shown in the revision logs. 2 | // Licensed under the Apache License 2.0 ("the License"). 3 | // You may not use this file except in compliance with the License. 4 | 5 | package tests; 6 | 7 | import org.ibex.nestedvm.Runtime; 8 | 9 | class Env { 10 | public static void main(String[] args) throws Exception { 11 | int n = 0; 12 | while(n < args.length && args[n].indexOf("=") != -1) n++; 13 | 14 | if(n==args.length) { 15 | System.err.println("Usage: Env [name=value ...] classname [args ...]"); 16 | System.exit(1); 17 | } 18 | 19 | String[] env = new String[n]; 20 | String[] appArgs = new String[args.length-n-1]; 21 | for(int i=0;i 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #define FT_Check(expr) do { \ 8 | if((expr) != 0) { \ 9 | fprintf(stderr,#expr " failed\n"); \ 10 | exit(EXIT_FAILURE); \ 11 | } \ 12 | } while(0) 13 | 14 | #define BMP_WIDTH 800 15 | #define BMP_HEIGHT 600 16 | 17 | static char buf[BMP_WIDTH*BMP_HEIGHT]; 18 | 19 | int main(int argc, char **argv) { 20 | char *ttf; 21 | char *out; 22 | FT_Library library; 23 | FT_Face face; 24 | FT_GlyphSlot glyph; 25 | int num_glyphs; 26 | int c; 27 | int glyph_index; 28 | int loc_x; 29 | int loc_y; 30 | int glyph_width; 31 | int glyph_height; 32 | int i,j; 33 | int fd; 34 | char *p; 35 | int n,count; 36 | char *glyph_buf; 37 | int pixel_size; 38 | 39 | if(argc < 3) { 40 | fprintf(stderr,"Usage: %s ttf bmp\n",argv[0]); 41 | exit(1); 42 | } 43 | 44 | ttf = argv[1]; 45 | out = argv[2]; 46 | 47 | memset(buf,'\377',BMP_WIDTH*BMP_HEIGHT); 48 | 49 | FT_Check(FT_Init_FreeType(&library)); 50 | FT_Check(FT_New_Face(library,ttf,0,&face)); 51 | 52 | loc_y = loc_x = 0; 53 | for(pixel_size=8;pixel_size<48;pixel_size+=4) { 54 | FT_Check(FT_Set_Pixel_Sizes(face,0,pixel_size)); 55 | for(c=32;c<127;c++) { 56 | glyph_index = FT_Get_Char_Index(face,c); 57 | FT_Check(FT_Load_Glyph(face,glyph_index,FT_LOAD_DEFAULT)); 58 | FT_Check(FT_Render_Glyph(face->glyph, ft_render_mode_normal)); 59 | glyph = face->glyph; 60 | glyph_width = glyph->bitmap.width; 61 | glyph_height = glyph->bitmap.rows; 62 | glyph_buf = glyph->bitmap.buffer; 63 | if(loc_x + glyph_width + glyph->bitmap_left >= BMP_WIDTH) { 64 | loc_x = 0; 65 | loc_y += pixel_size; 66 | if(loc_y >= BMP_HEIGHT-pixel_size) goto done; 67 | } 68 | 69 | for(i=0;iglyph->advance.x/64; 73 | } 74 | } 75 | done: 76 | 77 | if((fd = open(out,O_CREAT|O_WRONLY,0644)) < 0) { 78 | perror("open"); 79 | exit(1); 80 | } 81 | p = buf; 82 | count = BMP_WIDTH*BMP_HEIGHT; 83 | 84 | while(count) { 85 | n = write(fd,p,count); 86 | if(n < 0) { 87 | perror("write"); 88 | exit(1); 89 | } 90 | count -=n; 91 | p += n; 92 | } 93 | close(fd); 94 | 95 | return 0; 96 | } 97 | -------------------------------------------------------------------------------- /src/tests/Fork.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int main() { 7 | fprintf(stderr,"In the main process (pid: %d), about to fork\n",getpid()); 8 | pid_t pid; 9 | int status; 10 | int i; 11 | 12 | pid = fork(); 13 | switch(pid) { 14 | case -1: perror("fork"); break; 15 | case 0: 16 | fprintf(stderr,"In the forked process (pid: %d), sleeping for 2 sec\n",getpid()); 17 | sleep(2); 18 | fprintf(stderr,"Child done sleeping... exiting\n"); 19 | _exit(0); 20 | break; 21 | default: 22 | fprintf(stderr,"In the main process (child is: %d) waiting for child\n",pid); 23 | if(waitpid(pid,&status,0) < 0) 24 | perror("waitpid"); 25 | else 26 | fprintf(stderr,"Child process exited (status: %d)\n",status); 27 | } 28 | 29 | pid = fork(); 30 | if(pid==0) { 31 | fprintf(stderr,"1st fork (pid: %d)\n",getpid()); 32 | if(fork()==0) { 33 | fprintf(stderr,"2nd fork (pid: %d).. sleeping\n",getpid()); 34 | sleep(5); 35 | fprintf(stderr,"2nd fork exiting\n"); 36 | _exit(0); 37 | } 38 | fprintf(stderr,"1st fork (pid: %d) exiting\n",getpid()); 39 | _exit(0); 40 | } else { 41 | waitpid(pid,NULL,0); 42 | fprintf(stderr,"1st fork terminated\n"); 43 | } 44 | fprintf(stderr,"Sleeping for a bit\n"); 45 | sleep(10); 46 | 47 | fprintf(stderr,"Next few pids should be sequential\n"); 48 | for(i=0;i<10;i++) { 49 | if(fork() == 0) { 50 | fprintf(stderr,"I am a child %d\n",getpid()); 51 | sleep(i%4 + 5); 52 | fprintf(stderr,"Child %d exiting\n",getpid()); 53 | _exit(0); 54 | } 55 | } 56 | for(i=0;i<10;i++) fprintf(stderr,"Waited on %d\n",waitpid(-1,NULL,0)); 57 | 58 | return 0; 59 | } 60 | -------------------------------------------------------------------------------- /src/tests/FreeTypeDemo.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2005 the Contributors, as shown in the revision logs. 2 | // Licensed under the Apache License 2.0 ("the License"). 3 | // You may not use this file except in compliance with the License. 4 | 5 | package tests; 6 | 7 | import org.ibex.nestedvm.Runtime; 8 | import org.ibex.nestedvm.Interpreter; 9 | 10 | import javax.swing.*; 11 | import java.awt.*; 12 | import java.awt.image.*; 13 | import java.awt.event.*; 14 | import java.io.*; 15 | 16 | public class FreeTypeDemo { 17 | private JFrame frame; 18 | private static final int OURWIDTH=640; 19 | private static final int OURHEIGHT=256; 20 | private static final int BASELINE=160; 21 | private byte[] render = new byte[OURWIDTH*OURHEIGHT]; 22 | private int size = 72; 23 | private StringBuffer sb = new StringBuffer(); 24 | private View view; 25 | private Image image; 26 | 27 | private Runnable renderThread; 28 | private String theText; 29 | private boolean renderNeeded; 30 | 31 | private String name; 32 | private Runtime rt; 33 | 34 | int renderAddr; 35 | int stringAddr; 36 | int stringSize; 37 | 38 | public static void main(String[] argv) throws Exception { 39 | new FreeTypeDemo(argv); 40 | } 41 | 42 | public FreeTypeDemo(String[] argv) throws Exception { 43 | if(argv.length >= 2 && argv[1].startsWith("int")) { 44 | name = "Interpreter"; 45 | rt = new Interpreter("build/FreeTypeDemoHelper.mips"); 46 | } else { 47 | rt = (Runtime) Class.forName("tests.FreeTypeDemoHelper").newInstance(); 48 | name = "Compiler"; 49 | } 50 | 51 | rt.start(new String[]{ "freetype.mips"}); 52 | if(rt.execute()) throw new Error("freetype.mips exited"); 53 | 54 | byte[] font = InputStreamToByteArray.convert(new FileInputStream(argv[0])); 55 | int fontAddr = rt.malloc(font.length); 56 | if(fontAddr == 0) throw new Error("malloc() failed"); 57 | rt.copyout(font,fontAddr,font.length); 58 | 59 | rt.setUserInfo(0,fontAddr); 60 | rt.setUserInfo(1,font.length); 61 | 62 | renderAddr = rt.malloc(OURWIDTH*OURHEIGHT); 63 | if(renderAddr == 0) throw new Error("malloc() failed"); 64 | 65 | if(rt.execute()) throw new Error("freetype.mips exited (" + rt.getUserInfo(1) +")"); 66 | 67 | createImage(); 68 | 69 | frame = new JFrame("FreeTypeDemo - " + name); 70 | frame.setSize(OURWIDTH,OURHEIGHT); 71 | view = new View(); 72 | frame.getContentPane().add(view,BorderLayout.CENTER); 73 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 74 | frame.show(); 75 | view.requestFocus(); 76 | renderThread = new Runnable() { 77 | public void run() { 78 | try { 79 | for(;;) { 80 | synchronized(this) { while(!renderNeeded) wait(); renderNeeded = false; } 81 | renderText(theText==null ? "" : theText); 82 | } 83 | } catch(Exception e) { throw new Error(e); } 84 | } 85 | }; 86 | new Thread(renderThread).start(); 87 | keyPress('\n'); 88 | } 89 | 90 | private static ColorModel cmodel = new DirectColorModel(8, 0xff,0xff,0xff); 91 | private void createImage() { 92 | for(int i=0;i 4 | #include 5 | #include FT_FREETYPE_H 6 | 7 | FT_Library library; /* handle to library */ 8 | FT_Face face; /* handle to face object */ 9 | 10 | #define FT_Check(expr,err) do { \ 11 | if((expr) != 0) { \ 12 | errprint(#expr " failed\n"); \ 13 | return err; \ 14 | } \ 15 | } while(0) 16 | 17 | #define max(a,b) ((a) > (b) ? (a) : (b)) 18 | #define min(a,b) ((a) < (b) ? (a) : (b)) 19 | 20 | static int errprint(const char *s) { 21 | int l = strlen(s); 22 | int n; 23 | while(l) { 24 | n = write(STDERR_FILENO,s,l); 25 | if(n < 0) return n; 26 | l -= n; 27 | s += n; 28 | } 29 | return 0; 30 | } 31 | 32 | void draw(FT_GlyphSlot glyph,int x, char *buf, int buf_width, int buf_height, int baseline) { 33 | int y = max(baseline - glyph->bitmap_top,0); 34 | int rows = glyph->bitmap.rows; 35 | int width = glyph->bitmap.width; 36 | int i,j; 37 | x = x + glyph->bitmap_left; 38 | if(x + width >= buf_width) return; 39 | if(y + rows >= buf_height) return; 40 | //if(buf == NULL) fprintf(stderr,"ABout to dereference %p\n",buf); 41 | for(i=0;ibitmap.buffer[i*width+j]; 44 | } 45 | 46 | /* Prevent --gc-sections from blowing this away */ 47 | int render(short *s, int size, char *buf, int buf_width, int buf_height, int baseline) __attribute__((section(".text"))); 48 | int render(short *s, int size, char *buf, int buf_width, int buf_height, int baseline) { 49 | int glyph_index; 50 | int x = 0; 51 | FT_Check(FT_Set_Pixel_Sizes(face,0,size),0); 52 | memset(buf,'\0',buf_width*buf_height); 53 | //fprintf(stderr,"Rendering %d pt %c... at %p (%dx%d)\n",size,*s,buf,buf_width,buf_height); 54 | while(*s) { 55 | glyph_index = FT_Get_Char_Index(face,*s); 56 | FT_Check(FT_Load_Glyph(face,glyph_index,FT_LOAD_DEFAULT),0); 57 | FT_Check(FT_Render_Glyph(face->glyph,FT_RENDER_MODE_NORMAL/*256color antialiased*/),0); 58 | draw(face->glyph,x,buf,buf_width,buf_height,baseline); 59 | x += face->glyph->advance.x/64; 60 | s++; 61 | } 62 | return 1; 63 | } 64 | 65 | char * user_info[2]; 66 | extern void _pause(); 67 | 68 | int main(int argc,char** argv) { 69 | char *fontdata; 70 | int fontsize; 71 | 72 | _pause(); 73 | 74 | fontdata = user_info[0]; 75 | fontsize = (int)user_info[1]; 76 | 77 | //fprintf(stderr,"Initializng freetype with a %d byte font at %p\n", fontsize, fontdata); 78 | 79 | FT_Check(FT_Init_FreeType(&library),EXIT_FAILURE); 80 | FT_Check(FT_New_Memory_Face(library, fontdata,fontsize, 0, &face),EXIT_FAILURE); 81 | 82 | errprint("Freetype initialized\n"); 83 | _pause(); 84 | errprint("Unpaused\n"); 85 | 86 | /* not reached */ 87 | return EXIT_FAILURE; 88 | } 89 | -------------------------------------------------------------------------------- /src/tests/GenericSpeedTest.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2005 the Contributors, as shown in the revision logs. 2 | // Licensed under the Apache License 2.0 ("the License"). 3 | // You may not use this file except in compliance with the License. 4 | 5 | package tests; 6 | 7 | import java.lang.reflect.*; 8 | 9 | class GenericSpeedTest { 10 | private static long start,end; 11 | private static long now() { return System.currentTimeMillis(); } 12 | private static void start() { start = now(); } 13 | private static void end() { end = now(); } 14 | private static float diff() { return ((float)(end-start))/1000; } 15 | 16 | public static void main(String[] args) throws Exception { 17 | float d; 18 | 19 | if(args.length < 2) { System.err.println("Usage: GenericSpeedTest runs classname args"); System.exit(1); } 20 | int runs = Integer.parseInt(args[0]); 21 | String className = args[1]; 22 | if(runs < 5) throw new Error("Runs must be >= 5"); 23 | String[] appArgs = new String[args.length-2]; 24 | for(int i=2;i 2 | 3 | int main() { 4 | puts("Hello, World"); 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /src/tests/MSPack.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2005 the Contributors, as shown in the revision logs. 2 | // Licensed under the Apache License 2.0 ("the License"). 3 | // You may not use this file except in compliance with the License. 4 | 5 | package tests; 6 | 7 | import org.ibex.nestedvm.Runtime; 8 | import java.io.*; 9 | 10 | public class MSPack { 11 | private String[] fileNames; 12 | private int[] lengths; 13 | private byte[][] data; 14 | 15 | public static class MSPackException extends IOException { public MSPackException(String s) { super(s); } } 16 | 17 | public MSPack(InputStream cabIS) throws IOException { 18 | byte[] cab = InputStreamToByteArray.convert(cabIS); 19 | try { 20 | //Interpreter vm = new Interpreter("mspack.mips"); 21 | Runtime vm; 22 | try { 23 | vm = (Runtime) Class.forName("tests.MSPackHelper").newInstance(); 24 | } catch(Exception e) { 25 | throw new MSPackException("couldn't instansiate MSPackHelper"); 26 | } 27 | int cabAddr = vm.sbrk(cab.length); 28 | if(cabAddr < 0) throw new MSPackException("sbrk failed"); 29 | 30 | vm.copyout(cab,cabAddr,cab.length); 31 | 32 | vm.setUserInfo(0,cabAddr); 33 | vm.setUserInfo(1,cab.length); 34 | 35 | int status = vm.run(new String[]{ "mspack.mips"} ); 36 | if(status != 0) throw new MSPackException("mspack.mips failed (" + status + ")"); 37 | 38 | /*static struct { 39 | char *filename; 40 | char *data; 41 | int length; 42 | } output_table[MAX_MEMBERS+1]; */ 43 | 44 | int filesTable = vm.getUserInfo(2); 45 | int count=0; 46 | while(vm.memRead(filesTable+count*12) != 0) count++; 47 | 48 | fileNames = new String[count]; 49 | data = new byte[count][]; 50 | lengths = new int[count]; 51 | 52 | for(int i=0,addr=filesTable;i 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "mspack.h" 8 | 9 | int main(int argc, char **argv) { 10 | struct mscab_decompressor *decomp; 11 | struct mscabd_cabinet *cab; 12 | struct mscabd_file *file; 13 | int i; 14 | 15 | if(argc < 2) { 16 | fprintf(stderr,"Usage: %s cab\n",argv[0]); 17 | exit(1); 18 | } 19 | 20 | 21 | decomp = mspack_create_cab_decompressor(NULL); 22 | if(!decomp) exit(1); 23 | 24 | for(i=1;isearch(decomp,argv[i]); 26 | if(!cab) exit(2); 27 | 28 | for(file = cab->files;file;file=file->next) 29 | decomp->extract(decomp,file,file->filename); 30 | 31 | decomp->close(decomp,cab); 32 | } 33 | mspack_destroy_cab_decompressor(decomp); 34 | 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /src/tests/MSPackHelper.c: -------------------------------------------------------------------------------- 1 | /* 2 | UserInfo: 3 | On start: 4 | 0: Addr of CAB/EXE 5 | 1: Length of CAB/EXE 6 | On Edit: 7 | 2: Addr of output_table array 8 | 9 | Exit codes: 10 | 0: Success 11 | 1: Internal Error 12 | 2: Invalid CAB 13 | */ 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include "mspack.h" 22 | 23 | #define MAX(a,b) (((a)>(b))?(a):(b)) 24 | #define MIN(a,b) (((a)<(b))?(a):(b)) 25 | #define MAX_MEMBERS 64 26 | 27 | char *xstrdup(const char *s) { 28 | char *ret = strdup(s); 29 | if(ret == NULL) exit(1); 30 | return ret; 31 | } 32 | 33 | typedef struct { 34 | char *addr; 35 | int pos; 36 | int size; 37 | int length; 38 | int writable; 39 | } mem_buf_t; 40 | 41 | static mem_buf_t *cab_mem_buf = NULL; 42 | 43 | static void mem_buf_grow(mem_buf_t *buf,size_t newsize) { 44 | size_t new_len; 45 | char *p; 46 | if(buf->length < 0) exit(1); 47 | if(newsize <= buf->length) return; 48 | new_len = MAX(buf->length ? buf->length*2 : 65536,newsize); 49 | p = realloc(buf->addr,new_len); 50 | if(p == NULL) exit(1); 51 | buf->addr = p; 52 | buf->length = new_len; 53 | } 54 | 55 | static struct { 56 | char *filename; 57 | mem_buf_t buf; 58 | } write_buf_table[MAX_MEMBERS]; 59 | 60 | static struct { 61 | char *filename; 62 | char *data; 63 | int length; 64 | } output_table[MAX_MEMBERS+1]; 65 | 66 | static struct mspack_file *my_open(struct mspack_system *sys, char *filename, int mode) { 67 | mem_buf_t *buf = NULL; 68 | int i; 69 | if(strcmp(filename,"/dev/cab")==0) { 70 | if(mode != MSPACK_SYS_OPEN_READ) return NULL; 71 | buf = cab_mem_buf; 72 | } else { 73 | if(mode != MSPACK_SYS_OPEN_WRITE) return NULL; 74 | 75 | for(i=0;iwritable = 1; 81 | break; 82 | } 83 | } 84 | } 85 | 86 | return (struct mspack_file *) buf; 87 | } 88 | 89 | static void my_close(struct mspack_file *buf_) { 90 | mem_buf_t *buf = (mem_buf_t*) buf_; 91 | /* NO OP */ 92 | } 93 | 94 | static int my_read(struct mspack_file *buf_, void *out, int count) { 95 | mem_buf_t *buf = (mem_buf_t*) buf_; 96 | count = MIN(buf->size - buf->pos, count); 97 | memcpy(out,buf->addr + buf->pos,count); 98 | buf->pos += count; 99 | return count; 100 | } 101 | 102 | static int my_write(struct mspack_file *buf_, void *in, int count) { 103 | mem_buf_t *buf = (mem_buf_t*) buf_; 104 | if(!buf->writable) return -1; 105 | if(buf->length < buf->pos + count) mem_buf_grow(buf,buf->pos + count); 106 | memcpy(buf->addr+buf->pos,in,count); 107 | buf->pos += count; 108 | buf->size = MAX(buf->size,buf->pos); 109 | return count; 110 | } 111 | 112 | static int my_seek(struct mspack_file *buf_, off_t off, int mode) { 113 | mem_buf_t *buf = (mem_buf_t*) buf_; 114 | int newpos; 115 | switch(mode) { 116 | case MSPACK_SYS_SEEK_START: newpos = off; break; 117 | case MSPACK_SYS_SEEK_CUR: newpos = buf->pos + off; break; 118 | case MSPACK_SYS_SEEK_END: newpos = buf->size - off; break; 119 | default: return -1; 120 | } 121 | if(newpos < 0) return -1; 122 | if(newpos > buf->size) { 123 | if(!buf->writable) return -1; 124 | if(newpos > buf->length) 125 | mem_buf_grow(buf,newpos); 126 | } 127 | buf->pos = newpos; 128 | return 0; 129 | } 130 | 131 | static off_t my_tell(struct mspack_file *buf_) { 132 | mem_buf_t *buf = (mem_buf_t*) buf_; 133 | return buf ? buf->pos : 0; 134 | } 135 | 136 | static void my_message(struct mspack_file *file, char *format, ...) { 137 | va_list ap; 138 | va_start(ap, format); 139 | vfprintf(stderr, format, ap); 140 | va_end(ap); 141 | fputc((int) '\n', stderr); 142 | fflush(stderr); 143 | } 144 | 145 | static void *my_alloc(struct mspack_system *sys, size_t size) { return malloc(size); } 146 | static void my_free(void *p) { free(p); } 147 | static void my_copy(void *src, void *dest, size_t bytes) { memcpy(dest, src, bytes); } 148 | 149 | static struct mspack_system my_system = { 150 | &my_open, 151 | &my_close, 152 | &my_read, 153 | &my_write, 154 | &my_seek, 155 | &my_tell, 156 | &my_message, 157 | &my_alloc, 158 | &my_free, 159 | &my_copy, 160 | NULL 161 | }; 162 | 163 | char *user_info[4]; 164 | 165 | int main(int argc, char **argv) { 166 | struct mscab_decompressor *decomp; 167 | struct mscabd_cabinet *cab; 168 | struct mscabd_file *file; 169 | mem_buf_t mem_buf; 170 | size_t size = (size_t)user_info[1]; 171 | int i; 172 | 173 | mem_buf.addr = user_info[0]; 174 | mem_buf.pos = mem_buf.writable = 0; 175 | mem_buf.length = -1; 176 | mem_buf.size = size; 177 | 178 | cab_mem_buf = &mem_buf; 179 | 180 | decomp = mspack_create_cab_decompressor(&my_system); 181 | if(!decomp) exit(1); 182 | 183 | cab = decomp->search(decomp,"/dev/cab"); 184 | if(!cab) exit(2); 185 | 186 | for(file = cab->files;file;file=file->next) 187 | decomp->extract(decomp,file,file->filename); 188 | 189 | decomp->close(decomp,cab); 190 | mspack_destroy_cab_decompressor(decomp); 191 | 192 | printf("Success!\n"); 193 | 194 | for(i=0;i 2 | 3 | double d = -1.23; 4 | 5 | int _start() { 6 | int n; 7 | d = fabs(d); 8 | n = (int)(d*100); 9 | return n;; 10 | } 11 | -------------------------------------------------------------------------------- /src/tests/SpeedTest.java: -------------------------------------------------------------------------------- 1 | // Copyright 2000-2005 the Contributors, as shown in the revision logs. 2 | // Licensed under the Apache License 2.0 ("the License"). 3 | // You may not use this file except in compliance with the License. 4 | 5 | package tests; 6 | 7 | import org.ibex.nestedvm.Runtime; 8 | 9 | //import java.io.*; 10 | //import java.util.*; 11 | 12 | class SpeedTest { 13 | private static long start,end; 14 | private static long now() { return System.currentTimeMillis(); } 15 | private static void start() { start = now(); } 16 | private static void end() { end = now(); } 17 | private static float diff() { return ((float)(end-start))/1000; } 18 | 19 | /*private static InputStream is = new InputStream() { 20 | int left = 100*1024*1024; 21 | int c = 0; 22 | public int read() { if(left==0) return -1; left--; return (c++)&0xff; } 23 | public int read(byte[] buf, int pos,int len) { 24 | len = Math.min(left,len); 25 | Arrays.fill(buf,pos,len,(byte)c++); 26 | left -= len; 27 | return len; 28 | } 29 | public void close() { left = 100*1024*1024; } 30 | }; 31 | 32 | private static OutputStream os = new OutputStream() { 33 | public void write(int c) { } 34 | public void write(byte[] buf, int pos, int len) { } 35 | };*/ 36 | 37 | public static void main(String[] args) throws Exception { 38 | float d; 39 | 40 | if(args.length < 2) { System.err.println("Usage: SpeedTest {classname|mips binary} number_of_runs args"); System.exit(1); } 41 | String className = args[0]; 42 | int runs = Integer.parseInt(args[1]); 43 | if(runs < 5) throw new Error("Runs must be >= 5"); 44 | String[] appArgs = new String[args.length-1]; 45 | appArgs[0] = className; 46 | for(int i=2;i 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | char *user_info[1024]; 17 | 18 | extern void _pause(); 19 | extern int _call_java(int a, int b, int c, int d); 20 | 21 | void suckram(); 22 | 23 | int main(int argc, char **argv) { 24 | int i,n,fd; 25 | time_t now; 26 | DIR *dir; 27 | struct dirent *dent; 28 | char buf[1024]; 29 | unsigned char ubuf[1024]; 30 | unsigned short sbuf[1024]; 31 | char *s; 32 | 33 | printf("Entered main()\n"); 34 | 35 | if(argc > 1 && strcmp(argv[1],"calltest")==0) { 36 | printf("pausing for call test\n"); 37 | _pause(); 38 | printf("unpaused from call test\n"); 39 | 40 | for(i=1;i<=3;i++) { 41 | char *s = (char*)_call_java(i,0,0,0); 42 | printf("_call_java(%d,0,0,0) = \"%s\" (%d chars)\n",i,s,strlen(s)); 43 | free(s); 44 | } 45 | fd = _call_java(4,0,0,0); 46 | if(fd != -1) { 47 | FILE *fp; 48 | fprintf(stderr,"fd: %i\n",fd); 49 | fp = fdopen(fd,"w"); 50 | if(fp != NULL) { 51 | fprintf(fp,"It worked! fp is %p - Hello, Java!\n",fp); 52 | fclose(fp); 53 | } else { 54 | fprintf(stderr,"fdopen failed\n"); 55 | close(fd); 56 | } 57 | } else { 58 | fprintf(stderr,"fd == -1\n"); 59 | } 60 | 61 | printf("In main() in MIPS\n"); 62 | _call_java(5,0,0,0); 63 | printf("Back in main() in MIPS\n"); 64 | } else if(argc > 2 && strcmp(argv[1],"fdtest")==0) { 65 | printf("opening %s\n",argv[2]); 66 | fd = open(argv[2],O_RDONLY); 67 | if(fd < 0) { perror("open"); exit(1); } 68 | 69 | printf("reading up to 64 bytes\n"); 70 | n = read(fd,buf,64); 71 | if(n < 0) {perror("read"); exit(1); } 72 | printf("read %d bytes\n",n); 73 | for(i=0;i 1 && strcmp(argv[1],"fptest")==0) { 93 | double d = 0.0; 94 | while(d != 10.0) { 95 | printf("d: %f\n",d); 96 | d += 2.5; 97 | } 98 | } else if(argc > 1 && strcmp(argv[1],"nullderef")==0) { 99 | volatile int *mem = 0; 100 | *mem = 1; 101 | } else if(argc > 2 && strcmp(argv[1],"crashme") == 0) { 102 | volatile int *mem = (int*) atoi(argv[2]); 103 | *mem = 1; 104 | } else { 105 | printf("%d\n", 0xffffff); 106 | printf("%u\n", 0xffffffU); 107 | printf("%li\n",0xffffffL); 108 | printf("%lu\n",0xffffffUL); 109 | 110 | 111 | for(i=0;id_name,&statbuf); 144 | printf("\t[%s] %lu %i %i\n",dent->d_name,dent->d_ino,statbuf.st_ino,statbuf.st_dev); 145 | } 146 | if(errno != 0) { fprintf(stderr,"readdir errno: %d\n",errno); perror("readdir"); } 147 | closedir(dir); 148 | } else { 149 | perror("opendir"); 150 | } 151 | 152 | 153 | #if 0 154 | printf("Sleeping...\n"); 155 | sleep(1); 156 | printf("Done\n"); 157 | #endif 158 | 159 | fd = open("test.txt",O_RDONLY); 160 | if(fd != -1) { 161 | printf("Opened test.txt\n"); 162 | n = read(fd,sbuf,sizeof(sbuf)); 163 | printf("n: %d\n",n); 164 | if(n < 0) perror("read"); 165 | ubuf[n] = '\0'; 166 | printf("buf: %s\n",buf); 167 | for(i=0;i 0 202 | ? -1 : ((HOST_WIDE_INT) 1 << (precision - 1)) - 1), 203 | (precision - HOST_BITS_PER_WIDE_INT - 1 > 0 204 | ? (((HOST_WIDE_INT) 1 205 | << (precision - HOST_BITS_PER_WIDE_INT - 1))) - 1 206 | : 0); 207 | 208 | printf("%llX\n",l); 209 | } 210 | 211 | { 212 | double d = -2.34; 213 | d = fabs(d); 214 | printf("fabs(-2.24) = %g\n",d); 215 | } 216 | 217 | 218 | //printf("cwd: %s\n",getcwd(NULL,0)); 219 | //printf("isatty(0): %d\n",isatty(0)); 220 | //printf("exiting\n"); 221 | return 0; 222 | } 223 | 224 | long long zero = 0; 225 | int izero = 0; 226 | long long rl(long long n) { return n + zero; } 227 | int ri(int n) { return n + izero; } 228 | 229 | void suckram() { 230 | int total = 0; 231 | fprintf(stderr,"Eating up all available memory\n"); 232 | while(malloc(1024*1024) != NULL) total ++; 233 | fprintf(stderr,"Ate up %d megs\n",total); 234 | } 235 | 236 | __attribute__((constructor)) static void my_ctor() { printf("Constructor!\n"); } 237 | __attribute__((destructor)) static void my_dtor() { printf("Destructor!\n"); } 238 | 239 | int callme(int a1,int a2, int a3, int a4, int a5, int a6) __attribute__((section(".text"))); 240 | int callme(int a1,int a2, int a3, int a4, int a5, int a6) { 241 | printf("You said: %d %d %d %d %d %d\n",a1,a2,a3,a4,a5,a6); 242 | return a1+a2+a3+a4+a5+a6; 243 | } 244 | 245 | void echo(const char *string, int count) __attribute__((section(".text"))); 246 | void echo(const char *string, int count) { 247 | int i; 248 | for(i=0;i&2 15 | exit 1 16 | fi 17 | 18 | INT="$2" 19 | 20 | cd tmp 21 | 22 | if [ ! -e .skipmspack ]; then 23 | 24 | mkdir -p mspack 25 | cd mspack 26 | rm -f *.TTT *.inf FONTINST.EXE *.DLL *.TXT; 27 | for f in \ 28 | andale32.exe arial32.exe arialb32.exe comic32.exe courie32.exe georgi32.exe \ 29 | impact32.exe times32.exe trebuc32.exe verdan32.exe webdin32.exe; \ 30 | do 31 | [ -e "$f" ] || wget "http://beebo.org/corefonts/$f" || rm -f "$f" 32 | [ -e "$f" ] || exit 1 33 | done 34 | 35 | echo "Extracting MS Core Fonts using MSPackBench..." 36 | $JAVA tests.MSPackBench *32.exe 37 | 38 | cat < md5.1" 162 | md5sum mspack/*.ttf > md5.2 163 | cmp md5.1 md5.2 && echo "The BusyBox md5sum command and sh work properly!" 164 | fi 165 | 166 | cat < ldscripts/${EMULATION_NAME}.xa 30 | fi 31 | 32 | - case " $EMULATION_LIBPATH " in 33 | - *" ${EMULATION_NAME} "*) COMPILE_IN=true;; 34 | - esac 35 | - 36 | # PR ld/5652: 37 | # Determine if the shell has support for the variable BASH_LINENO. 38 | # When it is the case, it is only available inside functions. 39 | has_lineno() 40 | --- 419,426 ---- 41 | -------------------------------------------------------------------------------- /upstream/patches/binutils-2.25.patch: -------------------------------------------------------------------------------- 1 | diff -aur ../binutils-2.25-original/bfd/config.bfd ./bfd/config.bfd 2 | --- ../binutils-2.25-original/bfd/config.bfd 2014-10-14 03:32:02.000000000 -0400 3 | +++ ./bfd/config.bfd 2017-01-29 14:34:29.605174255 -0500 4 | @@ -1041,6 +1041,10 @@ 5 | targ_defvec=mips_elf32_le_vec 6 | targ_selvecs="mips_elf32_be_vec mips_elf64_be_vec mips_elf64_le_vec" 7 | ;; 8 | + mips*-unknown-elf*) 9 | + targ_defvec=mips_elf32_be_vec 10 | + targ_selvecs="mips_elf32_le_vec" 11 | + ;; 12 | mips*-*-elf* | mips*-*-rtems* | mips*-*-vxworks | mips*-*-windiss) 13 | targ_defvec=mips_elf32_be_vec 14 | targ_selvecs="mips_elf32_le_vec mips_elf64_be_vec mips_elf64_le_vec" 15 | Only in .: binutils-2.27.patch 16 | diff -aur ../binutils-2.25-original/ld/configure.tgt ./ld/configure.tgt 17 | --- ../binutils-2.25-original/ld/configure.tgt 2014-10-14 03:32:04.000000000 -0400 18 | +++ ./ld/configure.tgt 2017-01-29 14:34:29.685175064 -0500 19 | @@ -469,6 +469,7 @@ 20 | targ_extra_emuls="elf32lr5900n32" 21 | targ_extra_libpath=$targ_extra_emuls ;; 22 | mips*el-*-elf*) targ_emul=elf32elmip ;; 23 | +mips*-unknown-elf*) targ_emul=elf32ebmip ;; 24 | mips*-*-elf*) targ_emul=elf32ebmip ;; 25 | mips*-*-rtems*) targ_emul=elf32ebmip ;; 26 | mips*el-*-vxworks*) targ_emul=elf32elmipvxworks 27 | Only in ./ld: configure.tgt.orig 28 | diff -aur ../binutils-2.25-original/ld/genscripts.sh ./ld/genscripts.sh 29 | --- ../binutils-2.25-original/ld/genscripts.sh 2014-10-14 03:32:04.000000000 -0400 30 | +++ ./ld/genscripts.sh 2017-01-29 14:34:29.685175064 -0500 31 | @@ -407,9 +407,10 @@ 32 | ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xa 33 | fi 34 | 35 | -case "$COMPILE_IN: $EMULATION_LIBPATH " in 36 | - :*" ${EMULATION_NAME} "*) COMPILE_IN=yes;; 37 | -esac 38 | +# case "$COMPILE_IN: $EMULATION_LIBPATH " in 39 | +# :*" ${EMULATION_NAME} "*) COMPILE_IN=yes;; 40 | +#esac 41 | +COMPILE_IN= 42 | 43 | # PR ld/5652: 44 | # Determine if the shell has support for the variable BASH_LINENO. 45 | -------------------------------------------------------------------------------- /upstream/patches/binutils-2.26.patch: -------------------------------------------------------------------------------- 1 | diff -aur ../binutils-2.26-original/bfd/config.bfd ./bfd/config.bfd 2 | --- ../binutils-2.26-original/bfd/config.bfd 2015-11-13 03:27:40.000000000 -0500 3 | +++ ./bfd/config.bfd 2017-01-29 15:14:12.397347153 -0500 4 | @@ -1066,6 +1066,10 @@ 5 | targ_defvec=mips_elf32_le_vec 6 | targ_selvecs="mips_elf32_be_vec mips_elf64_be_vec mips_elf64_le_vec" 7 | ;; 8 | + mips*-unknown-elf*) 9 | + targ_defvec=mips_elf32_be_vec 10 | + targ_selvecs="mips_elf32_le_vec" 11 | + ;; 12 | mips*-*-elf* | mips*-*-rtems* | mips*-*-vxworks | mips*-*-windiss) 13 | targ_defvec=mips_elf32_be_vec 14 | targ_selvecs="mips_elf32_le_vec mips_elf64_be_vec mips_elf64_le_vec" 15 | diff -aur ../binutils-2.26-original/ld/configure.tgt ./ld/configure.tgt 16 | --- ../binutils-2.26-original/ld/configure.tgt 2015-11-13 03:27:42.000000000 -0500 17 | +++ ./ld/configure.tgt 2017-01-29 15:11:26.647679654 -0500 18 | @@ -502,6 +502,7 @@ 19 | targ_extra_emuls="elf32lr5900n32" 20 | targ_extra_libpath=$targ_extra_emuls ;; 21 | mips*el-*-elf*) targ_emul=elf32elmip ;; 22 | +mips*-unknown-elf*) targ_emul=elf32ebmip ;; 23 | mips*-*-elf*) targ_emul=elf32ebmip ;; 24 | mips*-*-rtems*) targ_emul=elf32ebmip ;; 25 | mips*el-*-vxworks*) targ_emul=elf32elmipvxworks 26 | Only in ./ld: configure.tgt.orig 27 | diff -aur ../binutils-2.26-original/ld/genscripts.sh ./ld/genscripts.sh 28 | --- ../binutils-2.26-original/ld/genscripts.sh 2015-11-13 03:27:42.000000000 -0500 29 | +++ ./ld/genscripts.sh 2017-01-29 15:11:26.647679654 -0500 30 | @@ -407,9 +407,10 @@ 31 | ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xa 32 | fi 33 | 34 | -case "$COMPILE_IN: $EMULATION_LIBPATH " in 35 | - :*" ${EMULATION_NAME} "*) COMPILE_IN=yes;; 36 | -esac 37 | +# case "$COMPILE_IN: $EMULATION_LIBPATH " in 38 | +# :*" ${EMULATION_NAME} "*) COMPILE_IN=yes;; 39 | +#esac 40 | +COMPILE_IN= 41 | 42 | # PR ld/5652: 43 | # Determine if the shell has support for the variable BASH_LINENO. 44 | -------------------------------------------------------------------------------- /upstream/patches/binutils-2.27.patch: -------------------------------------------------------------------------------- 1 | diff -Naur ../binutils-2.27-original/bfd/config.bfd ./bfd/config.bfd 2 | --- ../binutils-2.27-original/bfd/config.bfd 2016-08-03 03:36:50.000000000 -0400 3 | +++ ./bfd/config.bfd 2017-01-29 02:50:48.862957935 -0500 4 | @@ -1084,6 +1084,10 @@ 5 | targ_defvec=mips_elf32_le_vec 6 | targ_selvecs="mips_elf32_be_vec mips_elf64_be_vec mips_elf64_le_vec" 7 | ;; 8 | + mips*-unknown-elf*) 9 | + targ_defvec=mips_elf32_be_vec 10 | + targ_selvecs="mips_elf32_le_vec" 11 | + ;; 12 | mips*-*-elf* | mips*-*-rtems* | mips*-*-windiss | mips*-*-none) 13 | targ_defvec=mips_elf32_be_vec 14 | targ_selvecs="mips_elf32_le_vec mips_elf64_be_vec mips_elf64_le_vec" 15 | diff -Naur ../binutils-2.27-original/binutils-2.27.patch ./binutils-2.27.patch 16 | --- ../binutils-2.27-original/binutils-2.27.patch 1969-12-31 19:00:00.000000000 -0500 17 | +++ ./binutils-2.27.patch 2017-01-29 02:51:04.479128972 -0500 18 | @@ -0,0 +1,14 @@ 19 | +diff -Naur ../binutils-2.27-original/bfd/config.bfd ./bfd/config.bfd 20 | +--- ../binutils-2.27-original/bfd/config.bfd 2016-08-03 03:36:50.000000000 -0400 21 | ++++ ./bfd/config.bfd 2017-01-29 02:50:48.862957935 -0500 22 | +@@ -1084,6 +1084,10 @@ 23 | + targ_defvec=mips_elf32_le_vec 24 | + targ_selvecs="mips_elf32_be_vec mips_elf64_be_vec mips_elf64_le_vec" 25 | + ;; 26 | ++ mips*-unknown-elf*) 27 | ++ targ_defvec=mips_elf32_be_vec 28 | ++ targ_selvecs="mips_elf32_le_vec" 29 | ++ ;; 30 | + mips*-*-elf* | mips*-*-rtems* | mips*-*-windiss | mips*-*-none) 31 | + targ_defvec=mips_elf32_be_vec 32 | + targ_selvecs="mips_elf32_le_vec mips_elf64_be_vec mips_elf64_le_vec" 33 | diff -Naur ../binutils-2.27-original/ld/configure.tgt ./ld/configure.tgt 34 | --- ../binutils-2.27-original/ld/configure.tgt 2016-08-03 03:36:54.000000000 -0400 35 | +++ ./ld/configure.tgt 2017-01-29 02:47:05.404507821 -0500 36 | @@ -506,6 +506,7 @@ 37 | targ_extra_emuls="elf32lr5900n32" 38 | targ_extra_libpath=$targ_extra_emuls ;; 39 | mips*el-*-elf*) targ_emul=elf32elmip ;; 40 | +mips*-unknown-elf*) targ_emul=elf32ebmip ;; 41 | mips*-*-elf*) targ_emul=elf32ebmip ;; 42 | mips*-*-rtems*) targ_emul=elf32ebmip ;; 43 | mips*el-*-vxworks*) targ_emul=elf32elmipvxworks 44 | diff -Naur ../binutils-2.27-original/ld/genscripts.sh ./ld/genscripts.sh 45 | --- ../binutils-2.27-original/ld/genscripts.sh 2016-08-03 03:36:54.000000000 -0400 46 | +++ ./ld/genscripts.sh 2017-01-29 01:45:47.678359102 -0500 47 | @@ -407,9 +407,10 @@ 48 | ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xa 49 | fi 50 | 51 | -case "$COMPILE_IN: $EMULATION_LIBPATH " in 52 | - :*" ${EMULATION_NAME} "*) COMPILE_IN=yes;; 53 | -esac 54 | +# case "$COMPILE_IN: $EMULATION_LIBPATH " in 55 | +# :*" ${EMULATION_NAME} "*) COMPILE_IN=yes;; 56 | +#esac 57 | +COMPILE_IN= 58 | 59 | # PR ld/5652: 60 | # Determine if the shell has support for the variable BASH_LINENO. 61 | -------------------------------------------------------------------------------- /upstream/patches/binutils-no64.patch: -------------------------------------------------------------------------------- 1 | diff -ru ../binutils-2.14/bfd/config.bfd ./bfd/config.bfd 2 | --- ../binutils-2.14/bfd/config.bfd Mon Jun 2 16:35:20 2003 3 | +++ ./bfd/config.bfd Mon Sep 1 01:06:32 2003 4 | @@ -777,6 +777,10 @@ 5 | targ_defvec=bfd_elf32_littlemips_vec 6 | targ_selvecs="bfd_elf32_bigmips_vec bfd_elf64_bigmips_vec bfd_elf64_littlemips_vec" 7 | ;; 8 | + mips*-unknown-elf*) 9 | + targ_defvec=bfd_elf32_bigmips_vec 10 | + targ_selvecs=bfd_elf32_littlemips_vec 11 | + ;; 12 | mips*-*-elf* | mips*-*-rtems* | mips*-*-vxworks*) 13 | targ_defvec=bfd_elf32_bigmips_vec 14 | targ_selvecs="bfd_elf32_littlemips_vec bfd_elf64_bigmips_vec bfd_elf64_littlemips_vec" 15 | Only in ./bfd: config.bfd.old 16 | Only in ./bfd: config.bfd~ 17 | diff -ru ../binutils-2.14/ld/configure.tgt ./ld/configure.tgt 18 | --- ../binutils-2.14/ld/configure.tgt Thu Jun 12 10:25:52 2003 19 | +++ ./ld/configure.tgt Mon Sep 1 01:07:42 2003 20 | @@ -405,6 +405,7 @@ 21 | mips*vr5000el-*-elf*) targ_emul=elf32l4300 ;; 22 | mips*vr5000-*-elf*) targ_emul=elf32b4300 ;; 23 | mips*el-*-elf*) targ_emul=elf32elmip ;; 24 | +mips*-unknown-elf*) targ_emul=elf32ebmip ;; 25 | mips*-*-elf*) targ_emul=elf32ebmip ;; 26 | mips*el-*-rtems*) targ_emul=elf32elmip ;; 27 | mips*-*-rtems*) targ_emul=elf32ebmip ;; 28 | Only in ./ld: configure.tgt.old 29 | Only in ./ld: configure.tgt~ 30 | -------------------------------------------------------------------------------- /upstream/patches/binutils-nocompilein.patch: -------------------------------------------------------------------------------- 1 | --- ld/genscripts.sh~ 2004-05-20 20:51:07.000000000 -0400 2 | +++ ld/genscripts.sh 2004-05-20 20:51:07.000000000 -0400 3 | @@ -229,9 +229,5 @@ 4 | fi 5 | fi 6 | 7 | -case " $EMULATION_LIBPATH " in 8 | - *" ${EMULATION_NAME} "*) COMPILE_IN=true;; 9 | -esac 10 | - 11 | # Generate e${EMULATION_NAME}.c. 12 | . ${srcdir}/emultempl/${TEMPLATE_NAME-generic}.em 13 | -------------------------------------------------------------------------------- /upstream/patches/binutils.patch: -------------------------------------------------------------------------------- 1 | --- bfd/config.bfd~ 2013-11-04 09:33:37.000000000 -0600 2 | +++ bfd/config.bfd 2014-09-19 22:37:33.244376936 -0500 3 | @@ -1032,6 +1032,10 @@ 4 | targ_defvec=bfd_elf32_littlemips_vec 5 | targ_selvecs="bfd_elf32_bigmips_vec bfd_elf64_bigmips_vec bfd_elf64_littlemips_vec" 6 | ;; 7 | + mips*-unknown-elf*) 8 | + targ_defvec=bfd_elf32_bigmips_vec 9 | + targ_selvecs=bfd_elf32_littlemips_vec 10 | + ;; 11 | mips*-*-elf* | mips*-*-rtems* | mips*-*-vxworks | mips*-*-windiss) 12 | targ_defvec=bfd_elf32_bigmips_vec 13 | targ_selvecs="bfd_elf32_littlemips_vec bfd_elf64_bigmips_vec bfd_elf64_littlemips_vec" 14 | --- ld/configure.tgt~ 2013-11-26 05:37:33.000000000 -0600 15 | +++ ld/configure.tgt 2014-09-19 22:40:46.857337004 -0500 16 | @@ -464,6 +464,7 @@ 17 | targ_extra_emuls="elf32lr5900n32" 18 | targ_extra_libpath=$targ_extra_emuls ;; 19 | mips*el-*-elf*) targ_emul=elf32elmip ;; 20 | +mips*-unknown-elf*) targ_emul=elf32ebmip ;; 21 | mips*-*-elf*) targ_emul=elf32ebmip ;; 22 | mips*-*-rtems*) targ_emul=elf32ebmip ;; 23 | mips*el-*-vxworks*) targ_emul=elf32elmipvxworks 24 | *** ld/genscripts.sh~ 2013-11-08 04:13:48.000000000 -0600 25 | --- ld/genscripts.sh 2014-09-19 22:42:49.401944653 -0500 26 | *************** 27 | *** 419,430 **** 28 | . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc 29 | ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xa 30 | fi 31 | 32 | - case " $EMULATION_LIBPATH " in 33 | - *" ${EMULATION_NAME} "*) COMPILE_IN=true;; 34 | - esac 35 | - 36 | # PR ld/5652: 37 | # Determine if the shell has support for the variable BASH_LINENO. 38 | # When it is the case, it is only available inside functions. 39 | has_lineno() 40 | --- 419,426 ---- 41 | -------------------------------------------------------------------------------- /upstream/patches/freetype.patch: -------------------------------------------------------------------------------- 1 | --- include/freetype/config/ftmodule.h Thu Jul 31 12:59:06 2003 2 | +++ include/freetype/config/ftmodule.h Thu Jul 31 12:59:17 2003 3 | @@ -1,4 +1,5 @@ 4 | FT_USE_MODULE(autohint_module_class) 5 | +/* 6 | FT_USE_MODULE(cff_driver_class) 7 | FT_USE_MODULE(t1cid_driver_class) 8 | FT_USE_MODULE(pcf_driver_class) 9 | @@ -7,13 +8,15 @@ 10 | FT_USE_MODULE(psnames_module_class) 11 | FT_USE_MODULE(pshinter_module_class) 12 | FT_USE_MODULE(ft_raster1_renderer_class) 13 | +*/ 14 | FT_USE_MODULE(sfnt_module_class) 15 | FT_USE_MODULE(ft_smooth_renderer_class) 16 | FT_USE_MODULE(ft_smooth_lcd_renderer_class) 17 | FT_USE_MODULE(ft_smooth_lcdv_renderer_class) 18 | FT_USE_MODULE(tt_driver_class) 19 | +/* 20 | FT_USE_MODULE(t1_driver_class) 21 | FT_USE_MODULE(t42_driver_class) 22 | FT_USE_MODULE(pfr_driver_class) 23 | FT_USE_MODULE(winfnt_driver_class) 24 | - 25 | +*/ 26 | -------------------------------------------------------------------------------- /upstream/patches/ft-nostdio.patch: -------------------------------------------------------------------------------- 1 | --- src/base/ftsystem.c.origf Mon Dec 29 05:45:54 2003 2 | +++ src/base/ftsystem.c Mon Dec 29 05:46:08 2003 3 | @@ -32,7 +32,8 @@ 4 | #include FT_ERRORS_H 5 | #include FT_TYPES_H 6 | 7 | -#include 8 | +#include 9 | +#include 10 | #include 11 | 12 | 13 | @@ -151,7 +152,7 @@ 14 | 15 | /* We use the macro STREAM_FILE for convenience to extract the */ 16 | /* system-specific stream handle from a given FreeType stream object */ 17 | -#define STREAM_FILE( stream ) ( (FILE*)stream->descriptor.pointer ) 18 | +#define STREAM_FD( stream ) ( (int)stream->descriptor.value ) 19 | 20 | 21 | /*************************************************************************/ 22 | @@ -168,7 +169,7 @@ 23 | FT_CALLBACK_DEF( void ) 24 | ft_ansi_stream_close( FT_Stream stream ) 25 | { 26 | - fclose( STREAM_FILE( stream ) ); 27 | + close(STREAM_FD(stream)); 28 | 29 | stream->descriptor.pointer = NULL; 30 | stream->size = 0; 31 | @@ -202,14 +203,14 @@ 32 | unsigned char* buffer, 33 | unsigned long count ) 34 | { 35 | - FILE* file; 36 | + int fd; 37 | 38 | 39 | - file = STREAM_FILE( stream ); 40 | + fd = STREAM_FD( stream ); 41 | 42 | - fseek( file, offset, SEEK_SET ); 43 | + if(lseek( fd, offset, SEEK_SET ) < 0) return 0; 44 | 45 | - return (unsigned long)fread( buffer, 1, count, file ); 46 | + return (unsigned long) read(fd,buffer,count); 47 | } 48 | 49 | 50 | @@ -219,14 +220,14 @@ 51 | FT_Stream_Open( FT_Stream stream, 52 | const char* filepathname ) 53 | { 54 | - FILE* file; 55 | + int fd,n; 56 | 57 | 58 | if ( !stream ) 59 | return FT_Err_Invalid_Stream_Handle; 60 | 61 | - file = fopen( filepathname, "rb" ); 62 | - if ( !file ) 63 | + fd = open( filepathname, O_RDONLY); 64 | + if (fd < 0) 65 | { 66 | FT_ERROR(( "FT_Stream_Open:" )); 67 | FT_ERROR(( " could not open `%s'\n", filepathname )); 68 | @@ -234,11 +235,11 @@ 69 | return FT_Err_Cannot_Open_Resource; 70 | } 71 | 72 | - fseek( file, 0, SEEK_END ); 73 | - stream->size = ftell( file ); 74 | - fseek( file, 0, SEEK_SET ); 75 | + n = lseek( fd, 0, SEEK_END ); 76 | + stream-> size = n < 0 ? 0 : n; 77 | + lseek( fd, 0, SEEK_SET ); 78 | 79 | - stream->descriptor.pointer = file; 80 | + stream->descriptor.value = fd; 81 | stream->pathname.pointer = (char*)filepathname; 82 | stream->pos = 0; 83 | 84 | -------------------------------------------------------------------------------- /upstream/patches/gcc-64bitclean.patch: -------------------------------------------------------------------------------- 1 | --- ../gcc-3.3.3.orig/gcc/config/mips/mips.c 2004-07-16 2 | 12:58:11.873718000 -0500 3 | +++ gcc/config/mips/mips.c 2004-07-16 14:41:44.477442899 -0500 4 | @@ -6731,7 +6731,7 @@ 5 | if (regs_ever_live[regno] && !call_used_regs[regno]) 6 | { 7 | fp_reg_size += FP_INC * UNITS_PER_FPREG; 8 | - fmask |= ((1 << FP_INC) - 1) << (regno - FP_REG_FIRST); 9 | + fmask |= ((1L << FP_INC) - 1L) << (regno - FP_REG_FIRST); 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /upstream/patches/gcc-fdata-sections-bss.patch: -------------------------------------------------------------------------------- 1 | --- gcc/config/mips/mips.c.orig Mon Dec 29 06:30:42 2003 2 | +++ gcc/config/mips/mips.c Mon Dec 29 07:16:35 2003 3 | @@ -10535,11 +10535,13 @@ 4 | int len, size, sec; 5 | const char *name, *prefix; 6 | char *string; 7 | - static const char *const prefixes[4][2] = { 8 | + static const char *const prefixes[6][2] = { 9 | { ".text.", ".gnu.linkonce.t." }, 10 | { ".rodata.", ".gnu.linkonce.r." }, 11 | { ".data.", ".gnu.linkonce.d." }, 12 | - { ".sdata.", ".gnu.linkonce.s." } 13 | + { ".sdata.", ".gnu.linkonce.s." }, 14 | + { ".bss.", ".gnu.linkonce.b." }, 15 | + { ".sbss.", ".gnu.linkonce.sb." } 16 | }; 17 | 18 | name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); 19 | @@ -10551,8 +10553,9 @@ 20 | if (TREE_CODE (decl) == FUNCTION_DECL) 21 | sec = 0; 22 | else if (DECL_INITIAL (decl) == 0 23 | - || DECL_INITIAL (decl) == error_mark_node) 24 | - sec = 2; 25 | + || DECL_INITIAL (decl) == error_mark_node 26 | + || initializer_zerop (DECL_INITIAL (decl))) 27 | + sec = (size > 0 && size <= mips_section_threshold) ? 5 : 4; 28 | else if ((TARGET_EMBEDDED_PIC || TARGET_MIPS16) 29 | && TREE_CODE (decl) == STRING_CST 30 | && !flag_writable_strings) 31 | -------------------------------------------------------------------------------- /upstream/patches/gcc-fixes.patch: -------------------------------------------------------------------------------- 1 | diff -urN ../gcc-3.3.1/gcc/builtin-attrs.def ./gcc/builtin-attrs.def 2 | --- ../gcc-3.3.1/gcc/builtin-attrs.def Tue Mar 4 09:37:20 2003 3 | +++ ./gcc/builtin-attrs.def Wed Aug 27 00:09:45 2003 4 | @@ -110,6 +110,7 @@ 5 | ATTR_NOTHROW_LIST) 6 | 7 | /* Construct a tree for a format attribute. */ 8 | +#if 0 9 | #define DEF_FORMAT_ATTRIBUTE(TYPE, FA, VALUES) \ 10 | DEF_ATTR_TREE_LIST (CONCAT4 (ATTR_,TYPE,_,VALUES), ATTR_NULL, \ 11 | CONCAT2 (ATTR_,TYPE), CONCAT2 (ATTR_LIST_,VALUES)) \ 12 | @@ -128,6 +129,32 @@ 13 | DEF_FORMAT_ATTRIBUTE(STRFTIME,3,3_0) 14 | DEF_FORMAT_ATTRIBUTE(STRFMON,3,3_4) 15 | #undef DEF_FORMAT_ATTRIBUTE 16 | +#else 17 | +DEF_ATTR_TREE_LIST (ATTR_PRINTF_1_0, ATTR_NULL, ATTR_PRINTF, ATTR_LIST_1_0) 18 | +DEF_ATTR_TREE_LIST (ATTR_FORMAT_PRINTF_1_0, ATTR_FORMAT, ATTR_PRINTF_1_0, ATTR_NONNULL_1) 19 | +DEF_ATTR_TREE_LIST (ATTR_PRINTF_1_2, ATTR_NULL, ATTR_PRINTF, ATTR_LIST_1_2) 20 | +DEF_ATTR_TREE_LIST (ATTR_FORMAT_PRINTF_1_2, ATTR_FORMAT, ATTR_PRINTF_1_2, ATTR_NONNULL_1) 21 | +DEF_ATTR_TREE_LIST (ATTR_PRINTF_2_0, ATTR_NULL, ATTR_PRINTF, ATTR_LIST_2_0) 22 | +DEF_ATTR_TREE_LIST (ATTR_FORMAT_PRINTF_2_0, ATTR_FORMAT, ATTR_PRINTF_2_0, ATTR_NONNULL_2) 23 | +DEF_ATTR_TREE_LIST (ATTR_PRINTF_2_3, ATTR_NULL, ATTR_PRINTF, ATTR_LIST_2_3) 24 | +DEF_ATTR_TREE_LIST (ATTR_FORMAT_PRINTF_2_3, ATTR_FORMAT, ATTR_PRINTF_2_3, ATTR_NONNULL_2) 25 | +DEF_ATTR_TREE_LIST (ATTR_PRINTF_3_0, ATTR_NULL, ATTR_PRINTF, ATTR_LIST_3_0) 26 | +DEF_ATTR_TREE_LIST (ATTR_FORMAT_PRINTF_3_0, ATTR_FORMAT, ATTR_PRINTF_3_0, ATTR_NONNULL_3) 27 | +DEF_ATTR_TREE_LIST (ATTR_PRINTF_3_4, ATTR_NULL, ATTR_PRINTF, ATTR_LIST_3_4) 28 | +DEF_ATTR_TREE_LIST (ATTR_FORMAT_PRINTF_3_4, ATTR_FORMAT, ATTR_PRINTF_3_4, ATTR_NONNULL_3) 29 | +DEF_ATTR_TREE_LIST (ATTR_SCANF_1_0, ATTR_NULL, ATTR_SCANF, ATTR_LIST_1_0) 30 | +DEF_ATTR_TREE_LIST (ATTR_FORMAT_SCANF_1_0, ATTR_FORMAT, ATTR_SCANF_1_0, ATTR_NONNULL_1) 31 | +DEF_ATTR_TREE_LIST (ATTR_SCANF_1_2, ATTR_NULL, ATTR_SCANF, ATTR_LIST_1_2) 32 | +DEF_ATTR_TREE_LIST (ATTR_FORMAT_SCANF_1_2, ATTR_FORMAT, ATTR_SCANF_1_2, ATTR_NONNULL_1) 33 | +DEF_ATTR_TREE_LIST (ATTR_SCANF_2_0, ATTR_NULL, ATTR_SCANF, ATTR_LIST_2_0) 34 | +DEF_ATTR_TREE_LIST (ATTR_FORMAT_SCANF_2_0, ATTR_FORMAT, ATTR_SCANF_2_0, ATTR_NONNULL_2) 35 | +DEF_ATTR_TREE_LIST (ATTR_SCANF_2_3, ATTR_NULL, ATTR_SCANF, ATTR_LIST_2_3) 36 | +DEF_ATTR_TREE_LIST (ATTR_FORMAT_SCANF_2_3, ATTR_FORMAT, ATTR_SCANF_2_3, ATTR_NONNULL_2) 37 | +DEF_ATTR_TREE_LIST (ATTR_STRFTIME_3_0, ATTR_NULL, ATTR_STRFTIME, ATTR_LIST_3_0) 38 | +DEF_ATTR_TREE_LIST (ATTR_FORMAT_STRFTIME_3_0, ATTR_FORMAT, ATTR_STRFTIME_3_0, ATTR_NONNULL_3) 39 | +DEF_ATTR_TREE_LIST (ATTR_STRFMON_3_4, ATTR_NULL, ATTR_STRFMON, ATTR_LIST_3_4) 40 | +DEF_ATTR_TREE_LIST (ATTR_FORMAT_STRFMON_3_4, ATTR_FORMAT, ATTR_STRFMON_3_4, ATTR_NONNULL_3) 41 | +#endif 42 | 43 | /* Construct a tree for a format_arg attribute. */ 44 | #define DEF_FORMAT_ARG_ATTRIBUTE(FA) \ 45 | diff -urN ../gcc-3.3.1/gcc/config/mips/t-unknown ./gcc/config/mips/t-unknown 46 | --- ../gcc-3.3.1/gcc/config/mips/t-unknown Wed Dec 31 19:00:00 1969 47 | +++ ./gcc/config/mips/t-unknown Mon Sep 1 01:19:35 2003 48 | @@ -0,0 +1,3 @@ 49 | +MULTILIB_OPTIONS= msingle-float 50 | +MULTILIB_DIRNAMES = single-float 51 | +MULTILIB_MATCHES = 52 | diff -urN ../gcc-3.3.1/gcc/config.gcc ./gcc/config.gcc 53 | --- ../gcc-3.3.1/gcc/config.gcc Fri Jun 27 07:44:22 2003 54 | +++ ./gcc/config.gcc Sun Aug 31 12:39:12 2003 55 | @@ -1932,6 +1932,10 @@ 56 | target_cpu_default="MASK_64BIT|MASK_FLOAT64|MASK_GAS" 57 | tm_defines="MIPS_ISA_DEFAULT=64 MIPS_CPU_STRING_DEFAULT=\\\"sb1\\\" MIPS_ABI_DEFAULT=ABI_O64" 58 | ;; 59 | +mips*-unknown-elf*) 60 | + tm_file="${tm_file} mips/elf.h" 61 | + tmake_file="mips/t-elf mips/t-unknown" 62 | + ;; 63 | mips-*-elf* | mipsel-*-elf*) 64 | tm_file="${tm_file} mips/elf.h" 65 | tmake_file=mips/t-elf 66 | -------------------------------------------------------------------------------- /upstream/patches/gcc-with-newer-version.patch: -------------------------------------------------------------------------------- 1 | --- gcc/f/com.orig.h 2010-05-06 16:31:53.000000000 +0000 2 | +++ gcc/f/com.h 2010-05-06 16:32:03.000000000 +0000 3 | @@ -233,7 +233,7 @@ 4 | void ffecom_finish_progunit (void); 5 | tree ffecom_get_invented_identifier (const char *pattern, ...) 6 | ATTRIBUTE_PRINTF_1; 7 | -ffeinfoKindtype ffecom_gfrt_basictype (ffecomGfrt ix); 8 | +ffeinfoBasictype ffecom_gfrt_basictype (ffecomGfrt gfrt); 9 | ffeinfoKindtype ffecom_gfrt_kindtype (ffecomGfrt ix); 10 | void ffecom_init_0 (void); 11 | void ffecom_init_2 (void); 12 | -------------------------------------------------------------------------------- /upstream/patches/gcc.patch: -------------------------------------------------------------------------------- 1 | *** gcc/config.gcc~ 2013-10-02 19:47:24.000000000 -0500 2 | --- gcc/config.gcc 2014-09-19 23:05:47.878447819 -0500 3 | *************** 4 | *** 1916,1923 **** 5 | --- 1916,1927 ---- 6 | tmake_file="mips/t-elf mips/t-sb1" 7 | target_cpu_default="MASK_64BIT|MASK_FLOAT64" 8 | tm_defines="${tm_defines} MIPS_ISA_DEFAULT=64 MIPS_CPU_STRING_DEFAULT=\\\"sb1\\\" MIPS_ABI_DEFAULT=ABI_O64" 9 | ;; 10 | + mips*-unknown-elf*) 11 | + tm_file="elfos.h newlib-stdint.h ${tm_file} mips/elf.h" 12 | + tmake_file="mips/t-elf mips/t-unknown" 13 | + ;; 14 | mips-*-elf* | mipsel-*-elf*) 15 | tm_file="elfos.h newlib-stdint.h ${tm_file} mips/elf.h" 16 | tmake_file="mips/t-elf" 17 | ;; 18 | *** gcc/config/mips/t-unknown~ 2014-09-19 23:07:48.767047085 -0500 19 | --- gcc/config/mips/t-unknown 2014-09-19 23:04:35.686089598 -0500 20 | *************** 21 | *** 0 **** 22 | --- 1,3 ---- 23 | + MULTILIB_OPTIONS = msingle-float 24 | + MULTILIB_DIRNAMES = single-float 25 | + MULTILIB_MATCHES = msingle-float=m4650 26 | -------------------------------------------------------------------------------- /upstream/patches/gpc-noutils.patch: -------------------------------------------------------------------------------- 1 | --- gcc/p/Make-lang.in.orig 2004-05-21 03:22:35.000000000 -0400 2 | +++ gcc/p/Make-lang.in 2004-05-21 03:24:03.000000000 -0400 3 | @@ -374,8 +374,8 @@ 4 | MAKEINFO_ES=LANG=es_ES LC_ALL=es_ES $(MAKEINFO) $(MAKEINFOFLAGS) $(GPC_DOC_DIRS_ES) 5 | 6 | # Define the names for selecting Pascal in LANGUAGES. 7 | -Pascal pascal: xgpc$(exeext) gpc1$(exeext) gpcpp$(exeext) gpc-run pascal.utils \ 8 | - pascal.rts specs pascal.generated-files pascal.docdemos 9 | +Pascal pascal: xgpc$(exeext) gpc1$(exeext) gpcpp$(exeext) gpc-run \ 10 | + pascal.rts specs pascal.generated-files 11 | 12 | # Tell GNU make to ignore these if they exist. 13 | .PHONY: Pascal pascal 14 | @@ -1026,7 +1026,7 @@ 15 | fi; exit 0 16 | 17 | pascal.install-normal: pascal.install-common pascal.install-compiler \ 18 | - install-gpcpp pascal.install-utils pascal.install-lib pascal.install-man \ 19 | + install-gpcpp pascal.install-lib pascal.install-man \ 20 | pascal.install-info pascal.install-units pascal.install-doc 21 | 22 | # This target will install GPC into an existing GCC installation, 23 | -------------------------------------------------------------------------------- /upstream/patches/gpc-with-3.3.3.patch: -------------------------------------------------------------------------------- 1 | --- gcc/p/diffs/gcc-3.3.diff~ 2004-05-21 02:17:02.000000000 -0400 2 | +++ gcc/p/diffs/gcc-3.3.diff 2004-05-21 02:17:02.000000000 -0400 3 | @@ -727,22 +727,3 @@ 4 | abort (); 5 | } 6 | 7 | -*** gcc/varasm.c Sat Aug 16 19:06:03 2003 8 | ---- gcc/varasm.c Sat Aug 16 19:04:13 2003 9 | -*************** 10 | -*** 2411,2417 **** 11 | - if (get_set_constructor_bytes (t2, tmp2, len) != NULL_TREE) 12 | - return 0; 13 | - 14 | -! return memcmp (tmp1, tmp2, len) != 0; 15 | - } 16 | - else 17 | - { 18 | ---- 2411,2417 ---- 19 | - if (get_set_constructor_bytes (t2, tmp2, len) != NULL_TREE) 20 | - return 0; 21 | - 22 | -! return memcmp (tmp1, tmp2, len) == 0; 23 | - } 24 | - else 25 | - { 26 | -------------------------------------------------------------------------------- /upstream/patches/libmspack.patch: -------------------------------------------------------------------------------- 1 | --- ../libmspack.orig/mspack/Makefile Sat Jul 26 10:44:57 2003 2 | +++ mspack/Makefile Sun Nov 2 17:12:35 2003 3 | @@ -1,12 +1,13 @@ 4 | CC=gcc 5 | RM=rm -f 6 | AR=ar 7 | +RANLIB=ranlib 8 | 9 | WARNINGS=-Wall -Wsign-compare -Wconversion -pedantic 10 | LARGEFILE=-std=c99 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE 11 | DEBUG=-g -DDEBUG 12 | OPTIM=-O3 13 | -CFLAGS= $(WARNINGS) $(LARGEFILE) $(DEBUG) $(OPTIM) -I. 14 | +CFLAGS= $(WARNINGS) $(LARGEFILE) $(OPTIM) -I. #-DMSPACK_NO_DEFAULT_SYSTEM 15 | 16 | all: libmspack.a 17 | 18 | @@ -27,6 +28,7 @@ 19 | libmspack.a: $(OBJS) 20 | -$(RM) $@ 21 | $(AR) q $@ $(OBJS) 22 | + $(RANLIB) $@ 23 | 24 | .c.o: 25 | $(CC) $(CFLAGS) -o $@ -c $< 26 | -------------------------------------------------------------------------------- /upstream/patches/newlib-malloc.patch: -------------------------------------------------------------------------------- 1 | *** newlib/libc/stdlib/mallocr.c~ 2010-05-31 14:15:41.000000000 -0500 2 | --- newlib/libc/stdlib/mallocr.c 2014-10-03 23:25:33.240503853 -0500 3 | *************** 4 | *** 306,323 **** 5 | #define POINTER_UINT unsigned _POINTER_INT 6 | #define SEPARATE_OBJECTS 7 | #define HAVE_MMAP 0 8 | #define MORECORE(size) _sbrk_r(reent_ptr, (size)) 9 | ! #define MORECORE_CLEARS 0 10 | #define MALLOC_LOCK __malloc_lock(reent_ptr) 11 | #define MALLOC_UNLOCK __malloc_unlock(reent_ptr) 12 | 13 | #ifdef __CYGWIN__ 14 | # undef _WIN32 15 | # undef WIN32 16 | #endif 17 | 18 | ! #ifndef _WIN32 19 | #ifdef SMALL_MEMORY 20 | #define malloc_getpagesize (128) 21 | #else 22 | #define malloc_getpagesize (4096) 23 | --- 306,324 ---- 24 | #define POINTER_UINT unsigned _POINTER_INT 25 | #define SEPARATE_OBJECTS 26 | #define HAVE_MMAP 0 27 | #define MORECORE(size) _sbrk_r(reent_ptr, (size)) 28 | ! #define MORECORE_CLEARS 1 29 | ! #define malloc_getpagesize getpagesize() 30 | #define MALLOC_LOCK __malloc_lock(reent_ptr) 31 | #define MALLOC_UNLOCK __malloc_unlock(reent_ptr) 32 | 33 | #ifdef __CYGWIN__ 34 | # undef _WIN32 35 | # undef WIN32 36 | #endif 37 | 38 | ! #if !defined(_WIN32) && !defined(malloc_getpagesize) 39 | #ifdef SMALL_MEMORY 40 | #define malloc_getpagesize (128) 41 | #else 42 | #define malloc_getpagesize (4096) 43 | -------------------------------------------------------------------------------- /upstream/patches/newlib-mips.patch: -------------------------------------------------------------------------------- 1 | *** libgloss/configure.in~ 2011-12-15 16:58:40.000000000 -0600 2 | --- libgloss/configure.in 2014-10-14 15:10:54.639686243 -0500 3 | *************** 4 | *** 60,67 **** 5 | --- 60,70 ---- 6 | ;; 7 | sh*-*-pe | mips*-*-pe | *arm-wince-pe) 8 | AC_CONFIG_SUBDIRS([wince]) 9 | ;; 10 | + mips*-unknown-elf*) 11 | + AC_CONFIG_SUBDIRS() 12 | + ;; 13 | mips*-*-*) 14 | AC_CONFIG_SUBDIRS([mips]) 15 | ;; 16 | powerpc-*-*|powerpcle-*-*) 17 | *** libgloss/configure~ 2011-12-15 16:58:40.000000000 -0600 18 | --- libgloss/configure 2014-10-14 15:10:56.139693681 -0500 19 | *************** 20 | *** 2425,2432 **** 21 | --- 2425,2435 ---- 22 | sh*-*-pe | mips*-*-pe | *arm-wince-pe) 23 | subdirs="$subdirs wince" 24 | 25 | ;; 26 | + mips*-unknown-elf*) 27 | + subdirs="$subdirs" 28 | + ;; 29 | mips*-*-*) 30 | subdirs="$subdirs mips" 31 | 32 | ;; 33 | *** newlib/libc/include/sys/stat.h~ 2010-08-06 13:26:21.000000000 -0500 34 | --- newlib/libc/include/sys/stat.h 2014-10-14 15:24:57.579866157 -0500 35 | *************** 36 | *** 149,157 **** 37 | int _EXFUN(mkfifo,( const char *__path, mode_t __mode )); 38 | int _EXFUN(stat,( const char *__path, struct stat *__sbuf )); 39 | mode_t _EXFUN(umask,( mode_t __mask )); 40 | 41 | ! #if defined (__SPU__) || defined(__rtems__) || defined(__CYGWIN__) && !defined(__INSIDE_CYGWIN__) 42 | int _EXFUN(lstat,( const char *__path, struct stat *__buf )); 43 | int _EXFUN(mknod,( const char *__path, mode_t __mode, dev_t __dev )); 44 | #endif 45 | 46 | --- 149,157 ---- 47 | int _EXFUN(mkfifo,( const char *__path, mode_t __mode )); 48 | int _EXFUN(stat,( const char *__path, struct stat *__sbuf )); 49 | mode_t _EXFUN(umask,( mode_t __mask )); 50 | 51 | ! #if defined (__SPU__) || defined(__rtems__) || defined(__CYGWIN__) && !defined(__INSIDE_CYGWIN__) || 1 52 | int _EXFUN(lstat,( const char *__path, struct stat *__buf )); 53 | int _EXFUN(mknod,( const char *__path, mode_t __mode, dev_t __dev )); 54 | #endif 55 | 56 | *** newlib/libc/include/sys/utime.h~ 2000-02-17 13:39:46.000000000 -0600 57 | --- newlib/libc/include/sys/utime.h 2014-10-14 15:26:42.652387184 -0500 58 | *************** 59 | *** 14,21 **** 60 | --- 14,23 ---- 61 | time_t actime; 62 | time_t modtime; 63 | }; 64 | 65 | + extern int utime(const char *file, const struct utimbuf *buf); 66 | + 67 | #ifdef __cplusplus 68 | }; 69 | #endif 70 | 71 | *** newlib/libc/include/sys/dirent.h~ 2005-10-04 15:47:39.000000000 -0500 72 | --- newlib/libc/include/sys/dirent.h 2014-10-14 15:29:52.217327186 -0500 73 | *************** 74 | *** 1,13 **** 75 | - /* includes , which is this file. On a 76 | - system which supports , this file is overridden by 77 | - dirent.h in the libc/sys/.../sys directory. On a system which does 78 | - not support , we will get this file which uses #error to force 79 | - an error. */ 80 | - 81 | #ifdef __cplusplus 82 | extern "C" { 83 | #endif 84 | ! #error " not supported" 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | --- 1,30 ---- 89 | #ifdef __cplusplus 90 | extern "C" { 91 | #endif 92 | ! 93 | ! #define MAXNAMLEN 4087 94 | ! 95 | ! struct dirent { 96 | ! unsigned long d_reclen; 97 | ! unsigned long d_ino; 98 | ! char d_name[MAXNAMLEN+1]; 99 | ! }; 100 | ! 101 | ! typedef struct { 102 | ! int dd_fd; 103 | ! char *dd_buf; 104 | ! long dd_loc; 105 | ! long dd_size; 106 | ! long dd_len; 107 | ! } DIR; 108 | ! 109 | ! DIR *opendir (const char *); 110 | ! struct dirent *readdir (DIR *); 111 | ! int readdir_r(DIR *, struct dirent *, struct dirent **); 112 | ! void rewinddir (DIR *); 113 | ! int closedir (DIR *); 114 | ! 115 | ! 116 | #ifdef __cplusplus 117 | } 118 | #endif 119 | *** newlib/libc/include/sys/signal.h~ 2011-04-19 03:02:59.000000000 -0500 120 | --- newlib/libc/include/sys/signal.h 2014-10-14 15:31:00.289664738 -0500 121 | *************** 122 | *** 134,150 **** 123 | #if defined(_POSIX_THREADS) 124 | int _EXFUN(pthread_sigmask, (int how, const sigset_t *set, sigset_t *oset)); 125 | #endif 126 | 127 | /* protos for functions found in winsup sources for CYGWIN */ 128 | ! #if defined(__CYGWIN__) || defined(__rtems__) 129 | #undef sigaddset 130 | #undef sigdelset 131 | #undef sigemptyset 132 | #undef sigfillset 133 | #undef sigismember 134 | 135 | ! int _EXFUN(kill, (pid_t, int)); 136 | int _EXFUN(killpg, (pid_t, int)); 137 | int _EXFUN(sigaction, (int, const struct sigaction *, struct sigaction *)); 138 | int _EXFUN(sigaddset, (sigset_t *, const int)); 139 | int _EXFUN(sigdelset, (sigset_t *, const int)); 140 | --- 134,154 ---- 141 | #if defined(_POSIX_THREADS) 142 | int _EXFUN(pthread_sigmask, (int how, const sigset_t *set, sigset_t *oset)); 143 | #endif 144 | 145 | + int _EXFUN(kill, (int, int)); 146 | + 147 | + 148 | /* protos for functions found in winsup sources for CYGWIN */ 149 | ! #if defined(__CYGWIN__) || defined(__rtems__) || 1 150 | #undef sigaddset 151 | #undef sigdelset 152 | #undef sigemptyset 153 | #undef sigfillset 154 | #undef sigismember 155 | 156 | ! #include 157 | ! 158 | int _EXFUN(killpg, (pid_t, int)); 159 | int _EXFUN(sigaction, (int, const struct sigaction *, struct sigaction *)); 160 | int _EXFUN(sigaddset, (sigset_t *, const int)); 161 | int _EXFUN(sigdelset, (sigset_t *, const int)); 162 | *** newlib/libc/include/sys/resource.h~ 2000-02-17 13:39:46.000000000 -0600 163 | --- newlib/libc/include/sys/resource.h 2014-10-14 15:34:18.334646790 -0500 164 | *************** 165 | *** 10,15 **** 166 | --- 10,22 ---- 167 | struct timeval ru_utime; /* user time used */ 168 | struct timeval ru_stime; /* system time used */ 169 | }; 170 | 171 | + #define PRIO_PROCESS 0 172 | + #define PRIO_MIN -20 173 | + #define PRIO_MAX 20 174 | + 175 | + int getpriority(int which, int who); 176 | + int setpriority(int which, int who, int prio); 177 | + 178 | #endif 179 | 180 | *** newlib/libc/include/paths.h~ 2000-02-17 13:39:46.000000000 -0600 181 | --- newlib/libc/include/paths.h 2014-10-03 23:32:34.814594320 -0500 182 | *************** 183 | *** 2,7 **** 184 | --- 2,8 ---- 185 | #define _PATHS_H_ 186 | 187 | #define _PATH_DEV "/dev/" 188 | #define _PATH_BSHELL "/bin/sh" 189 | + #define _PATH_DEVNULL "/dev/null" 190 | 191 | #endif /* _PATHS_H_ */ 192 | *** newlib/libc/include/stdlib.h~ 2010-07-19 13:21:11.000000000 -0500 193 | --- newlib/libc/include/stdlib.h 2014-10-14 15:33:41.110462205 -0500 194 | *************** 195 | *** 192,199 **** 196 | --- 192,200 ---- 197 | unsigned long long _EXFUN(_strtoull_r,(struct _reent *, const char *__n, char **__end_PTR, int __base)); 198 | 199 | #ifndef __CYGWIN__ 200 | _VOID _EXFUN(cfree,(_PTR)); 201 | + char * _EXFUN(realpath,(const char *, char *)); 202 | int _EXFUN(unsetenv,(const char *__string)); 203 | int _EXFUN(_unsetenv_r,(struct _reent *, const char *__string)); 204 | #endif 205 | 206 | *************** 207 | *** 214,221 **** 208 | --- 215,225 ---- 209 | int _EXFUN(_system_r,(struct _reent *, const char *)); 210 | 211 | _VOID _EXFUN(__eprintf,(const char *, const char *, unsigned int, const char *)); 212 | 213 | + int _EXFUN(daemon,(int,int)); 214 | + 215 | + 216 | /* On platforms where long double equals double. */ 217 | #ifdef _LDBL_EQ_DBL 218 | extern long double strtold (const char *, char **); 219 | extern long double wcstold (const wchar_t *, wchar_t **); 220 | *** newlib/configure.host~ 2011-11-29 00:33:48.000000000 -0600 221 | --- newlib/configure.host 2014-10-03 23:32:16.846505222 -0500 222 | *************** 223 | *** 456,463 **** 224 | --- 456,466 ---- 225 | ;; 226 | mips*-dec-*) 227 | sys_dir=decstation 228 | ;; 229 | + mips-unknown-elf*) 230 | + posix_dir=posix; unix_dir=unix 231 | + ;; 232 | mmix-knuth-mmixware) 233 | sys_dir=mmixware 234 | ;; 235 | moxie*) 236 | *************** 237 | *** 664,671 **** 238 | --- 667,678 ---- 239 | mips64vr*-*-*) 240 | default_newlib_io_long_long="yes" 241 | newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES" 242 | ;; 243 | + mips*-unknown-elf*) 244 | + newlib_cflags="${newlib_cflags} -DHAVE_GETTIMEOFDAY -DHAVE_FCNTL -DHAVE_OPENDIR -DWANT_PRINTF_LONG_LONG -D_NO_GETUT -D_NO_FNMATCH -D_NO_GLOB -D_NO_POPEN -D_NO_PREAD -D_NO_PWRITE -D_NO_REGEX -D_NO_SIGSET -D_NO_WORDEXP -DREENTRANT_SYSCALLS_PROVIDED -D_NO_GETLOGIN -D_NO_GETPASS" 245 | + syscall_dir=syscalls 246 | + ;; 247 | mips*-*-elf*) 248 | default_newlib_io_long_long="yes" 249 | newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES" 250 | ;; 251 | -------------------------------------------------------------------------------- /upstream/patches/newlib-nestedvm-define.patch: -------------------------------------------------------------------------------- 1 | *** newlib/libc/include/sys/config.h~ 2010-12-02 13:30:46.000000000 -0600 2 | --- newlib/libc/include/sys/config.h 2014-10-14 16:24:31.197586771 -0500 3 | *************** 4 | *** 3,10 **** 5 | --- 3,15 ---- 6 | 7 | #include /* floating point macros */ 8 | #include /* POSIX defs */ 9 | 10 | + #ifndef __NESTEDVM__ 11 | + #define __NESTEDVM__ 12 | + #endif 13 | + 14 | + 15 | /* exceptions first */ 16 | #if defined(__H8500__) || defined(__W65__) 17 | #define __SMALL_BITFIELDS 18 | /* ??? This conditional is true for the h8500 and the w65, defining H8300 19 | -------------------------------------------------------------------------------- /upstream/patches/newlib-new.patch: -------------------------------------------------------------------------------- 1 | *** missing~ 2009-08-22 06:48:33.000000000 -0500 2 | --- missing 2014-10-22 15:19:20.713544905 -0500 3 | *************** 4 | *** 313,321 **** 5 | test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info 6 | fi 7 | # If the file does not exist, the user really needs makeinfo; 8 | # let's fail without touching anything. 9 | ! test -f $file || exit 1 10 | touch $file 11 | ;; 12 | 13 | tar*) 14 | --- 313,321 ---- 15 | test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info 16 | fi 17 | # If the file does not exist, the user really needs makeinfo; 18 | # let's fail without touching anything. 19 | ! # test -f $file || exit 1 20 | touch $file 21 | ;; 22 | 23 | tar*) 24 | *** newlib/libc/include/sys/unistd.h~ 2014-10-22 18:02:53.000000000 -0500 25 | --- newlib/libc/include/sys/unistd.h 2014-10-22 18:09:44.011333923 -0500 26 | *************** 27 | *** 235,243 **** 28 | 29 | #if defined(__CYGWIN__) || defined(__SPU__) || defined(__rtems__) 30 | #endif 31 | 32 | ! ssize_t _EXFUN(readlink, (const char *__path, char *__buf, size_t __buflen)); 33 | #if defined(__CYGWIN__) 34 | ssize_t _EXFUN(readlinkat, (int __dirfd1, const char *__path, char *__buf, size_t __buflen)); 35 | #endif 36 | int _EXFUN(symlink, (const char *__name1, const char *__name2)); 37 | --- 235,243 ---- 38 | 39 | #if defined(__CYGWIN__) || defined(__SPU__) || defined(__rtems__) 40 | #endif 41 | 42 | ! ssize_t _EXFUN(readlink, (const char *__path, char *__buf, int __buflen)); 43 | #if defined(__CYGWIN__) 44 | ssize_t _EXFUN(readlinkat, (int __dirfd1, const char *__path, char *__buf, size_t __buflen)); 45 | #endif 46 | int _EXFUN(symlink, (const char *__name1, const char *__name2)); 47 | -------------------------------------------------------------------------------- /upstream/patches/newlib-nomemcpy.patch: -------------------------------------------------------------------------------- 1 | *** newlib/libc/machine/mips/Makefile.in~ 2011-12-19 16:03:28.000000000 -0600 2 | --- newlib/libc/machine/mips/Makefile.in 2014-10-14 16:45:52.591940862 -0500 3 | *************** 4 | *** 52,61 **** 5 | ARFLAGS = cru 6 | lib_a_AR = $(AR) $(ARFLAGS) 7 | lib_a_LIBADD = 8 | am_lib_a_OBJECTS = lib_a-setjmp.$(OBJEXT) lib_a-strlen.$(OBJEXT) \ 9 | ! lib_a-strcmp.$(OBJEXT) lib_a-strncpy.$(OBJEXT) \ 10 | ! lib_a-memset.$(OBJEXT) lib_a-memcpy.$(OBJEXT) 11 | lib_a_OBJECTS = $(am_lib_a_OBJECTS) 12 | DEFAULT_INCLUDES = -I.@am__isrc@ 13 | depcomp = 14 | am__depfiles_maybe = 15 | --- 52,60 ---- 16 | ARFLAGS = cru 17 | lib_a_AR = $(AR) $(ARFLAGS) 18 | lib_a_LIBADD = 19 | am_lib_a_OBJECTS = lib_a-setjmp.$(OBJEXT) lib_a-strlen.$(OBJEXT) \ 20 | ! lib_a-strcmp.$(OBJEXT) lib_a-strncpy.$(OBJEXT) 21 | lib_a_OBJECTS = $(am_lib_a_OBJECTS) 22 | DEFAULT_INCLUDES = -I.@am__isrc@ 23 | depcomp = 24 | am__depfiles_maybe = 25 | *** newlib/libc/string/Makefile.in~ 2011-03-28 09:51:28.000000000 -0500 26 | --- newlib/libc/string/Makefile.in 2014-10-14 16:45:18.851773554 -0500 27 | *************** 28 | *** 56,65 **** 29 | lib_a_AR = $(AR) $(ARFLAGS) 30 | lib_a_LIBADD = 31 | am__objects_1 = lib_a-bcopy.$(OBJEXT) lib_a-bzero.$(OBJEXT) \ 32 | lib_a-index.$(OBJEXT) lib_a-memchr.$(OBJEXT) \ 33 | ! lib_a-memcmp.$(OBJEXT) lib_a-memcpy.$(OBJEXT) \ 34 | ! lib_a-memmove.$(OBJEXT) lib_a-memset.$(OBJEXT) \ 35 | lib_a-rindex.$(OBJEXT) lib_a-strcasecmp.$(OBJEXT) \ 36 | lib_a-strcat.$(OBJEXT) lib_a-strchr.$(OBJEXT) \ 37 | lib_a-strcmp.$(OBJEXT) lib_a-strcoll.$(OBJEXT) \ 38 | lib_a-strcpy.$(OBJEXT) lib_a-strcspn.$(OBJEXT) \ 39 | --- 56,65 ---- 40 | lib_a_AR = $(AR) $(ARFLAGS) 41 | lib_a_LIBADD = 42 | am__objects_1 = lib_a-bcopy.$(OBJEXT) lib_a-bzero.$(OBJEXT) \ 43 | lib_a-index.$(OBJEXT) lib_a-memchr.$(OBJEXT) \ 44 | ! lib_a-memcmp.$(OBJEXT) \ 45 | ! lib_a-memmove.$(OBJEXT) \ 46 | lib_a-rindex.$(OBJEXT) lib_a-strcasecmp.$(OBJEXT) \ 47 | lib_a-strcat.$(OBJEXT) lib_a-strchr.$(OBJEXT) \ 48 | lib_a-strcmp.$(OBJEXT) lib_a-strcoll.$(OBJEXT) \ 49 | lib_a-strcpy.$(OBJEXT) lib_a-strcspn.$(OBJEXT) \ 50 | -------------------------------------------------------------------------------- /upstream/patches/newlib-sdata.patch: -------------------------------------------------------------------------------- 1 | *** newlib/libc/include/sys/config.h~ 2014-10-17 15:48:33.000000000 -0500 2 | --- newlib/libc/include/sys/config.h 2014-10-17 16:53:22.342853277 -0500 3 | *************** 4 | *** 131,139 **** 5 | #endif 6 | #endif 7 | 8 | #if defined(__mips__) && !defined(__rtems__) 9 | ! #define __ATTRIBUTE_IMPURE_PTR__ __attribute__((__section__(".sdata"))) 10 | #endif 11 | 12 | #ifdef __xstormy16__ 13 | #define __SMALL_BITFIELDS 14 | --- 131,139 ---- 15 | #endif 16 | #endif 17 | 18 | #if defined(__mips__) && !defined(__rtems__) 19 | ! /*#define __ATTRIBUTE_IMPURE_PTR__ __attribute__((__section__(".sdata")))*/ 20 | #endif 21 | 22 | #ifdef __xstormy16__ 23 | #define __SMALL_BITFIELDS 24 | -------------------------------------------------------------------------------- /upstream/patches/newlib-texinfo.patch: -------------------------------------------------------------------------------- 1 | *** missing~ 2009-08-22 06:48:33.000000000 -0500 2 | --- missing 2014-10-17 14:55:17.991723886 -0500 3 | *************** 4 | *** 313,321 **** 5 | test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info 6 | fi 7 | # If the file does not exist, the user really needs makeinfo; 8 | # let's fail without touching anything. 9 | ! test -f $file || exit 1 10 | touch $file 11 | ;; 12 | 13 | tar*) 14 | --- 313,321 ---- 15 | test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info 16 | fi 17 | # If the file does not exist, the user really needs makeinfo; 18 | # let's fail without touching anything. 19 | ! # test -f $file || exit 1 20 | touch $file 21 | ;; 22 | 23 | tar*) 24 | -------------------------------------------------------------------------------- /upstream/patches/newlib-tzset.patch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bgould/nestedvm/e0a5f7bedd8555bef78822f43fa2510810e2fe0c/upstream/patches/newlib-tzset.patch -------------------------------------------------------------------------------- /upstream/patches/newlib-unistd.patch: -------------------------------------------------------------------------------- 1 | *** newlib/libc/include/sys/unistd.h~ 2011-08-19 09:29:34.000000000 -0500 2 | --- newlib/libc/include/sys/unistd.h 2014-10-14 16:53:02.642073366 -0500 3 | *************** 4 | *** 180,188 **** 5 | #if defined(__CYGWIN__) || defined(__rtems__) 6 | int _EXFUN(ttyname_r, (int, char *, size_t)); 7 | #endif 8 | int _EXFUN(unlink, (const char *__path )); 9 | - int _EXFUN(usleep, (useconds_t __useconds)); 10 | int _EXFUN(vhangup, (void )); 11 | _READ_WRITE_RETURN_TYPE _EXFUN(write, (int __fd, const void *__buf, size_t __nbyte )); 12 | 13 | #ifdef __CYGWIN__ 14 | --- 180,187 ---- 15 | *************** 16 | *** 220,229 **** 17 | #endif 18 | 19 | #if defined(__CYGWIN__) || defined(__rtems__) || defined(__sh__) || defined(__SPU__) 20 | #if !defined(__INSIDE_CYGWIN__) 21 | - int _EXFUN(ftruncate, (int __fd, off_t __length)); 22 | - int _EXFUN(truncate, (const char *, off_t __length)); 23 | #endif 24 | #endif 25 | 26 | #if defined(__CYGWIN__) || defined(__rtems__) 27 | --- 219,226 ---- 28 | *************** 29 | *** 233,245 **** 30 | #if !(defined (_WINSOCK_H) || defined (__USE_W32_SOCKETS)) 31 | /* winsock[2].h defines as __stdcall, and with int as 2nd arg */ 32 | int _EXFUN(gethostname, (char *__name, size_t __len)); 33 | #endif 34 | - char * _EXFUN(mktemp, (char *)); 35 | #endif 36 | 37 | #if defined(__CYGWIN__) || defined(__SPU__) || defined(__rtems__) 38 | - void _EXFUN(sync, (void)); 39 | #endif 40 | 41 | ssize_t _EXFUN(readlink, (const char *__path, char *__buf, size_t __buflen)); 42 | #if defined(__CYGWIN__) 43 | --- 230,240 ---- 44 | *************** 45 | *** 250,257 **** 46 | --- 245,259 ---- 47 | int _EXFUN(symlinkat, (const char *, int, const char *)); 48 | int _EXFUN(unlinkat, (int, const char *, int)); 49 | #endif 50 | 51 | + unsigned _EXFUN(usleep, (unsigned int __useconds)); 52 | + int _EXFUN(ftruncate, (int __fd, off_t __length)); 53 | + int _EXFUN(truncate, (const char *, off_t __length)); 54 | + char * _EXFUN(mktemp, (char *)); 55 | + int _EXFUN(sync, (void)); 56 | + 57 | + 58 | #define F_OK 0 59 | #define R_OK 4 60 | #define W_OK 2 61 | #define X_OK 1 62 | -------------------------------------------------------------------------------- /upstream/patches/newlib-unix.patch: -------------------------------------------------------------------------------- 1 | *** newlib/libc/unix/Makefile.in~ 2011-12-19 16:03:49.000000000 -0600 2 | --- newlib/libc/unix/Makefile.in 2014-10-14 17:04:04.477355230 -0500 3 | *************** 4 | *** 54,62 **** 5 | LIBRARIES = $(noinst_LIBRARIES) 6 | ARFLAGS = cru 7 | lib_a_AR = $(AR) $(ARFLAGS) 8 | lib_a_LIBADD = 9 | ! am__objects_1 = lib_a-getcwd.$(OBJEXT) lib_a-pread.$(OBJEXT) \ 10 | lib_a-pwrite.$(OBJEXT) lib_a-sigset.$(OBJEXT) 11 | am__objects_2 = lib_a-ttyname.$(OBJEXT) lib_a-ttyname_r.$(OBJEXT) 12 | am__objects_3 = lib_a-basename.$(OBJEXT) lib_a-dirname.$(OBJEXT) \ 13 | lib_a-getlogin.$(OBJEXT) lib_a-getpass.$(OBJEXT) \ 14 | --- 54,62 ---- 15 | LIBRARIES = $(noinst_LIBRARIES) 16 | ARFLAGS = cru 17 | lib_a_AR = $(AR) $(ARFLAGS) 18 | lib_a_LIBADD = 19 | ! am__objects_1 = lib_a-pread.$(OBJEXT) \ 20 | lib_a-pwrite.$(OBJEXT) lib_a-sigset.$(OBJEXT) 21 | am__objects_2 = lib_a-ttyname.$(OBJEXT) lib_a-ttyname_r.$(OBJEXT) 22 | am__objects_3 = lib_a-basename.$(OBJEXT) lib_a-dirname.$(OBJEXT) \ 23 | lib_a-getlogin.$(OBJEXT) lib_a-getpass.$(OBJEXT) \ 24 | *************** 25 | *** 70,78 **** 26 | @USE_LIBTOOL_FALSE@ $(am__objects_4) 27 | lib_a_OBJECTS = $(am_lib_a_OBJECTS) 28 | LTLIBRARIES = $(noinst_LTLIBRARIES) 29 | libunix_la_LIBADD = 30 | ! am__objects_5 = getcwd.lo pread.lo pwrite.lo sigset.lo 31 | am__objects_6 = ttyname.lo ttyname_r.lo 32 | am__objects_7 = basename.lo dirname.lo getlogin.lo getpass.lo \ 33 | getpwent.lo getut.lo 34 | @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@am__objects_8 = $(am__objects_6) \ 35 | --- 70,78 ---- 36 | @USE_LIBTOOL_FALSE@ $(am__objects_4) 37 | lib_a_OBJECTS = $(am_lib_a_OBJECTS) 38 | LTLIBRARIES = $(noinst_LTLIBRARIES) 39 | libunix_la_LIBADD = 40 | ! am__objects_5 = pread.lo pwrite.lo sigset.lo 41 | am__objects_6 = ttyname.lo ttyname_r.lo 42 | am__objects_7 = basename.lo dirname.lo getlogin.lo getpass.lo \ 43 | getpwent.lo getut.lo 44 | @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@am__objects_8 = $(am__objects_6) \ 45 | *************** 46 | *** 249,257 **** 47 | top_srcdir = @top_srcdir@ 48 | AUTOMAKE_OPTIONS = cygnus 49 | INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS) 50 | GENERAL_SOURCES = \ 51 | - getcwd.c \ 52 | pread.c \ 53 | pwrite.c \ 54 | sigset.c 55 | 56 | --- 249,256 ---- 57 | *************** 58 | *** 266,277 **** 59 | getpass.c \ 60 | getpwent.c \ 61 | getut.c 62 | 63 | ! @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ELIX_SOURCES = $(ELIX_2_SOURCES) $(ELIX_4_SOURCES) 64 | ! @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_TRUE@ELIX_SOURCES = $(ELIX_2_SOURCES) 65 | ! @ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_TRUE@ELIX_SOURCES = $(ELIX_2_SOURCES) 66 | ! @ELIX_LEVEL_1_TRUE@ELIX_SOURCES = 67 | libunix_la_LDFLAGS = -Xcompiler -nostdlib 68 | @USE_LIBTOOL_TRUE@noinst_LTLIBRARIES = libunix.la 69 | @USE_LIBTOOL_TRUE@libunix_la_SOURCES = $(GENERAL_SOURCES) $(ELIX_SOURCES) 70 | @USE_LIBTOOL_FALSE@noinst_DATA = 71 | --- 265,274 ---- 72 | getpass.c \ 73 | getpwent.c \ 74 | getut.c 75 | 76 | ! ELIX_SOURCES = 77 | ! 78 | libunix_la_LDFLAGS = -Xcompiler -nostdlib 79 | @USE_LIBTOOL_TRUE@noinst_LTLIBRARIES = libunix.la 80 | @USE_LIBTOOL_TRUE@libunix_la_SOURCES = $(GENERAL_SOURCES) $(ELIX_SOURCES) 81 | @USE_LIBTOOL_FALSE@noinst_DATA = 82 | -------------------------------------------------------------------------------- /upstream/patches/newlib.patch: -------------------------------------------------------------------------------- 1 | *** newlib/libc/ctype/ctype_.c~ 2001-06-11 14:25:59.000000000 -0500 2 | --- newlib/libc/ctype/ctype_.c 2014-09-22 22:57:17.370539945 -0500 3 | *************** 4 | *** 84,95 **** 5 | _CTYPE_DATA_128_256 6 | }; 7 | 8 | #if defined(__CYGWIN__) || defined(__CYGWIN32__) 9 | ! extern _CONST char __declspec(dllexport) _ctype_[1 + 256] __attribute__ ((alias ("_ctype_b+127"))); 10 | _CONST char __declspec(dllexport) *__ctype_ptr = _ctype_b + 128; 11 | #else 12 | ! extern _CONST char _ctype_[1 + 256] __attribute__ ((alias ("_ctype_b+127"))); 13 | _CONST char *__ctype_ptr = _ctype_b + 128; 14 | #endif 15 | 16 | #else /* !defined(ALLOW_NEGATIVE_CTYPE_INDEX) */ 17 | --- 84,105 ---- 18 | _CTYPE_DATA_128_256 19 | }; 20 | 21 | #if defined(__CYGWIN__) || defined(__CYGWIN32__) 22 | ! _CONST char __declspec(dllexport) _ctype_[1 + 256] = 23 | ! { 0, 24 | ! _CTYPE_DATA_0_127, 25 | ! _CTYPE_DATA_128_256 26 | ! }; 27 | ! 28 | _CONST char __declspec(dllexport) *__ctype_ptr = _ctype_b + 128; 29 | #else 30 | ! _CONST char _ctype_[1 + 256] = 31 | ! { 0, 32 | ! _CTYPE_DATA_0_127, 33 | ! _CTYPE_DATA_128_256 34 | ! }; 35 | ! 36 | _CONST char *__ctype_ptr = _ctype_b + 128; 37 | #endif 38 | 39 | #else /* !defined(ALLOW_NEGATIVE_CTYPE_INDEX) */ 40 | *** newlib/libc/ctype/iswctype.c~ 2002-09-20 15:13:10.000000000 -0500 41 | --- newlib/libc/ctype/iswctype.c 2014-09-22 23:01:18.775736950 -0500 42 | *************** 43 | *** 61,68 **** 44 | --- 61,69 ---- 45 | return iswupper (c); 46 | case WC_XDIGIT: 47 | return iswxdigit (c); 48 | default: 49 | + ; 50 | } 51 | 52 | /* otherwise unknown */ 53 | return 0; 54 | *** newlib/libc/ctype/wctype.c~ 2002-09-20 15:13:10.000000000 -0500 55 | --- newlib/libc/ctype/wctype.c 2014-09-22 23:02:47.412176483 -0500 56 | *************** 57 | *** 120,127 **** 58 | --- 120,128 ---- 59 | if (!strcmp (c, "xdigit")) 60 | return WC_XDIGIT; 61 | break; 62 | default: 63 | + ; 64 | } 65 | 66 | /* otherwise invalid */ 67 | r->_errno = EINVAL; 68 | -------------------------------------------------------------------------------- /upstream/patches/samba.patch: -------------------------------------------------------------------------------- 1 | --- ../samba-3.0.4/source/lib/iconv.c 2004-04-04 03:37:34.000000000 -0400 2 | +++ source/lib/iconv.c 2004-06-29 20:56:57.000000000 -0400 3 | @@ -110,6 +110,9 @@ 4 | static BOOL initialized; 5 | int i; 6 | 7 | + extern NTSTATUS charset_CP850_init(); 8 | + extern NTSTATUS charset_CP437_init(); 9 | + 10 | if (!initialized) { 11 | initialized = True; 12 | for(i = 0; builtin_functions[i].name; i++) 13 | diff -ru ../samba-3.0.4/source/lib/module.c source/lib/module.c 14 | --- ../samba-3.0.4/source/lib/module.c 2004-04-04 03:37:34.000000000 -0400 15 | +++ source/lib/module.c 2004-06-30 20:53:24.000000000 -0400 16 | @@ -130,7 +130,7 @@ 17 | 18 | NTSTATUS smb_probe_module(const char *subsystem, const char *module) 19 | { 20 | - DEBUG(0,("This samba executable has not been built with plugin support, not probing\n")); 21 | + /*DEBUG(0,("This samba executable has not been built with plugin support, not probing\n")); */ 22 | return NT_STATUS_NOT_SUPPORTED; 23 | } 24 | 25 | diff -ru ../samba-3.0.4/source/utils/ntlm_auth_diagnostics.c source/utils/ntlm_auth_diagnostics.c 26 | --- ../samba-3.0.4/source/utils/ntlm_auth_diagnostics.c 2004-04-20 16:42:58.000000000 -0400 27 | +++ source/utils/ntlm_auth_diagnostics.c 2004-06-30 01:21:08.000000000 -0400 28 | @@ -580,7 +580,8 @@ 29 | {test_plaintext_lm_broken, "Plaintext LM broken"}, 30 | {test_plaintext_nt_broken, "Plaintext NT broken"}, 31 | {test_plaintext_nt_only, "Plaintext NT only"}, 32 | - {test_plaintext_lm_only, "Plaintext LM only"} 33 | + {test_plaintext_lm_only, "Plaintext LM only"}, 34 | + {NULL, NULL} 35 | }; 36 | 37 | BOOL diagnose_ntlm_auth(void) 38 | -------------------------------------------------------------------------------- /upstream/tasks/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bgould/nestedvm/e0a5f7bedd8555bef78822f43fa2510810e2fe0c/upstream/tasks/.gitignore -------------------------------------------------------------------------------- /upstream/tasks/download_boehmgc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bgould/nestedvm/e0a5f7bedd8555bef78822f43fa2510810e2fe0c/upstream/tasks/download_boehmgc -------------------------------------------------------------------------------- /upstream/tasks/download_gpc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bgould/nestedvm/e0a5f7bedd8555bef78822f43fa2510810e2fe0c/upstream/tasks/download_gpc -------------------------------------------------------------------------------- /upstream/tasks/download_openbsdglob: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bgould/nestedvm/e0a5f7bedd8555bef78822f43fa2510810e2fe0c/upstream/tasks/download_openbsdglob -------------------------------------------------------------------------------- /upstream/tasks/download_regex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bgould/nestedvm/e0a5f7bedd8555bef78822f43fa2510810e2fe0c/upstream/tasks/download_regex --------------------------------------------------------------------------------