├── .gitignore ├── rt ├── .gitignore ├── README.md ├── src │ ├── hexagon.rs │ ├── arm.rs │ ├── lib.rs │ └── x86.rs ├── Cargo.toml └── LICENSE ├── tests ├── .gitignore ├── README.md ├── Cargo.toml ├── src │ └── lib.rs └── LICENSE ├── Cargo.toml ├── README.md ├── src └── lib.rs └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | **/*.rs.bk 3 | Cargo.lock 4 | -------------------------------------------------------------------------------- /rt/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | **/*.rs.bk 3 | Cargo.lock 4 | -------------------------------------------------------------------------------- /tests/.gitignore: -------------------------------------------------------------------------------- 1 | Cargo.lock 2 | target/ 3 | **/*.rs.bk 4 | -------------------------------------------------------------------------------- /rt/README.md: -------------------------------------------------------------------------------- 1 | # runtime-target-feature-rt-rs 2 | Runtime for runtime-target-feature 3 | -------------------------------------------------------------------------------- /tests/README.md: -------------------------------------------------------------------------------- 1 | # runtime-target-feature-test-rs 2 | Tests for runtime-target-feature 3 | -------------------------------------------------------------------------------- /rt/src/hexagon.rs: -------------------------------------------------------------------------------- 1 | // TODO: implement somehow 2 | pub fn have_hvx() -> bool { 3 | false 4 | } 5 | 6 | pub fn have_hvx_double() -> bool { 7 | false 8 | } 9 | -------------------------------------------------------------------------------- /rt/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "runtime-target-feature-rt" 3 | version = "0.1.0" 4 | authors = ["James Duley "] 5 | 6 | [dependencies.atomic] 7 | version = "0.3.3" 8 | features = ["nightly"] 9 | 10 | [dependencies] 11 | lazy_static = "0.2" 12 | -------------------------------------------------------------------------------- /tests/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "runtime-target-feature-tests" 3 | version = "0.1.0" 4 | authors = ["James Duley "] 5 | 6 | [dependencies] 7 | runtime-target-feature = { path = ".." } 8 | runtime-target-feature-rt = { path = "../rt" } 9 | 10 | -------------------------------------------------------------------------------- /rt/src/arm.rs: -------------------------------------------------------------------------------- 1 | // TODO: implement with auxv crate on linux 2 | 3 | pub fn have_neon() -> bool { 4 | true 5 | } 6 | 7 | pub fn have_vfp2() -> bool { 8 | true 9 | } 10 | 11 | pub fn have_vfp3() -> bool { 12 | true 13 | } 14 | 15 | pub fn have_vfp4() -> bool { 16 | true 17 | } 18 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "runtime-target-feature" 3 | version = "0.1.0" 4 | authors = ["James Duley "] 5 | 6 | [lib] 7 | proc-macro = true 8 | 9 | [dependencies] 10 | quote = "0.3" 11 | 12 | [dependencies.syn] 13 | version = "0.11" 14 | features = ["full"] 15 | 16 | [workspace] 17 | members = ["rt", "tests"] 18 | -------------------------------------------------------------------------------- /rt/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![feature(asm)] 2 | 3 | #[macro_use] 4 | extern crate lazy_static; 5 | 6 | pub extern crate atomic; 7 | 8 | #[cfg(target_arch = "arm")] 9 | mod arm; 10 | #[cfg(target_arch = "arm")] 11 | pub use arm::*; 12 | 13 | #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] 14 | mod x86; 15 | #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] 16 | pub use x86::*; 17 | 18 | // TODO: hexagon 19 | -------------------------------------------------------------------------------- /tests/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![feature(proc_macro)] 2 | #![feature(target_feature)] 3 | #![feature(const_fn)] 4 | 5 | extern crate runtime_target_feature; 6 | 7 | use runtime_target_feature::runtime_target_feature; 8 | 9 | #[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), runtime_target_feature("+avx"))] 10 | #[cfg_attr(target_arch = "arm", runtime_target_feature("+neon"))] 11 | pub fn sum(input: &[u32]) -> u32 { 12 | input.iter().sum() 13 | } 14 | 15 | #[test] 16 | fn test_multitarget() { 17 | let numbers = [1, 2, 3, 4, 5]; 18 | assert_eq!(15, sum(&numbers)); 19 | } 20 | 21 | #[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), runtime_target_feature("+sse4.1"))] 22 | pub fn product(input: &[u32]) -> u32 { 23 | input.iter().product() 24 | } 25 | 26 | #[test] 27 | fn test_dot_replacement() { 28 | let numbers = [1, 2, 3, 4, 5]; 29 | assert_eq!(120, product(&numbers)); 30 | } 31 | 32 | #[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), runtime_target_feature(" +avx , +sse "))] 33 | #[cfg_attr(target_arch = "arm", runtime_target_feature(" +neon "))] 34 | pub fn sum_whitespace(input: &[u32]) -> u32 { 35 | input.iter().sum() 36 | } 37 | 38 | #[test] 39 | fn test_whitespace() { 40 | let numbers = [1, 2, 3, 4, 5]; 41 | assert_eq!(15, sum_whitespace(&numbers)); 42 | } 43 | 44 | #[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), runtime_target_feature("+avx2;+avx;+sse4.2;+sse4.1;+ssse3;+sse3;+sse2"))] 45 | #[cfg_attr(target_arch = "arm", runtime_target_feature("+vfp4;+vfp3"))] 46 | pub fn sum_sets(input: &[u32]) -> u32 { 47 | input.iter().sum() 48 | } 49 | 50 | #[test] 51 | fn test_sets() { 52 | let numbers = [1, 2, 3, 4, 5]; 53 | assert_eq!(15, sum_sets(&numbers)); 54 | } 55 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # runtime-target-feature-rs 2 | Rust procedural macro to enable target features at runtime 3 | 4 | ## How to use 5 | 6 | You have to both add the derive-crate and the runtime to your dependencies: 7 | 8 | ```toml 9 | [dependencies] 10 | runtime-target-feature = { git = "https://github.com/parched/runtime-target-feature-rs" } 11 | runtime-target-feature-rt = { git = "https://github.com/parched/runtime-target-feature-rs" } 12 | ``` 13 | 14 | Then, use the crate like this: 15 | 16 | ```rust 17 | #![feature(proc_macro)] 18 | #![feature(target_feature)] 19 | #![feature(const_fn)] 20 | 21 | extern crate runtime_target_feature; 22 | 23 | use runtime_target_feature::runtime_target_feature; 24 | 25 | #[runtime_target_feature("+avx2;+sse4.1")] 26 | pub fn some_function() { 27 | // some code that would benefit from avx2 or sse4.1 28 | } 29 | ``` 30 | This generates 3 versions of `some_function`, one with avx2, one with sse4.1 and the default that would have been generated without the attribute. When `some_function` is called it will correctly call the first version the current CPU supports, starting from the left. This means the binary code will get the added performance of avx2 if the CPU it's run on supports, otherwise will fallback to the usual version. 31 | 32 | ### Notes: 33 | * The above isn't portable between archectures, so you should use `runtime_target_feature` with `cfg_attr` like 34 | ```rust 35 | #[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), runtime_target_feature("+avx"))] 36 | #[cfg_attr(target_arch = "arm", runtime_target_feature("+neon"))] 37 | pub fn some_function() 38 | ... 39 | ``` 40 | * The features come in sets for each version of the function so `runtime_target_feature("+a,+b;+c,+d")` will generate three versions, one with `a` and `b` enabled, one with `c` and `d` enabled, and the deafult. 41 | -------------------------------------------------------------------------------- /rt/src/x86.rs: -------------------------------------------------------------------------------- 1 | pub fn have_avx() -> bool { 2 | test_bit(1, 28) 3 | } 4 | 5 | pub fn have_avx2() -> bool { 6 | test_bit(2, 5) 7 | } 8 | 9 | pub fn have_bmi() -> bool { 10 | test_bit(2, 3) 11 | } 12 | 13 | pub fn have_bmi2() -> bool { 14 | test_bit(2, 8) 15 | } 16 | 17 | pub fn have_sse() -> bool { 18 | test_bit(0, 25) 19 | } 20 | 21 | pub fn have_sse2() -> bool { 22 | test_bit(0, 26) 23 | } 24 | 25 | pub fn have_sse3() -> bool { 26 | test_bit(1, 0) 27 | } 28 | 29 | pub fn have_sse4_1() -> bool { 30 | test_bit(1, 19) 31 | } 32 | 33 | pub fn have_sse4_2() -> bool { 34 | test_bit(1, 20) 35 | } 36 | 37 | pub fn have_ssse3() -> bool { 38 | test_bit(1, 9) 39 | } 40 | 41 | pub fn have_tbm() -> bool { 42 | test_bit(6, 21) 43 | } 44 | 45 | pub fn have_lzcnt() -> bool { 46 | test_bit(6, 55) 47 | } 48 | 49 | pub fn have_popcnt() -> bool { 50 | test_bit(1, 23) 51 | } 52 | 53 | pub fn have_sse4a() -> bool { 54 | test_bit(6, 6) 55 | } 56 | 57 | pub fn have_rdrnd() -> bool { 58 | test_bit(1, 30) 59 | } 60 | 61 | pub fn have_rdseed() -> bool { 62 | test_bit(2, 18) 63 | } 64 | 65 | pub fn have_fma() -> bool { 66 | test_bit(1, 12) 67 | } 68 | 69 | lazy_static! { static ref FEATURES: [u32; 7] = unsafe { 70 | let highest_cpuid: u32; 71 | let features_0: u32; 72 | let features_1: u32; 73 | let features_2: u32; 74 | let features_3: u32; 75 | let features_4: u32; 76 | 77 | let extended_highest_cpuid: u32; 78 | let features_5: u32; 79 | let features_6: u32; 80 | 81 | asm!("cpuid" : "={eax}"(highest_cpuid) : "{eax}"(0) : "ebx", "ecx", "edx"); 82 | 83 | if highest_cpuid >= 1 { 84 | asm!("cpuid" : "={ecx}"(features_1), "={edx}"(features_0) : "{eax}"(1) : "eax", "ebx"); 85 | if highest_cpuid >= 7 { 86 | asm!("cpuid": 87 | "={ebx}"(features_2), "={ecx}"(features_3), "={edx}"(features_4): 88 | "{eax}"(7), "{ecx}"(0): 89 | "eax"); 90 | } else { 91 | features_2 = 0; 92 | features_3 = 0; 93 | features_4 = 0; 94 | } 95 | 96 | } else { 97 | features_0 = 0; 98 | features_1 = 0; 99 | features_2 = 0; 100 | features_3 = 0; 101 | features_4 = 0; 102 | } 103 | 104 | asm!("cpuid" : "={eax}"(extended_highest_cpuid) : "{eax}"(0) : "ebx", "ecx", "edx"); 105 | 106 | if extended_highest_cpuid >= 0x80000001u32 { 107 | asm!("cpuid": 108 | "={ecx}"(features_6), "={edx}"(features_5): 109 | "{eax}"(0x80000001u32): 110 | "eax", "ebx"); 111 | } else { 112 | features_5 = 0; 113 | features_6 = 0; 114 | } 115 | 116 | [features_0, features_1, features_2, features_3, features_4, features_5, features_6] 117 | };} 118 | 119 | fn test_bit(word: usize, bit: usize) -> bool { 120 | FEATURES[word] & (1u32 << bit) != 0u32 121 | } 122 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | #![feature(proc_macro)] 2 | 3 | extern crate proc_macro; 4 | extern crate syn; 5 | #[macro_use] 6 | extern crate quote; 7 | 8 | use proc_macro::TokenStream; 9 | use syn::{parse_expr, Abi, BareFnArg, BareFnTy, Block, Expr, ExprKind, FnArg, FnDecl, Generics, 10 | Ident, Item, ItemKind, Pat, Path, PathSegment, UnOp, Unsafety, Visibility}; 11 | use quote::{Tokens, ToTokens}; 12 | use std::option::Option; 13 | 14 | #[proc_macro_attribute] 15 | pub fn runtime_target_feature(features: TokenStream, function: TokenStream) -> TokenStream { 16 | let features_string = features.to_string(); 17 | 18 | let features_str = strip_quotes(strip_parens(features_string.as_str())) 19 | .split(";") 20 | .map(str::trim) 21 | .collect::>(); 22 | 23 | let features = features_str 24 | .iter() 25 | .map(|x| { 26 | x.split(",") 27 | .map(str::trim) 28 | .map(Feature::new) 29 | .collect::>() 30 | }) 31 | .collect::>(); 32 | 33 | let have_features = features 34 | .iter() 35 | .map(|x| x.iter().map(|ref x| x.checker_expr()).collect::>()) 36 | .collect::>(); 37 | 38 | let function_string = function.to_string(); 39 | 40 | let function_item = syn::parse_item(&function_string).unwrap(); 41 | let function_type = function_item_to_type(&function_item.node); 42 | 43 | let (function_decl, function_unsafety, function_constness, function_abi, function_generics) = 44 | match function_item.node { 45 | ItemKind::Fn(ref a, b, c, ref d, ref e, _) => (a.as_ref(), b, c, d, e), 46 | _ => panic!("item must be a function"), 47 | }; 48 | 49 | let args = function_decl 50 | .inputs 51 | .iter() 52 | .map(fn_arg_to_expr) 53 | .collect::>(); 54 | 55 | let setup_ident = Ident::new("setup"); 56 | let default_ident = Ident::new("default"); 57 | let features_ident: Vec = features 58 | .iter() 59 | .map(|x| { 60 | x.iter() 61 | .map(|x| x.to_ident_string()) 62 | .fold("with".to_string(), |acc, x| acc + "_" + &x) 63 | .into() 64 | }) 65 | .collect(); 66 | 67 | let function_item_default = Item { 68 | ident: default_ident.clone(), 69 | vis: Visibility::Inherited, 70 | attrs: function_item.attrs.clone(), 71 | node: function_item.node.clone(), 72 | }; 73 | 74 | let function_item_with_features = features_ident 75 | .iter() 76 | .map(|x| { 77 | Item { 78 | ident: x.clone(), 79 | vis: Visibility::Inherited, 80 | attrs: function_item.attrs.clone(), 81 | node: function_item.node.clone(), 82 | } 83 | }) 84 | .collect::>(); 85 | 86 | let setup_args = args.clone(); 87 | 88 | let setup_block_tokens = quote! { 89 | { 90 | let chosen_function = #(if #(#have_features)&&* { 91 | #features_ident 92 | } else )*{ 93 | #default_ident 94 | }; 95 | 96 | PTR.store(chosen_function, rt::atomic::Ordering::Relaxed); 97 | 98 | chosen_function(#(#setup_args),*) 99 | } 100 | }; 101 | 102 | let setup_block = parse_block(setup_block_tokens.as_str()); 103 | let setup_node = ItemKind::Fn(Box::new(function_decl.clone()), 104 | function_unsafety, 105 | function_constness, 106 | function_abi.clone(), 107 | function_generics.clone(), 108 | setup_block); 109 | 110 | let function_item_setup = Item { 111 | ident: setup_ident.clone(), 112 | vis: Visibility::Inherited, 113 | attrs: function_item.attrs.clone(), 114 | node: setup_node, 115 | }; 116 | 117 | let dispatch_function_block_tokens = quote! { 118 | { 119 | pub extern crate runtime_target_feature_rt as rt; 120 | 121 | static PTR: rt::atomic::Atomic<#function_type> = rt::atomic::Atomic::new(#setup_ident); 122 | 123 | #function_item_setup 124 | 125 | #function_item_default 126 | 127 | #(#[target_feature = #features_str] 128 | #function_item_with_features)* 129 | 130 | PTR.load(rt::atomic::Ordering::Relaxed)(#(#args),*) 131 | } 132 | }; 133 | 134 | let dispatch_function_block = parse_block(dispatch_function_block_tokens.as_str()); 135 | 136 | let dispatch_function_node = ItemKind::Fn(Box::new(function_decl.clone()), 137 | function_unsafety, 138 | function_constness, 139 | function_abi.clone(), 140 | function_generics.clone(), 141 | dispatch_function_block); 142 | 143 | let dispatch_function = Item { 144 | ident: function_item.ident.clone(), 145 | vis: function_item.vis, 146 | attrs: function_item.attrs.clone(), 147 | node: dispatch_function_node, 148 | }; 149 | 150 | 151 | let mut tokens = Tokens::new(); 152 | dispatch_function.to_tokens(&mut tokens); 153 | // println!("{}", tokens); 154 | tokens.parse().unwrap() 155 | } 156 | 157 | fn parse_block(input: &str) -> Box { 158 | Box::new(match parse_expr(input).unwrap().node { 159 | ExprKind::Block(_, block) => block, 160 | _ => unreachable!(), 161 | }) 162 | } 163 | 164 | fn strip_parens(str_with_parens: &str) -> &str { 165 | if !(str_with_parens.starts_with("(") || str_with_parens.ends_with(")")) { 166 | panic!("attribute arguments must begin with '(' and end with ')'"); 167 | } 168 | 169 | &str_with_parens[1..str_with_parens.len() - 1].trim() 170 | } 171 | 172 | fn strip_quotes(str_with_quotes: &str) -> &str { 173 | if !(str_with_quotes.starts_with("\"") || str_with_quotes.ends_with("\"")) { 174 | panic!("attribute arguments must be a string literal"); 175 | } 176 | 177 | &str_with_quotes[1..str_with_quotes.len() - 1].trim() 178 | } 179 | 180 | fn function_item_to_type(item_kind: &ItemKind) -> BareFnTy { 181 | // TODO: handle generics 182 | let (decl, unsafety, abi, _): (&FnDecl, Unsafety, &Option, &Generics) = match *item_kind { 183 | ItemKind::Fn(ref a, b, _, ref d, ref e, _) => (&*a, b, d, e), 184 | _ => panic!("item must be a function"), 185 | }; 186 | 187 | let inputs = decl.inputs 188 | .iter() 189 | .map(|x| match *x { 190 | FnArg::Captured(_, ref ty) => ty, 191 | FnArg::Ignored(ref ty) => ty, 192 | _ => panic!("self not supported"), 193 | }) 194 | .map(|ty| { 195 | BareFnArg { 196 | name: Option::None, 197 | ty: ty.clone(), 198 | } 199 | }) 200 | .collect::>(); 201 | 202 | let lifetimes = Vec::new(); // TODO 203 | 204 | 205 | BareFnTy { 206 | unsafety: unsafety, 207 | abi: abi.clone(), 208 | lifetimes: lifetimes, 209 | inputs: inputs, 210 | output: decl.output.clone(), 211 | variadic: decl.variadic, 212 | } 213 | } 214 | 215 | fn fn_arg_to_expr(arg: &FnArg) -> Expr { 216 | match *arg { 217 | FnArg::Captured(ref pat, _) => { 218 | match *pat { 219 | Pat::Ident(_, ref ident, _) => { 220 | Expr { 221 | node: ExprKind::Path(Option::None, Path::from(ident.clone())), 222 | attrs: Vec::new(), 223 | } 224 | } 225 | _ => panic!("pattern must be identifier"), 226 | } 227 | } 228 | _ => panic!("argument must be captured"), 229 | } 230 | } 231 | 232 | enum Feature<'a> { 233 | Enable(&'a str), 234 | Disable(&'a str), 235 | } 236 | 237 | impl<'a> Feature<'a> { 238 | fn new(feature_str: &'a str) -> Self { 239 | if feature_str.starts_with("+") { 240 | Feature::Enable(&feature_str[1..]) 241 | } else if feature_str.starts_with("-") { 242 | Feature::Disable(&feature_str[1..]) 243 | } else { 244 | panic!("feature must begin with '+' or '-'"); 245 | } 246 | } 247 | 248 | fn name(&self) -> String { 249 | match *self { 250 | Feature::Enable(x) => x, 251 | Feature::Disable(x) => x, 252 | } 253 | .replace(|c| c == '.' || c == '-', "_") 254 | } 255 | 256 | fn to_ident_string(&self) -> String { 257 | match *self { 258 | Feature::Enable(_) => "enable_", 259 | Feature::Disable(_) => "disable_", 260 | } 261 | .to_string() + &self.name() 262 | } 263 | 264 | fn checker_expr(&self) -> Expr { 265 | let segments = ["rt", &("have_".to_string() + &self.name())] 266 | .iter() 267 | .map(|x| PathSegment::from(*x)) 268 | .collect(); 269 | let path = Path { 270 | global: false, 271 | segments: segments, 272 | }; 273 | let function = Expr { 274 | node: ExprKind::Path(Option::None, path), 275 | attrs: Vec::new(), 276 | }; 277 | let call = Expr { 278 | node: ExprKind::Call(Box::new(function), Vec::new()), 279 | attrs: Vec::new(), 280 | }; 281 | match *self { 282 | Feature::Enable(_) => call, 283 | Feature::Disable(_) => { 284 | Expr { 285 | node: ExprKind::Unary(UnOp::Not, Box::new(call)), 286 | attrs: Vec::new(), 287 | } 288 | } 289 | } 290 | } 291 | } 292 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /rt/LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /tests/LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------