path
stringlengths
14
112
content
stringlengths
0
6.32M
size
int64
0
6.32M
max_lines
int64
1
100k
repo_name
stringclasses
2 values
autogenerated
bool
1 class
cosmopolitan/libc/testlib/viewables.txt
VIEWABLE UNICODE CHARACTERS According To PragmataPro Basic Latin ═══════════════════════════════════════════════════════ 0000 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 0020 │ ! " # $ % & ' ( ) * + , - . / 0030 │ 0 1 2 3 4 5 6 7 8 9 : ; < = > ? 0040 │ @ A B C D E F G H I J K L M N O 0050 │ P Q R S T U V W X Y Z [ \ ] ^ _ 0060 │ ` a b c d e f g h i j k l m n o 0070 │ p q r s t u v w x y z { | } ~ Latin-1 Supplement ═══════════════════════════════════════════════════════ 0080 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 00a0 │ ¡ ¢ £ ¤ ¥ ¦ § ¨ © ª « ¬ ­ ® ¯ 00b0 │ ° ± ² ³ ´ µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿ 00c0 │ À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï 00d0 │ Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß 00e0 │ à á â ã ä å æ ç è é ê ë ì í î ï 00f0 │ ð ñ ò ó ô õ ö ÷ ø ù ú û ü ý þ ÿ Latin Extended-A ═══════════════════════════════════════════════════════ 0100 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 0100 │ Ā ā Ă ă Ą ą Ć ć Ĉ ĉ Ċ ċ Č č Ď ď 0110 │ Đ đ Ē ē Ĕ ĕ Ė ė Ę ę Ě ě Ĝ ĝ Ğ ğ 0120 │ Ġ ġ Ģ ģ Ĥ ĥ Ħ ħ Ĩ ĩ Ī ī Ĭ ĭ Į į 0130 │ İ ı IJ ij Ĵ ĵ Ķ ķ ĸ Ĺ ĺ Ļ ļ Ľ ľ Ŀ 0140 │ ŀ Ł ł Ń ń Ņ ņ Ň ň ʼn Ŋ ŋ Ō ō Ŏ ŏ 0150 │ Ő ő Œ œ Ŕ ŕ Ŗ ŗ Ř ř Ś ś Ŝ ŝ Ş ş 0160 │ Š š Ţ ţ Ť ť Ŧ ŧ Ũ ũ Ū ū Ŭ ŭ Ů ů 0170 │ Ű ű Ų ų Ŵ ŵ Ŷ ŷ Ÿ Ź ź Ż ż Ž ž ſ Latin Extended-B ═══════════════════════════════════════════════════════ 0180 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 0180 │ ƀ Ɓ Ƃ ƃ Ƅ ƅ Ɔ Ƈ ƈ Ɖ Ɗ Ƌ ƌ ƍ Ǝ Ə 0190 │ Ɛ Ƒ ƒ Ɠ Ɣ ƕ Ɩ Ɨ Ƙ ƙ ƚ ƛ Ɯ Ɲ ƞ Ɵ 01a0 │ Ơ ơ Ƣ ƣ Ƥ ƥ Ʀ Ƨ ƨ Ʃ ƪ ƫ Ƭ ƭ Ʈ Ư 01b0 │ ư Ʊ Ʋ Ƴ ƴ Ƶ ƶ Ʒ Ƹ ƹ ƺ ƻ Ƽ ƽ ƾ ƿ 01c0 │ ǀ ǁ ǂ ǃ DŽ Dž dž LJ Lj lj NJ Nj nj Ǎ ǎ Ǐ 01d0 │ ǐ Ǒ ǒ Ǔ ǔ Ǖ ǖ Ǘ ǘ Ǚ ǚ Ǜ ǜ ǝ Ǟ ǟ 01e0 │ Ǡ ǡ Ǣ ǣ Ǥ ǥ Ǧ ǧ Ǩ ǩ Ǫ ǫ Ǭ ǭ Ǯ ǯ 01f0 │ ǰ DZ Dz dz Ǵ ǵ Ƕ Ƿ Ǹ ǹ Ǻ ǻ Ǽ ǽ Ǿ ǿ 0200 │ Ȁ ȁ Ȃ ȃ Ȅ ȅ Ȇ ȇ Ȉ ȉ Ȋ ȋ Ȍ ȍ Ȏ ȏ 0210 │ Ȑ ȑ Ȓ ȓ Ȕ ȕ Ȗ ȗ Ș ș Ț ț Ȝ ȝ Ȟ ȟ 0220 │ Ƞ ȡ Ȣ ȣ Ȥ ȥ Ȧ ȧ Ȩ ȩ Ȫ ȫ Ȭ ȭ Ȯ ȯ 0230 │ Ȱ ȱ Ȳ ȳ ȴ ȵ ȶ ȷ ȸ ȹ Ⱥ Ȼ ȼ Ƚ Ⱦ ȿ 0240 │ ɀ Ɂ ɂ Ƀ Ʉ Ʌ Ɇ ɇ Ɉ ɉ Ɋ ɋ Ɍ ɍ Ɏ ɏ IPA Extensions ═══════════════════════════════════════════════════════ 0250 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 0250 │ ɐ ɑ ɒ ɓ ɔ ɕ ɖ ɗ ɘ ə ɚ ɛ ɜ ɝ ɞ ɟ 0260 │ ɠ ɡ ɢ ɣ ɤ ɥ ɦ ɧ ɨ ɩ ɪ ɫ ɬ ɭ ɮ ɯ 0270 │ ɰ ɱ ɲ ɳ ɴ ɵ ɶ ɷ ɸ ɹ ɺ ɻ ɼ ɽ ɾ ɿ 0280 │ ʀ ʁ ʂ ʃ ʄ ʅ ʆ ʇ ʈ ʉ ʊ ʋ ʌ ʍ ʎ ʏ 0290 │ ʐ ʑ ʒ ʓ ʔ ʕ ʖ ʗ ʘ ʙ ʚ ʛ ʜ ʝ ʞ ʟ 02a0 │ ʠ ʡ ʢ ʣ ʤ ʥ ʦ ʧ ʨ ʩ ʪ ʫ ʬ ʭ ʮ ʯ Spacing Modifier Letters ═══════════════════════════════════════════════════════ 02b0 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 02b0 │ ʰ ʱ ʲ ʳ ʴ ʵ ʶ ʷ ʸ ʹ ʺ ʻ ʼ ʽ ʾ ʿ 02c0 │ ˀ ˁ ˂ ˃ ˄ ˅ ˆ ˇ ˈ ˉ ˊ ˋ ˌ ˍ ˎ ˏ 02d0 │ ː ˑ ˒ ˓ ˔ ˕ ˖ ˗ ˘ ˙ ˚ ˛ ˜ ˝ ˞ ˟ 02e0 │ ˠ ˡ ˢ ˣ ˤ ˥ ˦ ˧ ˨ ˩ ˪ ˫ ˬ ˭ ˮ ˯ 02f0 │ ˰ ˱ ˲ ˳ ˴ ˵ ˶ ˷ ˸ ˹ ˺ ˻ ˼ ˽ ˾ ˿ Greek and Coptic ═══════════════════════════════════════════════════════ 0370 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 0370 │ ; 0380 │ ΄ ΅ Ά · Έ Ή Ί Ό Ύ Ώ 0390 │ ΐ Α Β Γ Δ Ε Ζ Η Θ Ι Κ Λ Μ Ν Ξ Ο 03a0 │ Π Ρ Σ Τ Υ Φ Χ Ψ Ω Ϊ Ϋ ά έ ή ί 03b0 │ ΰ α β γ δ ε ζ η θ ι κ λ μ ν ξ ο 03c0 │ π ρ ς σ τ υ φ χ ψ ω ϊ ϋ ό ύ ώ 03d0 │ ϐ ϑ ϕ ϖ Ϝ ϝ 03f0 │ ϰ ϱ ϴ ϵ Cyrillic ═══════════════════════════════════════════════════════ 0400 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 0400 │ Ѐ Ё Ђ Ѓ Є Ѕ І Ї Ј Љ Њ Ћ Ќ Ѝ Ў Џ 0410 │ А Б В Г Д Е Ж З И Й К Л М Н О П 0420 │ Р С Т У Ф Х Ц Ч Ш Щ Ъ Ы Ь Э Ю Я 0430 │ а б в г д е ж з и й к л м н о п 0440 │ р с т у ф х ц ч ш щ ъ ы ь э ю я 0450 │ ѐ ё ђ ѓ є ѕ і ї ј љ њ ћ ќ ѝ ў џ 0460 │ Ѡ ѡ Ѣ ѣ Ѥ ѥ 0470 │ Ѳ ѳ 0490 │ Ґ ґ Ҙ ҙ Қ қ Runic ═══════════════════════════════════════════════════════ 16a0 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 16a0 │ ᚠ ᚡ ᚢ ᚣ ᚤ ᚥ ᚦ ᚧ ᚨ ᚩ ᚪ ᚫ ᚬ ᚭ ᚮ ᚯ 16b0 │ ᚰ ᚱ ᚲ ᚳ ᚴ ᚵ ᚶ ᚷ ᚸ ᚹ ᚺ ᚻ ᚼ ᚽ ᚾ ᚿ 16c0 │ ᛀ ᛁ ᛂ ᛃ ᛄ ᛅ ᛆ ᛇ ᛈ ᛉ ᛊ ᛋ ᛌ ᛍ ᛎ ᛏ 16d0 │ ᛐ ᛑ ᛒ ᛓ ᛔ ᛕ ᛖ ᛗ ᛘ ᛙ ᛚ ᛛ ᛜ ᛝ ᛞ ᛟ 16e0 │ ᛠ ᛡ ᛢ ᛣ ᛤ ᛥ ᛦ ᛧ ᛨ ᛩ ᛪ ᛫ ᛬ ᛭ ᛮ ᛯ 16f0 │ ᛰ Phonetic Extensions ═══════════════════════════════════════════════════════ 1d00 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 1d00 │ ᴀ ᴁ ᴂ ᴃ ᴄ ᴅ ᴆ ᴇ ᴈ ᴉ ᴊ ᴋ ᴌ ᴍ ᴎ ᴏ 1d10 │ ᴐ ᴑ ᴒ ᴓ ᴔ ᴕ ᴖ ᴗ ᴘ ᴙ ᴚ ᴛ ᴜ ᴝ ᴞ ᴟ 1d20 │ ᴠ ᴡ ᴢ ᴣ ᴤ ᴥ ᴦ ᴧ ᴨ ᴩ ᴪ ᴫ ᴬ ᴭ ᴮ ᴯ 1d30 │ ᴰ ᴱ ᴲ ᴳ ᴴ ᴵ ᴶ ᴷ ᴸ ᴹ ᴺ ᴻ ᴼ ᴽ ᴾ ᴿ 1d40 │ ᵀ ᵁ ᵂ ᵃ ᵄ ᵅ ᵆ ᵇ ᵈ ᵉ ᵊ ᵋ ᵌ ᵍ ᵎ ᵏ 1d50 │ ᵐ ᵑ ᵒ ᵓ ᵔ ᵕ ᵖ ᵗ ᵘ ᵙ ᵚ ᵛ ᵜ ᵝ ᵞ ᵟ 1d60 │ ᵠ ᵡ ᵢ ᵣ ᵤ ᵥ ᵦ ᵧ ᵨ ᵩ ᵪ ᵫ ᵬ ᵭ ᵮ ᵯ 1d70 │ ᵰ ᵱ ᵲ ᵳ ᵴ ᵵ ᵶ ᵷ ᵸ ᵹ ᵺ ᵻ ᵼ ᵽ ᵾ ᵿ Phonetic Extensions Supplement ═══════════════════════════════════════════════════════ 1d80 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 1d90 │ ᶜ 1da0 │ ᶠ ᶥ 1db0 │ ᶷ ᶻ ᶿ Latin Extended Additional ═══════════════════════════════════════════════════════ 1e00 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 1e00 │ Ḁ ḁ Ḃ ḃ Ḅ ḅ Ḇ ḇ Ḉ ḉ Ḋ ḋ Ḍ ḍ Ḏ ḏ 1e10 │ Ḑ ḑ Ḓ ḓ Ḕ ḕ Ḗ ḗ Ḙ ḙ Ḛ ḛ Ḝ ḝ Ḟ ḟ 1e20 │ Ḡ ḡ Ḣ ḣ Ḥ ḥ Ḧ ḧ Ḩ ḩ Ḫ ḫ Ḭ ḭ Ḯ ḯ 1e30 │ Ḱ ḱ Ḳ ḳ Ḵ ḵ Ḷ ḷ Ḹ ḹ Ḻ ḻ Ḽ ḽ Ḿ ḿ 1e40 │ Ṁ ṁ Ṃ ṃ Ṅ ṅ Ṇ ṇ Ṉ ṉ Ṋ ṋ Ṍ ṍ Ṏ ṏ 1e50 │ Ṑ ṑ Ṓ ṓ Ṕ ṕ Ṗ ṗ Ṙ ṙ Ṛ ṛ Ṝ ṝ Ṟ ṟ 1e60 │ Ṡ ṡ Ṣ ṣ Ṥ ṥ Ṧ ṧ Ṩ ṩ Ṫ ṫ Ṭ ṭ Ṯ ṯ 1e70 │ Ṱ ṱ Ṳ ṳ Ṵ ṵ Ṷ ṷ Ṹ ṹ Ṻ ṻ Ṽ ṽ Ṿ ṿ 1e80 │ Ẁ ẁ Ẃ ẃ Ẅ ẅ Ẇ ẇ Ẉ ẉ Ẋ ẋ Ẍ ẍ Ẏ ẏ 1e90 │ Ẑ ẑ Ẓ ẓ Ẕ ẕ ẖ ẗ ẘ ẙ ẚ ẛ ẜ ẝ ẞ ẟ 1ea0 │ Ạ ạ Ả ả Ấ ấ Ầ ầ Ẩ ẩ Ẫ ẫ Ậ ậ Ắ ắ 1eb0 │ Ằ ằ Ẳ ẳ Ẵ ẵ Ặ ặ Ẹ ẹ Ẻ ẻ Ẽ ẽ Ế ế 1ec0 │ Ề ề Ể ể Ễ ễ Ệ ệ Ỉ ỉ Ị ị Ọ ọ Ỏ ỏ 1ed0 │ Ố ố Ồ ồ Ổ ổ Ỗ ỗ Ộ ộ Ớ ớ Ờ ờ Ở ở 1ee0 │ Ỡ ỡ Ợ ợ Ụ ụ Ủ ủ Ứ ứ Ừ ừ Ử ử Ữ ữ 1ef0 │ Ự ự Ỳ ỳ Ỵ ỵ Ỷ ỷ Ỹ ỹ Ỻ ỻ Ỽ ỽ Ỿ ỿ Greek Extended ═══════════════════════════════════════════════════════ 1f00 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 1f00 │ ἀ ἁ ἂ ἃ ἄ ἅ ἆ ἇ Ἀ Ἁ Ἂ Ἃ Ἄ Ἅ Ἆ Ἇ 1f10 │ ἐ ἑ ἒ ἓ ἔ ἕ Ἐ Ἑ Ἒ Ἓ Ἔ Ἕ 1f20 │ ἠ ἡ ἢ ἣ ἤ ἥ ἦ ἧ Ἠ Ἡ Ἢ Ἣ Ἤ Ἥ Ἦ Ἧ 1f30 │ ἰ ἱ ἲ ἳ ἴ ἵ ἶ ἷ Ἰ Ἱ Ἲ Ἳ Ἴ Ἵ Ἶ Ἷ 1f40 │ ὀ ὁ ὂ ὃ ὄ ὅ Ὀ Ὁ Ὂ Ὃ Ὄ Ὅ 1f50 │ ὐ ὑ ὒ ὓ ὔ ὕ ὖ ὗ Ὑ Ὓ Ὕ Ὗ 1f60 │ ὠ ὡ ὢ ὣ ὤ ὥ ὦ ὧ Ὠ Ὡ Ὢ Ὣ Ὤ Ὥ Ὦ Ὧ 1f70 │ ὰ ά ὲ έ ὴ ή ὶ ί ὸ ό ὺ ύ ὼ ώ 1f80 │ ᾀ ᾁ ᾂ ᾃ ᾄ ᾅ ᾆ ᾇ ᾈ ᾉ ᾊ ᾋ ᾌ ᾍ ᾎ ᾏ 1f90 │ ᾐ ᾑ ᾒ ᾓ ᾔ ᾕ ᾖ ᾗ ᾘ ᾙ ᾚ ᾛ ᾜ ᾝ ᾞ ᾟ 1fa0 │ ᾠ ᾡ ᾢ ᾣ ᾤ ᾥ ᾦ ᾧ ᾨ ᾩ ᾪ ᾫ ᾬ ᾭ ᾮ ᾯ 1fb0 │ ᾰ ᾱ ᾲ ᾳ ᾴ ᾶ ᾷ Ᾰ Ᾱ Ὰ Ά ᾼ 1fc0 │ ῁ ῂ ῃ ῄ ῆ ῇ Ὲ Έ Ὴ Ή ῌ ῍ ῎ ῏ 1fd0 │ ῐ ῑ ῒ ΐ ῖ ῗ Ῐ Ῑ Ὶ Ί ῝ ῞ ῟ 1fe0 │ ῠ ῡ ῢ ΰ ῤ ῥ ῦ ῧ Ῠ Ῡ Ὺ Ύ Ῥ ῭ ΅ ` 1ff0 │ ῲ ῳ ῴ ῶ ῷ Ὸ Ό Ὼ Ώ ῼ ´ General Punctuation ═══════════════════════════════════════════════════════ 2000 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 2010 │ ‐ ‑ ‒ – — ― ‖ ‗ ‘ ’ ‚ ‛ “ ” „ ‟ 2020 │ † ‡ • ‣ ․ ‥ … ‧ 2030 │ ‰ ‱ ′ ″ ‴ ‵ ‶ ‷ ‸ ‹ › ※ ‼ ‽ ‾ ‿ 2040 │ ⁀ ⁁ ⁂ ⁃ ⁄ ⁅ ⁆ ⁇ ⁈ ⁉ ⁊ ⁋ ⁌ ⁍ ⁎ ⁏ 2050 │ ⁐ ⁑ ⁒ ⁓ ⁔ ⁕ ⁖ ⁗ ⁘ ⁙ ⁚ ⁛ ⁜ ⁝ ⁞ Superscripts and Subscripts ═══════════════════════════════════════════════════════ 2070 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 2070 │ ⁰ ⁱ ⁴ ⁵ ⁶ ⁷ ⁸ ⁹ ⁺ ⁻ ⁼ ⁽ ⁾ ⁿ 2080 │ ₀ ₁ ₂ ₃ ₄ ₅ ₆ ₇ ₈ ₉ ₊ ₋ ₌ ₍ ₎ 2090 │ ₐ ₑ ₒ ₓ ₔ ₕ ₖ ₗ ₘ ₙ ₚ ₛ ₜ Currency Symbols ═══════════════════════════════════════════════════════ 20a0 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 20a0 │ ₣ ₤ ₩ ₪ € 20b0 │ ₱ ₲ ₳ ₵ ₹ ₺ ₽ ₿ Letterlike Symbols ═══════════════════════════════════════════════════════ 2100 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 2100 │ ℀ ℁ ℂ ℃ ℄ ℅ ℆ ℇ ℈ ℉ ℊ ℋ ℌ ℍ ℎ ℏ 2110 │ ℐ ℑ ℒ ℓ ℔ ℕ № ℗ ℘ ℙ ℚ ℛ ℜ ℝ ℞ ℟ 2120 │ ℠ ℡ ™ ℣ ℤ ℥ Ω ℧ ℨ ℩ K Å ℬ ℭ ℮ ℯ 2130 │ ℰ ℱ Ⅎ ℳ ℴ ℵ ℶ ℷ ℸ ℹ ℺ ℻ ℼ ℽ ℾ ℿ 2140 │ ⅀ ⅁ ⅂ ⅃ ⅄ ⅅ ⅆ ⅇ ⅈ ⅉ ⅊ ⅋ ⅌ ⅍ ⅎ ⅏ Number Forms ═══════════════════════════════════════════════════════ 2150 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 2150 │ ⅐ ⅑ ⅒ ⅓ ⅔ ⅕ ⅖ ⅗ ⅘ ⅙ ⅚ ⅛ ⅜ ⅝ ⅞ ⅟ 2160 │ Ⅰ Ⅱ Ⅲ Ⅳ Ⅴ Ⅵ Ⅶ Ⅷ Ⅸ Ⅹ Ⅺ Ⅻ Ⅼ Ⅽ Ⅾ Ⅿ 2170 │ ⅰ ⅱ ⅲ ⅳ ⅴ ⅵ ⅶ ⅷ ⅸ ⅹ ⅺ ⅻ ⅼ ⅽ ⅾ ⅿ 2180 │ ↀ ↁ ↂ Ↄ ↄ ↅ ↆ ↇ ↈ ↉ ↊ ↋ Arrows ═══════════════════════════════════════════════════════ 2190 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 2190 │ ← ↑ → ↓ ↔ ↕ ↖ ↗ ↘ ↙ ↚ ↛ ↜ ↝ ↞ ↟ 21a0 │ ↠ ↡ ↢ ↣ ↤ ↥ ↦ ↧ ↨ ↩ ↪ ↫ ↬ ↭ ↮ ↯ 21b0 │ ↰ ↱ ↲ ↳ ↴ ↵ ↶ ↷ ↸ ↹ ↺ ↻ ↼ ↽ ↾ ↿ 21c0 │ ⇀ ⇁ ⇂ ⇃ ⇄ ⇅ ⇆ ⇇ ⇈ ⇉ ⇊ ⇋ ⇌ ⇍ ⇎ ⇏ 21d0 │ ⇐ ⇑ ⇒ ⇓ ⇔ ⇕ ⇖ ⇗ ⇘ ⇙ ⇚ ⇛ ⇜ ⇝ ⇞ ⇟ 21e0 │ ⇠ ⇡ ⇢ ⇣ ⇤ ⇥ ⇦ ⇧ ⇨ ⇩ ⇪ ⇫ ⇬ ⇭ ⇮ ⇯ 21f0 │ ⇰ ⇱ ⇲ ⇳ ⇴ ⇵ ⇶ ⇷ ⇸ ⇹ ⇺ ⇻ ⇼ ⇽ ⇾ ⇿ Mathematical Operators ═══════════════════════════════════════════════════════ 2200 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 2200 │ ∀ ∁ ∂ ∃ ∄ ∅ ∆ ∇ ∈ ∉ ∊ ∋ ∌ ∍ ∎ ∏ 2210 │ ∐ ∑ − ∓ ∔ ∕ ∖ ∗ ∘ ∙ √ ∛ ∜ ∝ ∞ ∟ 2220 │ ∠ ∡ ∢ ∣ ∤ ∥ ∦ ∧ ∨ ∩ ∪ ∫ ∬ ∭ ∮ ∯ 2230 │ ∰ ∱ ∲ ∳ ∴ ∵ ∶ ∷ ∸ ∹ ∺ ∻ ∼ ∽ ∾ ∿ 2240 │ ≀ ≁ ≂ ≃ ≄ ≅ ≆ ≇ ≈ ≉ ≊ ≋ ≌ ≍ ≎ ≏ 2250 │ ≐ ≑ ≒ ≓ ≔ ≕ ≖ ≗ ≘ ≙ ≚ ≛ ≜ ≝ ≞ ≟ 2260 │ ≠ ≡ ≢ ≣ ≤ ≥ ≦ ≧ ≨ ≩ ≪ ≫ ≬ ≭ ≮ ≯ 2270 │ ≰ ≱ ≲ ≳ ≴ ≵ ≶ ≷ ≸ ≹ ≺ ≻ ≼ ≽ ≾ ≿ 2280 │ ⊀ ⊁ ⊂ ⊃ ⊄ ⊅ ⊆ ⊇ ⊈ ⊉ ⊊ ⊋ ⊌ ⊍ ⊎ ⊏ 2290 │ ⊐ ⊑ ⊒ ⊓ ⊔ ⊕ ⊖ ⊗ ⊘ ⊙ ⊚ ⊛ ⊜ ⊝ ⊞ ⊟ 22a0 │ ⊠ ⊡ ⊢ ⊣ ⊤ ⊥ ⊦ ⊧ ⊨ ⊩ ⊪ ⊫ ⊬ ⊭ ⊮ ⊯ 22b0 │ ⊰ ⊱ ⊲ ⊳ ⊴ ⊵ ⊶ ⊷ ⊸ ⊹ ⊺ ⊻ ⊼ ⊽ ⊾ ⊿ 22c0 │ ⋀ ⋁ ⋂ ⋃ ⋄ ⋅ ⋆ ⋇ ⋈ ⋉ ⋊ ⋋ ⋌ ⋍ ⋎ ⋏ 22d0 │ ⋐ ⋑ ⋒ ⋓ ⋔ ⋕ ⋖ ⋗ ⋘ ⋙ ⋚ ⋛ ⋜ ⋝ ⋞ ⋟ 22e0 │ ⋠ ⋡ ⋢ ⋣ ⋤ ⋥ ⋦ ⋧ ⋨ ⋩ ⋪ ⋫ ⋬ ⋭ ⋮ ⋯ 22f0 │ ⋰ ⋱ ⋲ ⋳ ⋴ ⋵ ⋶ ⋷ ⋸ ⋹ ⋺ ⋻ ⋼ ⋽ ⋾ ⋿ Miscellaneous Technical ═══════════════════════════════════════════════════════ 2300 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 2300 │ ⌀ ⌁ ⌂ ⌃ ⌄ ⌅ ⌆ ⌇ ⌈ ⌉ ⌊ ⌋ ⌌ ⌍ ⌎ ⌏ 2310 │ ⌐ ⌑ ⌒ ⌓ ⌔ ⌕ ⌖ ⌗ ⌘ ⌙ ⌚ ⌛ ⌜ ⌝ ⌞ ⌟ 2320 │ ⌠ ⌡ ⌢ ⌣ ⌤ ⌥ ⌦ ⌧ ⌨ 〈 〉 ⌫ ⌬ 2330 │ ⌴ ⌶ ⌷ ⌸ ⌹ ⌺ ⌻ ⌼ ⌽ ⌾ ⌿ 2340 │ ⍀ ⍁ ⍂ ⍃ ⍄ ⍅ ⍆ ⍇ ⍈ ⍉ ⍊ ⍋ ⍌ ⍍ ⍎ ⍏ 2350 │ ⍐ ⍑ ⍒ ⍓ ⍔ ⍕ ⍖ ⍗ ⍘ ⍙ ⍚ ⍛ ⍜ ⍝ ⍞ ⍟ 2360 │ ⍠ ⍡ ⍢ ⍣ ⍤ ⍥ ⍦ ⍧ ⍨ ⍩ ⍪ ⍫ ⍬ ⍭ ⍮ ⍯ 2370 │ ⍱ ⍲ ⍳ ⍴ ⍵ ⍶ ⍷ ⍸ ⍹ ⍺ ⍽ 2380 │ ⎀ ⎁ ⎂ ⎃ ⎄ ⎅ ⎆ ⎇ ⎈ ⎉ ⎊ ⎋ ⎌ ⎍ ⎎ ⎏ 2390 │ ⎐ ⎑ ⎒ ⎓ ⎔ ⎕ ⎖ ⎗ ⎘ ⎙ ⎚ ⎛ ⎜ ⎝ ⎞ ⎟ 23a0 │ ⎠ ⎡ ⎢ ⎣ ⎤ ⎥ ⎦ ⎧ ⎨ ⎩ ⎪ ⎫ ⎬ ⎭ ⎮ ⎯ 23b0 │ ⎰ ⎱ ⎲ ⎳ ⎴ ⎵ ⎶ ⎷ ⎸ ⎹ ⎺ ⎻ ⎼ ⎽ 23c0 │ ⏏ 23d0 │ ⏐ ⏜ ⏝ ⏞ ⏟ 23e0 │ ⏠ ⏡ ⏩ ⏪ ⏫ ⏬ ⏭ ⏮ ⏯ 23f0 │ ⏰ ⏱ ⏲ ⏳ ⏸ ⏹ ⏺ ⏻ ⏼ ⏽ ⏾ Control Pictures ═══════════════════════════════════════════════════════ 2400 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 2400 │ ␀ ␁ ␂ ␃ ␄ ␅ ␆ ␇ ␈ ␉ ␊ ␋ ␌ ␍ ␎ ␏ 2410 │ ␐ ␑ ␒ ␓ ␔ ␕ ␖ ␗ ␘ ␙ ␚ ␛ ␜ ␝ ␞ ␟ 2420 │ ␠ ␡ ␢ ␣ ␤ ␥ ␦ Enclosed Alphanumerics ═══════════════════════════════════════════════════════ 2460 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 2460 │ ① ② ③ ④ ⑤ ⑥ ⑦ ⑧ ⑨ ⑩ ⑪ ⑫ ⑬ ⑭ ⑮ ⑯ 2470 │ ⑰ ⑱ ⑲ ⑳ ⑴ ⑵ ⑶ ⑷ ⑸ ⑹ ⑺ ⑻ ⑼ ⑽ ⑾ ⑿ 2480 │ ⒀ ⒁ ⒂ ⒃ ⒄ ⒅ ⒆ ⒇ 24b0 │ Ⓐ Ⓑ Ⓒ Ⓓ Ⓔ Ⓕ Ⓖ Ⓗ Ⓘ Ⓙ 24c0 │ Ⓚ Ⓛ Ⓜ Ⓝ Ⓞ Ⓟ Ⓠ Ⓡ Ⓢ Ⓣ Ⓤ Ⓥ Ⓦ Ⓧ Ⓨ Ⓩ 24d0 │ ⓐ ⓑ ⓒ ⓓ ⓔ ⓕ ⓖ ⓗ ⓘ ⓙ ⓚ ⓛ ⓜ ⓝ ⓞ ⓟ 24e0 │ ⓠ ⓡ ⓢ ⓣ ⓤ ⓥ ⓦ ⓧ ⓨ ⓩ ⓪ Box Drawing ═══════════════════════════════════════════════════════ 2500 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 2500 │ ─ ━ │ ┃ ┄ ┅ ┆ ┇ ┈ ┉ ┊ ┋ ┌ ┍ ┎ ┏ 2510 │ ┐ ┑ ┒ ┓ └ ┕ ┖ ┗ ┘ ┙ ┚ ┛ ├ ┝ ┞ ┟ 2520 │ ┠ ┡ ┢ ┣ ┤ ┥ ┦ ┧ ┨ ┩ ┪ ┫ ┬ ┭ ┮ ┯ 2530 │ ┰ ┱ ┲ ┳ ┴ ┵ ┶ ┷ ┸ ┹ ┺ ┻ ┼ ┽ ┾ ┿ 2540 │ ╀ ╁ ╂ ╃ ╄ ╅ ╆ ╇ ╈ ╉ ╊ ╋ ╌ ╍ ╎ ╏ 2550 │ ═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟ 2560 │ ╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬ ╭ ╮ ╯ 2570 │ ╰ ╱ ╲ ╳ ╴ ╵ ╶ ╷ ╸ ╹ ╺ ╻ ╼ ╽ ╾ ╿ Block Elements ═══════════════════════════════════════════════════════ 2580 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 2580 │ ▀ ▁ ▂ ▃ ▄ ▅ ▆ ▇ █ ▉ ▊ ▋ ▌ ▍ ▎ ▏ 2590 │ ▐ ░ ▒ ▓ ▔ ▕ ▖ ▗ ▘ ▙ ▚ ▛ ▜ ▝ ▞ ▟ Geometric Shapes ═══════════════════════════════════════════════════════ 25a0 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 25a0 │ ■ □ ▢ ▣ ▤ ▥ ▦ ▧ ▨ ▩ ▪ ▫ ▬ ▭ ▮ ▯ 25b0 │ ▰ ▱ ▲ △ ▴ ▵ ▶ ▷ ▸ ▹ ► ▻ ▼ ▽ ▾ ▿ 25c0 │ ◀ ◁ ◂ ◃ ◄ ◅ ◆ ◇ ◈ ◉ ◊ ○ ◌ ◍ ◎ ● 25d0 │ ◐ ◑ ◒ ◓ ◔ ◕ ◖ ◗ ◘ ◙ ◚ ◛ ◜ ◝ ◞ ◟ 25e0 │ ◠ ◡ ◢ ◣ ◤ ◥ ◦ ◧ ◨ ◩ ◪ ◫ ◬ ◭ ◮ ◯ 25f0 │ ◰ ◱ ◲ ◳ ◴ ◵ ◶ ◷ ◸ ◹ ◺ ◻ ◼ ◽ ◾ ◿ Miscellaneous Symbols ═══════════════════════════════════════════════════════ 2600 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 2600 │ ☀ ☁ ☂ ☃ ☄ ★ ☆ ☇ ☈ ☉ ☊ ☋ ☌ ☍ ☎ ☏ 2610 │ ☐ ☑ ☒ ☓ ☔ ☕ ☖ ☗ ☘ ☚ ☛ ☜ ☝ ☞ ☟ 2620 │ ☠ ☡ ☢ ☣ ☤ ☥ ☦ ☧ ☨ ☩ ☪ ☭ ☮ ☯ 2630 │ ☰ ☱ ☲ ☳ ☴ ☵ ☶ ☷ ☹ ☺ ☻ ☼ ☽ ☾ ☿ 2640 │ ♀ ♁ ♂ ♃ ♄ ♅ ♆ ♇ ♈ ♉ ♊ ♋ ♌ ♍ ♎ ♏ 2650 │ ♐ ♑ ♒ ♓ ♔ ♕ ♖ ♗ ♘ ♙ ♚ ♛ ♜ ♝ ♞ ♟ 2660 │ ♠ ♡ ♢ ♣ ♤ ♥ ♦ ♧ ♩ ♪ ♫ ♬ ♭ ♮ ♯ 2670 │ ♳ ♴ ♵ ♶ ♷ ♸ ♹ ♺ 2680 │ ⚀ ⚁ ⚂ ⚃ ⚄ ⚅ ⚆ ⚇ ⚈ ⚉ ⚊ ⚋ ⚌ ⚍ ⚎ ⚏ 2690 │ ⚐ ⚑ ⚒ ⚙ 26a0 │ ⚠ ⚡ ⚢ ⚣ ⚤ ⚥ ⚦ ⚧ ⚨ ⚪ ⚫ ⚬ ⚭ ⚮ ⚯ 26b0 │ ⚰ ⚱ ⚲ ⚳ ⚴ ⚵ ⚶ ⚷ ⚸ ⚹ ⚺ ⚻ ⚼ ⚽ 26d0 │ ⛔ Dingbats ═══════════════════════════════════════════════════════ 2700 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 2700 │ ✁ ✂ ✃ ✈ 2710 │ ✓ ✔ ✘ ✚ 2720 │ ✭ 2740 │ ❌ 2750 │ ❘ ❙ ❚ 2760 │ ❨ ❩ ❪ ❫ ❬ ❭ ❮ ❯ 2770 │ ❰ ❱ ❲ ❳ ❴ ❵ ❶ ❷ ❸ ❹ ❺ ❻ ❼ ❽ ❾ ❿ 2780 │ ➀ ➁ ➂ ➃ ➄ ➅ ➆ ➇ ➈ ➉ ➊ ➋ ➌ ➍ ➎ ➏ 2790 │ ➐ ➑ ➒ ➓ ➔ ➕ ➖ ➗ ➘ ➙ ➚ ➛ ➜ ➝ ➞ ➟ 27a0 │ ➠ ➡ ➢ ➣ ➤ ➥ ➦ ➧ ➨ ➩ ➪ ➫ ➬ ➭ ➮ ➯ 27b0 │ ➰ ➱ ➲ ➳ ➴ ➵ ➶ ➷ ➸ ➹ ➺ ➻ ➼ ➽ ➾ ➿ Miscellaneous Mathematical Symbols-A ═══════════════════════════════════════════════════════ 27c0 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 27c0 │ ⟀ ⟁ ⟂ ⟃ ⟄ ⟅ ⟆ ⟇ ⟈ ⟉ ⟊ ⟌ 27d0 │ ⟐ ⟑ ⟒ ⟓ ⟔ ⟕ ⟖ ⟗ ⟘ ⟙ ⟚ ⟛ ⟜ ⟝ ⟞ ⟟ 27e0 │ ⟠ ⟡ ⟢ ⟣ ⟤ ⟥ ⟦ ⟧ ⟨ ⟩ ⟪ ⟫ ⟬ ⟭ ⟮ ⟯ Supplemental Arrows-A ═══════════════════════════════════════════════════════ 27f0 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 27f0 │ ⟰ ⟱ ⟲ ⟳ ⟴ ⟵ ⟶ ⟷ ⟸ ⟹ ⟺ ⟻ ⟼ ⟽ ⟾ ⟿ Braille Patterns ═══════════════════════════════════════════════════════ 2800 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 2800 │ ⠁ ⠂ ⠃ ⠄ ⠅ ⠆ ⠇ ⠈ ⠉ ⠊ ⠋ ⠌ ⠍ ⠎ ⠏ 2810 │ ⠐ ⠑ ⠒ ⠓ ⠔ ⠕ ⠖ ⠗ ⠘ ⠙ ⠚ ⠛ ⠜ ⠝ ⠞ ⠟ 2820 │ ⠠ ⠡ ⠢ ⠣ ⠤ ⠥ ⠦ ⠧ ⠨ ⠩ ⠪ ⠫ ⠬ ⠭ ⠮ ⠯ 2830 │ ⠰ ⠱ ⠲ ⠳ ⠴ ⠵ ⠶ ⠷ ⠸ ⠹ ⠺ ⠻ ⠼ ⠽ ⠾ ⠿ 2840 │ ⡀ ⡁ ⡂ ⡃ ⡄ ⡅ ⡆ ⡇ ⡈ ⡉ ⡊ ⡋ ⡌ ⡍ ⡎ ⡏ 2850 │ ⡐ ⡑ ⡒ ⡓ ⡔ ⡕ ⡖ ⡗ ⡘ ⡙ ⡚ ⡛ ⡜ ⡝ ⡞ ⡟ 2860 │ ⡠ ⡡ ⡢ ⡣ ⡤ ⡥ ⡦ ⡧ ⡨ ⡩ ⡪ ⡫ ⡬ ⡭ ⡮ ⡯ 2870 │ ⡰ ⡱ ⡲ ⡳ ⡴ ⡵ ⡶ ⡷ ⡸ ⡹ ⡺ ⡻ ⡼ ⡽ ⡾ ⡿ 2880 │ ⢀ ⢁ ⢂ ⢃ ⢄ ⢅ ⢆ ⢇ ⢈ ⢉ ⢊ ⢋ ⢌ ⢍ ⢎ ⢏ 2890 │ ⢐ ⢑ ⢒ ⢓ ⢔ ⢕ ⢖ ⢗ ⢘ ⢙ ⢚ ⢛ ⢜ ⢝ ⢞ ⢟ 28a0 │ ⢠ ⢡ ⢢ ⢣ ⢤ ⢥ ⢦ ⢧ ⢨ ⢩ ⢪ ⢫ ⢬ ⢭ ⢮ ⢯ 28b0 │ ⢰ ⢱ ⢲ ⢳ ⢴ ⢵ ⢶ ⢷ ⢸ ⢹ ⢺ ⢻ ⢼ ⢽ ⢾ ⢿ 28c0 │ ⣀ ⣁ ⣂ ⣃ ⣄ ⣅ ⣆ ⣇ ⣈ ⣉ ⣊ ⣋ ⣌ ⣍ ⣎ ⣏ 28d0 │ ⣐ ⣑ ⣒ ⣓ ⣔ ⣕ ⣖ ⣗ ⣘ ⣙ ⣚ ⣛ ⣜ ⣝ ⣞ ⣟ 28e0 │ ⣠ ⣡ ⣢ ⣣ ⣤ ⣥ ⣦ ⣧ ⣨ ⣩ ⣪ ⣫ ⣬ ⣭ ⣮ ⣯ 28f0 │ ⣰ ⣱ ⣲ ⣳ ⣴ ⣵ ⣶ ⣷ ⣸ ⣹ ⣺ ⣻ ⣼ ⣽ ⣾ ⣿ Supplemental Arrows-B ═══════════════════════════════════════════════════════ 2900 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 2900 │ ⤆ ⤇ ⤈ ⤉ ⤊ ⤋ 2910 │ ⤒ ⤓ ⤙ ⤚ ⤛ ⤜ 2930 │ ⤸ 2940 │ ⥀ ⥁ ⥂ ⥃ ⥄ ⥅ ⥆ ⥉ ⥊ ⥋ ⥌ ⥍ ⥎ ⥏ 2950 │ ⥐ ⥑ ⥒ ⥓ ⥔ ⥕ ⥖ ⥗ ⥘ ⥙ ⥚ ⥛ ⥜ ⥝ ⥞ ⥟ 2960 │ ⥠ ⥡ ⥢ ⥣ ⥤ ⥥ ⥦ ⥧ ⥨ ⥩ ⥪ ⥫ ⥬ ⥭ ⥮ ⥯ 2970 │ ⥰ ⥱ ⥲ ⥳ ⥴ ⥵ ⥶ ⥷ ⥸ ⥹ ⥺ ⥻ ⥼ ⥽ ⥾ ⥿ Miscellaneous Mathematical Symbols-B ═══════════════════════════════════════════════════════ 2980 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 2980 │ ⦀ ⦁ ⦂ ⦃ ⦄ ⦅ ⦆ ⦇ ⦈ ⦉ ⦊ ⦋ ⦌ ⦍ ⦎ ⦏ 2990 │ ⦐ ⦑ ⦒ ⦓ ⦔ ⦗ ⦘ ⦙ ⦚ ⦜ 29b0 │ ⦻ ⦼ ⦽ ⦾ ⦿ 29c0 │ ⧊ ⧋ ⧎ ⧏ 29d0 │ ⧐ ⧑ ⧒ ⧓ ⧔ ⧕ ⧖ ⧗ ⧘ ⧙ ⧚ ⧛ ⧜ ⧞ 29e0 │ ⧣ ⧤ ⧥ ⧦ ⧧ ⧨ ⧩ ⧪ ⧫ ⧬ ⧭ ⧮ ⧯ 29f0 │ ⧰ ⧱ ⧲ ⧳ ⧴ ⧵ ⧶ ⧷ ⧸ ⧹ ⧺ ⧻ ⧼ ⧽ ⧾ ⧿ Supplemental Mathematical Operators ═══════════════════════════════════════════════════════ 2a00 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 2a00 │ ⨀ ⨁ ⨂ ⨍ ⨎ ⨏ 2a10 │ ⨐ ⨑ ⨒ ⨓ ⨔ ⨕ ⨖ ⨗ ⨘ ⨙ ⨚ ⨛ ⨜ ⨟ 2a20 │ ⨡ ⨢ ⨣ ⨤ ⨥ ⨦ ⨧ ⨨ ⨩ ⨪ ⨫ ⨬ ⨭ ⨮ ⨯ 2a30 │ ⨰ ⨱ ⨲ ⨳ ⨴ ⨵ ⨼ ⨽ ⨾ ⨿ 2a40 │ ⩀ ⩁ ⩂ ⩃ ⩄ ⩅ ⩆ ⩇ ⩈ ⩉ ⩌ ⩍ ⩎ ⩏ 2a50 │ ⩑ ⩒ ⩓ ⩔ ⩕ ⩖ ⩗ ⩘ ⩙ ⩚ ⩛ ⩜ ⩝ ⩞ ⩟ 2a60 │ ⩠ ⩡ ⩢ ⩣ ⩤ ⩥ ⩦ ⩧ ⩨ ⩩ ⩪ ⩫ ⩬ ⩭ ⩮ ⩯ 2a70 │ ⩰ ⩱ ⩲ ⩳ ⩷ ⩹ ⩺ ⩻ ⩼ ⩽ ⩾ ⩿ 2a80 │ ⪀ ⪁ ⪂ ⪃ ⪄ ⪅ ⪆ ⪇ ⪈ ⪉ ⪊ ⪋ ⪌ ⪍ ⪎ ⪏ 2a90 │ ⪐ ⪑ ⪒ ⪓ ⪔ ⪕ ⪖ ⪗ ⪘ ⪙ ⪚ ⪛ ⪜ ⪝ ⪞ ⪟ 2aa0 │ ⪠ ⪡ ⪢ ⪣ ⪤ ⪦ ⪧ ⪨ ⪩ ⪪ ⪫ ⪬ ⪭ ⪮ ⪯ 2ab0 │ ⪰ ⪱ ⪲ ⪳ ⪴ ⪵ ⪶ ⪷ ⪸ ⪹ ⪺ ⪽ ⪾ ⪿ 2ac0 │ ⫀ ⫁ ⫂ ⫃ ⫄ ⫅ ⫆ ⫇ ⫈ ⫉ ⫊ ⫋ ⫌ ⫏ 2ad0 │ ⫐ ⫑ ⫒ ⫓ ⫔ ⫕ ⫖ ⫙ ⫚ ⫛ ⫝̸ ⫝ ⫞ 2ae0 │ ⫬ ⫭ ⫮ ⫯ 2af0 │ ⫰ ⫱ ⫲ ⫳ ⫴ ⫵ ⫶ ⫹ ⫺ ⫻ ⫼ ⫽ ⫾ ⫿ Miscellaneous Symbols and Arrows ═══════════════════════════════════════════════════════ 2b00 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 2b00 │ ⬀ ⬁ ⬂ ⬃ ⬅ ⬆ ⬇ ⬈ ⬉ ⬊ ⬋ ⬍ ⬎ ⬏ 2b10 │ ⬐ ⬑ ⬒ ⬓ ⬔ ⬕ ⬖ ⬗ ⬘ ⬙ ⬚ ⬛ ⬜ ⬝ ⬞ ⬟ 2b20 │ ⬥ ⬦ ⬧ ⬨ ⬩ ⬪ ⬫ ⬮ ⬯ 2b30 │ ⬱ 2b40 │ ⭍ ⭎ ⭏ 2b50 │ ⭐ ⭑ ⭒ ⭖ ⭗ ⭘ ⭙ ⭚ ⭛ ⭜ ⭝ ⭞ ⭟ 2b60 │ ⭠ ⭡ ⭢ ⭣ ⭤ ⭥ ⭦ ⭧ ⭨ ⭩ ⭪ ⭫ ⭬ ⭭ ⭮ ⭯ 2b70 │ ⭱ ⭳ ⭿ 2b80 │ ⮀ ⮁ ⮂ ⮃ ⮄ ⮅ ⮆ ⮇ ⮈ ⮊ ⮌ ⮍ ⮎ ⮏ 2b90 │ ⮕ ⮘ ⮙ ⮚ ⮛ ⮜ ⮝ ⮞ ⮟ 2ba0 │ ⮠ ⮡ ⮢ ⮣ ⮤ ⮥ ⮦ ⮧ ⮨ ⮩ ⮪ ⮫ ⮬ ⮭ ⮮ ⮯ 2bb0 │ ⮸ ⮽ 2bc0 │ ⯀ ⯁ ⯂ ⯃ ⯅ ⯆ ⯇ ⯈ ⯌ ⯍ ⯎ ⯏ 2be0 │ ⯭ ⯯ Latin Extended-C ═══════════════════════════════════════════════════════ 2c60 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 2c70 │ ⱱ ⱼ ⱽ Supplemental Punctuation ═══════════════════════════════════════════════════════ 2e00 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 2e20 │ ⸮ Bopomofo ═══════════════════════════════════════════════════════ 3100 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 3100 │ ㄅ ㄆ ㄇ ㄈ ㄉ ㄊ ㄋ ㄌ ㄍ ㄎ ㄏ 3110 │ ㄐ ㄑ ㄒ ㄓ ㄔ ㄕ ㄖ ㄗ ㄘ ㄙ ㄚ ㄛ ㄜ ㄝ ㄞ ㄟ 3120 │ ㄠ ㄡ ㄢ ㄣ ㄤ ㄥ ㄦ ㄧ ㄨ ㄩ Private Use Area ═══════════════════════════════════════════════════════ e000 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── e0a0 │       e0b0 │                 e1c0 │       e4c0 │              e8c0 │   e900 │         e920 │        e930 │     e940 │          e950 │  e960 │     e970 │      e980 │             e990 │       e9a0 │         e9b0 │                 e9c0 │                 e9d0 │                 e9e0 │                 e9f0 │            ea00 │           ea10 │    ea20 │            ea40 │              ea50 │     ea60 │                ea70 │     ea80 │   ea90 │   eb00 │             eb20 │              eb30 │            eb40 │                 eb50 │                 eb60 │                 eb70 │     eb80 │                 eb90 │                 eba0 │                 ebb0 │                 ebc0 │           ebe0 │                 ebf0 │                 ec00 │                 ec10 │                 ec20 │                 ec30 │                 ec40 │          eca0 │                ecc0 │                 ecd0 │            ece0 │                 ecf0 │                 ed00 │                 ed10 │     ed20 │                 ed30 │                 ed40 │                 ed50 │                 ed60 │           ed80 │                 ed90 │                 eda0 │                 edb0 │                 edc0 │                 edd0 │                 ede0 │          Alphabetic Presentation Forms ═══════════════════════════════════════════════════════ fb00 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── fb00 │ fi fl fb20 │ ﬩ CJK Compatibility Forms ═══════════════════════════════════════════════════════ fe30 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── fe30 │ ︰ ︱ ︲ ︳ ︿ fe40 │ ﹀ ﹁ ﹂ ﹇ ﹈ Small Form Variants ═══════════════════════════════════════════════════════ fe50 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── fe50 │ ﹐ ﹑ ﹒ ﹔ ﹕ ﹖ ﹗ ﹘ ﹙ ﹚ ﹛ ﹜ ﹝ ﹞ ﹟ fe60 │ ﹠ ﹡ ﹢ ﹣ ﹤ ﹥ ﹦ ﹨ ﹩ ﹪ ﹫ Halfwidth and Fullwidth Forms ═══════════════════════════════════════════════════════ ff00 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── ff00 │ ! " # $ % & ' ( ) * + , - . / ff10 │ 0 1 2 3 4 5 6 7 8 9 : ; < = > ? ff20 │ @ A B C D E F G H I J K L M N O ff30 │ P Q R S T U V W X Y Z [ \ ] ^ _ ff40 │ ` a b c d e f g h i j k l m n o ff50 │ p q r s t u v w x y z { | } ~ ff60 │ 。 「 」 、 ・ ffe0 │ ¢ £ ¬  ̄ ¦ ¥ ₩ │ ← ↑ → ↓ ■ ○ Specials ═══════════════════════════════════════════════════════ fff0 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── fff0 │     � _ _ __ _ ___| |_ _ __ __ _| | / _` / __| __| '__/ _` | | | (_| \__ \ |_| | | (_| | | \__,_|___/\__|.| \__,_|_| _ __ | | __ _ _ __ ___ ___ | '_ \| |/ _` | '_ \ / _ \/ __| | |_) | | (_| | | | | __/\__ \ | .__/|_|\__,_|_| |_|\___||___/ |_| Old Italic ═══════════════════════════════════════════════════════ 10300 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 10300 │ 𐌀 𐌁 𐌂 𐌃 𐌄 𐌅 𐌆 𐌇 𐌈 𐌉 𐌊 𐌋 𐌌 𐌍 𐌎 𐌏 10310 │ 𐌐 𐌑 𐌒 𐌓 𐌔 𐌕 𐌖 𐌗 𐌘 𐌙 𐌚 𐌛 𐌜 𐌝 𐌞 𐌟 10320 │ 𐌠 𐌡 𐌢 𐌣 Gothic ═══════════════════════════════════════════════════════ 10330 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 10330 │ 𐌰 𐌱 𐌲 𐌳 𐌴 𐌵 𐌶 𐌷 𐌸 𐌹 𐌺 𐌻 𐌼 𐌽 𐌾 𐌿 10340 │ 𐍀 𐍁 𐍂 𐍃 𐍄 𐍅 𐍆 𐍇 𐍈 𐍉 𐍊 Deseret ═══════════════════════════════════════════════════════ 10400 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 10400 │ 𐐀 𐐁 𐐂 𐐃 𐐄 𐐅 𐐆 𐐇 𐐈 𐐉 𐐊 𐐋 𐐌 𐐍 𐐎 𐐏 10410 │ 𐐐 𐐑 𐐒 𐐓 𐐔 𐐕 𐐖 𐐗 𐐘 𐐙 𐐚 𐐛 𐐜 𐐝 𐐞 𐐟 10420 │ 𐐠 𐐡 𐐢 𐐣 𐐤 𐐥 𐐦 𐐧 𐐨 𐐩 𐐪 𐐫 𐐬 𐐭 𐐮 𐐯 10430 │ 𐐰 𐐱 𐐲 𐐳 𐐴 𐐵 𐐶 𐐷 𐐸 𐐹 𐐺 𐐻 𐐼 𐐽 𐐾 𐐿 10440 │ 𐑀 𐑁 𐑂 𐑃 𐑄 𐑅 𐑆 𐑇 𐑈 𐑉 𐑊 𐑋 𐑌 𐑍 𐑎 𐑏 Osmanya ═══════════════════════════════════════════════════════ 10480 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 10480 │ 𐒀 𐒁 𐒂 𐒃 𐒄 𐒅 𐒆 𐒇 𐒈 𐒉 𐒊 𐒋 𐒌 𐒍 𐒎 𐒏 10490 │ 𐒐 𐒑 𐒒 𐒓 𐒔 𐒕 𐒖 𐒗 𐒘 𐒙 𐒚 𐒛 𐒜 𐒝 Osage ═══════════════════════════════════════════════════════ 104b0 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 104b0 │ 𐒰 𐒱 𐒲 𐒳 𐒴 𐒵 𐒶 𐒷 𐒸 𐒹 𐒺 𐒻 𐒼 𐒽 𐒾 𐒿 104c0 │ 𐓀 𐓁 𐓂 𐓃 𐓄 𐓅 𐓆 𐓇 𐓈 𐓉 𐓊 𐓋 𐓌 𐓍 𐓎 𐓏 104d0 │ 𐓐 𐓑 𐓒 𐓓 𐓘 𐓙 𐓚 𐓛 𐓜 𐓝 𐓞 𐓟 104e0 │ 𐓠 𐓡 𐓢 𐓣 𐓤 𐓥 𐓦 𐓧 𐓨 𐓩 𐓪 𐓫 𐓬 𐓭 𐓮 𐓯 104f0 │ 𐓰 𐓱 𐓲 𐓳 𐓴 𐓵 𐓶 𐓷 𐓸 𐓹 𐓺 𐓻 Brahmi ═══════════════════════════════════════════════════════ 11000 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 11000 │ 𑀃 𑀄 𑀅 𑀆 𑀇 𑀈 𑀉 𑀊 𑀋 𑀌 𑀍 𑀎 𑀏 11010 │ 𑀐 𑀑 𑀒 𑀓 𑀔 𑀕 𑀖 𑀗 𑀘 𑀙 𑀚 𑀛 𑀜 𑀝 𑀞 𑀟 11020 │ 𑀠 𑀡 𑀢 𑀣 𑀤 𑀥 𑀦 𑀧 𑀨 𑀩 𑀪 𑀫 𑀬 𑀭 𑀮 𑀯 11030 │ 𑀰 𑀱 𑀲 𑀳 𑀴 𑀵 𑀶 𑀷 11040 │ 𑁇 𑁈 𑁉 𑁊 𑁋 𑁌 𑁍 11050 │ 𑁒 𑁓 𑁔 𑁕 𑁖 𑁗 𑁘 𑁙 𑁚 𑁛 𑁜 𑁝 𑁞 𑁟 11060 │ 𑁠 𑁡 𑁢 𑁣 𑁤 𑁥 𑁦 𑁧 𑁨 𑁩 𑁪 𑁫 𑁬 𑁭 𑁮 𑁯 Sinhala Archaic Numbers ═══════════════════════════════════════════════════════ 111e0 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 111e0 │ 𑇡 𑇢 𑇣 𑇤 𑇥 𑇦 𑇧 𑇨 𑇩 𑇪 𑇫 𑇬 𑇭 𑇮 𑇯 111f0 │ 𑇰 𑇱 𑇲 𑇳 𑇴 Egyptian Hieroglyphs ═══════════════════════════════════════════════════════ 13000 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 13000 │ 𓀀 𓀁 𓀂 𓀃 𓀄 𓀅 𓀆 𓀇 𓀈 𓀉 𓀊 𓀋 𓀌 𓀍 𓀎 𓀏 13010 │ 𓀐 𓀑 𓀒 𓀓 𓀔 𓀕 𓀖 𓀗 𓀘 𓀙 𓀚 𓀛 𓀜 𓀝 𓀞 𓀟 13020 │ 𓀠 𓀡 𓀢 𓀣 𓀤 𓀥 𓀦 𓀧 𓀨 𓀩 𓀪 𓀫 𓀬 𓀭 𓀮 𓀯 13030 │ 𓀰 𓀱 𓀲 𓀳 𓀴 𓀵 𓀶 𓀷 𓀸 𓀹 𓀺 𓀻 𓀼 𓀽 𓀾 𓀿 13040 │ 𓁀 𓁁 𓁂 𓁃 𓁄 𓁅 𓁆 𓁇 𓁈 𓁉 𓁊 𓁋 𓁌 𓁍 𓁎 𓁏 13050 │ 𓁐 𓁑 𓁒 𓁓 𓁔 𓁕 𓁖 𓁗 𓁘 𓁙 𓁚 𓁛 𓁜 𓁝 𓁞 𓁟 13060 │ 𓁠 𓁡 𓁢 𓁣 𓁤 𓁥 𓁦 𓁧 𓁨 𓁩 𓁪 𓁫 𓁬 𓁭 𓁮 𓁯 13070 │ 𓁰 𓁱 𓁲 𓁳 𓁴 𓁵 𓁶 𓁷 𓁸 𓁹 𓁺 𓁻 𓁼 𓁽 𓁾 𓁿 13080 │ 𓂀 𓂁 𓂂 𓂃 𓂄 𓂅 𓂆 𓂇 𓂈 𓂉 𓂊 𓂋 𓂌 𓂍 𓂎 𓂏 13090 │ 𓂐 𓂑 𓂒 𓂓 𓂔 𓂕 𓂖 𓂗 𓂘 𓂙 𓂚 𓂛 𓂜 𓂝 𓂞 𓂟 130a0 │ 𓂠 𓂡 𓂢 𓂣 𓂤 𓂥 𓂦 𓂧 𓂨 𓂩 𓂪 𓂫 𓂬 𓂭 𓂮 𓂯 130b0 │ 𓂰 𓂱 𓂲 𓂳 𓂴 𓂵 𓂶 𓂷 𓂻 𓂼 𓂽 𓂾 𓂿 130c0 │ 𓃀 𓃁 𓃂 𓃃 𓃄 𓃅 𓃆 𓃇 𓃈 𓃉 𓃊 𓃋 𓃌 𓃍 𓃎 𓃏 130d0 │ 𓃐 𓃑 𓃒 𓃓 𓃔 𓃕 𓃖 𓃗 𓃘 𓃙 𓃚 𓃛 𓃜 𓃝 𓃞 𓃟 130e0 │ 𓃠 𓃡 𓃢 𓃣 𓃤 𓃥 𓃦 𓃧 𓃨 𓃩 𓃪 𓃫 𓃬 𓃭 𓃮 𓃯 130f0 │ 𓃰 𓃱 𓃲 𓃳 𓃴 𓃵 𓃶 𓃷 𓃸 𓃹 𓃺 𓃻 𓃼 𓃽 𓃾 𓃿 13100 │ 𓄀 𓄁 𓄂 𓄃 𓄄 𓄅 𓄆 𓄇 𓄈 𓄉 𓄊 𓄋 𓄌 𓄍 𓄎 𓄏 13110 │ 𓄐 𓄑 𓄒 𓄓 𓄔 𓄕 𓄖 𓄗 𓄘 𓄙 𓄚 𓄛 𓄜 𓄝 𓄞 𓄟 13120 │ 𓄠 𓄡 𓄢 𓄣 𓄤 𓄥 𓄦 𓄧 𓄨 𓄩 𓄪 𓄫 𓄬 𓄭 𓄮 𓄯 13130 │ 𓄰 𓄱 𓄲 𓄳 𓄴 𓄵 𓄶 𓄷 𓄸 𓄹 𓄺 𓄻 𓄼 𓄽 𓄾 𓄿 13140 │ 𓅀 𓅁 𓅂 𓅃 𓅄 𓅅 𓅆 𓅇 𓅈 𓅉 𓅊 𓅋 𓅌 𓅍 𓅎 𓅏 13150 │ 𓅐 𓅑 𓅒 𓅓 𓅔 𓅕 𓅖 𓅗 𓅘 𓅙 𓅚 𓅛 𓅜 𓅝 𓅞 𓅟 13160 │ 𓅠 𓅡 𓅢 𓅣 𓅤 𓅥 𓅦 𓅧 𓅨 𓅩 𓅪 𓅫 𓅬 𓅭 𓅮 𓅯 13170 │ 𓅰 𓅱 𓅲 𓅳 𓅴 𓅵 𓅶 𓅷 𓅸 𓅹 𓅺 𓅻 𓅼 𓅽 𓅾 𓅿 13180 │ 𓆀 𓆁 𓆂 𓆃 𓆄 𓆅 𓆆 𓆇 𓆈 𓆉 𓆊 𓆋 𓆌 𓆍 𓆎 𓆏 13190 │ 𓆐 𓆑 𓆒 𓆓 𓆔 𓆕 𓆖 𓆗 𓆘 𓆙 𓆚 𓆛 𓆜 𓆝 𓆞 𓆟 131a0 │ 𓆠 𓆡 𓆢 𓆣 𓆤 𓆥 𓆦 𓆧 𓆨 𓆩 𓆪 𓆫 𓆬 𓆭 𓆮 𓆯 131b0 │ 𓆰 𓆱 𓆲 𓆳 𓆴 𓆵 𓆶 𓆷 𓆸 𓆹 𓆺 𓆻 𓆼 𓆽 𓆾 𓆿 131c0 │ 𓇀 𓇁 𓇂 𓇃 𓇄 𓇅 𓇆 𓇇 𓇈 𓇉 𓇊 𓇋 𓇌 𓇍 𓇎 𓇏 131d0 │ 𓇐 𓇑 𓇒 𓇓 𓇔 𓇕 𓇖 𓇗 𓇘 𓇙 𓇚 𓇛 𓇜 𓇝 𓇞 𓇟 131e0 │ 𓇠 𓇡 𓇢 𓇣 𓇤 𓇥 𓇦 𓇧 𓇨 𓇩 𓇪 𓇫 𓇬 𓇭 𓇮 𓇯 131f0 │ 𓇰 𓇱 𓇲 𓇳 𓇴 𓇵 𓇶 𓇷 𓇸 𓇹 𓇺 𓇻 𓇼 𓇽 𓇾 𓇿 13200 │ 𓈀 𓈁 𓈂 𓈃 𓈄 𓈅 𓈆 𓈇 𓈈 𓈉 𓈊 𓈋 𓈌 𓈍 𓈎 𓈏 13210 │ 𓈐 𓈑 𓈒 𓈓 𓈔 𓈕 𓈖 𓈗 𓈘 𓈙 𓈚 𓈛 𓈜 𓈝 𓈞 𓈟 13220 │ 𓈠 𓈡 𓈢 𓈣 𓈤 𓈥 𓈦 𓈧 𓈨 𓈩 𓈪 𓈫 𓈬 𓈭 𓈮 𓈯 13230 │ 𓈰 𓈱 𓈲 𓈳 𓈴 𓈵 𓈶 𓈷 𓈸 𓈹 𓈺 𓈻 𓈼 𓈽 𓈾 𓈿 13240 │ 𓉀 𓉁 𓉂 𓉃 𓉄 𓉅 𓉆 𓉇 𓉈 𓉉 𓉊 𓉋 𓉌 𓉍 𓉎 𓉏 13250 │ 𓉐 𓉑 𓉒 𓉓 𓉔 𓉕 𓉖 𓉗 𓉘 𓉙 𓉚 𓉛 𓉜 𓉝 𓉞 𓉟 13260 │ 𓉠 𓉡 𓉢 𓉣 𓉤 𓉥 𓉦 𓉧 𓉨 𓉩 𓉪 𓉫 𓉬 𓉭 𓉮 𓉯 13270 │ 𓉰 𓉱 𓉲 𓉳 𓉴 𓉵 𓉶 𓉷 𓉸 𓉹 𓉺 𓉻 𓉼 𓉽 𓉾 𓉿 13280 │ 𓊀 𓊁 𓊂 𓊃 𓊄 𓊅 𓊆 𓊇 𓊈 𓊉 𓊊 𓊋 𓊌 𓊍 𓊎 𓊏 13290 │ 𓊐 𓊑 𓊒 𓊓 𓊔 𓊕 𓊖 𓊗 𓊘 𓊙 𓊚 𓊛 𓊜 𓊝 𓊞 𓊟 132a0 │ 𓊠 𓊡 𓊢 𓊣 𓊤 𓊥 𓊦 𓊧 𓊨 𓊩 𓊪 𓊫 𓊬 𓊭 𓊮 𓊯 132b0 │ 𓊰 𓊱 𓊲 𓊳 𓊴 𓊵 𓊶 𓊷 𓊸 𓊹 𓊺 𓊻 𓊼 𓊽 𓊾 𓊿 132c0 │ 𓋀 𓋁 𓋂 𓋃 𓋄 𓋅 𓋆 𓋇 𓋈 𓋉 𓋊 𓋋 𓋌 𓋍 𓋎 𓋏 132d0 │ 𓋐 𓋑 𓋒 𓋓 𓋔 𓋕 𓋖 𓋗 𓋘 𓋙 𓋚 𓋛 𓋜 𓋝 𓋞 𓋟 132e0 │ 𓋠 𓋡 𓋢 𓋣 𓋤 𓋥 𓋦 𓋧 𓋨 𓋩 𓋪 𓋫 𓋬 𓋭 𓋮 𓋯 132f0 │ 𓋰 𓋱 𓋲 𓋳 𓋴 𓋵 𓋶 𓋷 𓋸 𓋹 𓋺 𓋻 𓋼 𓋽 𓋾 𓋿 13300 │ 𓌀 𓌁 𓌂 𓌃 𓌄 𓌅 𓌆 𓌇 𓌈 𓌉 𓌊 𓌋 𓌌 𓌍 𓌎 𓌏 13310 │ 𓌐 𓌑 𓌒 𓌓 𓌔 𓌕 𓌖 𓌗 𓌘 𓌙 𓌚 𓌛 𓌜 𓌝 𓌞 𓌟 13320 │ 𓌠 𓌡 𓌢 𓌣 𓌤 𓌥 𓌦 𓌧 𓌨 𓌩 𓌪 𓌫 𓌬 𓌭 𓌮 𓌯 13330 │ 𓌰 𓌱 𓌲 𓌳 𓌴 𓌵 𓌶 𓌷 𓌸 𓌹 𓌺 𓌻 𓌼 𓌽 𓌾 𓌿 13340 │ 𓍀 𓍁 𓍂 𓍃 𓍄 𓍅 𓍆 𓍇 𓍈 𓍉 𓍊 𓍋 𓍌 𓍍 𓍎 𓍏 13350 │ 𓍐 𓍑 𓍒 𓍓 𓍔 𓍕 𓍖 𓍗 𓍘 𓍙 𓍚 𓍛 𓍜 𓍝 𓍞 𓍟 13360 │ 𓍠 𓍡 𓍢 𓍣 𓍤 𓍥 𓍦 𓍧 𓍨 𓍩 𓍪 𓍫 𓍬 𓍭 𓍮 𓍯 13370 │ 𓍰 𓍱 𓍲 𓍳 𓍴 𓍵 𓍶 𓍷 𓍸 𓍹 𓍺 𓍻 𓍼 𓍽 𓍾 𓍿 13380 │ 𓎀 𓎁 𓎂 𓎃 𓎄 𓎅 𓎆 𓎇 𓎈 𓎉 𓎊 𓎋 𓎌 𓎍 𓎎 𓎏 13390 │ 𓎐 𓎑 𓎒 𓎓 𓎔 𓎕 𓎖 𓎗 𓎘 𓎙 𓎚 𓎛 𓎜 𓎝 𓎞 𓎟 133a0 │ 𓎠 𓎡 𓎢 𓎣 𓎤 𓎥 𓎦 𓎧 𓎨 𓎩 𓎪 𓎫 𓎬 𓎭 𓎮 𓎯 133b0 │ 𓎰 𓎱 𓎲 𓎳 𓎴 𓎵 𓎶 𓎷 𓎸 𓎹 𓎺 𓎻 𓎼 𓎽 𓎾 𓎿 133c0 │ 𓏀 𓏁 𓏂 𓏃 𓏄 𓏅 𓏆 𓏇 𓏈 𓏉 𓏊 𓏋 𓏌 𓏍 𓏎 𓏏 133d0 │ 𓏐 𓏑 𓏒 𓏓 𓏔 𓏕 𓏖 𓏗 𓏘 𓏙 𓏚 𓏛 𓏜 𓏝 𓏞 𓏟 133e0 │ 𓏠 𓏡 𓏢 𓏣 𓏤 𓏥 𓏦 𓏧 𓏨 𓏩 𓏪 𓏫 𓏬 𓏭 𓏮 𓏯 133f0 │ 𓏰 𓏱 𓏲 𓏳 𓏴 𓏵 𓏶 𓏷 𓏸 𓏹 𓏺 𓏻 𓏼 𓏽 𓏾 𓏿 13400 │ 𓐀 𓐁 𓐂 𓐃 𓐄 𓐅 𓐆 𓐇 𓐈 𓐉 𓐊 𓐋 𓐌 𓐍 𓐎 𓐏 13410 │ 𓐐 𓐑 𓐒 𓐓 𓐔 𓐕 𓐖 𓐗 𓐘 𓐙 𓐚 𓐛 𓐜 𓐝 𓐞 𓐟 13420 │ 𓐠 𓐡 𓐢 𓐣 𓐤 𓐥 𓐦 𓐧 𓐨 𓐩 𓐪 𓐫 𓐬 𓐭 𓐮 Mathematical Alphanumeric Symbols ═══════════════════════════════════════════════════════ 1d400 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 1d400 │ 𝐀 𝐁 𝐂 𝐃 𝐄 𝐅 𝐆 𝐇 𝐈 𝐉 𝐊 𝐋 𝐌 𝐍 𝐎 𝐏 1d410 │ 𝐐 𝐑 𝐒 𝐓 𝐔 𝐕 𝐖 𝐗 𝐘 𝐙 𝐚 𝐛 𝐜 𝐝 𝐞 𝐟 1d420 │ 𝐠 𝐡 𝐢 𝐣 𝐤 𝐥 𝐦 𝐧 𝐨 𝐩 𝐪 𝐫 𝐬 𝐭 𝐮 𝐯 1d430 │ 𝐰 𝐱 𝐲 𝐳 𝐴 𝐵 𝐶 𝐷 𝐸 𝐹 𝐺 𝐻 𝐼 𝐽 𝐾 𝐿 1d440 │ 𝑀 𝑁 𝑂 𝑃 𝑄 𝑅 𝑆 𝑇 𝑈 𝑉 𝑊 𝑋 𝑌 𝑍 𝑎 𝑏 1d450 │ 𝑐 𝑑 𝑒 𝑓 𝑔 𝑕 𝑖 𝑗 𝑘 𝑙 𝑚 𝑛 𝑜 𝑝 𝑞 𝑟 1d460 │ 𝑠 𝑡 𝑢 𝑣 𝑤 𝑥 𝑦 𝑧 𝑨 𝑩 𝑪 𝑫 𝑬 𝑭 𝑮 𝑯 1d470 │ 𝑰 𝑱 𝑲 𝑳 𝑴 𝑵 𝑶 𝑷 𝑸 𝑹 𝑺 𝑻 𝑼 𝑽 𝑾 𝑿 1d480 │ 𝒀 𝒁 𝒂 𝒃 𝒄 𝒅 𝒆 𝒇 𝒈 𝒉 𝒊 𝒋 𝒌 𝒍 𝒎 𝒏 1d490 │ 𝒐 𝒑 𝒒 𝒓 𝒔 𝒕 𝒖 𝒗 𝒘 𝒙 𝒚 𝒛 𝒜 𝒝 𝒞 𝒟 1d4a0 │ 𝒠 𝒡 𝒢 𝒣 𝒤 𝒥 𝒦 𝒧 𝒨 𝒩 𝒪 𝒫 𝒬 𝒭 𝒮 𝒯 1d4b0 │ 𝒰 𝒱 𝒲 𝒳 𝒴 𝒵 𝒶 𝒷 𝒸 𝒹 𝒺 𝒻 𝒽 𝒾 𝒿 1d4c0 │ 𝓀 𝓁 𝓂 𝓃 𝓄 𝓅 𝓆 𝓇 𝓈 𝓉 𝓊 𝓋 𝓌 𝓍 𝓎 𝓏 1d4d0 │ 𝓐 𝓑 𝓒 𝓓 𝓔 𝓕 𝓖 𝓗 𝓘 𝓙 𝓚 𝓛 𝓜 𝓝 𝓞 𝓟 1d4e0 │ 𝓠 𝓡 𝓢 𝓣 𝓤 𝓥 𝓦 𝓧 𝓨 𝓩 𝓪 𝓫 𝓬 𝓭 𝓮 𝓯 1d4f0 │ 𝓰 𝓱 𝓲 𝓳 𝓴 𝓵 𝓶 𝓷 𝓸 𝓹 𝓺 𝓻 𝓼 𝓽 𝓾 𝓿 1d500 │ 𝔀 𝔁 𝔂 𝔃 𝔄 𝔅 𝔆 𝔇 𝔈 𝔉 𝔊 𝔋 𝔌 𝔍 𝔎 𝔏 1d510 │ 𝔐 𝔑 𝔒 𝔓 𝔔 𝔕 𝔖 𝔗 𝔘 𝔙 𝔚 𝔛 𝔜 𝔝 𝔞 𝔟 1d520 │ 𝔠 𝔡 𝔢 𝔣 𝔤 𝔥 𝔦 𝔧 𝔨 𝔩 𝔪 𝔫 𝔬 𝔭 𝔮 𝔯 1d530 │ 𝔰 𝔱 𝔲 𝔳 𝔴 𝔵 𝔶 𝔷 𝔸 𝔹 𝔻 𝔼 𝔽 𝔾 1d540 │ 𝕀 𝕁 𝕂 𝕃 𝕄 𝕆 𝕊 𝕋 𝕌 𝕍 𝕎 𝕏 1d550 │ 𝕐 𝕒 𝕓 𝕔 𝕕 𝕖 𝕗 𝕘 𝕙 𝕚 𝕛 𝕜 𝕝 𝕞 𝕟 1d560 │ 𝕠 𝕡 𝕢 𝕣 𝕤 𝕥 𝕦 𝕧 𝕨 𝕩 𝕪 𝕫 𝕬 𝕭 𝕮 𝕯 1d570 │ 𝕰 𝕱 𝕲 𝕳 𝕴 𝕵 𝕶 𝕷 𝕸 𝕹 𝕺 𝕻 𝕼 𝕽 𝕾 𝕿 1d580 │ 𝖀 𝖁 𝖂 𝖃 𝖄 𝖅 𝖆 𝖇 𝖈 𝖉 𝖊 𝖋 𝖌 𝖍 𝖎 𝖏 1d590 │ 𝖐 𝖑 𝖒 𝖓 𝖔 𝖕 𝖖 𝖗 𝖘 𝖙 𝖚 𝖛 𝖜 𝖝 𝖞 𝖟 1d5a0 │ 𝖠 𝖡 𝖢 𝖣 𝖤 𝖥 𝖦 𝖧 𝖨 𝖩 𝖪 𝖫 𝖬 𝖭 𝖮 𝖯 1d5b0 │ 𝖰 𝖱 𝖲 𝖳 𝖴 𝖵 𝖶 𝖷 𝖸 𝖹 𝖺 𝖻 𝖼 𝖽 𝖾 𝖿 1d5c0 │ 𝗀 𝗁 𝗂 𝗃 𝗄 𝗅 𝗆 𝗇 𝗈 𝗉 𝗊 𝗋 𝗌 𝗍 𝗎 𝗏 1d5d0 │ 𝗐 𝗑 𝗒 𝗓 𝗔 𝗕 𝗖 𝗗 𝗘 𝗙 𝗚 𝗛 𝗜 𝗝 𝗞 𝗟 1d5e0 │ 𝗠 𝗡 𝗢 𝗣 𝗤 𝗥 𝗦 𝗧 𝗨 𝗩 𝗪 𝗫 𝗬 𝗭 𝗮 𝗯 1d5f0 │ 𝗰 𝗱 𝗲 𝗳 𝗴 𝗵 𝗶 𝗷 𝗸 𝗹 𝗺 𝗻 𝗼 𝗽 𝗾 𝗿 1d600 │ 𝘀 𝘁 𝘂 𝘃 𝘄 𝘅 𝘆 𝘇 𝘈 𝘉 𝘊 𝘋 𝘌 𝘍 𝘎 𝘏 1d610 │ 𝘐 𝘑 𝘒 𝘓 𝘔 𝘕 𝘖 𝘗 𝘘 𝘙 𝘚 𝘛 𝘜 𝘝 𝘞 𝘟 1d620 │ 𝘠 𝘡 𝘢 𝘣 𝘤 𝘥 𝘦 𝘧 𝘨 𝘩 𝘪 𝘫 𝘬 𝘭 𝘮 𝘯 1d630 │ 𝘰 𝘱 𝘲 𝘳 𝘴 𝘵 𝘶 𝘷 𝘸 𝘹 𝘺 𝘻 𝘼 𝘽 𝘾 𝘿 1d640 │ 𝙀 𝙁 𝙂 𝙃 𝙄 𝙅 𝙆 𝙇 𝙈 𝙉 𝙊 𝙋 𝙌 𝙍 𝙎 𝙏 1d650 │ 𝙐 𝙑 𝙒 𝙓 𝙔 𝙕 𝙖 𝙗 𝙘 𝙙 𝙚 𝙛 𝙜 𝙝 𝙞 𝙟 1d660 │ 𝙠 𝙡 𝙢 𝙣 𝙤 𝙥 𝙦 𝙧 𝙨 𝙩 𝙪 𝙫 𝙬 𝙭 𝙮 𝙯 1d670 │ 𝙰 𝙱 𝙲 𝙳 𝙴 𝙵 𝙶 𝙷 𝙸 𝙹 𝙺 𝙻 𝙼 𝙽 𝙾 𝙿 1d680 │ 𝚀 𝚁 𝚂 𝚃 𝚄 𝚅 𝚆 𝚇 𝚈 𝚉 𝚊 𝚋 𝚌 𝚍 𝚎 𝚏 1d690 │ 𝚐 𝚑 𝚒 𝚓 𝚔 𝚕 𝚖 𝚗 𝚘 𝚙 𝚚 𝚛 𝚜 𝚝 𝚞 𝚟 1d6a0 │ 𝚠 𝚡 𝚢 𝚣 𝚤 𝚥 𝚩 𝚪 𝚫 𝚬 𝚭 𝚮 𝚯 1d6b0 │ 𝚰 𝚱 𝚲 𝚳 𝚴 𝚵 𝚶 𝚷 𝚸 𝚹 𝚺 𝚻 𝚼 𝚽 𝚾 𝚿 1d6c0 │ 𝛀 𝛁 𝛂 𝛃 𝛄 𝛅 𝛆 𝛇 𝛈 𝛉 𝛊 𝛋 𝛌 𝛍 𝛎 𝛏 1d6d0 │ 𝛐 𝛑 𝛒 𝛓 𝛔 𝛕 𝛖 𝛗 𝛘 𝛙 𝛚 𝛛 𝛜 𝛝 𝛞 𝛟 1d6e0 │ 𝛠 𝛡 𝛢 𝛣 𝛤 𝛥 𝛦 𝛧 𝛨 𝛩 𝛪 𝛫 𝛬 𝛭 𝛮 𝛯 1d6f0 │ 𝛰 𝛱 𝛲 𝛳 𝛴 𝛵 𝛶 𝛷 𝛸 𝛹 𝛺 𝛻 𝛼 𝛽 𝛾 𝛿 1d700 │ 𝜀 𝜁 𝜂 𝜃 𝜄 𝜅 𝜆 𝜇 𝜈 𝜉 𝜊 𝜋 𝜌 𝜍 𝜎 𝜏 1d710 │ 𝜐 𝜑 𝜒 𝜓 𝜔 𝜕 𝜖 𝜗 𝜘 𝜙 𝜚 𝜛 𝜜 𝜝 𝜞 𝜟 1d720 │ 𝜠 𝜡 𝜢 𝜣 𝜤 𝜥 𝜦 𝜧 𝜨 𝜩 𝜪 𝜫 𝜬 𝜭 𝜮 𝜯 1d730 │ 𝜰 𝜱 𝜲 𝜳 𝜴 𝜵 𝜶 𝜷 𝜸 𝜹 𝜺 𝜻 𝜼 𝜽 𝜾 𝜿 1d740 │ 𝝀 𝝁 𝝂 𝝃 𝝄 𝝅 𝝆 𝝇 𝝈 𝝉 𝝊 𝝋 𝝌 𝝍 𝝎 𝝏 1d750 │ 𝝐 𝝑 𝝒 𝝓 𝝔 𝝕 𝝖 𝝗 𝝘 𝝙 𝝚 𝝛 𝝜 𝝝 𝝞 𝝟 1d760 │ 𝝠 𝝡 𝝢 𝝣 𝝤 𝝥 𝝦 𝝧 𝝨 𝝩 𝝪 𝝫 𝝬 𝝭 𝝮 𝝯 1d770 │ 𝝰 𝝱 𝝲 𝝳 𝝴 𝝵 𝝶 𝝷 𝝸 𝝹 𝝺 𝝻 𝝼 𝝽 𝝾 𝝿 1d780 │ 𝞀 𝞁 𝞂 𝞃 𝞄 𝞅 𝞆 𝞇 𝞈 𝞉 𝞊 𝞋 𝞌 𝞍 𝞎 𝞏 1d790 │ 𝞐 𝞑 𝞒 𝞓 𝞔 𝞕 𝞖 𝞗 𝞘 𝞙 𝞚 𝞛 𝞜 𝞝 𝞞 𝞟 1d7a0 │ 𝞠 𝞡 𝞢 𝞣 𝞤 𝞥 𝞦 𝞧 𝞨 𝞩 𝞪 𝞫 𝞬 𝞭 𝞮 𝞯 1d7b0 │ 𝞰 𝞱 𝞲 𝞳 𝞴 𝞵 𝞶 𝞷 𝞸 𝞹 𝞺 𝞻 𝞼 𝞽 𝞾 𝞿 1d7c0 │ 𝟀 𝟁 𝟂 𝟃 𝟄 𝟅 𝟆 𝟇 𝟈 𝟉 𝟊 𝟎 𝟏 1d7d0 │ 𝟐 𝟑 𝟒 𝟓 𝟔 𝟕 𝟖 𝟗 𝟘 𝟙 𝟚 𝟛 𝟜 𝟝 𝟞 𝟟 1d7e0 │ 𝟠 𝟡 𝟢 𝟣 𝟤 𝟥 𝟦 𝟧 𝟨 𝟩 𝟪 𝟫 𝟬 𝟭 𝟮 𝟯 1d7f0 │ 𝟰 𝟱 𝟲 𝟳 𝟴 𝟵 𝟶 𝟷 𝟸 𝟹 𝟺 𝟻 𝟼 𝟽 𝟾 𝟿 Mahjong Tiles ═══════════════════════════════════════════════════════ 1f000 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 1f000 │ 🀀 🀁 🀂 🀃 🀄 🀅 🀆 🀇 🀈 🀉 🀊 🀋 🀌 🀍 🀎 🀏 1f010 │ 🀐 🀑 🀒 🀓 🀔 🀕 🀖 🀗 🀘 🀙 🀚 🀛 🀜 🀝 🀞 🀟 1f020 │ 🀠 🀡 🀢 🀣 🀤 🀥 🀦 🀧 🀨 🀩 🀪 🀫 Domino Tiles ═══════════════════════════════════════════════════════ 1f030 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 1f030 │ 🀰 🀱 🀲 🀳 🀴 🀵 🀶 🀷 🀸 🀹 🀺 🀻 🀼 🀽 🀾 🀿 1f040 │ 🁀 🁁 🁂 🁃 🁄 🁅 🁆 🁇 🁈 🁉 🁊 🁋 🁌 🁍 🁎 🁏 1f050 │ 🁐 🁑 🁒 🁓 🁔 🁕 🁖 🁗 🁘 🁙 🁚 🁛 🁜 🁝 🁞 🁟 1f060 │ 🁠 🁡 🁢 🁣 🁤 🁥 🁦 🁧 🁨 🁩 🁪 🁫 🁬 🁭 🁮 🁯 1f070 │ 🁰 🁱 🁲 🁳 🁴 🁵 🁶 🁷 🁸 🁹 🁺 🁻 🁼 🁽 🁾 🁿 1f080 │ 🂀 🂁 🂂 🂃 🂄 🂅 🂆 🂇 🂈 🂉 🂊 🂋 🂌 🂍 🂎 🂏 1f090 │ 🂐 🂑 🂒 🂓 Playing Cards ═══════════════════════════════════════════════════════ 1f0a0 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 1f0a0 │ 🂠 🂡 🂢 🂣 🂤 🂥 🂦 🂧 🂨 🂩 🂪 🂫 🂬 🂭 🂮 1f0b0 │ 🂰 🂱 🂲 🂳 🂴 🂵 🂶 🂷 🂸 🂹 🂺 🂻 🂼 🂽 🂾 1f0c0 │ 🃀 🃁 🃂 🃃 🃄 🃅 🃆 🃇 🃈 🃉 🃊 🃋 🃌 🃍 🃎 🃏 1f0d0 │ 🃐 🃑 🃒 🃓 🃔 🃕 🃖 🃗 🃘 🃙 🃚 🃛 🃜 🃝 🃞 🃟 Enclosed Alphanumeric Supplement ═══════════════════════════════════════════════════════ 1f100 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 1f100 │ 🄀 🄁 🄂 🄃 🄄 🄅 🄆 🄇 🄈 🄉 🄊 1f110 │ 🄐 🄑 🄒 🄓 🄔 🄕 🄖 🄗 🄘 🄙 🄚 🄛 🄜 🄝 🄞 🄟 1f120 │ 🄠 🄡 🄢 🄣 🄤 🄥 🄦 🄧 🄨 🄩 🄪 🄫 🄬 🄭 🄮 🄯 1f130 │ 🄰 🄱 🄲 🄳 🄴 🄵 🄶 🄷 🄸 🄹 🄺 🄻 🄼 🄽 🄾 🄿 1f140 │ 🅀 🅁 🅂 🅃 🅄 🅅 🅆 🅇 🅈 🅉 🅊 🅋 🅌 🅍 🅎 🅏 1f150 │ 🅐 🅑 🅒 🅓 🅔 🅕 🅖 🅗 🅘 🅙 🅚 🅛 🅜 🅝 🅞 🅟 1f160 │ 🅠 🅡 🅢 🅣 🅤 🅥 🅦 🅧 🅨 🅩 1f170 │ 🅰 🅱 🅲 🅳 🅴 🅵 🅶 🅷 🅸 🅹 🅺 🅻 🅼 🅽 🅾 🅿 1f180 │ 🆀 🆁 🆂 🆃 🆄 🆅 🆆 🆇 🆈 🆉 🆊 🆋 🆌 🆍 🆎 🆏 1f190 │ 🆐 🆑 🆒 🆓 🆔 🆕 🆖 🆗 🆘 🆙 🆚 1f1e0 │ 🇦 🇧 🇨 🇩 🇪 🇫 🇬 🇭 🇮 🇯 1f1f0 │ 🇰 🇱 🇲 🇳 🇴 🇵 🇶 🇷 🇸 🇹 🇺 🇻 🇼 🇽 🇾 🇿 Enclosed Ideographic Supplement ═══════════════════════════════════════════════════════ 1f200 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 1f200 │ 🈀 🈁 🈂 1f210 │ 🈐 🈑 🈒 🈓 🈔 🈕 🈖 🈗 🈘 🈙 🈚 🈛 🈜 🈝 🈞 🈟 1f220 │ 🈠 🈡 🈢 🈣 🈤 🈥 🈦 🈧 🈨 🈩 🈪 🈫 🈬 🈭 🈮 🈯 1f230 │ 🈰 🈱 🈲 🈳 🈴 🈵 🈶 🈷 🈸 🈹 🈺 1f240 │ 🉀 🉁 🉂 🉃 🉄 🉅 🉆 🉇 🉈 1f250 │ 🉐 🉑 Miscellaneous Symbols and Pictographs ═══════════════════════════════════════════════════════ 1f300 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 1f300 │ 🌀 🌁 🌂 🌃 🌄 🌅 🌆 🌇 🌈 🌉 🌊 🌋 🌌 🌍 🌎 🌏 1f310 │ 🌐 🌑 🌒 🌓 🌔 🌕 🌖 🌗 🌘 🌙 🌚 🌛 🌜 🌝 🌞 🌟 1f320 │ 🌠 🌡 🌢 🌣 🌤 🌥 🌦 🌧 🌨 🌩 🌪 🌫 🌬 🌭 🌮 🌯 1f330 │ 🌰 🌱 🌲 🌳 🌴 🌵 🌶 🌷 🌸 🌹 🌺 🌻 🌼 🌽 🌾 🌿 1f340 │ 🍀 🍁 🍂 🍃 🍄 🍅 🍆 🍇 🍈 🍉 🍊 🍋 🍌 🍍 🍎 🍏 1f350 │ 🍐 🍑 🍒 🍓 🍔 🍕 🍖 🍗 🍘 🍙 🍚 🍛 🍜 🍝 🍞 🍟 1f360 │ 🍠 🍡 🍢 🍣 🍤 🍥 🍦 🍧 🍨 🍩 🍪 🍫 🍬 🍭 🍮 🍯 1f370 │ 🍰 🍱 🍲 🍳 🍴 🍵 🍶 🍷 🍸 🍹 🍺 🍻 🍼 🍽 🍾 🍿 1f380 │ 🎀 🎁 🎂 🎃 🎄 🎅 🎆 🎇 🎈 🎉 🎊 🎋 🎌 🎍 🎎 🎏 1f390 │ 🎐 🎑 🎒 🎓 🎔 🎕 🎖 🎗 🎘 🎙 🎚 🎛 🎜 🎝 🎞 🎟 1f3a0 │ 🎠 🎡 🎢 🎣 🎤 🎥 🎦 🎧 🎨 🎩 🎪 🎫 🎬 🎭 🎮 🎯 1f3b0 │ 🎰 🎱 🎲 🎳 🎴 🎵 🎶 🎷 🎸 🎹 🎺 🎻 🎼 🎽 🎾 🎿 1f3c0 │ 🏀 🏁 🏂 🏃 🏄 🏅 🏆 🏇 🏈 🏉 🏊 🏋 🏌 🏍 🏎 🏏 1f3d0 │ 🏐 🏑 🏒 🏓 🏔 🏕 🏖 🏗 🏘 🏙 🏚 🏛 🏜 🏝 🏞 🏟 1f3e0 │ 🏠 🏡 🏢 🏣 🏤 🏥 🏦 🏧 🏨 🏩 🏪 🏫 🏬 🏭 🏮 🏯 1f3f0 │ 🏰 🏱 🏲 🏳 🏴 🏵 🏶 🏷 🏸 🏹 🏺 🏻 🏼 🏽 🏾 🏿 1f400 │ 🐀 🐁 🐂 🐃 🐄 🐅 🐆 🐇 🐈 🐉 🐊 🐋 🐌 🐍 🐎 🐏 1f410 │ 🐐 🐑 🐒 🐓 🐔 🐕 🐖 🐗 🐘 🐙 🐚 🐛 🐜 🐝 🐞 🐟 1f420 │ 🐠 🐡 🐢 🐣 🐤 🐥 🐦 🐧 🐨 🐩 🐪 🐫 🐬 🐭 🐮 🐯 1f430 │ 🐰 🐱 🐲 🐳 🐴 🐵 🐶 🐷 🐸 🐹 🐺 🐻 🐼 🐽 🐾 🐿 1f440 │ 👀 👁 👂 👃 👄 👅 👆 👇 👈 👉 👊 👋 👌 👍 👎 👏 1f450 │ 👐 👑 👒 👓 👔 👕 👖 👗 👘 👙 👚 👛 👜 👝 👞 👟 1f460 │ 👠 👡 👢 👣 👤 👥 👦 👧 👨 👩 👪 👫 👬 👭 👮 👯 1f470 │ 👰 👱 👲 👳 👴 👵 👶 👷 👸 👹 👺 👻 👼 👽 👾 👿 1f480 │ 💀 💁 💂 💃 💄 💅 💆 💇 💈 💉 💊 💋 💌 💍 💎 💏 1f490 │ 💐 💑 💒 💓 💔 💕 💖 💗 💘 💙 💚 💛 💜 💝 💞 💟 1f4a0 │ 💠 💡 💢 💣 💤 💥 💦 💧 💨 💩 💪 💫 💬 💭 💮 💯 1f4b0 │ 💰 💱 💲 💳 💴 💵 💶 💷 💸 💹 💺 💻 💼 💽 💾 💿 1f4c0 │ 📀 📁 📂 📃 📄 📅 📆 📇 📈 📉 📊 📋 📌 📍 📎 📏 1f4d0 │ 📐 📑 📒 📓 📔 📕 📖 📗 📘 📙 📚 📛 📜 📝 📞 📟 1f4e0 │ 📠 📡 📢 📣 📤 📥 📦 📧 📨 📩 📪 📫 📬 📭 📮 📯 1f4f0 │ 📰 📱 📲 📳 📴 📵 📶 📷 📸 📹 📺 📻 📼 📽 📾 📿 1f500 │ 🔀 🔁 🔂 🔃 🔄 🔅 🔆 🔇 🔈 🔉 🔊 🔋 🔌 🔍 🔎 🔏 1f510 │ 🔐 🔑 🔒 🔓 🔔 🔕 🔖 🔗 🔘 🔙 🔚 🔛 🔜 🔝 🔞 🔟 1f520 │ 🔠 🔡 🔢 🔣 🔤 🔥 🔦 🔧 🔨 🔩 🔪 🔫 🔬 🔭 🔮 🔯 1f530 │ 🔰 🔱 🔲 🔳 🔴 🔵 🔶 🔷 🔸 🔹 🔺 🔻 🔼 🔽 🔾 🔿 1f540 │ 🕀 🕁 🕂 🕃 🕄 🕅 🕆 🕇 🕈 🕉 🕊 🕋 🕌 🕍 🕎 🕏 1f550 │ 🕐 🕑 🕒 🕓 🕔 🕕 🕖 🕗 🕘 🕙 🕚 🕛 🕜 🕝 🕞 🕟 1f560 │ 🕠 🕡 🕢 🕣 🕤 🕥 🕦 🕧 🕨 🕩 🕪 🕫 🕬 🕭 🕮 🕯 1f570 │ 🕰 🕱 🕲 🕳 🕴 🕵 🕶 🕷 🕸 🕹 🕺 🕻 🕼 🕽 🕾 🕿 1f580 │ 🖀 🖁 🖂 🖃 🖄 🖅 🖆 🖇 🖈 🖉 🖊 🖋 🖌 🖍 🖎 🖏 1f590 │ 🖐 🖑 🖒 🖓 🖔 🖕 🖖 🖗 🖘 🖙 🖚 🖛 🖜 🖝 🖞 🖟 1f5a0 │ 🖠 🖡 🖢 🖣 🖤 🖥 🖦 🖧 🖨 🖩 🖪 🖫 🖬 🖭 🖮 🖯 1f5b0 │ 🖰 🖱 🖲 🖳 🖴 🖵 🖶 🖷 🖸 🖹 🖺 🖻 🖼 🖽 🖾 🖿 1f5c0 │ 🗀 🗁 🗂 🗃 🗄 🗅 🗆 🗇 🗈 🗉 🗊 🗋 🗌 🗍 🗎 🗏 1f5d0 │ 🗐 🗑 🗒 🗓 🗔 🗕 🗖 🗗 🗘 🗙 🗚 🗛 🗜 🗝 🗞 🗟 1f5e0 │ 🗠 🗡 🗢 🗣 🗤 🗥 🗦 🗧 🗨 🗩 🗪 🗫 🗬 🗭 🗮 🗯 1f5f0 │ 🗰 🗱 🗲 🗳 🗴 🗵 🗶 🗷 🗸 🗹 🗺 🗻 🗼 🗽 🗾 🗿 Emoticons ═══════════════════════════════════════════════════════ 1f600 │ 0 1 2 3 4 5 6 7 8 9 a b c d e f ─────────────────────────────────────────────────────── 1f600 │ 😀 😁 😂 😃 😄 😅 😆 😇 😈 😉 😊 😋 😌 😍 😎 😏 1f610 │ 😐 😑 😒 😓 😔 😕 😖 😗 😘 😙 😚 😛 😜 😝 😞 😟 1f620 │ 😠 😡 😢 😣 😤 😥 😦 😧 😨 😩 😪 😫 😬 😭 😮 😯 1f630 │ 😰 😱 😲 😳 😴 😵 😶 😷 😸 😹 😺 😻 😼 😽 😾 😿 1f640 │ 🙀 🙁 🙂 🙃 🙄 🙅 🙆 🙇 🙈 🙉 🙊 🙋 🙌 🙍 🙎 🙏
76,529
925
jart/cosmopolitan
false
cosmopolitan/libc/testlib/hyperion.S
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│ │vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/macros.internal.h" .rodata // Nontrivial NUL-terminated string test vector. .underrun kHyperion: 0: .incbin "libc/testlib/hyperion.txt" 1: .byte 0 .endobj kHyperion,globl .overrun .balign 8 kHyperionSize: .quad 1b-0b .endobj kHyperionSize,globl
2,104
34
jart/cosmopolitan
false
cosmopolitan/libc/testlib/thrashcodecache.S
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│ │vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/macros.internal.h" .testonly // Empties L1 instruction cache. thrashcodecache: #ifdef __x86_64__ .leafprologue push %rbx xor %eax,%eax xor %ecx,%ecx cpuid add %r9,%r8 // Generate 32kb of junk code clobbering r8,r9,r10,r11 i = 0xdeadbeef 0: .rept 32768/(3+7) rex.wrb .byte 0001|(i&030) // ADD/OR/... Evqp Gvqp .byte 0300|(i&033) // %r8-%r11 to %r8-%r11 .byte 0x49,0x81,0360|(i&003) // XOR immed32,%r8-%r11 .long i i = ((i * 1103515245 + 12345) >> 16) & 0xffffffff .endr xor %eax,%eax xor %ecx,%ecx cpuid pop %rbx .leafepilogue #else ret #endif .endfn thrashcodecache,globl
2,450
50
jart/cosmopolitan
false
cosmopolitan/libc/testlib/globals.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/atomic.h" #include "libc/testlib/testlib.h" char g_fixturename[256]; atomic_uint g_testlib_ran; atomic_uint g_testlib_failed;
1,978
25
jart/cosmopolitan
false
cosmopolitan/libc/testlib/thunks.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2023 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/mem/mem.h" #include "libc/testlib/testlib.h" void testlib_free(void *p) { free(p); }
1,939
25
jart/cosmopolitan
false
cosmopolitan/libc/testlib/hyperion.h
#ifndef COSMOPOLITAN_LIBC_TESTLIB_HYPERION_H_ #define COSMOPOLITAN_LIBC_TESTLIB_HYPERION_H_ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ extern size_t kHyperionSize; extern char kHyperion[]; extern uint8_t kHyperionZip[]; extern size_t kMobySize; extern char kMoby[]; extern uint8_t kMobyZip[]; COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_TESTLIB_HYPERION_H_ */
431
17
jart/cosmopolitan
false
cosmopolitan/libc/testlib/moby.h
#ifndef COSMOPOLITAN_LIBC_TESTLIB_MOBY_H_ #define COSMOPOLITAN_LIBC_TESTLIB_MOBY_H_ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ extern size_t kMobySize; extern char kMoby[]; extern uint8_t kMobyZip[]; COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_TESTLIB_MOBY_H_ */
333
13
jart/cosmopolitan
false
cosmopolitan/libc/testlib/testrunner.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" #include "libc/calls/calls.h" #include "libc/calls/state.internal.h" #include "libc/calls/struct/sigaction.h" #include "libc/calls/struct/sigset.h" #include "libc/calls/syscall-sysv.internal.h" #include "libc/dce.h" #include "libc/errno.h" #include "libc/fmt/fmt.h" #include "libc/fmt/itoa.h" #include "libc/intrin/atomic.h" #include "libc/intrin/strace.internal.h" #include "libc/intrin/weaken.h" #include "libc/log/check.h" #include "libc/log/internal.h" #include "libc/macros.internal.h" #include "libc/nt/process.h" #include "libc/runtime/internal.h" #include "libc/runtime/runtime.h" #include "libc/runtime/symbols.internal.h" #include "libc/sock/sock.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/sysv/consts/poll.h" #include "libc/sysv/consts/sa.h" #include "libc/sysv/consts/sig.h" #include "libc/sysv/consts/w.h" #include "libc/testlib/testlib.h" #include "libc/thread/thread.h" #include "libc/x/x.h" static int x; char g_testlib_olddir[PATH_MAX]; char g_testlib_tmpdir[PATH_MAX]; struct sigaction wanthandlers[31]; static pthread_mutex_t testlib_error_lock; void testlib_finish(void) { if (g_testlib_failed) { fprintf(stderr, "%u / %u %s\n", g_testlib_failed, g_testlib_ran, "tests failed"); } } void testlib_error_enter(const char *file, const char *func) { ftrace_enabled(-1); strace_enabled(-1); pthread_mutex_lock(&testlib_error_lock); if (!IsWindows()) sys_getpid(); /* make strace easier to read */ if (!IsWindows()) sys_getpid(); if (g_testlib_shoulddebugbreak) { DebugBreak(); } testlib_showerror_file = file; testlib_showerror_func = func; } void testlib_error_leave(void) { strace_enabled(+1); ftrace_enabled(+1); pthread_mutex_unlock(&testlib_error_lock); } wontreturn void testlib_abort(void) { testlib_finish(); _Exitr(MAX(1, MIN(255, g_testlib_failed))); } static void SetupTmpDir(void) { char *p = g_testlib_tmpdir; p = stpcpy(p, kTmpPath); p = stpcpy(p, program_invocation_short_name), *p++ = '.'; p = FormatInt64(p, getpid()), *p++ = '.'; p = FormatInt64(p, x++); p[0] = '\0'; CHECK_NE(-1, makedirs(g_testlib_tmpdir, 0755), "%s", g_testlib_tmpdir); CHECK_NOTNULL(realpath(g_testlib_tmpdir, g_testlib_tmpdir), "%`'s", g_testlib_tmpdir); CHECK_NE(-1, chdir(g_testlib_tmpdir), "%s", g_testlib_tmpdir); } static void TearDownTmpDir(void) { CHECK_NE(-1, chdir(g_testlib_olddir)); CHECK_NE(-1, rmrf(g_testlib_tmpdir), "%s", g_testlib_tmpdir); } static void DoNothing(int sig) { // function intentionally empty } static void CopySignalHandlers(void) { #if 0 int i; for (i = 0; i < ARRAYLEN(wanthandlers); ++i) { if (i + 1 == SIGKILL || i + 1 == SIGSTOP) continue; CHECK_EQ(0, sigaction(i + 1, 0, wanthandlers + i), "sig=%d", i + 1); } #endif } static void CheckSignalHandler(int sig) { #if 0 int i; struct sigaction sa = {0}; _unassert(0 <= sig - 1 && sig - 1 < ARRAYLEN(wanthandlers)); CHECK_EQ(0, sigaction(sig, 0, &sa)); CHECK_EQ(0, memcmp(wanthandlers + sig - 1, &sa, sizeof(sa)), "signal handler for %s was %p/%#x/%#x:%x " "but should have been restored to %p/%#x/%#x:%x", strsignal(sig), sa.sa_handler, sa.sa_flags, sa.sa_mask.__bits[0], sa.sa_mask.__bits[1], wanthandlers[sig - 1].sa_handler, wanthandlers[sig - 1].sa_flags, wanthandlers[sig - 1].sa_mask.__bits[0], wanthandlers[sig - 1].sa_mask.__bits[1]); #endif } static void CheckForSignalHandlers(void) { #if 0 CheckSignalHandler(SIGINT); CheckSignalHandler(SIGQUIT); CheckSignalHandler(SIGCHLD); CheckSignalHandler(SIGFPE); CheckSignalHandler(SIGILL); CheckSignalHandler(SIGSEGV); CheckSignalHandler(SIGTRAP); CheckSignalHandler(SIGABRT); CheckSignalHandler(SIGBUS); CheckSignalHandler(SIGSYS); CheckSignalHandler(SIGWINCH); #endif } static void CheckForFileDescriptors(void) { #if 0 // TODO: race condition on fd cleanup :'( int i; struct pollfd pfds[16]; if (!_weaken(open) && !_weaken(socket)) return; for (i = 0; i < ARRAYLEN(pfds); ++i) { pfds[i].fd = i + 3; pfds[i].events = POLLIN; } if (poll(pfds, ARRAYLEN(pfds), 0) > 0) { for (i = 0; i < ARRAYLEN(pfds); ++i) { if (pfds[i].revents & POLLNVAL) continue; ++g_testlib_failed; fprintf(stderr, "error: test failed to close() fd %d\n", pfds[i].fd); } } #endif } static void CheckForZombies(void) { #if 0 int e, pid; sigset_t ss, oldss; struct sigaction oldsa; struct sigaction ignore = {.sa_handler = DoNothing}; if (!_weaken(fork)) return; for (;;) { if ((pid = wait(0)) == -1) { CHECK_EQ(ECHILD, errno); break; } else { ++g_testlib_failed; fprintf(stderr, "error: test failed to reap zombies %d\n", pid); } } #endif } /** * Runs all test case functions in sorted order. */ void testlib_runtestcases(testfn_t *start, testfn_t *end, testfn_t warmup) { /* * getpid() calls are inserted to help visually see tests in traces * which can be performed on Linux, FreeBSD, OpenBSD, and XNU: * * strace -f o/default/test.com |& less * truss o/default/test.com |& less * ktrace -f trace o/default/test.com </dev/null; kdump -f trace | less * dtruss o/default/test.com |& less * * Test cases are iterable via a decentralized section. Your TEST() * macro inserts .testcase.SUITENAME sections into the binary which * the linker sorts into an array. * * @see ape/ape.lds */ const testfn_t *fn; CopySignalHandlers(); if (_weaken(testlib_enable_tmp_setup_teardown) || _weaken(testlib_enable_tmp_setup_teardown_once)) { CHECK_NOTNULL(getcwd(g_testlib_olddir, sizeof(g_testlib_olddir))); } if (_weaken(testlib_enable_tmp_setup_teardown_once)) { SetupTmpDir(); } if (_weaken(SetUpOnce)) _weaken(SetUpOnce)(); for (x = 0, fn = start; fn != end; ++fn) { STRACE(""); STRACE("# setting up %t", fn); if (_weaken(testlib_enable_tmp_setup_teardown)) SetupTmpDir(); if (_weaken(SetUp)) _weaken(SetUp)(); errno = 0; SetLastError(0); if (!IsWindows()) sys_getpid(); if (warmup) warmup(); testlib_clearxmmregisters(); STRACE(""); STRACE("# running test %t", fn); (*fn)(); STRACE(""); STRACE("# tearing down %t", fn); if (!IsWindows()) sys_getpid(); if (_weaken(TearDown)) _weaken(TearDown)(); if (_weaken(testlib_enable_tmp_setup_teardown)) TearDownTmpDir(); CheckForFileDescriptors(); CheckForSignalHandlers(); CheckForZombies(); } if (_weaken(TearDownOnce)) { _weaken(TearDownOnce)(); } if (_weaken(testlib_enable_tmp_setup_teardown_once)) { TearDownTmpDir(); } }
8,582
249
jart/cosmopolitan
false
cosmopolitan/libc/testlib/clearxmmregisters.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/testlib/testlib.h" void testlib_clearxmmregisters(void) { #ifdef __x86_64__ asm("pxor\t%xmm0,%xmm0\n\t" "pxor\t%xmm1,%xmm1\n\t" "pxor\t%xmm2,%xmm2\n\t" "pxor\t%xmm3,%xmm3\n\t" "pxor\t%xmm4,%xmm4\n\t" "pxor\t%xmm5,%xmm5\n\t" "pxor\t%xmm6,%xmm6\n\t" "pxor\t%xmm7,%xmm7"); #endif }
2,175
33
jart/cosmopolitan
false
cosmopolitan/libc/testlib/viewables.S
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│ │vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/macros.internal.h" .rodata // Nontrivial NUL-terminated string test vector. .underrun kViewables: 0: .incbin "libc/testlib/viewables.txt" 1: .byte 0 .endobj kViewables,globl .overrun .balign 8 kViewablesSize: .quad 1b-0b .endobj kViewablesSize,globl
2,109
34
jart/cosmopolitan
false
cosmopolitan/libc/testlib/benchrunner.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "ape/sections.internal.h" #include "libc/calls/calls.h" #include "libc/errno.h" #include "libc/log/log.h" #include "libc/nexgen32e/x86feature.h" #include "libc/runtime/runtime.h" #include "libc/sysv/consts/f.h" #include "libc/sysv/consts/mlock.h" #include "libc/sysv/consts/o.h" #include "libc/testlib/testlib.h" double g_avx2_juiceup_doubles_[4] forcealign(32); unsigned long long g_avx2_juiceup_quadwords_[4] forcealign(32); void testlib_benchwarmup(void) { /* get mathematical parts of cpu juiced up */ if (X86_HAVE(AVX2) && X86_HAVE(FMA)) { asm("vmovdqa\t%1,%%ymm0\n\t" "vpmaddwd\t(%2),%%ymm0,%%ymm0\n\t" "vmovdqa\t%%ymm0,%0\n\t" "vzeroall" : "=m"(g_avx2_juiceup_quadwords_) : "m"(g_avx2_juiceup_quadwords_), "r"(&__executable_start[0])); asm("vmovapd\t%1,%%ymm1\n\t" "vfmadd132pd\t(%2),%%ymm1,%%ymm1\n\t" "vmovapd\t%%ymm1,%0\n\t" "vzeroall" : "=m"(g_avx2_juiceup_doubles_) : "m"(g_avx2_juiceup_doubles_), "r"(&__executable_start[32])); } } void EnableCruiseControlForCool(void) { int fd, micros = 10; if ((fd = open("/dev/cpu_dma_latency", O_WRONLY)) != -1) { write(fd, &micros, sizeof(micros)); fcntl(fd, F_DUPFD_CLOEXEC, 123); close(fd); } } /** * Runs all benchmark functions in sorted order. * * @see BENCH() */ void testlib_runallbenchmarks(void) { int e; __log_level = kLogWarn; EnableCruiseControlForCool(); testlib_runtestcases(__bench_start, __bench_end, testlib_benchwarmup); }
3,366
71
jart/cosmopolitan
false
cosmopolitan/libc/testlib/geterrno.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2022 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/errno.h" #include "libc/testlib/testlib.h" int testlib_geterrno(void) { return errno; }
1,942
25
jart/cosmopolitan
false
cosmopolitan/libc/testlib/quota.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2021 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/calls/struct/sigaction.h" #include "libc/errno.h" #include "libc/intrin/bits.h" #include "libc/intrin/kprintf.h" #include "libc/log/backtrace.internal.h" #include "libc/log/internal.h" #include "libc/log/libfatal.internal.h" #include "libc/log/log.h" #include "libc/runtime/internal.h" #include "libc/runtime/memtrack.internal.h" #include "libc/runtime/runtime.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/sysv/consts/sig.h" #include "libc/testlib/testlib.h" #include "third_party/dlmalloc/dlmalloc.h" static noasan noubsan relegated uint64_t CountMappedBytes(void) { size_t i; uint64_t x, y; for (x = i = 0; i < _mmi.i; ++i) { y = _mmi.p[i].y - _mmi.p[i].x; x += (y + 1) << 16; } return x; } static relegated void DieBecauseOfQuota(int rc, const char *message) { int e = errno; char hostname[32]; stpcpy(hostname, "unknown"); gethostname(hostname, sizeof(hostname)); kprintf("%s on %s pid %d\n", message, hostname, (long)getpid()); PrintBacktraceUsingSymbols(2, 0, GetSymbolTable()); _Exitr(rc); } static relegated void OnXcpu(int sig) { __restore_tty(); DieBecauseOfQuota(23, "\n\nSIGXCPU: ran out of cpu"); } static relegated void OnXfsz(int sig) { __restore_tty(); DieBecauseOfQuota(25, "\n\nSIGXFSZ: exceeded maximum file size"); } relegated void __oom_hook(size_t request) { int e; uint64_t toto, newlim; __restore_tty(); e = errno; toto = CountMappedBytes(); kprintf("\n\nWE REQUIRE MORE VESPENE GAS"); if (e != ENOMEM) kprintf(" (%s)", strerror(e)); if (IsRunningUnderMake()) { newlim = toto + request; newlim += newlim >> 1; newlim = _roundup2pow(newlim); kprintf("FIX CODE OR TUNE QUOTA += -M%dm\n", newlim / (1024 * 1024)); } kprintf("\n"); __print_maps(); kprintf("\nTHE STRAW THAT BROKE THE CAMEL'S BACK\n"); PrintBacktraceUsingSymbols(2, 0, GetSymbolTable()); PrintSystemMappings(2); _Exitr(42); } static textstartup void InstallQuotaHandlers(void) { int e; struct sigaction sa; e = errno; sa.sa_flags = 0; sa.sa_handler = OnXcpu; sigemptyset(&sa.sa_mask); sigaction(SIGXCPU, &sa, 0); sa.sa_handler = OnXfsz; sigaction(SIGXFSZ, &sa, 0); GetSymbolTable(); /* for effect in case we oom */ errno = e; } const void *const testlib_quota_handlers[] initarray = { InstallQuotaHandlers, };
4,225
106
jart/cosmopolitan
false
cosmopolitan/libc/testlib/ezbenchcontrol.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/stdio/stdio.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" static bool once; static double g_ezbenchcontrol; double __testlib_ezbenchcontrol(void) { if (!once) { int Core, Tries, Interrupts; Tries = 0; do { __testlib_yield(); Core = __testlib_getcore(); Interrupts = __testlib_getinterrupts(); g_ezbenchcontrol = BENCHLOOP(__startbench, __endbench, 128, donothing, (void)0); } while (++Tries < 10 && (__testlib_getcore() != Core && __testlib_getinterrupts() > Interrupts)); if (Tries == 10) { fputs("warning: failed to accurately benchmark control\n", stderr); } fprintf(stderr, "will subtract benchmark overhead of %g cycles\n\n", g_ezbenchcontrol); once = true; } return g_ezbenchcontrol; }
2,690
47
jart/cosmopolitan
false
cosmopolitan/libc/testlib/contains.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/str/str.h" #include "libc/testlib/testlib.h" bool testlib_contains(size_t cw, const void *s, const void *needle) { if (s == needle) return true; if (!s || !needle) return false; return sizeof(cw) == sizeof(char16_t) ? !!strstr16(s, needle) : !!strstr(s, needle); }
2,163
28
jart/cosmopolitan
false
cosmopolitan/libc/testlib/blocktronics.h
#ifndef COSMOPOLITAN_LIBC_TESTLIB_BLOCKTRONICS_H_ #define COSMOPOLITAN_LIBC_TESTLIB_BLOCKTRONICS_H_ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ extern size_t kBlocktronicsSize; extern char kBlocktronics[]; extern uint8_t kBlocktronicsZip[]; COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_TESTLIB_BLOCKTRONICS_H_ */
381
13
jart/cosmopolitan
false
cosmopolitan/libc/testlib/polluteregisters.S
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│ │vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2021 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/nexgen32e/x86feature.h" #include "libc/macros.internal.h" __polluteregisters: #ifdef __x86_64__ .leafprologue xor %eax,%eax xor %ecx,%ecx xor %edx,%edx xor %edi,%edi xor %esi,%esi xor %r8d,%r8d xor %r9d,%r9d xor %r10d,%r10d xor %r11d,%r11d testb X86_HAVE(AVX)+kCpuids(%rip) jz .Lsse vpxor %xmm0,%xmm0,%xmm0 vpxor %xmm1,%xmm1,%xmm1 vpxor %xmm2,%xmm2,%xmm2 vpxor %xmm3,%xmm3,%xmm3 vpxor %xmm4,%xmm4,%xmm4 vpxor %xmm5,%xmm5,%xmm5 vpxor %xmm6,%xmm6,%xmm6 vpxor %xmm7,%xmm7,%xmm7 .leafepilogue .Lsse: xorps %xmm0,%xmm0 xorps %xmm1,%xmm1 xorps %xmm2,%xmm2 xorps %xmm3,%xmm3 xorps %xmm4,%xmm4 xorps %xmm5,%xmm5 xorps %xmm6,%xmm6 xorps %xmm7,%xmm7 .leafepilogue #elif defined(__aarch64__) mov x0,#0 mov x1,#0 mov x2,#0 mov x3,#0 mov x4,#0 mov x5,#0 mov x6,#0 mov x7,#0 mov x9,#0 mov x10,#0 mov x11,#0 mov x12,#0 mov x13,#0 mov x14,#0 mov x15,#0 movi v0.16b,#0 movi v1.16b,#0 movi v2.16b,#0 movi v3.16b,#0 movi v4.16b,#0 movi v5.16b,#0 movi v6.16b,#0 movi v7.16b,#0 ret #else ret #endif .endfn __polluteregisters,globl .end // Fill registers with junk data to create false dependencies. // Which shall create the problem that happens w/o vzeroupper. // Or the Core Architecture errata regarding BSR/BSF w/ 64bit. __polluteregisters_old: .leafprologue mov $-1,%rax mov %rax,%rcx mov %rax,%rdx mov %rax,%r8 mov %rax,%r9 mov %rax,%r10 mov %rax,%r11 movq %rax,%xmm0 testb X86_HAVE(AVX)+kCpuids(%rip) jz .Lsse vmovq %r8,%xmm0 vmovq %r9,%xmm1 vmovq %r10,%xmm2 vmovq %r11,%xmm3 vmovq %r12,%xmm4 vmovq %r13,%xmm5 vmovq %r14,%xmm6 vmovq %r15,%xmm7 vinsertf128 $0x1,%xmm0,%ymm0,%ymm0 vinsertf128 $0x1,%xmm1,%ymm1,%ymm1 vinsertf128 $0x1,%xmm2,%ymm2,%ymm2 vinsertf128 $0x1,%xmm3,%ymm3,%ymm3 vinsertf128 $0x1,%xmm4,%ymm4,%ymm4 vinsertf128 $0x1,%xmm5,%ymm5,%ymm5 vinsertf128 $0x1,%xmm6,%ymm6,%ymm6 vinsertf128 $0x1,%xmm7,%ymm7,%ymm7 .leafepilogue .Lsse: punpcklqdq %xmm0,%xmm0 punpcklqdq %xmm0,%xmm1 punpcklqdq %xmm0,%xmm2 punpcklqdq %xmm0,%xmm3 punpcklqdq %xmm0,%xmm4 punpcklqdq %xmm0,%xmm5 punpcklqdq %xmm0,%xmm6 punpcklqdq %xmm0,%xmm7 .leafepilogue .endfn __polluteregisters_old,globl
4,011
127
jart/cosmopolitan
false
cosmopolitan/libc/testlib/formatbinaryashex.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/mem/mem.h" #include "libc/str/str.h" #include "libc/testlib/testlib.h" #include "libc/x/x.h" void testlib_formatbinaryashex(const char *want, const void *got, size_t n, char **out_v1, char **out_v2) { size_t i; uint8_t b; char *gothex; if (n == -1ul) n = strlen(want) / 2; gothex = xmalloc(n * 2 + 1); gothex[n * 2] = '\0'; for (i = 0; i < n; ++i) { b = ((uint8_t *)got)[i]; gothex[i * 2 + 0] = "0123456789abcdef"[(b >> 4) & 0xf]; gothex[i * 2 + 1] = "0123456789abcdef"[(b >> 0) & 0xf]; } *out_v1 = strdup(want); *out_v2 = gothex; }
2,448
40
jart/cosmopolitan
false
cosmopolitan/libc/testlib/memoryexists.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2022 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" #include "libc/atomic.h" #include "libc/calls/struct/sigaction.h" #include "libc/calls/struct/siginfo.h" #include "libc/calls/ucontext.h" #include "libc/intrin/atomic.h" #include "libc/sysv/consts/sa.h" #include "libc/sysv/consts/sig.h" #include "libc/testlib/testlib.h" #include "third_party/xed/x86.h" static volatile _Thread_local int gotsignal; static void ContinueOnError(int sig, siginfo_t *si, void *vctx) { struct ucontext *ctx = vctx; gotsignal = sig; #ifdef __aarch64__ ctx->uc_mcontext.pc += 4; #elif defined(__x86_64__) struct XedDecodedInst xedd; xed_decoded_inst_zero_set_mode(&xedd, XED_MACHINE_MODE_LONG_64); xed_instruction_length_decode(&xedd, (void *)ctx->uc_mcontext.rip, 15); ctx->uc_mcontext.rip += xedd.length; #else #error "unsupported architecture" #endif /* __x86_64__ */ } /** * Returns true if byte at address `p` is readable. * * This function temporarily catches `SIGSEGV` and `SIGBUS` to recover * on error. It then attempts a volatile read and if it faults, then * this function shall return false. The value at `p` isn't considered. */ noasan bool testlib_memoryexists(const void *p) { volatile char c; const atomic_char *mem = p; struct sigaction old[2]; struct sigaction sa = { .sa_sigaction = ContinueOnError, .sa_flags = SA_SIGINFO, }; gotsignal = 0; _npassert(!sigaction(SIGSEGV, &sa, old + 0)); _npassert(!sigaction(SIGBUS, &sa, old + 1)); c = atomic_load(mem); _npassert(!sigaction(SIGBUS, old + 1, 0)); _npassert(!sigaction(SIGSEGV, old + 0, 0)); return !gotsignal; }
3,429
70
jart/cosmopolitan
false
cosmopolitan/libc/testlib/fastrandomstring.h
#ifndef COSMOPOLITAN_LIBC_TESTLIB_FASTRANDOMSTRING_H_ #define COSMOPOLITAN_LIBC_TESTLIB_FASTRANDOMSTRING_H_ #if !(__ASSEMBLER__ + __LINKER__ + 0) static inline const char *FastRandomString(void) { static unsigned long t; static union { unsigned long x; char b[sizeof(unsigned long)]; } u; u.x = (t = (t * 0xdeaadead) + 0xdeaadead) & 0x7e7e7e7e7e7e7e; return u.b; } #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_TESTLIB_FASTRANDOMSTRING_H_ */
491
17
jart/cosmopolitan
false
cosmopolitan/libc/testlib/hyperion.txt
The fall of Hyperion - a Dream John Keats CANTO I Fanatics have their dreams, wherewith they weave A paradise for a sect; the savage too From forth the loftiest fashion of his sleep Guesses at Heaven; pity these have not Trac'd upon vellum or wild Indian leaf The shadows of melodious utterance. But bare of laurel they live, dream, and die; For Poesy alone can tell her dreams, With the fine spell of words alone can save Imagination from the sable charm And dumb enchantment. Who alive can say, 'Thou art no Poet may'st not tell thy dreams?' Since every man whose soul is not a clod Hath visions, and would speak, if he had loved And been well nurtured in his mother tongue. Whether the dream now purpos'd to rehearse Be poet's or fanatic's will be known When this warm scribe my hand is in the grave. Methought I stood where trees of every clime, Palm, myrtle, oak, and sycamore, and beech, With plantain, and spice blossoms, made a screen; In neighbourhood of fountains, by the noise Soft showering in my ears, and, by the touch Of scent, not far from roses. Turning round I saw an arbour with a drooping roof Of trellis vines, and bells, and larger blooms, Like floral censers swinging light in air; Before its wreathed doorway, on a mound Of moss, was spread a feast of summer fruits, Which, nearer seen, seem'd refuse of a meal By angel tasted or our Mother Eve; For empty shells were scattered on the grass, And grape stalks but half bare, and remnants more, Sweet smelling, whose pure kinds I could not know. Still was more plenty than the fabled horn Thrice emptied could pour forth, at banqueting For Proserpine return'd to her own fields, Where the white heifers low. And appetite More yearning than on earth I ever felt Growing within, I ate deliciously; And, after not long, thirsted, for thereby Stood a cool vessel of transparent juice Sipp'd by the wander'd bee, the which I took, And, pledging all the mortals of the world, And all the dead whose names are in our lips, Drank. That full draught is parent of my theme. No Asian poppy nor elixir fine Of the soon fading jealous Caliphat, No poison gender'd in close monkish cell To thin the scarlet conclave of old men, Could so have rapt unwilling life away. Among the fragrant husks and berries crush'd, Upon the grass I struggled hard against The domineering potion; but in vain: The cloudy swoon came on, and down I sunk Like a Silenus on an antique vase. How long I slumber'd 'tis a chance to guess. When sense of life return'd, I started up As if with wings; but the fair trees were gone, The mossy mound and arbour were no more: I look'd around upon the carved sides Of an old sanctuary with roof august, Builded so high, it seem'd that filmed clouds Might spread beneath, as o'er the stars of heaven; So old the place was, I remember'd none The like upon the earth: what I had seen Of grey cathedrals, buttress'd walls, rent towers, The superannuations of sunk realms, Or Nature's rocks toil'd hard in waves and winds, Seem'd but the faulture of decrepit things To that eternal domed monument. Upon the marble at my feet there lay Store of strange vessels and large draperies, Which needs had been of dyed asbestos wove, Or in that place the moth could not corrupt, So white the linen, so, in some, distinct Ran imageries from a sombre loom. All in a mingled heap confus'd there lay Robes, golden tongs, censer and chafing dish, Girdles, and chains, and holy jewelries. Turning from these with awe, once more I rais'd My eyes to fathom the space every way; The embossed roof, the silent massy range Of columns north and south, ending in mist Of nothing, then to eastward, where black gates Were shut against the sunrise evermore. Then to the west I look'd, and saw far off An image, huge of feature as a cloud, At level of whose feet an altar slept, To be approach'd on either side by steps, And marble balustrade, and patient travail To count with toil the innumerable degrees. Towards the altar sober paced I went, Repressing haste, as too unholy there; And, coming nearer, saw beside the shrine One minist'ring; and there arose a flame. When in mid May the sickening East wind Shifts sudden to the south, the small warm rain Melts out the frozen incense from all flowers, And fills the air with so much pleasant health That even the dying man forgets his shroud; Even so that lofty sacrificial fire, Sending forth Maian incense, spread around Forgetfulness of everything but bliss, And clouded all the altar with soft smoke, From whose white fragrant curtains thus I heard Language pronounc'd: 'If thou canst not ascend 'These steps, die on that marble where thou art. 'Thy flesh, near cousin to the common dust, 'Will parch for lack of nutriment thy bones 'Will wither in few years, and vanish so 'That not the quickest eye could find a grain 'Of what thou now art on that pavement cold. 'The sands of thy short life are spent this hour, 'And no hand in the universe can turn 'Thy hourglass, if these gummed leaves be burnt 'Ere thou canst mount up these immortal steps.' I heard, I look'd: two senses both at once, So fine, so subtle, felt the tyranny Of that fierce threat and the hard task proposed. Prodigious seem'd the toil, the leaves were yet Burning when suddenly a palsied chill Struck from the paved level up my limbs, And was ascending quick to put cold grasp Upon those streams that pulse beside the throat: I shriek'd; and the sharp anguish of my shriek Stung my own ears I strove hard to escape The numbness; strove to gain the lowest step. Slow, heavy, deadly was my pace: the cold Grew stifling, suffocating, at the heart; And when I clasp'd my hands I felt them not. One minute before death, my iced foot touch'd The lowest stair; and as it touch'd, life seem'd To pour in at the toes: I mounted up, As once fair angels on a ladder flew From the green turf to Heaven. 'Holy Power,' Cried I, approaching near the horned shrine, 'What am I that should so be saved from death? 'What am I that another death come not 'To choke my utterance sacrilegious here?' Then said the veiled shadow 'Thou hast felt 'What 'tis to die and live again before 'Thy fated hour. That thou hadst power to do so 'Is thy own safety; thou hast dated on 'Thy doom.' 'High Prophetess,' said I, 'purge off, 'Benign, if so it please thee, my mind's film.' 'None can usurp this height,' return'd that shade, 'But those to whom the miseries of the world 'Are misery, and will not let them rest. 'All else who find a haven in the world, 'Where they may thoughtless sleep away their days, 'If by a chance into this fane they come, 'Rot on the pavement where thou rottedst half.' 'Are there not thousands in the world,' said I, Encourag'd by the sooth voice of the shade, 'Who love their fellows even to the death; 'Who feel the giant agony of the world; 'And more, like slaves to poor humanity, 'Labour for mortal good? I sure should see 'Other men here; but I am here alone.' 'Those whom thou spak'st of are no vision'ries,' Rejoin'd that voice; 'they are no dreamers weak; 'They seek no wonder but the human face, 'No music but a happy noted voice; 'They come not here, they have no thought to come; 'And thou art here, for thou art less than they: 'What benefit canst thou do, or all thy tribe, 'To the great world? Thou art a dreaming thing, 'A fever of thyself think of the Earth; 'What bliss even in hope is there for thee? 'What haven? every creature hath its home; 'Every sole man hath days of joy and pain, 'Whether his labours be sublime or low 'The pain alone; the joy alone; distinct: 'Only the dreamer venoms all his days, 'Bearing more woe than all his sins deserve. 'Therefore, that happiness be somewhat shar'd, 'Such things as thou art are admitted oft 'Into like gardens thou didst pass erewhile, 'And suffer'd in these temples: for that cause 'Thou standest safe beneath this statue's knees.' 'That I am favour'd for unworthiness, 'By such propitious parley medicin'd 'In sickness not ignoble, I rejoice, 'Aye, and could weep for love of such award.' So answer'd I, continuing, 'If it please, 'Majestic shadow, tell me: sure not all 'Those melodies sung into the world's ear 'Are useless: sure a poet is a sage; 'A humanist, physician to all men. 'That I am none I feel, as vultures feel 'They are no birds when eagles are abroad. 'What am I then? Thou spakest of my tribe: 'What tribe?' The tall shade veil'd in drooping white Then spake, so much more earnest, that the breath Moved the thin linen folds that drooping hung About a golden censer from the hand Pendent. 'Art thou not of the dreamer tribe? 'The poet and the dreamer are distinct, 'Diverse, sheer opposite, antipodes. 'The one pours out a balm upon the world, 'The other vexes it.' Then shouted I Spite of myself, and with a Pythia's spleen, 'Apollo! faded! O far flown Apollo! 'Where is thy misty pestilence to creep 'Into the dwellings, through the door crannies 'Of all mock lyrists, large self worshipers, 'And careless Hectorers in proud bad verse. 'Though I breathe death with them it will be life 'To see them sprawl before me into graves. 'Majestic shadow, tell me where I am, 'Whose altar this; for whom this incense curls; 'What image this whose face I cannot see, 'For the broad marble knees; and who thou art, 'Of accent feminine so courteous?' Then the tall shade, in drooping linens veil'd, Spoke out, so much more earnest, that her breath Stirr'd the thin folds of gauze that drooping hung About a golden censer from her hand Pendent; and by her voice I knew she shed Long treasured tears. 'This temple, sad and lone, 'Is all spar'd from the thunder of a war 'Foughten long since by giant hierarchy 'Against rebellion: this old image here, 'Whose carved features wrinkled as he fell, 'Is Saturn's; I Moneta, left supreme 'Sole priestess of this desolation.' I had no words to answer, for my tongue, Useless, could find about its roofed home No syllable of a fit majesty To make rejoinder to Moneta's mourn. There was a silence, while the altar's blaze Was fainting for sweet food: I look'd thereon, And on the paved floor, where nigh were piled Faggots of cinnamon, and many heaps Of other crisped spice wood then again I look'd upon the altar, and its horns Whiten'd with ashes, and its lang'rous flame, And then upon the offerings again; And so by turns till sad Moneta cried, 'The sacrifice is done, but not the less 'Will I be kind to thee for thy good will. 'My power, which to me is still a curse, 'Shall be to thee a wonder; for the scenes 'Still swooning vivid through my globed brain 'With an electral changing misery 'Thou shalt with those dull mortal eyes behold, 'Free from all pain, if wonder pain thee not.' As near as an immortal's sphered words Could to a mother's soften, were these last: And yet I had a terror of her robes, And chiefly of the veils, that from her brow Hung pale, and curtain'd her in mysteries That made my heart too small to hold its blood. This saw that G-ddess, and with sacred hand Parted the veils. Then saw I a wan face, Not pin'd by human sorrows, but bright blanch'd By an immortal sickness which kills not; It works a constant change, which happy death Can put no end to; deathwards progressing To no death was that visage; it had pass'd The lily and the snow; and beyond these I must not think now, though I saw that face But for her eyes I should have fled away. They held me back, with a benignant light Soft mitigated by divinest lids Half closed, and visionless entire they seem'd Of all external things; they saw me not, But in blank splendour beam'd like the mild moon, Who comforts those she sees not, who knows not What eyes are upward cast. As I had found A grain of gold upon a mountain side, And twing'd with avarice strain'd out my eyes To search its sullen entrails rich with ore, So at the view of sad Moneta's brow I ach'd to see what things the hollow brain Behind enwombed: what high tragedy In the dark secret chambers of her skull Was acting, that could give so dread a stress To her cold lips, and fill with such a light Her planetary eyes, and touch her voice With such a sorrow 'Shade of Memory!' Cried I, with act adorant at her feet, 'By all the gloom hung round thy fallen house, 'By this last temple, by the golden age, 'By great Apollo, thy dear Foster Child, 'And by thyself, forlorn divinity, 'The pale Omega of a withered race, 'Let me behold, according as thou saidst, 'What in thy brain so ferments to and fro!' No sooner had this conjuration pass'd My devout lips, than side by side we stood (Like a stunt bramble by a solemn pine) Deep in the shady sadness of a vale, Far sunken from the healthy breath of morn, Far from the fiery noon and eve's one star. Onward I look'd beneath the gloomy boughs, And saw, what first I thought an image huge, Like to the image pedestal'd so high In Saturn's temple. Then Moneta's voice Came brief upon mine ear 'So Saturn sat When he had lost his realms ' whereon there grew A power within me of enormous ken To see as a g-d sees, and take the depth Of things as nimbly as the outward eye Can size and shape pervade. The lofty theme At those few words hung vast before my mind, With half unravel'd web. I set myself Upon an eagle's watch, that I might see, And seeing ne'er forget. No stir of life Was in this shrouded vale, not so much air As in the zoning of a summer's day Robs not one light seed from the feather'd grass, But where the dead leaf fell there did it rest. A stream went voiceless by, still deaden'd more By reason of the fallen divinity Spreading more shade; the Naiad 'mid her reeds Press'd her cold finger closer to her lips. Along the margin sand large footmarks went No farther than to where old Saturn's feet Had rested, and there slept, how long a sleep! Degraded, cold, upon the sodden ground His old right hand lay nerveless, listless, dead, Unsceptred; and his realmless eyes were clos'd, While his bow'd head seem'd listening to the Earth, His ancient mother, for some comfort yet. It seem'd no force could wake him from his place; But there came one who with a kindred hand Touch'd his wide shoulders after bending low With reverence, though to one who knew it not. Then came the griev'd voice of Mnemosyne, And griev'd I hearken'd. 'That divinity 'Whom thou saw'st step from yon forlornest wood, 'And with slow pace approach our fallen King, 'Is Thea, softest natur'd of our brood.' I mark'd the G-ddess in fair statuary Surpassing wan Moneta by the head, And in her sorrow nearer woman's tears. There was a listening fear in her regard, As if calamity had but begun; As if the vanward clouds of evil days Had spent their malice, and the sullen rear Was with its stored thunder labouring up. One hand she press'd upon that aching spot Where beats the human heart, as if just there, Though an immortal, she felt cruel pain; The other upon Saturn's bended neck She laid, and to the level of his hollow ear Leaning with parted lips, some words she spake In solemn tenor and deep organ tune; Some mourning words, which in our feeble tongue Would come in this like accenting; how frail To that large utterance of the early G-ds! 'Saturn! look up and for what, poor lost King? 'I have no comfort for thee; no not one; 'I cannot cry, Wherefore thus sleepest thou? 'For Heaven is parted from thee, and the Earth 'Knows thee not, so afflicted, for a G-d; 'And Ocean too, with all its solemn noise, 'Has from thy sceptre pass'd, and all the air 'Is emptied of thine hoary majesty: 'Thy thunder, captious at the new command, 'Rumbles reluctant o'er our fallen house; 'And thy sharp lightning, in unpracticed hands, 'Scorches and burns our once serene domain. 'With such remorseless speed still come new woes, 'That unbelief has not a space to breathe. 'Saturn! sleep on: Me thoughtless, why should I 'Thus violate thy slumbrous solitude? 'Why should I ope thy melancholy eyes? 'Saturn, sleep on, while at thy feet I weep.' As when upon a tranced summer night Forests, branch charmed by the earnest stars, Dream, and so dream all night without a noise, Save from one gradual solitary gust, Swelling upon the silence; dying off; As if the ebbing air had but one wave; So came these words, and went; the while in tears She press'd her fair large forehead to the earth, Just where her fallen hair might spread in curls A soft and silken mat for Saturn's feet. Long, long those two were postured motionless, Like sculpture builded up upon the grave Of their own power. A long awful time I look'd upon them: still they were the same; The frozen G-d still bending to the earth, And the sad G-ddess weeping at his feet, Moneta silent. Without stay or prop But my own weak mortality, I bore The load of this eternal quietude, The unchanging gloom, and the three fixed shapes Ponderous upon my senses, a whole moon. For by my burning brain I measured sure Her silver seasons shedded on the night, And ever day by day methought I grew More gaunt and ghostly. Oftentimes I pray'd Intense, that Death would take me from the vale And all its burthens gasping with despair Of change, hour after hour I curs'd myself; Until old Saturn rais'd his faded eyes, And look'd around and saw his kingdom gone, And all the gloom and sorrow of the place, And that fair kneeling G-ddess at his feet. As the moist scent of flowers, and grass, and leaves Fills forest dells with a pervading air, Known to the woodland nostril, so the words Of Saturn fill'd the mossy glooms around, Even to the hollows of time eaten oaks And to the windings of the foxes' hole, With sad low tones, while thus he spake, and sent Strange musings to the solitary Pan. 'Moan, brethren, moan; for we are swallow'd up 'And buried from all G-dlike exercise 'Of influence benign on planets pale, 'And peaceful sway above man's harvesting, 'And all those acts which Deity supreme 'Doth ease its heart of love in. Moan and wail, 'Moan, brethren, moan; for lo, the rebel spheres 'Spin round, the stars their ancient courses keep, 'Clouds still with shadowy moisture haunt the earth, 'Still suck their fill of light from sun and moon, 'Still buds the tree, and still the sea shores murmur; 'There is no death in all the Universe, 'No smell of death there shall be death Moan, moan, 'Moan, Cybele, moan; for thy pernicious babes 'Have changed a G-d into a shaking Palsy. 'Moan, brethren, moan, for I have no strength left, 'Weak as the reed weak feeble as my voice 'O, O, the pain, the pain of feebleness. 'Moan, moan, for still I thaw or give me help; 'Throw down those imps, and give me victory. 'Let me hear other groans, and trumpets blown 'Of triumph calm, and hymns of festival 'From the gold peaks of Heaven's high piled clouds; 'Voices of soft proclaim, and silver stir 'Of strings in hollow shells; and let there be 'Beautiful things made new, for the surprise 'Of the sky children.' So he feebly ceas'd, With such a poor and sickly sounding pause, Methought I heard some old man of the earth Bewailing earthly loss; nor could my eyes And ears act with that pleasant unison of sense Which marries sweet sound with the grace of form, And dolorous accent from a tragic harp With large limb'd visions. More I scrutinized: Still fix'd he sat beneath the sable trees, Whose arms spread straggling in wild serpent forms, With leaves all hush'd; his awful presence there (Now all was silent) gave a deadly lie To what I erewhile heard only his lips Trembled amid the white curls of his beard. They told the truth, though, round, the snowy locks Hung nobly, as upon the face of heaven A mid day fleece of clouds. Thea arose, And stretched her white arm through the hollow dark, Pointing some whither: whereat he too rose Like a vast giant, seen by men at sea To grow pale from the waves at dull midnight. They melted from my sight into the woods; Ere I could turn, Moneta cried, 'These twain 'Are speeding to the families of grief, 'Where roof'd in by black rocks they waste, in pain 'And darkness, for no hope.' And she spake on, As ye may read who can unwearied pass Onward from the antechamber of this dream, Where even at the open doors awhile I must delay, and glean my memory Of her high phrase: perhaps no further dare. CANTO II 'Mortal, that thou may'st understand aright, 'I humanize my sayings to thine ear, 'Making comparisons of earthly things; 'Or thou might'st better listen to the wind, 'Whose language is to thee a barren noise, 'Though it blows legend laden through the trees. 'In melancholy realms big tears are shed, 'More sorrow like to this, and such like woe, 'Too huge for mortal tongue, or pen of scribe. 'The Titans fierce, self hid or prison bound, 'Groan for the old allegiance once more, 'Listening in their doom for Saturn's voice. 'But one of our whole eagle brood still keeps 'His sov'reignty, and rule, and majesty; 'Blazing Hyperion on his orbed fire 'Still sits, still snuffs the incense teeming up 'From man to the sun's G-d: yet unsecure, 'For as upon the earth dire prodigies 'Fright and perplex, so also shudders he: 'Nor at dog's howl or gloom bird's Even screech, 'Or the familiar visitings of one 'Upon the first toll of his passing bell: 'But horrors, portioned to a giant nerve, 'Make great Hyperion ache. His palace bright, 'Bastion'd with pyramids of glowing gold, 'And touch'd with shade of bronzed obelisks, 'Glares a blood red through all the thousand courts, 'Arches, and domes, and fiery galleries: 'And all its curtains of Aurorian clouds 'Flush angerly; when he would taste the wreaths 'Of incense breath'd aloft from sacred hills, 'Instead of sweets his ample palate takes 'Savour of poisonous brass and metals sick. 'Wherefore when harbour'd in the sleepy West, 'After the full completion of fair day, 'For rest divine upon exalted couch 'And slumber in the arms of melody, 'He paces through the pleasant hours of ease 'With strides colossal, on from hall to hall; 'While far within each aisle and deep recess 'His winged minions in close clusters stand 'Amaz'd, and full of fear; like anxious men, 'Who on a wide plain gather in sad troops, 'When earthquakes jar their battlements and towers. 'Even now, while Saturn, roused from icy trance, 'Goes step for step with Thea from yon woods, 'Hyperion, leaving twilight in the rear, 'Is sloping to the threshold of the West. 'Thither we tend.' Now in clear light I stood, Reliev'd from the dusk vale. Mnemosyne Was sitting on a square edg'd polish'd stone, That in its lucid depth reflected pure Her priestess garments. My quick eyes ran on From stately nave to nave, from vault to vault, Through bow'rs of fragrant and enwreathed light And diamond paved lustrous long arcades. Anon rush'd by the bright Hyperion; His flaming robes stream'd out beyond his heels, And gave a roar, as if of earthly fire, That scared away the meek ethereal hours And made their dove wings tremble. On he flared. THE END
22,851
548
jart/cosmopolitan
false
cosmopolitan/libc/testlib/blocktronics.txt
░▄██▒▄█ ▐██ ░░░ ▀▀████▒▀█▄ ▐███▓██░ ██▌ ▀████▄■█▄ ▐█▓███▀█░██▀ ░ ░▀█████▓▄ ▐█▓██▀▄█▒██▀ ▄▄░ ▄▄▄ ░░░ ░▀████▒▄ ▐████▀▄█■█▀ ▀▀ ░█████░ ▐█▓█▀████▀ ░ ▐▓███▒ █░███▀▀ ░░░ ▄█ ░░░ █████ ▐█▓█░▀▀ ░░▄█▄▄▄▄▄ ▀▄ ▌▄▄▄░▄▄▄▄▄ ▐████░ ▐███▌ ▄▀█████████▄ ▌▐▄████████▄ ▐▓███░ ▐███░░░▀▄█▀▄▄████▄▀░ ▐████████▒ ▀ ░███░ ░████░ ▓▀ ▄███████▀▌ ▀▄■████▀▀█▀ ██▀█ ▓███░ ░▄▀▀░░░ ▀ ░░▌ ▄▀▀▄░░▀░▄▀▄ ▐██▀▄ ░███░ ▄▓▓▄▄░▀▀█▀█ ▌░░ ▀█▀█▀▀ ▐██▀ █▀▄▐██ ▀░░ ▄▀ ▐ █ ▀ ▄▄▄░ ░▀▄█▄▀█ ▌▄ █▓ ▒ ░ █▄█▄▀▄▄▄███▄▀▄ ░░ ░ ▀ █▌ █▌▄░▌ ░░░▄▀█▀███████▄▀▄▀▄▀▀▄▄▄ █▀█░▐ ██▄ ░░░▄█▄▀██▄█■██████▄█▄█▄■▀█░ ▐░▐ ▀██░ ░▄██████████████████▄█▄█ ░█ ░ ▄▀ ▀▓█▄▓░░ ▒█▀█████████████████████▒ ██▀ ▀███ ▓▒ ██████████████▀▀▀▀█▄▀ ░▄█▒ ▀███ ▀█▄▀▄█████▀▀ ▓▓▓▄░ ▐ ░▄██ ▀██ ▄███████▄████████▀░░ ░▄██ ▄██▀▀▄ █▄▀▄██▒▒███████████▀▀▀▄░ ░███░ ▄██▀▄▄░░▀▐▄████▄ █████▀▄░░█▀▄▀░░ ▄██░ █████▄▄▄███▀░█▌██▄▀▀█████▄▄░░░▄▄███▀██▄ ▄▀▀▀▄▄ ▀██████▀■▄█▄▄ ░▀███████████████▓▓░░▄██▀▄████▄▄▀▄ █▀█ █ █▀█ █▀█ █▄▀ ▐▀█▀▌█▀█ █▀█ █▄ █ ▀█▀ █▀█ █▀▀ █▀▄ █ █ █ █ █ ▀▄ █ █▀▄ █ █ █ ▀█ █ █ ▀▀█ █▄█ █▄▌█▄█ █▄█ █ █ █ █ █ █▄█ █ █ ▄█▄ █▄█ █▄█ THERE WILL BE BLOCKS march 01 2017
3,193
33
jart/cosmopolitan
false
cosmopolitan/libc/testlib/ezbenchreport.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/fmt/fmt.h" #include "libc/math.h" #include "libc/runtime/runtime.h" #include "libc/stdio/stdio.h" #include "libc/testlib/testlib.h" #include "libc/time/time.h" #include "libc/x/x.h" STATIC_YOINK("strnwidth"); void __testlib_ezbenchreport(const char *form, double c1, double c2) { long ns1, ns2; __warn_if_powersave(); ns1 = lrintl(ConvertTicksToNanos(c1)); ns2 = lrintl(ConvertTicksToNanos(c2)); (fprintf)(stderr, VEIL("r", " * %-19s l: %,9luc %,9luns m: %,9luc %,9luns\n"), form, lrint(c1), ns1, lrint(c2), ns2); } void __testlib_ezbenchreport_n(const char *form, char z, size_t n, double c) { char msg[128]; uint64_t bps; long double cn, lat; __warn_if_powersave(); (snprintf)(msg, sizeof(msg), "%s %c=%d", form, z, n); cn = ConvertTicksToNanos(c); if (!n) { (fprintf)(stderr, "\n"); (fprintf)(stderr, " * %-28s", msg); if (cn < 1) { (fprintf)(stderr, VEIL("r", " %,9lu %-12s"), (int64_t)(cn * 1024), "picoseconds"); } else if (cn > 1024) { (fprintf)(stderr, VEIL("r", " %,9lu %-12s"), (int64_t)(cn / 1024), "microseconds"); } else { (fprintf)(stderr, VEIL("r", " %,9lu %-12s"), (int64_t)cn, "nanoseconds"); } } else { (fprintf)(stderr, " * %-28s", msg); bps = n / cn * 1e9; lat = cn / n; if (lat < 1e-3) { (fprintf)(stderr, VEIL("r", " %,9lu %-12s"), (int64_t)(lat * 1024 * 1024), "fs/byte"); } else if (lat < 1) { (fprintf)(stderr, VEIL("r", " %,9lu %-12s"), (int64_t)(lat * 1024), "ps/byte"); } else if (lat > 1024) { (fprintf)(stderr, VEIL("r", " %,9lu %-12s"), (int64_t)(lat / 1024), "µs/byte"); } else { (fprintf)(stderr, VEIL("r", " %,9lu %-12s"), (int64_t)lat, "ns/byte"); } if (bps < 10 * 1000) { (fprintf)(stderr, VEIL("r", " %,9lu b/s"), bps); } else if (bps < 10 * 1000 * 1024) { (fprintf)(stderr, VEIL("r", " %,9lu kb/s"), bps / 1024); } else if (bps < 10ul * 1000 * 1024 * 1024) { (fprintf)(stderr, VEIL("r", " %,9lu mb/s"), bps / (1024 * 1024)); } else if (bps < 10ul * 1000 * 1024 * 1024 * 1024) { (fprintf)(stderr, VEIL("r", " %,9lu GB/s"), bps / (1024 * 1024 * 1024)); } else { (fprintf)(stderr, VEIL("r", " %,9lu TB/s"), bps / (1024ul * 1024 * 1024 * 1024)); } } (fprintf)(stderr, "\n", form); }
4,288
89
jart/cosmopolitan
false
cosmopolitan/libc/testlib/getcore.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2021 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/nexgen32e/rdtscp.h" #include "libc/testlib/ezbench.h" int __testlib_getcore(void) { #ifdef __x86__ long tscaux; tscaux = rdpid(); return TSC_AUX_CORE(tscaux); #else return 0; #endif }
2,044
31
jart/cosmopolitan
false
cosmopolitan/libc/testlib/endswith.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/str/str.h" #include "libc/testlib/testlib.h" bool testlib_endswith(size_t cw, const void *s, const void *suffix) { if (s == suffix) return true; if (!s || !suffix) return false; return cw == sizeof(wchar_t) ? _wcsendswith(s, suffix) : cw == sizeof(char16_t) ? _endswith16(s, suffix) : _endswith(s, suffix); }
2,213
29
jart/cosmopolitan
false
cosmopolitan/libc/testlib/runner.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/log/log.h" #include "libc/nexgen32e/nexgen32e.h" #include "libc/runtime/runtime.h" #include "libc/stdio/stdio.h" #include "libc/testlib/testlib.h" /** * Runs all TEST(), FIXTURE(), etc. recorded by ld. * @see libc/testlib/testlib.h * @see ape/ape.lds */ void testlib_runalltests(void) { if ((intptr_t)__testcase_end > (intptr_t)__testcase_start) { if (testlib_countfixtures(__combo_start, __combo_end)) { testlib_runcombos(__testcase_start, __testcase_end, __combo_start, __combo_end); } else { testlib_runtestcases(__testcase_start, __testcase_end, NULL); testlib_runfixtures(__testcase_start, __testcase_end, __fixture_start, __fixture_end); testlib_finish(); } } }
2,644
44
jart/cosmopolitan
false
cosmopolitan/libc/testlib/combo.S
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│ │vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/macros.internal.h" // Decentralized section for test combo registration. // // @see ape/ape.lds .section .piro.relo.sort.combo.1,"aw",@nobits .type __combo_start,@object .type __combo_end,@object .globl __combo_start,__combo_end .hidden __combo_start,__combo_end .byte 0 .balign __SIZEOF_POINTER__ .underrun __combo_start: .previous/* ... decentralized content ... */.section .piro.relo.sort.combo.3,"aw",@nobits __combo_end: .quad 0 .overrun .previous
2,321
42
jart/cosmopolitan
false
cosmopolitan/libc/testlib/strerror.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2022 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/errno.h" #include "libc/str/str.h" #include "libc/testlib/testlib.h" const char *testlib_strerror(void) { return strerror(errno); }
1,986
26
jart/cosmopolitan
false
cosmopolitan/libc/testlib/binequals.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/str/str.h" #include "libc/str/tab.internal.h" #include "libc/testlib/testlib.h" /** * Tests that raw memory is equal to visual representation, e.g. * * testlib_binequals(u" ☺☻♥", "\0\1\2\3", -1ul); * * @see libc/nexgen32e/kCp437.S */ bool testlib_binequals(const char16_t *want, const void *got, size_t n) { size_t i; const unsigned char *p = (const unsigned char *)got; if (!got) return false; for (i = 0; i < n; ++i) { if (!want[i]) break; if (i == n) break; if (want[i] != kCp437[p[i]]) return false; } return true; }
2,412
41
jart/cosmopolitan
false
cosmopolitan/libc/testlib/bench.h
#ifndef COSMOPOLITAN_LIBC_BENCH_H_ #define COSMOPOLITAN_LIBC_BENCH_H_ #include "libc/nexgen32e/bench.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ /** * @fileoverview Microbenchmarking Toolz. */ #define BENCHLOOPER(START, STOP, N, EXPR) \ ({ \ long Iter = 1; \ long Toto = (N); \ uint64_t Time1 = START(); \ asm volatile("" ::: "memory"); \ for (; Iter < Toto; ++Iter) { \ asm volatile("" ::: "memory"); \ EXPR; \ asm volatile("" ::: "memory"); \ } \ asm volatile("" ::: "memory"); \ uint64_t Time2 = STOP(); \ (double)(long)(Time2 - Time1) / Iter; \ }) #ifndef BENCHLOOP /* TODO(jart): DELETE */ #define BENCHLOOP(START, STOP, N, INIT, EXPR) \ ({ \ double Average; \ uint64_t Time1, Time2; \ unsigned long Iter, Count; \ for (Average = 1, Iter = 1, Count = (N); Iter < Count; ++Iter) { \ INIT; \ Time1 = START(); \ asm volatile("" ::: "memory"); \ EXPR; \ asm volatile("" ::: "memory"); \ Time2 = STOP(); \ Average += 1. / Iter * ((int)(Time2 - Time1) - Average); \ } \ Average; \ }) #endif /* BENCHLOOP */ COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_BENCH_H_ */
2,082
50
jart/cosmopolitan
false
cosmopolitan/libc/testlib/almostequalf.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/testlib/testlib.h" /* ┌sign │ ┌exponent │ │ ┌fraction │ │ │ │┌┴─────┐┌┴────────────────────┐*/ #define BINARY32_SIGN 0b10000000000000000000000000000000u #define BINARY32_EXPO 0b01111111100000000000000000000000u #define BINARY32_FRAC 0b00000000011111111111111111111111u
2,332
29
jart/cosmopolitan
false
cosmopolitan/libc/testlib/testlib.mk
#-*-mode:makefile-gmake;indent-tabs-mode:t;tab-width:8;coding:utf-8-*-┐ #───vi: set et ft=make ts=8 tw=8 fenc=utf-8 :vi───────────────────────┘ # Description: # Cosmopolitan Testing Library. PKGS += LIBC_TESTLIB #─────────────────────────────────────────────────────────────────────────────── LIBC_TESTLIB_ARTIFACTS += LIBC_TESTLIB_A LIBC_TESTLIB = $(LIBC_TESTLIB_A_DEPS) $(LIBC_TESTLIB_A) LIBC_TESTLIB_A = o/$(MODE)/libc/testlib/testlib.a LIBC_TESTLIB_A_CHECKS = $(LIBC_TESTLIB_A).pkg LIBC_TESTLIB_A_ASSETS = \ libc/testlib/blocktronics.txt \ libc/testlib/viewables.txt \ libc/testlib/hyperion.txt \ libc/testlib/moby.txt LIBC_TESTLIB_A_HDRS = \ libc/testlib/bench.h \ libc/testlib/blocktronics.h \ libc/testlib/ezbench.h \ libc/testlib/fastrandomstring.h \ libc/testlib/hyperion.h \ libc/testlib/moby.h \ libc/testlib/subprocess.h \ libc/testlib/testlib.h \ libc/testlib/viewables.h LIBC_TESTLIB_A_SRCS_S = \ libc/testlib/bench.S \ libc/testlib/blocktronics.S \ libc/testlib/combo.S \ libc/testlib/fixture.S \ libc/testlib/hyperion.S \ libc/testlib/moby.S \ libc/testlib/polluteregisters.S \ libc/testlib/testcase.S \ libc/testlib/thrashcodecache.S \ libc/testlib/viewables.S LIBC_TESTLIB_A_SRCS_C = \ libc/testlib/almostequallongdouble.c \ libc/testlib/benchrunner.c \ libc/testlib/binequals.c \ libc/testlib/clearxmmregisters.c \ libc/testlib/comborunner.c \ libc/testlib/contains.c \ libc/testlib/endswith.c \ libc/testlib/extract.c \ libc/testlib/ezbenchcontrol.c \ libc/testlib/ezbenchreport.c \ libc/testlib/ezbenchwarn.c \ libc/testlib/fixturerunner.c \ libc/testlib/formatbinaryasglyphs.c \ libc/testlib/formatbinaryashex.c \ libc/testlib/formatbool.c \ libc/testlib/formatfloat.c \ libc/testlib/formatint.c \ libc/testlib/formatrange.c \ libc/testlib/formatstr.c \ libc/testlib/getcore.c \ libc/testlib/geterrno.c \ libc/testlib/getinterrupts.c \ libc/testlib/globals.c \ libc/testlib/hexequals.c \ libc/testlib/incrementfailed.c \ libc/testlib/memoryexists.c \ libc/testlib/quota.c \ libc/testlib/seterrno.c \ libc/testlib/shoulddebugbreak.c \ libc/testlib/showerror.c \ libc/testlib/startswith.c \ libc/testlib/strcaseequals.c \ libc/testlib/strequals.c \ libc/testlib/strerror.c \ libc/testlib/testrunner.c \ libc/testlib/thunks.c \ libc/testlib/waitforexit.c \ libc/testlib/waitforterm.c \ libc/testlib/yield.c LIBC_TESTLIB_A_SRCS = \ $(LIBC_TESTLIB_A_SRCS_S) \ $(LIBC_TESTLIB_A_SRCS_C) LIBC_TESTLIB_A_OBJS = \ $(LIBC_TESTLIB_A_SRCS_C:%.c=o/$(MODE)/%.o) \ $(LIBC_TESTLIB_A_SRCS_S:%.S=o/$(MODE)/%.o) \ $(LIBC_TESTLIB_A_ASSETS:%=o/$(MODE)/%.zip.o) LIBC_TESTLIB_A_DIRECTDEPS = \ LIBC_CALLS \ LIBC_FMT \ LIBC_INTRIN \ LIBC_LOG \ LIBC_MEM \ LIBC_NEXGEN32E \ LIBC_NT_KERNEL32 \ LIBC_RUNTIME \ LIBC_STDIO \ LIBC_STR \ LIBC_STUBS \ LIBC_SYSV \ LIBC_SYSV_CALLS \ LIBC_TIME \ LIBC_TINYMATH \ LIBC_X \ LIBC_ZIPOS \ THIRD_PARTY_COMPILER_RT \ THIRD_PARTY_DLMALLOC \ THIRD_PARTY_GDTOA \ THIRD_PARTY_XED LIBC_TESTLIB_A_DEPS := \ $(call uniq,$(foreach x,$(LIBC_TESTLIB_A_DIRECTDEPS),$($(x)))) $(LIBC_TESTLIB_A): \ libc/testlib/ \ $(LIBC_TESTLIB_A).pkg \ $(LIBC_TESTLIB_A_OBJS) $(LIBC_TESTLIB_A).pkg: \ $(LIBC_TESTLIB_A_OBJS) \ $(foreach x,$(LIBC_TESTLIB_A_DIRECTDEPS),$($(x)_A).pkg) o/$(MODE)/libc/testlib/blocktronics.o: libc/testlib/blocktronics.txt o/$(MODE)/libc/testlib/viewables.o: libc/testlib/viewables.txt o/$(MODE)/libc/testlib/hyperion.o: libc/testlib/hyperion.txt o/$(MODE)/libc/testlib/moby.o: libc/testlib/moby.txt # these assembly files are safe to build on aarch64 o/$(MODE)/libc/testlib/bench.o: libc/testlib/bench.S @$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $< o/$(MODE)/libc/testlib/blocktronics.o: libc/testlib/blocktronics.S @$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $< o/$(MODE)/libc/testlib/combo.o: libc/testlib/combo.S @$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $< o/$(MODE)/libc/testlib/fixture.o: libc/testlib/fixture.S @$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $< o/$(MODE)/libc/testlib/hyperion.o: libc/testlib/hyperion.S @$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $< o/$(MODE)/libc/testlib/moby.o: libc/testlib/moby.S @$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $< o/$(MODE)/libc/testlib/polluteregisters.o: libc/testlib/polluteregisters.S @$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $< o/$(MODE)/libc/testlib/testcase.o: libc/testlib/testcase.S @$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $< o/$(MODE)/libc/testlib/thrashcodecache.o: libc/testlib/thrashcodecache.S @$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $< o/$(MODE)/libc/testlib/viewables.o: libc/testlib/viewables.S @$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $< #─────────────────────────────────────────────────────────────────────────────── LIBC_TESTLIB_ARTIFACTS += LIBC_TESTLIB_RUNNER_A LIBC_TESTLIB_RUNNER = $(LIBC_TESTLIB_RUNNER_A_DEPS) $(LIBC_TESTLIB_RUNNER_A) LIBC_TESTLIB_RUNNER_A = o/$(MODE)/libc/testlib/runner.a LIBC_TESTLIB_RUNNER_A_SRCS = libc/testlib/runner.c LIBC_TESTLIB_RUNNER_A_CHECKS = $(LIBC_TESTLIB_RUNNER_A).pkg LIBC_TESTLIB_RUNNER_A_OBJS = \ $(LIBC_TESTLIB_RUNNER_A_SRCS:%.c=o/$(MODE)/%.o) LIBC_TESTLIB_RUNNER_A_DIRECTDEPS = \ LIBC_FMT \ LIBC_INTRIN \ LIBC_NEXGEN32E \ LIBC_RUNTIME \ LIBC_STDIO \ LIBC_STR \ LIBC_STUBS \ LIBC_TESTLIB LIBC_TESTLIB_RUNNER_A_DEPS := \ $(call uniq,$(foreach x,$(LIBC_TESTLIB_RUNNER_A_DIRECTDEPS),$($(x)))) $(LIBC_TESTLIB_RUNNER_A): \ libc/testlib/ \ $(LIBC_TESTLIB_RUNNER_A).pkg \ $(LIBC_TESTLIB_RUNNER_A_OBJS) $(LIBC_TESTLIB_RUNNER_A).pkg: \ $(LIBC_TESTLIB_RUNNER_A_OBJS) \ $(foreach x,$(LIBC_TESTLIB_RUNNER_A_DIRECTDEPS),$($(x)_A).pkg) #─────────────────────────────────────────────────────────────────────────────── LIBC_TESTLIB_ARTIFACTS += LIBC_TESTMAIN LIBC_TESTMAIN = \ $(LIBC_TESTMAIN_DEPS) \ $(LIBC_TESTMAIN_OBJS) LIBC_TESTMAIN_CHECKS = \ o/$(MODE)/libc/testlib/testmain.pkg LIBC_TESTMAIN_SRCS = \ libc/testlib/testmain.c LIBC_TESTMAIN_OBJS = \ o/$(MODE)/libc/testlib/testmain.o LIBC_TESTMAIN_DIRECTDEPS = \ LIBC_CALLS \ LIBC_INTRIN \ LIBC_LOG \ LIBC_MEM \ LIBC_NEXGEN32E \ LIBC_RUNTIME \ LIBC_STDIO \ LIBC_STUBS \ LIBC_SYSV \ LIBC_SYSV_CALLS \ LIBC_TESTLIB \ LIBC_TESTLIB_RUNNER \ THIRD_PARTY_DLMALLOC \ THIRD_PARTY_GETOPT LIBC_TESTMAIN_DEPS := \ $(call uniq,$(foreach x,$(LIBC_TESTMAIN_DIRECTDEPS),$($(x)))) o/$(MODE)/libc/testlib/testmain.pkg: \ $(LIBC_TESTMAIN_OBJS) \ $(foreach x,$(LIBC_TESTMAIN_DIRECTDEPS),$($(x)_A).pkg) #─────────────────────────────────────────────────────────────────────────────── LIBC_TESTLIB_LIBS = $(foreach x,$(LIBC_TESTLIB_ARTIFACTS),$($(x)_A)) LIBC_TESTLIB_ARCHIVES = $(foreach x,$(LIBC_TESTLIB_ARTIFACTS),$($(x)_A)) LIBC_TESTLIB_SRCS = $(foreach x,$(LIBC_TESTLIB_ARTIFACTS),$($(x)_SRCS)) LIBC_TESTLIB_HDRS = $(foreach x,$(LIBC_TESTLIB_ARTIFACTS),$($(x)_HDRS)) LIBC_TESTLIB_CHECKS = $(foreach x,$(LIBC_TESTLIB_ARTIFACTS),$($(x)_CHECKS)) LIBC_TESTLIB_OBJS = $(foreach x,$(LIBC_TESTLIB_ARTIFACTS),$($(x)_OBJS)) $(LIBC_TESTLIB_OBJS): $(BUILD_FILES) libc/libc.mk .PHONY: o/$(MODE)/libc/testlib o/$(MODE)/libc/testlib: $(LIBC_TESTLIB_LIBS) $(LIBC_TESTLIB_CHECKS)
8,515
241
jart/cosmopolitan
false
cosmopolitan/libc/testlib/yield.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2021 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/testlib/ezbench.h" void __testlib_yield(void) { sched_yield(); }
1,949
25
jart/cosmopolitan
false
cosmopolitan/libc/testlib/hexequals.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/str/str.h" #include "libc/testlib/testlib.h" /** * Tests that raw memory is equal to numeric representation, e.g. * * testlib_hexequals("00010203", "\0\1\2\3", -1ul); * * @see unhexstr() */ bool testlib_hexequals(const char *want, const void *got, size_t n) { size_t i; const unsigned char *p = (const unsigned char *)got; if (!got) return false; for (i = 0; i < n; ++i) { if (!want[i * 2]) break; if (i == n) break; if (p[i] != (unsigned char)(hextoint(want[i * 2 + 0]) * 16 + hextoint(want[i * 2 + 1]))) { return false; } } return true; }
2,467
43
jart/cosmopolitan
false
cosmopolitan/libc/testlib/shoulddebugbreak.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/testlib/testlib.h" bool g_testlib_shoulddebugbreak;
1,904
22
jart/cosmopolitan
false
cosmopolitan/libc/testlib/fixturerunner.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/fmt/fmt.h" #include "libc/runtime/internal.h" #include "libc/sysv/consts/prot.h" #include "libc/testlib/testlib.h" int testlib_countfixtures(const struct TestFixture *start, const struct TestFixture *end) { return ((intptr_t)end - (intptr_t)start) / sizeof(struct TestFixture); } /** * Runs test cases for each FIXTURE() registered with the linker. * @see ape/ape.lds * @see libc/testlib/testlib.h */ void testlib_runfixtures(testfn_t *test_start, testfn_t *test_end, const struct TestFixture *fixture_start, const struct TestFixture *fixture_end) { unsigned i, count; count = testlib_countfixtures(fixture_start, fixture_end); for (i = 0; i < count && !g_testlib_failed; ++i) { (snprintf)(g_fixturename, sizeof(g_fixturename), "%s_%s", fixture_start[i].group, fixture_start[i].name); fixture_start[i].fn(); testlib_runtestcases(test_start, test_end, NULL); } }
2,832
46
jart/cosmopolitan
false
cosmopolitan/libc/testlib/bench.S
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│ │vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/macros.internal.h" .yoink testlib_runallbenchmarks // Decentralized section for benchmark registration. // // @see ape/ape.lds .section .piro.relo.sort.bench.1,"aw",@nobits .type __bench_start,@object .type __bench_end,@object .globl __bench_start,__bench_end .hidden __bench_start,__bench_end .byte 0 .balign __SIZEOF_POINTER__ .underrun __bench_start: .previous/* ... decentralized content ... */.section .piro.relo.sort.bench.3,"aw",@nobits __bench_end: .quad 0 .overrun .previous
2,352
43
jart/cosmopolitan
false
cosmopolitan/libc/testlib/almostequallongdouble.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/math.h" #include "libc/testlib/testlib.h" #define EPSILON 0.00000001L bool testlib_almostequallongdouble(long double x, long double y) { /* TODO(jart): This algorithm has to be binary. */ if (isnan(x) || isnan(y)) return false; return fabsl(x - y) <= EPSILON; }
2,121
29
jart/cosmopolitan
false
cosmopolitan/libc/testlib/waitforexit.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2022 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/intrin/kprintf.h" #include "libc/runtime/runtime.h" #include "libc/str/str.h" #include "libc/testlib/testlib.h" STATIC_YOINK("strsignal"); void testlib_waitforexit(const char *file, int line, const char *code, int rc, int pid) { int ws; char host[64]; ASSERT_NE(-1, wait(&ws)); if (WIFEXITED(ws)) { if (WEXITSTATUS(ws) == rc) { return; } kprintf("%s:%d: test failed\n" "\tEXITS(%s)\n" "\t want WEXITSTATUS(%d)\n" "\t got WEXITSTATUS(%d)\n", file, line, code, rc, WEXITSTATUS(ws)); } else if (WIFSIGNALED(ws)) { kprintf("%s:%d: test failed\n" "\tEXITS(%s)\n" "\t want _Exit(%d)\n" "\t got WTERMSIG(%G)\n", file, line, code, rc, WTERMSIG(ws)); } else if (WIFSTOPPED(ws)) { kprintf("%s:%d: test failed\n" "\tEXITS(%s)\n" "\t want _Exit(%d)\n" "\t got WSTOPSIG(%G)\n", file, line, code, rc, WSTOPSIG(ws)); } else { kprintf("%s:%d: test failed\n" "\tEXITS(%s)\n" "\t want _Exit(%d)\n" "\t got ws=%#x\n", file, line, code, rc, ws); } if (gethostname(host, sizeof(host))) { strcpy(host, "unknown"); } kprintf("\t%s\n", host); exit(1); }
3,200
66
jart/cosmopolitan
false
cosmopolitan/libc/testlib/ezbenchwarn.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2021 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/stdio/stdio.h" #include "libc/testlib/testlib.h" void __testlib_ezbenchwarn(const char *msg) { fputs("warning: failed to accurately benchmark", stderr); fputs(msg, stderr); fputc('\n', stderr); }
2,054
27
jart/cosmopolitan
false
cosmopolitan/libc/testlib/formatstr.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/str/str.h" #include "libc/testlib/testlib.h" #include "libc/x/xasprintf.h" /** * Turns string into code. */ dontdiscard char *testlib_formatstr(size_t cw, const void *s, int n) { if (s) { switch (cw) { case 1: if (n == -1) n = s ? strlen(s) : 0; return xasprintf("%`'.*s", n, s); case 2: if (n == -1) n = s ? strlen16(s) : 0; return xasprintf("%`'.*hs", n, s); case 4: if (n == -1) n = s ? wcslen(s) : 0; return xasprintf("%`'.*ls", n, s); default: abort(); } } else { return strdup("NULL"); } }
2,508
47
jart/cosmopolitan
false
cosmopolitan/libc/stubs/gcov.S
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│ │vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/macros.internal.h" // Magic words to unbreak build if GCOV flags are passed. __gcov_init: ret .endfn __gcov_init,globl,weak __gcov_exit: ret .endfn __gcov_exit,globl,weak __gcov_merge_add: ret .endfn __gcov_merge_add,globl,weak __gcov_fork: ret .endfn __gcov_fork,globl,weak __gcov_execle: ret .endfn __gcov_execle,globl,weak __gcov_execlp: ret .endfn __gcov_execlp,globl,weak __gcov_execl: ret .endfn __gcov_execl,globl,weak __gcov_execv: ret .endfn __gcov_execv,globl,weak __gcov_execvp: ret .endfn __gcov_execvp,globl,weak __gcov_execve: ret .endfn __gcov_execve,globl,weak
2,459
62
jart/cosmopolitan
false
cosmopolitan/libc/stubs/instrumentation.S
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│ │vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/macros.internal.h" // @fileoverview Function Instrumentation No-Op Runtime // // The compiler generates synthetic calls to these functions when // the -finstrument-functions flag is passed. __cyg_profile_func_enter: ret .endfn __cyg_profile_func_enter,weak __cyg_profile_func_exit: ret .endfn __cyg_profile_func_exit,weak
2,180
33
jart/cosmopolitan
false
cosmopolitan/libc/stubs/pututxline.S
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│ │vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2022 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/macros.internal.h" // Puts in the user accounting database. // @note unsupported pututxline: xor %eax,%eax ret .endfn pututxline,globl .alias pututxline,pututline
2,019
28
jart/cosmopolitan
false
cosmopolitan/libc/stubs/debugbreak.S
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│ │vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/macros.internal.h" .real .code16 # ∩ .code32 ∩ .code64 // Triggers breakpoint in software debugger. // // This should work with GDB, Bochs, WinDbg, etc. // // @mode long,legacy,real DebugBreak: .softicebp ret .endfn DebugBreak,weak
2,091
32
jart/cosmopolitan
false
cosmopolitan/libc/stubs/stackguard.S
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│ │vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "ape/macros.internal.h" .real .code16 # ∩ .code32 ∩ .code64 /** * @fileoverview Overridable stubs for synthetic stack protector calls. */ __stack_chk_fail_local: nop // fallthrough .endfn __stack_chk_fail_local,weak,hidden __stack_chk_fail: push %bp mov %sp,%bp rlcall abort nop .endfn __stack_chk_fail,weak .bss .balign 8 __stack_chk_guard: .quad 0 .endobj __stack_chk_guard,weak .previous
2,258
45
jart/cosmopolitan
false
cosmopolitan/libc/stubs/xnu.S
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│ │vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/macros.internal.h" _xnu: ud2 .endfn _xnu,weak
1,899
23
jart/cosmopolitan
false
cosmopolitan/libc/stubs/abort.S
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│ │vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "ape/macros.internal.h" .real // Most basic tier of program self-termination. // // @mode long,legacy,real abort: #ifdef __x86_64__ ud2 #elif defined(__aarch64__) brk #1000 #else #error "architecture unsupported" #endif .endfn abort,weak
2,087
34
jart/cosmopolitan
false
cosmopolitan/libc/stubs/retpoline.S
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│ │vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/macros.internal.h" // See -mfunction-return=thunk __x86_return_thunk: ret .endfn __x86_return_thunk,weak
1,959
25
jart/cosmopolitan
false
cosmopolitan/libc/stubs/stubs.mk
#-*-mode:makefile-gmake;indent-tabs-mode:t;tab-width:8;coding:utf-8-*-┐ #───vi: set et ft=make ts=8 tw=8 fenc=utf-8 :vi───────────────────────┘ # # SYNOPSIS # # Universally Linkable Weak Functions # # DESCRIPTION # # This package contains no-op implementations for (1) synthetic # compiler surprises and (2) mission-critical core functions, e.g. # abort(). These functions are designed to work in all addressing # modes, including real mode. Every package links this. It's at the # base of the topological order of things. PKGS += LIBC_STUBS LIBC_STUBS_ARTIFACTS += LIBC_STUBS_A LIBC_STUBS = $(LIBC_STUBS_A) LIBC_STUBS_A = o/$(MODE)/libc/stubs/stubs.a LIBC_STUBS_A_FILES := $(wildcard libc/stubs/*.S) LIBC_STUBS_A_HDRS = \ $(filter %.h,$(LIBC_STUBS_A_FILES)) LIBC_STUBS_A_SRCS = \ $(filter %.S,$(LIBC_STUBS_A_FILES)) LIBC_STUBS_A_OBJS = \ $(LIBC_STUBS_A_SRCS:%.S=o/$(MODE)/%.o) LIBC_STUBS_A_CHECKS = \ $(LIBC_STUBS_A).pkg \ $(LIBC_STUBS_A_HDRS:%=o/%.ok) $(LIBC_STUBS_A): \ libc/stubs/ \ $(LIBC_STUBS_A).pkg \ $(LIBC_STUBS_A_OBJS) $(LIBC_STUBS_A).pkg: \ $(LIBC_STUBS_A_OBJS) \ $(foreach x,$(LIBC_STUBS_A_DIRECTDEPS),$($(x)_A).pkg) # these assembly files are safe to build on aarch64 o/$(MODE)/libc/stubs/abort.o: libc/stubs/abort.S @$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $< LIBC_STUBS_LIBS = $(foreach x,$(LIBC_STUBS_ARTIFACTS),$($(x))) LIBC_STUBS_SRCS = $(foreach x,$(LIBC_STUBS_ARTIFACTS),$($(x)_SRCS)) LIBC_STUBS_CHECKS = $(foreach x,$(LIBC_STUBS_ARTIFACTS),$($(x)_CHECKS)) LIBC_STUBS_OBJS = $(foreach x,$(LIBC_STUBS_ARTIFACTS),$($(x)_OBJS)) .PHONY: o/$(MODE)/libc/stubs o/$(MODE)/libc/stubs: \ $(LIBC_STUBS_CHECKS)
1,776
57
jart/cosmopolitan
false
cosmopolitan/libc/stubs/stackchkguard.S
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│ │vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/macros.internal.h" #include "libc/notice.inc" // Canary for -fstack-protector. // // This global is referenced by synthetic code generated by GCC. // The -mstack-protector-guard=global flag might need to be passed. // // @note this value is protected by piro .initbss 200,_init___stack_chk_guard __stack_chk_guard: .quad 0 .endobj __stack_chk_guard,globl .previous .init.start 301,_init___stack_chk_guard rdtsc stosl xchg %edx,%eax stosl .init.end 301,_init___stack_chk_guard
2,339
40
jart/cosmopolitan
false
cosmopolitan/libc/stubs/typeinfo.S
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│ │vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/macros.internal.h" // __cxxabiv1::__function_type_info (?) // Because Clang in MODE=dbg doesn't respect -fno-rtti .balign 8 _ZTVN10__cxxabiv120__function_type_infoE: .quad 0 .endobj _ZTVN10__cxxabiv120__function_type_infoE,globl
2,084
27
jart/cosmopolitan
false
cosmopolitan/libc/stubs/panic.S
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│ │vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/macros.internal.h" .real .code16 # ∩ .code32 ∩ .code64 // Aborts or hard blocks instruction pointer. // @mode long,legacy,real __panic: push %bp mov %sp,%bp .softicebp cli 1: hlt jmp 1b .endfn __panic,weak
2,068
33
jart/cosmopolitan
false
cosmopolitan/libc/elf/getelfdynstringtable.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/elf/def.h" #include "libc/elf/elf.h" #include "libc/str/str.h" char *GetElfDynStringTable(const Elf64_Ehdr *elf, size_t mapsize) { char *name; Elf64_Half i; Elf64_Shdr *shdr; if (elf->e_shentsize) { for (i = 0; i < elf->e_shnum; ++i) { shdr = GetElfSectionHeaderAddress(elf, mapsize, i); if (shdr->sh_type == SHT_STRTAB) { name = GetElfSectionName(elf, mapsize, GetElfSectionHeaderAddress(elf, mapsize, i)); if (name && !strcmp(name, ".dynstr")) { return GetElfSectionAddress(elf, mapsize, shdr); } } } } return NULL; }
2,477
41
jart/cosmopolitan
false
cosmopolitan/libc/elf/getelfsectionname.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/elf/elf.h" const char *GetElfSectionName(const Elf64_Ehdr *elf, size_t mapsize, Elf64_Shdr *shdr) { if (!elf || !shdr) return NULL; return GetElfString(elf, mapsize, GetElfSectionNameStringTable(elf, mapsize), shdr->sh_name); }
2,136
27
jart/cosmopolitan
false
cosmopolitan/libc/elf/getelfdynsymboltable.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/elf/def.h" #include "libc/elf/elf.h" Elf64_Sym *GetElfDynSymbolTable(const Elf64_Ehdr *elf, size_t mapsize, Elf64_Xword *out_count) { Elf64_Half i; Elf64_Shdr *shdr; if (elf->e_shentsize) { for (i = elf->e_shnum; i > 0; --i) { shdr = GetElfSectionHeaderAddress(elf, mapsize, i - 1); if (shdr->sh_type == SHT_DYNSYM) { if (shdr->sh_entsize != sizeof(Elf64_Sym)) continue; if (out_count) *out_count = shdr->sh_size / shdr->sh_entsize; return GetElfSectionAddress(elf, mapsize, shdr); } } } return NULL; }
2,447
38
jart/cosmopolitan
false
cosmopolitan/libc/elf/getelfstringtable.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/elf/def.h" #include "libc/elf/elf.h" #include "libc/str/str.h" char *GetElfStringTable(const Elf64_Ehdr *elf, size_t mapsize) { char *name; Elf64_Half i; Elf64_Shdr *shdr; if (elf->e_shentsize) { for (i = 0; i < elf->e_shnum; ++i) { shdr = GetElfSectionHeaderAddress(elf, mapsize, i); if (shdr->sh_type == SHT_STRTAB) { name = GetElfSectionName(elf, mapsize, GetElfSectionHeaderAddress(elf, mapsize, i)); if (name && !strcmp(name, ".strtab")) { return GetElfSectionAddress(elf, mapsize, shdr); } } } } return NULL; }
2,474
41
jart/cosmopolitan
false
cosmopolitan/libc/elf/getelfsegmentheaderaddress.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/elf/elf.h" Elf64_Phdr *GetElfSegmentHeaderAddress(const Elf64_Ehdr *elf, size_t mapsize, unsigned i) { intptr_t addr = ((intptr_t)elf + (intptr_t)elf->e_phoff + (intptr_t)elf->e_phentsize * i); CheckElfAddress(elf, mapsize, addr, elf->e_phentsize); return (Elf64_Phdr *)addr; }
2,181
28
jart/cosmopolitan
false
cosmopolitan/libc/elf/checkelfaddress.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/elf/elf.h" #include "libc/runtime/runtime.h" void CheckElfAddress(const Elf64_Ehdr *elf, size_t mapsize, intptr_t addr, size_t addrsize) { #if !(TRUSTWORTHY + ELF_TRUSTWORTHY + 0) || ELF_UNTRUSTWORTHY + 0 if (addr < (intptr_t)elf || addr + addrsize > (intptr_t)elf + mapsize) { /* kprintf("%p-%p falls outside interval %p-%p", // */ /* addr, addr + addrsize, // */ /* elf, (char *)elf + mapsize); // */ abort(); } #endif }
2,359
33
jart/cosmopolitan
false
cosmopolitan/libc/elf/getelfsymboltable.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/elf/def.h" #include "libc/elf/elf.h" Elf64_Sym *GetElfSymbolTable(const Elf64_Ehdr *elf, size_t mapsize, Elf64_Xword *out_count) { Elf64_Half i; Elf64_Shdr *shdr; if (elf->e_shentsize) { for (i = elf->e_shnum; i > 0; --i) { shdr = GetElfSectionHeaderAddress(elf, mapsize, i - 1); if (shdr->sh_type == SHT_SYMTAB) { if (shdr->sh_entsize != sizeof(Elf64_Sym)) continue; if (out_count) *out_count = shdr->sh_size / shdr->sh_entsize; return GetElfSectionAddress(elf, mapsize, shdr); } } } return NULL; }
2,441
38
jart/cosmopolitan
false
cosmopolitan/libc/elf/elf.h
#ifndef COSMOPOLITAN_LIBC_ELF_H_ #define COSMOPOLITAN_LIBC_ELF_H_ #include "libc/elf/struct/ehdr.h" #include "libc/elf/struct/phdr.h" #include "libc/elf/struct/shdr.h" #include "libc/elf/struct/sym.h" #include "libc/runtime/ezmap.internal.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ /*───────────────────────────────────────────────────────────────────────────│─╗ │ cosmopolitan § executable & linkable format ─╬─│┼ ╚────────────────────────────────────────────────────────────────────────────│*/ char *GetElfStringTable(const Elf64_Ehdr *, size_t); char *GetElfStrs(const Elf64_Ehdr *, size_t, size_t *); Elf64_Sym *GetElfSymbolTable(const Elf64_Ehdr *, size_t, Elf64_Xword *); bool IsElf64Binary(const Elf64_Ehdr *, size_t); void CheckElfAddress(const Elf64_Ehdr *, size_t, intptr_t, size_t); bool IsElfSymbolContent(const Elf64_Sym *); Elf64_Phdr *GetElfSegmentHeaderAddress(const Elf64_Ehdr *, size_t, unsigned); Elf64_Shdr *GetElfSectionHeaderAddress(const Elf64_Ehdr *, size_t, Elf64_Half); void *GetElfSectionAddress(const Elf64_Ehdr *, size_t, const Elf64_Shdr *); char *GetElfSectionNameStringTable(const Elf64_Ehdr *, size_t); void GetElfVirtualAddressRange(const Elf64_Ehdr *, size_t, intptr_t *, intptr_t *); char *GetElfString(const Elf64_Ehdr *, size_t, const char *, Elf64_Word); const char *GetElfSectionName(const Elf64_Ehdr *, size_t, Elf64_Shdr *); Elf64_Sym *GetElfDynSymbolTable(const Elf64_Ehdr *, size_t, Elf64_Xword *); char *GetElfDynStringTable(const Elf64_Ehdr *, size_t); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_ELF_H_ */
2,012
35
jart/cosmopolitan
false
cosmopolitan/libc/elf/scalar.h
#ifndef COSMOPOLITAN_LIBC_ELF_SCALAR_H_ #define COSMOPOLITAN_LIBC_ELF_SCALAR_H_ #if !(__ASSEMBLER__ + __LINKER__ + 0) #define Elf64_Addr uint64_t #define Elf64_Half uint16_t #define Elf64_Off uint64_t #define Elf64_Section uint16_t #define Elf64_Sword int32_t #define Elf64_Sxword int64_t #define Elf64_Versym Elf64_Half #define Elf64_Word uint32_t #define Elf64_Xword uint64_t #define Elf_Symndx uint32_t #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_ELF_SCALAR_H_ */
522
18
jart/cosmopolitan
false
cosmopolitan/libc/elf/pf2prot.internal.h
#ifndef COSMOPOLITAN_LIBC_ELF_PF2PROT_INTERNAL_H_ #define COSMOPOLITAN_LIBC_ELF_PF2PROT_INTERNAL_H_ #include "libc/elf/def.h" #define _PF2PROT(x) ((PF_R & (x)) >> 2 | (PF_W & (x)) | (PF_X & (x)) << 2) #endif /* COSMOPOLITAN_LIBC_ELF_PF2PROT_INTERNAL_H_ */
258
8
jart/cosmopolitan
false
cosmopolitan/libc/elf/def.h
#ifndef COSMOPOLITAN_LIBC_ELF_STRUCT_DEF_H_ #define COSMOPOLITAN_LIBC_ELF_STRUCT_DEF_H_ /** * @fileoverview Executable and Linkable Format Definitions. */ #define EI_NIDENT 16 #define EI_MAG0 0 #define EI_MAG1 1 #define EI_MAG2 2 #define EI_MAG3 3 #define ELFMAG "\177ELF" #define ELFMAG0 0x7f #define ELFMAG1 'E' #define ELFMAG2 'L' #define ELFMAG3 'F' #define SELFMAG 4 #define EI_CLASS 4 #define ELFCLASSNONE 0 #define ELFCLASS32 1 #define ELFCLASS64 2 #define ELFCLASSNUM 3 #define EI_DATA 5 #define ELFDATANONE 0 #define ELFDATA2LSB 1 #define ELFDATA2MSB 2 #define ELFDATANUM 3 #define EI_VERSION 6 #define EI_OSABI 7 #define ELFOSABI_NONE 0 #define ELFOSABI_SYSV 0 #define ELFOSABI_HPUX 1 #define ELFOSABI_NETBSD 2 #define ELFOSABI_LINUX 3 #define ELFOSABI_GNU 3 #define ELFOSABI_SOLARIS 6 #define ELFOSABI_AIX 7 #define ELFOSABI_IRIX 8 #define ELFOSABI_FREEBSD 9 #define ELFOSABI_TRU64 10 #define ELFOSABI_MODESTO 11 #define ELFOSABI_OPENBSD 12 #define ELFOSABI_ARM 97 #define ELFOSABI_STANDALONE 255 #define EI_ABIVERSION 8 #define EI_PAD 9 #define ET_NONE 0 #define ET_REL 1 #define ET_EXEC 2 #define ET_DYN 3 #define ET_CORE 4 #define ET_NUM 5 #define ET_LOOS 0xfe00 #define ET_HIOS 0xfeff #define ET_LOPROC 0xff00 #define ET_HIPROC 0xffff #define EM_NONE 0 #define EM_M32 1 #define EM_386 3 #define EM_PPC64 21 #define EM_S390 22 #define EM_ARM 40 #define EM_NEXGEN32E 62 #define EM_X86_64 EM_NEXGEN32E #define EM_IA32E EM_NEXGEN32E #define EM_AMD64 EM_NEXGEN32E #define EM_PDP11 65 #define EM_CRAYNV2 172 #define EM_L10M 180 #define EM_K10M 181 #define EM_AARCH64 183 #define EM_CUDA 190 #define EM_Z80 220 #define EM_RISCV 243 #define EM_BPF 247 #define GRP_COMDAT 1 #define STN_UNDEF 0 #define EV_NONE 0 #define EV_CURRENT 1 #define EV_NUM 2 #define SYMINFO_NONE 0 #define SYMINFO_CURRENT 1 #define SYMINFO_NUM 2 #define SYMINFO_BT_SELF 0xffff #define SYMINFO_BT_PARENT 0xfffe #define SYMINFO_BT_LOWRESERVE 0xff00 #define SYMINFO_FLG_DIRECT 0x0001 #define SYMINFO_FLG_PASSTHRU 0x0002 #define SYMINFO_FLG_COPY 0x0004 #define SYMINFO_FLG_LAZYLOAD 0x0008 #define PT_NULL 0 #define PT_LOAD 1 #define PT_DYNAMIC 2 #define PT_INTERP 3 #define PT_NOTE 4 #define PT_SHLIB 5 #define PT_PHDR 6 #define PT_TLS 7 #define PT_NUM 8 #define PT_LOOS 0x60000000 #define PT_GNU_EH_FRAME 0x6474e550 #define PT_GNU_STACK 0x6474e551 #define PT_GNU_RELRO 0x6474e552 #define PT_LOSUNW 0x6ffffffa #define PT_SUNWBSS 0x6ffffffa #define PT_SUNWSTACK 0x6ffffffb #define PT_HISUNW 0x6fffffff #define PT_HIOS 0x6fffffff #define PT_LOPROC 0x70000000 #define PT_HIPROC 0x7fffffff #define PN_XNUM 0xffff #define PF_X 1 #define PF_W 2 #define PF_R 4 #define PF_MASKOS 0x0ff00000 #define PF_MASKPROC 0xf0000000 #define R_X86_64_NONE 0 #define R_X86_64_64 1 #define R_X86_64_PC32 2 #define R_X86_64_GOT32 3 #define R_X86_64_PLT32 4 #define R_X86_64_COPY 5 #define R_X86_64_GLOB_DAT 6 #define R_X86_64_JUMP_SLOT 7 #define R_X86_64_RELATIVE 8 #define R_X86_64_GOTPCREL 9 #define R_X86_64_32 10 #define R_X86_64_32S 11 #define R_X86_64_16 12 #define R_X86_64_PC16 13 #define R_X86_64_8 14 #define R_X86_64_PC8 15 #define R_X86_64_DTPMOD64 16 #define R_X86_64_DTPOFF64 17 #define R_X86_64_TPOFF64 18 #define R_X86_64_TLSGD 19 #define R_X86_64_TLSLD 20 #define R_X86_64_DTPOFF32 21 #define R_X86_64_GOTTPOFF 22 #define R_X86_64_TPOFF32 23 #define R_X86_64_PC64 24 #define R_X86_64_GOTOFF64 25 #define R_X86_64_GOTPC32 26 #define R_X86_64_GOT64 27 #define R_X86_64_GOTPCREL64 28 #define R_X86_64_GOTPC64 29 #define R_X86_64_GOTPLT64 30 #define R_X86_64_PLTOFF64 31 #define R_X86_64_SIZE32 32 #define R_X86_64_SIZE64 33 #define R_X86_64_GOTPC32_TLSDESC 34 #define R_X86_64_TLSDESC_CALL 35 #define R_X86_64_TLSDESC 36 #define R_X86_64_IRELATIVE 37 #define R_X86_64_RELATIVE64 38 #define R_X86_64_GOTPCRELX 41 /* 6 bytes */ #define R_X86_64_REX_GOTPCRELX 42 /* 7 bytes */ #define R_X86_64_NUM 43 #define R_AARCH64_NONE 0 #define R_AARCH64_ABS64 257 #define R_AARCH64_ABS32 258 #define R_AARCH64_ABS16 259 #define R_AARCH64_PREL64 260 #define R_AARCH64_PREL32 261 #define R_AARCH64_PREL16 262 #define R_PPC_NONE 0 #define R_PPC_ADDR32 1 #define R_PPC_ADDR24 2 #define R_PPC_ADDR16 3 #define R_PPC64_NONE R_PPC_NONE #define R_PPC64_ADDR32 R_PPC_ADDR32 #define R_PPC64_ADDR24 R_PPC_ADDR24 #define R_PPC64_ADDR16 R_PPC_ADDR16 #define R_RISCV_NONE 0 #define R_RISCV_32 1 #define R_RISCV_64 2 #define R_RISCV_RELATIVE 3 #define R_390_NONE 0 #define R_390_8 1 #define R_390_12 2 #define R_390_16 3 #define R_390_32 4 #define R_390_PC32 5 #define STB_LOCAL 0 #define STB_GLOBAL 1 #define STB_WEAK 2 #define STB_NUM 3 #define STB_LOOS 10 #define STB_GNU_UNIQUE 10 #define STB_HIOS 12 #define STB_LOPROC 13 #define STB_HIPROC 15 #define STT_NOTYPE 0 #define STT_OBJECT 1 #define STT_FUNC 2 #define STT_SECTION 3 #define STT_FILE 4 #define STT_COMMON 5 #define STT_TLS 6 #define STT_NUM 7 #define STT_LOOS 10 #define STT_GNU_IFUNC 10 #define STT_HIOS 12 #define STT_LOPROC 13 #define STT_HIPROC 15 #define STV_DEFAULT 0 #define STV_INTERNAL 1 #define STV_HIDDEN 2 #define STV_PROTECTED 3 #define SHN_UNDEF 0 #define SHN_LORESERVE 0xff00 #define SHN_LOPROC 0xff00 #define SHN_BEFORE 0xff00 #define SHN_AFTER 0xff01 #define SHN_HIPROC 0xff1f #define SHN_LOOS 0xff20 #define SHN_HIOS 0xff3f #define SHN_ABS 0xfff1 #define SHN_COMMON 0xfff2 #define SHN_XINDEX 0xffff #define SHN_HIRESERVE 0xffff #define SHF_WRITE (1 << 0) #define SHF_ALLOC (1 << 1) #define SHF_EXECINSTR (1 << 2) #define SHF_MERGE (1 << 4) #define SHF_STRINGS (1 << 5) #define SHF_INFO_LINK (1 << 6) #define SHF_LINK_ORDER (1 << 7) #define SHF_OS_NONCONFORMING (1 << 8) #define SHF_GROUP (1 << 9) #define SHF_TLS (1 << 10) #define SHF_COMPRESSED (1 << 11) #define SHF_MASKOS 0x0ff00000 #define SHF_MASKPROC 0xf0000000 #define SHF_ORDERED (1 << 30) #define SHF_EXCLUDE (1U << 31) #define ELFCOMPRESS_ZLIB 1 #define ELFCOMPRESS_LOOS 0x60000000 #define ELFCOMPRESS_HIOS 0x6fffffff #define ELFCOMPRESS_LOPROC 0x70000000 #define ELFCOMPRESS_HIPROC 0x7fffffff #define SHT_NULL 0 #define SHT_PROGBITS 1 #define SHT_SYMTAB 2 #define SHT_STRTAB 3 #define SHT_RELA 4 #define SHT_HASH 5 #define SHT_DYNAMIC 6 #define SHT_NOTE 7 #define SHT_NOBITS 8 #define SHT_REL 9 #define SHT_SHLIB 10 #define SHT_DYNSYM 11 #define SHT_INIT_ARRAY 14 #define SHT_FINI_ARRAY 15 #define SHT_PREINIT_ARRAY 16 #define SHT_GROUP 17 #define SHT_SYMTAB_SHNDX 18 #define SHT_NUM 19 #define SHT_LOOS 0x60000000 #define SHT_GNU_ATTRIBUTES 0x6ffffff5 #define SHT_GNU_HASH 0x6ffffff6 #define SHT_GNU_LIBLIST 0x6ffffff7 #define SHT_CHECKSUM 0x6ffffff8 #define SHT_LOSUNW 0x6ffffffa #define SHT_SUNW_move 0x6ffffffa #define SHT_SUNW_COMDAT 0x6ffffffb #define SHT_SUNW_syminfo 0x6ffffffc #define SHT_GNU_verdef 0x6ffffffd #define SHT_GNU_verneed 0x6ffffffe #define SHT_GNU_versym 0x6fffffff #define SHT_HISUNW 0x6fffffff #define SHT_HIOS 0x6fffffff #define SHT_LOPROC 0x70000000 #define SHT_HIPROC 0x7fffffff #define SHT_LOUSER 0x80000000 #define SHT_HIUSER 0x8fffffff #define DT_NULL 0 #define DT_NEEDED 1 #define DT_PLTRELSZ 2 #define DT_PLTGOT 3 #define DT_HASH 4 #define DT_STRTAB 5 #define DT_SYMTAB 6 #define DT_RELA 7 #define DT_RELASZ 8 #define DT_RELAENT 9 #define DT_STRSZ 10 #define DT_SYMENT 11 #define DT_INIT 12 #define DT_FINI 13 #define DT_SONAME 14 #define DT_RPATH 15 #define DT_SYMBOLIC 16 #define DT_REL 17 #define DT_RELSZ 18 #define DT_RELENT 19 #define DT_PLTREL 20 #define DT_DEBUG 21 #define DT_TEXTREL 22 #define DT_JMPREL 23 #define DT_BIND_NOW 24 #define DT_INIT_ARRAY 25 #define DT_FINI_ARRAY 26 #define DT_INIT_ARRAYSZ 27 #define DT_FINI_ARRAYSZ 28 #define DT_RUNPATH 29 #define DT_FLAGS 30 #define DT_ENCODING 32 #define DT_PREINIT_ARRAY 32 #define DT_PREINIT_ARRAYSZ 33 #define DT_SYMTAB_SHNDX 34 #define DT_NUM 35 #define DT_LOOS 0x6000000d #define DT_HIOS 0x6ffff000 #define DT_LOPROC 0x70000000 #define DT_HIPROC 0x7fffffff #define DT_VALRNGLO 0x6ffffd00 #define DT_GNU_PRELINKED 0x6ffffdf5 #define DT_GNU_CONFLICTSZ 0x6ffffdf6 #define DT_GNU_LIBLISTSZ 0x6ffffdf7 #define DT_CHECKSUM 0x6ffffdf8 #define DT_PLTPADSZ 0x6ffffdf9 #define DT_MOVEENT 0x6ffffdfa #define DT_MOVESZ 0x6ffffdfb #define DT_FEATURE_1 0x6ffffdfc #define DT_POSFLAG_1 0x6ffffdfd #define DT_SYMINSZ 0x6ffffdfe #define DT_SYMINENT 0x6ffffdff #define DT_VALRNGHI 0x6ffffdff #define DT_VALTAGIDX(tag) (DT_VALRNGHI - (tag)) #define DT_VALNUM 12 #define DT_ADDRRNGLO 0x6ffffe00 #define DT_GNU_HASH 0x6ffffef5 #define DT_TLSDESC_PLT 0x6ffffef6 #define DT_TLSDESC_GOT 0x6ffffef7 #define DT_GNU_CONFLICT 0x6ffffef8 #define DT_GNU_LIBLIST 0x6ffffef9 #define DT_CONFIG 0x6ffffefa #define DT_DEPAUDIT 0x6ffffefb #define DT_AUDIT 0x6ffffefc #define DT_PLTPAD 0x6ffffefd #define DT_MOVETAB 0x6ffffefe #define DT_SYMINFO 0x6ffffeff #define DT_ADDRRNGHI 0x6ffffeff #define DT_ADDRTAGIDX(tag) (DT_ADDRRNGHI - (tag)) #define DT_ADDRNUM 11 #define DT_VERSYM 0x6ffffff0 #define DT_RELACOUNT 0x6ffffff9 #define DT_RELCOUNT 0x6ffffffa #define DT_FLAGS_1 0x6ffffffb #define DT_VERDEF 0x6ffffffc #define DT_VERDEFNUM 0x6ffffffd #define DT_VERNEED 0x6ffffffe #define DT_VERNEEDNUM 0x6fffffff #define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) #define DT_VERSIONTAGNUM 16 #define DT_AUXILIARY 0x7ffffffd #define DT_FILTER 0x7fffffff #define DT_EXTRATAGIDX(tag) ((Elf32_Word) - ((Elf32_Sword)(tag) << 1 >> 1) - 1) #define DT_EXTRANUM 3 #define VER_NEED_NONE 0 #define VER_NEED_CURRENT 1 #define VER_NEED_NUM 2 #define VER_FLG_WEAK 0x2 #define ELF_NOTE_SOLARIS "SUNW Solaris" #define ELF_NOTE_GNU "GNU" #define ELF_NOTE_PAGESIZE_HINT 1 #define ELF_NOTE_ABI NT_GNU_ABI_TAG #define ELF_NOTE_OS_LINUX 0 #define ELF_NOTE_OS_GNU 1 #define ELF_NOTE_OS_SOLARIS2 2 #define ELF_NOTE_OS_FREEBSD 3 #define NT_GNU_ABI_TAG 1 #define NT_GNU_BUILD_ID 3 #define NT_GNU_GOLD_VERSION 4 #define EF_CPU32 0x00810000 #define DF_ORIGIN 0x00000001 #define DF_SYMBOLIC 0x00000002 #define DF_TEXTREL 0x00000004 #define DF_BIND_NOW 0x00000008 #define DF_STATIC_TLS 0x00000010 #define DF_1_NOW 0x00000001 #define DF_1_GLOBAL 0x00000002 #define DF_1_GROUP 0x00000004 #define DF_1_NODELETE 0x00000008 #define DF_1_LOADFLTR 0x00000010 #define DF_1_INITFIRST 0x00000020 #define DF_1_NOOPEN 0x00000040 #define DF_1_ORIGIN 0x00000080 #define DF_1_DIRECT 0x00000100 #define DF_1_TRANS 0x00000200 #define DF_1_INTERPOSE 0x00000400 #define DF_1_NODEFLIB 0x00000800 #define DF_1_NODUMP 0x00001000 #define DF_1_CONFALT 0x00002000 #define DF_1_ENDFILTEE 0x00004000 #define DF_1_DISPRELDNE 0x00008000 #define DF_1_DISPRELPND 0x00010000 #define DF_1_NODIRECT 0x00020000 #define DF_1_IGNMULDEF 0x00040000 #define DF_1_NOKSYMS 0x00080000 #define DF_1_NOHDR 0x00100000 #define DF_1_EDITED 0x00200000 #define DF_1_NORELOC 0x00400000 #define DF_1_SYMINTPOSE 0x00800000 #define DF_1_GLOBAUDIT 0x01000000 #define DF_1_SINGLETON 0x02000000 #define DF_1_STUB 0x04000000 #define DF_1_PIE 0x08000000 #define DTF_1_PARINIT 0x00000001 #define DTF_1_CONFEXP 0x00000002 #define DF_P1_LAZYLOAD 0x00000001 #define DF_P1_GROUPPERM 0x00000002 #define ELF64_ST_BIND(val) (((unsigned char)(val)) >> 4) #define ELF64_ST_TYPE(val) ((val)&0xf) #define ELF64_ST_INFO(bind, type) (((bind) << 4) + ((type)&0xf)) #define ELF64_ST_VISIBILITY(o) ((o)&0x03) #define ELF64_R_SYM(i) ((i) >> 32) #define ELF64_R_TYPE(i) ((i)&0xffffffff) #define ELF64_R_INFO(sym, type) ((((Elf64_Xword)(sym)) << 32) + (type)) #define ELF64_M_SYM(info) ((info) >> 8) #define ELF64_M_SIZE(info) ((unsigned char)(info)) #define ELF64_M_INFO(sym, size) (((sym) << 8) + (unsigned char)(size)) #define NT_PRSTATUS 1 #define NT_PRFPREG 2 #define NT_FPREGSET 2 #define NT_PRPSINFO 3 #define NT_PRXREG 4 #define NT_TASKSTRUCT 4 #define NT_PLATFORM 5 #define NT_AUXV 6 #define NT_GWINDOWS 7 #define NT_ASRS 8 #define NT_PSTATUS 10 #define NT_PSINFO 13 #define NT_PRCRED 14 #define NT_UTSNAME 15 #define NT_LWPSTATUS 16 #define NT_LWPSINFO 17 #define NT_PRFPXREG 20 #define NT_SIGINFO 0x53494749 #define NT_FILE 0x46494c45 #define NT_PRXFPREG 0x46e62b7f #define NT_PPC_VMX 0x100 #define NT_PPC_SPE 0x101 #define NT_PPC_VSX 0x102 #define NT_PPC_TAR 0x103 #define NT_PPC_PPR 0x104 #define NT_PPC_DSCR 0x105 #define NT_PPC_EBB 0x106 #define NT_PPC_PMU 0x107 #define NT_PPC_TM_CGPR 0x108 #define NT_PPC_TM_CFPR 0x109 #define NT_PPC_TM_CVMX 0x10a #define NT_PPC_TM_CVSX 0x10b #define NT_PPC_TM_SPR 0x10c #define NT_PPC_TM_CTAR 0x10d #define NT_PPC_TM_CPPR 0x10e #define NT_PPC_TM_CDSCR 0x10f #define NT_X86_XSTATE 0x202 #define NT_S390_HIGH_GPRS 0x300 #define NT_S390_TIMER 0x301 #define NT_S390_TODCMP 0x302 #define NT_S390_TODPREG 0x303 #define NT_S390_CTRS 0x304 #define NT_S390_PREFIX 0x305 #define NT_S390_LAST_BREAK 0x306 #define NT_S390_SYSTEM_CALL 0x307 #define NT_S390_TDB 0x308 #define NT_S390_VXRS_LOW 0x309 #define NT_S390_VXRS_HIGH 0x30a #define NT_S390_GS_CB 0x30b #define NT_S390_GS_BC 0x30c #define NT_S390_RI_CB 0x30d #define NT_ARM_VFP 0x400 #define NT_ARM_TLS 0x401 #define NT_ARM_HW_BREAK 0x402 #define NT_ARM_HW_WATCH 0x403 #define NT_ARM_SYSTEM_CALL 0x404 #define NT_ARM_SVE 0x405 #define NT_ARM_PAC_MASK 0x406 #define NT_METAG_CBUF 0x500 #define NT_METAG_RPIPE 0x501 #define NT_METAG_TLS 0x502 #define NT_ARC_V2 0x600 #define NT_VMCOREDD 0x700 #define NT_VERSION 1 #define VER_DEF_NONE 0 #define VER_DEF_CURRENT 1 #define VER_DEF_NUM 2 #define VER_FLG_BASE 0x1 #define VER_FLG_WEAK 0x2 #define VER_NDX_LOCAL 0 #define VER_NDX_GLOBAL 1 #define VER_NDX_LORESERVE 0xff00 #define VER_NDX_ELIMINATE 0xff01 #define LL_NONE 0 #define LL_EXACT_MATCH (1 << 0) #define LL_IGNORE_INT_VER (1 << 1) #define LL_REQUIRE_MINOR (1 << 2) #define LL_EXPORTS (1 << 3) #define LL_DELAY_LOAD (1 << 4) #define LL_DELTA (1 << 5) #define R_BPF_NONE 0 #define R_BPF_MAP_FD 1 #endif /* COSMOPOLITAN_LIBC_ELF_STRUCT_DEF_H_ */
16,583
552
jart/cosmopolitan
false
cosmopolitan/libc/elf/iself64binary.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/elf/elf.h" #include "libc/str/str.h" bool IsElf64Binary(const Elf64_Ehdr *elf, size_t mapsize) { if (mapsize < sizeof(Elf64_Ehdr)) return false; if (memcmp(elf->e_ident, ELFMAG, 4)) return false; return (elf->e_ident[EI_CLASS] == ELFCLASSNONE || elf->e_ident[EI_CLASS] == ELFCLASS64); }
2,155
28
jart/cosmopolitan
false
cosmopolitan/libc/elf/getelfvirtualaddressrange.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/elf/elf.h" #include "libc/limits.h" void GetElfVirtualAddressRange(const Elf64_Ehdr *elf, size_t elfsize, intptr_t *out_start, intptr_t *out_end) { unsigned i; Elf64_Phdr *phdr; intptr_t start, end, pstart, pend; start = INTPTR_MAX; end = 0; for (i = 0; i < elf->e_phnum; ++i) { phdr = GetElfSegmentHeaderAddress(elf, elfsize, i); if (phdr->p_type != PT_LOAD) continue; pstart = phdr->p_vaddr; pend = phdr->p_vaddr + phdr->p_memsz; if (pstart < start) start = pstart; if (pend > end) end = pend; } if (out_start) *out_start = start; if (out_end) *out_end = end; }
2,489
40
jart/cosmopolitan
false
cosmopolitan/libc/elf/iselfsymbolcontent.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/elf/elf.h" bool IsElfSymbolContent(const Elf64_Sym *sym) { return sym->st_size > 0 && (ELF64_ST_TYPE(sym->st_info) == STT_FUNC || ELF64_ST_TYPE(sym->st_info) == STT_OBJECT); }
2,060
25
jart/cosmopolitan
false
cosmopolitan/libc/elf/getelfstrs.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/elf/def.h" #include "libc/elf/elf.h" #include "libc/str/str.h" char *GetElfStrs(const Elf64_Ehdr *elf, size_t mapsize, size_t *out_size) { char *name; Elf64_Half i; Elf64_Shdr *shdr; for (i = 0; i < elf->e_shnum; ++i) { shdr = GetElfSectionHeaderAddress(elf, mapsize, i); if (shdr->sh_type == SHT_STRTAB) { name = GetElfSectionName(elf, mapsize, GetElfSectionHeaderAddress(elf, mapsize, i)); if (name && !strcmp(name, ".strtab")) { if (out_size) *out_size = shdr->sh_size; return GetElfSectionAddress(elf, mapsize, shdr); } } } return 0; }
2,481
40
jart/cosmopolitan
false
cosmopolitan/libc/elf/getelfsectionheaderaddress.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/elf/elf.h" Elf64_Shdr *GetElfSectionHeaderAddress(const Elf64_Ehdr *elf, size_t mapsize, Elf64_Half i) { intptr_t addr = ((intptr_t)elf + (intptr_t)elf->e_shoff + (intptr_t)elf->e_shentsize * i); CheckElfAddress(elf, mapsize, addr, elf->e_shentsize); return (Elf64_Shdr *)addr; }
2,183
28
jart/cosmopolitan
false
cosmopolitan/libc/elf/elf.mk
#-*-mode:makefile-gmake;indent-tabs-mode:t;tab-width:8;coding:utf-8-*-┐ #───vi: set et ft=make ts=8 tw=8 fenc=utf-8 :vi───────────────────────┘ PKGS += LIBC_ELF LIBC_ELF_ARTIFACTS += LIBC_ELF_A LIBC_ELF = $(LIBC_ELF_A_DEPS) $(LIBC_ELF_A) LIBC_ELF_A = o/$(MODE)/libc/elf/elf.a LIBC_ELF_A_FILES := $(wildcard libc/elf/*) $(wildcard libc/elf/struct/*) LIBC_ELF_A_HDRS = $(filter %.h,$(LIBC_ELF_A_FILES)) LIBC_ELF_A_SRCS_S = $(filter %.S,$(LIBC_ELF_A_FILES)) LIBC_ELF_A_SRCS_C = $(filter %.c,$(LIBC_ELF_A_FILES)) LIBC_ELF_A_SRCS = \ $(LIBC_ELF_A_SRCS_S) \ $(LIBC_ELF_A_SRCS_C) LIBC_ELF_A_OBJS = \ $(LIBC_ELF_A_SRCS_S:%.S=o/$(MODE)/%.o) \ $(LIBC_ELF_A_SRCS_C:%.c=o/$(MODE)/%.o) LIBC_ELF_A_CHECKS = \ $(LIBC_ELF_A).pkg \ $(LIBC_ELF_A_HDRS:%=o/$(MODE)/%.ok) LIBC_ELF_A_DIRECTDEPS = \ LIBC_INTRIN \ LIBC_NEXGEN32E \ LIBC_STR \ LIBC_STUBS LIBC_ELF_A_DEPS := \ $(call uniq,$(foreach x,$(LIBC_ELF_A_DIRECTDEPS),$($(x)))) $(LIBC_ELF_A): libc/elf/ \ $(LIBC_ELF_A).pkg \ $(LIBC_ELF_A_OBJS) $(LIBC_ELF_A).pkg: \ $(LIBC_ELF_A_OBJS) \ $(foreach x,$(LIBC_ELF_A_DIRECTDEPS),$($(x)_A).pkg) LIBC_ELF_LIBS = $(foreach x,$(LIBC_ELF_ARTIFACTS),$($(x))) LIBC_ELF_SRCS = $(foreach x,$(LIBC_ELF_ARTIFACTS),$($(x)_SRCS)) LIBC_ELF_HDRS = $(foreach x,$(LIBC_ELF_ARTIFACTS),$($(x)_HDRS)) LIBC_ELF_CHECKS = $(foreach x,$(LIBC_ELF_ARTIFACTS),$($(x)_CHECKS)) LIBC_ELF_OBJS = $(foreach x,$(LIBC_ELF_ARTIFACTS),$($(x)_OBJS)) $(LIBC_ELF_OBJS): $(BUILD_FILES) libc/elf/elf.mk .PHONY: o/$(MODE)/libc/elf o/$(MODE)/libc/elf: $(LIBC_ELF_CHECKS)
1,625
52
jart/cosmopolitan
false
cosmopolitan/libc/elf/getelfsectionaddress.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/elf/elf.h" void *GetElfSectionAddress(const Elf64_Ehdr *elf, size_t mapsize, const Elf64_Shdr *shdr) { intptr_t addr, size; addr = (intptr_t)elf + (intptr_t)shdr->sh_offset; size = (intptr_t)shdr->sh_size; CheckElfAddress(elf, mapsize, addr, size); return (void *)addr; }
2,161
29
jart/cosmopolitan
false
cosmopolitan/libc/elf/getelfstring.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/elf/elf.h" #include "libc/str/str.h" char *GetElfString(const Elf64_Ehdr *elf, size_t mapsize, const char *strtab, Elf64_Word rva) { intptr_t addr = (intptr_t)strtab + rva; #if !(TRUSTWORTHY + ELF_TRUSTWORTHY + 0) CheckElfAddress(elf, mapsize, addr, 0); CheckElfAddress(elf, mapsize, addr, strnlen((char *)addr, (intptr_t)elf + mapsize - addr) + 1); #endif return (char *)addr; }
2,277
32
jart/cosmopolitan
false
cosmopolitan/libc/elf/getelfsectionnamestringtable.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/elf/elf.h" char *GetElfSectionNameStringTable(const Elf64_Ehdr *elf, size_t mapsize) { if (!elf->e_shoff || !elf->e_shentsize) return NULL; return GetElfSectionAddress( elf, mapsize, GetElfSectionHeaderAddress(elf, mapsize, elf->e_shstrndx)); }
2,107
26
jart/cosmopolitan
false
cosmopolitan/libc/elf/struct/verneed.h
#ifndef COSMOPOLITAN_LIBC_ELF_STRUCT_VERNEED_H_ #define COSMOPOLITAN_LIBC_ELF_STRUCT_VERNEED_H_ #include "libc/elf/scalar.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) typedef struct Elf64_Verneed { Elf64_Half vn_version; Elf64_Half vn_cnt; Elf64_Word vn_file; Elf64_Word vn_aux; Elf64_Word vn_next; } Elf64_Verneed; #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_ELF_STRUCT_VERNEED_H_ */
424
16
jart/cosmopolitan
false
cosmopolitan/libc/elf/struct/verdaux.h
#ifndef COSMOPOLITAN_LIBC_ELF_STRUCT_VERDAUX_H_ #define COSMOPOLITAN_LIBC_ELF_STRUCT_VERDAUX_H_ #include "libc/elf/scalar.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) typedef struct Elf64_Verdaux { Elf64_Word vda_name; Elf64_Word vda_next; } Elf64_Verdaux; #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_ELF_STRUCT_VERDAUX_H_ */
359
13
jart/cosmopolitan
false
cosmopolitan/libc/elf/struct/nhdr.h
#ifndef COSMOPOLITAN_LIBC_ELF_STRUCT_NHDR_H_ #define COSMOPOLITAN_LIBC_ELF_STRUCT_NHDR_H_ #include "libc/elf/scalar.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) typedef struct Elf64_Nhdr { Elf64_Word n_namesz; Elf64_Word n_descsz; Elf64_Word n_type; } Elf64_Nhdr; #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_ELF_STRUCT_NHDR_H_ */
365
14
jart/cosmopolitan
false
cosmopolitan/libc/elf/struct/move.h
#ifndef COSMOPOLITAN_LIBC_ELF_STRUCT_MOVE_H_ #define COSMOPOLITAN_LIBC_ELF_STRUCT_MOVE_H_ #include "libc/elf/scalar.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) typedef struct Elf64_Move { Elf64_Xword m_value; Elf64_Xword m_info; Elf64_Xword m_poffset; Elf64_Half m_repeat; Elf64_Half m_stride; } Elf64_Move; #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_ELF_STRUCT_MOVE_H_ */
414
16
jart/cosmopolitan
false
cosmopolitan/libc/elf/struct/dyn.h
#ifndef COSMOPOLITAN_LIBC_ELF_STRUCT_DYN_H_ #define COSMOPOLITAN_LIBC_ELF_STRUCT_DYN_H_ #include "libc/elf/scalar.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) typedef struct Elf64_Dyn { Elf64_Sxword d_tag; union { Elf64_Xword d_val; Elf64_Addr d_ptr; } d_un; } Elf64_Dyn; #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_ELF_STRUCT_DYN_H_ */
380
16
jart/cosmopolitan
false
cosmopolitan/libc/elf/struct/ehdr.h
#ifndef COSMOPOLITAN_LIBC_ELF_STRUCT_EHDR_H_ #define COSMOPOLITAN_LIBC_ELF_STRUCT_EHDR_H_ #include "libc/elf/def.h" #include "libc/elf/scalar.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) #define EI_NIDENT 16 typedef struct Elf64_Ehdr { unsigned char e_ident[EI_NIDENT]; Elf64_Half e_type; Elf64_Half e_machine; Elf64_Word e_version; Elf64_Addr e_entry; Elf64_Off e_phoff; Elf64_Off e_shoff; Elf64_Word e_flags; Elf64_Half e_ehsize; Elf64_Half e_phentsize; Elf64_Half e_phnum; Elf64_Half e_shentsize; Elf64_Half e_shnum; Elf64_Half e_shstrndx; } Elf64_Ehdr; #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_ELF_STRUCT_EHDR_H_ */
681
28
jart/cosmopolitan
false
cosmopolitan/libc/elf/struct/rela.h
#ifndef COSMOPOLITAN_LIBC_ELF_STRUCT_RELA_H_ #define COSMOPOLITAN_LIBC_ELF_STRUCT_RELA_H_ #include "libc/elf/scalar.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) typedef struct Elf64_Rela { /*u64*/ Elf64_Addr r_offset; /* * ELF64_R_SYM(r_info) → sym * ELF64_R_TYPE(r_info) → R_X86_64_{64,PC32,GOTPCRELX,...} * ELF64_R_INFO(sym, type) → r_info */ /*u64*/ Elf64_Xword r_info; /* ELF64_R_{SYM,SIZE,INFO} */ /*i64*/ Elf64_Sxword r_addend; } Elf64_Rela; #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_ELF_STRUCT_RELA_H_ */
569
19
jart/cosmopolitan
false
cosmopolitan/libc/elf/struct/verdef.h
#ifndef COSMOPOLITAN_LIBC_ELF_STRUCT_VERDEF_H_ #define COSMOPOLITAN_LIBC_ELF_STRUCT_VERDEF_H_ #include "libc/elf/scalar.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) typedef struct Elf64_Verdef { Elf64_Half vd_version; Elf64_Half vd_flags; Elf64_Half vd_ndx; Elf64_Half vd_cnt; Elf64_Word vd_hash; Elf64_Word vd_aux; Elf64_Word vd_next; } Elf64_Verdef; #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_ELF_STRUCT_VERDEF_H_ */
463
18
jart/cosmopolitan
false
cosmopolitan/libc/elf/struct/auxv.h
#ifndef COSMOPOLITAN_LIBC_ELF_STRUCT_AUXV_H_ #define COSMOPOLITAN_LIBC_ELF_STRUCT_AUXV_H_ #if !(__ASSEMBLER__ + __LINKER__ + 0) typedef struct Elf64_auxv_t { uint64_t a_type; union { uint64_t a_val; } a_un; } Elf64_auxv_t; #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_ELF_STRUCT_AUXV_H_ */
332
14
jart/cosmopolitan
false
cosmopolitan/libc/elf/struct/lib.h
#ifndef COSMOPOLITAN_LIBC_ELF_STRUCT_LIB_H_ #define COSMOPOLITAN_LIBC_ELF_STRUCT_LIB_H_ #include "libc/elf/scalar.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) typedef struct Elf64_Lib { Elf64_Word l_name; Elf64_Word l_time_stamp; Elf64_Word l_checksum; Elf64_Word l_version; Elf64_Word l_flags; } Elf64_Lib; #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_ELF_STRUCT_LIB_H_ */
412
16
jart/cosmopolitan
false
cosmopolitan/libc/elf/struct/vernaux.h
#ifndef COSMOPOLITAN_LIBC_ELF_STRUCT_VERNAUX_H_ #define COSMOPOLITAN_LIBC_ELF_STRUCT_VERNAUX_H_ #include "libc/elf/scalar.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) typedef struct Elf64_Vernaux { Elf64_Word vna_hash; Elf64_Half vna_flags; Elf64_Half vna_other; Elf64_Word vna_name; Elf64_Word vna_next; } Elf64_Vernaux; #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_ELF_STRUCT_VERNAUX_H_ */
430
16
jart/cosmopolitan
false
cosmopolitan/libc/elf/struct/sym.h
#ifndef COSMOPOLITAN_LIBC_ELF_STRUCT_SYM_H_ #define COSMOPOLITAN_LIBC_ELF_STRUCT_SYM_H_ #include "libc/elf/scalar.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) typedef struct Elf64_Sym { Elf64_Word st_name; /* ELF64_ST_TYPE(st_info) → STT_{NOTYPE,OBJECT,FUNC,SECTION,FILE,COMMON,...} * ELF64_ST_BIND(st_info) → STB_{LOCAL,GLOBAL,WEAK,...} */ uint8_t st_info; /* STV_{DEFAULT,INTERNAL,HIDDEN,PROTECTED} */ uint8_t st_other; /* SHN_UNDEF, <section index>, SHN_ABS, SHN_COMMON, etc. */ Elf64_Section st_shndx; Elf64_Addr st_value; Elf64_Xword st_size; } Elf64_Sym; #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_ELF_STRUCT_SYM_H_ */
680
21
jart/cosmopolitan
false
cosmopolitan/libc/elf/struct/syminfo.h
#ifndef COSMOPOLITAN_LIBC_ELF_STRUCT_SYMINFO_H_ #define COSMOPOLITAN_LIBC_ELF_STRUCT_SYMINFO_H_ #include "libc/elf/scalar.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) typedef struct Elf64_Syminfo { Elf64_Half si_boundto; Elf64_Half si_flags; } Elf64_Syminfo; #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_ELF_STRUCT_SYMINFO_H_ */
361
13
jart/cosmopolitan
false
cosmopolitan/libc/elf/struct/phdr.h
#ifndef COSMOPOLITAN_LIBC_ELF_STRUCT_PHDR_H_ #define COSMOPOLITAN_LIBC_ELF_STRUCT_PHDR_H_ #include "libc/elf/scalar.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) typedef struct Elf64_Phdr { Elf64_Word p_type; Elf64_Word p_flags; Elf64_Off p_offset; Elf64_Addr p_vaddr; Elf64_Addr p_paddr; Elf64_Xword p_filesz; Elf64_Xword p_memsz; Elf64_Xword p_align; } Elf64_Phdr; #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_ELF_STRUCT_PHDR_H_ */
477
19
jart/cosmopolitan
false
cosmopolitan/libc/elf/struct/shdr.h
#ifndef COSMOPOLITAN_LIBC_ELF_STRUCT_SHDR_H_ #define COSMOPOLITAN_LIBC_ELF_STRUCT_SHDR_H_ #include "libc/elf/scalar.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) /** * Section header. * @see https://docs.oracle.com/cd/E19683-01/816-1386/chapter6-94076/index.html */ typedef struct Elf64_Shdr { Elf64_Word sh_name; Elf64_Word sh_type; /* SHT_{PROGBITS,NOBITS,STRTAB,SYMTAB,RELA,...} */ Elf64_Xword sh_flags; /* SHF_{WRITE,ALLOC,EXECINSTR,MERGE,STRINGS,...} */ Elf64_Addr sh_addr; Elf64_Off sh_offset; Elf64_Xword sh_size; /* * If SHT_RELA: Index of section of associated symbol table. * If SHT_SYMTAB: Index of section of associated string table. */ Elf64_Word sh_link; /* * If SHT_RELA: Index of section to which relocations apply. * If SHT_SYMTAB: One greater than symbol table index of last local symbol. */ Elf64_Word sh_info; Elf64_Xword sh_addralign; Elf64_Xword sh_entsize; } Elf64_Shdr; #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_ELF_STRUCT_SHDR_H_ */
1,035
33
jart/cosmopolitan
false
cosmopolitan/libc/elf/struct/rel.h
#ifndef COSMOPOLITAN_LIBC_ELF_STRUCT_REL_H_ #define COSMOPOLITAN_LIBC_ELF_STRUCT_REL_H_ #include "libc/elf/scalar.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) typedef struct Elf64_Rel { Elf64_Addr r_offset; Elf64_Xword r_info; /** @see ELF64_R_{SYM,SIZE,INFO} */ } Elf64_Rel; #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_ELF_STRUCT_REL_H_ */
374
13
jart/cosmopolitan
false
cosmopolitan/libc/elf/struct/chdr.h
#ifndef COSMOPOLITAN_LIBC_ELF_STRUCT_CHDR_H_ #define COSMOPOLITAN_LIBC_ELF_STRUCT_CHDR_H_ #include "libc/elf/scalar.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) typedef struct Elf64_Chdr { Elf64_Word ch_type; Elf64_Word ch_reserved; Elf64_Xword ch_size; Elf64_Xword ch_addralign; } Elf64_Chdr; #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_ELF_STRUCT_CHDR_H_ */
397
15
jart/cosmopolitan
false
cosmopolitan/libc/dns/rfc0226.txt
NETWORK WORKING GROUP PEGGY KARP REQUEST FOR COMMENTS #226 MITRE NIC #7625 20 SEPT 71 CATEGORIES: D.3 UPDATES: NONE OBSOLETES: NONE STANDARDIZATION OF HOST MNEUMONICS IN EACH TELNET IMPLEMENTATION, A LIST OF HOST NMEUMONICS IS PROVIDED FOR THE USER TO INDICATE THE SERVING HOST DESIRED. CURRENTLY, EACH SITE EMPLOYS THEIR OWN SPECIAL LIST. RATHER THAN REQUIRE THE USER TO BE COGNIZANT OF THE IDIOSYNCRASIES OF EACH LIST, ESPECIALLY WHEN CHAINED THROUGH SEVERAL HOSTS VIA TELNET, IT HAS BEEN RECOMMENDED THAT STANDARD HOST DESIGNATORS BE ADOPTED. THE FOLLOWING LIST OF SIX CHARACTER DESIGNATORS IS PROPOSED AS THE STANDARD LIST. REGISTER ANY OBJECTIONS BY 3 OCTOBER TO P. KARP (703) 893-3500 X2391, X2318. AN OFFICIAL POLICY AND IMPLEMENTATION DATE WILL BE SET ON 8 OCTOBER. THE LIST: HOST # DESIGNATOR 1 UCLA 65 UCLA36 2 SRIARC 66 SRIAI 3 UCSB 4 UTAH 6 MULTCS 70 MITDM 7 RAND 8 SDC 9 HARV 10 LNCTX2 74 LNC360 11 STAN 12 ILL 69 BBN 133 BBNB 144 AMES 145 MITRE 158 TIP [ This RFC was put into machine readable form for entry ] [ into the online RFC archives by BBN Corp. under the ] [ direction of Alex McKenzie. 12/96 ] [Page 1]
2,012
60
jart/cosmopolitan
false
cosmopolitan/libc/dns/parseresolvconf.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/dns/dns.h" #include "libc/dns/resolvconf.h" #include "libc/mem/arraylist.internal.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/sock/sock.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/sysv/consts/af.h" #include "libc/sysv/consts/inaddr.h" /** * Parses /etc/resolv.conf file. * * The content of the file usually looks like this: * * nameserver 8.8.8.8 * nameserver 8.8.4.4 * * @param resolv points to a ResolvConf object, which should be zero * initialized by the caller; or if it already contains items, * this function will append * @param f is an open stream with file content * @return number of nameservers appended, or -1 w/ errno */ int ParseResolvConf(struct ResolvConf *resolv, struct FILE *f) { /* TODO(jart): options ndots:5 */ int rc; char *line; size_t linesize; struct sockaddr_in nameserver; char *directive, *value, *tok, *comment; rc = 0; line = 0; linesize = 0; nameserver.sin_family = AF_INET; nameserver.sin_port = htons(DNS_PORT); while (getline(&line, &linesize, f) != -1) { if ((comment = strchr(line, '#'))) *comment = '\0'; if ((directive = strtok_r(line, " \t\r\n\v", &tok)) && (value = strtok_r(NULL, " \t\r\n\v", &tok))) { if ((strcmp(directive, "nameserver") == 0 && inet_pton(AF_INET, value, &nameserver.sin_addr.s_addr) == 1)) { if (append(&resolv->nameservers, &nameserver) != -1) ++rc; } } } free(line); return rc | ferror(f); }
3,383
69
jart/cosmopolitan
false
cosmopolitan/libc/dns/gethostbyaddr.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ This is free and unencumbered software released into the public domain. │ │ │ │ Anyone is free to copy, modify, publish, use, compile, sell, or │ │ distribute this software, either in source code form or as a compiled │ │ binary, for any purpose, commercial or non-commercial, and by any │ │ means. │ │ │ │ In jurisdictions that recognize copyright laws, the author or authors │ │ of this software dedicate any and all copyright interest in the │ │ software to the public domain. We make this dedication for the benefit │ │ of the public at large and to the detriment of our heirs and │ │ successors. We intend this dedication to be an overt act of │ │ relinquishment in perpetuity of all present and future rights to this │ │ software under copyright law. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │ │ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │ │ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │ │ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR │ │ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, │ │ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR │ │ OTHER DEALINGS IN THE SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/dns/ent.h" #include "libc/mem/mem.h" #include "libc/sysv/consts/af.h" struct hostent *gethostbyaddr(const void *s_addr, socklen_t len, int type) { static struct hostent *ptr1, he1; static char h_name[DNS_NAME_MAX + 1]; static char *h_aliases[1]; static char *h_addr_list[2]; static char h_addr_list0[4]; struct sockaddr_in addr; if (!ptr1) { he1.h_name = h_name; he1.h_aliases = h_aliases; he1.h_aliases[0] = NULL; he1.h_addrtype = AF_INET; he1.h_length = 4; he1.h_addr_list = h_addr_list; he1.h_addr_list[0] = h_addr_list0; he1.h_addr_list[1] = NULL; ptr1 = &he1; } if (type != AF_INET || len != sizeof(uint32_t)) return NULL; addr.sin_family = AF_INET; addr.sin_port = 0; addr.sin_addr.s_addr = *(uint32_t *)(s_addr); if (getnameinfo((struct sockaddr *)&addr, sizeof(addr), ptr1->h_name, DNS_NAME_MAX, NULL, 0, 0)) return NULL; *((uint32_t *)ptr1->h_addr_list[0]) = (addr.sin_addr.s_addr); return ptr1; }
3,527
59
jart/cosmopolitan
false
cosmopolitan/libc/dns/dnsquestion.h
#ifndef COSMOPOLITAN_LIBC_DNS_DNSQUESTION_H_ #define COSMOPOLITAN_LIBC_DNS_DNSQUESTION_H_ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ struct DnsQuestion { const char *qname; uint16_t qtype; uint16_t qclass; }; int SerializeDnsQuestion(uint8_t *, size_t, const struct DnsQuestion *); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_DNS_DNSQUESTION_H_ */
425
17
jart/cosmopolitan
false
cosmopolitan/libc/dns/resolvednsreverse.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ This is free and unencumbered software released into the public domain. │ │ │ │ Anyone is free to copy, modify, publish, use, compile, sell, or │ │ distribute this software, either in source code form or as a compiled │ │ binary, for any purpose, commercial or non-commercial, and by any │ │ means. │ │ │ │ In jurisdictions that recognize copyright laws, the author or authors │ │ of this software dedicate any and all copyright interest in the │ │ software to the public domain. We make this dedication for the benefit │ │ of the public at large and to the detriment of our heirs and │ │ successors. We intend this dedication to be an overt act of │ │ relinquishment in perpetuity of all present and future rights to this │ │ software under copyright law. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │ │ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │ │ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │ │ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR │ │ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, │ │ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR │ │ OTHER DEALINGS IN THE SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/dns/consts.h" #include "libc/dns/dns.h" #include "libc/dns/dnsheader.h" #include "libc/dns/dnsquestion.h" #include "libc/dns/resolvconf.h" #include "libc/intrin/bits.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/sock/sock.h" #include "libc/sock/struct/sockaddr.h" #include "libc/stdio/rand.h" #include "libc/str/str.h" #include "libc/sysv/consts/af.h" #include "libc/sysv/consts/ipproto.h" #include "libc/sysv/consts/sock.h" #include "libc/sysv/errfuns.h" #define kMsgMax 512 /** * Performs reverse DNS lookup with IP address. * * @param resolvconf can be GetResolvConf() * @param af can be AF_INET, AF_UNSPEC * @param name is a reversed IP address string ending with .in-addr.arpa * @param buf to store the obtained hostname if any * @param bufsize is size of buf * @return 0 on success, or -1 w/ errno * @error EAFNOSUPPORT, ENETDOWN, ENAMETOOLONG, EBADMSG */ int ResolveDnsReverse(const struct ResolvConf *resolvconf, int af, const char *name, char *buf, size_t bufsize) { int rc, fd, n; struct DnsQuestion q; struct DnsHeader h, h2; uint8_t *p, *pe, msg[512]; uint16_t rtype, rclass, rdlength; if (af != AF_INET && af != AF_UNSPEC) return eafnosupport(); if (!resolvconf->nameservers.i) return 0; bzero(&h, sizeof(h)); rc = ebadmsg(); h.id = _rand64(); h.bf1 = 1; /* recursion desired */ h.qdcount = 1; q.qname = name; q.qtype = DNS_TYPE_PTR; q.qclass = DNS_CLASS_IN; bzero(msg, sizeof(msg)); SerializeDnsHeader(msg, &h); if ((n = SerializeDnsQuestion(msg + 12, 500, &q)) == -1) return -1; if ((fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) return -1; if (sendto(fd, msg, 12 + n, 0, (struct sockaddr *)resolvconf->nameservers.p, sizeof(*resolvconf->nameservers.p)) == 12 + n && (n = read(fd, msg, 512)) >= 12) { DeserializeDnsHeader(&h2, msg); if (h2.id == h.id) { rc = 0; if (h2.ancount) { p = msg + 12; pe = msg + n; while (p < pe && h2.qdcount) { p += strnlen((char *)p, pe - p) + 1 + 4; h2.qdcount--; } if (p + 1 < pe) { if ((p[0] & 0b11000000) == 0b11000000) { /* name pointer */ p += 2; } else { p += strnlen((char *)p, pe - p) + 1; } if (p + 2 + 2 + 4 + 2 < pe) { rtype = READ16BE(p), p += 2; rclass = READ16BE(p), p += 2; /* ttl */ p += 4; rdlength = READ16BE(p), p += 2; if (p + rdlength <= pe && rtype == DNS_TYPE_PTR && rclass == DNS_CLASS_IN) { if (strnlen((char *)p, pe - p) + 1 > bufsize) rc = -1; else { /* domain name starts with a letter */ for (; !isalnum((char)(*p)) && p < pe; p++) rdlength--; for (char *tmp = (char *)p; rdlength > 0 && *tmp != '\0'; tmp++) { /* each label is alphanumeric or hyphen * any other character is assumed separator */ if (!isalnum(*tmp) && *tmp != '-') *tmp = '.'; rdlength--; } strcpy(buf, (char *)p); } } else rc = -1; } } } } } close(fd); return rc; }
5,914
129
jart/cosmopolitan
false
cosmopolitan/libc/dns/pascalifydnsname.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/dns/dns.h" #include "libc/str/str.h" #include "libc/sysv/errfuns.h" /** * Writes dotted hostname to DNS message wire. * * The wire format is basically a sequence of Pascal strings, for each * label in the name. We only do enough validation to maintain protocol * invariants. * * @param name is a dotted NUL-terminated hostname string * @return bytes written (excluding NUL) or -1 w/ errno */ int PascalifyDnsName(uint8_t *buf, size_t size, const char *name) { size_t i, j, k, namelen; if ((namelen = strlen(name)) > DNS_NAME_MAX) return enametoolong(); i = 0; if (size || namelen) { if (namelen + 1 > size) return enospc(); buf[0] = '\0'; j = 0; for (;;) { for (k = 0; name[j + k] && name[j + k] != '.'; ++k) { buf[i + k + 1] = name[j + k]; } if (k) { if (k > DNS_LABEL_MAX) return enametoolong(); buf[i] = k; i += k + 1; } j += k + 1; if (!name[j - 1]) { break; } } buf[i] = '\0'; } return i; }
2,875
59
jart/cosmopolitan
false
cosmopolitan/libc/dns/gethoststxt.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2020 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/dce.h" #include "libc/dns/hoststxt.h" #include "libc/fmt/fmt.h" #include "libc/intrin/bits.h" #include "libc/intrin/pushpop.h" #include "libc/intrin/safemacros.internal.h" #include "libc/macros.internal.h" #include "libc/mem/mem.h" #include "libc/nt/systeminfo.h" #include "libc/runtime/runtime.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/thread/thread.h" static struct HostsTxt *g_hoststxt; static struct HostsTxtInitialStaticMemory { struct HostsTxt ht; pthread_mutex_t lock; struct HostsTxtEntry entries[8]; char strings[64]; } g_hoststxt_init; static textwindows dontinline char *GetNtHostsTxtPath(char *pathbuf, uint32_t size) { const char *const kWinHostsPath = "\\drivers\\etc\\hosts"; uint32_t len = GetSystemDirectoryA(&pathbuf[0], size); if (len && len + strlen(kWinHostsPath) + 1 < size) { if (pathbuf[len] == '\\') pathbuf[len--] = '\0'; memcpy(&pathbuf[len], kWinHostsPath, strlen(kWinHostsPath) + 1); return &pathbuf[0]; } else { return NULL; } } /** * Returns hosts.txt map. * * @note yoinking realloc() ensures there's no size limits * @threadsafe */ const struct HostsTxt *GetHostsTxt(void) { FILE *f; const char *path; char pathbuf[PATH_MAX]; struct HostsTxtInitialStaticMemory *init; init = &g_hoststxt_init; pthread_mutex_lock(&init->lock); if (!g_hoststxt) { g_hoststxt = &init->ht; init->ht.entries.n = pushpop(ARRAYLEN(init->entries)); init->ht.entries.p = init->entries; init->ht.strings.n = pushpop(ARRAYLEN(init->strings)); init->ht.strings.p = init->strings; __cxa_atexit(FreeHostsTxt, &g_hoststxt, NULL); path = "/etc/hosts"; if (IsWindows()) { path = firstnonnull(GetNtHostsTxtPath(pathbuf, ARRAYLEN(pathbuf)), path); } if (fileexists(path) && (f = fopen(path, "r"))) { if (ParseHostsTxt(g_hoststxt, f) == -1) { /* TODO(jart): Elevate robustness. */ } fclose(f); } } pthread_mutex_unlock(&init->lock); return g_hoststxt; } /** * Frees HOSTS.TXT data structure populated by ParseHostsTxt(). */ void FreeHostsTxt(struct HostsTxt **ht) { if (*ht) { if ((*ht)->entries.p != g_hoststxt_init.entries) { free((*ht)->entries.p); } if ((*ht)->strings.p != g_hoststxt_init.strings) { free((*ht)->strings.p); } if (*ht != &g_hoststxt_init.ht) { free(*ht); } *ht = 0; } }
4,345
107
jart/cosmopolitan
false
cosmopolitan/libc/dns/servicestxt.h
#ifndef COSMOPOLITAN_LIBC_DNS_SERVICESTXT_H_ #define COSMOPOLITAN_LIBC_DNS_SERVICESTXT_H_ #include "libc/sock/sock.h" #include "libc/stdio/stdio.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ int LookupServicesByPort(const int, char *, size_t, char *, size_t, const char *) paramsnonnull((2, 4)); int LookupServicesByName(const char *, char *, size_t, char *, size_t, const char *) paramsnonnull((1, 2)); char *GetNtServicesTxtPath(char *, uint32_t); /* TODO: implement like struct HostsTxt? */ COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_DNS_SERVICESTXT_H_ */
681
19
jart/cosmopolitan
false
cosmopolitan/libc/dns/resolvehostsreverse.c
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ │vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ ╞══════════════════════════════════════════════════════════════════════════════╡ │ Copyright 2021 Justine Alexandra Roberts Tunney │ │ │ │ Permission to use, copy, modify, and/or distribute this software for │ │ any purpose with or without fee is hereby granted, provided that the │ │ above copyright notice and this permission notice appear in all copies. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ │ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ │ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ │ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ │ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ │ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/dns/consts.h" #include "libc/dns/dns.h" #include "libc/dns/hoststxt.h" #include "libc/fmt/fmt.h" #include "libc/intrin/bits.h" #include "libc/mem/alg.h" #include "libc/sock/sock.h" #include "libc/str/str.h" #include "libc/sysv/consts/af.h" #include "libc/sysv/errfuns.h" /** * Finds name associated with address in HOSTS.TXT table. * * @param ht can be GetHostsTxt() * @param af can be AF_INET * @param ip is IP address in binary (sin_addr) * @param buf is buffer to store the name * @param bufsize is length of buf * @return 1 if found, 0 if not found, or -1 w/ errno * @error EAFNOSUPPORT */ int ResolveHostsReverse(const struct HostsTxt *ht, int af, const uint8_t *ip, char *buf, size_t bufsize) { size_t i; if (af != AF_INET && af != AF_UNSPEC) return eafnosupport(); for (i = 0; i < ht->entries.i; ++i) { if (READ32LE(ip) == READ32LE(ht->entries.p[i].ip)) { if (memccpy(buf, ht->strings.p + ht->entries.p[i].name, '\0', bufsize)) { return 1; } } } return 0; }
2,889
54
jart/cosmopolitan
false
cosmopolitan/libc/dns/dns.h
#ifndef COSMOPOLITAN_LIBC_DNS_DNS_H_ #define COSMOPOLITAN_LIBC_DNS_DNS_H_ #include "libc/calls/weirdtypes.h" #include "libc/dns/resolvconf.h" #include "libc/sock/sock.h" #include "libc/sock/struct/sockaddr.h" #define DNS_PORT 53 #define DNS_NAME_MAX 253 #define DNS_LABEL_MAX 63 #define EAI_SUCCESS 0 #define EAI_BADFLAGS -1 #define EAI_NONAME -2 #define EAI_AGAIN -3 #define EAI_FAIL -4 #define EAI_NODATA -5 #define EAI_FAMILY -6 #define EAI_SOCKTYPE -7 #define EAI_SERVICE -8 #define EAI_ADDRFAMILY -9 #define EAI_MEMORY -10 #define EAI_OVERFLOW -12 #define EAI_SYSTEM -11 #define EAI_ALLDONE -103 #define EAI_CANCELED -101 #define EAI_IDN_ENCODE -105 #define EAI_INPROGRESS -100 #define EAI_INTR -104 #define EAI_NOTCANCELED -102 /* AI_* conforms to NT ABI */ #define AI_PASSIVE 1 #define AI_CANONNAME 2 #define AI_NUMERICHOST 4 #define AI_NUMERICSERV 8 #define AI_ALL 0x0100 #define AI_ADDRCONFIG 0x0400 #define AI_V4MAPPED 0x0800 #define NI_NUMERICSCOPE 0 #define NI_NUMERICHOST 1 #define NI_NUMERICSERV 2 #define NI_NOFQDN 4 #define NI_NAMEREQD 8 #define NI_DGRAM 16 #define NI_MAXSERV 32 #define NI_MAXHOST 1025 #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ struct addrinfo { int32_t ai_flags; /* AI_XXX */ int32_t ai_family; /* AF_INET */ int32_t ai_socktype; /* SOCK_XXX */ int32_t ai_protocol; /* IPPROTO_XXX */ uint32_t ai_addrlen; union { struct sockaddr *ai_addr; struct sockaddr_in *ai_addr4; }; char *ai_canonname /*[DNS_NAME_MAX + 1]*/; struct addrinfo *ai_next; }; int getaddrinfo(const char *, const char *, const struct addrinfo *, struct addrinfo **) paramsnonnull((4)); void freeaddrinfo(struct addrinfo *); int getnameinfo(const struct sockaddr *, socklen_t, char *, socklen_t, char *, socklen_t, int); const char *gai_strerror(int); int CompareDnsNames(const char *, const char *) paramsnonnull(); int PascalifyDnsName(uint8_t *, size_t, const char *) paramsnonnull(); int ResolveDns(const struct ResolvConf *, int, const char *, struct sockaddr *, uint32_t) paramsnonnull(); int ResolveDnsReverse(const struct ResolvConf *, int, const char *, char *, size_t) paramsnonnull(); struct addrinfo *newaddrinfo(uint16_t); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_DNS_DNS_H_ */
2,497
84
jart/cosmopolitan
false