-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Original repo: https://cs140e.sergio.bz/assignments/1-shell/skeleton.git
- Loading branch information
Showing
89 changed files
with
1,889 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
# Swap | ||
[._]*.s[a-v][a-z] | ||
[._]*.sw[a-p] | ||
[._]s[a-v][a-z] | ||
[._]sw[a-p] | ||
|
||
# Session | ||
Session.vim | ||
|
||
# Temporary | ||
.netrwhist | ||
*~ | ||
|
||
# Org-mode | ||
.org-id-locations | ||
*_archive | ||
|
||
# flymake-mode | ||
*_flymake.* | ||
|
||
# reftex files | ||
*.rel | ||
|
||
# cask packages | ||
.cask/ | ||
|
||
# Flycheck | ||
flycheck_*.el | ||
|
||
# projectiles files | ||
.projectile | ||
|
||
# directory configuration | ||
.dir-locals.el | ||
|
||
# Prerequisites | ||
*.d | ||
|
||
# Object files | ||
*.o | ||
*.ko | ||
*.obj | ||
*.elf | ||
|
||
# Linker output | ||
*.ilk | ||
*.map | ||
*.exp | ||
|
||
# Precompiled Headers | ||
*.gch | ||
*.pch | ||
|
||
# Libraries | ||
*.lib | ||
*.a | ||
*.la | ||
*.lo | ||
|
||
# Shared objects (inc. Windows DLLs) | ||
*.dll | ||
*.so | ||
*.so.* | ||
*.dylib | ||
|
||
# Executables | ||
*.exe | ||
*.out | ||
*.app | ||
*.i*86 | ||
*.x86_64 | ||
*.hex | ||
*.bin | ||
*.img | ||
|
||
# Debug files | ||
*.dSYM/ | ||
*.su | ||
*.idb | ||
*.pdb | ||
|
||
# Kernel Module Compile Results | ||
*.mod* | ||
*.cmd | ||
.tmp_versions/ | ||
modules.order | ||
Module.symvers | ||
Mkfile.old | ||
dkms.conf | ||
|
||
# Generated by Cargo | ||
# will have compiled files and executables | ||
target/ | ||
|
||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries | ||
# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock | ||
Cargo.lock | ||
|
||
# These are backup files generated by rustfmt | ||
**/*.rs.bk | ||
|
||
# Windows thumbnail cache files | ||
Thumbs.db | ||
ehthumbs.db | ||
ehthumbs_vista.db | ||
|
||
# Dump file | ||
*.stackdump | ||
|
||
# Folder config file | ||
[Dd]esktop.ini | ||
|
||
# Recycle Bin used on file shares | ||
$RECYCLE.BIN/ | ||
|
||
# Windows Installer files | ||
*.cab | ||
*.msi | ||
*.msm | ||
*.msp | ||
|
||
# Windows shortcuts | ||
*.lnk | ||
|
||
# General | ||
.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
|
||
# Thumbnails | ||
._* | ||
|
||
# Files that might appear in the root of a volume | ||
.DocumentRevisions-V100 | ||
.fseventsd | ||
.Spotlight-V100 | ||
.TemporaryItems | ||
.Trashes | ||
.VolumeIcon.icns | ||
.com.apple.timemachine.donotpresent | ||
|
||
# Directories potentially created on remote AFP share | ||
.AppleDB | ||
.AppleDesktop | ||
Network Trash Folder | ||
Temporary Items | ||
.apdisk | ||
|
||
# Submission files | ||
*.tar.gz | ||
|
||
# Assignment 1 specific | ||
ttywrite/input | ||
ttywrite/output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
ASSIGNMENT_NAME := assignment1 | ||
BASE_URL := https://cs140e.sergio.bz | ||
SUBMISSION_SITE := $(BASE_URL)/assignments/submission/ | ||
SUBMIT_TAR := $(ASSIGNMENT_NAME).tar.gz | ||
|
||
CS140E_REL_ROOT := .. | ||
REPO_NAMES := 0-blinky 1-shell os | ||
QUESTIONS_DIRS := $(shell find . -type d -name "questions") | ||
|
||
.PHONY: all test check submission clean | ||
|
||
all: | ||
@echo "usage: make [target]" | ||
@echo | ||
@echo "available targets:" | ||
@echo "test run tests for all targets" | ||
@echo "check ensure every question is answered" | ||
@echo "submission create submission tarball" | ||
@echo "clean clean products from all targets" | ||
|
||
test: | ||
cd ttywrite && ./test.sh | ||
cd stack-vec && cargo test | ||
cd xmodem && cargo test | ||
|
||
check: | ||
@okay=true; \ | ||
for qdir in $(QUESTIONS_DIRS); do \ | ||
for file in "$${qdir}/"*; do \ | ||
if ! [ -s "$${file}" ]; then \ | ||
okay=false; \ | ||
echo "Question file '$${file}' is empty."; \ | ||
fi \ | ||
done \ | ||
done; \ | ||
if ! $$okay; then \ | ||
echo "Questions remain unanswered. Aborting."; \ | ||
exit 1; \ | ||
else \ | ||
echo "All questions appear to be answered."; \ | ||
fi | ||
|
||
submission: $(SUBMIT_TAR) | ||
@echo "Your submission file "$^" was successfully created." | ||
@echo "Submit it at $(SUBMISSION_SITE)" | ||
|
||
.FORCE: | ||
$(SUBMIT_TAR): .FORCE | ||
@rm -f $@ | ||
@cwd="$${PWD}"; \ | ||
for repo in $(REPO_NAMES); do \ | ||
repo_path="$${cwd}/$(CS140E_REL_ROOT)/$${repo}"; \ | ||
cd "$${repo_path}"; \ | ||
if ! [ -z "$$(git status --porcelain)" ]; then \ | ||
echo "There are uncommited changes in $${repo}! Aborting."; \ | ||
rm -f $@; \ | ||
exit 1; \ | ||
else \ | ||
git_files=$$(git ls-files) ; \ | ||
cd "$${repo_path}/.." ; \ | ||
for file in $$git_files; do \ | ||
tar -rf "$${cwd}/$@" "$${repo}/$${file}"; \ | ||
done \ | ||
fi \ | ||
done | ||
@gzip -f $@ | ||
@mv $@.gz $@ | ||
|
||
clean: | ||
rm -f $(SUBMIT_TAR) | ||
cd ttywrite && cargo clean | ||
cd stack-vec && cargo clean | ||
cd xmodem && cargo clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// FIXME: Prevent this file from compiling! Diff budget: 1 line. | ||
|
||
mod a { | ||
pub fn f() { } | ||
} | ||
|
||
// Do not modify this function. | ||
fn main() { | ||
a::f(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// FIXME: Prevent this file from compiling! Diff budget: 1 line. | ||
#[derive(Clone, Copy)] | ||
struct MyType(usize); | ||
|
||
// Note: do not modify this function. | ||
fn main() { | ||
let x = MyType(10); | ||
let y = x; | ||
let z = x; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// FIXME: Make me compile! Diff budget: 1 line. | ||
|
||
struct MyType(usize); | ||
|
||
// Do not modify this function. | ||
pub fn main() { | ||
let x = MyType(1); | ||
let y = &x; | ||
let z = *y; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// FIXME: Make me compile! Diff budget: 3 lines. | ||
|
||
const VAR: i32 = add(34, 10); | ||
|
||
fn add(a: i32, b: i32) -> i32 { | ||
a + b | ||
} | ||
|
||
fn main() { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// FIXME: Make me compile! Diff budget: 1 line. | ||
enum Duration { | ||
MilliSeconds(u64), | ||
Seconds(u32), | ||
Minutes(u16) | ||
} | ||
|
||
pub fn main() { | ||
println!("Duration: {:?}", Duration::MilliSeconds(1200)); | ||
|
||
let x = Duration::Minutes(10); | ||
let y = x; | ||
let z = x; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// FIXME: Make me compile! Diff budget: 2 lines. | ||
// Do not modify this definition. | ||
enum Duration { | ||
MicroSeconds(u128), | ||
MilliSeconds(u64), | ||
Seconds(u32), | ||
Minutes(u16) | ||
} | ||
|
||
fn main() { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// FIXME: Make me compile! Diff budget: 2 lines. | ||
use std::io; | ||
|
||
struct ReadWrapper<T: io::Read> { | ||
inner: T | ||
} | ||
|
||
impl io::Read for ReadWrapper<T> { | ||
fn read(&mut self, buf: &mut [u8]) -> Result<usize> { | ||
self.inner.read(buf) | ||
} | ||
} | ||
|
||
fn main() { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// FIXME: Make me compile! Diff budget: 1 line. | ||
|
||
struct StrWrapper<'a>(&'a str); | ||
|
||
impl<'a> StrWrapper<'a> { | ||
fn inner(&self) -> &str { | ||
self.0 | ||
} | ||
} | ||
|
||
// Do not modify this function. | ||
pub fn main() { | ||
let string = "Hello!"; | ||
let wrapper = StrWrapper(&string); | ||
let _: &'static str = wrapper.inner(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// FIXME: Make me compile! Diff budget: 3 lines. | ||
|
||
// Do not modify the inner type &'a T. | ||
struct RefWrapper<T>(&'a T); | ||
|
||
impl RefWrapper { | ||
fn inner(&self) -> &T { | ||
self.0 | ||
} | ||
} | ||
|
||
// Do not modify this function. | ||
pub fn main() { | ||
let x = 1; | ||
let mut r = &x; | ||
r = RefWrapper(r).inner(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// FIXME: Make me compile! Diff budget: 2 lines. | ||
|
||
// Do not modify the inner type &'a T. | ||
struct RefWrapper<T>(&'a T); | ||
|
||
// Do not modify the inner type &'b RefWrapper<'a, T>. | ||
struct RefWrapperWrapper<T>(&'b RefWrapper<'a, T>); | ||
|
||
pub fn main() { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// FIXME: Make me compile! Diff budget: 3 lines. | ||
|
||
// Do not modify the inner type &'a T. | ||
struct RefWrapper<T>(&'a T); | ||
|
||
// Do not modify the inner type &'b RefWrapper<'a, T>. | ||
struct RefWrapperWrapper<T>(&'b RefWrapper<'a, T>); | ||
|
||
impl RefWrapperWrapper { | ||
fn inner(&self) -> &'a T { | ||
(self.0).0 | ||
} | ||
} | ||
|
||
pub fn main() { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// FIXME: Make me compile! Diff budget: 1 line. | ||
fn make_1(v: &u32) { | ||
*v = 1; | ||
} | ||
|
||
pub fn main() { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// FIXME: Make me compile! Diff budget: 1 line. | ||
|
||
pub fn main() { | ||
let x = 10; | ||
*x = 20; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// FIXME: Make me compile! Diff budget: 1 line. | ||
|
||
pub fn main() { | ||
let x = 10; | ||
x = 20; | ||
} |
Oops, something went wrong.