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/stdio/posix_spawn.internal.h | #ifndef COSMOPOLITAN_LIBC_STDIO_SPAWNA_INTERNAL_H_
#define COSMOPOLITAN_LIBC_STDIO_SPAWNA_INTERNAL_H_
#include "libc/calls/struct/sched_param.h"
#include "libc/calls/struct/sigset.h"
#define _POSIX_SPAWN_CLOSE 1
#define _POSIX_SPAWN_DUP2 2
#define _POSIX_SPAWN_OPEN 3
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
struct _posix_spawna {
char flags;
bool schedparam_isset;
bool schedpolicy_isset;
bool sigmask_isset;
int pgroup;
int schedpolicy;
struct sched_param schedparam;
sigset_t sigmask;
sigset_t sigdefault;
};
struct _posix_faction {
struct _posix_faction *next;
int action;
union {
int fildes;
int oflag;
};
union {
int newfildes;
unsigned mode;
};
const char *path;
};
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_STDIO_SPAWNA_INTERNAL_H_ */
| 871 | 42 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/getchar_unlocked.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"
/**
* Reads byte from stdin.
* @return byte in range 0..255, or -1 w/ errno
*/
int getchar_unlocked(void) {
return fgetc_unlocked(stdin);
}
| 2,012 | 28 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/freading.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_ext.h"
#include "libc/sysv/consts/o.h"
/**
* Returns nonzero if stream is read only.
*/
int __freading(FILE *f) {
return (f->iomode & O_ACCMODE) == O_RDONLY;
}
| 2,028 | 28 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/mkostemp.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/temp.h"
int mkostemp(char *template, unsigned flags) {
return mkostempsm(template, 0, flags, 0600);
}
| 1,962 | 24 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/clearerr_unlocked.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"
/**
* Clears eof and error state indicators on stream.
*
* @param f is file object stream pointer
* @see clearerr()
* @threadsafe
*/
void clearerr_unlocked(FILE *f) {
f->state = 0;
}
| 2,058 | 31 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/ftrylockfile.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/stdio/lock.internal.h"
#include "libc/stdio/stdio.h"
#include "libc/thread/thread.h"
/**
* Tries to acquire reentrant stdio object lock.
*
* @return 0 on success, or non-zero if another thread owns the lock
*/
int(ftrylockfile)(FILE *f) {
return pthread_mutex_trylock((pthread_mutex_t *)f->lock);
}
| 2,157 | 31 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/big5.inc | 12288,65292,12289,12290,65294,8231,65307,65306,65311,65281,65072,8230,8229,
65104,65105,65106,183,65108,65109,65110,65111,65372,8211,65073,8212,65075,
9588,65076,65103,65288,65289,65077,65078,65371,65373,65079,65080,12308,12309,
65081,65082,12304,12305,65083,65084,12298,12299,65085,65086,12296,12297,65087,
65088,12300,12301,65089,65090,12302,12303,65091,65092,65113,65114,65115,65116,
65117,65118,8216,8217,8220,8221,12317,12318,8245,8242,65283,65286,65290,8251,
167,12291,9675,9679,9651,9650,9678,9734,9733,9671,9670,9633,9632,9661,9660,
12963,8453,175,65507,65343,717,65097,65098,65101,65102,65099,65100,65119,
65120,65121,65291,65293,215,247,177,8730,65308,65310,65309,8806,8807,8800,
8734,8786,8801,65122,65123,65124,65125,65126,65374,8745,8746,8869,8736,8735,
8895,13266,13265,8747,8750,8757,8756,9792,9794,8853,8857,8593,8595,8592,8594,
8598,8599,8601,8600,8741,8739,65295,65340,8725,65128,65284,65509,12306,65504,
65505,65285,65312,8451,8457,65129,65130,65131,13269,13212,13213,13214,13262,
13217,13198,13199,13252,176,20825,20827,20830,20829,20833,20835,21991,29929,
31950,9601,9602,9603,9604,9605,9606,9607,9608,9615,9614,9613,9612,9611,9610,
9609,9532,9524,9516,9508,9500,9620,9472,9474,9621,9484,9488,9492,9496,9581,
9582,9584,9583,9552,9566,9578,9569,9698,9699,9701,9700,9585,9586,9587,65296,
65297,65298,65299,65300,65301,65302,65303,65304,65305,8544,8545,8546,8547,
8548,8549,8550,8551,8552,8553,12321,
12322,12323,12324,12325,12326,12327,12328,12329,21313,21316,21317,65313,65314,
65315,65316,65317,65318,65319,65320,65321,65322,65323,65324,65325,65326,65327,
65328,65329,65330,65331,65332,65333,65334,65335,65336,65337,65338,65345,65346,
65347,65348,65349,65350,65351,65352,65353,65354,65355,65356,65357,65358,65359,
65360,65361,65362,65363,65364,65365,65366,65367,65368,65369,65370,913,914,915,
916,917,918,919,920,921,922,923,924,925,926,927,928,929,931,932,933,934,935,
936,937,945,946,947,948,949,950,951,952,953,954,955,956,957,958,959,960,961,
963,964,965,966,967,968,969,12549,12550,12551,12552,12553,12554,12555,12556,
12557,12558,12559,12560,12561,12562,12563,12564,12565,12566,12567,12568,12569,
12570,12571,12572,12573,12574,12575,12576,12577,12578,12579,12580,12581,12582,
12583,12584,12585,729,713,714,711,715,9216,9217,9218,9219,9220,9221,9222,9223,
9224,9225,9226,9227,9228,9229,9230,9231,9232,9233,9234,9235,9236,9237,9238,
9239,9240,9241,9242,9243,9244,9245,9246,9247,9249,8364,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19968,20057,19969,19971,20035,20061,20102,
20108,20154,20799,20837,20843,20960,20992,20993,21147,21269,21313,21340,21448,
19977,19979,19976,19978,20011,20024,20961,20037,20040,20063,20062,20110,20129,
20800,20995,21242,21315,21449,21475,22303,
22763,22805,22823,22899,23376,23377,23379,23544,23567,23586,23608,23665,24029,
24037,24049,24050,24051,24062,24178,24318,24331,24339,25165,19985,19984,19981,
20013,20016,20025,20043,23609,20104,20113,20117,20114,20116,20130,20161,20160,
20163,20166,20167,20173,20170,20171,20164,20803,20801,20839,20845,20846,20844,
20887,20982,20998,20999,21000,21243,21246,21247,21270,21305,21320,21319,21317,
21342,21380,21451,21450,21453,22764,22825,22827,22826,22829,23380,23569,23588,
23610,23663,24052,24187,24319,24340,24341,24515,25096,25142,25163,25166,25903,
25991,26007,26020,26041,26085,26352,26376,26408,27424,27490,27513,27595,27604,
27611,27663,27700,28779,29226,29238,29243,29255,29273,29275,29356,29579,19993,
19990,19989,19988,19992,20027,20045,20047,20046,20197,20184,20180,20181,20182,
20183,20195,20196,20185,20190,20805,20804,20873,20874,20908,20985,20986,20984,
21002,21152,21151,21253,21254,21271,21277,20191,21322,21321,21345,21344,21359,
21358,21435,21487,21476,21491,21484,21486,21481,21480,21500,21496,21493,21483,
21478,21482,21490,21489,21488,21477,21485,21499,22235,22234,22806,22830,22833,
22900,22902,23381,23427,23612,24040,24039,24038,24066,24067,24179,24188,24321,
24344,24343,24517,25098,25171,25172,25170,25169,26021,26086,26414,26412,26410,
26411,26413,27491,27597,27665,27664,27704,27713,27712,27710,29359,29572,29577,
29916,29926,29976,29983,29992,29993,30000,30001,30002,30003,30091,30333,30382,
30399,30446,30683,30690,30707,31034,31166,31348,31435,19998,19999,20050,20051,
20073,20121,20132,20134,20133,20223,20233,20249,20234,
20245,20237,20240,20241,20239,20210,20214,20219,20208,20211,20221,20225,20235,
20809,20807,20806,20808,20840,20849,20877,20912,21015,21009,21010,21006,21014,
21155,21256,21281,21280,21360,21361,21513,21519,21516,21514,21520,21505,21515,
21508,21521,21517,21512,21507,21518,21510,21522,22240,22238,22237,22323,22320,
22312,22317,22316,22319,22313,22809,22810,22839,22840,22916,22904,22915,22909,
22905,22914,22913,23383,23384,23431,23432,23429,23433,23546,23574,23673,24030,
24070,24182,24180,24335,24347,24537,24534,25102,25100,25101,25104,25187,25179,
25176,25910,26089,26088,26092,26093,26354,26355,26377,26429,26420,26417,26421,
27425,27492,27515,27670,27741,27735,27737,27743,27744,27728,27733,27745,27739,
27725,27726,28784,29279,29277,30334,31481,31859,31992,32566,32650,32701,32769,
32771,32780,32786,32819,32895,32905,32907,32908,33251,33258,33267,33276,33292,
33307,33311,33390,33394,33406,34411,34880,34892,34915,35199,38433,20018,20136,
20301,20303,20295,20311,20318,20276,20315,20309,20272,20304,20305,20285,20282,
20280,20291,20308,20284,20294,20323,20316,20320,20271,20302,20278,20313,20317,
20296,20314,20812,20811,20813,20853,20918,20919,21029,21028,21033,21034,21032,
21163,21161,21162,21164,21283,21363,21365,21533,21549,21534,21566,21542,21582,
21543,21574,21571,21555,21576,21570,21531,21545,21578,21561,21563,21560,21550,
21557,21558,21536,21564,21568,21553,21547,21535,21548,22250,22256,22244,22251,
22346,22353,22336,22349,22343,22350,22334,22352,22351,22331,22767,22846,22941,
22930,22952,22942,22947,22937,22934,22925,22948,22931,
22922,22949,23389,23388,23386,23387,23436,23435,23439,23596,23616,23617,23615,
23614,23696,23697,23700,23692,24043,24076,24207,24199,24202,24311,24324,24351,
24420,24418,24439,24441,24536,24524,24535,24525,24561,24555,24568,24554,25106,
25105,25220,25239,25238,25216,25206,25225,25197,25226,25212,25214,25209,25203,
25234,25199,25240,25198,25237,25235,25233,25222,25913,25915,25912,26097,26356,
26463,26446,26447,26448,26449,26460,26454,26462,26441,26438,26464,26451,26455,
27493,27599,27714,27742,27801,27777,27784,27785,27781,27803,27754,27770,27792,
27760,27788,27752,27798,27794,27773,27779,27762,27774,27764,27782,27766,27789,
27796,27800,27778,28790,28796,28797,28792,29282,29281,29280,29380,29378,29590,
29996,29995,30007,30008,30338,30447,30691,31169,31168,31167,31350,31995,32597,
32918,32915,32925,32920,32923,32922,32946,33391,33426,33419,33421,35211,35282,
35328,35895,35910,35925,35997,36196,36208,36275,36523,36554,36763,36784,36802,
36806,36805,36804,24033,37009,37026,37034,37030,37027,37193,37318,37324,38450,
38446,38449,38442,38444,20006,20054,20083,20107,20123,20126,20139,20140,20335,
20381,20365,20339,20351,20332,20379,20363,20358,20355,20336,20341,20360,20329,
20347,20374,20350,20367,20369,20346,20820,20818,20821,20841,20855,20854,20856,
20925,20989,21051,21048,21047,21050,21040,21038,21046,21057,21182,21179,21330,
21332,21331,21329,21350,21367,21368,21369,21462,21460,21463,21619,21621,21654,
21624,21653,21632,21627,21623,21636,21650,21638,21628,21648,21617,21622,21644,
21658,21602,21608,21643,21629,21646,22266,22403,22391,
22378,22377,22369,22374,22372,22396,22812,22857,22855,22856,22852,22868,22974,
22971,22996,22969,22958,22993,22982,22992,22989,22987,22995,22986,22959,22963,
22994,22981,23391,23396,23395,23447,23450,23448,23452,23449,23451,23578,23624,
23621,23622,23735,23713,23736,23721,23723,23729,23731,24088,24090,24086,24085,
24091,24081,24184,24218,24215,24220,24213,24214,24310,24358,24359,24361,24448,
24449,24447,24444,24541,24544,24573,24565,24575,24591,24596,24623,24629,24598,
24618,24597,24609,24615,24617,24619,24603,25110,25109,25151,25150,25152,25215,
25289,25292,25284,25279,25282,25273,25298,25307,25259,25299,25300,25291,25288,
25256,25277,25276,25296,25305,25287,25293,25269,25306,25265,25304,25302,25303,
25286,25260,25294,25918,26023,26044,26106,26132,26131,26124,26118,26114,26126,
26112,26127,26133,26122,26119,26381,26379,26477,26507,26517,26481,26524,26483,
26487,26503,26525,26519,26479,26480,26495,26505,26494,26512,26485,26522,26515,
26492,26474,26482,27427,27494,27495,27519,27667,27675,27875,27880,27891,27825,
27852,27877,27827,27837,27838,27836,27874,27819,27861,27859,27832,27844,27833,
27841,27822,27863,27845,27889,27839,27835,27873,27867,27850,27820,27887,27868,
27862,27872,28821,28814,28818,28810,28825,29228,29229,29240,29256,29287,29289,
29376,29390,29401,29399,29392,29609,29608,29599,29611,29605,30013,30109,30105,
30106,30340,30402,30450,30452,30693,30717,31038,31040,31041,31177,31176,31354,
31353,31482,31998,32596,32652,32651,32773,32954,32933,32930,32945,32929,32939,
32937,32948,32938,32943,33253,33278,33293,33459,33437,
33433,33453,33469,33439,33465,33457,33452,33445,33455,33464,33443,33456,33470,
33463,34382,34417,21021,34920,36555,36814,36820,36817,37045,37048,37041,37046,
37319,37329,38263,38272,38428,38464,38463,38459,38468,38466,38585,38632,38738,
38750,20127,20141,20142,20449,20405,20399,20415,20448,20433,20431,20445,20419,
20406,20440,20447,20426,20439,20398,20432,20420,20418,20442,20430,20446,20407,
20823,20882,20881,20896,21070,21059,21066,21069,21068,21067,21063,21191,21193,
21187,21185,21261,21335,21371,21402,21467,21676,21696,21672,21710,21705,21688,
21670,21683,21703,21698,21693,21674,21697,21700,21704,21679,21675,21681,21691,
21673,21671,21695,22271,22402,22411,22432,22435,22434,22478,22446,22419,22869,
22865,22863,22862,22864,23004,23000,23039,23011,23016,23043,23013,23018,23002,
23014,23041,23035,23401,23459,23462,23460,23458,23461,23553,23630,23631,23629,
23627,23769,23762,24055,24093,24101,24095,24189,24224,24230,24314,24328,24365,
24421,24456,24453,24458,24459,24455,24460,24457,24594,24605,24608,24613,24590,
24616,24653,24688,24680,24674,24646,24643,24684,24683,24682,24676,25153,25308,
25366,25353,25340,25325,25345,25326,25341,25351,25329,25335,25327,25324,25342,
25332,25361,25346,25919,25925,26027,26045,26082,26149,26157,26144,26151,26159,
26143,26152,26161,26148,26359,26623,26579,26609,26580,26576,26604,26550,26543,
26613,26601,26607,26564,26577,26548,26586,26597,26552,26575,26590,26611,26544,
26585,26594,26589,26578,27498,27523,27526,27573,27602,27607,27679,27849,27915,
27954,27946,27969,27941,27916,27953,27934,27927,27963,
27965,27966,27958,27931,27893,27961,27943,27960,27945,27950,27957,27918,27947,
28843,28858,28851,28844,28847,28845,28856,28846,28836,29232,29298,29295,29300,
29417,29408,29409,29623,29642,29627,29618,29645,29632,29619,29978,29997,30031,
30028,30030,30027,30123,30116,30117,30114,30115,30328,30342,30343,30344,30408,
30406,30403,30405,30465,30457,30456,30473,30475,30462,30460,30471,30684,30722,
30740,30732,30733,31046,31049,31048,31047,31161,31162,31185,31186,31179,31359,
31361,31487,31485,31869,32002,32005,32000,32009,32007,32004,32006,32568,32654,
32703,32772,32784,32781,32785,32822,32982,32997,32986,32963,32964,32972,32993,
32987,32974,32990,32996,32989,33268,33314,33511,33539,33541,33507,33499,33510,
33540,33509,33538,33545,33490,33495,33521,33537,33500,33492,33489,33502,33491,
33503,33519,33542,34384,34425,34427,34426,34893,34923,35201,35284,35336,35330,
35331,35998,36000,36212,36211,36276,36557,36556,36848,36838,36834,36842,36837,
36845,36843,36836,36840,37066,37070,37057,37059,37195,37194,37325,38274,38480,
38475,38476,38477,38754,38761,38859,38893,38899,38913,39080,39131,39135,39318,
39321,20056,20147,20492,20493,20515,20463,20518,20517,20472,20521,20502,20486,
20540,20511,20506,20498,20497,20474,20480,20500,20520,20465,20513,20491,20505,
20504,20467,20462,20525,20522,20478,20523,20489,20860,20900,20901,20898,20941,
20940,20934,20939,21078,21084,21076,21083,21085,21290,21375,21407,21405,21471,
21736,21776,21761,21815,21756,21733,21746,21766,21754,21780,21737,21741,21729,
21769,21742,21738,21734,21799,21767,21757,21775,22275,
22276,22466,22484,22475,22467,22537,22799,22871,22872,22874,23057,23064,23068,
23071,23067,23059,23020,23072,23075,23081,23077,23052,23049,23403,23640,23472,
23475,23478,23476,23470,23477,23481,23480,23556,23633,23637,23632,23789,23805,
23803,23786,23784,23792,23798,23809,23796,24046,24109,24107,24235,24237,24231,
24369,24466,24465,24464,24665,24675,24677,24656,24661,24685,24681,24687,24708,
24735,24730,24717,24724,24716,24709,24726,25159,25331,25352,25343,25422,25406,
25391,25429,25410,25414,25423,25417,25402,25424,25405,25386,25387,25384,25421,
25420,25928,25929,26009,26049,26053,26178,26185,26191,26179,26194,26188,26181,
26177,26360,26388,26389,26391,26657,26680,26696,26694,26707,26681,26690,26708,
26665,26803,26647,26700,26705,26685,26612,26704,26688,26684,26691,26666,26693,
26643,26648,26689,27530,27529,27575,27683,27687,27688,27686,27684,27888,28010,
28053,28040,28039,28006,28024,28023,27993,28051,28012,28041,28014,27994,28020,
28009,28044,28042,28025,28037,28005,28052,28874,28888,28900,28889,28872,28879,
29241,29305,29436,29433,29437,29432,29431,29574,29677,29705,29678,29664,29674,
29662,30036,30045,30044,30042,30041,30142,30149,30151,30130,30131,30141,30140,
30137,30146,30136,30347,30384,30410,30413,30414,30505,30495,30496,30504,30697,
30768,30759,30776,30749,30772,30775,30757,30765,30752,30751,30770,31061,31056,
31072,31071,31062,31070,31069,31063,31066,31204,31203,31207,31199,31206,31209,
31192,31364,31368,31449,31494,31505,31881,32033,32023,32011,32010,32032,32034,
32020,32016,32021,32026,32028,32013,32025,32027,32570,
32607,32660,32709,32705,32774,32792,32789,32793,32791,32829,32831,33009,33026,
33008,33029,33005,33012,33030,33016,33011,33032,33021,33034,33020,33007,33261,
33260,33280,33296,33322,33323,33320,33324,33467,33579,33618,33620,33610,33592,
33616,33609,33589,33588,33615,33586,33593,33590,33559,33600,33585,33576,33603,
34388,34442,34474,34451,34468,34473,34444,34467,34460,34928,34935,34945,34946,
34941,34937,35352,35344,35342,35340,35349,35338,35351,35347,35350,35343,35345,
35912,35962,35961,36001,36002,36215,36524,36562,36564,36559,36785,36865,36870,
36855,36864,36858,36852,36867,36861,36869,36856,37013,37089,37085,37090,37202,
37197,37196,37336,37341,37335,37340,37337,38275,38498,38499,38497,38491,38493,
38500,38488,38494,38587,39138,39340,39592,39640,39717,39730,39740,20094,20602,
20605,20572,20551,20547,20556,20570,20553,20581,20598,20558,20565,20597,20596,
20599,20559,20495,20591,20589,20828,20885,20976,21098,21103,21202,21209,21208,
21205,21264,21263,21273,21311,21312,21310,21443,26364,21830,21866,21862,21828,
21854,21857,21827,21834,21809,21846,21839,21845,21807,21860,21816,21806,21852,
21804,21859,21811,21825,21847,22280,22283,22281,22495,22533,22538,22534,22496,
22500,22522,22530,22581,22519,22521,22816,22882,23094,23105,23113,23142,23146,
23104,23100,23138,23130,23110,23114,23408,23495,23493,23492,23490,23487,23494,
23561,23560,23559,23648,23644,23645,23815,23814,23822,23835,23830,23842,23825,
23849,23828,23833,23844,23847,23831,24034,24120,24118,24115,24119,24247,24248,
24246,24245,24254,24373,24375,24407,24428,24425,24427,
24471,24473,24478,24472,24481,24480,24476,24703,24739,24713,24736,24744,24779,
24756,24806,24765,24773,24763,24757,24796,24764,24792,24789,24774,24799,24760,
24794,24775,25114,25115,25160,25504,25511,25458,25494,25506,25509,25463,25447,
25496,25514,25457,25513,25481,25475,25499,25451,25512,25476,25480,25497,25505,
25516,25490,25487,25472,25467,25449,25448,25466,25949,25942,25937,25945,25943,
21855,25935,25944,25941,25940,26012,26011,26028,26063,26059,26060,26062,26205,
26202,26212,26216,26214,26206,26361,21207,26395,26753,26799,26786,26771,26805,
26751,26742,26801,26791,26775,26800,26755,26820,26797,26758,26757,26772,26781,
26792,26783,26785,26754,27442,27578,27627,27628,27691,28046,28092,28147,28121,
28082,28129,28108,28132,28155,28154,28165,28103,28107,28079,28113,28078,28126,
28153,28088,28151,28149,28101,28114,28186,28085,28122,28139,28120,28138,28145,
28142,28136,28102,28100,28074,28140,28095,28134,28921,28937,28938,28925,28911,
29245,29309,29313,29468,29467,29462,29459,29465,29575,29701,29706,29699,29702,
29694,29709,29920,29942,29943,29980,29986,30053,30054,30050,30064,30095,30164,
30165,30133,30154,30157,30350,30420,30418,30427,30519,30526,30524,30518,30520,
30522,30827,30787,30798,31077,31080,31085,31227,31378,31381,31520,31528,31515,
31532,31526,31513,31518,31534,31890,31895,31893,32070,32067,32113,32046,32057,
32060,32064,32048,32051,32068,32047,32066,32050,32049,32573,32670,32666,32716,
32718,32722,32796,32842,32838,33071,33046,33059,33067,33065,33072,33060,33282,
33333,33335,33334,33337,33678,33694,33688,33656,33698,
33686,33725,33707,33682,33674,33683,33673,33696,33655,33659,33660,33670,33703,
34389,24426,34503,34496,34486,34500,34485,34502,34507,34481,34479,34505,34899,
34974,34952,34987,34962,34966,34957,34955,35219,35215,35370,35357,35363,35365,
35377,35373,35359,35355,35362,35913,35930,36009,36012,36011,36008,36010,36007,
36199,36198,36286,36282,36571,36575,36889,36877,36890,36887,36899,36895,36893,
36880,36885,36894,36896,36879,36898,36886,36891,36884,37096,37101,37117,37207,
37326,37365,37350,37347,37351,37357,37353,38281,38506,38517,38515,38520,38512,
38516,38518,38519,38508,38592,38634,38633,31456,31455,38914,38915,39770,40165,
40565,40575,40613,40635,20642,20621,20613,20633,20625,20608,20630,20632,20634,
26368,20977,21106,21108,21109,21097,21214,21213,21211,21338,21413,21883,21888,
21927,21884,21898,21917,21912,21890,21916,21930,21908,21895,21899,21891,21939,
21934,21919,21822,21938,21914,21947,21932,21937,21886,21897,21931,21913,22285,
22575,22570,22580,22564,22576,22577,22561,22557,22560,22777,22778,22880,23159,
23194,23167,23186,23195,23207,23411,23409,23506,23500,23507,23504,23562,23563,
23601,23884,23888,23860,23879,24061,24133,24125,24128,24131,24190,24266,24257,
24258,24260,24380,24429,24489,24490,24488,24785,24801,24754,24758,24800,24860,
24867,24826,24853,24816,24827,24820,24936,24817,24846,24822,24841,24832,24850,
25119,25161,25507,25484,25551,25536,25577,25545,25542,25549,25554,25571,25552,
25569,25558,25581,25582,25462,25588,25578,25563,25682,25562,25593,25950,25958,
25954,25955,26001,26000,26031,26222,26224,26228,26230,
26223,26257,26234,26238,26231,26366,26367,26399,26397,26874,26837,26848,26840,
26839,26885,26847,26869,26862,26855,26873,26834,26866,26851,26827,26829,26893,
26898,26894,26825,26842,26990,26875,27454,27450,27453,27544,27542,27580,27631,
27694,27695,27692,28207,28216,28244,28193,28210,28263,28234,28192,28197,28195,
28187,28251,28248,28196,28246,28270,28205,28198,28271,28212,28237,28218,28204,
28227,28189,28222,28363,28297,28185,28238,28259,28228,28274,28265,28255,28953,
28954,28966,28976,28961,28982,29038,28956,29260,29316,29312,29494,29477,29492,
29481,29754,29738,29747,29730,29733,29749,29750,29748,29743,29723,29734,29736,
29989,29990,30059,30058,30178,30171,30179,30169,30168,30174,30176,30331,30332,
30358,30355,30388,30428,30543,30701,30813,30828,30831,31245,31240,31243,31237,
31232,31384,31383,31382,31461,31459,31561,31574,31558,31568,31570,31572,31565,
31563,31567,31569,31903,31909,32094,32080,32104,32085,32043,32110,32114,32097,
32102,32098,32112,32115,21892,32724,32725,32779,32850,32901,33109,33108,33099,
33105,33102,33081,33094,33086,33100,33107,33140,33298,33308,33769,33795,33784,
33805,33760,33733,33803,33729,33775,33777,33780,33879,33802,33776,33804,33740,
33789,33778,33738,33848,33806,33796,33756,33799,33748,33759,34395,34527,34521,
34541,34516,34523,34532,34512,34526,34903,35009,35010,34993,35203,35222,35387,
35424,35413,35422,35388,35393,35412,35419,35408,35398,35380,35386,35382,35414,
35937,35970,36015,36028,36019,36029,36033,36027,36032,36020,36023,36022,36031,
36024,36234,36229,36225,36302,36317,36299,36314,36305,
36300,36315,36294,36603,36600,36604,36764,36910,36917,36913,36920,36914,36918,
37122,37109,37129,37118,37219,37221,37327,37396,37397,37411,37385,37406,37389,
37392,37383,37393,38292,38287,38283,38289,38291,38290,38286,38538,38542,38539,
38525,38533,38534,38541,38514,38532,38593,38597,38596,38598,38599,38639,38642,
38860,38917,38918,38920,39143,39146,39151,39145,39154,39149,39342,39341,40643,
40653,40657,20098,20653,20661,20658,20659,20677,20670,20652,20663,20667,20655,
20679,21119,21111,21117,21215,21222,21220,21218,21219,21295,21983,21992,21971,
21990,21966,21980,21959,21969,21987,21988,21999,21978,21985,21957,21958,21989,
21961,22290,22291,22622,22609,22616,22615,22618,22612,22635,22604,22637,22602,
22626,22610,22603,22887,23233,23241,23244,23230,23229,23228,23219,23234,23218,
23913,23919,24140,24185,24265,24264,24338,24409,24492,24494,24858,24847,24904,
24863,24819,24859,24825,24833,24840,24910,24908,24900,24909,24894,24884,24871,
24845,24838,24887,25121,25122,25619,25662,25630,25642,25645,25661,25644,25615,
25628,25620,25613,25654,25622,25623,25606,25964,26015,26032,26263,26249,26247,
26248,26262,26244,26264,26253,26371,27028,26989,26970,26999,26976,26964,26997,
26928,27010,26954,26984,26987,26974,26963,27001,27014,26973,26979,26971,27463,
27506,27584,27583,27603,27645,28322,28335,28371,28342,28354,28304,28317,28359,
28357,28325,28312,28348,28346,28331,28369,28310,28316,28356,28372,28330,28327,
28340,29006,29017,29033,29028,29001,29031,29020,29036,29030,29004,29029,29022,
28998,29032,29014,29242,29266,29495,29509,29503,29502,
29807,29786,29781,29791,29790,29761,29759,29785,29787,29788,30070,30072,30208,
30192,30209,30194,30193,30202,30207,30196,30195,30430,30431,30555,30571,30566,
30558,30563,30585,30570,30572,30556,30565,30568,30562,30702,30862,30896,30871,
30872,30860,30857,30844,30865,30867,30847,31098,31103,31105,33836,31165,31260,
31258,31264,31252,31263,31262,31391,31392,31607,31680,31584,31598,31591,31921,
31923,31925,32147,32121,32145,32129,32143,32091,32622,32617,32618,32626,32681,
32680,32676,32854,32856,32902,32900,33137,33136,33144,33125,33134,33139,33131,
33145,33146,33126,33285,33351,33922,33911,33853,33841,33909,33894,33899,33865,
33900,33883,33852,33845,33889,33891,33897,33901,33862,34398,34396,34399,34553,
34579,34568,34567,34560,34558,34555,34562,34563,34566,34570,34905,35039,35028,
35033,35036,35032,35037,35041,35018,35029,35026,35228,35299,35435,35442,35443,
35430,35433,35440,35463,35452,35427,35488,35441,35461,35437,35426,35438,35436,
35449,35451,35390,35432,35938,35978,35977,36042,36039,36040,36036,36018,36035,
36034,36037,36321,36319,36328,36335,36339,36346,36330,36324,36326,36530,36611,
36617,36606,36618,36767,36786,36939,36938,36947,36930,36948,36924,36949,36944,
36935,36943,36942,36941,36945,36926,36929,37138,37143,37228,37226,37225,37321,
37431,37463,37432,37437,37440,37438,37467,37451,37476,37457,37428,37449,37453,
37445,37433,37439,37466,38296,38552,38548,38549,38605,38603,38601,38602,38647,
38651,38649,38646,38742,38772,38774,38928,38929,38931,38922,38930,38924,39164,
39156,39165,39166,39347,39345,39348,39649,40169,40578,
40718,40723,40736,20711,20718,20709,20694,20717,20698,20693,20687,20689,20721,
20686,20713,20834,20979,21123,21122,21297,21421,22014,22016,22043,22039,22013,
22036,22022,22025,22029,22030,22007,22038,22047,22024,22032,22006,22296,22294,
22645,22654,22659,22675,22666,22649,22661,22653,22781,22821,22818,22820,22890,
22889,23265,23270,23273,23255,23254,23256,23267,23413,23518,23527,23521,23525,
23526,23528,23522,23524,23519,23565,23650,23940,23943,24155,24163,24149,24151,
24148,24275,24278,24330,24390,24432,24505,24903,24895,24907,24951,24930,24931,
24927,24922,24920,24949,25130,25735,25688,25684,25764,25720,25695,25722,25681,
25703,25652,25709,25723,25970,26017,26071,26070,26274,26280,26269,27036,27048,
27029,27073,27054,27091,27083,27035,27063,27067,27051,27060,27088,27085,27053,
27084,27046,27075,27043,27465,27468,27699,28467,28436,28414,28435,28404,28457,
28478,28448,28460,28431,28418,28450,28415,28399,28422,28465,28472,28466,28451,
28437,28459,28463,28552,28458,28396,28417,28402,28364,28407,29076,29081,29053,
29066,29060,29074,29246,29330,29334,29508,29520,29796,29795,29802,29808,29805,
29956,30097,30247,30221,30219,30217,30227,30433,30435,30596,30589,30591,30561,
30913,30879,30887,30899,30889,30883,31118,31119,31117,31278,31281,31402,31401,
31469,31471,31649,31637,31627,31605,31639,31645,31636,31631,31672,31623,31620,
31929,31933,31934,32187,32176,32156,32189,32190,32160,32202,32180,32178,32177,
32186,32162,32191,32181,32184,32173,32210,32199,32172,32624,32736,32737,32735,
32862,32858,32903,33104,33152,33167,33160,33162,33151,
33154,33255,33274,33287,33300,33310,33355,33993,33983,33990,33988,33945,33950,
33970,33948,33995,33976,33984,34003,33936,33980,34001,33994,34623,34588,34619,
34594,34597,34612,34584,34645,34615,34601,35059,35074,35060,35065,35064,35069,
35048,35098,35055,35494,35468,35486,35491,35469,35489,35475,35492,35498,35493,
35496,35480,35473,35482,35495,35946,35981,35980,36051,36049,36050,36203,36249,
36245,36348,36628,36626,36629,36627,36771,36960,36952,36956,36963,36953,36958,
36962,36957,36955,37145,37144,37150,37237,37240,37239,37236,37496,37504,37509,
37528,37526,37499,37523,37532,37544,37500,37521,38305,38312,38313,38307,38309,
38308,38553,38556,38555,38604,38610,38656,38780,38789,38902,38935,38936,39087,
39089,39171,39173,39180,39177,39361,39599,39600,39654,39745,39746,40180,40182,
40179,40636,40763,40778,20740,20736,20731,20725,20729,20738,20744,20745,20741,
20956,21127,21128,21129,21133,21130,21232,21426,22062,22075,22073,22066,22079,
22068,22057,22099,22094,22103,22132,22070,22063,22064,22656,22687,22686,22707,
22684,22702,22697,22694,22893,23305,23291,23307,23285,23308,23304,23534,23532,
23529,23531,23652,23653,23965,23956,24162,24159,24161,24290,24282,24287,24285,
24291,24288,24392,24433,24503,24501,24950,24935,24942,24925,24917,24962,24956,
24944,24939,24958,24999,24976,25003,24974,25004,24986,24996,24980,25006,25134,
25705,25711,25721,25758,25778,25736,25744,25776,25765,25747,25749,25769,25746,
25774,25773,25771,25754,25772,25753,25762,25779,25973,25975,25976,26286,26283,
26292,26289,27171,27167,27112,27137,27166,27161,27133,
27169,27155,27146,27123,27138,27141,27117,27153,27472,27470,27556,27589,27590,
28479,28540,28548,28497,28518,28500,28550,28525,28507,28536,28526,28558,28538,
28528,28516,28567,28504,28373,28527,28512,28511,29087,29100,29105,29096,29270,
29339,29518,29527,29801,29835,29827,29822,29824,30079,30240,30249,30239,30244,
30246,30241,30242,30362,30394,30436,30606,30599,30604,30609,30603,30923,30917,
30906,30922,30910,30933,30908,30928,31295,31292,31296,31293,31287,31291,31407,
31406,31661,31665,31684,31668,31686,31687,31681,31648,31692,31946,32224,32244,
32239,32251,32216,32236,32221,32232,32227,32218,32222,32233,32158,32217,32242,
32249,32629,32631,32687,32745,32806,33179,33180,33181,33184,33178,33176,34071,
34109,34074,34030,34092,34093,34067,34065,34083,34081,34068,34028,34085,34047,
34054,34690,34676,34678,34656,34662,34680,34664,34649,34647,34636,34643,34907,
34909,35088,35079,35090,35091,35093,35082,35516,35538,35527,35524,35477,35531,
35576,35506,35529,35522,35519,35504,35542,35533,35510,35513,35547,35916,35918,
35948,36064,36062,36070,36068,36076,36077,36066,36067,36060,36074,36065,36205,
36255,36259,36395,36368,36381,36386,36367,36393,36383,36385,36382,36538,36637,
36635,36639,36649,36646,36650,36636,36638,36645,36969,36974,36968,36973,36983,
37168,37165,37159,37169,37255,37257,37259,37251,37573,37563,37559,37610,37548,
37604,37569,37555,37564,37586,37575,37616,37554,38317,38321,38660,38662,38663,
38665,38752,38797,38795,38799,38945,38955,38940,39091,39178,39187,39186,39192,
39389,39376,39391,39387,39377,39381,39378,39385,39607,
39662,39663,39719,39749,39748,39799,39791,40198,40201,40195,40617,40638,40654,
22696,40786,20754,20760,20756,20752,20757,20864,20906,20957,21137,21139,21235,
22105,22123,22137,22121,22116,22136,22122,22120,22117,22129,22127,22124,22114,
22134,22721,22718,22727,22725,22894,23325,23348,23416,23536,23566,24394,25010,
24977,25001,24970,25037,25014,25022,25034,25032,25136,25797,25793,25803,25787,
25788,25818,25796,25799,25794,25805,25791,25810,25812,25790,25972,26310,26313,
26297,26308,26311,26296,27197,27192,27194,27225,27243,27224,27193,27204,27234,
27233,27211,27207,27189,27231,27208,27481,27511,27653,28610,28593,28577,28611,
28580,28609,28583,28595,28608,28601,28598,28582,28576,28596,29118,29129,29136,
29138,29128,29141,29113,29134,29145,29148,29123,29124,29544,29852,29859,29848,
29855,29854,29922,29964,29965,30260,30264,30266,30439,30437,30624,30622,30623,
30629,30952,30938,30956,30951,31142,31309,31310,31302,31308,31307,31418,31705,
31761,31689,31716,31707,31713,31721,31718,31957,31958,32266,32273,32264,32283,
32291,32286,32285,32265,32272,32633,32690,32752,32753,32750,32808,33203,33193,
33192,33275,33288,33368,33369,34122,34137,34120,34152,34153,34115,34121,34157,
34154,34142,34691,34719,34718,34722,34701,34913,35114,35122,35109,35115,35105,
35242,35238,35558,35578,35563,35569,35584,35548,35559,35566,35582,35585,35586,
35575,35565,35571,35574,35580,35947,35949,35987,36084,36420,36401,36404,36418,
36409,36405,36667,36655,36664,36659,36776,36774,36981,36980,36984,36978,36988,
36986,37172,37266,37664,37686,37624,37683,37679,37666,
37628,37675,37636,37658,37648,37670,37665,37653,37678,37657,38331,38567,38568,
38570,38613,38670,38673,38678,38669,38675,38671,38747,38748,38758,38808,38960,
38968,38971,38967,38957,38969,38948,39184,39208,39198,39195,39201,39194,39405,
39394,39409,39608,39612,39675,39661,39720,39825,40213,40227,40230,40232,40210,
40219,40664,40660,40845,40860,20778,20767,20769,20786,21237,22158,22144,22160,
22149,22151,22159,22741,22739,22737,22734,23344,23338,23332,23418,23607,23656,
23996,23994,23997,23992,24171,24396,24509,25033,25026,25031,25062,25035,25138,
25140,25806,25802,25816,25824,25840,25830,25836,25841,25826,25837,25986,25987,
26329,26326,27264,27284,27268,27298,27292,27355,27299,27262,27287,27280,27296,
27484,27566,27610,27656,28632,28657,28639,28640,28635,28644,28651,28655,28544,
28652,28641,28649,28629,28654,28656,29159,29151,29166,29158,29157,29165,29164,
29172,29152,29237,29254,29552,29554,29865,29872,29862,29864,30278,30274,30284,
30442,30643,30634,30640,30636,30631,30637,30703,30967,30970,30964,30959,30977,
31143,31146,31319,31423,31751,31757,31742,31735,31756,31712,31968,31964,31966,
31970,31967,31961,31965,32302,32318,32326,32311,32306,32323,32299,32317,32305,
32325,32321,32308,32313,32328,32309,32319,32303,32580,32755,32764,32881,32882,
32880,32879,32883,33222,33219,33210,33218,33216,33215,33213,33225,33214,33256,
33289,33393,34218,34180,34174,34204,34193,34196,34223,34203,34183,34216,34186,
34407,34752,34769,34739,34770,34758,34731,34747,34746,34760,34763,35131,35126,
35140,35128,35133,35244,35598,35607,35609,35611,35594,
35616,35613,35588,35600,35905,35903,35955,36090,36093,36092,36088,36091,36264,
36425,36427,36424,36426,36676,36670,36674,36677,36671,36991,36989,36996,36993,
36994,36992,37177,37283,37278,37276,37709,37762,37672,37749,37706,37733,37707,
37656,37758,37740,37723,37744,37722,37716,38346,38347,38348,38344,38342,38577,
38584,38614,38684,38686,38816,38867,38982,39094,39221,39425,39423,39854,39851,
39850,39853,40251,40255,40587,40655,40670,40668,40669,40667,40766,40779,21474,
22165,22190,22745,22744,23352,24413,25059,25139,25844,25842,25854,25862,25850,
25851,25847,26039,26332,26406,27315,27308,27331,27323,27320,27330,27310,27311,
27487,27512,27567,28681,28683,28670,28678,28666,28689,28687,29179,29180,29182,
29176,29559,29557,29863,29887,29973,30294,30296,30290,30653,30655,30651,30652,
30990,31150,31329,31330,31328,31428,31429,31787,31783,31786,31774,31779,31777,
31975,32340,32341,32350,32346,32353,32338,32345,32584,32761,32763,32887,32886,
33229,33231,33290,34255,34217,34253,34256,34249,34224,34234,34233,34214,34799,
34796,34802,34784,35206,35250,35316,35624,35641,35628,35627,35920,36101,36441,
36451,36454,36452,36447,36437,36544,36681,36685,36999,36995,37000,37291,37292,
37328,37780,37770,37782,37794,37811,37806,37804,37808,37784,37786,37783,38356,
38358,38352,38357,38626,38620,38617,38619,38622,38692,38819,38822,38829,38905,
38989,38991,38988,38990,38995,39098,39230,39231,39229,39214,39333,39438,39617,
39683,39686,39759,39758,39757,39882,39881,39933,39880,39872,40273,40285,40288,
40672,40725,40748,20787,22181,22750,22751,22754,23541,
40848,24300,25074,25079,25078,25077,25856,25871,26336,26333,27365,27357,27354,
27347,28699,28703,28712,28698,28701,28693,28696,29190,29197,29272,29346,29560,
29562,29885,29898,29923,30087,30086,30303,30305,30663,31001,31153,31339,31337,
31806,31807,31800,31805,31799,31808,32363,32365,32377,32361,32362,32645,32371,
32694,32697,32696,33240,34281,34269,34282,34261,34276,34277,34295,34811,34821,
34829,34809,34814,35168,35167,35158,35166,35649,35676,35672,35657,35674,35662,
35663,35654,35673,36104,36106,36476,36466,36487,36470,36460,36474,36468,36692,
36686,36781,37002,37003,37297,37294,37857,37841,37855,37827,37832,37852,37853,
37846,37858,37837,37848,37860,37847,37864,38364,38580,38627,38698,38695,38753,
38876,38907,39006,39000,39003,39100,39237,39241,39446,39449,39693,39912,39911,
39894,39899,40329,40289,40306,40298,40300,40594,40599,40595,40628,21240,22184,
22199,22198,22196,22204,22756,23360,23363,23421,23542,24009,25080,25082,25880,
25876,25881,26342,26407,27372,28734,28720,28722,29200,29563,29903,30306,30309,
31014,31018,31020,31019,31431,31478,31820,31811,31821,31983,31984,36782,32381,
32380,32386,32588,32768,33242,33382,34299,34297,34321,34298,34310,34315,34311,
34314,34836,34837,35172,35258,35320,35696,35692,35686,35695,35679,35691,36111,
36109,36489,36481,36485,36482,37300,37323,37912,37891,37885,38369,38704,39108,
39250,39249,39336,39467,39472,39479,39477,39955,39949,40569,40629,40680,40751,
40799,40803,40801,20791,20792,22209,22208,22210,22804,23660,24013,25084,25086,
25885,25884,26005,26345,27387,27396,27386,27570,28748,
29211,29351,29910,29908,30313,30675,31824,32399,32396,32700,34327,34349,34330,
34851,34850,34849,34847,35178,35180,35261,35700,35703,35709,36115,36490,36493,
36491,36703,36783,37306,37934,37939,37941,37946,37944,37938,37931,38370,38712,
38713,38706,38911,39015,39013,39255,39493,39491,39488,39486,39631,39764,39761,
39981,39973,40367,40372,40386,40376,40605,40687,40729,40796,40806,40807,20796,
20795,22216,22218,22217,23423,24020,24018,24398,25087,25892,27402,27489,28753,
28760,29568,29924,30090,30318,30316,31155,31840,31839,32894,32893,33247,35186,
35183,35324,35712,36118,36119,36497,36499,36705,37192,37956,37969,37970,38717,
38718,38851,38849,39019,39253,39509,39501,39634,39706,40009,39985,39998,39995,
40403,40407,40756,40812,40810,40852,22220,24022,25088,25891,25899,25898,26348,
27408,29914,31434,31844,31843,31845,32403,32406,32404,33250,34360,34367,34865,
35722,37008,37007,37987,37984,37988,38760,39023,39260,39514,39515,39511,39635,
39636,39633,40020,40023,40022,40421,40607,40692,22225,22761,25900,28766,30321,
30322,30679,32592,32648,34870,34873,34914,35731,35730,35734,33399,36123,37312,
37994,38722,38728,38724,38854,39024,39519,39714,39768,40031,40441,40442,40572,
40573,40711,40823,40818,24307,27414,28771,31852,31854,34875,35264,36513,37313,
38002,38000,39025,39262,39638,39715,40652,28772,30682,35738,38007,38857,39522,
39525,32412,35740,36522,37317,38013,38014,38012,40055,40056,40695,35924,38015,
40474,29224,39530,39729,40475,40478,31858,9312,9313,9314,9315,9316,9317,9318,
9319,9320,9321,9332,9333,9334,9335,9336,
9337,9338,9339,9340,9341,8560,8561,8562,8563,8564,8565,8566,8567,8568,8569,
20022,20031,20101,20128,20866,20886,20907,21241,21304,21353,21430,22794,23424,
24027,24186,24191,24308,24400,24417,25908,26080,30098,30326,36789,38582,168,
710,12541,12542,12445,12446,0,0,12293,12294,12295,12540,65339,65341,10045,
12353,12354,12355,12356,12357,12358,12359,12360,12361,12362,12363,12364,12365,
12366,12367,12368,12369,12370,12371,12372,12373,12374,12375,12376,12377,12378,
12379,12380,12381,12382,12383,12384,12385,12386,12387,12388,12389,12390,12391,
12392,12393,12394,12395,12396,12397,12398,12399,12400,12401,12402,12403,12404,
12405,12406,12407,12408,12409,12410,12411,12412,12413,12414,12415,12416,12417,
12418,12419,12420,12421,12422,12423,12424,12425,12426,12427,12428,12429,12430,
12431,12432,12433,12434,12435,12449,12450,12451,12452,12453,12454,12455,12456,
12457,12458,12459,12460,12461,12462,12463,12464,12465,12466,12467,12468,12469,
12470,12471,12472,12473,12474,12475,12476,12477,12478,12479,12480,12481,12482,
12483,12484,12485,12486,12487,12488,12489,12490,12491,12492,12493,12494,12495,
12496,12497,12498,12499,12500,12501,12502,12503,12504,12505,12506,12507,12508,
12509,12510,12511,12512,12513,12514,12515,12516,12517,12518,12519,12520,12521,
12522,12523,12524,12525,12526,12527,12528,12529,12530,12531,12532,12533,12534,
1040,1041,1042,1043,1044,1045,1025,1046,1047,1048,1049,1050,1051,1052,1053,
1054,1055,1056,1057,1058,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,
1069,1070,
1071,1072,1073,1074,1075,1076,1077,1105,1078,1079,1080,1081,1082,1083,1084,
1085,1086,1087,1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,
1100,1101,1102,1103,8679,8632,8633,12751,204,20058,138,20994,17553,40880,
20872,40881,30215,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,65506,65508,65287,65282,12849,8470,8481,12443,12444,11904,
11908,11910,11911,11912,11914,11916,11917,11925,11932,11933,11941,11943,11946,
11948,11950,11958,11964,11966,11974,11978,11980,11981,11983,11990,11991,11998,
12003,0,0,0,643,592,603,596,629,339,248,331,650,618,20034,20060,20981,21274,
21378,19975,19980,20039,20109,22231,64012,23662,24435,19983,20871,19982,20014,
20115,20162,20169,20168,20888,21244,21356,21433,22304,22787,22828,23568,24063,
26081,27571,27596,27668,29247,20017,20028,20200,20188,20201,20193,20189,20186,
21004,21276,21324,22306,22307,22807,22831,23425,23428,23570,23611,23668,23667,
24068,24192,24194,24521,25097,25168,27669,27702,27715,27711,27707,29358,29360,
29578,31160,32906,38430,20238,20248,20268,20213,20244,20209,20224,20215,20232,
20253,20226,20229,20258,20243,20228,20212,20242,20913,21011,21001,21008,21158,
21282,21279,21325,21386,21511,22241,22239,22318,22314,22324,22844,22912,22908,
22917,22907,22910,22903,22911,23382,23573,23589,23676,23674,23675,
23678,24031,24181,24196,24322,24346,24436,24533,24532,24527,25180,25182,25188,
25185,25190,25186,25177,25184,25178,25189,26095,26094,26430,26425,26424,26427,
26426,26431,26428,26419,27672,27718,27730,27740,27727,27722,27732,27723,27724,
28785,29278,29364,29365,29582,29994,30335,31349,32593,33400,33404,33408,33405,
33407,34381,35198,37017,37015,37016,37019,37012,38434,38436,38432,38435,20310,
20283,20322,20297,20307,20324,20286,20327,20306,20319,20289,20312,20269,20275,
20287,20321,20879,20921,21020,21022,21025,21165,21166,21257,21347,21362,21390,
21391,21552,21559,21546,21588,21573,21529,21532,21541,21528,21565,21583,21569,
21544,21540,21575,22254,22247,22245,22337,22341,22348,22345,22347,22354,22790,
22848,22950,22936,22944,22935,22926,22946,22928,22927,22951,22945,23438,23442,
23592,23594,23693,23695,23688,23691,23689,23698,23690,23686,23699,23701,24032,
24074,24078,24203,24201,24204,24200,24205,24325,24349,24440,24438,24530,24529,
24528,24557,24552,24558,24563,24545,24548,24547,24570,24559,24567,24571,24576,
24564,25146,25219,25228,25230,25231,25236,25223,25201,25211,25210,25200,25217,
25224,25207,25213,25202,25204,25911,26096,26100,26099,26098,26101,26437,26439,
26457,26453,26444,26440,26461,26445,26458,26443,27600,27673,27674,27768,27751,
27755,27780,27787,27791,27761,27759,27753,27802,27757,27783,27797,27804,27750,
27763,27749,27771,27790,28788,28794,29283,29375,29373,29379,29382,29377,29370,
29381,29589,29591,29587,29588,29586,30010,30009,30100,30101,30337,31037,32820,
32917,32921,32912,32914,32924,33424,33423,33413,33422,
33425,33427,33418,33411,33412,35960,36809,36799,37023,37025,37029,37022,37031,
37024,38448,38440,38447,38445,20019,20376,20348,20357,20349,20352,20359,20342,
20340,20361,20356,20343,20300,20375,20330,20378,20345,20353,20344,20368,20380,
20372,20382,20370,20354,20373,20331,20334,20894,20924,20926,21045,21042,21043,
21062,21041,21180,21258,21259,21308,21394,21396,21639,21631,21633,21649,21634,
21640,21611,21626,21630,21605,21612,21620,21606,21645,21615,21601,21600,21656,
21603,21607,21604,22263,22265,22383,22386,22381,22379,22385,22384,22390,22400,
22389,22395,22387,22388,22370,22376,22397,22796,22853,22965,22970,22991,22990,
22962,22988,22977,22966,22972,22979,22998,22961,22973,22976,22984,22964,22983,
23394,23397,23443,23445,23620,23623,23726,23716,23712,23733,23727,23720,23724,
23711,23715,23725,23714,23722,23719,23709,23717,23734,23728,23718,24087,24084,
24089,24360,24354,24355,24356,24404,24450,24446,24445,24542,24549,24621,24614,
24601,24626,24587,24628,24586,24599,24627,24602,24606,24620,24610,24589,24592,
24622,24595,24593,24588,24585,24604,25108,25149,25261,25268,25297,25278,25258,
25270,25290,25262,25267,25263,25275,25257,25264,25272,25917,26024,26043,26121,
26108,26116,26130,26120,26107,26115,26123,26125,26117,26109,26129,26128,26358,
26378,26501,26476,26510,26514,26486,26491,26520,26502,26500,26484,26509,26508,
26490,26527,26513,26521,26499,26493,26497,26488,26489,26516,27429,27520,27518,
27614,27677,27795,27884,27883,27886,27865,27830,27860,27821,27879,27831,27856,
27842,27834,27843,27846,27885,27890,27858,27869,27828,
27786,27805,27776,27870,27840,27952,27853,27847,27824,27897,27855,27881,27857,
28820,28824,28805,28819,28806,28804,28817,28822,28802,28826,28803,29290,29398,
29387,29400,29385,29404,29394,29396,29402,29388,29393,29604,29601,29613,29606,
29602,29600,29612,29597,29917,29928,30015,30016,30014,30092,30104,30383,30451,
30449,30448,30453,30712,30716,30713,30715,30714,30711,31042,31039,31173,31352,
31355,31483,31861,31997,32821,32911,32942,32931,32952,32949,32941,33312,33440,
33472,33451,33434,33432,33435,33461,33447,33454,33468,33438,33466,33460,33448,
33441,33449,33474,33444,33475,33462,33442,34416,34415,34413,34414,35926,36818,
36811,36819,36813,36822,36821,36823,37042,37044,37039,37043,37040,38457,38461,
38460,38458,38467,20429,20421,20435,20402,20425,20427,20417,20436,20444,20441,
20411,20403,20443,20423,20438,20410,20416,20409,20460,21060,21065,21184,21186,
21309,21372,21399,21398,21401,21400,21690,21665,21677,21669,21711,21699,33549,
21687,21678,21718,21686,21701,21702,21664,21616,21692,21666,21694,21618,21726,
21680,22453,22430,22431,22436,22412,22423,22429,22427,22420,22424,22415,22425,
22437,22426,22421,22772,22797,22867,23009,23006,23022,23040,23025,23005,23034,
23037,23036,23030,23012,23026,23031,23003,23017,23027,23029,23008,23038,23028,
23021,23464,23628,23760,23768,23756,23767,23755,23771,23774,23770,23753,23751,
23754,23766,23763,23764,23759,23752,23750,23758,23775,23800,24057,24097,24098,
24099,24096,24100,24240,24228,24226,24219,24227,24229,24327,24366,24406,24454,
24631,24633,24660,24690,24670,24645,24659,24647,24649,
24667,24652,24640,24642,24671,24612,24644,24664,24678,24686,25154,25155,25295,
25357,25355,25333,25358,25347,25323,25337,25359,25356,25336,25334,25344,25363,
25364,25338,25365,25339,25328,25921,25923,26026,26047,26166,26145,26162,26165,
26140,26150,26146,26163,26155,26170,26141,26164,26169,26158,26383,26384,26561,
26610,26568,26554,26588,26555,26616,26584,26560,26551,26565,26603,26596,26591,
26549,26573,26547,26615,26614,26606,26595,26562,26553,26574,26599,26608,26546,
26620,26566,26605,26572,26542,26598,26587,26618,26569,26570,26563,26602,26571,
27432,27522,27524,27574,27606,27608,27616,27680,27681,27944,27956,27949,27935,
27964,27967,27922,27914,27866,27955,27908,27929,27962,27930,27921,27904,27933,
27970,27905,27928,27959,27907,27919,27968,27911,27936,27948,27912,27938,27913,
27920,28855,28831,28862,28849,28848,28833,28852,28853,28841,29249,29257,29258,
29292,29296,29299,29294,29386,29412,29416,29419,29407,29418,29414,29411,29573,
29644,29634,29640,29637,29625,29622,29621,29620,29675,29631,29639,29630,29635,
29638,29624,29643,29932,29934,29998,30023,30024,30119,30122,30329,30404,30472,
30467,30468,30469,30474,30455,30459,30458,30695,30696,30726,30737,30738,30725,
30736,30735,30734,30729,30723,30739,31050,31052,31051,31045,31044,31189,31181,
31183,31190,31182,31360,31358,31441,31488,31489,31866,31864,31865,31871,31872,
31873,32003,32008,32001,32600,32657,32653,32702,32775,32782,32783,32788,32823,
32984,32967,32992,32977,32968,32962,32976,32965,32995,32985,32988,32970,32981,
32969,32975,32983,32998,32973,33279,33313,33428,33497,
33534,33529,33543,33512,33536,33493,33594,33515,33494,33524,33516,33505,33522,
33525,33548,33531,33526,33520,33514,33508,33504,33530,33523,33517,34423,34420,
34428,34419,34881,34894,34919,34922,34921,35283,35332,35335,36210,36835,36833,
36846,36832,37105,37053,37055,37077,37061,37054,37063,37067,37064,37332,37331,
38484,38479,38481,38483,38474,38478,20510,20485,20487,20499,20514,20528,20507,
20469,20468,20531,20535,20524,20470,20471,20503,20508,20512,20519,20533,20527,
20529,20494,20826,20884,20883,20938,20932,20933,20936,20942,21089,21082,21074,
21086,21087,21077,21090,21197,21262,21406,21798,21730,21783,21778,21735,21747,
21732,21786,21759,21764,21768,21739,21777,21765,21745,21770,21755,21751,21752,
21728,21774,21763,21771,22273,22274,22476,22578,22485,22482,22458,22470,22461,
22460,22456,22454,22463,22471,22480,22457,22465,22798,22858,23065,23062,23085,
23086,23061,23055,23063,23050,23070,23091,23404,23463,23469,23468,23555,23638,
23636,23788,23807,23790,23793,23799,23808,23801,24105,24104,24232,24238,24234,
24236,24371,24368,24423,24669,24666,24679,24641,24738,24712,24704,24722,24705,
24733,24707,24725,24731,24727,24711,24732,24718,25113,25158,25330,25360,25430,
25388,25412,25413,25398,25411,25572,25401,25419,25418,25404,25385,25409,25396,
25432,25428,25433,25389,25415,25395,25434,25425,25400,25431,25408,25416,25930,
25926,26054,26051,26052,26050,26186,26207,26183,26193,26386,26387,26655,26650,
26697,26674,26675,26683,26699,26703,26646,26673,26652,26677,26667,26669,26671,
26702,26692,26676,26653,26642,26644,26662,26664,26670,
26701,26682,26661,26656,27436,27439,27437,27441,27444,27501,32898,27528,27622,
27620,27624,27619,27618,27623,27685,28026,28003,28004,28022,27917,28001,28050,
27992,28002,28013,28015,28049,28045,28143,28031,28038,27998,28007,28000,28055,
28016,28028,27999,28034,28056,27951,28008,28043,28030,28032,28036,27926,28035,
28027,28029,28021,28048,28892,28883,28881,28893,28875,32569,28898,28887,28882,
28894,28896,28884,28877,28869,28870,28871,28890,28878,28897,29250,29304,29303,
29302,29440,29434,29428,29438,29430,29427,29435,29441,29651,29657,29669,29654,
29628,29671,29667,29673,29660,29650,29659,29652,29661,29658,29655,29656,29672,
29918,29919,29940,29941,29985,30043,30047,30128,30145,30139,30148,30144,30143,
30134,30138,30346,30409,30493,30491,30480,30483,30482,30499,30481,30485,30489,
30490,30498,30503,30755,30764,30754,30773,30767,30760,30766,30763,30753,30761,
30771,30762,30769,31060,31067,31055,31068,31059,31058,31057,31211,31212,31200,
31214,31213,31210,31196,31198,31197,31366,31369,31365,31371,31372,31370,31367,
31448,31504,31492,31507,31493,31503,31496,31498,31502,31497,31506,31876,31889,
31882,31884,31880,31885,31877,32030,32029,32017,32014,32024,32022,32019,32031,
32018,32015,32012,32604,32609,32606,32608,32605,32603,32662,32658,32707,32706,
32704,32790,32830,32825,33018,33010,33017,33013,33025,33019,33024,33281,33327,
33317,33587,33581,33604,33561,33617,33573,33622,33599,33601,33574,33564,33570,
33602,33614,33563,33578,33544,33596,33613,33558,33572,33568,33591,33583,33577,
33607,33605,33612,33619,33566,33580,33611,33575,33608,
34387,34386,34466,34472,34454,34445,34449,34462,34439,34455,34438,34443,34458,
34437,34469,34457,34465,34471,34453,34456,34446,34461,34448,34452,34883,34884,
34925,34933,34934,34930,34944,34929,34943,34927,34947,34942,34932,34940,35346,
35911,35927,35963,36004,36003,36214,36216,36277,36279,36278,36561,36563,36862,
36853,36866,36863,36859,36868,36860,36854,37078,37088,37081,37082,37091,37087,
37093,37080,37083,37079,37084,37092,37200,37198,37199,37333,37346,37338,38492,
38495,38588,39139,39647,39727,20095,20592,20586,20577,20574,20576,20563,20555,
20573,20594,20552,20557,20545,20571,20554,20578,20501,20549,20575,20585,20587,
20579,20580,20550,20544,20590,20595,20567,20561,20944,21099,21101,21100,21102,
21206,21203,21293,21404,21877,21878,21820,21837,21840,21812,21802,21841,21858,
21814,21813,21808,21842,21829,21772,21810,21861,21838,21817,21832,21805,21819,
21824,21835,22282,22279,22523,22548,22498,22518,22492,22516,22528,22509,22525,
22536,22520,22539,22515,22479,22535,22510,22499,22514,22501,22508,22497,22542,
22524,22544,22503,22529,22540,22513,22505,22512,22541,22532,22876,23136,23128,
23125,23143,23134,23096,23093,23149,23120,23135,23141,23148,23123,23140,23127,
23107,23133,23122,23108,23131,23112,23182,23102,23117,23097,23116,23152,23145,
23111,23121,23126,23106,23132,23410,23406,23489,23488,23641,23838,23819,23837,
23834,23840,23820,23848,23821,23846,23845,23823,23856,23826,23843,23839,23854,
24126,24116,24241,24244,24249,24242,24243,24374,24376,24475,24470,24479,24714,
24720,24710,24766,24752,24762,24787,24788,24783,24804,
24793,24797,24776,24753,24795,24759,24778,24767,24771,24781,24768,25394,25445,
25482,25474,25469,25533,25502,25517,25501,25495,25515,25486,25455,25479,25488,
25454,25519,25461,25500,25453,25518,25468,25508,25403,25503,25464,25477,25473,
25489,25485,25456,25939,26061,26213,26209,26203,26201,26204,26210,26392,26745,
26759,26768,26780,26733,26734,26798,26795,26966,26735,26787,26796,26793,26741,
26740,26802,26767,26743,26770,26748,26731,26738,26794,26752,26737,26750,26779,
26774,26763,26784,26761,26788,26744,26747,26769,26764,26762,26749,27446,27443,
27447,27448,27537,27535,27533,27534,27532,27690,28096,28075,28084,28083,28276,
28076,28137,28130,28087,28150,28116,28160,28104,28128,28127,28118,28094,28133,
28124,28125,28123,28148,28106,28093,28141,28144,28090,28117,28098,28111,28105,
28112,28146,28115,28157,28119,28109,28131,28091,28922,28941,28919,28951,28916,
28940,28912,28932,28915,28944,28924,28927,28934,28947,28928,28920,28918,28939,
28930,28942,29310,29307,29308,29311,29469,29463,29447,29457,29464,29450,29448,
29439,29455,29470,29576,29686,29688,29685,29700,29697,29693,29703,29696,29690,
29692,29695,29708,29707,29684,29704,30052,30051,30158,30162,30159,30155,30156,
30161,30160,30351,30345,30419,30521,30511,30509,30513,30514,30516,30515,30525,
30501,30523,30517,30792,30802,30793,30797,30794,30796,30758,30789,30800,31076,
31079,31081,31082,31075,31083,31073,31163,31226,31224,31222,31223,31375,31380,
31376,31541,31559,31540,31525,31536,31522,31524,31539,31512,31530,31517,31537,
31531,31533,31535,31538,31544,31514,31523,31892,31896,
31894,31907,32053,32061,32056,32054,32058,32069,32044,32041,32065,32071,32062,
32063,32074,32059,32040,32611,32661,32668,32669,32667,32714,32715,32717,32720,
32721,32711,32719,32713,32799,32798,32795,32839,32835,32840,33048,33061,33049,
33051,33069,33055,33068,33054,33057,33045,33063,33053,33058,33297,33336,33331,
33338,33332,33330,33396,33680,33699,33704,33677,33658,33651,33700,33652,33679,
33665,33685,33689,33653,33684,33705,33661,33667,33676,33693,33691,33706,33675,
33662,33701,33711,33672,33687,33712,33663,33702,33671,33710,33654,33690,34393,
34390,34495,34487,34498,34497,34501,34490,34480,34504,34489,34483,34488,34508,
34484,34491,34492,34499,34493,34494,34898,34953,34965,34984,34978,34986,34970,
34961,34977,34975,34968,34983,34969,34971,34967,34980,34988,34956,34963,34958,
35202,35286,35289,35285,35376,35367,35372,35358,35897,35899,35932,35933,35965,
36005,36221,36219,36217,36284,36290,36281,36287,36289,36568,36574,36573,36572,
36567,36576,36577,36900,36875,36881,36892,36876,36897,37103,37098,37104,37108,
37106,37107,37076,37099,37100,37097,37206,37208,37210,37203,37205,37356,37364,
37361,37363,37368,37348,37369,37354,37355,37367,37352,37358,38266,38278,38280,
38524,38509,38507,38513,38511,38591,38762,38916,39141,39319,20635,20629,20628,
20638,20619,20643,20611,20620,20622,20637,20584,20636,20626,20610,20615,20831,
20948,21266,21265,21412,21415,21905,21928,21925,21933,21879,22085,21922,21907,
21896,21903,21941,21889,21923,21906,21924,21885,21900,21926,21887,21909,21921,
21902,22284,22569,22583,22553,22558,22567,22563,22568,
22517,22600,22565,22556,22555,22579,22591,22582,22574,22585,22584,22573,22572,
22587,22881,23215,23188,23199,23162,23202,23198,23160,23206,23164,23205,23212,
23189,23214,23095,23172,23178,23191,23171,23179,23209,23163,23165,23180,23196,
23183,23187,23197,23530,23501,23499,23508,23505,23498,23502,23564,23600,23863,
23875,23915,23873,23883,23871,23861,23889,23886,23893,23859,23866,23890,23869,
23857,23897,23874,23865,23881,23864,23868,23858,23862,23872,23877,24132,24129,
24408,24486,24485,24491,24777,24761,24780,24802,24782,24772,24852,24818,24842,
24854,24837,24821,24851,24824,24828,24830,24769,24835,24856,24861,24848,24831,
24836,24843,25162,25492,25521,25520,25550,25573,25576,25583,25539,25757,25587,
25546,25568,25590,25557,25586,25589,25697,25567,25534,25565,25564,25540,25560,
25555,25538,25543,25548,25547,25544,25584,25559,25561,25906,25959,25962,25956,
25948,25960,25957,25996,26013,26014,26030,26064,26066,26236,26220,26235,26240,
26225,26233,26218,26226,26369,26892,26835,26884,26844,26922,26860,26858,26865,
26895,26838,26871,26859,26852,26870,26899,26896,26867,26849,26887,26828,26888,
26992,26804,26897,26863,26822,26900,26872,26832,26877,26876,26856,26891,26890,
26903,26830,26824,26845,26846,26854,26868,26833,26886,26836,26857,26901,26917,
26823,27449,27451,27455,27452,27540,27543,27545,27541,27581,27632,27634,27635,
27696,28156,28230,28231,28191,28233,28296,28220,28221,28229,28258,28203,28223,
28225,28253,28275,28188,28211,28235,28224,28241,28219,28163,28206,28254,28264,
28252,28257,28209,28200,28256,28273,28267,28217,28194,
28208,28243,28261,28199,28280,28260,28279,28245,28281,28242,28262,28213,28214,
28250,28960,28958,28975,28923,28974,28977,28963,28965,28962,28978,28959,28968,
28986,28955,29259,29274,29320,29321,29318,29317,29323,29458,29451,29488,29474,
29489,29491,29479,29490,29485,29478,29475,29493,29452,29742,29740,29744,29739,
29718,29722,29729,29741,29745,29732,29731,29725,29737,29728,29746,29947,29999,
30063,30060,30183,30170,30177,30182,30173,30175,30180,30167,30357,30354,30426,
30534,30535,30532,30541,30533,30538,30542,30539,30540,30686,30700,30816,30820,
30821,30812,30829,30833,30826,30830,30832,30825,30824,30814,30818,31092,31091,
31090,31088,31234,31242,31235,31244,31236,31385,31462,31460,31562,31547,31556,
31560,31564,31566,31552,31576,31557,31906,31902,31912,31905,32088,32111,32099,
32083,32086,32103,32106,32079,32109,32092,32107,32082,32084,32105,32081,32095,
32078,32574,32575,32613,32614,32674,32672,32673,32727,32849,32847,32848,33022,
32980,33091,33098,33106,33103,33095,33085,33101,33082,33254,33262,33271,33272,
33273,33284,33340,33341,33343,33397,33595,33743,33785,33827,33728,33768,33810,
33767,33764,33788,33782,33808,33734,33736,33771,33763,33727,33793,33757,33765,
33752,33791,33761,33739,33742,33750,33781,33737,33801,33807,33758,33809,33798,
33730,33779,33749,33786,33735,33745,33770,33811,33731,33772,33774,33732,33787,
33751,33762,33819,33755,33790,34520,34530,34534,34515,34531,34522,34538,34525,
34539,34524,34540,34537,34519,34536,34513,34888,34902,34901,35002,35031,35001,
35000,35008,35006,34998,35004,34999,35005,34994,35073,
35017,35221,35224,35223,35293,35290,35291,35406,35405,35385,35417,35392,35415,
35416,35396,35397,35410,35400,35409,35402,35404,35407,35935,35969,35968,36026,
36030,36016,36025,36021,36228,36224,36233,36312,36307,36301,36295,36310,36316,
36303,36309,36313,36296,36311,36293,36591,36599,36602,36601,36582,36590,36581,
36597,36583,36584,36598,36587,36593,36588,36596,36585,36909,36916,36911,37126,
37164,37124,37119,37116,37128,37113,37115,37121,37120,37127,37125,37123,37217,
37220,37215,37218,37216,37377,37386,37413,37379,37402,37414,37391,37388,37376,
37394,37375,37373,37382,37380,37415,37378,37404,37412,37401,37399,37381,37398,
38267,38285,38284,38288,38535,38526,38536,38537,38531,38528,38594,38600,38595,
38641,38640,38764,38768,38766,38919,39081,39147,40166,40697,20099,20100,20150,
20669,20671,20678,20654,20676,20682,20660,20680,20674,20656,20673,20666,20657,
20683,20681,20662,20664,20951,21114,21112,21115,21116,21955,21979,21964,21968,
21963,21962,21981,21952,21972,21956,21993,21951,21970,21901,21967,21973,21986,
21974,21960,22002,21965,21977,21954,22292,22611,22632,22628,22607,22605,22601,
22639,22613,22606,22621,22617,22629,22619,22589,22627,22641,22780,23239,23236,
23243,23226,23224,23217,23221,23216,23231,23240,23227,23238,23223,23232,23242,
23220,23222,23245,23225,23184,23510,23512,23513,23583,23603,23921,23907,23882,
23909,23922,23916,23902,23912,23911,23906,24048,24143,24142,24138,24141,24139,
24261,24268,24262,24267,24263,24384,24495,24493,24823,24905,24906,24875,24901,
24886,24882,24878,24902,24879,24911,24873,24896,25120,
37224,25123,25125,25124,25541,25585,25579,25616,25618,25609,25632,25636,25651,
25667,25631,25621,25624,25657,25655,25634,25635,25612,25638,25648,25640,25665,
25653,25647,25610,25626,25664,25637,25639,25611,25575,25627,25646,25633,25614,
25967,26002,26067,26246,26252,26261,26256,26251,26250,26265,26260,26232,26400,
26982,26975,26936,26958,26978,26993,26943,26949,26986,26937,26946,26967,26969,
27002,26952,26953,26933,26988,26931,26941,26981,26864,27000,26932,26985,26944,
26991,26948,26998,26968,26945,26996,26956,26939,26955,26935,26972,26959,26961,
26930,26962,26927,27003,26940,27462,27461,27459,27458,27464,27457,27547,64013,
27643,27644,27641,27639,27640,28315,28374,28360,28303,28352,28319,28307,28308,
28320,28337,28345,28358,28370,28349,28353,28318,28361,28343,28336,28365,28326,
28367,28338,28350,28355,28380,28376,28313,28306,28302,28301,28324,28321,28351,
28339,28368,28362,28311,28334,28323,28999,29012,29010,29027,29024,28993,29021,
29026,29042,29048,29034,29025,28994,29016,28995,29003,29040,29023,29008,29011,
28996,29005,29018,29263,29325,29324,29329,29328,29326,29500,29506,29499,29498,
29504,29514,29513,29764,29770,29771,29778,29777,29783,29760,29775,29776,29774,
29762,29766,29773,29780,29921,29951,29950,29949,29981,30073,30071,27011,30191,
30223,30211,30199,30206,30204,30201,30200,30224,30203,30198,30189,30197,30205,
30361,30389,30429,30549,30559,30560,30546,30550,30554,30569,30567,30548,30553,
30573,30688,30855,30874,30868,30863,30852,30869,30853,30854,30881,30851,30841,
30873,30848,30870,30843,31100,31106,31101,31097,31249,
31256,31257,31250,31255,31253,31266,31251,31259,31248,31395,31394,31390,31467,
31590,31588,31597,31604,31593,31602,31589,31603,31601,31600,31585,31608,31606,
31587,31922,31924,31919,32136,32134,32128,32141,32127,32133,32122,32142,32123,
32131,32124,32140,32148,32132,32125,32146,32621,32619,32615,32616,32620,32678,
32677,32679,32731,32732,32801,33124,33120,33143,33116,33129,33115,33122,33138,
26401,33118,33142,33127,33135,33092,33121,33309,33353,33348,33344,33346,33349,
34033,33855,33878,33910,33913,33935,33933,33893,33873,33856,33926,33895,33840,
33869,33917,33882,33881,33908,33907,33885,34055,33886,33847,33850,33844,33914,
33859,33912,33842,33861,33833,33753,33867,33839,33858,33837,33887,33904,33849,
33870,33868,33874,33903,33989,33934,33851,33863,33846,33843,33896,33918,33860,
33835,33888,33876,33902,33872,34571,34564,34551,34572,34554,34518,34549,34637,
34552,34574,34569,34561,34550,34573,34565,35030,35019,35021,35022,35038,35035,
35034,35020,35024,35205,35227,35295,35301,35300,35297,35296,35298,35292,35302,
35446,35462,35455,35425,35391,35447,35458,35460,35445,35459,35457,35444,35450,
35900,35915,35914,35941,35940,35942,35974,35972,35973,36044,36200,36201,36241,
36236,36238,36239,36237,36243,36244,36240,36242,36336,36320,36332,36337,36334,
36304,36329,36323,36322,36327,36338,36331,36340,36614,36607,36609,36608,36613,
36615,36616,36610,36619,36946,36927,36932,36937,36925,37136,37133,37135,37137,
37142,37140,37131,37134,37230,37231,37448,37458,37424,37434,37478,37427,37477,
37470,37507,37422,37450,37446,37485,37484,37455,37472,
37479,37487,37430,37473,37488,37425,37460,37475,37456,37490,37454,37459,37452,
37462,37426,38303,38300,38302,38299,38546,38547,38545,38551,38606,38650,38653,
38648,38645,38771,38775,38776,38770,38927,38925,38926,39084,39158,39161,39343,
39346,39344,39349,39597,39595,39771,40170,40173,40167,40576,40701,20710,20692,
20695,20712,20723,20699,20714,20701,20708,20691,20716,20720,20719,20707,20704,
20952,21120,21121,21225,21227,21296,21420,22055,22037,22028,22034,22012,22031,
22044,22017,22035,22018,22010,22045,22020,22015,22009,22665,22652,22672,22680,
22662,22657,22655,22644,22667,22650,22663,22673,22670,22646,22658,22664,22651,
22676,22671,22782,22891,23260,23278,23269,23253,23274,23258,23277,23275,23283,
23266,23264,23259,23276,23262,23261,23257,23272,23263,23415,23520,23523,23651,
23938,23936,23933,23942,23930,23937,23927,23946,23945,23944,23934,23932,23949,
23929,23935,24152,24153,24147,24280,24273,24279,24270,24284,24277,24281,24274,
24276,24388,24387,24431,24502,24876,24872,24897,24926,24945,24947,24914,24915,
24946,24940,24960,24948,24916,24954,24923,24933,24891,24938,24929,24918,25129,
25127,25131,25643,25677,25691,25693,25716,25718,25714,25715,25725,25717,25702,
25766,25678,25730,25694,25692,25675,25683,25696,25680,25727,25663,25708,25707,
25689,25701,25719,25971,26016,26273,26272,26271,26373,26372,26402,27057,27062,
27081,27040,27086,27030,27056,27052,27068,27025,27033,27022,27047,27021,27049,
27070,27055,27071,27076,27069,27044,27092,27065,27082,27034,27087,27059,27027,
27050,27041,27038,27097,27031,27024,27074,27061,27045,
27078,27466,27469,27467,27550,27551,27552,27587,27588,27646,28366,28405,28401,
28419,28453,28408,28471,28411,28462,28425,28494,28441,28442,28455,28440,28475,
28434,28397,28426,28470,28531,28409,28398,28461,28480,28464,28476,28469,28395,
28423,28430,28483,28421,28413,28406,28473,28444,28412,28474,28447,28429,28446,
28424,28449,29063,29072,29065,29056,29061,29058,29071,29051,29062,29057,29079,
29252,29267,29335,29333,29331,29507,29517,29521,29516,29794,29811,29809,29813,
29810,29799,29806,29952,29954,29955,30077,30096,30230,30216,30220,30229,30225,
30218,30228,30392,30593,30588,30597,30594,30574,30592,30575,30590,30595,30898,
30890,30900,30893,30888,30846,30891,30878,30885,30880,30892,30882,30884,31128,
31114,31115,31126,31125,31124,31123,31127,31112,31122,31120,31275,31306,31280,
31279,31272,31270,31400,31403,31404,31470,31624,31644,31626,31633,31632,31638,
31629,31628,31643,31630,31621,31640,21124,31641,31652,31618,31931,31935,31932,
31930,32167,32183,32194,32163,32170,32193,32192,32197,32157,32206,32196,32198,
32203,32204,32175,32185,32150,32188,32159,32166,32174,32169,32161,32201,32627,
32738,32739,32741,32734,32804,32861,32860,33161,33158,33155,33159,33165,33164,
33163,33301,33943,33956,33953,33951,33978,33998,33986,33964,33966,33963,33977,
33972,33985,33997,33962,33946,33969,34000,33949,33959,33979,33954,33940,33991,
33996,33947,33961,33967,33960,34006,33944,33974,33999,33952,34007,34004,34002,
34011,33968,33937,34401,34611,34595,34600,34667,34624,34606,34590,34593,34585,
34587,34627,34604,34625,34622,34630,34592,34610,34602,
34605,34620,34578,34618,34609,34613,34626,34598,34599,34616,34596,34586,34608,
34577,35063,35047,35057,35058,35066,35070,35054,35068,35062,35067,35056,35052,
35051,35229,35233,35231,35230,35305,35307,35304,35499,35481,35467,35474,35471,
35478,35901,35944,35945,36053,36047,36055,36246,36361,36354,36351,36365,36349,
36362,36355,36359,36358,36357,36350,36352,36356,36624,36625,36622,36621,37155,
37148,37152,37154,37151,37149,37146,37156,37153,37147,37242,37234,37241,37235,
37541,37540,37494,37531,37498,37536,37524,37546,37517,37542,37530,37547,37497,
37527,37503,37539,37614,37518,37506,37525,37538,37501,37512,37537,37514,37510,
37516,37529,37543,37502,37511,37545,37533,37515,37421,38558,38561,38655,38744,
38781,38778,38782,38787,38784,38786,38779,38788,38785,38783,38862,38861,38934,
39085,39086,39170,39168,39175,39325,39324,39363,39353,39355,39354,39362,39357,
39367,39601,39651,39655,39742,39743,39776,39777,39775,40177,40178,40181,40615,
20735,20739,20784,20728,20742,20743,20726,20734,20747,20748,20733,20746,21131,
21132,21233,21231,22088,22082,22092,22069,22081,22090,22089,22086,22104,22106,
22080,22067,22077,22060,22078,22072,22058,22074,22298,22699,22685,22705,22688,
22691,22703,22700,22693,22689,22783,23295,23284,23293,23287,23286,23299,23288,
23298,23289,23297,23303,23301,23311,23655,23961,23959,23967,23954,23970,23955,
23957,23968,23964,23969,23962,23966,24169,24157,24160,24156,32243,24283,24286,
24289,24393,24498,24971,24963,24953,25009,25008,24994,24969,24987,24979,25007,
25005,24991,24978,25002,24993,24973,24934,25011,25133,
25710,25712,25750,25760,25733,25751,25756,25743,25739,25738,25740,25763,25759,
25704,25777,25752,25974,25978,25977,25979,26034,26035,26293,26288,26281,26290,
26295,26282,26287,27136,27142,27159,27109,27128,27157,27121,27108,27168,27135,
27116,27106,27163,27165,27134,27175,27122,27118,27156,27127,27111,27200,27144,
27110,27131,27149,27132,27115,27145,27140,27160,27173,27151,27126,27174,27143,
27124,27158,27473,27557,27555,27554,27558,27649,27648,27647,27650,28481,28454,
28542,28551,28614,28562,28557,28553,28556,28514,28495,28549,28506,28566,28534,
28524,28546,28501,28530,28498,28496,28503,28564,28563,28509,28416,28513,28523,
28541,28519,28560,28499,28555,28521,28543,28565,28515,28535,28522,28539,29106,
29103,29083,29104,29088,29082,29097,29109,29085,29093,29086,29092,29089,29098,
29084,29095,29107,29336,29338,29528,29522,29534,29535,29536,29533,29531,29537,
29530,29529,29538,29831,29833,29834,29830,29825,29821,29829,29832,29820,29817,
29960,29959,30078,30245,30238,30233,30237,30236,30243,30234,30248,30235,30364,
30365,30366,30363,30605,30607,30601,30600,30925,30907,30927,30924,30929,30926,
30932,30920,30915,30916,30921,31130,31137,31136,31132,31138,31131,27510,31289,
31410,31412,31411,31671,31691,31678,31660,31694,31663,31673,31690,31669,31941,
31944,31948,31947,32247,32219,32234,32231,32215,32225,32259,32250,32230,32246,
32241,32240,32238,32223,32630,32684,32688,32685,32749,32747,32746,32748,32742,
32744,32868,32871,33187,33183,33182,33173,33186,33177,33175,33302,33359,33363,
33362,33360,33358,33361,34084,34107,34063,34048,34089,
34062,34057,34061,34079,34058,34087,34076,34043,34091,34042,34056,34060,34036,
34090,34034,34069,34039,34027,34035,34044,34066,34026,34025,34070,34046,34088,
34077,34094,34050,34045,34078,34038,34097,34086,34023,34024,34032,34031,34041,
34072,34080,34096,34059,34073,34095,34402,34646,34659,34660,34679,34785,34675,
34648,34644,34651,34642,34657,34650,34641,34654,34669,34666,34640,34638,34655,
34653,34671,34668,34682,34670,34652,34661,34639,34683,34677,34658,34663,34665,
34906,35077,35084,35092,35083,35095,35096,35097,35078,35094,35089,35086,35081,
35234,35236,35235,35309,35312,35308,35535,35526,35512,35539,35537,35540,35541,
35515,35543,35518,35520,35525,35544,35523,35514,35517,35545,35902,35917,35983,
36069,36063,36057,36072,36058,36061,36071,36256,36252,36257,36251,36384,36387,
36389,36388,36398,36373,36379,36374,36369,36377,36390,36391,36372,36370,36376,
36371,36380,36375,36378,36652,36644,36632,36634,36640,36643,36630,36631,36979,
36976,36975,36967,36971,37167,37163,37161,37162,37170,37158,37166,37253,37254,
37258,37249,37250,37252,37248,37584,37571,37572,37568,37593,37558,37583,37617,
37599,37592,37609,37591,37597,37580,37615,37570,37608,37578,37576,37582,37606,
37581,37589,37577,37600,37598,37607,37585,37587,37557,37601,37574,37556,38268,
38316,38315,38318,38320,38564,38562,38611,38661,38664,38658,38746,38794,38798,
38792,38864,38863,38942,38941,38950,38953,38952,38944,38939,38951,39090,39176,
39162,39185,39188,39190,39191,39189,39388,39373,39375,39379,39380,39374,39369,
39382,39384,39371,39383,39372,39603,39660,39659,39667,
39666,39665,39750,39747,39783,39796,39793,39782,39798,39797,39792,39784,39780,
39788,40188,40186,40189,40191,40183,40199,40192,40185,40187,40200,40197,40196,
40579,40659,40719,40720,20764,20755,20759,20762,20753,20958,21300,21473,22128,
22112,22126,22131,22118,22115,22125,22130,22110,22135,22300,22299,22728,22717,
22729,22719,22714,22722,22716,22726,23319,23321,23323,23329,23316,23315,23312,
23318,23336,23322,23328,23326,23535,23980,23985,23977,23975,23989,23984,23982,
23978,23976,23986,23981,23983,23988,24167,24168,24166,24175,24297,24295,24294,
24296,24293,24395,24508,24989,25000,24982,25029,25012,25030,25025,25036,25018,
25023,25016,24972,25815,25814,25808,25807,25801,25789,25737,25795,25819,25843,
25817,25907,25983,25980,26018,26312,26302,26304,26314,26315,26319,26301,26299,
26298,26316,26403,27188,27238,27209,27239,27186,27240,27198,27229,27245,27254,
27227,27217,27176,27226,27195,27199,27201,27242,27236,27216,27215,27220,27247,
27241,27232,27196,27230,27222,27221,27213,27214,27206,27477,27476,27478,27559,
27562,27563,27592,27591,27652,27651,27654,28589,28619,28579,28615,28604,28622,
28616,28510,28612,28605,28574,28618,28584,28676,28581,28590,28602,28588,28586,
28623,28607,28600,28578,28617,28587,28621,28591,28594,28592,29125,29122,29119,
29112,29142,29120,29121,29131,29140,29130,29127,29135,29117,29144,29116,29126,
29146,29147,29341,29342,29545,29542,29543,29548,29541,29547,29546,29823,29850,
29856,29844,29842,29845,29857,29963,30080,30255,30253,30257,30269,30259,30268,
30261,30258,30256,30395,30438,30618,30621,30625,30620,
30619,30626,30627,30613,30617,30615,30941,30953,30949,30954,30942,30947,30939,
30945,30946,30957,30943,30944,31140,31300,31304,31303,31414,31416,31413,31409,
31415,31710,31715,31719,31709,31701,31717,31706,31720,31737,31700,31722,31714,
31708,31723,31704,31711,31954,31956,31959,31952,31953,32274,32289,32279,32268,
32287,32288,32275,32270,32284,32277,32282,32290,32267,32271,32278,32269,32276,
32293,32292,32579,32635,32636,32634,32689,32751,32810,32809,32876,33201,33190,
33198,33209,33205,33195,33200,33196,33204,33202,33207,33191,33266,33365,33366,
33367,34134,34117,34155,34125,34131,34145,34136,34112,34118,34148,34113,34146,
34116,34129,34119,34147,34110,34139,34161,34126,34158,34165,34133,34151,34144,
34188,34150,34141,34132,34149,34156,34403,34405,34404,34715,34703,34711,34707,
34706,34696,34689,34710,34712,34681,34695,34723,34693,34704,34705,34717,34692,
34708,34716,34714,34697,35102,35110,35120,35117,35118,35111,35121,35106,35113,
35107,35119,35116,35103,35313,35552,35554,35570,35572,35573,35549,35604,35556,
35551,35568,35528,35550,35553,35560,35583,35567,35579,35985,35986,35984,36085,
36078,36081,36080,36083,36204,36206,36261,36263,36403,36414,36408,36416,36421,
36406,36412,36413,36417,36400,36415,36541,36662,36654,36661,36658,36665,36663,
36660,36982,36985,36987,36998,37114,37171,37173,37174,37267,37264,37265,37261,
37263,37671,37662,37640,37663,37638,37647,37754,37688,37692,37659,37667,37650,
37633,37702,37677,37646,37645,37579,37661,37626,37669,37651,37625,37623,37684,
37634,37668,37631,37673,37689,37685,37674,37652,37644,
37643,37630,37641,37632,37627,37654,38332,38349,38334,38329,38330,38326,38335,
38325,38333,38569,38612,38667,38674,38672,38809,38807,38804,38896,38904,38965,
38959,38962,39204,39199,39207,39209,39326,39406,39404,39397,39396,39408,39395,
39402,39401,39399,39609,39615,39604,39611,39670,39674,39673,39671,39731,39808,
39813,39815,39804,39806,39803,39810,39827,39826,39824,39802,39829,39805,39816,
40229,40215,40224,40222,40212,40233,40221,40216,40226,40208,40217,40223,40584,
40582,40583,40622,40621,40661,40662,40698,40722,40765,20774,20773,20770,20772,
20768,20777,21236,22163,22156,22157,22150,22148,22147,22142,22146,22143,22145,
22742,22740,22735,22738,23341,23333,23346,23331,23340,23335,23334,23343,23342,
23419,23537,23538,23991,24172,24170,24510,24507,25027,25013,25020,25063,25056,
25061,25060,25064,25054,25839,25833,25827,25835,25828,25832,25985,25984,26038,
26074,26322,27277,27286,27265,27301,27273,27295,27291,27297,27294,27271,27283,
27278,27285,27267,27304,27300,27281,27263,27302,27290,27269,27276,27282,27483,
27565,27657,28620,28585,28660,28628,28643,28636,28653,28647,28646,28638,28658,
28637,28642,28648,29153,29169,29160,29170,29156,29168,29154,29555,29550,29551,
29847,29874,29867,29840,29866,29869,29873,29861,29871,29968,29969,29970,29967,
30084,30275,30280,30281,30279,30372,30441,30645,30635,30642,30647,30646,30644,
30641,30632,30704,30963,30973,30978,30971,30972,30962,30981,30969,30974,30980,
31147,31144,31324,31323,31318,31320,31316,31322,31422,31424,31425,31749,31759,
31730,31744,31743,31739,31758,31732,31755,31731,31746,
31753,31747,31745,31736,31741,31750,31728,31729,31760,31754,31976,32301,32316,
32322,32307,38984,32312,32298,32329,32320,32327,32297,32332,32304,32315,32310,
32324,32314,32581,32639,32638,32637,32756,32754,32812,33211,33220,33228,33226,
33221,33223,33212,33257,33371,33370,33372,34179,34176,34191,34215,34197,34208,
34187,34211,34171,34212,34202,34206,34167,34172,34185,34209,34170,34168,34135,
34190,34198,34182,34189,34201,34205,34177,34210,34178,34184,34181,34169,34166,
34200,34192,34207,34408,34750,34730,34733,34757,34736,34732,34745,34741,34748,
34734,34761,34755,34754,34764,34743,34735,34756,34762,34740,34742,34751,34744,
34749,34782,34738,35125,35123,35132,35134,35137,35154,35127,35138,35245,35247,
35246,35314,35315,35614,35608,35606,35601,35589,35595,35618,35599,35602,35605,
35591,35597,35592,35590,35612,35603,35610,35919,35952,35954,35953,35951,35989,
35988,36089,36207,36430,36429,36435,36432,36428,36423,36675,36672,36997,36990,
37176,37274,37282,37275,37273,37279,37281,37277,37280,37793,37763,37807,37732,
37718,37703,37756,37720,37724,37750,37705,37712,37713,37728,37741,37775,37708,
37738,37753,37719,37717,37714,37711,37745,37751,37755,37729,37726,37731,37735,
37760,37710,37721,38343,38336,38345,38339,38341,38327,38574,38576,38572,38688,
38687,38680,38685,38681,38810,38817,38812,38814,38813,38869,38868,38897,38977,
38980,38986,38985,38981,38979,39205,39211,39212,39210,39219,39218,39215,39213,
39217,39216,39320,39331,39329,39426,39418,39412,39415,39417,39416,39414,39419,
39421,39422,39420,39427,39614,39678,39677,39681,39676,
39752,39834,39848,39838,39835,39846,39841,39845,39844,39814,39842,39840,39855,
40243,40257,40295,40246,40238,40239,40241,40248,40240,40261,40258,40259,40254,
40247,40256,40253,32757,40237,40586,40585,40589,40624,40648,40666,40699,40703,
40740,40739,40738,40788,40864,20785,20781,20782,22168,22172,22167,22170,22173,
22169,22896,23356,23657,23658,24000,24173,24174,25048,25055,25069,25070,25073,
25066,25072,25067,25046,25065,25855,25860,25853,25848,25857,25859,25852,26004,
26075,26330,26331,26328,27333,27321,27325,27361,27334,27322,27318,27319,27335,
27316,27309,27486,27593,27659,28679,28684,28685,28673,28677,28692,28686,28671,
28672,28667,28710,28668,28663,28682,29185,29183,29177,29187,29181,29558,29880,
29888,29877,29889,29886,29878,29883,29890,29972,29971,30300,30308,30297,30288,
30291,30295,30298,30374,30397,30444,30658,30650,30975,30988,30995,30996,30985,
30992,30994,30993,31149,31148,31327,31772,31785,31769,31776,31775,31789,31773,
31782,31784,31778,31781,31792,32348,32336,32342,32355,32344,32354,32351,32337,
32352,32343,32339,32693,32691,32759,32760,32885,33233,33234,33232,33375,33374,
34228,34246,34240,34243,34242,34227,34229,34237,34247,34244,34239,34251,34254,
34248,34245,34225,34230,34258,34340,34232,34231,34238,34409,34791,34790,34786,
34779,34795,34794,34789,34783,34803,34788,34772,34780,34771,34797,34776,34787,
34724,34775,34777,34817,34804,34792,34781,35155,35147,35151,35148,35142,35152,
35153,35145,35626,35623,35619,35635,35632,35637,35655,35631,35644,35646,35633,
35621,35639,35622,35638,35630,35620,35643,35645,35642,
35906,35957,35993,35992,35991,36094,36100,36098,36096,36444,36450,36448,36439,
36438,36446,36453,36455,36443,36442,36449,36445,36457,36436,36678,36679,36680,
36683,37160,37178,37179,37182,37288,37285,37287,37295,37290,37813,37772,37778,
37815,37787,37789,37769,37799,37774,37802,37790,37798,37781,37768,37785,37791,
37773,37809,37777,37810,37796,37800,37812,37795,37797,38354,38355,38353,38579,
38615,38618,24002,38623,38616,38621,38691,38690,38693,38828,38830,38824,38827,
38820,38826,38818,38821,38871,38873,38870,38872,38906,38992,38993,38994,39096,
39233,39228,39226,39439,39435,39433,39437,39428,39441,39434,39429,39431,39430,
39616,39644,39688,39684,39685,39721,39733,39754,39756,39755,39879,39878,39875,
39871,39873,39861,39864,39891,39862,39876,39865,39869,40284,40275,40271,40266,
40283,40267,40281,40278,40268,40279,40274,40276,40287,40280,40282,40590,40588,
40671,40705,40704,40726,40741,40747,40746,40745,40744,40780,40789,20788,20789,
21142,21239,21428,22187,22189,22182,22183,22186,22188,22746,22749,22747,22802,
23357,23358,23359,24003,24176,24511,25083,25863,25872,25869,25865,25868,25870,
25988,26078,26077,26334,27367,27360,27340,27345,27353,27339,27359,27356,27344,
27371,27343,27341,27358,27488,27568,27660,28697,28711,28704,28694,28715,28705,
28706,28707,28713,28695,28708,28700,28714,29196,29194,29191,29186,29189,29349,
29350,29348,29347,29345,29899,29893,29879,29891,29974,30304,30665,30666,30660,
30705,31005,31003,31009,31004,30999,31006,31152,31335,31336,31795,31804,31801,
31788,31803,31980,31978,32374,32373,32376,32368,32375,
32367,32378,32370,32372,32360,32587,32586,32643,32646,32695,32765,32766,32888,
33239,33237,33380,33377,33379,34283,34289,34285,34265,34273,34280,34266,34263,
34284,34290,34296,34264,34271,34275,34268,34257,34288,34278,34287,34270,34274,
34816,34810,34819,34806,34807,34825,34828,34827,34822,34812,34824,34815,34826,
34818,35170,35162,35163,35159,35169,35164,35160,35165,35161,35208,35255,35254,
35318,35664,35656,35658,35648,35667,35670,35668,35659,35669,35665,35650,35666,
35671,35907,35959,35958,35994,36102,36103,36105,36268,36266,36269,36267,36461,
36472,36467,36458,36463,36475,36546,36690,36689,36687,36688,36691,36788,37184,
37183,37296,37293,37854,37831,37839,37826,37850,37840,37881,37868,37836,37849,
37801,37862,37834,37844,37870,37859,37845,37828,37838,37824,37842,37863,38269,
38362,38363,38625,38697,38699,38700,38696,38694,38835,38839,38838,38877,38878,
38879,39004,39001,39005,38999,39103,39101,39099,39102,39240,39239,39235,39334,
39335,39450,39445,39461,39453,39460,39451,39458,39456,39463,39459,39454,39452,
39444,39618,39691,39690,39694,39692,39735,39914,39915,39904,39902,39908,39910,
39906,39920,39892,39895,39916,39900,39897,39909,39893,39905,39898,40311,40321,
40330,40324,40328,40305,40320,40312,40326,40331,40332,40317,40299,40308,40309,
40304,40297,40325,40307,40315,40322,40303,40313,40319,40327,40296,40596,40593,
40640,40700,40749,40768,40769,40781,40790,40791,40792,21303,22194,22197,22195,
22755,23365,24006,24007,24302,24303,24512,24513,25081,25879,25878,25877,25875,
26079,26344,26339,26340,27379,27376,27370,27368,27385,
27377,27374,27375,28732,28725,28719,28727,28724,28721,28738,28728,28735,28730,
28729,28736,28731,28723,28737,29203,29204,29352,29565,29564,29882,30379,30378,
30398,30445,30668,30670,30671,30669,30706,31013,31011,31015,31016,31012,31017,
31154,31342,31340,31341,31479,31817,31816,31818,31815,31813,31982,32379,32382,
32385,32384,32698,32767,32889,33243,33241,33291,33384,33385,34338,34303,34305,
34302,34331,34304,34294,34308,34313,34309,34316,34301,34841,34832,34833,34839,
34835,34838,35171,35174,35257,35319,35680,35690,35677,35688,35683,35685,35687,
35693,36270,36486,36488,36484,36697,36694,36695,36693,36696,36698,37005,37187,
37185,37303,37301,37298,37299,37899,37907,37883,37920,37903,37908,37886,37909,
37904,37928,37913,37901,37877,37888,37879,37895,37902,37910,37906,37882,37897,
37880,37898,37887,37884,37900,37878,37905,37894,38366,38368,38367,38702,38703,
38841,38843,38909,38910,39008,39010,39011,39007,39105,39106,39248,39246,39257,
39244,39243,39251,39474,39476,39473,39468,39466,39478,39465,39470,39480,39469,
39623,39626,39622,39696,39698,39697,39947,39944,39927,39941,39954,39928,40000,
39943,39950,39942,39959,39956,39945,40351,40345,40356,40349,40338,40344,40336,
40347,40352,40340,40348,40362,40343,40353,40346,40354,40360,40350,40355,40383,
40361,40342,40358,40359,40601,40603,40602,40677,40676,40679,40678,40752,40750,
40795,40800,40798,40797,40793,40849,20794,20793,21144,21143,22211,22205,22206,
23368,23367,24011,24015,24305,25085,25883,27394,27388,27395,27384,27392,28739,
28740,28746,28744,28745,28741,28742,29213,29210,29209,
29566,29975,30314,30672,31021,31025,31023,31828,31827,31986,32394,32391,32392,
32395,32390,32397,32589,32699,32816,33245,34328,34346,34342,34335,34339,34332,
34329,34343,34350,34337,34336,34345,34334,34341,34857,34845,34843,34848,34852,
34844,34859,34890,35181,35177,35182,35179,35322,35705,35704,35653,35706,35707,
36112,36116,36271,36494,36492,36702,36699,36701,37190,37188,37189,37305,37951,
37947,37942,37929,37949,37948,37936,37945,37930,37943,37932,37952,37937,38373,
38372,38371,38709,38714,38847,38881,39012,39113,39110,39104,39256,39254,39481,
39485,39494,39492,39490,39489,39482,39487,39629,39701,39703,39704,39702,39738,
39762,39979,39965,39964,39980,39971,39976,39977,39972,39969,40375,40374,40380,
40385,40391,40394,40399,40382,40389,40387,40379,40373,40398,40377,40378,40364,
40392,40369,40365,40396,40371,40397,40370,40570,40604,40683,40686,40685,40731,
40728,40730,40753,40782,40805,40804,40850,20153,22214,22213,22219,22897,23371,
23372,24021,24017,24306,25889,25888,25894,25890,27403,27400,27401,27661,28757,
28758,28759,28754,29214,29215,29353,29567,29912,29909,29913,29911,30317,30381,
31029,31156,31344,31345,31831,31836,31833,31835,31834,31988,31985,32401,32591,
32647,33246,33387,34356,34357,34355,34348,34354,34358,34860,34856,34854,34858,
34853,35185,35263,35262,35323,35710,35716,35714,35718,35717,35711,36117,36501,
36500,36506,36498,36496,36502,36503,36704,36706,37191,37964,37968,37962,37963,
37967,37959,37957,37960,37961,37958,38719,38883,39018,39017,39115,39252,39259,
39502,39507,39508,39500,39503,39496,39498,39497,39506,
39504,39632,39705,39723,39739,39766,39765,40006,40008,39999,40004,39993,39987,
40001,39996,39991,39988,39986,39997,39990,40411,40402,40414,40410,40395,40400,
40412,40401,40415,40425,40409,40408,40406,40437,40405,40413,40630,40688,40757,
40755,40754,40770,40811,40853,40866,20797,21145,22760,22759,22898,23373,24024,
34863,24399,25089,25091,25092,25897,25893,26006,26347,27409,27410,27407,27594,
28763,28762,29218,29570,29569,29571,30320,30676,31847,31846,32405,33388,34362,
34368,34361,34364,34353,34363,34366,34864,34866,34862,34867,35190,35188,35187,
35326,35724,35726,35723,35720,35909,36121,36504,36708,36707,37308,37986,37973,
37981,37975,37982,38852,38853,38912,39510,39513,39710,39711,39712,40018,40024,
40016,40010,40013,40011,40021,40025,40012,40014,40443,40439,40431,40419,40427,
40440,40420,40438,40417,40430,40422,40434,40432,40418,40428,40436,40435,40424,
40429,40642,40656,40690,40691,40710,40732,40760,40759,40758,40771,40783,40817,
40816,40814,40815,22227,22221,23374,23661,25901,26349,26350,27411,28767,28769,
28765,28768,29219,29915,29925,30677,31032,31159,31158,31850,32407,32649,33389,
34371,34872,34871,34869,34891,35732,35733,36510,36511,36512,36509,37310,37309,
37314,37995,37992,37993,38629,38726,38723,38727,38855,38885,39518,39637,39769,
40035,40039,40038,40034,40030,40032,40450,40446,40455,40451,40454,40453,40448,
40449,40457,40447,40445,40452,40608,40734,40774,40820,40821,40822,22228,25902,
26040,27416,27417,27415,27418,28770,29222,29354,30680,30681,31033,31849,31851,
31990,32410,32408,32411,32409,33248,33249,34374,34375,
34376,35193,35194,35196,35195,35327,35736,35737,36517,36516,36515,37998,37997,
37999,38001,38003,38729,39026,39263,40040,40046,40045,40459,40461,40464,40463,
40466,40465,40609,40693,40713,40775,40824,40827,40826,40825,22302,28774,31855,
34876,36274,36518,37315,38004,38008,38006,38005,39520,40052,40051,40049,40053,
40468,40467,40694,40714,40868,28776,28773,31991,34410,34878,34877,34879,35742,
35996,36521,36553,38731,39027,39028,39116,39265,39339,39524,39526,39527,39716,
40469,40471,40776,25095,27422,29223,34380,36520,38018,38016,38017,39529,39528,
39726,40473,29225,34379,35743,38019,40057,40631,30325,39531,40058,40477,28777,
28778,40612,40830,40777,40856,30849,37561,35023,22715,24658,31911,23290,9556,
9574,9559,9568,9580,9571,9562,9577,9565,9554,9572,9557,9566,9578,9569,9560,
9575,9563,9555,9573,9558,9567,9579,9570,9561,9576,9564,9553,9552,9581,9582,
9584,9583,9619,
| 84,194 | 1,086 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/appendz.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/assert.h"
#include "libc/dce.h"
#include "libc/mem/mem.h"
#include "libc/stdio/append.h"
#define W sizeof(size_t)
/**
* Returns size of append buffer.
*
* @param p must be 0 or have been allocated by an append*() function
* @return i is number of bytes stored in buffer
* @return n is number of bytes in allocation
*/
struct appendz appendz(char *p) {
struct appendz z;
if (p) {
z.n = malloc_usable_size(p);
_unassert(z.n >= W * 2 && !(z.n & (W - 1)));
z.i = *(size_t *)(p + z.n - W);
if (!IsTiny() && W == 8) {
/*
* This check should fail if an append*() function was passed a
* pointer that was allocated manually by malloc(). Append ptrs
* can be free()'d safely, but they need to be allocated by the
* append library, because we write a special value to the end.
*/
_unassert((z.i >> 48) == APPEND_COOKIE);
z.i &= 0x0000ffffffffffff;
}
_unassert(z.n >= z.i);
} else {
z.i = 0;
z.n = 0;
}
return z;
}
| 2,858 | 56 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fgetws_unlocked.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/errno.h"
#include "libc/stdio/stdio.h"
/**
* Reads UTF-8 content from stream into UTF-32 buffer.
*
* This function is similar to getline() except it'll truncate lines
* exceeding size. The line ending marker is included and may be removed
* using _chomp().
*
* @param s is is nul-terminated string that's non-null
* @param size is byte length of `s`
* @param f is file stream object pointer
* @see fgetws()
*/
wchar_t *fgetws_unlocked(wchar_t *s, int size, FILE *f) {
wint_t c;
wchar_t *p = s;
if (size > 0) {
while (--size > 0) {
if ((c = fgetwc_unlocked(f)) == -1) {
if (ferror_unlocked(f) == EINTR) continue;
break;
}
*p++ = c;
if (c == '\n') break;
}
*p = '\0';
}
return (intptr_t)p > (intptr_t)s ? s : NULL;
}
| 2,665 | 51 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fseeko_unlocked.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/errno.h"
#include "libc/stdio/internal.h"
#include "libc/stdio/stdio.h"
#include "libc/sysv/consts/o.h"
/**
* Repositions open file stream.
*
* This function flushes the buffer (unless it's currently in the EOF
* state) and then calls lseek() on the underlying file. If the stream
* is in the EOF state, this function can be used to restore it without
* needing to reopen the file.
*
* @param f is a non-null stream handle
* @param offset is the byte delta
* @param whence can be SEET_SET, SEEK_CUR, or SEEK_END
* @returns 0 on success or -1 on error
*/
int fseeko_unlocked(FILE *f, int64_t offset, int whence) {
int res;
ssize_t rc;
int64_t pos;
if (f->fd != -1) {
if (__fflush_impl(f) == -1) return -1;
if (whence == SEEK_CUR && f->beg < f->end) {
offset -= f->end - f->beg;
}
if (lseek(f->fd, offset, whence) != -1) {
f->beg = 0;
f->end = 0;
f->state = 0;
res = 0;
} else {
f->state = errno == ESPIPE ? EBADF : errno;
res = -1;
}
} else {
switch (whence) {
case SEEK_SET:
pos = offset;
break;
case SEEK_CUR:
pos = f->beg + offset;
break;
case SEEK_END:
pos = f->end + offset;
break;
default:
pos = -1;
break;
}
if (0 <= pos && pos <= f->end) {
f->beg = pos;
f->state = 0;
res = 0;
} else {
f->state = errno = EINVAL;
res = -1;
}
}
return res;
}
| 3,360 | 82 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/getdelim_unlocked.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/errno.h"
#include "libc/mem/mem.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/o.h"
/**
* Reads string from unlocked stream.
* @see getdelim() for documentation
*/
ssize_t getdelim_unlocked(char **s, size_t *n, int delim, FILE *f) {
ssize_t rc;
char *p, *s2;
size_t i, m, n2;
if ((f->iomode & O_ACCMODE) == O_WRONLY) {
f->state = errno = EBADF;
return -1;
}
if (f->beg > f->end) {
f->state = errno = EINVAL;
return -1;
}
if (!*s) *n = 0;
for (i = 0;; i += m) {
m = f->end - f->beg;
if ((p = memchr(f->buf + f->beg, delim, m))) {
m = p + 1 - (f->buf + f->beg);
}
if (i + m + 1 > *n) {
n2 = i + m + 1;
s2 = realloc(*s, n2);
if (s2) {
*s = s2;
*n = n2;
} else {
f->state = errno;
return -1;
}
}
memcpy(*s + i, f->buf + f->beg, m);
(*s)[i + m] = '\0';
if ((f->beg += m) == f->end) {
f->beg = f->end = 0;
}
if (p) {
return i + m;
} else if (f->fd == -1) {
break;
} else if ((rc = read(f->fd, f->buf, f->size)) != -1) {
if (!rc) break;
f->end = rc;
} else if (errno != EINTR) {
f->state = errno;
return -1;
}
}
f->state = -1;
if (i + m) {
return i + m;
} else {
return -1;
}
}
| 3,213 | 83 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/flushlbf.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/stdio/fflush.internal.h"
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h"
#include "libc/stdio/stdio_ext.h"
/**
* Flushes all line-buffered streams.
*/
void _flushlbf(void) {
int i;
FILE *f;
__fflush_lock();
for (i = 0; i < __fflush.handles.i; ++i) {
if ((f = __fflush.handles.p[i])) {
flockfile(f);
if (f->bufmode == _IOLBF) {
fflush_unlocked(f);
}
funlockfile(f);
}
}
__fflush_unlock();
}
| 2,346 | 43 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/lemur64.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/stdio/rand.h"
/**
* Returns linear congruential deterministic pseudorandom data, e.g.
*
* uint64_t x = lemur64();
*
* You can generate different types of numbers as follows:
*
* int64_t x = lemur64() >> 1; // make positive signed integer
* double x = _real1(lemur64()); // make float on [0,1]-interval
*
* If you want a fast pseudorandom number generator that seeds itself
* automatically on startup and fork(), then consider _rand64. If you
* want true random data then consider rdseed, rdrand, and getrandom.
*
* @return 64 bits of pseudorandom data
* @note this is Lemire's Lehmer generator
* @note this function takes at minimum 1 cycle
* @note this function passes bigcrush and practrand
* @note this function is not intended for cryptography
* @see _rand64(), rngset(), _real1(), _real2(), _real3()
*/
uint64_t lemur64(void) {
static uint128_t s = 2131259787901769494;
return (s *= 15750249268501108917ull) >> 64;
}
| 2,814 | 46 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/ftell.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"
/**
* Returns current position of stream.
*
* @param stream is a non-null stream handle
* @returns current byte offset from beginning, or -1 w/ errno
*/
long ftell(FILE *f) {
return ftello(f);
}
| 2,069 | 30 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/rngset.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/intrin/asan.internal.h"
#include "libc/stdio/rand.h"
#include "libc/stdio/stdio.h"
/**
* Fills memory with random bytes, e.g.
*
* char buf[512];
* rngset(buf, sizeof(buf), 0, 0);
*
* If reseed is zero then the internal PRNG is disabled and bytes are
* simply copied in little-endian order from the seed function. If seed
* is NULL then the reseed parameter is used as the seed value for the
* internal PRNG. If seed!=NULL and reseed>8 then reseed is the number
* of bytes after which the seed() function should be called again, to
* freshen up the PRNG.
*
* The main advantage of this generator is that it produces data at 13
* gigabytes per second since Vigna's Algorithm vectorizes better than
* alternatives, going even faster than xorshift.
*
* @return original buf
*/
noasan void *rngset(void *b, size_t n, uint64_t seed(void), size_t reseed) {
size_t m;
uint64_t i, x, t = 0;
unsigned char *p = b;
if (IsAsan()) {
__asan_verify(b, n);
}
if (!seed) {
t = reseed;
reseed = -1;
} else if (reseed < 8) {
reseed = 8;
}
while (n) {
if (seed) t = seed();
if (!seed || reseed > 8) {
n -= (m = reseed < n ? reseed : n);
while (m >= 8) {
x = (t += 0x9e3779b97f4a7c15);
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
x = (x ^ (x >> 31));
__builtin_memcpy(p, &x, 8);
p += 8;
m -= 8;
}
while (m--) {
*p++ = t;
t >>= 8;
}
} else if (n >= 8) {
p[0] = (0x00000000000000FF & t) >> 000;
p[1] = (0x000000000000FF00 & t) >> 010;
p[2] = (0x0000000000FF0000 & t) >> 020;
p[3] = (0x00000000FF000000 & t) >> 030;
p[4] = (0x000000FF00000000 & t) >> 040;
p[5] = (0x0000FF0000000000 & t) >> 050;
p[6] = (0x00FF000000000000 & t) >> 060;
p[7] = (0xFF00000000000000 & t) >> 070;
p += 8;
n -= 8;
} else {
while (n) {
*p++ = t;
t >>= 8;
--n;
}
}
}
return b;
}
| 3,957 | 95 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/stdio.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_STDIO
LIBC_STDIO_ARTIFACTS += LIBC_STDIO_A
LIBC_STDIO = $(LIBC_STDIO_A_DEPS) $(LIBC_STDIO_A)
LIBC_STDIO_A = o/$(MODE)/libc/stdio/stdio.a
LIBC_STDIO_A_FILES := $(wildcard libc/stdio/*) $(wildcard libc/stdio/unlocked/*)
LIBC_STDIO_A_HDRS = $(filter %.h,$(LIBC_STDIO_A_FILES))
LIBC_STDIO_A_SRCS_S = $(filter %.S,$(LIBC_STDIO_A_FILES))
LIBC_STDIO_A_SRCS_C = $(filter %.c,$(LIBC_STDIO_A_FILES))
LIBC_STDIO_A_SRCS = \
$(LIBC_STDIO_A_SRCS_S) \
$(LIBC_STDIO_A_SRCS_C)
LIBC_STDIO_A_OBJS = \
$(LIBC_STDIO_A_SRCS_S:%.S=o/$(MODE)/%.o) \
$(LIBC_STDIO_A_SRCS_C:%.c=o/$(MODE)/%.o)
LIBC_STDIO_A_CHECKS = \
$(LIBC_STDIO_A).pkg \
$(LIBC_STDIO_A_HDRS:%=o/$(MODE)/%.ok)
LIBC_STDIO_A_DIRECTDEPS = \
LIBC_CALLS \
LIBC_FMT \
LIBC_INTRIN \
LIBC_MEM \
LIBC_NEXGEN32E \
LIBC_NT_ADVAPI32 \
LIBC_NT_KERNEL32 \
LIBC_RUNTIME \
LIBC_STR \
LIBC_STUBS \
LIBC_SYSV \
LIBC_SYSV_CALLS \
THIRD_PARTY_GDTOA
LIBC_STDIO_A_DEPS := \
$(call uniq,$(foreach x,$(LIBC_STDIO_A_DIRECTDEPS),$($(x))))
$(LIBC_STDIO_A):libc/stdio/ \
$(LIBC_STDIO_A).pkg \
$(LIBC_STDIO_A_OBJS)
$(LIBC_STDIO_A).pkg: \
$(LIBC_STDIO_A_OBJS) \
$(foreach x,$(LIBC_STDIO_A_DIRECTDEPS),$($(x)_A).pkg)
o/$(MODE)/libc/stdio/fputc.o: private \
OVERRIDE_CFLAGS += \
-O3
o//libc/stdio/appendw.o: private \
OVERRIDE_CFLAGS += \
-Os
o/$(MODE)/libc/stdio/posix_spawnattr.o \
o/$(MODE)/libc/stdio/posix_spawn_file_actions.o \
o/$(MODE)/libc/stdio/mt19937.o: private \
OVERRIDE_CFLAGS += \
-ffunction-sections
LIBC_STDIO_LIBS = $(foreach x,$(LIBC_STDIO_ARTIFACTS),$($(x)))
LIBC_STDIO_SRCS = $(foreach x,$(LIBC_STDIO_ARTIFACTS),$($(x)_SRCS))
LIBC_STDIO_HDRS = $(foreach x,$(LIBC_STDIO_ARTIFACTS),$($(x)_HDRS))
LIBC_STDIO_CHECKS = $(foreach x,$(LIBC_STDIO_ARTIFACTS),$($(x)_CHECKS))
LIBC_STDIO_OBJS = $(foreach x,$(LIBC_STDIO_ARTIFACTS),$($(x)_OBJS))
$(LIBC_STDIO_OBJS): $(BUILD_FILES) libc/stdio/stdio.mk
.PHONY: o/$(MODE)/libc/stdio
o/$(MODE)/libc/stdio: $(LIBC_STDIO_CHECKS)
| 2,258 | 75 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/ecvt.c | /*-*- mode:c;indent-tabs-mode:t;c-basic-offset:8;tab-width:8;coding:utf-8 -*-â
âvi: set et ft=c ts=8 tw=8 fenc=utf-8 :viâ
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ¡
â $OpenBSD: ecvt.c,v 1.11 2019/01/25 00:19:25 millert Exp $ â
â â
â Copyright (c) 2002, 2006 Todd C. Miller <[email protected]> â
â â
â Permission to use, copy, modify, and 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. â
â â
â Sponsored in part by the Defense Advanced Research Projects â
â Agency (DARPA) and Air Force Research Laboratory, Air Force â
â Materiel Command, USAF, under agreement number F39502-99-1-0512. â
â SUCH DAMAGE. â
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ*/
#include "libc/fmt/fmt.h"
#include "libc/mem/mem.h"
#include "libc/runtime/runtime.h"
#include "libc/str/str.h"
#include "third_party/gdtoa/gdtoa.h"
asm(".ident\t\"\\n\\n\
OpenBSD ecvt/gcvt (MIT)\\n\
Copyright (c) 2002, 2006, 2010 Todd C. Miller <[email protected]>\"");
asm(".include \"libc/disclaimer.inc\"");
// clang-format off
static char *s;
static void
__cvt_atexit(void)
{
free(s);
s = 0;
}
static void __attribute__((__constructor__))
__cvt_init(void)
{
atexit(__cvt_atexit);
}
static char *
__cvt(double value, int ndigit, int *decpt, int *sign, int fmode, int pad)
{
char *p, *rve, c;
size_t siz;
if (ndigit == 0) {
*sign = value < 0.0;
*decpt = 0;
return ("");
}
free(s);
s = NULL;
if (ndigit < 0)
siz = -ndigit + 1;
else
siz = ndigit + 1;
/* __dtoa() doesn't allocate space for 0 so we do it by hand */
if (value == 0.0) {
*decpt = 1 - fmode; /* 1 for 'e', 0 for 'f' */
*sign = 0;
if ((rve = s = malloc(siz)) == NULL)
return(NULL);
*rve++ = '0';
*rve = '\0';
} else {
p = dtoa(value, fmode + 2, ndigit, decpt, sign, &rve);
if (p == NULL)
return (NULL);
if (*decpt == 9999) {
/* Infinity or Nan, convert to inf or nan like printf */
*decpt = 0;
c = *p;
freedtoa(p);
return(c == 'I' ? "inf" : "nan");
}
/* Make a local copy and adjust rve to be in terms of s */
if (pad && fmode)
siz += *decpt;
if ((s = malloc(siz)) == NULL) {
freedtoa(p);
return(NULL);
}
(void) strlcpy(s, p, siz);
rve = s + (rve - p);
freedtoa(p);
}
/* Add trailing zeros */
if (pad) {
siz -= rve - s;
while (--siz)
*rve++ = '0';
*rve = '\0';
}
return(s);
}
char *
ecvt(double value, int ndigit, int *decpt, int *sign)
{
return(__cvt(value, ndigit, decpt, sign, 0, 1));
}
char *
fcvt(double value, int ndigit, int *decpt, int *sign)
{
return(__cvt(value, ndigit, decpt, sign, 1, 1));
}
| 4,231 | 126 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/vfscanf.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/stdio/stdio.h"
/**
* Stream decoder.
* @see libc/fmt/vcscanf.h
*/
int(vfscanf)(FILE *stream, const char *fmt, va_list ap) {
return (vcscanf)((void *)fgetc, (void *)ungetc, stream, fmt, ap);
}
| 2,075 | 29 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/getwchar.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"
/**
* Reads UTF-8 character from stream.
* @return wide character or -1 on EOF or error
* @threadsafe
*/
wint_t getwchar(void) {
return fgetwc(stdin);
}
| 2,026 | 29 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/real1.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/rand.h"
/**
* Generates number on [0,1]-real-interval, e.g.
*
* double x = _real1(lemur64())
*
* @see lemur64(), mt19937()
*/
double _real1(uint64_t x) {
return 1. / 9007199254740991. * (x >> 11);
}
| 2,069 | 31 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/strlist.internal.h | #ifndef COSMOPOLITAN_LIBC_STDIO_STRLIST_H_
#define COSMOPOLITAN_LIBC_STDIO_STRLIST_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
struct StrList {
int i, n;
char **p;
};
void FreeStrList(struct StrList *) _Hide;
int AppendStrList(struct StrList *) _Hide;
void SortStrList(struct StrList *) _Hide;
int JoinStrList(struct StrList *, char **, uint64_t) _Hide;
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_STDIO_STRLIST_H_ */
| 495 | 19 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/__fpurge.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_ext.h"
/**
* Discards contents of stream buffer.
*/
void __fpurge(FILE *f) {
f->beg = f->end = 0;
}
| 1,968 | 27 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/posix_spawn.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/posix_spawn.h"
#include "libc/calls/calls.h"
#include "libc/calls/struct/sigaction.h"
#include "libc/calls/struct/sigset.h"
#include "libc/errno.h"
#include "libc/intrin/strace.internal.h"
#include "libc/intrin/weaken.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/posix_spawn.internal.h"
#include "libc/sysv/consts/sig.h"
#include "libc/thread/thread.h"
#include "libc/thread/tls.h"
static int RunFileActions(struct _posix_faction *a) {
int t;
if (!a) return 0;
if (RunFileActions(a->next) == -1) return -1;
switch (a->action) {
case _POSIX_SPAWN_CLOSE:
return close(a->fildes);
case _POSIX_SPAWN_DUP2:
return dup2(a->fildes, a->newfildes);
case _POSIX_SPAWN_OPEN:
if ((t = open(a->path, a->oflag, a->mode)) == -1) return -1;
if (t != a->fildes) {
if (dup2(t, a->fildes) == -1) {
close(t);
return -1;
}
if (close(t) == -1) {
return -1;
}
}
return 0;
default:
unreachable;
}
}
/**
* Spawns process, the POSIX way.
*
* This function provides an API for vfork() that's intended to be less
* terrifying to the uninitiated, since it only lets you define actions
* that are @vforksafe. This function requires TLS not be disabled.
*
* @param pid if non-null shall be set to child pid on success
* @param path is resolved path of program which is not `$PATH` searched
* @param file_actions specifies close(), dup2(), and open() operations
* @param attrp specifies signal masks, user ids, scheduling, etc.
* @param envp is environment variables, or `environ` if null
* @return 0 on success or error number on failure
* @see posix_spawnp() for `$PATH` searching
* @tlsrequired
* @threadsafe
*/
int posix_spawn(int *pid, const char *path,
const posix_spawn_file_actions_t *file_actions,
const posix_spawnattr_t *attrp, char *const argv[],
char *const envp[]) {
short flags = 0;
sigset_t sigmask;
int s, child, policy;
struct sched_param param;
struct sigaction dfl = {0};
if (!(child = vfork())) {
if (attrp && *attrp) {
posix_spawnattr_getflags(attrp, &flags);
if (flags & POSIX_SPAWN_SETPGROUP) {
if (setpgid(0, (*attrp)->pgroup)) {
STRACE("posix_spawn fail #%d", 1);
_Exit(127);
}
}
if (flags & POSIX_SPAWN_SETSIGMASK) {
posix_spawnattr_getsigmask(attrp, &sigmask);
sigprocmask(SIG_SETMASK, &sigmask, 0);
}
if ((flags & POSIX_SPAWN_RESETIDS) &&
(setgid(getgid()) || setuid(getuid()))) {
STRACE("posix_spawn fail #%d", 2);
_Exit(127);
}
if (flags & POSIX_SPAWN_SETSIGDEF) {
for (s = 1; s < 32; s++) {
if (sigismember(&(*attrp)->sigdefault, s)) {
if (sigaction(s, &dfl, 0) == -1) {
STRACE("posix_spawn fail #%d", 3);
_Exit(127);
}
}
}
}
}
if (file_actions) {
if (RunFileActions(*file_actions) == -1) {
STRACE("posix_spawn fail #%d", 4);
_Exit(127);
}
}
if (attrp && *attrp) {
if (flags & POSIX_SPAWN_SETSCHEDULER) {
posix_spawnattr_getschedpolicy(attrp, &policy);
posix_spawnattr_getschedparam(attrp, ¶m);
if (sched_setscheduler(0, policy, ¶m) == -1) {
STRACE("posix_spawn fail #%d", 5);
_Exit(127);
}
}
if (flags & POSIX_SPAWN_SETSCHEDPARAM) {
posix_spawnattr_getschedparam(attrp, ¶m);
if (sched_setparam(0, ¶m) == -1) {
STRACE("posix_spawn fail #%d", 6);
_Exit(127);
}
}
}
if (!envp) envp = environ;
execve(path, argv, envp);
STRACE("posix_spawn fail #%d", 7);
_Exit(127);
} else if (child != -1) {
if (pid) *pid = child;
return 0;
} else {
return errno;
}
}
| 5,770 | 147 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/vfprintf.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=8 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/lock.internal.h"
#include "libc/stdio/stdio.h"
/**
* Formats and writes text to stream.
* @see printf() for further documentation
*/
int(vfprintf)(FILE *f, const char *fmt, va_list va) {
int rc;
flockfile(f);
rc = (vfprintf_unlocked)(f, fmt, va);
funlockfile(f);
return rc;
}
| 2,147 | 33 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/putc.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=8 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"
/**
* Writes byte to stream.
*
* @param c is byte to buffer or write, which is masked
* @return c as unsigned char if written or -1 w/ errno
* @threadsafe
*/
int(putc)(int c, FILE *f) {
return fputc(c, f);
}
| 2,083 | 31 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/g_rando.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/stdio/stdio.h"
uint64_t g_rando = 1;
| 1,889 | 22 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fwrite_unlocked.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=8 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/internal.h"
#include "libc/calls/struct/iovec.h"
#include "libc/calls/struct/iovec.internal.h"
#include "libc/errno.h"
#include "libc/fmt/conv.h"
#include "libc/macros.internal.h"
#include "libc/runtime/runtime.h"
#include "libc/sock/sock.h"
#include "libc/stdio/internal.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/o.h"
/**
* Writes data to stream.
*
* @param stride specifies the size of individual items
* @param count is the number of strides to write
* @return count on success, [0,count) on EOF, 0 on error or count==0
*/
size_t fwrite_unlocked(const void *data, size_t stride, size_t count, FILE *f) {
ldiv_t d;
ssize_t rc;
size_t n, m;
const char *p;
struct iovec iov[2];
if (f->state) {
return 0;
}
if ((f->iomode & O_ACCMODE) == O_RDONLY) {
f->state = errno = EBADF;
return 0;
}
if (__builtin_mul_overflow(stride, count, &n)) {
f->state = errno = EOVERFLOW;
return 0;
}
m = f->size - f->beg;
if (n <= m && f->bufmode != _IONBF) {
// this isn't a fully buffered stream, and
// there's enough room in the buffer for the request
memcpy(f->buf + f->beg, data, n);
f->beg += n;
if (f->fd != -1 && f->bufmode == _IOLBF &&
(p = memrchr(f->buf, '\n', f->beg))) {
// write out as many lines as possible
n = p + 1 - f->buf;
if ((rc = write(f->fd, f->buf, n)) == -1) {
// the write() system call failed
if (errno == EINTR || errno == EAGAIN) {
return count;
} else {
f->state = errno;
return 0;
}
}
// copy backwards last line fragment or uncompleted data
n = rc;
if (f->beg - n) {
memmove(f->buf, f->buf + n, f->beg - n);
}
f->beg -= n;
}
return count;
}
// what's happening is either
// (1) a fully buffered stream, or
// (2) no room in buffer to hold full request
if (f->fd == -1) {
// this is an in-memory stream
// store as much of request as we can hold
n = MIN(n, m);
d = ldiv(n, stride);
n -= d.rem;
if (n) {
memcpy(f->buf + f->beg, data, n);
f->beg += n;
}
// trigger eof condition
f->state = EOF;
return d.quot;
}
// perform a fragmented write
// (1) we avoid needless copies in fully buffered mode
// (2) we avoid need for malloc() when it's out of room
iov[0].iov_base = f->buf;
iov[0].iov_len = f->beg;
iov[1].iov_base = data;
iov[1].iov_len = n;
n += f->beg;
if (WritevUninterruptible(f->fd, iov, 2) == -1) {
f->state = errno;
return 0;
}
f->beg = 0;
return count;
}
| 4,543 | 118 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/getchar.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"
/**
* Reads byte from stdin.
* @return byte in range 0..255, or -1 w/ errno
* @htreadsafe
*/
int getchar(void) {
return fgetc(stdin);
}
| 2,009 | 29 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/append.h | #ifndef COSMOPOLITAN_LIBC_STDIO_APPEND_H_
#define COSMOPOLITAN_LIBC_STDIO_APPEND_H_
#include "libc/fmt/pflink.h"
#define APPEND_COOKIE 21578
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
struct appendz {
size_t i;
size_t n;
};
struct appendz appendz(char *);
ssize_t appendr(char **, size_t);
ssize_t appendd(char **, const void *, size_t);
ssize_t appendw(char **, uint64_t);
ssize_t appends(char **, const char *);
ssize_t appendf(char **, const char *, ...);
ssize_t vappendf(char **, const char *, va_list);
ssize_t kappendf(char **, const char *, ...);
ssize_t kvappendf(char **, const char *, va_list);
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
#define appendf(BUF, FMT, ...) appendf(BUF, PFLINK(FMT), ##__VA_ARGS__)
#define vappendf(BUF, FMT, VA) vappendf(BUF, PFLINK(FMT), VA)
#endif
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_STDIO_APPEND_H_ */
| 939 | 33 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/mkstemps.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/temp.h"
int mkstemps(char *template, int suffixlen) {
return mkostempsm(template, suffixlen, 0, 0600);
}
| 1,965 | 24 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fsetlocking.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_ext.h"
/**
* Does nothing and returns `FSETLOCKING_INTERNAL`.
*/
int __fsetlocking(FILE *f, int type) {
return FSETLOCKING_INTERNAL;
}
| 2,003 | 27 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/strfry.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/shuffle.internal.h"
#include "libc/stdio/rand.h"
#include "libc/str/str.h"
/**
* Jumbles up string.
*/
char *strfry(char *s) {
shuffle(rand, s, strlen(s));
return s;
}
| 2,030 | 30 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fgetwc_unlocked.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/str/thompike.h"
#include "libc/str/tpdecodecb.internal.h"
/**
* Reads UTF-8 character from stream.
* @return wide character or -1 on EOF or error
*/
wint_t fgetwc_unlocked(FILE *f) {
int c, n;
wint_t b, x, y;
if (f->beg < f->end) {
b = f->buf[f->beg++] & 0xff;
} else if ((c = fgetc_unlocked(f)) != -1) {
b = c;
} else {
return -1;
}
if (b < 0300) return b;
n = ThomPikeLen(b);
x = ThomPikeByte(b);
while (--n) {
if ((c = fgetc_unlocked(f)) == -1) return -1;
y = c;
if (ThomPikeCont(y)) {
x = ThomPikeMerge(x, y);
} else {
ungetc_unlocked(y, f);
return b;
}
}
return x;
}
| 2,531 | 52 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fdopen.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=8 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/stdio/internal.h"
#include "libc/stdio/stdio.h"
#include "libc/sysv/consts/o.h"
#include "libc/sysv/errfuns.h"
#include "libc/thread/thread.h"
/**
* Allocates stream object for already-opened file descriptor.
*
* @param fd existing file descriptor or -1 for plain old buffer
* @param mode is passed to fopenflags()
* @return new stream or NULL w/ errno
* @error ENOMEM
*/
FILE *fdopen(int fd, const char *mode) {
FILE *f;
if ((f = __stdio_alloc())) {
f->fd = fd;
f->bufmode = ischardev(fd) ? _IOLBF : _IOFBF;
f->iomode = fopenflags(mode);
f->buf = f->mem;
f->size = BUFSIZ;
if ((f->iomode & O_ACCMODE) != O_RDONLY) {
__fflush_register(f);
}
return f;
}
return NULL;
}
| 2,603 | 49 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/random.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â
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
â â
â Musl Libc â
â Copyright © 2005-2014 Rich Felker, et al. â
â â
â Permission is hereby granted, free of charge, to any person obtaining â
â a copy of this software and associated documentation files (the â
â "Software"), to deal in the Software without restriction, including â
â without limitation the rights to use, copy, modify, merge, publish, â
â distribute, sublicense, and/or sell copies of the Software, and to â
â permit persons to whom the Software is furnished to do so, subject to â
â the following conditions: â
â â
â The above copyright notice and this permission notice shall be â
â included in all copies or substantial portions of the Software. â
â â
â 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 OR COPYRIGHT HOLDERS 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/stdio/rand.h"
asm(".ident\t\"\\n\\n\
Musl libc (MIT License)\\n\
Copyright 2005-2014 Rich Felker, et. al.\"");
asm(".include \"libc/disclaimer.inc\"");
/*
* this code uses the same lagged fibonacci generator as the
* original bsd random implementation except for the seeding
* which was broken in the original
*/
static uint32_t init[] = {
0x00000000, 0x5851f42d, 0xc0b18ccf, 0xcbb5f646, 0xc7033129, 0x30705b04,
0x20fd5db4, 0x9a8b7f78, 0x502959d8, 0xab894868, 0x6c0356a7, 0x88cdb7ff,
0xb477d43f, 0x70a3a52b, 0xa8e4baf1, 0xfd8341fc, 0x8ae16fd9, 0x742d2f7a,
0x0d1f0796, 0x76035e09, 0x40f7702c, 0x6fa72ca5, 0xaaa84157, 0x58a0df74,
0xc74a0364, 0xae533cc4, 0x04185faf, 0x6de3b115, 0x0cab8628, 0xf043bfa4,
0x398150e9, 0x37521657,
};
static int n = 31;
static int i = 3;
static int j = 0;
static uint32_t *x = init + 1;
static uint32_t lcg31(uint32_t x) {
return (1103515245 * x + 12345) & 0x7fffffff;
}
static uint64_t lcg64(uint64_t x) {
return 6364136223846793005ull * x + 1;
}
static void *savestate(void) {
x[-1] = (n << 16) | (i << 8) | j;
return x - 1;
}
static void loadstate(uint32_t *state) {
x = state + 1;
n = x[-1] >> 16;
i = (x[-1] >> 8) & 0xff;
j = x[-1] & 0xff;
}
void srandom(unsigned seed) {
int k;
uint64_t s = seed;
if (!n) {
x[0] = s;
return;
}
i = n == 31 || n == 7 ? 3 : 1;
j = 0;
for (k = 0; k < n; k++) {
s = lcg64(s);
x[k] = s >> 32;
}
/* make sure x contains at least one odd number */
x[0] |= 1;
}
char *initstate(unsigned seed, char *state, size_t size) {
void *old;
if (size < 8) return 0;
old = savestate();
if (size < 32) {
n = 0;
} else if (size < 64) {
n = 7;
} else if (size < 128) {
n = 15;
} else if (size < 256) {
n = 31;
} else {
n = 63;
}
x = (uint32_t *)state + 1;
srandom(seed);
savestate();
return old;
}
char *setstate(char *state) {
void *old;
old = savestate();
loadstate((uint32_t *)state);
return old;
}
long random(void) {
long k;
if (!n) return (x[0] = lcg31(x[0]));
x[i] += x[j];
k = x[i] >> 1;
if (++i == n) i = 0;
if (++j == n) j = 0;
return k;
}
| 4,770 | 129 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/getc_unlocked.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=8 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"
/**
* Reads byte from stream.
* @return byte in range 0..255, or -1 w/ errno
*/
int(getc_unlocked)(FILE *f) {
return fgetc_unlocked(f);
}
| 2,010 | 28 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/rewind.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/stdio/lock.internal.h"
#include "libc/stdio/stdio.h"
/**
* Moves standard i/o stream to beginning of file.
*
* Like fseek(), this function can be used to restore a stream from the
* EOF state, without reopening it.
*/
void rewind(FILE *f) {
flockfile(f);
fseeko_unlocked(f, 0, SEEK_SET);
f->state = 0;
funlockfile(f);
}
| 2,215 | 35 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/legacychars.inc | 256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,
275,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,
296,297,298,299,302,303,304,305,308,309,310,311,312,313,314,315,316,317,318,
321,322,323,324,325,326,327,328,330,331,332,333,336,337,338,339,340,341,342,
343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,
362,363,364,365,366,367,368,369,370,371,372,373,374,375,376,377,378,379,380,
381,382,402,416,417,431,432,536,537,538,539,710,711,728,729,731,732,733,768,
769,771,777,803,890,900,901,902,904,905,906,908,910,911,912,913,914,915,916,
917,918,919,920,921,922,923,924,925,926,927,928,929,931,932,933,934,935,936,
937,938,939,940,941,942,943,944,945,946,947,948,949,950,951,952,953,954,955,
956,957,958,959,960,961,962,963,964,965,966,967,968,969,970,971,972,973,974,
1025,1026,1027,1028,1029,1030,1031,1032,1033,1034,1035,1036,1038,1039,1040,
1041,1042,1043,1044,1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,
1056,1057,1058,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,
1071,
1072,1073,1074,1075,1076,1077,1078,1079,1080,1081,1082,1083,1084,1085,1086,
1087,1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,
1102,1103,1105,1106,1107,1108,1109,1110,1111,1112,1113,1114,1115,1116,1118,
1119,1168,1169,1456,1457,1458,1459,1460,1461,1462,1463,1464,1465,1467,1468,
1469,1470,1471,1472,1473,1474,1475,1488,1489,1490,1491,1492,1493,1494,1495,
1496,1497,1498,1499,1500,1501,1502,1503,1504,1505,1506,1507,1508,1509,1510,
1511,1512,1513,1514,1520,1521,1522,1523,1524,1548,1563,1567,1569,1570,1571,
1572,1573,1574,1575,1576,1577,1578,1579,1580,1581,1582,1583,1584,1585,1586,
1587,1588,1589,1590,1591,1592,1593,1594,1600,1601,1602,1603,1604,1605,1606,
1607,1608,1609,1610,1611,1612,1613,1614,1615,1616,1617,1618,1657,1662,1670,
1672,1681,1688,1705,1711,1722,1726,1729,1746,3585,3586,3587,3588,3589,3590,
3591,3592,3593,3594,3595,3596,3597,3598,3599,3600,3601,3602,3603,3604,3605,
3606,3607,3608,3609,3610,3611,3612,3613,3614,3615,3616,3617,3618,3619,3620,
3621,3622,3623,3624,3625,3626,3627,3628,3629,3630,3631,3632,3633,3634,3635,
3636,3637,3638,3639,3640,3641,3642,3647,3648,3649,3650,3651,3652,3653,3654,
3655,3656,3657,3658,3659,3660,3661,3662,3663,3664,3665,3666,3667,3668,3669,
3670,3671,3672,3673,3674,3675,7682,7683,7690,7691,7710,7711,7744,7745,7766,
7767,
7776,7777,7786,7787,7808,7809,7810,7811,7812,7813,7922,7923,8204,8205,8206,
8207,8211,8212,8213,8215,8216,8217,8218,8220,8221,8222,8224,8225,8226,8230,
8240,8249,8250,8319,8359,8362,8363,8364,8367,8470,8482,8729,8730,8734,8745,
8776,8801,8804,8805,8976,8992,8993,9472,9474,9484,9488,9492,9496,9500,9508,
9516,9524,9532,9552,9553,9554,9555,9556,9557,9558,9559,9560,9561,9562,9563,
9564,9565,9566,9567,9568,9569,9570,9571,9572,9573,9574,9575,9576,9577,9578,
9579,9580,9600,9604,9608,9612,9616,9617,9618,9619,9632,
| 2,891 | 41 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fscanf.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/stdio/stdio.h"
/**
* Decodes data from stream.
*
* To read a line of data from a well-formed trustworthy file:
*
* int x, y;
* char text[256];
* fscanf(f, "%d %d %s\n", &x, &y, text);
*
* Please note that this function is brittle by default, which makes it
* a good fit for yolo coding. With some toil it can be used in a way
* that makes it reasonably hardened although getline() may be better.
*
* @see libc/fmt/vcscanf.c
*/
int(fscanf)(FILE *stream, const char *fmt, ...) {
int rc;
va_list va;
va_start(va, fmt);
rc = (vcscanf)((int (*)(void *))fgetc, (void *)ungetc, stream, fmt, va);
va_end(va);
return rc;
}
| 2,530 | 45 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/xorshift32.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/xorshift.h"
uint32_t MarsagliaXorshift32(uint32_t state[hasatleast 1]) {
uint32_t x = state[0];
x ^= x << 13;
x ^= x >> 17;
x ^= x << 5;
state[0] = x;
return x;
}
| 2,033 | 29 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/internal.h | #ifndef COSMOPOLITAN_LIBC_STDIO_INTERNAL_H_
#define COSMOPOLITAN_LIBC_STDIO_INTERNAL_H_
#include "libc/stdio/stdio.h"
#define PUSHBACK 12
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
_Hide extern uint64_t g_rando;
int __fflush_impl(FILE *) _Hide;
int __fflush_register(FILE *) _Hide;
void __fflush_unregister(FILE *) _Hide;
bool __stdio_isok(FILE *) _Hide;
FILE *__stdio_alloc(void) _Hide;
void __stdio_free(FILE *) _Hide;
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_STDIO_INTERNAL_H_ */
| 559 | 22 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/posix_spawnp.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/errno.h"
#include "libc/stdio/posix_spawn.h"
/**
* Spawns process the POSIX way w/ PATH search.
*
* @param pid is non-NULL and will be set to child pid in parent
* @param path of executable is PATH searched unless it contains a slash
* @return 0 on success or error number on failure
*/
int posix_spawnp(int *pid, const char *path,
const posix_spawn_file_actions_t *file_actions,
const posix_spawnattr_t *attrp, char *const argv[],
char *const envp[]) {
char pathbuf[PATH_MAX];
if (!(path = commandv(path, pathbuf, sizeof(pathbuf)))) return errno;
return posix_spawn(pid, path, file_actions, attrp, argv, envp);
}
| 2,559 | 38 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/putwc.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"
/**
* Writes wide character to stream.
*
* @return wc if written or -1 w/ errno
* @threadsafe
*/
wint_t(putwc)(wchar_t wc, FILE *f) {
return fputwc(wc, f);
}
| 2,032 | 30 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/posix_spawnattr.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/assert.h"
#include "libc/calls/calls.h"
#include "libc/calls/struct/sigset.h"
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/mem/mem.h"
#include "libc/stdio/posix_spawn.h"
#include "libc/stdio/posix_spawn.internal.h"
#include "libc/sysv/consts/sig.h"
/**
* Initialize posix_spawn() attributes object with default values.
*
* @param attr needs to be passed to posix_spawnattr_destroy() later
* @return 0 on success, or errno on error
* @raise ENOMEM if we require more vespene gas
*/
int posix_spawnattr_init(posix_spawnattr_t *attr) {
int rc, e = errno;
struct _posix_spawna *a;
if ((a = calloc(1, sizeof(struct _posix_spawna)))) {
*attr = a;
rc = 0;
} else {
rc = errno;
errno = e;
}
return rc;
}
/**
* Destroys posix_spawn() attributes object.
*
* This function is safe to call multiple times.
*
* @param attr was initialized by posix_spawnattr_init()
* @return 0 on success, or errno on error
*/
int posix_spawnattr_destroy(posix_spawnattr_t *attr) {
if (*attr) {
free(*attr);
*attr = 0;
}
return 0;
}
/**
* Gets posix_spawn() flags.
*
* @param attr was initialized by posix_spawnattr_init()
* @return 0 on success, or errno on error
*/
int posix_spawnattr_getflags(const posix_spawnattr_t *attr, short *flags) {
*flags = (*attr)->flags;
return 0;
}
/**
* Sets posix_spawn() flags.
*
* Setting these flags is needed in order for the other setters in this
* function to take effect. If a flag is known but unsupported by the
* host platform, it'll be silently removed from the flags. You can
* check for this by calling the getter afterwards.
*
* @param attr was initialized by posix_spawnattr_init()
* @param flags may have any of the following
* - `POSIX_SPAWN_RESETIDS`
* - `POSIX_SPAWN_SETPGROUP`
* - `POSIX_SPAWN_SETSIGDEF`
* - `POSIX_SPAWN_SETSIGMASK`
* - `POSIX_SPAWN_SETSCHEDPARAM`
* - `POSIX_SPAWN_SETSCHEDULER`
* @return 0 on success, or errno on error
* @raise EINVAL if `flags` has invalid bits
*/
int posix_spawnattr_setflags(posix_spawnattr_t *attr, short flags) {
if (!(IsLinux() || IsFreebsd() || IsNetbsd())) {
flags &= ~(POSIX_SPAWN_SETSCHEDPARAM | POSIX_SPAWN_SETSCHEDULER);
}
if (flags & ~(POSIX_SPAWN_RESETIDS | POSIX_SPAWN_SETPGROUP |
POSIX_SPAWN_SETSIGDEF | POSIX_SPAWN_SETSIGMASK |
POSIX_SPAWN_SETSCHEDPARAM | POSIX_SPAWN_SETSCHEDULER)) {
return EINVAL;
}
(*attr)->flags = flags;
return 0;
}
int posix_spawnattr_getpgroup(const posix_spawnattr_t *attr, int *pgroup) {
*pgroup = (*attr)->pgroup;
return 0;
}
int posix_spawnattr_setpgroup(posix_spawnattr_t *attr, int pgroup) {
(*attr)->pgroup = pgroup;
return 0;
}
/**
* Gets scheduler policy that'll be used for spawned process.
*
* If the setter wasn't called then this function will return the
* scheduling policy of the current process.
*
* @param attr was initialized by posix_spawnattr_init()
* @param schedpolicy receives the result
* @return 0 on success, or errno on error
* @raise ENOSYS if platform support isn't available
*/
int posix_spawnattr_getschedpolicy(const posix_spawnattr_t *attr,
int *schedpolicy) {
int rc, e = errno;
struct _posix_spawna *a = *(/*unconst*/ posix_spawnattr_t *)attr;
if (!a->schedpolicy_isset) {
rc = sched_getscheduler(0);
if (rc == -1) {
rc = errno;
errno = e;
return rc;
}
a->schedpolicy = rc;
a->schedpolicy_isset = true;
}
*schedpolicy = a->schedpolicy;
return 0;
}
/**
* Specifies scheduler policy override for spawned process.
*
* Scheduling policies are inherited by default. Use this to change it.
*
* @param attr was initialized by posix_spawnattr_init()
* @param schedpolicy receives the result
* @return 0 on success, or errno on error
*/
int posix_spawnattr_setschedpolicy(posix_spawnattr_t *attr, int schedpolicy) {
(*attr)->schedpolicy = schedpolicy;
(*attr)->schedpolicy_isset = true;
return 0;
}
/**
* Gets scheduler parameter that'll be used for spawned process.
*
* If the setter wasn't called then this function will return the
* scheduling parameter of the current process.
*
* @param attr was initialized by posix_spawnattr_init()
* @param schedparam receives the result
* @return 0 on success, or errno on error
* @raise ENOSYS if platform support isn't available
*/
int posix_spawnattr_getschedparam(const posix_spawnattr_t *attr,
struct sched_param *schedparam) {
int rc, e = errno;
struct _posix_spawna *a = *(/*unconst*/ posix_spawnattr_t *)attr;
if (!a->schedparam_isset) {
rc = sched_getparam(0, &a->schedparam);
if (rc == -1) {
rc = errno;
errno = e;
return rc;
}
a->schedparam_isset = true;
}
*schedparam = a->schedparam;
return 0;
}
/**
* Specifies scheduler parameter override for spawned process.
*
* Scheduling parameters are inherited by default. Use this to change it.
*
* @param attr was initialized by posix_spawnattr_init()
* @param schedparam receives the result
* @return 0 on success, or errno on error
*/
int posix_spawnattr_setschedparam(posix_spawnattr_t *attr,
const struct sched_param *schedparam) {
(*attr)->schedparam = *schedparam;
(*attr)->schedparam_isset = true;
return 0;
}
/**
* Gets signal mask for sigprocmask() in child process.
*
* If the setter wasn't called then this function will return the
* scheduling parameter of the current process.
*
* @return 0 on success, or errno on error
*/
int posix_spawnattr_getsigmask(const posix_spawnattr_t *attr,
sigset_t *sigmask) {
struct _posix_spawna *a = *(/*unconst*/ posix_spawnattr_t *)attr;
if (!a->sigmask_isset) {
_npassert(!sigprocmask(SIG_SETMASK, 0, &a->sigmask));
a->sigmask_isset = true;
}
*sigmask = a->sigmask;
return 0;
}
/**
* Specifies signal mask for sigprocmask() in child process.
*
* Signal masks are inherited by default. Use this to change it.
*
* @return 0 on success, or errno on error
*/
int posix_spawnattr_setsigmask(posix_spawnattr_t *attr,
const sigset_t *sigmask) {
(*attr)->sigmask = *sigmask;
(*attr)->sigmask_isset = true;
return 0;
}
/**
* Retrieves which signals will be restored to `SIG_DFL`.
*
* @return 0 on success, or errno on error
*/
int posix_spawnattr_getsigdefault(const posix_spawnattr_t *attr,
sigset_t *sigdefault) {
*sigdefault = (*attr)->sigdefault;
return 0;
}
/**
* Specifies which signals should be restored to `SIG_DFL`.
*
* @return 0 on success, or errno on error
*/
int posix_spawnattr_setsigdefault(posix_spawnattr_t *attr,
const sigset_t *sigdefault) {
(*attr)->sigdefault = *sigdefault;
return 0;
}
| 8,752 | 260 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fwriting.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_ext.h"
#include "libc/sysv/consts/o.h"
/**
* Returns nonzero if stream is write only.
*/
int __fwriting(FILE *f) {
return (f->iomode & O_ACCMODE) == O_WRONLY;
}
| 2,029 | 28 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fwrite.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=8 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/intrin/describeflags.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h"
/**
* Writes data to stream.
*
* @param stride specifies the size of individual items
* @param count is the number of strides to write
* @return count on success, [0,count) on EOF, 0 on error or count==0
* @threadsafe
*/
size_t fwrite(const void *data, size_t stride, size_t count, FILE *f) {
size_t rc;
flockfile(f);
rc = fwrite_unlocked(data, stride, count, f);
STDIOTRACE("fwrite(%p, %'zu, %'zu, %p) â %'zu %s", data, stride, count, f, rc,
DescribeStdioState(f->state));
funlockfile(f);
return rc;
}
| 2,531 | 41 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fputc_unlocked.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=8 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/stdio/stdio.h"
/**
* Writes byte to stream.
*
* @param c is byte to buffer or write, which is masked
* @return c as unsigned char if written or -1 w/ errno
*/
int fputc_unlocked(int c, FILE *f) {
unsigned char b;
if (c != '\n' && f->beg < f->size && f->bufmode != _IONBF) {
f->buf[f->beg++] = c;
return c & 255;
} else {
b = c;
if (!fwrite_unlocked(&b, 1, 1, f)) return -1;
return b;
}
}
| 2,303 | 39 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fflushimpl.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/errno.h"
#include "libc/mem/mem.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/internal.h"
#include "libc/stdio/stdio.h"
#include "libc/sysv/consts/o.h"
int __fflush_impl(FILE *f) {
size_t i;
ssize_t rc;
free(f->getln);
f->getln = 0;
if (f->beg && !f->end && (f->iomode & O_ACCMODE) != O_RDONLY) {
for (i = 0; i < f->beg; i += rc) {
if ((rc = write(f->fd, f->buf + i, f->beg - i)) == -1) {
f->state = errno;
return -1;
}
}
f->beg = 0;
}
return 0;
}
| 2,396 | 43 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/rand.h | #ifndef COSMOPOLITAN_LIBC_RAND_RAND_H_
#define COSMOPOLITAN_LIBC_RAND_RAND_H_
#define RAND_MAX __INT_MAX__
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
/*ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
â cosmopolitan § random ââ¬âââ¼
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ*/
int rand(void);
void srand(unsigned);
double poz(double);
double pochisq(double, int);
void rt_init(int);
void rt_add(void *, int);
void rt_end(double *, double *, double *, double *, double *);
char *strfry(char *);
int getentropy(void *, size_t);
ssize_t getrandom(void *, size_t, unsigned);
char *initstate(unsigned, char *, size_t);
char *setstate(char *);
long random(void);
void srandom(unsigned);
uint64_t lemur64(void);
uint64_t _rand64(void);
uint64_t vigna(void);
uint64_t vigna_r(uint64_t[hasatleast 1]);
void svigna(uint64_t);
uint64_t rdrand(void);
uint64_t rdseed(void);
void _smt19937(uint64_t);
void _Smt19937(uint64_t[], size_t);
uint64_t _mt19937(void);
double _real1(uint64_t);
double _real2(uint64_t);
double _real3(uint64_t);
double MeasureEntropy(const char *, size_t);
void *rngset(void *, size_t, uint64_t (*)(void), size_t);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_RAND_RAND_H_ */
| 1,699 | 44 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/getwchar_unlocked.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"
/**
* Reads UTF-8 character from stream.
* @return wide character or -1 on EOF or error
*/
wint_t getwchar_unlocked(void) {
return fgetwc_unlocked(stdin);
}
| 2,029 | 28 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fgets.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/lock.internal.h"
#include "libc/stdio/stdio.h"
/**
* Reads line from stream.
*
* This function is similar to getline() except it'll truncate lines
* exceeding size. The line ending marker is included and may be removed
* using _chomp().
*
* @param s is output buffer
* @param size is capacity of s
* @param f is non-null file object stream pointer
* @return s on success, NULL on error, or NULL if EOF happens when
* zero characters have been read
* @see fgets_unlocked()
* @threadsafe
*/
char *fgets(char *s, int size, FILE *f) {
char *res;
flockfile(f);
res = fgets_unlocked(s, size, f);
funlockfile(f);
return res;
}
| 2,506 | 44 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/srand.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/rand.h"
extern uint64_t g_rando;
/**
* Seeds random number generator that's used by rand().
*/
void srand(unsigned seed) {
g_rando = seed;
}
| 2,004 | 29 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/clearerr.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/lock.internal.h"
#include "libc/stdio/stdio.h"
/**
* Clears eof and error state indicators on stream.
*
* @param f is file object stream pointer
* @see clearerr_unlocked()
* @threadsafe
*/
void clearerr(FILE *f) {
flockfile(f);
clearerr_unlocked(f);
funlockfile(f);
}
| 2,138 | 34 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/putwchar_unlocked.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"
/**
* Writes wide character to stdout.
* @return wc if written or -1 w/ errno
*/
wint_t putwchar_unlocked(wchar_t wc) {
return fputwc_unlocked(wc, stdout);
}
| 2,030 | 28 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/real2.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/rand.h"
/**
* Generates number on [0,1)-real-interval, e.g.
*
* double x = _real2(lemur64())
*
* @see lemur64(), mt19937()
*/
double _real2(uint64_t x) {
return 1. / 9007199254740992. * (x >> 11);
}
| 2,069 | 31 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/readdir64.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â
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ¡
â 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/macros.internal.h"
readdir64:
jmp readdir
.endfn readdir64,globl
| 2,599 | 32 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/putchar.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"
/**
* Writes byte to stdout.
*
* @return c (as unsigned char) if written or -1 w/ errno
* @threadsafe
*/
int putchar(int c) {
return fputc(c, stdout);
}
| 2,027 | 30 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/mt19937.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 (C) 2004, Makoto Matsumoto and Takuji Nishimura, â
â All rights reserved. â
â â
â Redistribution and use in source and binary forms, with or without â
â modification, are permitted provided that the following conditions â
â are met: â
â â
â 1. Redistributions of source code must retain the above copyright â
â notice, this list of conditions and the following disclaimer. â
â â
â 2. Redistributions in binary form must reproduce the above â
â copyright notice, this list of conditions and the following â
â disclaimer in the documentation and/or other materials â
â provided with the distribution. â
â â
â 3. The names of its contributors may not be used to endorse or â
â promote products derived from this software without specific â
â prior written permission. â
â â
â THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS â
â "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT â
â LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR â
â A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT â
â OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, â
â SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT â
â LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, â
â DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY â
â THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT â
â (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE â
â OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. â
â â
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ*/
#include "libc/intrin/likely.h"
#include "libc/macros.internal.h"
#include "libc/stdio/rand.h"
asm(".ident\t\"\\n\\n\
mt19937 (BSD-3)\\n\
Copyright 1997-2004 Makoto Matsumoto and Takuji Nishimura\"");
asm(".include \"libc/disclaimer.inc\"");
/*
* A C-program for MT19937-64 (2004/9/29 version).
* Coded by Takuji Nishimura and Makoto Matsumoto.
*
* This is a 64-bit version of Mersenne Twister pseudorandom number
* generator.
*
* Before using, initialize the state by using init_genrand64(seed)
* or init_by_array64(init_key, key_length).
*
* References:
* T. Nishimura, ``Tables of 64-bit Mersenne Twisters''
* ACM Transactions on Modeling and
* Computer Simulation 10. (2000) 348--357.
* M. Matsumoto and T. Nishimura,
* ``Mersenne Twister: a 623-dimensionally equidistributed
* uniform pseudorandom number generator''
* ACM Transactions on Modeling and
* Computer Simulation 8. (Jan. 1998) 3--30.
*
* Any feedback is very welcome.
* http://www.math.hiroshima-u.ac.jp/~m-mat/MT/emt.html
* email: m-mat @ math.sci.hiroshima-u.ac.jp (remove spaces)
*/
#define NN 312
#define MM 156
#define LM 0x7fffffff
#define UM 0xffffffff80000000
static int mti = NN + 1;
static uint64_t mt[NN];
static const uint64_t mag01[2] = {0, 0xb5026f5aa96619e9};
/**
* Initializes mt[NN] with small seed value.
*
* @see mt19937(), Smt19937()
*/
void _smt19937(uint64_t seed) {
mt[0] = seed;
for (mti = 1; mti < NN; mti++) {
mt[mti] = 0x5851f42d4c957f2d * (mt[mti - 1] ^ (mt[mti - 1] >> 62)) + mti;
}
}
/**
* Initializes mt[NN] with array.
*
* @param K is the array for initializing keys
* @param n is its length
* @see mt19937(), smt19937()
*/
void _Smt19937(uint64_t K[], size_t n) {
size_t i, j, k;
_smt19937(19650218);
for (i = 1, j = 0, k = MAX(NN, n); k; k--) {
mt[i] = (mt[i] ^ ((mt[i - 1] ^ (mt[i - 1] >> 62)) * 0x369dea0f31a53f85)) +
K[j] + j;
if (++i >= NN) mt[0] = mt[NN - 1], i = 1;
if (++j >= n) j = 0;
}
for (k = NN - 1; k; k--) {
mt[i] =
(mt[i] ^ ((mt[i - 1] ^ (mt[i - 1] >> 62)) * 0x27bb2ee687b0b0fd)) - i;
if (++i >= NN) mt[0] = mt[NN - 1], i = 1;
}
mt[0] = 0x8000000000000000; /* assures non-zero initial array */
}
/**
* Generates random integer on [0, 2^64)-interval.
*
* This uses the Mersenne Twister pseudorandom number generator.
*
* @see smt19937(), Smt19937()
*/
uint64_t _mt19937(void) {
int i;
uint64_t x;
if (mti >= NN) {
if (mti == NN + 1) _smt19937(5489);
for (i = 0; i < NN - MM; i++) {
x = (mt[i] & UM) | (mt[i + 1] & LM);
mt[i] = mt[i + MM] ^ (x >> 1) ^ mag01[x & 1];
}
for (; i < NN - 1; i++) {
x = (mt[i] & UM) | (mt[i + 1] & LM);
mt[i] = mt[i + (MM - NN)] ^ (x >> 1) ^ mag01[x & 1];
}
x = (mt[NN - 1] & UM) | (mt[0] & LM);
mt[NN - 1] = mt[MM - 1] ^ (x >> 1) ^ mag01[x & 1];
mti = 0;
}
x = mt[mti++];
x ^= (x >> 29) & 0x5555555555555555;
x ^= (x << 17) & 0x71d67fffeda60000;
x ^= (x << 37) & 0xfff7eee000000000;
x ^= (x >> 43);
return x;
}
| 6,420 | 147 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/setbuffer.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/runtime/runtime.h"
#include "libc/stdio/stdio.h"
#include "libc/sysv/errfuns.h"
/**
* Sets buffer on stdio stream.
*
* @param buf may optionally be non-NULL to set the stream's underlying
* buffer, which the stream will own, but won't free
* @param size is ignored if buf is NULL
*/
void setbuffer(FILE *f, char *buf, size_t size) {
setvbuf(f, buf, buf ? _IOFBF : _IONBF, size);
}
| 2,275 | 34 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/popen.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/assert.h"
#include "libc/calls/calls.h"
#include "libc/errno.h"
#include "libc/intrin/weaken.h"
#include "libc/paths.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/internal.h"
#include "libc/stdio/stdio.h"
#include "libc/sysv/consts/f.h"
#include "libc/sysv/consts/fd.h"
#include "libc/sysv/consts/o.h"
#include "libc/sysv/errfuns.h"
#include "libc/thread/thread.h"
/**
* Spawns subprocess and returns pipe stream.
*
* The returned resource needs to be passed to pclose().
*
* This embeds the Cosmopolitan Command Interpreter which provides
* Bourne-like syntax on all platforms including Windows.
*
* @param cmdline is a unix shell script
* @param mode can be:
* - `"r"` for reading from subprocess standard output
* - `"w"` for writing to subprocess standard input
* @raise EINVAL if `mode` is invalid or specifies read+write
* @raise EMFILE if process `RLIMIT_NOFILE` has been reached
* @raise ENFILE if system-wide file limit has been reached
* @raise ECANCELED if thread was cancelled in masked mode
* @raise ENOMEM if we require more vespene gas
* @raise EAGAIN if `RLIMIT_NPROC` was exceeded
* @raise EINTR if signal was delivered
* @cancellationpoint
* @threadsafe
*/
FILE *popen(const char *cmdline, const char *mode) {
FILE *f;
int e, rc, pid, dir, flags, pipefds[2];
flags = fopenflags(mode);
if ((flags & O_ACCMODE) == O_RDONLY) {
dir = 0;
} else if ((flags & O_ACCMODE) == O_WRONLY) {
dir = 1;
} else {
einval();
return NULL;
}
if (_weaken(pthread_testcancel_np) &&
(rc = _weaken(pthread_testcancel_np)())) {
errno = rc;
return 0;
}
if (pipe2(pipefds, O_CLOEXEC) == -1) return NULL;
if ((f = fdopen(pipefds[dir], mode))) {
switch ((pid = fork())) {
case 0:
_unassert(dup2(pipefds[!dir], !dir) == !dir);
// we can't rely on cloexec because cocmd builtins don't execve
if (pipefds[0] != !dir) _unassert(!close(pipefds[0]));
if (pipefds[1] != !dir) _unassert(!close(pipefds[1]));
_Exit(_cocmd(3, (char *[]){"popen", "-c", cmdline, 0}, environ));
default:
f->pid = pid;
_unassert(!close(pipefds[!dir]));
return f;
case -1:
e = errno;
_unassert(!fclose(f));
_unassert(!close(pipefds[!dir]));
errno = e;
return NULL;
}
} else {
e = errno;
_unassert(!close(pipefds[0]));
_unassert(!close(pipefds[1]));
errno = e;
return NULL;
}
}
| 4,334 | 100 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/lcg.internal.h | #ifndef COSMOPOLITAN_LIBC_LCG_H_
#define COSMOPOLITAN_LIBC_LCG_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
forceinline uint64_t KnuthLinearCongruentialGenerator(uint64_t prev[1]) {
/* Knuth, D.E., "The Art of Computer Programming," Vol 2,
Seminumerical Algorithms, Third Edition, Addison-Wesley, 1998,
p. 106 (line 26) & p. 108 */
prev[0] = prev[0] * 6364136223846793005 + 1442695040888963407;
return prev[0]; /* be sure to shift! */
}
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_LCG_H_ */
| 536 | 15 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/xorshift64.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/xorshift.h"
uint64_t MarsagliaXorshift64(uint64_t state[hasatleast 1]) {
uint64_t x = state[0];
x ^= x << 13;
x ^= x >> 7;
x ^= x << 17;
state[0] = x;
return x;
}
| 2,033 | 29 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fread_unlocked.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=8 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/calls/struct/iovec.h"
#include "libc/errno.h"
#include "libc/fmt/conv.h"
#include "libc/macros.internal.h"
#include "libc/runtime/runtime.h"
#include "libc/sock/sock.h"
#include "libc/stdio/internal.h"
#include "libc/stdio/stdio.h"
#include "libc/str/internal.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/o.h"
#include "libc/sysv/errfuns.h"
/**
* Reads data from stream.
*
* @param stride specifies the size of individual items
* @param count is the number of strides to fetch
* @return count on success, [0,count) on eof, or 0 on error or count==0
*/
size_t fread_unlocked(void *buf, size_t stride, size_t count, FILE *f) {
char *p;
ssize_t rc;
size_t n, m;
struct iovec iov[2];
if (f->state) {
return 0;
}
if ((f->iomode & O_ACCMODE) == O_WRONLY) {
f->state = errno = EBADF;
return 0;
}
if (f->beg > f->end) {
f->state = errno = EINVAL;
return 0;
}
if (__builtin_mul_overflow(stride, count, &n)) {
f->state = errno = EOVERFLOW;
return 0;
}
p = buf;
m = f->end - f->beg;
if (MIN(n, m)) {
memcpy(p, f->buf + f->beg, MIN(n, m));
}
if (n < m) {
f->beg += n;
return count;
}
if (n == m) {
f->beg = f->end = 0;
return count;
}
if (f->fd == -1) {
f->beg = 0;
f->end = 0;
f->state = -1;
return m / stride;
}
iov[0].iov_base = p + m;
iov[0].iov_len = n - m;
if (f->bufmode != _IONBF && n < f->size) {
iov[1].iov_base = f->buf;
if (f->size > PUSHBACK) {
iov[1].iov_len = f->size - PUSHBACK;
} else {
iov[1].iov_len = f->size;
}
} else {
iov[1].iov_base = NULL;
iov[1].iov_len = 0;
}
if ((rc = readv(f->fd, iov, 2)) == -1) {
f->state = errno;
return 0;
}
n = rc;
f->beg = 0;
f->end = 0;
if (n > iov[0].iov_len) {
f->end += n - iov[0].iov_len;
return count;
} else {
n = (m + n) / stride;
if (n < count) f->state = -1;
return n;
}
}
| 3,820 | 108 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/ftello.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/errno.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/internal.h"
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h"
#include "libc/sysv/consts/o.h"
static inline int64_t ftello_unlocked(FILE *f) {
int64_t pos;
uint32_t skew;
if (f->fd != -1) {
if (__fflush_impl(f) == -1) return -1;
if ((pos = lseek(f->fd, 0, SEEK_CUR)) != -1) {
if (f->beg < f->end) pos -= f->end - f->beg;
return pos;
} else {
f->state = errno == ESPIPE ? EBADF : errno;
return -1;
}
} else {
return f->beg;
}
}
/**
* Returns current position of stream.
*
* @param stream is a non-null stream handle
* @returns current byte offset from beginning, or -1 w/ errno
* @threadsafe
*/
int64_t ftello(FILE *f) {
int64_t rc;
flockfile(f);
rc = ftello_unlocked(f);
funlockfile(f);
return rc;
}
| 2,735 | 58 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/lock.internal.h | #ifndef COSMOPOLITAN_LIBC_STDIO_LOCK_H_
#define COSMOPOLITAN_LIBC_STDIO_LOCK_H_
#include "libc/intrin/nopl.internal.h"
#include "libc/stdio/stdio.h"
#include "libc/thread/tls.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
#ifdef _NOPL1
#define flockfile(f) _NOPL1("__threadcalls", flockfile, f)
#define funlockfile(f) _NOPL1("__threadcalls", funlockfile, f)
#define ftrylockfile(f) _NOPL1("__threadcalls", ftrylockfile, f)
#else
#define flockfile(f) (__threaded ? flockfile(f) : 0)
#define funlockfile(f) (__threaded ? funlockfile(f) : 0)
#define ftrylockfile(f) (__threaded ? ftrylockfile(f) : 0)
#endif
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_STDIO_LOCK_H_ */
| 743 | 22 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fmemopen.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/intrin/weaken.h"
#include "libc/mem/mem.h"
#include "libc/stdio/internal.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/o.h"
#include "libc/sysv/errfuns.h"
#include "libc/thread/thread.h"
// TODO(jart): POSIX says buffer needs to grow in write modes?
/**
* Opens buffer as stream.
*
* @param buf becomes owned by this function, and is allocated if NULL
* @return new stream or NULL w/ errno
* @raise ENOMEM if `buf` is NULL and we failed to allocate it
* @raise ENOMEM if `buf` is NULL and malloc() wasn't linked
* @raise EINVAL if `buf` is NULL when `+` isn't in `mode`
*/
FILE *fmemopen(void *buf, size_t size, const char *mode) {
FILE *f;
char *p;
int iomode;
unsigned flags;
iomode = fopenflags(mode);
if ((size && size > 0x7ffff000) || //
(!buf && (iomode & O_ACCMODE) != O_RDWR)) {
einval();
return NULL;
}
if (!(f = __stdio_alloc())) {
return NULL;
}
if (buf) {
f->nofree = true;
} else {
if (!size) size = BUFSIZ;
// TODO(jart): Why do we need calloc()?
if (!_weaken(calloc) || !(buf = _weaken(calloc)(1, size))) {
__stdio_free(f);
enomem();
return NULL;
}
}
f->fd = -1;
f->buf = buf;
f->end = size;
f->size = size;
f->iomode = iomode;
if (iomode & O_APPEND) {
if ((p = memchr(buf, '\0', size))) {
f->beg = p - (char *)buf;
} else {
f->beg = f->end;
}
}
return f;
}
| 3,295 | 78 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/scanf.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/stdio/stdio.h"
/**
* Standard input decoder.
* @see libc/fmt/vcscanf.h
*/
int(scanf)(const char *fmt, ...) {
int rc;
va_list va;
va_start(va, fmt);
rc = (vcscanf)((int (*)(void *))fgetc, NULL, stdin, fmt, va);
va_end(va);
return rc;
}
| 2,128 | 34 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fprintf.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=8 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/lock.internal.h"
#include "libc/stdio/stdio.h"
/**
* Formats and writes text to stream.
* @see printf() for further documentation
*/
int(fprintf)(FILE *f, const char *fmt, ...) {
int rc;
va_list va;
flockfile(f);
va_start(va, fmt);
rc = (vfprintf_unlocked)(f, fmt, va);
va_end(va);
funlockfile(f);
return rc;
}
| 2,188 | 36 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/tmpfile.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/stdio/stdio.h"
#include "libc/stdio/temp.h"
/**
* Opens stream backed by anonymous file, e.g.
*
* FILE *f;
* if (!(f = tmpfile())) {
* perror("tmpfile");
* exit(1);
* }
* // do stuff
* fclose(f);
*
* This creates a secure temporary file inside $TMPDIR. If it isn't
* defined, then /tmp is used on UNIX and GetTempPath() is used on the
* New Technology. This resolution of $TMPDIR happens once in a ctor,
* which is copied to the `kTmpDir` global.
*
* Once fclose() is called, the returned file is guaranteed to be
* deleted automatically. On UNIX the file is unlink()'d before this
* function returns. On the New Technology it happens upon fclose().
*
* On newer Linux only (c. 2013) it's possible to turn the anonymous
* returned file back into a real file, by doing this:
*
* linkat(AT_FDCWD, _gc(xasprintf("/proc/self/fd/%d", fileno(f))),
* AT_FDCWD, "real.txt", AT_SYMLINK_FOLLOW)
*
* On the New Technology, temporary files created by this function
* should have better performance, because `kNtFileAttributeTemporary`
* asks the kernel to more aggressively cache and reduce i/o ops.
*
* Favor tmpfd() or tmpfile() over `open(O_TMPFILE)` because the latter
* is Linux-only and will cause open() failures on all other platforms.
*
* @see tmpfd() if you don't want to link stdio/malloc
* @raise ECANCELED if thread was cancelled in masked mode
* @raise EINTR if signal was delivered
* @cancellationpoint
* @asyncsignalsafe
* @threadsafe
* @vforksafe
*/
FILE *tmpfile(void) {
int fd;
FILE *f;
if ((fd = tmpfd()) != -1) {
if ((f = fdopen(fd, "w+"))) {
return f;
} else {
close(fd);
return 0;
}
} else {
return 0;
}
}
| 3,630 | 78 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/alloc.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/intrin/atomic.h"
#include "libc/intrin/kmalloc.h"
#include "libc/stdio/internal.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
#include "libc/thread/thread.h"
static _Atomic(FILE *) __stdio_freelist;
FILE *__stdio_alloc(void) {
FILE *f;
f = atomic_load_explicit(&__stdio_freelist, memory_order_acquire);
while (f) {
if (atomic_compare_exchange_weak_explicit(
&__stdio_freelist, &f,
atomic_load_explicit((_Atomic(struct FILE *) *)&f->next,
memory_order_acquire),
memory_order_release, memory_order_relaxed)) {
atomic_store_explicit((_Atomic(struct FILE *) *)&f->next, 0,
memory_order_release);
break;
}
}
if (!f) {
f = kmalloc(sizeof(FILE));
}
if (f) {
((pthread_mutex_t *)f->lock)->_type = PTHREAD_MUTEX_RECURSIVE;
}
return f;
}
void __stdio_free(FILE *f) {
FILE *g;
bzero(f, sizeof(*f));
g = atomic_load_explicit(&__stdio_freelist, memory_order_acquire);
for (;;) {
atomic_store_explicit((_Atomic(struct FILE *) *)&f->next, g,
memory_order_release);
if (atomic_compare_exchange_weak_explicit(&__stdio_freelist, &g, f,
memory_order_release,
memory_order_relaxed)) {
break;
}
}
}
| 3,234 | 65 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/vappendf.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/assert.h"
#include "libc/dce.h"
#include "libc/fmt/fmt.h"
#include "libc/macros.internal.h"
#include "libc/mem/mem.h"
#include "libc/stdio/append.h"
#define W sizeof(size_t)
/**
* Appends formatted string to buffer.
*/
ssize_t(vappendf)(char **b, const char *f, va_list v) {
char *p;
int r, s;
size_t n;
va_list w;
struct appendz z;
z = appendz((p = *b));
va_copy(w, v);
if ((r = (vsnprintf)(p + z.i, z.n ? z.n - W - z.i : 0, f, v)) >= 0) {
n = ROUNDUP(z.i + r + 1, 8) + W;
if (n > z.n) {
if (!z.n) z.n = W * 2;
while (n > z.n) z.n += z.n >> 1;
z.n = ROUNDUP(z.n, W);
if ((p = realloc(p, z.n))) {
z.n = malloc_usable_size(p);
_unassert(!(z.n & (W - 1)));
s = (vsnprintf)(p + z.i, z.n - W - z.i, f, w);
_unassert(s == r);
*b = p;
} else {
va_end(w);
return -1;
}
}
z.i += r;
if (!IsTiny() && W == 8) z.i |= (size_t)APPEND_COOKIE << 48;
*(size_t *)(p + z.n - W) = z.i;
}
va_end(w);
return r;
}
| 2,885 | 63 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/getwc_unlocked.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"
/**
* Reads UTF-8 character from stream.
* @return wide character or -1 on EOF or error
*/
wint_t(getwc_unlocked)(FILE *f) {
return fgetwc_unlocked(f);
}
| 2,026 | 28 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/posix_spawn_file_actions.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/errno.h"
#include "libc/fmt/fmt.h"
#include "libc/mem/mem.h"
#include "libc/stdio/posix_spawn.h"
#include "libc/stdio/posix_spawn.internal.h"
#include "libc/str/str.h"
static int AddFileAction(posix_spawn_file_actions_t *l,
struct _posix_faction a) {
struct _posix_faction *ap;
if (!(ap = malloc(sizeof(*ap)))) return ENOMEM;
a.next = *l;
*ap = a;
*l = ap;
return 0;
}
/**
* Initializes posix_spawn() file actions list.
*
* @param file_actions will need posix_spawn_file_actions_destroy()
* @return 0 on success, or errno on error
*/
int posix_spawn_file_actions_init(posix_spawn_file_actions_t *file_actions) {
*file_actions = 0;
return 0;
}
/**
* Destroys posix_spawn() file actions list.
*
* This function is safe to call multiple times.
*
* @param file_actions was initialized by posix_spawn_file_actions_init()
* @return 0 on success, or errno on error
*/
int posix_spawn_file_actions_destroy(posix_spawn_file_actions_t *file_actions) {
if (*file_actions) {
posix_spawn_file_actions_destroy(&(*file_actions)->next);
free((*file_actions)->path);
free(*file_actions);
*file_actions = 0;
}
return 0;
}
/**
* Add a close action to object.
*
* @param file_actions was initialized by posix_spawn_file_actions_init()
* @return 0 on success, or errno on error
* @raise ENOMEM if we require more vespene gas
*/
int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *file_actions,
int fildes) {
return AddFileAction(file_actions, (struct _posix_faction){
.action = _POSIX_SPAWN_CLOSE,
.fildes = fildes,
});
}
/**
* Add a dup2 action to object.
*
* @param file_actions was initialized by posix_spawn_file_actions_init()
* @return 0 on success, or errno on error
* @raise ENOMEM if we require more vespene gas
*/
int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *file_actions,
int fildes, int newfildes) {
return AddFileAction(file_actions, (struct _posix_faction){
.action = _POSIX_SPAWN_DUP2,
.fildes = fildes,
.newfildes = newfildes,
});
}
/**
* Add an open action to object.
*
* @param file_actions was initialized by posix_spawn_file_actions_init()
* @param filedes is what open() result gets duplicated to
* @param path will be safely copied
* @return 0 on success, or errno on error
* @raise ENOMEM if we require more vespene gas
*/
int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t *file_actions,
int fildes, const char *path, int oflag,
unsigned mode) {
if (!(path = strdup(path))) return ENOMEM;
return AddFileAction(file_actions, (struct _posix_faction){
.action = _POSIX_SPAWN_OPEN,
.fildes = fildes,
.path = path,
.oflag = oflag,
.mode = mode,
});
}
| 5,226 | 117 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fputws.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/lock.internal.h"
#include "libc/stdio/stdio.h"
/**
* Writes wide character string to stream.
*
* Writing stops at the NUL-terminator, which isn't included in output.
* This function blocks until the full string is written, unless an
* unrecoverable error happens.
*
* @param s is a NUL-terminated string that's non-NULL
* @param f is an open stream
* @return strlen(s), or -1 w/ errno
* @threadsafe
*/
int fputws(const wchar_t *s, FILE *f) {
int rc;
flockfile(f);
rc = fputws_unlocked(s, f);
funlockfile(f);
return rc;
}
| 2,400 | 41 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/flockfile.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/lock.internal.h"
#include "libc/stdio/stdio.h"
#include "libc/thread/thread.h"
/**
* Acquires reentrant lock on stdio object, blocking if needed.
*/
void(flockfile)(FILE *f) {
pthread_mutex_lock((pthread_mutex_t *)f->lock);
}
| 2,088 | 29 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/freadable.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_ext.h"
#include "libc/sysv/consts/o.h"
/**
* Returns nonzero if stream allows reading.
*/
int __freadable(FILE *f) {
return (f->iomode & O_ACCMODE) == O_RDONLY ||
(f->iomode & O_ACCMODE) == O_RDWR;
}
| 2,077 | 29 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/rdrand_init.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/kcpuids.h"
#include "libc/nexgen32e/vendor.internal.h"
#include "libc/nexgen32e/x86feature.h"
#include "libc/nexgen32e/x86info.h"
#include "libc/stdio/rand.h"
textstartup void rdrand_init(int argc, char **argv, char **envp,
intptr_t *auxv) {
extern unsigned kMutableCpuids[KCPUIDS_LEN][4] asm("kCpuids");
/*
* Clear RDRAND on AMD models before Zen and then some
* since it's not only slow but can freeze after sleep
* https://bugzilla.redhat.com/show_bug.cgi?id=1150286
*/
if ((X86_HAVE(RDRND) || X86_HAVE(RDSEED)) &&
(IsAuthenticAMD() &&
(kX86CpuFamily < 0x17 ||
(kX86CpuFamily == 0x17 &&
(0x70 <= kX86CpuModel && kX86CpuModel <= 0x7F))))) {
kMutableCpuids[KCPUIDS_1H][KCPUIDS_ECX] &= ~(1u << 30);
kMutableCpuids[KCPUIDS_7H][KCPUIDS_EBX] &= ~(1u << 18);
}
}
const void *const g_rdrand_init[] initarray = {rdrand_init};
| 2,770 | 44 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/ksc.inc | 12288,12289,12290,183,8229,8230,168,12291,173,8213,8741,65340,8764,8216,8217,
8220,8221,12308,12309,12296,12297,12298,12299,12300,12301,12302,12303,12304,
12305,177,215,247,8800,8804,8805,8734,8756,176,8242,8243,8451,8491,65504,
65505,65509,9794,9792,8736,8869,8978,8706,8711,8801,8786,167,8251,9734,9733,
9675,9679,9678,9671,9670,9633,9632,9651,9650,9661,9660,8594,8592,8593,8595,
8596,12307,8810,8811,8730,8765,8733,8757,8747,8748,8712,8715,8838,8839,8834,
8835,8746,8745,8743,8744,65506,8658,8660,8704,8707,180,65374,711,728,733,730,
729,184,731,161,191,720,8750,8721,8719,164,8457,8240,9665,9664,9655,9654,9828,
9824,9825,9829,9831,9827,8857,9672,9635,9680,9681,9618,9636,9637,9640,9639,
9638,9641,9832,9743,9742,9756,9758,182,8224,8225,8597,8599,8601,8598,8600,
9837,9833,9834,9836,12927,12828,8470,13255,8482,13250,13272,8481,8364,174,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,65281,65282,65283,65284,65285,65286,
65287,65288,65289,65290,65291,65292,65293,65294,65295,65296,65297,65298,65299,
65300,65301,65302,65303,65304,65305,65306,65307,65308,65309,65310,65311,65312,
65313,65314,65315,65316,65317,65318,65319,65320,65321,65322,65323,65324,65325,
65326,65327,65328,65329,65330,65331,65332,65333,65334,65335,65336,65337,65338,
65339,65510,65341,65342,65343,65344,65345,65346,65347,
65348,65349,65350,65351,65352,65353,65354,65355,65356,65357,65358,65359,65360,
65361,65362,65363,65364,65365,65366,65367,65368,65369,65370,65371,65372,65373,
65507,12593,12594,12595,12596,12597,12598,12599,12600,12601,12602,12603,12604,
12605,12606,12607,12608,12609,12610,12611,12612,12613,12614,12615,12616,12617,
12618,12619,12620,12621,12622,12623,12624,12625,12626,12627,12628,12629,12630,
12631,12632,12633,12634,12635,12636,12637,12638,12639,12640,12641,12642,12643,
12644,12645,12646,12647,12648,12649,12650,12651,12652,12653,12654,12655,12656,
12657,12658,12659,12660,12661,12662,12663,12664,12665,12666,12667,12668,12669,
12670,12671,12672,12673,12674,12675,12676,12677,12678,12679,12680,12681,12682,
12683,12684,12685,12686,8560,8561,8562,8563,8564,8565,8566,8567,8568,8569,0,0,
0,0,0,8544,8545,8546,8547,8548,8549,8550,8551,8552,8553,0,0,0,0,0,0,0,913,914,
915,916,917,918,919,920,921,922,923,924,925,926,927,928,929,931,932,933,934,
935,936,937,0,0,0,0,0,0,0,0,945,946,947,948,949,950,951,952,953,954,955,956,
957,958,959,960,961,963,964,965,966,967,968,969,0,0,0,0,0,0,9472,9474,9484,
9488,9496,9492,9500,9516,9508,9524,9532,9473,9475,9487,9491,9499,9495,9507,
9523,9515,9531,9547,9504,9519,9512,9527,9535,9501,9520,9509,9528,9538,9490,
9489,9498,9497,9494,9493,9486,9485,9502,
9503,9505,9506,9510,9511,9513,9514,9517,9518,9521,9522,9525,9526,9529,9530,
9533,9534,9536,9537,9539,9540,9541,9542,9543,9544,9545,9546,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,13205,13206,13207,8467,13208,13252,13219,
13220,13221,13222,13209,13210,13211,13212,13213,13214,13215,13216,13217,13218,
13258,13197,13198,13199,13263,13192,13193,13256,13223,13224,13232,13233,13234,
13235,13236,13237,13238,13239,13240,13241,13184,13185,13186,13187,13188,13242,
13243,13244,13245,13246,13247,13200,13201,13202,13203,13204,8486,13248,13249,
13194,13195,13196,13270,13253,13229,13230,13231,13275,13225,13226,13227,13228,
13277,13264,13267,13251,13257,13276,13254,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,198,
208,170,294,0,306,0,319,321,216,338,186,222,358,330,0,12896,12897,12898,12899,
12900,12901,12902,12903,12904,12905,12906,12907,12908,12909,12910,12911,12912,
12913,12914,12915,12916,12917,12918,12919,12920,12921,12922,12923,9424,9425,
9426,9427,9428,9429,9430,9431,9432,9433,9434,9435,9436,9437,9438,9439,9440,
9441,9442,9443,9444,9445,9446,9447,9448,9449,9312,9313,9314,9315,9316,9317,
9318,9319,9320,9321,9322,9323,9324,9325,9326,189,8531,8532,188,190,8539,8540,
8541,8542,230,273,240,295,305,307,312,320,322,248,339,223,254,359,331,
329,12800,12801,12802,12803,12804,12805,12806,12807,12808,12809,12810,12811,
12812,12813,12814,12815,12816,12817,12818,12819,12820,12821,12822,12823,12824,
12825,12826,12827,9372,9373,9374,9375,9376,9377,9378,9379,9380,9381,9382,9383,
9384,9385,9386,9387,9388,9389,9390,9391,9392,9393,9394,9395,9396,9397,9332,
9333,9334,9335,9336,9337,9338,9339,9340,9341,9342,9343,9344,9345,9346,185,178,
179,8308,8319,8321,8322,8323,8324,12353,12354,12355,12356,12357,12358,12359,
12360,12361,12362,12363,12364,12365,12366,12367,12368,12369,12370,12371,12372,
12373,12374,12375,12376,12377,12378,12379,12380,12381,12382,12383,12384,12385,
12386,12387,12388,12389,12390,12391,12392,12393,12394,12395,12396,12397,12398,
12399,12400,12401,12402,12403,12404,12405,12406,12407,12408,12409,12410,12411,
12412,12413,12414,12415,12416,12417,12418,12419,12420,12421,12422,12423,12424,
12425,12426,12427,12428,12429,12430,12431,12432,12433,12434,12435,0,0,0,0,0,0,
0,0,0,0,0,12449,12450,12451,12452,12453,12454,12455,12456,12457,12458,12459,
12460,12461,12462,12463,12464,12465,12466,12467,12468,12469,12470,12471,12472,
12473,12474,12475,12476,12477,12478,12479,12480,12481,12482,12483,12484,12485,
12486,12487,12488,12489,12490,12491,12492,12493,12494,12495,12496,12497,12498,
12499,12500,12501,12502,12503,12504,12505,12506,12507,12508,12509,12510,12511,
12512,12513,12514,12515,12516,12517,12518,12519,12520,12521,12522,12523,12524,
12525,12526,12527,12528,12529,12530,12531,
12532,12533,12534,0,0,0,0,0,0,0,0,1040,1041,1042,1043,1044,1045,1025,1046,
1047,1048,1049,1050,1051,1052,1053,1054,1055,1056,1057,1058,1059,1060,1061,
1062,1063,1064,1065,1066,1067,1068,1069,1070,1071,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,1072,1073,1074,1075,1076,1077,1105,1078,1079,1080,1081,1082,1083,1084,1085,
1086,1087,1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,
1101,1102,1103,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,44032,44033,44036,44039,44040,44041,44042,44048,
44049,44050,44051,44052,44053,44054,44055,44057,44058,44059,44060,44061,44064,
44068,44076,44077,44079,44080,44081,44088,44089,44092,44096,44107,44109,44116,
44120,44124,44144,44145,44148,44151,44152,44154,44160,44161,44163,44164,44165,
44166,44169,44170,44171,44172,44176,44180,44188,44189,44191,44192,44193,44200,
44201,44202,44204,44207,44208,44216,44217,44219,44220,44221,44225,44228,44232,
44236,44245,44247,44256,44257,44260,44263,44264,44266,44268,44271,44272,44273,
44275,44277,44278,44284,44285,44288,44292,44294,44300,44301,44303,44305,44312,
44316,44320,44329,44332,44333,44340,44341,44344,44348,44356,44357,44359,44361,
44368,44372,44376,44385,44387,44396,44397,44400,44403,44404,44405,44406,44411,
44412,44413,44415,44417,44418,44424,44425,44428,44432,44444,44445,44452,44471,
44480,44481,44484,44488,44496,44497,44499,44508,44512,44516,44536,44537,44540,
44543,44544,44545,44552,44553,44555,44557,44564,44592,44593,44596,44599,44600,
44602,44608,44609,44611,44613,44614,44618,44620,44621,44622,44624,44628,44630,
44636,44637,44639,44640,44641,44645,44648,44649,44652,44656,44664,44665,44667,
44668,44669,44676,44677,44684,44732,44733,44734,44736,44740,44748,44749,44751,
44752,44753,44760,44761,44764,44776,44779,44781,44788,44792,44796,44807,44808,
44813,44816,44844,44845,44848,44850,44852,44860,44861,44863,44865,44866,44867,
44872,44873,44880,44892,44893,44900,44901,44921,44928,44932,44936,44944,44945,
44949,44956,44984,44985,44988,44992,44999,45000,45001,45003,45005,45006,45012,
45020,45032,45033,45040,45041,45044,45048,45056,45057,45060,45068,45072,45076,
45084,45085,45096,45124,45125,45128,45130,45132,45134,45139,45140,45141,45143,
45145,45149,45180,45181,45184,45188,45196,45197,45199,45201,45208,45209,45210,
45212,45215,45216,45217,45218,45224,45225,45227,45228,45229,45230,45231,45233,
45235,45236,45237,45240,45244,45252,45253,45255,45256,45257,45264,45265,45268,
45272,45280,45285,45320,45321,45323,45324,45328,45330,45331,45336,45337,45339,
45340,45341,45347,45348,45349,45352,45356,45364,45365,45367,45368,45369,45376,
45377,45380,45384,45392,45393,45396,45397,45400,45404,45408,45432,45433,45436,
45440,45442,45448,45449,45451,45453,45458,45459,45460,45464,45468,45480,45516,
45520,45524,45532,45533,45535,45544,45545,45548,45552,
45561,45563,45565,45572,45573,45576,45579,45580,45588,45589,45591,45593,45600,
45620,45628,45656,45660,45664,45672,45673,45684,45685,45692,45700,45701,45705,
45712,45713,45716,45720,45721,45722,45728,45729,45731,45733,45734,45738,45740,
45744,45748,45768,45769,45772,45776,45778,45784,45785,45787,45789,45794,45796,
45797,45798,45800,45803,45804,45805,45806,45807,45811,45812,45813,45815,45816,
45817,45818,45819,45823,45824,45825,45828,45832,45840,45841,45843,45844,45845,
45852,45908,45909,45910,45912,45915,45916,45918,45919,45924,45925,45927,45929,
45931,45934,45936,45937,45940,45944,45952,45953,45955,45956,45957,45964,45968,
45972,45984,45985,45992,45996,46020,46021,46024,46027,46028,46030,46032,46036,
46037,46039,46041,46043,46045,46048,46052,46056,46076,46096,46104,46108,46112,
46120,46121,46123,46132,46160,46161,46164,46168,46176,46177,46179,46181,46188,
46208,46216,46237,46244,46248,46252,46261,46263,46265,46272,46276,46280,46288,
46293,46300,46301,46304,46307,46308,46310,46316,46317,46319,46321,46328,46356,
46357,46360,46363,46364,46372,46373,46375,46376,46377,46378,46384,46385,46388,
46392,46400,46401,46403,46404,46405,46411,46412,46413,46416,46420,46428,46429,
46431,46432,46433,46496,46497,46500,46504,46506,46507,46512,46513,46515,46516,
46517,46523,46524,46525,46528,46532,46540,46541,46543,46544,46545,46552,46572,
46608,46609,46612,46616,46629,46636,46644,46664,46692,46696,46748,46749,46752,
46756,46763,46764,46769,46804,46832,46836,46840,46848,46849,46853,46888,46889,
46892,46895,46896,46904,46905,46907,46916,46920,46924,
46932,46933,46944,46948,46952,46960,46961,46963,46965,46972,46973,46976,46980,
46988,46989,46991,46992,46993,46994,46998,46999,47000,47001,47004,47008,47016,
47017,47019,47020,47021,47028,47029,47032,47047,47049,47084,47085,47088,47092,
47100,47101,47103,47104,47105,47111,47112,47113,47116,47120,47128,47129,47131,
47133,47140,47141,47144,47148,47156,47157,47159,47160,47161,47168,47172,47185,
47187,47196,47197,47200,47204,47212,47213,47215,47217,47224,47228,47245,47272,
47280,47284,47288,47296,47297,47299,47301,47308,47312,47316,47325,47327,47329,
47336,47337,47340,47344,47352,47353,47355,47357,47364,47384,47392,47420,47421,
47424,47428,47436,47439,47441,47448,47449,47452,47456,47464,47465,47467,47469,
47476,47477,47480,47484,47492,47493,47495,47497,47498,47501,47502,47532,47533,
47536,47540,47548,47549,47551,47553,47560,47561,47564,47566,47567,47568,47569,
47570,47576,47577,47579,47581,47582,47585,47587,47588,47589,47592,47596,47604,
47605,47607,47608,47609,47610,47616,47617,47624,47637,47672,47673,47676,47680,
47682,47688,47689,47691,47693,47694,47699,47700,47701,47704,47708,47716,47717,
47719,47720,47721,47728,47729,47732,47736,47747,47748,47749,47751,47756,47784,
47785,47787,47788,47792,47794,47800,47801,47803,47805,47812,47816,47832,47833,
47868,47872,47876,47885,47887,47889,47896,47900,47904,47913,47915,47924,47925,
47926,47928,47931,47932,47933,47934,47940,47941,47943,47945,47949,47951,47952,
47956,47960,47969,47971,47980,48008,48012,48016,48036,48040,48044,48052,48055,
48064,48068,48072,48080,48083,48120,48121,48124,48127,
48128,48130,48136,48137,48139,48140,48141,48143,48145,48148,48149,48150,48151,
48152,48155,48156,48157,48158,48159,48164,48165,48167,48169,48173,48176,48177,
48180,48184,48192,48193,48195,48196,48197,48201,48204,48205,48208,48221,48260,
48261,48264,48267,48268,48270,48276,48277,48279,48281,48282,48288,48289,48292,
48295,48296,48304,48305,48307,48308,48309,48316,48317,48320,48324,48333,48335,
48336,48337,48341,48344,48348,48372,48373,48374,48376,48380,48388,48389,48391,
48393,48400,48404,48420,48428,48448,48456,48457,48460,48464,48472,48473,48484,
48488,48512,48513,48516,48519,48520,48521,48522,48528,48529,48531,48533,48537,
48538,48540,48548,48560,48568,48596,48597,48600,48604,48617,48624,48628,48632,
48640,48643,48645,48652,48653,48656,48660,48668,48669,48671,48708,48709,48712,
48716,48718,48724,48725,48727,48729,48730,48731,48736,48737,48740,48744,48746,
48752,48753,48755,48756,48757,48763,48764,48765,48768,48772,48780,48781,48783,
48784,48785,48792,48793,48808,48848,48849,48852,48855,48856,48864,48867,48868,
48869,48876,48897,48904,48905,48920,48921,48923,48924,48925,48960,48961,48964,
48968,48976,48977,48981,49044,49072,49093,49100,49101,49104,49108,49116,49119,
49121,49212,49233,49240,49244,49248,49256,49257,49296,49297,49300,49304,49312,
49313,49315,49317,49324,49325,49327,49328,49331,49332,49333,49334,49340,49341,
49343,49344,49345,49349,49352,49353,49356,49360,49368,49369,49371,49372,49373,
49380,49381,49384,49388,49396,49397,49399,49401,49408,49412,49416,49424,49429,
49436,49437,49438,49439,49440,49443,49444,49446,49447,
49452,49453,49455,49456,49457,49462,49464,49465,49468,49472,49480,49481,49483,
49484,49485,49492,49493,49496,49500,49508,49509,49511,49512,49513,49520,49524,
49528,49541,49548,49549,49550,49552,49556,49558,49564,49565,49567,49569,49573,
49576,49577,49580,49584,49597,49604,49608,49612,49620,49623,49624,49632,49636,
49640,49648,49649,49651,49660,49661,49664,49668,49676,49677,49679,49681,49688,
49689,49692,49695,49696,49704,49705,49707,49709,49711,49713,49714,49716,49736,
49744,49745,49748,49752,49760,49765,49772,49773,49776,49780,49788,49789,49791,
49793,49800,49801,49808,49816,49819,49821,49828,49829,49832,49836,49837,49844,
49845,49847,49849,49884,49885,49888,49891,49892,49899,49900,49901,49903,49905,
49910,49912,49913,49915,49916,49920,49928,49929,49932,49933,49939,49940,49941,
49944,49948,49956,49957,49960,49961,49989,50024,50025,50028,50032,50034,50040,
50041,50044,50045,50052,50056,50060,50112,50136,50137,50140,50143,50144,50146,
50152,50153,50157,50164,50165,50168,50184,50192,50212,50220,50224,50228,50236,
50237,50248,50276,50277,50280,50284,50292,50293,50297,50304,50324,50332,50360,
50364,50409,50416,50417,50420,50424,50426,50431,50432,50433,50444,50448,50452,
50460,50472,50473,50476,50480,50488,50489,50491,50493,50500,50501,50504,50505,
50506,50508,50509,50510,50515,50516,50517,50519,50520,50521,50525,50526,50528,
50529,50532,50536,50544,50545,50547,50548,50549,50556,50557,50560,50564,50567,
50572,50573,50575,50577,50581,50583,50584,50588,50592,50601,50612,50613,50616,
50617,50619,50620,50621,50622,50628,50629,50630,50631,
50632,50633,50634,50636,50638,50640,50641,50644,50648,50656,50657,50659,50661,
50668,50669,50670,50672,50676,50678,50679,50684,50685,50686,50687,50688,50689,
50693,50694,50695,50696,50700,50704,50712,50713,50715,50716,50724,50725,50728,
50732,50733,50734,50736,50739,50740,50741,50743,50745,50747,50752,50753,50756,
50760,50768,50769,50771,50772,50773,50780,50781,50784,50796,50799,50801,50808,
50809,50812,50816,50824,50825,50827,50829,50836,50837,50840,50844,50852,50853,
50855,50857,50864,50865,50868,50872,50873,50874,50880,50881,50883,50885,50892,
50893,50896,50900,50908,50909,50912,50913,50920,50921,50924,50928,50936,50937,
50941,50948,50949,50952,50956,50964,50965,50967,50969,50976,50977,50980,50984,
50992,50993,50995,50997,50999,51004,51005,51008,51012,51018,51020,51021,51023,
51025,51026,51027,51028,51029,51030,51031,51032,51036,51040,51048,51051,51060,
51061,51064,51068,51069,51070,51075,51076,51077,51079,51080,51081,51082,51086,
51088,51089,51092,51094,51095,51096,51098,51104,51105,51107,51108,51109,51110,
51116,51117,51120,51124,51132,51133,51135,51136,51137,51144,51145,51148,51150,
51152,51160,51165,51172,51176,51180,51200,51201,51204,51208,51210,51216,51217,
51219,51221,51222,51228,51229,51232,51236,51244,51245,51247,51249,51256,51260,
51264,51272,51273,51276,51277,51284,51312,51313,51316,51320,51322,51328,51329,
51331,51333,51334,51335,51339,51340,51341,51348,51357,51359,51361,51368,51388,
51389,51396,51400,51404,51412,51413,51415,51417,51424,51425,51428,51445,51452,
51453,51456,51460,51461,51462,51468,51469,51471,51473,
51480,51500,51508,51536,51537,51540,51544,51552,51553,51555,51564,51568,51572,
51580,51592,51593,51596,51600,51608,51609,51611,51613,51648,51649,51652,51655,
51656,51658,51664,51665,51667,51669,51670,51673,51674,51676,51677,51680,51682,
51684,51687,51692,51693,51695,51696,51697,51704,51705,51708,51712,51720,51721,
51723,51724,51725,51732,51736,51753,51788,51789,51792,51796,51804,51805,51807,
51808,51809,51816,51837,51844,51864,51900,51901,51904,51908,51916,51917,51919,
51921,51923,51928,51929,51936,51948,51956,51976,51984,51988,51992,52000,52001,
52033,52040,52041,52044,52048,52056,52057,52061,52068,52088,52089,52124,52152,
52180,52196,52199,52201,52236,52237,52240,52244,52252,52253,52257,52258,52263,
52264,52265,52268,52270,52272,52280,52281,52283,52284,52285,52286,52292,52293,
52296,52300,52308,52309,52311,52312,52313,52320,52324,52326,52328,52336,52341,
52376,52377,52380,52384,52392,52393,52395,52396,52397,52404,52405,52408,52412,
52420,52421,52423,52425,52432,52436,52452,52460,52464,52481,52488,52489,52492,
52496,52504,52505,52507,52509,52516,52520,52524,52537,52572,52576,52580,52588,
52589,52591,52593,52600,52616,52628,52629,52632,52636,52644,52645,52647,52649,
52656,52676,52684,52688,52712,52716,52720,52728,52729,52731,52733,52740,52744,
52748,52756,52761,52768,52769,52772,52776,52784,52785,52787,52789,52824,52825,
52828,52831,52832,52833,52840,52841,52843,52845,52852,52853,52856,52860,52868,
52869,52871,52873,52880,52881,52884,52888,52896,52897,52899,52900,52901,52908,
52909,52929,52964,52965,52968,52971,52972,52980,52981,
52983,52984,52985,52992,52993,52996,53000,53008,53009,53011,53013,53020,53024,
53028,53036,53037,53039,53040,53041,53048,53076,53077,53080,53084,53092,53093,
53095,53097,53104,53105,53108,53112,53120,53125,53132,53153,53160,53168,53188,
53216,53217,53220,53224,53232,53233,53235,53237,53244,53248,53252,53265,53272,
53293,53300,53301,53304,53308,53316,53317,53319,53321,53328,53332,53336,53344,
53356,53357,53360,53364,53372,53373,53377,53412,53413,53416,53420,53428,53429,
53431,53433,53440,53441,53444,53448,53449,53456,53457,53459,53460,53461,53468,
53469,53472,53476,53484,53485,53487,53488,53489,53496,53517,53552,53553,53556,
53560,53562,53568,53569,53571,53572,53573,53580,53581,53584,53588,53596,53597,
53599,53601,53608,53612,53628,53636,53640,53664,53665,53668,53672,53680,53681,
53683,53685,53690,53692,53696,53720,53748,53752,53767,53769,53776,53804,53805,
53808,53812,53820,53821,53823,53825,53832,53852,53860,53888,53889,53892,53896,
53904,53905,53909,53916,53920,53924,53932,53937,53944,53945,53948,53951,53952,
53954,53960,53961,53963,53972,53976,53980,53988,53989,54000,54001,54004,54008,
54016,54017,54019,54021,54028,54029,54030,54032,54036,54038,54044,54045,54047,
54048,54049,54053,54056,54057,54060,54064,54072,54073,54075,54076,54077,54084,
54085,54140,54141,54144,54148,54156,54157,54159,54160,54161,54168,54169,54172,
54176,54184,54185,54187,54189,54196,54200,54204,54212,54213,54216,54217,54224,
54232,54241,54243,54252,54253,54256,54260,54268,54269,54271,54273,54280,54301,
54336,54340,54364,54368,54372,54381,54383,54392,54393,
54396,54399,54400,54402,54408,54409,54411,54413,54420,54441,54476,54480,54484,
54492,54495,54504,54508,54512,54520,54523,54525,54532,54536,54540,54548,54549,
54551,54588,54589,54592,54596,54604,54605,54607,54609,54616,54617,54620,54624,
54629,54632,54633,54635,54637,54644,54645,54648,54652,54660,54661,54663,54664,
54665,54672,54693,54728,54729,54732,54736,54738,54744,54745,54747,54749,54756,
54757,54760,54764,54772,54773,54775,54777,54784,54785,54788,54792,54800,54801,
54803,54804,54805,54812,54816,54820,54829,54840,54841,54844,54848,54853,54856,
54857,54859,54861,54865,54868,54869,54872,54876,54887,54889,54896,54897,54900,
54915,54917,54924,54925,54928,54932,54941,54943,54945,54952,54956,54960,54969,
54971,54980,54981,54984,54988,54993,54996,54999,55001,55008,55012,55016,55024,
55029,55036,55037,55040,55044,55057,55064,55065,55068,55072,55080,55081,55083,
55085,55092,55093,55096,55100,55108,55111,55113,55120,55121,55124,55126,55127,
55128,55129,55136,55137,55139,55141,55145,55148,55152,55156,55164,55165,55169,
55176,55177,55180,55184,55192,55193,55195,55197,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,20285,20339,20551,20729,21152,21487,21621,21733,
22025,23233,23478,26247,26550,26551,26607,27468,29634,30146,31292,33499,33540,
34903,34952,35382,36040,36303,36603,36838,39381,21051,21364,21508,24682,24932,
27580,29647,33050,35258,35282,38307,20355,21002,22718,22904,23014,24178,24185,
25031,25536,26438,26604,26751,28567,30286,30475,30965,31240,31487,31777,32925,
33390,33393,35563,38291,20075,21917,26359,28212,30883,31469,33883,35088,34638,
38824,21208,22350,22570,23884,24863,25022,25121,25954,26577,27204,28187,29976,
30131,30435,30640,32058,37039,37969,37970,40853,21283,23724,30002,32987,37440,
38296,21083,22536,23004,23713,23831,24247,24378,24394,24951,27743,30074,30086,
31968,32115,32177,32652,33108,33313,34193,35137,35611,37628,38477,40007,20171,
20215,20491,20977,22607,24887,24894,24936,25913,27114,28433,30117,30342,30422,
31623,33445,33995,63744,37799,38283,21888,23458,22353,63745,31923,32697,37301,
20520,21435,23621,24040,25298,25454,25818,25831,28192,28844,31067,36317,36382,
63746,36989,37445,37624,20094,20214,20581,24062,24314,24838,26967,33137,34388,
36423,37749,39467,20062,20625,26480,26688,20745,21133,21138,27298,30652,37392,
40660,21163,24623,36850,20552,25001,25581,25802,26684,27268,28608,33160,35233,
38548,22533,29309,29356,29956,32121,32365,32937,35211,35700,36963,40273,25225,
27770,28500,32080,32570,35363,20860,24906,31645,35609,37463,37772,20140,20435,
20510,20670,20742,21185,21197,21375,22384,22659,24218,24465,24950,25004,
25806,25964,26223,26299,26356,26775,28039,28805,28913,29855,29861,29898,30169,
30828,30956,31455,31478,32069,32147,32789,32831,33051,33686,35686,36629,36885,
37857,38915,38968,39514,39912,20418,21843,22586,22865,23395,23622,24760,25106,
26690,26800,26856,28330,30028,30328,30926,31293,31995,32363,32380,35336,35489,
35903,38542,40388,21476,21481,21578,21617,22266,22993,23396,23611,24235,25335,
25911,25925,25970,26272,26543,27073,27837,30204,30352,30590,31295,32660,32771,
32929,33167,33510,33533,33776,34241,34865,34996,35493,63747,36764,37678,38599,
39015,39640,40723,21741,26011,26354,26767,31296,35895,40288,22256,22372,23825,
26118,26801,26829,28414,29736,34974,39908,27752,63748,39592,20379,20844,20849,
21151,23380,24037,24656,24685,25329,25511,25915,29657,31354,34467,36002,38799,
20018,23521,25096,26524,29916,31185,33747,35463,35506,36328,36942,37707,38982,
24275,27112,34303,37101,63749,20896,23448,23532,24931,26874,27454,28748,29743,
29912,31649,32592,33733,35264,36011,38364,39208,21038,24669,25324,36866,20362,
20809,21281,22745,24291,26336,27960,28826,29378,29654,31568,33009,37979,21350,
25499,32619,20054,20608,22602,22750,24618,24871,25296,27088,39745,23439,32024,
32945,36703,20132,20689,21676,21932,23308,23968,24039,25898,25934,26657,27211,
29409,30350,30703,32094,32761,33184,34126,34527,36611,36686,37066,39171,39509,
39851,19992,20037,20061,20167,20465,20855,21246,21312,21475,21477,21646,22036,
22389,22434,23495,23943,24272,25084,25304,25937,26552,26601,27083,27472,27590,
27628,27714,28317,28792,29399,29590,29699,30655,30697,
31350,32127,32777,33276,33285,33290,33503,34914,35635,36092,36544,36881,37041,
37476,37558,39378,39493,40169,40407,40860,22283,23616,33738,38816,38827,40628,
21531,31384,32676,35033,36557,37089,22528,23624,25496,31391,23470,24339,31353,
31406,33422,36524,20518,21048,21240,21367,22280,25331,25458,27402,28099,30519,
21413,29527,34152,36470,38357,26426,27331,28528,35437,36556,39243,63750,26231,
27512,36020,39740,63751,21483,22317,22862,25542,27131,29674,30789,31418,31429,
31998,33909,35215,36211,36917,38312,21243,22343,30023,31584,33740,37406,63752,
27224,20811,21067,21127,25119,26840,26997,38553,20677,21156,21220,25027,26020,
26681,27135,29822,31563,33465,33771,35250,35641,36817,39241,63753,20170,22935,
25810,26129,27278,29748,31105,31165,33449,34942,34943,35167,63754,37670,20235,
21450,24613,25201,27762,32026,32102,20120,20834,30684,32943,20225,20238,20854,
20864,21980,22120,22331,22522,22524,22804,22855,22931,23492,23696,23822,24049,
24190,24524,25216,26071,26083,26398,26399,26462,26827,26820,27231,27450,27683,
27773,27778,28103,29592,29734,29738,29826,29859,30072,30079,30849,30959,31041,
31047,31048,31098,31637,32000,32186,32648,32774,32813,32908,35352,35663,35912,
36215,37665,37668,39138,39249,39438,39439,39525,40594,32202,20342,21513,25326,
26708,37329,21931,20794,63755,63756,23068,25062,63757,25295,25343,63758,63759,
63760,63761,63762,63763,37027,63764,63765,63766,63767,63768,35582,63769,63770,
63771,63772,26262,63773,29014,63774,63775,38627,63776,25423,25466,21335,63777,
26511,26976,28275,63778,30007,63779,63780,63781,32013,
63782,63783,34930,22218,23064,63784,63785,63786,63787,63788,20035,63789,20839,
22856,26608,32784,63790,22899,24180,25754,31178,24565,24684,25288,25467,23527,
23511,21162,63791,22900,24361,24594,63792,63793,63794,29785,63795,63796,63797,
63798,63799,63800,39377,63801,63802,63803,63804,63805,63806,63807,63808,63809,
63810,63811,28611,63812,63813,33215,36786,24817,63814,63815,33126,63816,63817,
23615,63818,63819,63820,63821,63822,63823,63824,63825,23273,35365,26491,32016,
63826,63827,63828,63829,63830,63831,33021,63832,63833,23612,27877,21311,28346,
22810,33590,20025,20150,20294,21934,22296,22727,24406,26039,26086,27264,27573,
28237,30701,31471,31774,32222,34507,34962,37170,37723,25787,28606,29562,30136,
36948,21846,22349,25018,25812,26311,28129,28251,28525,28601,30192,32835,33213,
34113,35203,35527,35674,37663,27795,30035,31572,36367,36957,21776,22530,22616,
24162,25095,25758,26848,30070,31958,34739,40680,20195,22408,22382,22823,23565,
23729,24118,24453,25140,25825,29619,33274,34955,36024,38538,40667,23429,24503,
24755,20498,20992,21040,22294,22581,22615,23566,23648,23798,23947,24230,24466,
24764,25361,25481,25623,26691,26873,27330,28120,28193,28372,28644,29182,30428,
30585,31153,31291,33796,35241,36077,36339,36424,36867,36884,36947,37117,37709,
38518,38876,27602,28678,29272,29346,29544,30563,31167,31716,32411,35712,22697,
24775,25958,26109,26302,27788,28958,29129,35930,38931,20077,31361,20189,20908,
20941,21205,21516,24999,26481,26704,26847,27934,28540,30140,30643,31461,33012,
33891,37509,20828,26007,26460,26515,30168,31431,33651,
63834,35910,36887,38957,23663,33216,33434,36929,36975,37389,24471,23965,27225,
29128,30331,31561,34276,35588,37159,39472,21895,25078,63835,30313,32645,34367,
34746,35064,37007,63836,27931,28889,29662,32097,33853,63837,37226,39409,63838,
20098,21365,27396,27410,28734,29211,34349,40478,21068,36771,23888,25829,25900,
27414,28651,31811,32412,34253,35172,35261,25289,33240,34847,24266,26391,28010,
29436,29701,29807,34690,37086,20358,23821,24480,33802,20919,25504,30053,20142,
20486,20841,20937,26753,27153,31918,31921,31975,33391,35538,36635,37327,20406,
20791,21237,21570,24300,24942,25150,26053,27354,28670,31018,34268,34851,38317,
39522,39530,40599,40654,21147,26310,27511,28701,31019,36706,38722,24976,25088,
25891,28451,29001,29833,32244,32879,34030,36646,36899,37706,20925,21015,21155,
27916,28872,35010,24265,25986,27566,28610,31806,29557,20196,20278,22265,63839,
23738,23994,24604,29618,31533,32666,32718,32838,36894,37428,38646,38728,38936,
40801,20363,28583,31150,37300,38583,21214,63840,25736,25796,27347,28510,28696,
29200,30439,32769,34310,34396,36335,36613,38706,39791,40442,40565,30860,31103,
32160,33737,37636,40575,40595,35542,22751,24324,26407,28711,29903,31840,32894,
20769,28712,29282,30922,36034,36058,36084,38647,20102,20698,23534,24278,26009,
29134,30274,30637,32842,34044,36988,39719,40845,22744,23105,23650,27155,28122,
28431,30267,32047,32311,34078,35128,37860,38475,21129,26066,26611,27060,27969,
28316,28687,29705,29792,30041,30244,30827,35628,39006,20845,25134,38520,20374,
20523,23833,28138,32184,36650,24459,24900,26647,63841,
38534,21202,32907,20956,20940,26974,31260,32190,33777,38517,20442,21033,21400,
21519,21774,23653,24743,26446,26792,28012,29313,29432,29702,29827,63842,30178,
31852,32633,32696,33673,35023,35041,37324,37328,38626,39881,21533,28542,29136,
29848,34298,36522,38563,40023,40607,26519,28107,29747,33256,38678,30764,31435,
31520,31890,25705,29802,30194,30908,30952,39340,39764,40635,23518,24149,28448,
33180,33707,37000,19975,21325,23081,24018,24398,24930,25405,26217,26364,28415,
28459,28771,30622,33836,34067,34875,36627,39237,39995,21788,25273,26411,27819,
33545,35178,38778,20129,22916,24536,24537,26395,32178,32596,33426,33579,33725,
36638,37017,22475,22969,23186,23504,26151,26522,26757,27599,29028,32629,36023,
36067,36993,39749,33032,35978,38476,39488,40613,23391,27667,29467,30450,30431,
33804,20906,35219,20813,20885,21193,26825,27796,30468,30496,32191,32236,38754,
40629,28357,34065,20901,21517,21629,26126,26269,26919,28319,30399,30609,33559,
33986,34719,37225,37528,40180,34946,20398,20882,21215,22982,24125,24917,25720,
25721,26286,26576,27169,27597,27611,29279,29281,29761,30520,30683,32791,33468,
33541,35584,35624,35980,26408,27792,29287,30446,30566,31302,40361,27519,27794,
22818,26406,33945,21359,22675,22937,24287,25551,26164,26483,28218,29483,31447,
33495,37672,21209,24043,25006,25035,25098,25287,25771,26080,26969,27494,27595,
28961,29687,30045,32326,33310,33538,34154,35491,36031,38695,40289,22696,40664,
20497,21006,21563,21839,25991,27766,32010,32011,32862,34442,38272,38639,21247,
27797,29289,21619,23194,23614,23883,24396,24494,26410,
26806,26979,28220,28228,30473,31859,32654,34183,35598,36855,38753,40692,23735,
24758,24845,25003,25935,26107,26108,27665,27887,29599,29641,32225,38292,23494,
34588,35600,21085,21338,25293,25615,25778,26420,27192,27850,29632,29854,31636,
31893,32283,33162,33334,34180,36843,38649,39361,20276,21322,21453,21467,25292,
25644,25856,26001,27075,27886,28504,29677,30036,30242,30436,30460,30928,30971,
31020,32070,33324,34784,36820,38930,39151,21187,25300,25765,28196,28497,30332,
36299,37297,37474,39662,39747,20515,20621,22346,22952,23592,24135,24439,25151,
25918,26041,26049,26121,26507,27036,28354,30917,32033,32938,33152,33323,33459,
33953,34444,35370,35607,37030,38450,40848,20493,20467,63843,22521,24472,25308,
25490,26479,28227,28953,30403,32972,32986,35060,35061,35097,36064,36649,37197,
38506,20271,20336,24091,26575,26658,30333,30334,39748,24161,27146,29033,29140,
30058,63844,32321,34115,34281,39132,20240,31567,32624,38309,20961,24070,26805,
27710,27726,27867,29359,31684,33539,27861,29754,20731,21128,22721,25816,27287,
29863,30294,30887,34327,38370,38713,63845,21342,24321,35722,36776,36783,37002,
21029,30629,40009,40712,19993,20482,20853,23643,24183,26142,26170,26564,26821,
28851,29953,30149,31177,31453,36647,39200,39432,20445,22561,22577,23542,26222,
27493,27921,28282,28541,29668,29995,33769,35036,35091,35676,36628,20239,20693,
21264,21340,23443,24489,26381,31119,33145,33583,34068,35079,35206,36665,36667,
39333,39954,26412,20086,20472,22857,23553,23791,23792,25447,26834,28925,29090,
29739,32299,34028,34562,36898,37586,40179,19981,20184,
20463,20613,21078,21103,21542,21648,22496,22827,23142,23386,23413,23500,24220,
63846,25206,25975,26023,28014,28325,29238,31526,31807,32566,33104,33105,33178,
33344,33433,33705,35331,36000,36070,36091,36212,36282,37096,37340,38428,38468,
39385,40167,21271,20998,21545,22132,22707,22868,22894,24575,24996,25198,26128,
27774,28954,30406,31881,31966,32027,33452,36033,38640,63847,20315,24343,24447,
25282,23849,26379,26842,30844,32323,40300,19989,20633,21269,21290,21329,22915,
23138,24199,24754,24970,25161,25209,26000,26503,27047,27604,27606,27607,27608,
27832,63848,29749,30202,30738,30865,31189,31192,31875,32203,32737,32933,33086,
33218,33778,34586,35048,35513,35692,36027,37145,38750,39131,40763,22188,23338,
24428,25996,27315,27567,27996,28657,28693,29277,29613,36007,36051,38971,24977,
27703,32856,39425,20045,20107,20123,20181,20282,20284,20351,20447,20735,21490,
21496,21766,21987,22235,22763,22882,23057,23531,23546,23556,24051,24107,24473,
24605,25448,26012,26031,26614,26619,26797,27515,27801,27863,28195,28681,29509,
30722,31038,31040,31072,31169,31721,32023,32114,32902,33293,33678,34001,34503,
35039,35408,35422,35613,36060,36198,36781,37034,39164,39391,40605,21066,63849,
26388,63850,20632,21034,23665,25955,27733,29642,29987,30109,31639,33948,37240,
38704,20087,25746,27578,29022,34217,19977,63851,26441,26862,28183,33439,34072,
34923,25591,28545,37394,39087,19978,20663,20687,20767,21830,21930,22039,23360,
23577,23776,24120,24202,24224,24258,24819,26705,27233,28248,29245,29248,29376,
30456,31077,31665,32724,35059,35316,35443,35937,36062,
38684,22622,29885,36093,21959,63852,31329,32034,33394,29298,29983,29989,63853,
31513,22661,22779,23996,24207,24246,24464,24661,25234,25471,25933,26257,26329,
26360,26646,26866,29312,29790,31598,32110,32214,32626,32997,33298,34223,35199,
35475,36893,37604,40653,40736,22805,22893,24109,24796,26132,26227,26512,27728,
28101,28511,30707,30889,33990,37323,37675,20185,20682,20808,21892,23307,23459,
25159,25982,26059,28210,29053,29697,29764,29831,29887,30316,31146,32218,32341,
32680,33146,33203,33337,34330,34796,35445,36323,36984,37521,37925,39245,39854,
21352,23633,26964,27844,27945,28203,33292,34203,35131,35373,35498,38634,40807,
21089,26297,27570,32406,34814,36109,38275,38493,25885,28041,29166,63854,22478,
22995,23468,24615,24826,25104,26143,26207,29481,29689,30427,30465,31596,32854,
32882,33125,35488,37266,19990,21218,27506,27927,31237,31545,32048,63855,36016,
21484,22063,22609,23477,23567,23569,24034,25152,25475,25620,26157,26803,27836,
28040,28335,28703,28836,29138,29990,30095,30094,30233,31505,31712,31787,32032,
32057,34092,34157,34311,35380,36877,36961,37045,37559,38902,39479,20439,23660,
26463,28049,31903,32396,35606,36118,36895,23403,24061,25613,33984,36956,39137,
29575,23435,24730,26494,28126,35359,35494,36865,38924,21047,63856,28753,30862,
37782,34928,37335,20462,21463,22013,22234,22402,22781,23234,23432,23723,23744,
24101,24833,25101,25163,25480,25628,25910,25976,27193,27530,27700,27929,28465,
29159,29417,29560,29703,29874,30246,30561,31168,31319,31466,31929,32143,32172,
32353,32670,33065,33585,33936,34010,34282,34966,35504,
35728,36664,36930,36995,37228,37526,37561,38539,38567,38568,38614,38656,38920,
39318,39635,39706,21460,22654,22809,23408,23487,28113,28506,29087,29729,29881,
32901,33789,24033,24455,24490,24642,26092,26642,26991,27219,27529,27957,28147,
29667,30462,30636,31565,32020,33059,33308,33600,34036,34147,35426,35524,37255,
37662,38918,39348,25100,34899,36848,37477,23815,23847,23913,29791,33181,34664,
28629,25342,32722,35126,35186,19998,20056,20711,21213,21319,25215,26119,32361,
34821,38494,20365,21273,22070,22987,23204,23608,23630,23629,24066,24337,24643,
26045,26159,26178,26558,26612,29468,30690,31034,32709,33940,33997,35222,35430,
35433,35553,35925,35962,22516,23508,24335,24687,25325,26893,27542,28252,29060,
31698,34645,35672,36606,39135,39166,20280,20353,20449,21627,23072,23480,24892,
26032,26216,29180,30003,31070,32051,33102,33251,33688,34218,34254,34563,35338,
36523,36763,63857,36805,22833,23460,23526,24713,23529,23563,24515,27777,63858,
28145,28683,29978,33455,35574,20160,21313,63859,38617,27663,20126,20420,20818,
21854,23077,23784,25105,29273,33469,33706,34558,34905,35357,38463,38597,39187,
40201,40285,22538,23731,23997,24132,24801,24853,25569,27138,28197,37122,37716,
38990,39952,40823,23433,23736,25353,26191,26696,30524,38593,38797,38996,39839,
26017,35585,36555,38332,21813,23721,24022,24245,26263,30284,33780,38343,22739,
25276,29390,40232,20208,22830,24591,26171,27523,31207,40230,21395,21696,22467,
23830,24859,26326,28079,30861,33406,38552,38724,21380,25212,25494,28082,32266,
33099,38989,27387,32588,40367,40474,20063,20539,20918,
22812,24825,25590,26928,29242,32822,63860,37326,24369,63861,63862,32004,33509,
33903,33979,34277,36493,63863,20335,63864,63865,22756,23363,24665,25562,25880,
25965,26264,63866,26954,27171,27915,28673,29036,30162,30221,31155,31344,63867,
32650,63868,35140,63869,35731,37312,38525,63870,39178,22276,24481,26044,28417,
30208,31142,35486,39341,39770,40812,20740,25014,25233,27277,33222,20547,22576,
24422,28937,35328,35578,23420,34326,20474,20796,22196,22852,25513,28153,23978,
26989,20870,20104,20313,63871,63872,63873,22914,63874,63875,27487,27741,63876,
29877,30998,63877,33287,33349,33593,36671,36701,63878,39192,63879,63880,63881,
20134,63882,22495,24441,26131,63883,63884,30123,32377,35695,63885,36870,39515,
22181,22567,23032,23071,23476,63886,24310,63887,63888,25424,25403,63889,26941,
27783,27839,28046,28051,28149,28436,63890,28895,28982,29017,63891,29123,29141,
63892,30799,30831,63893,31605,32227,63894,32303,63895,34893,36575,63896,63897,
63898,37467,63899,40182,63900,63901,63902,24709,28037,63903,29105,63904,63905,
38321,21421,63906,63907,63908,26579,63909,28814,28976,29744,33398,33490,63910,
38331,39653,40573,26308,63911,29121,33865,63912,63913,22603,63914,63915,23992,
24433,63916,26144,26254,27001,27054,27704,27891,28214,28481,28634,28699,28719,
29008,29151,29552,63917,29787,63918,29908,30408,31310,32403,63919,63920,33521,
35424,36814,63921,37704,63922,38681,63923,63924,20034,20522,63925,21000,21473,
26355,27757,28618,29450,30591,31330,33454,34269,34306,63926,35028,35427,35709,
35947,63927,37555,63928,38675,38928,20116,20237,20425,
20658,21320,21566,21555,21978,22626,22714,22887,23067,23524,24735,63929,25034,
25942,26111,26212,26791,27738,28595,28879,29100,29522,31613,34568,35492,39986,
40711,23627,27779,29508,29577,37434,28331,29797,30239,31337,32277,34314,20800,
22725,25793,29934,29973,30320,32705,37013,38605,39252,28198,29926,31401,31402,
33253,34521,34680,35355,23113,23436,23451,26785,26880,28003,29609,29715,29740,
30871,32233,32747,33048,33109,33694,35916,38446,38929,26352,24448,26106,26505,
27754,29579,20525,23043,27498,30702,22806,23916,24013,29477,30031,63930,63931,
20709,20985,22575,22829,22934,23002,23525,63932,63933,23970,25303,25622,25747,
25854,63934,26332,63935,27208,63936,29183,29796,63937,31368,31407,32327,32350,
32768,33136,63938,34799,35201,35616,36953,63939,36992,39250,24958,27442,28020,
32287,35109,36785,20433,20653,20887,21191,22471,22665,23481,24248,24898,27029,
28044,28263,28342,29076,29794,29992,29996,32883,33592,33993,36362,37780,37854,
63940,20110,20305,20598,20778,21448,21451,21491,23431,23507,23588,24858,24962,
26100,29275,29591,29760,30402,31056,31121,31161,32006,32701,33419,34261,34398,
36802,36935,37109,37354,38533,38632,38633,21206,24423,26093,26161,26671,29020,
31286,37057,38922,20113,63941,27218,27550,28560,29065,32792,33464,34131,36939,
38549,38642,38907,34074,39729,20112,29066,38596,20803,21407,21729,22291,22290,
22435,23195,23236,23491,24616,24895,25588,27781,27961,28274,28304,29232,29503,
29783,33489,34945,36677,36960,63942,38498,39000,40219,26376,36234,37470,20301,
20553,20702,21361,22285,22996,23041,23561,24944,26256,
28205,29234,29771,32239,32963,33806,33894,34111,34655,34907,35096,35586,36949,
38859,39759,20083,20369,20754,20842,63943,21807,21929,23418,23461,24188,24189,
24254,24736,24799,24840,24841,25540,25912,26377,63944,26580,26586,63945,26977,
26978,27833,27943,63946,28216,63947,28641,29494,29495,63948,29788,30001,63949,
30290,63950,63951,32173,33278,33848,35029,35480,35547,35565,36400,36418,36938,
36926,36986,37193,37321,37742,63952,63953,22537,63954,27603,32905,32946,63955,
63956,20801,22891,23609,63957,63958,28516,29607,32996,36103,63959,37399,38287,
63960,63961,63962,63963,32895,25102,28700,32104,34701,63964,22432,24681,24903,
27575,35518,37504,38577,20057,21535,28139,34093,38512,38899,39150,25558,27875,
37009,20957,25033,33210,40441,20381,20506,20736,23452,24847,25087,25836,26885,
27589,30097,30691,32681,33380,34191,34811,34915,35516,35696,37291,20108,20197,
20234,63965,63966,22839,23016,63967,24050,24347,24411,24609,63968,63969,63970,
63971,29246,29669,63972,30064,30157,63973,31227,63974,32780,32819,32900,33505,
33617,63975,63976,36029,36019,36999,63977,63978,39156,39180,63979,63980,28727,
30410,32714,32716,32764,35610,20154,20161,20995,21360,63981,21693,22240,23035,
23493,24341,24525,28270,63982,63983,32106,33589,63984,34451,35469,63985,38765,
38775,63986,63987,19968,20314,20350,22777,26085,28322,36920,37808,39353,20219,
22764,22922,23001,24641,63988,63989,31252,63990,33615,36035,20837,21316,63991,
63992,63993,20173,21097,23381,33471,20180,21050,21672,22985,23039,23376,23383,
23388,24675,24904,28363,28825,29038,29574,29943,30133,
30913,32043,32773,33258,33576,34071,34249,35566,36039,38604,20316,21242,22204,
26027,26152,28796,28856,29237,32189,33421,37196,38592,40306,23409,26855,27544,
28538,30430,23697,26283,28507,31668,31786,34870,38620,19976,20183,21280,22580,
22715,22767,22892,23559,24115,24196,24373,25484,26290,26454,27167,27299,27404,
28479,29254,63994,29520,29835,31456,31911,33144,33247,33255,33674,33900,34083,
34196,34255,35037,36115,37292,38263,38556,20877,21705,22312,23472,25165,26448,
26685,26771,28221,28371,28797,32289,35009,36001,36617,40779,40782,29229,31631,
35533,37658,20295,20302,20786,21632,22992,24213,25269,26485,26990,27159,27822,
28186,29401,29482,30141,31672,32053,33511,33785,33879,34295,35419,36015,36487,
36889,37048,38606,40799,21219,21514,23265,23490,25688,25973,28404,29380,63995,
30340,31309,31515,31821,32318,32735,33659,35627,36042,36196,36321,36447,36842,
36857,36969,37841,20291,20346,20659,20840,20856,21069,21098,22625,22652,22880,
23560,23637,24283,24731,25136,26643,27583,27656,28593,29006,29728,30000,30008,
30033,30322,31564,31627,31661,31686,32399,35438,36670,36681,37439,37523,37666,
37931,38651,39002,39019,39198,20999,25130,25240,27993,30308,31434,31680,32118,
21344,23742,24215,28472,28857,31896,38673,39822,40670,25509,25722,34678,19969,
20117,20141,20572,20597,21576,22979,23450,24128,24237,24311,24449,24773,25402,
25919,25972,26060,26230,26232,26622,26984,27273,27491,27712,28096,28136,28191,
28254,28702,28833,29582,29693,30010,30555,30855,31118,31243,31357,31934,32142,
33351,35330,35562,35998,37165,37194,37336,37478,37580,
37664,38662,38742,38748,38914,40718,21046,21137,21884,22564,24093,24351,24716,
25552,26799,28639,31085,31532,33229,34234,35069,35576,36420,37261,38500,38555,
38717,38988,40778,20430,20806,20939,21161,22066,24340,24427,25514,25805,26089,
26177,26362,26361,26397,26781,26839,27133,28437,28526,29031,29157,29226,29866,
30522,31062,31066,31199,31264,31381,31895,31967,32068,32368,32903,34299,34468,
35412,35519,36249,36481,36896,36973,37347,38459,38613,40165,26063,31751,36275,
37827,23384,23562,21330,25305,29469,20519,23447,24478,24752,24939,26837,28121,
29742,31278,32066,32156,32305,33131,36394,36405,37758,37912,20304,22352,24038,
24231,25387,32618,20027,20303,20367,20570,23005,32964,21610,21608,22014,22863,
23449,24030,24282,26205,26417,26609,26666,27880,27954,28234,28557,28855,29664,
30087,31820,32002,32044,32162,33311,34523,35387,35461,36208,36490,36659,36913,
37198,37202,37956,39376,31481,31909,20426,20737,20934,22472,23535,23803,26201,
27197,27994,28310,28652,28940,30063,31459,34850,36897,36981,38603,39423,33537,
20013,20210,34886,37325,21373,27355,26987,27713,33914,22686,24974,26366,25327,
28893,29969,30151,32338,33976,35657,36104,20043,21482,21675,22320,22336,24535,
25345,25351,25711,25903,26088,26234,26525,26547,27490,27744,27802,28460,30693,
30757,31049,31063,32025,32930,33026,33267,33437,33463,34584,35468,63996,36100,
36286,36978,30452,31257,31287,32340,32887,21767,21972,22645,25391,25634,26185,
26187,26733,27035,27524,27941,28337,29645,29800,29857,30043,30137,30433,30494,
30603,31206,32265,32285,33275,34095,34967,35386,36049,
36587,36784,36914,37805,38499,38515,38663,20356,21489,23018,23241,24089,26702,
29894,30142,31209,31378,33187,34541,36074,36300,36845,26015,26389,63997,22519,
28503,32221,36655,37878,38598,24501,25074,28548,19988,20376,20511,21449,21983,
23919,24046,27425,27492,30923,31642,63998,36425,36554,36974,25417,25662,30528,
31364,37679,38015,40810,25776,28591,29158,29864,29914,31428,31762,32386,31922,
32408,35738,36106,38013,39184,39244,21049,23519,25830,26413,32046,20717,21443,
22649,24920,24921,25082,26028,31449,35730,35734,20489,20513,21109,21809,23100,
24288,24432,24884,25950,26124,26166,26274,27085,28356,28466,29462,30241,31379,
33081,33369,33750,33980,20661,22512,23488,23528,24425,25505,30758,32181,33756,
34081,37319,37365,20874,26613,31574,36012,20932,22971,24765,34389,20508,63999,
21076,23610,24957,25114,25299,25842,26021,28364,30240,33034,36448,38495,38587,
20191,21315,21912,22825,24029,25797,27849,28154,29588,31359,33307,34214,36068,
36368,36983,37351,38369,38433,38854,20984,21746,21894,24505,25764,28552,32180,
36639,36685,37941,20681,23574,27838,28155,29979,30651,31805,31844,35449,35522,
22558,22974,24086,25463,29266,30090,30571,35548,36028,36626,24307,26228,28152,
32893,33729,35531,38737,39894,64000,21059,26367,28053,28399,32224,35558,36910,
36958,39636,21021,21119,21736,24980,25220,25307,26786,26898,26970,27189,28818,
28966,30813,30977,30990,31186,31245,32918,33400,33493,33609,34121,35970,36229,
37218,37259,37294,20419,22225,29165,30679,34560,35320,23544,24534,26449,37032,
21474,22618,23541,24740,24961,25696,32317,32880,34085,
37507,25774,20652,23828,26368,22684,25277,25512,26894,27000,27166,28267,30394,
31179,33467,33833,35535,36264,36861,37138,37195,37276,37648,37656,37786,38619,
39478,39949,19985,30044,31069,31482,31569,31689,32302,33988,36441,36468,36600,
36880,26149,26943,29763,20986,26414,40668,20805,24544,27798,34802,34909,34935,
24756,33205,33795,36101,21462,21561,22068,23094,23601,28810,32736,32858,33030,
33261,36259,37257,39519,40434,20596,20164,21408,24827,28204,23652,20360,20516,
21988,23769,24159,24677,26772,27835,28100,29118,30164,30196,30305,31258,31305,
32199,32251,32622,33268,34473,36636,38601,39347,40786,21063,21189,39149,35242,
19971,26578,28422,20405,23522,26517,27784,28024,29723,30759,37341,37756,34756,
31204,31281,24555,20182,21668,21822,22702,22949,24816,25171,25302,26422,26965,
33333,38464,39345,39389,20524,21331,21828,22396,64001,25176,64002,25826,26219,
26589,28609,28655,29730,29752,35351,37944,21585,22022,22374,24392,24986,27470,
28760,28845,32187,35477,22890,33067,25506,30472,32829,36010,22612,25645,27067,
23445,24081,28271,64003,34153,20812,21488,22826,24608,24907,27526,27760,27888,
31518,32974,33492,36294,37040,39089,64004,25799,28580,25745,25860,20814,21520,
22303,35342,24927,26742,64005,30171,31570,32113,36890,22534,27084,33151,35114,
36864,38969,20600,22871,22956,25237,36879,39722,24925,29305,38358,22369,23110,
24052,25226,25773,25850,26487,27874,27966,29228,29750,30772,32631,33453,36315,
38935,21028,22338,26495,29256,29923,36009,36774,37393,38442,20843,21485,25420,
20329,21764,24726,25943,27803,28031,29260,29437,31255,
35207,35997,24429,28558,28921,33192,24846,20415,20559,25153,29255,31687,32232,
32745,36941,38829,39449,36022,22378,24179,26544,33805,35413,21536,23318,24163,
24290,24330,25987,32954,34109,38281,38491,20296,21253,21261,21263,21638,21754,
22275,24067,24598,25243,25265,25429,64006,27873,28006,30129,30770,32990,33071,
33502,33889,33970,34957,35090,36875,37610,39165,39825,24133,26292,26333,28689,
29190,64007,20469,21117,24426,24915,26451,27161,28418,29922,31080,34920,35961,
39111,39108,39491,21697,31263,26963,35575,35914,39080,39342,24444,25259,30130,
30382,34987,36991,38466,21305,24380,24517,27852,29644,30050,30091,31558,33534,
39325,20047,36924,19979,20309,21414,22799,24264,26160,27827,29781,33655,34662,
36032,36944,38686,39957,22737,23416,34384,35604,40372,23506,24680,24717,26097,
27735,28450,28579,28698,32597,32752,38289,38290,38480,38867,21106,36676,20989,
21547,21688,21859,21898,27323,28085,32216,33382,37532,38519,40569,21512,21704,
30418,34532,38308,38356,38492,20130,20233,23022,23270,24055,24658,25239,26477,
26689,27782,28207,32568,32923,33322,64008,64009,38917,20133,20565,21683,22419,
22874,23401,23475,25032,26999,28023,28707,34809,35299,35442,35559,36994,39405,
39608,21182,26680,20502,24184,26447,33607,34892,20139,21521,22190,29670,37141,
38911,39177,39255,39321,22099,22687,34395,35377,25010,27382,29563,36562,27463,
38570,39511,22869,29184,36203,38761,20436,23796,24358,25080,26203,27883,28843,
29572,29625,29694,30505,30541,32067,32098,32291,33335,34898,64010,36066,37449,
39023,23377,31348,34880,38913,23244,20448,21332,22846,
23805,25406,28025,29433,33029,33031,33698,37583,38960,20136,20804,21009,22411,
24418,27842,28366,28677,28752,28847,29074,29673,29801,33610,34722,34913,36872,
37026,37795,39336,20846,24407,24800,24935,26291,34137,36426,37295,38795,20046,
20114,21628,22741,22778,22909,23733,24359,25142,25160,26122,26215,27627,28009,
28111,28246,28408,28564,28640,28649,28765,29392,29733,29786,29920,30355,31068,
31946,32286,32993,33446,33899,33983,34382,34399,34676,35703,35946,37804,38912,
39013,24785,25110,37239,23130,26127,28151,28222,29759,39746,24573,24794,31503,
21700,24344,27742,27859,27946,28888,32005,34425,35340,40251,21270,21644,23301,
27194,28779,30069,31117,31166,33457,33775,35441,35649,36008,38772,64011,25844,
25899,30906,30907,31339,20024,21914,22864,23462,24187,24739,25563,27489,26213,
26707,28185,29029,29872,32008,36996,39529,39973,27963,28369,29502,35905,38346,
20976,24140,24488,24653,24822,24880,24908,26179,26180,27045,27841,28255,28361,
28514,29004,29852,30343,31681,31783,33618,34647,36945,38541,40643,21295,22238,
24315,24458,24674,24724,25079,26214,26371,27292,28142,28590,28784,29546,32362,
33214,33588,34516,35496,36036,21123,29554,23446,27243,37892,21742,22150,23389,
25928,25989,26313,26783,28045,28102,29243,32948,37237,39501,20399,20505,21402,
21518,21564,21897,21957,24127,24460,26429,29030,29661,36869,21211,21235,22628,
22734,28932,29071,29179,34224,35347,26248,34216,21927,26244,29002,33841,21321,
21913,27585,24409,24509,25582,26249,28999,35569,36637,40638,20241,25658,28875,
30054,34407,24676,35662,40440,20807,20982,21256,27958,
33016,40657,26133,27427,28824,30165,21507,23673,32007,35350,27424,27453,27462,
21560,24688,27965,32725,33288,20694,20958,21916,22123,22221,23020,23305,24076,
24985,24984,25137,26206,26342,29081,29113,29114,29351,31143,31232,32690,35440,
| 50,463 | 651 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/vscanf.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/stdio/stdio.h"
/**
* String decoder.
* @see libc/fmt/vcscanf.h
*/
int(vscanf)(const char *fmt, va_list ap) {
return (vcscanf)((int (*)(void *))fgetc, (void *)ungetc, stdin, fmt, ap);
}
| 2,068 | 29 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/pclose.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/assert.h"
#include "libc/calls/calls.h"
#include "libc/calls/struct/rusage.h"
#include "libc/errno.h"
#include "libc/stdio/stdio.h"
#include "libc/sysv/errfuns.h"
/**
* Closes stream created by popen().
*
* This function may be interrupted or cancelled, however it won't
* actually return until the child process has terminated. Thus we
* always release the resource, and errors are purely advisory.
*
* @return termination status of subprocess, or -1 w/ ECHILD
* @raise ECANCELED if thread was cancelled in masked mode
* @raise ECHILD if child pid didn't exist
* @raise EINTR if signal was delivered
* @cancellationpoint
*/
int pclose(FILE *f) {
int e, rc, ws, pid;
bool iscancelled, wasinterrupted;
pid = f->pid;
fclose(f);
if (!pid) return 0;
iscancelled = false;
wasinterrupted = false;
for (e = errno;;) {
if (wait4(pid, &ws, 0, 0) != -1) {
rc = ws;
break;
} else if (errno == ECANCELED) {
iscancelled = true;
errno = e;
} else if (errno == EINTR) {
wasinterrupted = true;
errno = e;
} else {
rc = echild();
break;
}
}
if (iscancelled) {
return ecanceled();
} else if (wasinterrupted) {
return eintr();
} else {
return rc;
}
}
| 3,102 | 70 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/mkostempsm.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/errno.h"
#include "libc/intrin/strace.internal.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/lcg.internal.h"
#include "libc/stdio/rand.h"
#include "libc/stdio/temp.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/o.h"
#include "libc/sysv/errfuns.h"
#define RESEED 1024
#define ATTEMPTS 10
#define WILDCARD "XXXXXX"
int mkostempsmi(char *tpl, int slen, unsigned flags, uint64_t *rando, int mode,
int openit(const char *file, int flags, ...)) {
size_t len = strlen(tpl);
size_t wildlen = strlen(WILDCARD);
if (len < wildlen || slen > len - wildlen) return einval();
char *ss = tpl + len - wildlen - slen;
_npassert(memcmp(ss, WILDCARD, wildlen) == 0);
flags = (flags & ~(flags & O_ACCMODE)) | O_RDWR | O_CREAT | O_EXCL;
unsigned attempts = ATTEMPTS;
do {
char *p = ss;
uint32_t num = KnuthLinearCongruentialGenerator(rando) >> 32;
for (unsigned i = 0; i < wildlen; ++i) {
p[i] = "0123456789abcdefghijklmnopqrstuvwxyz"[num & 31];
num >>= 5;
}
int fd;
if ((fd = openit(tpl, flags, 0600)) != -1) return fd;
} while (--attempts && errno == EEXIST);
memcpy(ss, WILDCARD, wildlen);
return -1;
}
static uint64_t g_mkostemps_rand;
static uint64_t g_mkostemps_reseed;
/**
* Opens unique temporary file.
*
* The substring XXXXXX is replaced with a pseudorandom number that's
* seeded automatically and grants 30 bits of randomness to each value.
* Retries are made in the unlikely event of collisions.
*
* @param template is a pathname relative to current directory by default,
* that needs to have "XXXXXX" at the end of the string
* @param suffixlen may be nonzero to permit characters after the XXXXXX
* @param flags can have O_APPEND, O_CLOEXEC, etc.
* @param mode is conventionally 0600, for owner-only non-exec access
* @return exclusive open file descriptor for generated pathname,
* or -1 w/ errno
* @see kTmpPath
*/
dontdiscard int mkostempsm(char *template, int suffixlen, unsigned flags,
int mode) {
int fd;
if (g_mkostemps_reseed++ % RESEED == 0) g_mkostemps_rand = _rand64();
fd = mkostempsmi(template, suffixlen, flags, &g_mkostemps_rand, mode, open);
STRACE("mkostempsm([%#s], %'d, %#x, %#o) â %d% m", template, suffixlen, flags,
mode, fd);
return fd;
}
| 4,233 | 86 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/ungetwc.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=8 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/lock.internal.h"
#include "libc/stdio/stdio.h"
/**
* Pushes wide character back to stream.
* @threadsafe
*/
wint_t ungetwc(wint_t c, FILE *f) {
wint_t rc;
flockfile(f);
rc = ungetwc_unlocked(c, f);
funlockfile(f);
return rc;
}
| 2,098 | 33 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fclose.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=8 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/errno.h"
#include "libc/intrin/weaken.h"
#include "libc/mem/mem.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/internal.h"
#include "libc/stdio/stdio.h"
/**
* Closes standard i/o stream and its underlying thing.
*
* @param f is the file object
* @return 0 on success or -1 on error, which can be a trick for
* differentiating between EOF and real errors during previous
* i/o calls, without needing to call ferror()
*/
int fclose(FILE *f) {
int rc;
if (!f) return 0;
__fflush_unregister(f);
fflush(f);
if (_weaken(free)) {
_weaken(free)(f->getln);
if (!f->nofree && f->buf != f->mem) {
_weaken(free)(f->buf);
}
}
f->state = EOF;
if (f->noclose) {
f->fd = -1;
} else if (close(f->fd) == -1) {
f->state = errno;
}
if (f->state == EOF) {
rc = 0;
} else {
errno = f->state;
rc = EOF;
}
__stdio_free(f);
return rc;
}
| 2,813 | 62 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/getc.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=8 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"
/**
* Reads byte from stream.
* @return byte in range 0..255, or -1 w/ errno
* @threadsafe
*/
int(getc)(FILE *f) {
return fgetc(f);
}
| 2,007 | 29 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/stdout.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=8 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/stdio/internal.h"
#include "libc/stdio/stdio.h"
#include "libc/sysv/consts/fileno.h"
#include "libc/sysv/consts/o.h"
#include "libc/thread/thread.h"
/**
* Pointer to standard output stream.
*/
FILE *stdout;
static FILE __stdout;
__attribute__((__constructor__)) static void __stdout_init(void) {
stdout = &__stdout;
stdout->fd = STDOUT_FILENO;
stdout->iomode = O_WRONLY;
stdout->buf = stdout->mem;
stdout->size = sizeof(stdout->mem);
((pthread_mutex_t *)stdout->lock)->_type = PTHREAD_MUTEX_RECURSIVE;
/*
* Unlike other C libraries we don't bother calling fstat() to check
* if stdio is a character device and we instead choose to always line
* buffer it. We need it because there's no way to use the unbuffer
* command on a statically linked binary. This still goes fast. We
* value latency more than throughput, and stdio isn't the best api
* when the goal is throughput.
*/
stdout->bufmode = _IOLBF;
__fflush_register(stdout);
}
| 2,882 | 55 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/appendw.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/assert.h"
#include "libc/dce.h"
#include "libc/intrin/bits.h"
#include "libc/intrin/bsr.h"
#include "libc/macros.internal.h"
#include "libc/mem/mem.h"
#include "libc/stdio/append.h"
#define W sizeof(size_t)
/**
* Appends character or word-encoded string to buffer.
*
* Up to eight characters can be appended. For example:
*
* appendw(&s, 'h'|'i'<<8);
* appendw(&s, READ64LE("hi\0\0\0\0\0"));
*
* Are equivalent to:
*
* appends(&s, "hi");
*
* The special case:
*
* appendw(&s, 0);
*
* Will append a single NUL character.
*
* This function is slightly faster than appendd() and appends(). Its
* main advantage is it improves code size in functions that call it.
*
* The resulting buffer is guaranteed to be NUL-terminated, i.e.
* `!b[appendz(b).i]` will be the case.
*
* @return bytes appended or -1 if `ENOMEM`
* @see appendz(b).i to get buffer length
*/
ssize_t appendw(char **b, uint64_t w) {
size_t n;
unsigned l;
char *p, *q;
struct appendz z;
z = appendz((p = *b));
l = w ? (_bsrl(w) >> 3) + 1 : 1;
n = ROUNDUP(z.i + 8 + 1, 8) + W;
if (n > z.n) {
if (!z.n) z.n = W * 2;
while (n > z.n) z.n += z.n >> 1;
z.n = ROUNDUP(z.n, W);
if ((p = realloc(p, z.n))) {
z.n = malloc_usable_size(p);
_unassert(!(z.n & (W - 1)));
*b = p;
} else {
return -1;
}
}
q = p + z.i;
WRITE64LE(q, w);
q[8] = 0;
z.i += l;
if (!IsTiny() && W == 8) z.i |= (size_t)APPEND_COOKIE << 48;
*(size_t *)(p + z.n - W) = z.i;
return l;
}
| 3,379 | 84 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fputs_unlocked.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=8 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/str/str.h"
/**
* Writes string to stream.
*
* Writing stops at the NUL-terminator, which isn't included in output.
* This function blocks until the full string is written, unless an
* unrecoverable error happens.
*
* @param s is a NUL-terminated string that's non-NULL
* @param f is an open stream
* @return bytes written, or -1 w/ errno
*/
int fputs_unlocked(const char *s, FILE *f) {
size_t n, r;
n = strlen(s);
r = fwrite_unlocked(s, 1, n, f);
if (!r && n) return -1;
return r;
}
| 2,385 | 40 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fflush.internal.h | #ifndef COSMOPOLITAN_LIBC_STDIO_FFLUSH_H_
#define COSMOPOLITAN_LIBC_STDIO_FFLUSH_H_
#include "libc/intrin/nopl.internal.h"
#include "libc/stdio/stdio.h"
#include "libc/thread/thread.h"
#include "libc/thread/tls.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
struct StdioFlushHandles {
size_t i, n;
FILE **p;
};
struct StdioFlush {
struct StdioFlushHandles handles;
FILE *handles_initmem[8];
};
_Hide extern struct StdioFlush __fflush;
_Hide extern pthread_mutex_t __fflush_lock_obj;
void __fflush_lock(void);
void __fflush_unlock(void);
#ifdef _NOPL0
#define __fflush_lock() _NOPL0("__threadcalls", __fflush_lock)
#define __fflush_unlock() _NOPL0("__threadcalls", __fflush_unlock)
#else
#define __fflush_lock() (__threaded ? __fflush_lock() : 0)
#define __fflush_unlock() (__threaded ? __fflush_unlock() : 0)
#endif
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_STDIO_FFLUSH_H_ */
| 964 | 37 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fseeko.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/intrin/describeflags.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h"
/**
* Repositions open file stream.
*
* This function flushes the buffer (unless it's currently in the EOF
* state) and then calls lseek() on the underlying file. If the stream
* is in the EOF state, this function can be used to restore it without
* needing to reopen the file.
*
* @param f is a non-null stream handle
* @param offset is the byte delta
* @param whence can be SEET_SET, SEEK_CUR, or SEEK_END
* @returns 0 on success or -1 on error
* @threadsafe
*/
int fseeko(FILE *f, int64_t offset, int whence) {
int rc;
flockfile(f);
rc = fseeko_unlocked(f, offset, whence);
STDIOTRACE("fseeko(%p, %'ld, %s) â %d %s", f, offset, DescribeWhence(whence),
rc, DescribeStdioState(f->state));
funlockfile(f);
return rc;
}
| 2,753 | 47 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/appendr.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/assert.h"
#include "libc/dce.h"
#include "libc/intrin/bsr.h"
#include "libc/macros.internal.h"
#include "libc/mem/mem.h"
#include "libc/stdio/append.h"
#include "libc/str/str.h"
#define W sizeof(size_t)
/**
* Resets length of append buffer, e.g.
*
* char *b = 0;
* appends(&b, "hello");
* appendr(&b, 1);
* assert(!strcmp(b, "h"));
* appendr(&b, 0);
* assert(!strcmp(b, ""));
* free(b);
*
* If `i` is greater than the current length then the extra bytes are
* filled with NUL characters. If `i` is less than the current length
* then memory is released to the system.
*
* The resulting buffer is guaranteed to be NUL-terminated, i.e.
* `!b[appendz(b).i]` will be the case even if both params are 0.
*
* @return `i` or -1 if `ENOMEM`
* @see appendz(b).i to get buffer length
*/
ssize_t appendr(char **b, size_t i) {
char *p;
size_t n;
struct appendz z;
_unassert(b);
z = appendz((p = *b));
if (i != z.i || !p) {
n = ROUNDUP(i + 1, 8) + W;
if (n > z.n || _bsrl(n) < _bsrl(z.n)) {
if ((p = realloc(p, n))) {
z.n = malloc_usable_size(p);
_unassert(!(z.n & (W - 1)));
*b = p;
} else {
return -1;
}
}
if (i > z.i) {
bzero(p + z.i, i - z.i + 1);
} else {
p[i] = 0;
}
*(size_t *)(p + z.n - W) =
i | (!IsTiny() && W == 8 ? (size_t)APPEND_COOKIE << 48 : 0);
}
return i;
}
| 3,277 | 77 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fgetwc.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/lock.internal.h"
#include "libc/stdio/stdio.h"
/**
* Reads UTF-8 character from stream.
*
* @param f is non-null file object stream pointer
* @return wide character or -1 on EOF or error
* @see fgetwc_unlocked()
* @threadsafe
*/
wint_t fgetwc(FILE *f) {
wint_t wc;
flockfile(f);
wc = fgetwc_unlocked(f);
funlockfile(f);
return wc;
}
| 2,208 | 37 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/scandir.c | /*-*- mode:c;indent-tabs-mode:t;c-basic-offset:8;tab-width:8;coding:utf-8 -*-â
âvi: set et ft=c ts=8 tw=8 fenc=utf-8 :viâ
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
â â
â Musl Libc â
â Copyright © 2005-2014 Rich Felker, et al. â
â â
â Permission is hereby granted, free of charge, to any person obtaining â
â a copy of this software and associated documentation files (the â
â "Software"), to deal in the Software without restriction, including â
â without limitation the rights to use, copy, modify, merge, publish, â
â distribute, sublicense, and/or sell copies of the Software, and to â
â permit persons to whom the Software is furnished to do so, subject to â
â the following conditions: â
â â
â The above copyright notice and this permission notice shall be â
â included in all copies or substantial portions of the Software. â
â â
â 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 OR COPYRIGHT HOLDERS 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/struct/dirent.h"
#include "libc/errno.h"
#include "libc/limits.h"
#include "libc/mem/alg.h"
#include "libc/mem/mem.h"
#include "libc/str/str.h"
asm(".ident\t\"\\n\\n\
Musl libc (MIT License)\\n\
Copyright 2005-2014 Rich Felker, et. al.\"");
asm(".include \"libc/disclaimer.inc\"");
// clang-format off
int scandir(const char *path, struct dirent ***res,
int (*sel)(const struct dirent *),
int (*cmp)(const struct dirent **, const struct dirent **))
{
DIR *d = opendir(path);
struct dirent *de, **names=0, **tmp;
size_t cnt=0, len=0;
int old_errno = errno;
if (!d) return -1;
while ((errno=0), (de = readdir(d))) {
if (sel && !sel(de)) continue;
if (cnt >= len) {
len = 2*len+1;
if (len > SIZE_MAX/sizeof *names) break;
tmp = realloc(names, len * sizeof *names);
if (!tmp) break;
names = tmp;
}
names[cnt] = malloc(de->d_reclen);
if (!names[cnt]) break;
memcpy(names[cnt++], de, de->d_reclen);
}
closedir(d);
if (errno) {
if (names) while (cnt-->0) free(names[cnt]);
free(names);
return -1;
}
errno = old_errno;
if (cmp) qsort(names, cnt, sizeof *names, (int (*)(const void *, const void *))cmp);
*res = names;
return cnt;
}
| 3,803 | 79 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/real3.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/rand.h"
/**
* Generates number on (0,1)-real-interval, e.g.
*
* double x = _real3(lemur64())
*
* @see lemur64(), mt19937()
*/
double _real3(uint64_t x) {
return 1. / 4503599627370496. * ((x >> 12) + .5);
}
| 2,076 | 31 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fputs.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=8 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/lock.internal.h"
#include "libc/stdio/stdio.h"
/**
* Writes string to stream.
*
* Writing stops at the NUL-terminator, which isn't included in output.
* This function blocks until the full string is written, unless an
* unrecoverable error happens.
*
* @param s is a NUL-terminated string that's non-NULL
* @param f is an open stream
* @return bytes written, or -1 w/ errno
* @threadsafe
*/
int fputs(const char *s, FILE *f) {
int rc;
flockfile(f);
rc = fputs_unlocked(s, f);
funlockfile(f);
return rc;
}
| 2,384 | 41 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/jis0208.inc | 12288,12289,12290,65292,65294,12539,65306,65307,65311,65281,12443,12444,180,
65344,168,65342,65507,65343,12541,12542,12445,12446,12291,20189,12293,12294,
12295,12540,8213,8208,65295,92,12316,8214,65372,8230,8229,8216,8217,8220,8221,
65288,65289,12308,12309,65339,65341,65371,65373,12296,12297,12298,12299,12300,
12301,12302,12303,12304,12305,65291,8722,177,215,247,65309,8800,65308,65310,
8806,8807,8734,8756,9794,9792,176,8242,8243,8451,65509,65284,162,163,65285,
65283,65286,65290,65312,167,9734,9733,9675,9679,9678,9671,9670,9633,9632,9651,
9650,9661,9660,8251,12306,8594,8592,8593,8595,12307,0,0,0,0,0,0,0,0,0,0,0,
8712,8715,8838,8839,8834,8835,8746,8745,0,0,0,0,0,0,0,0,8743,8744,172,8658,
8660,8704,8707,0,0,0,0,0,0,0,0,0,0,0,8736,8869,8978,8706,8711,8801,8786,8810,
8811,8730,8765,8733,8757,8747,8748,0,0,0,0,0,0,0,8491,8240,9839,9837,9834,
8224,8225,182,0,0,0,0,9711,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,65296,65297,65298,
65299,65300,65301,65302,65303,65304,65305,0,0,0,0,0,0,0,65313,65314,65315,
65316,65317,65318,65319,65320,65321,65322,65323,65324,65325,65326,65327,65328,
65329,65330,65331,65332,65333,65334,65335,65336,65337,65338,0,0,0,0,0,0,65345,
65346,65347,
65348,65349,65350,65351,65352,65353,65354,65355,65356,65357,65358,65359,65360,
65361,65362,65363,65364,65365,65366,65367,65368,65369,65370,0,0,0,0,12353,
12354,12355,12356,12357,12358,12359,12360,12361,12362,12363,12364,12365,12366,
12367,12368,12369,12370,12371,12372,12373,12374,12375,12376,12377,12378,12379,
12380,12381,12382,12383,12384,12385,12386,12387,12388,12389,12390,12391,12392,
12393,12394,12395,12396,12397,12398,12399,12400,12401,12402,12403,12404,12405,
12406,12407,12408,12409,12410,12411,12412,12413,12414,12415,12416,12417,12418,
12419,12420,12421,12422,12423,12424,12425,12426,12427,12428,12429,12430,12431,
12432,12433,12434,12435,0,0,0,0,0,0,0,0,0,0,0,12449,12450,12451,12452,12453,
12454,12455,12456,12457,12458,12459,12460,12461,12462,12463,12464,12465,12466,
12467,12468,12469,12470,12471,12472,12473,12474,12475,12476,12477,12478,12479,
12480,12481,12482,12483,12484,12485,12486,12487,12488,12489,12490,12491,12492,
12493,12494,12495,12496,12497,12498,12499,12500,12501,12502,12503,12504,12505,
12506,12507,12508,12509,12510,12511,12512,12513,12514,12515,12516,12517,12518,
12519,12520,12521,12522,12523,12524,12525,12526,12527,12528,12529,12530,12531,
12532,12533,12534,0,0,0,0,0,0,0,0,913,914,915,916,917,918,919,920,921,922,923,
924,925,926,927,928,929,931,932,933,934,935,936,937,0,0,0,0,0,0,0,0,945,946,
947,948,949,950,951,952,953,
954,955,956,957,958,959,960,961,963,964,965,966,967,968,969,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1040,1041,1042,1043,
1044,1045,1025,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,1056,1057,
1058,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,1072,1073,1074,1075,1076,1077,1105,1078,1079,1080,1081,
1082,1083,1084,1085,1086,1087,1088,1089,1090,1091,1092,1093,1094,1095,1096,
1097,1098,1099,1100,1101,1102,1103,0,0,0,0,0,0,0,0,0,0,0,0,0,9472,9474,9484,
9488,9496,9492,9500,9516,9508,9524,9532,9473,9475,9487,9491,9499,9495,9507,
9523,9515,9531,9547,9504,9519,9512,9527,9535,9501,9520,9509,9528,9538,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,20124,21782,23043,38463,21696,24859,25384,23030,
36898,33909,33564,31312,24746,25569,28197,26093,33894,33446,39925,26771,22311,
26017,25201,23451,22992,34427,39156,32098,32190,39822,25110,31903,34999,23433,
24245,25353,26263,26696,38343,38797,26447,20197,20234,20301,20381,20553,22258,
22839,22996,23041,23561,24799,24847,24944,26131,26885,28858,30031,30064,31227,
32173,32239,32963,33806,34915,35586,36949,36986,21307,20117,20133,22495,32946,
37057,30959,19968,22769,28322,36920,31282,33576,33419,39983,20801,21360,21693,
21729,22240,23035,24341,39154,28139,32996,34093,38498,38512,38560,38907,21515,
21491,23431,28879,32701,36802,38632,21359,40284,31418,19985,30867,33276,28198,
22040,21764,27421,34074,39995,23013,21417,28006,29916,38287,22082,20113,36939,
38642,33615,39180,21473,21942,23344,24433,26144,26355,26628,27704,27891,27945,
29787,30408,31310,38964,33521,34907,35424,37613,28082,30123,30410,39365,24742,
35585,36234,38322,27022,21421,20870,22290,22576,22852,23476,24310,24616,25513,
25588,27839,28436,28814,28948,29017,29141,29503,32257,33398,33489,34199,36960,
37467,40219,22633,26044,27738,29989,20985,22830,22885,24448,24540,25276,26106,
27178,27431,27572,29579,32705,35158,40236,40206,40644,23713,27798,33659,20740,
23627,25014,33222,26742,29281,20057,20474,21368,24681,28201,31311,38899,19979,
21270,20206,20309,20285,20385,20339,21152,21487,22025,22799,23233,23478,23521,
31185,26247,26524,26550,27468,27827,28779,29634,31117,31166,31292,31623,33457,
33499,33540,33655,33775,33747,34662,35506,22057,36008,36838,36942,38686,34442,
20420,23784,25105,29273,30011,33253,33469,34558,36032,38597,39187,39381,20171,
20250,35299,22238,22602,22730,24315,24555,24618,24724,24674,25040,25106,25296,
25913,39745,26214,26800,28023,28784,30028,30342,32117,33445,34809,38283,38542,
35997,20977,21182,22806,21683,23475,23830,24936,27010,28079,30861,33995,34903,
35442,37799,39608,28012,39336,34521,22435,26623,34510,37390,21123,22151,21508,
24275,25313,25785,26684,26680,27579,29554,30906,31339,35226,35282,36203,36611,
37101,38307,38548,38761,23398,23731,27005,38989,38990,25499,31520,27179,27263,
26806,39949,28511,21106,21917,24688,25324,27963,28167,28369,33883,35088,36676,
19988,39993,21494,26907,27194,38788,26666,20828,31427,33970,37340,37772,22107,
40232,26658,33541,33841,31909,21000,33477,29926,20094,
20355,20896,23506,21002,21208,21223,24059,21914,22570,23014,23436,23448,23515,
24178,24185,24739,24863,24931,25022,25563,25954,26577,26707,26874,27454,27475,
27735,28450,28567,28485,29872,29976,30435,30475,31487,31649,31777,32233,32566,
32752,32925,33382,33694,35251,35532,36011,36996,37969,38291,38289,38306,38501,
38867,39208,33304,20024,21547,23736,24012,29609,30284,30524,23721,32747,36107,
38593,38929,38996,39000,20225,20238,21361,21916,22120,22522,22855,23305,23492,
23696,24076,24190,24524,25582,26426,26071,26082,26399,26827,26820,27231,24112,
27589,27671,27773,30079,31048,23395,31232,32000,24509,35215,35352,36020,36215,
36556,36637,39138,39438,39740,20096,20605,20736,22931,23452,25135,25216,25836,
27450,29344,30097,31047,32681,34811,35516,35696,25516,33738,38816,21513,21507,
21931,26708,27224,35440,30759,26485,40653,21364,23458,33050,34384,36870,19992,
20037,20167,20241,21450,21560,23470,24339,24613,25937,26429,27714,27762,27875,
28792,29699,31350,31406,31496,32026,31998,32102,26087,29275,21435,23621,24040,
25298,25312,25369,28192,34394,35377,36317,37624,28417,31142,39770,20136,20139,
20140,20379,20384,20689,20807,31478,20849,20982,21332,21281,21375,21483,21932,
22659,23777,24375,24394,24623,24656,24685,25375,25945,27211,27841,29378,29421,
30703,33016,33029,33288,34126,37111,37857,38911,39255,39514,20208,20957,23597,
26241,26989,23616,26354,26997,29577,26704,31873,20677,21220,22343,24062,37670,
26020,27427,27453,29748,31105,31165,31563,32202,33465,33740,34943,35167,35641,
36817,37329,21535,37504,20061,20534,21477,21306,29399,
29590,30697,33510,36527,39366,39368,39378,20855,24858,34398,21936,31354,20598,
23507,36935,38533,20018,27355,37351,23633,23624,25496,31391,27795,38772,36705,
31402,29066,38536,31874,26647,32368,26705,37740,21234,21531,34219,35347,32676,
36557,37089,21350,34952,31041,20418,20670,21009,20804,21843,22317,29674,22411,
22865,24418,24452,24693,24950,24935,25001,25522,25658,25964,26223,26690,28179,
30054,31293,31995,32076,32153,32331,32619,33550,33610,34509,35336,35427,35686,
36605,38938,40335,33464,36814,39912,21127,25119,25731,28608,38553,26689,20625,
27424,27770,28500,31348,32080,34880,35363,26376,20214,20537,20518,20581,20860,
21048,21091,21927,22287,22533,23244,24314,25010,25080,25331,25458,26908,27177,
29309,29356,29486,30740,30831,32121,30476,32937,35211,35609,36066,36562,36963,
37749,38522,38997,39443,40568,20803,21407,21427,24187,24358,28187,28304,29572,
29694,32067,33335,35328,35578,38480,20046,20491,21476,21628,22266,22993,23396,
24049,24235,24359,25144,25925,26543,28246,29392,31946,34996,32929,32993,33776,
34382,35463,36328,37431,38599,39015,40723,20116,20114,20237,21320,21577,21566,
23087,24460,24481,24735,26791,27278,29786,30849,35486,35492,35703,37264,20062,
39881,20132,20348,20399,20505,20502,20809,20844,21151,21177,21246,21402,21475,
21521,21518,21897,22353,22434,22909,23380,23389,23439,24037,24039,24055,24184,
24195,24218,24247,24344,24658,24908,25239,25304,25511,25915,26114,26179,26356,
26477,26657,26775,27083,27743,27946,28009,28207,28317,30002,30343,30828,31295,
31968,32005,32024,32094,32177,32789,32771,32943,32945,
33108,33167,33322,33618,34892,34913,35611,36002,36092,37066,37237,37489,30783,
37628,38308,38477,38917,39321,39640,40251,21083,21163,21495,21512,22741,25335,
28640,35946,36703,40633,20811,21051,21578,22269,31296,37239,40288,40658,29508,
28425,33136,29969,24573,24794,39592,29403,36796,27492,38915,20170,22256,22372,
22718,23130,24680,25031,26127,26118,26681,26801,28151,30165,32058,33390,39746,
20123,20304,21449,21766,23919,24038,24046,26619,27801,29811,30722,35408,37782,
35039,22352,24231,25387,20661,20652,20877,26368,21705,22622,22971,23472,24425,
25165,25505,26685,27507,28168,28797,37319,29312,30741,30758,31085,25998,32048,
33756,35009,36617,38555,21092,22312,26448,32618,36001,20916,22338,38442,22586,
27018,32948,21682,23822,22524,30869,40442,20316,21066,21643,25662,26152,26388,
26613,31364,31574,32034,37679,26716,39853,31545,21273,20874,21047,23519,25334,
25774,25830,26413,27578,34217,38609,30352,39894,25420,37638,39851,30399,26194,
19977,20632,21442,23665,24808,25746,25955,26719,29158,29642,29987,31639,32386,
34453,35715,36059,37240,39184,26028,26283,27531,20181,20180,20282,20351,21050,
21496,21490,21987,22235,22763,22987,22985,23039,23376,23629,24066,24107,24535,
24605,25351,25903,23388,26031,26045,26088,26525,27490,27515,27663,29509,31049,
31169,31992,32025,32043,32930,33026,33267,35222,35422,35433,35430,35468,35566,
36039,36060,38604,39164,27503,20107,20284,20365,20816,23383,23546,24904,25345,
26178,27425,28363,27835,29246,29885,30164,30913,31034,32780,32819,33258,33940,
36766,27728,40575,24335,35672,40235,31482,36600,23437,
38635,19971,21489,22519,22833,23241,23460,24713,28287,28422,30142,36074,23455,
34048,31712,20594,26612,33437,23649,34122,32286,33294,20889,23556,25448,36198,
26012,29038,31038,32023,32773,35613,36554,36974,34503,37034,20511,21242,23610,
26451,28796,29237,37196,37320,37675,33509,23490,24369,24825,20027,21462,23432,
25163,26417,27530,29417,29664,31278,33131,36259,37202,39318,20754,21463,21610,
23551,25480,27193,32172,38656,22234,21454,21608,23447,23601,24030,20462,24833,
25342,27954,31168,31179,32066,32333,32722,33261,33311,33936,34886,35186,35728,
36468,36655,36913,37195,37228,38598,37276,20160,20303,20805,21313,24467,25102,
26580,27713,28171,29539,32294,37325,37507,21460,22809,23487,28113,31069,32302,
31899,22654,29087,20986,34899,36848,20426,23803,26149,30636,31459,33308,39423,
20934,24490,26092,26991,27529,28147,28310,28516,30462,32020,24033,36981,37255,
38918,20966,21021,25152,26257,26329,28186,24246,32210,32626,26360,34223,34295,
35576,21161,21465,22899,24207,24464,24661,37604,38500,20663,20767,21213,21280,
21319,21484,21736,21830,21809,22039,22888,22974,23100,23477,23558,23567,23569,
23578,24196,24202,24288,24432,25215,25220,25307,25484,25463,26119,26124,26157,
26230,26494,26786,27167,27189,27836,28040,28169,28248,28988,28966,29031,30151,
30465,30813,30977,31077,31216,31456,31505,31911,32057,32918,33750,33931,34121,
34909,35059,35359,35388,35412,35443,35937,36062,37284,37478,37758,37912,38556,
38808,19978,19976,19998,20055,20887,21104,22478,22580,22732,23330,24120,24773,
25854,26465,26454,27972,29366,30067,31331,33976,35698,
37304,37664,22065,22516,39166,25325,26893,27542,29165,32340,32887,33394,35302,
39135,34645,36785,23611,20280,20449,20405,21767,23072,23517,23529,24515,24910,
25391,26032,26187,26862,27035,28024,28145,30003,30137,30495,31070,31206,32051,
33251,33455,34218,35242,35386,36523,36763,36914,37341,38663,20154,20161,20995,
22645,22764,23563,29978,23613,33102,35338,36805,38499,38765,31525,35535,38920,
37218,22259,21416,36887,21561,22402,24101,25512,27700,28810,30561,31883,32736,
34928,36930,37204,37648,37656,38543,29790,39620,23815,23913,25968,26530,36264,
38619,25454,26441,26905,33733,38935,38592,35070,28548,25722,23544,19990,28716,
30045,26159,20932,21046,21218,22995,24449,24615,25104,25919,25972,26143,26228,
26866,26646,27491,28165,29298,29983,30427,31934,32854,22768,35069,35199,35488,
35475,35531,36893,37266,38738,38745,25993,31246,33030,38587,24109,24796,25114,
26021,26132,26512,30707,31309,31821,32318,33034,36012,36196,36321,36447,30889,
20999,25305,25509,25666,25240,35373,31363,31680,35500,38634,32118,33292,34633,
20185,20808,21315,21344,23459,23554,23574,24029,25126,25159,25776,26643,26676,
27849,27973,27927,26579,28508,29006,29053,26059,31359,31661,32218,32330,32680,
33146,33307,33337,34214,35438,36046,36341,36984,36983,37549,37521,38275,39854,
21069,21892,28472,28982,20840,31109,32341,33203,31950,22092,22609,23720,25514,
26366,26365,26970,29401,30095,30094,30990,31062,31199,31895,32032,32068,34311,
35380,38459,36961,40736,20711,21109,21452,21474,20489,21930,22766,22863,29245,
23435,23652,21277,24803,24819,25436,25475,25407,25531,
25805,26089,26361,24035,27085,27133,28437,29157,20105,30185,30456,31379,31967,
32207,32156,32865,33609,33624,33900,33980,34299,35013,36208,36865,36973,37783,
38684,39442,20687,22679,24974,33235,34101,36104,36896,20419,20596,21063,21363,
24687,25417,26463,28204,36275,36895,20439,23646,36042,26063,32154,21330,34966,
20854,25539,23384,23403,23562,25613,26449,36956,20182,22810,22826,27760,35409,
21822,22549,22949,24816,25171,26561,33333,26965,38464,39364,39464,20307,22534,
23550,32784,23729,24111,24453,24608,24907,25140,26367,27888,28382,32974,33151,
33492,34955,36024,36864,36910,38538,40667,39899,20195,21488,22823,31532,37261,
38988,40441,28381,28711,21331,21828,23429,25176,25246,25299,27810,28655,29730,
35351,37944,28609,35582,33592,20967,34552,21482,21481,20294,36948,36784,22890,
33073,24061,31466,36799,26842,35895,29432,40008,27197,35504,20025,21336,22022,
22374,25285,25506,26086,27470,28129,28251,28845,30701,31471,31658,32187,32829,
32966,34507,35477,37723,22243,22727,24382,26029,26262,27264,27573,30007,35527,
20516,30693,22320,24347,24677,26234,27744,30196,31258,32622,33268,34584,36933,
39347,31689,30044,31481,31569,33988,36880,31209,31378,33590,23265,30528,20013,
20210,23449,24544,25277,26172,26609,27880,34411,34935,35387,37198,37619,39376,
27159,28710,29482,33511,33879,36015,19969,20806,20939,21899,23541,24086,24115,
24193,24340,24373,24427,24500,25074,25361,26274,26397,28526,29266,30010,30522,
32884,33081,33144,34678,35519,35548,36229,36339,37530,38263,38914,40165,21189,
25431,30452,26389,27784,29645,36035,37806,38515,27941,
22684,26894,27084,36861,37786,30171,36890,22618,26626,25524,27131,20291,28460,
26584,36795,34086,32180,37716,26943,28528,22378,22775,23340,32044,29226,21514,
37347,40372,20141,20302,20572,20597,21059,35998,21576,22564,23450,24093,24213,
24237,24311,24351,24716,25269,25402,25552,26799,27712,30855,31118,31243,32224,
33351,35330,35558,36420,36883,37048,37165,37336,40718,27877,25688,25826,25973,
28404,30340,31515,36969,37841,28346,21746,24505,25764,36685,36845,37444,20856,
22635,22825,23637,24215,28155,32399,29980,36028,36578,39003,28857,20253,27583,
28593,30000,38651,20814,21520,22581,22615,22956,23648,24466,26007,26460,28193,
30331,33759,36077,36884,37117,37709,30757,30778,21162,24230,22303,22900,24594,
20498,20826,20908,20941,20992,21776,22612,22616,22871,23445,23798,23947,24764,
25237,25645,26481,26691,26812,26847,30423,28120,28271,28059,28783,29128,24403,
30168,31095,31561,31572,31570,31958,32113,21040,33891,34153,34276,35342,35588,
35910,36367,36867,36879,37913,38518,38957,39472,38360,20685,21205,21516,22530,
23566,24999,25758,27934,30643,31461,33012,33796,36947,37509,23776,40199,21311,
24471,24499,28060,29305,30563,31167,31716,27602,29420,35501,26627,27233,20984,
31361,26932,23626,40182,33515,23493,37193,28702,22136,23663,24775,25958,27788,
35930,36929,38931,21585,26311,37389,22856,37027,20869,20045,20970,34201,35598,
28760,25466,37707,26978,39348,32260,30071,21335,26976,36575,38627,27741,20108,
23612,24336,36841,21250,36049,32905,34425,24319,26085,20083,20837,22914,23615,
38894,20219,22922,24525,35469,28641,31152,31074,23527,
33905,29483,29105,24180,24565,25467,25754,29123,31896,20035,24316,20043,22492,
22178,24745,28611,32013,33021,33075,33215,36786,35223,34468,24052,25226,25773,
35207,26487,27874,27966,29750,30772,23110,32629,33453,39340,20467,24259,25309,
25490,25943,26479,30403,29260,32972,32954,36649,37197,20493,22521,23186,26757,
26995,29028,29437,36023,22770,36064,38506,36889,34687,31204,30695,33833,20271,
21093,21338,25293,26575,27850,30333,31636,31893,33334,34180,36843,26333,28448,
29190,32283,33707,39361,40614,20989,31665,30834,31672,32903,31560,27368,24161,
32908,30033,30048,20843,37474,28300,30330,37271,39658,20240,32624,25244,31567,
38309,40169,22138,22617,34532,38588,20276,21028,21322,21453,21467,24070,25644,
26001,26495,27710,27726,29256,29359,29677,30036,32321,33324,34281,36009,31684,
37318,29033,38930,39151,25405,26217,30058,30436,30928,34115,34542,21290,21329,
21542,22915,24199,24444,24754,25161,25209,25259,26000,27604,27852,30130,30382,
30865,31192,32203,32631,32933,34987,35513,36027,36991,38750,39131,27147,31800,
20633,23614,24494,26503,27608,29749,30473,32654,40763,26570,31255,21305,30091,
39661,24422,33181,33777,32920,24380,24517,30050,31558,36924,26727,23019,23195,
32016,30334,35628,20469,24426,27161,27703,28418,29922,31080,34920,35413,35961,
24287,25551,30149,31186,33495,37672,37618,33948,34541,39981,21697,24428,25996,
27996,28693,36007,36051,38971,25935,29942,19981,20184,22496,22827,23142,23500,
20904,24067,24220,24598,25206,25975,26023,26222,28014,29238,31526,33104,33178,
33433,35676,36000,36070,36212,38428,38468,20398,25771,
27494,33310,33889,34154,37096,23553,26963,39080,33914,34135,20239,21103,24489,
24133,26381,31119,33145,35079,35206,28149,24343,25173,27832,20175,29289,39826,
20998,21563,22132,22707,24996,25198,28954,22894,31881,31966,32027,38640,25991,
32862,19993,20341,20853,22592,24163,24179,24330,26564,20006,34109,38281,38491,
31859,38913,20731,22721,30294,30887,21029,30629,34065,31622,20559,22793,29255,
31687,32232,36794,36820,36941,20415,21193,23081,24321,38829,20445,33303,37610,
22275,25429,27497,29995,35036,36628,31298,21215,22675,24917,25098,26286,27597,
31807,33769,20515,20472,21253,21574,22577,22857,23453,23792,23791,23849,24214,
25265,25447,25918,26041,26379,27861,27873,28921,30770,32299,32990,33459,33804,
34028,34562,35090,35370,35914,37030,37586,39165,40179,40300,20047,20129,20621,
21078,22346,22952,24125,24536,24537,25151,26292,26395,26576,26834,20882,32033,
32938,33192,35584,35980,36031,37502,38450,21536,38956,21271,20693,21340,22696,
25778,26420,29287,30566,31302,37350,21187,27809,27526,22528,24140,22868,26412,
32763,20961,30406,25705,30952,39764,40635,22475,22969,26151,26522,27598,21737,
27097,24149,33180,26517,39850,26622,40018,26717,20134,20451,21448,25273,26411,
27819,36804,20397,32365,40639,19975,24930,28288,28459,34067,21619,26410,39749,
24051,31637,23724,23494,34588,28234,34001,31252,33032,22937,31885,27665,30496,
21209,22818,28961,29279,30683,38695,40289,26891,23167,23064,20901,21517,21629,
26126,30431,36855,37528,40180,23018,29277,28357,20813,26825,32191,32236,38754,
40634,25720,27169,33538,22916,23391,27611,29467,30450,
32178,32791,33945,20786,26408,40665,30446,26466,21247,39173,23588,25147,31870,
36016,21839,24758,32011,38272,21249,20063,20918,22812,29242,32822,37326,24357,
30690,21380,24441,32004,34220,35379,36493,38742,26611,34222,37971,24841,24840,
27833,30290,35565,36664,21807,20305,20778,21191,21451,23461,24189,24736,24962,
25558,26377,26586,28263,28044,29494,29495,30001,31056,35029,35480,36938,37009,
37109,38596,34701,22805,20104,20313,19982,35465,36671,38928,20653,24188,22934,
23481,24248,25562,25594,25793,26332,26954,27096,27915,28342,29076,29992,31407,
32650,32768,33865,33993,35201,35617,36362,36965,38525,39178,24958,25233,27442,
27779,28020,32716,32764,28096,32645,34746,35064,26469,33713,38972,38647,27931,
32097,33853,37226,20081,21365,23888,27396,28651,34253,34349,35239,21033,21519,
23653,26446,26792,29702,29827,30178,35023,35041,37324,38626,38520,24459,29575,
31435,33870,25504,30053,21129,27969,28316,29705,30041,30827,31890,38534,31452,
40845,20406,24942,26053,34396,20102,20142,20698,20001,20940,23534,26009,26753,
28092,29471,30274,30637,31260,31975,33391,35538,36988,37327,38517,38936,21147,
32209,20523,21400,26519,28107,29136,29747,33256,36650,38563,40023,40607,29792,
22593,28057,32047,39006,20196,20278,20363,20919,21169,23994,24604,29618,31036,
33491,37428,38583,38646,38666,40599,40802,26278,27508,21015,21155,28872,35010,
24265,24651,24976,28451,29001,31806,32244,32879,34030,36899,37676,21570,39791,
27347,28809,36034,36335,38706,21172,23105,24266,24324,26391,27004,27028,28010,
28431,29282,29436,31725,32769,32894,34635,37070,20845,
40595,31108,32907,37682,35542,20525,21644,35441,27498,36036,33031,24785,26528,
40434,20121,20120,39952,35435,34241,34152,26880,28286,30871,33109,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
24332,19984,19989,20010,20017,20022,20028,20031,20034,20054,20056,20098,20101,
35947,20106,33298,24333,20110,20126,20127,20128,20130,20144,20147,20150,20174,
20173,20164,20166,20162,20183,20190,20205,20191,20215,20233,20314,20272,20315,
20317,20311,20295,20342,20360,20367,20376,20347,20329,20336,20369,20335,20358,
20374,20760,20436,20447,20430,20440,20443,20433,20442,20432,20452,20453,20506,
20520,20500,20522,20517,20485,20252,20470,20513,20521,20524,20478,20463,20497,
20486,20547,20551,26371,20565,20560,20552,20570,20566,20588,20600,20608,20634,
20613,20660,20658,20681,20682,20659,20674,20694,20702,20709,20717,20707,20718,
20729,20725,20745,20737,20738,20758,20757,20756,20762,20769,20794,20791,20796,
20795,20799,20800,20818,20812,20820,20834,31480,20841,20842,20846,20864,20866,
22232,20876,20873,20879,20881,20883,20885,20886,20900,20902,20898,20905,20906,
20907,20915,20913,20914,20912,20917,20925,20933,20937,20955,20960,34389,20969,
20973,20976,20981,20990,20996,21003,21012,21006,21031,21034,21038,21043,21049,
21071,21060,21067,21068,21086,21076,21098,21108,21097,21107,21119,21117,21133,
21140,21138,21105,21128,21137,36776,36775,
21164,21165,21180,21173,21185,21197,21207,21214,21219,21222,39149,21216,21235,
21237,21240,21241,21254,21256,30008,21261,21264,21263,21269,21274,21283,21295,
21297,21299,21304,21312,21318,21317,19991,21321,21325,20950,21342,21353,21358,
22808,21371,21367,21378,21398,21408,21414,21413,21422,21424,21430,21443,31762,
38617,21471,26364,29166,21486,21480,21485,21498,21505,21565,21568,21548,21549,
21564,21550,21558,21545,21533,21582,21647,21621,21646,21599,21617,21623,21616,
21650,21627,21632,21622,21636,21648,21638,21703,21666,21688,21669,21676,21700,
21704,21672,21675,21698,21668,21694,21692,21720,21733,21734,21775,21780,21757,
21742,21741,21754,21730,21817,21824,21859,21836,21806,21852,21829,21846,21847,
21816,21811,21853,21913,21888,21679,21898,21919,21883,21886,21912,21918,21934,
21884,21891,21929,21895,21928,21978,21957,21983,21956,21980,21988,21972,22036,
22007,22038,22014,22013,22043,22009,22094,22096,29151,22068,22070,22066,22072,
22123,22116,22063,22124,22122,22150,22144,22154,22176,22164,22159,22181,22190,
22198,22196,22210,22204,22209,22211,22208,22216,22222,22225,22227,22231,22254,
22265,22272,22271,22276,22281,22280,22283,22285,22291,22296,22294,21959,22300,
22310,22327,22328,22350,22331,22336,22351,22377,22464,22408,22369,22399,22409,
22419,22432,22451,22436,22442,22448,22467,22470,22484,22482,22483,22538,22486,
22499,22539,22553,22557,22642,22561,22626,22603,22640,27584,22610,22589,22649,
22661,22713,22687,22699,22714,22750,22715,22712,22702,22725,22739,22737,22743,
22745,22744,22757,22748,22756,22751,22767,22778,22777,
22779,22780,22781,22786,22794,22800,22811,26790,22821,22828,22829,22834,22840,
22846,31442,22869,22864,22862,22874,22872,22882,22880,22887,22892,22889,22904,
22913,22941,20318,20395,22947,22962,22982,23016,23004,22925,23001,23002,23077,
23071,23057,23068,23049,23066,23104,23148,23113,23093,23094,23138,23146,23194,
23228,23230,23243,23234,23229,23267,23255,23270,23273,23254,23290,23291,23308,
23307,23318,23346,23248,23338,23350,23358,23363,23365,23360,23377,23381,23386,
23387,23397,23401,23408,23411,23413,23416,25992,23418,23424,23427,23462,23480,
23491,23495,23497,23508,23504,23524,23526,23522,23518,23525,23531,23536,23542,
23539,23557,23559,23560,23565,23571,23584,23586,23592,23608,23609,23617,23622,
23630,23635,23632,23631,23409,23660,23662,20066,23670,23673,23692,23697,23700,
22939,23723,23739,23734,23740,23735,23749,23742,23751,23769,23785,23805,23802,
23789,23948,23786,23819,23829,23831,23900,23839,23835,23825,23828,23842,23834,
23833,23832,23884,23890,23886,23883,23916,23923,23926,23943,23940,23938,23970,
23965,23980,23982,23997,23952,23991,23996,24009,24013,24019,24018,24022,24027,
24043,24050,24053,24075,24090,24089,24081,24091,24118,24119,24132,24131,24128,
24142,24151,24148,24159,24162,24164,24135,24181,24182,24186,40636,24191,24224,
24257,24258,24264,24272,24271,24278,24291,24285,24282,24283,24290,24289,24296,
24297,24300,24305,24307,24304,24308,24312,24318,24323,24329,24413,24412,24331,
24337,24342,24361,24365,24376,24385,24392,24396,24398,24367,24401,24406,24407,
24409,24417,24429,24435,24439,24451,24450,24447,24458,
24456,24465,24455,24478,24473,24472,24480,24488,24493,24508,24534,24571,24548,
24568,24561,24541,24755,24575,24609,24672,24601,24592,24617,24590,24625,24603,
24597,24619,24614,24591,24634,24666,24641,24682,24695,24671,24650,24646,24653,
24675,24643,24676,24642,24684,24683,24665,24705,24717,24807,24707,24730,24708,
24731,24726,24727,24722,24743,24715,24801,24760,24800,24787,24756,24560,24765,
24774,24757,24792,24909,24853,24838,24822,24823,24832,24820,24826,24835,24865,
24827,24817,24845,24846,24903,24894,24872,24871,24906,24895,24892,24876,24884,
24893,24898,24900,24947,24951,24920,24921,24922,24939,24948,24943,24933,24945,
24927,24925,24915,24949,24985,24982,24967,25004,24980,24986,24970,24977,25003,
25006,25036,25034,25033,25079,25032,25027,25030,25018,25035,32633,25037,25062,
25059,25078,25082,25076,25087,25085,25084,25086,25088,25096,25097,25101,25100,
25108,25115,25118,25121,25130,25134,25136,25138,25139,25153,25166,25182,25187,
25179,25184,25192,25212,25218,25225,25214,25234,25235,25238,25300,25219,25236,
25303,25297,25275,25295,25343,25286,25812,25288,25308,25292,25290,25282,25287,
25243,25289,25356,25326,25329,25383,25346,25352,25327,25333,25424,25406,25421,
25628,25423,25494,25486,25472,25515,25462,25507,25487,25481,25503,25525,25451,
25449,25534,25577,25536,25542,25571,25545,25554,25590,25540,25622,25652,25606,
25619,25638,25654,25885,25623,25640,25615,25703,25711,25718,25678,25898,25749,
25747,25765,25769,25736,25788,25818,25810,25797,25799,25787,25816,25794,25841,
25831,33289,25824,25825,25260,25827,25839,25900,25846,
25844,25842,25850,25856,25853,25880,25884,25861,25892,25891,25899,25908,25909,
25911,25910,25912,30027,25928,25942,25941,25933,25944,25950,25949,25970,25976,
25986,25987,35722,26011,26015,26027,26039,26051,26054,26049,26052,26060,26066,
26075,26073,26080,26081,26097,26482,26122,26115,26107,26483,26165,26166,26164,
26140,26191,26180,26185,26177,26206,26205,26212,26215,26216,26207,26210,26224,
26243,26248,26254,26249,26244,26264,26269,26305,26297,26313,26302,26300,26308,
26296,26326,26330,26336,26175,26342,26345,26352,26357,26359,26383,26390,26398,
26406,26407,38712,26414,26431,26422,26433,26424,26423,26438,26462,26464,26457,
26467,26468,26505,26480,26537,26492,26474,26508,26507,26534,26529,26501,26551,
26607,26548,26604,26547,26601,26552,26596,26590,26589,26594,26606,26553,26574,
26566,26599,27292,26654,26694,26665,26688,26701,26674,26702,26803,26667,26713,
26723,26743,26751,26783,26767,26797,26772,26781,26779,26755,27310,26809,26740,
26805,26784,26810,26895,26765,26750,26881,26826,26888,26840,26914,26918,26849,
26892,26829,26836,26855,26837,26934,26898,26884,26839,26851,26917,26873,26848,
26863,26920,26922,26906,26915,26913,26822,27001,26999,26972,27000,26987,26964,
27006,26990,26937,26996,26941,26969,26928,26977,26974,26973,27009,26986,27058,
27054,27088,27071,27073,27091,27070,27086,23528,27082,27101,27067,27075,27047,
27182,27025,27040,27036,27029,27060,27102,27112,27138,27163,27135,27402,27129,
27122,27111,27141,27057,27166,27117,27156,27115,27146,27154,27329,27171,27155,
27204,27148,27250,27190,27256,27207,27234,27225,27238,
27208,27192,27170,27280,27277,27296,27268,27298,27299,27287,34327,27323,27331,
27330,27320,27315,27308,27358,27345,27359,27306,27354,27370,27387,27397,34326,
27386,27410,27414,39729,27423,27448,27447,30428,27449,39150,27463,27459,27465,
27472,27481,27476,27483,27487,27489,27512,27513,27519,27520,27524,27523,27533,
27544,27541,27550,27556,27562,27563,27567,27570,27569,27571,27575,27580,27590,
27595,27603,27615,27628,27627,27635,27631,40638,27656,27667,27668,27675,27684,
27683,27742,27733,27746,27754,27778,27789,27802,27777,27803,27774,27752,27763,
27794,27792,27844,27889,27859,27837,27863,27845,27869,27822,27825,27838,27834,
27867,27887,27865,27882,27935,34893,27958,27947,27965,27960,27929,27957,27955,
27922,27916,28003,28051,28004,27994,28025,27993,28046,28053,28644,28037,28153,
28181,28170,28085,28103,28134,28088,28102,28140,28126,28108,28136,28114,28101,
28154,28121,28132,28117,28138,28142,28205,28270,28206,28185,28274,28255,28222,
28195,28267,28203,28278,28237,28191,28227,28218,28238,28196,28415,28189,28216,
28290,28330,28312,28361,28343,28371,28349,28335,28356,28338,28372,28373,28303,
28325,28354,28319,28481,28433,28748,28396,28408,28414,28479,28402,28465,28399,
28466,28364,28478,28435,28407,28550,28538,28536,28545,28544,28527,28507,28659,
28525,28546,28540,28504,28558,28561,28610,28518,28595,28579,28577,28580,28601,
28614,28586,28639,28629,28652,28628,28632,28657,28654,28635,28681,28683,28666,
28689,28673,28687,28670,28699,28698,28532,28701,28696,28703,28720,28734,28722,
28753,28771,28825,28818,28847,28913,28844,28856,28851,
28846,28895,28875,28893,28889,28937,28925,28956,28953,29029,29013,29064,29030,
29026,29004,29014,29036,29071,29179,29060,29077,29096,29100,29143,29113,29118,
29138,29129,29140,29134,29152,29164,29159,29173,29180,29177,29183,29197,29200,
29211,29224,29229,29228,29232,29234,29243,29244,29247,29248,29254,29259,29272,
29300,29310,29314,29313,29319,29330,29334,29346,29351,29369,29362,29379,29382,
29380,29390,29394,29410,29408,29409,29433,29431,20495,29463,29450,29468,29462,
29469,29492,29487,29481,29477,29502,29518,29519,40664,29527,29546,29544,29552,
29560,29557,29563,29562,29640,29619,29646,29627,29632,29669,29678,29662,29858,
29701,29807,29733,29688,29746,29754,29781,29759,29791,29785,29761,29788,29801,
29808,29795,29802,29814,29822,29835,29854,29863,29898,29903,29908,29681,29920,
29923,29927,29929,29934,29938,29936,29937,29944,29943,29956,29955,29957,29964,
29966,29965,29973,29971,29982,29990,29996,30012,30020,30029,30026,30025,30043,
30022,30042,30057,30052,30055,30059,30061,30072,30070,30086,30087,30068,30090,
30089,30082,30100,30106,30109,30117,30115,30146,30131,30147,30133,30141,30136,
30140,30129,30157,30154,30162,30169,30179,30174,30206,30207,30204,30209,30192,
30202,30194,30195,30219,30221,30217,30239,30247,30240,30241,30242,30244,30260,
30256,30267,30279,30280,30278,30300,30296,30305,30306,30312,30313,30314,30311,
30316,30320,30322,30326,30328,30332,30336,30339,30344,30347,30350,30358,30355,
30361,30362,30384,30388,30392,30393,30394,30402,30413,30422,30418,30430,30433,
30437,30439,30442,34351,30459,30472,30471,30468,30505,
30500,30494,30501,30502,30491,30519,30520,30535,30554,30568,30571,30555,30565,
30591,30590,30585,30606,30603,30609,30624,30622,30640,30646,30649,30655,30652,
30653,30651,30663,30669,30679,30682,30684,30691,30702,30716,30732,30738,31014,
30752,31018,30789,30862,30836,30854,30844,30874,30860,30883,30901,30890,30895,
30929,30918,30923,30932,30910,30908,30917,30922,30956,30951,30938,30973,30964,
30983,30994,30993,31001,31020,31019,31040,31072,31063,31071,31066,31061,31059,
31098,31103,31114,31133,31143,40779,31146,31150,31155,31161,31162,31177,31189,
31207,31212,31201,31203,31240,31245,31256,31257,31264,31263,31104,31281,31291,
31294,31287,31299,31319,31305,31329,31330,31337,40861,31344,31353,31357,31368,
31383,31381,31384,31382,31401,31432,31408,31414,31429,31428,31423,36995,31431,
31434,31437,31439,31445,31443,31449,31450,31453,31457,31458,31462,31469,31472,
31490,31503,31498,31494,31539,31512,31513,31518,31541,31528,31542,31568,31610,
31492,31565,31499,31564,31557,31605,31589,31604,31591,31600,31601,31596,31598,
31645,31640,31647,31629,31644,31642,31627,31634,31631,31581,31641,31691,31681,
31692,31695,31668,31686,31709,31721,31761,31764,31718,31717,31840,31744,31751,
31763,31731,31735,31767,31757,31734,31779,31783,31786,31775,31799,31787,31805,
31820,31811,31828,31823,31808,31824,31832,31839,31844,31830,31845,31852,31861,
31875,31888,31908,31917,31906,31915,31905,31912,31923,31922,31921,31918,31929,
31933,31936,31941,31938,31960,31954,31964,31970,39739,31983,31986,31988,31990,
31994,32006,32002,32028,32021,32010,32069,32075,32046,
32050,32063,32053,32070,32115,32086,32078,32114,32104,32110,32079,32099,32147,
32137,32091,32143,32125,32155,32186,32174,32163,32181,32199,32189,32171,32317,
32162,32175,32220,32184,32159,32176,32216,32221,32228,32222,32251,32242,32225,
32261,32266,32291,32289,32274,32305,32287,32265,32267,32290,32326,32358,32315,
32309,32313,32323,32311,32306,32314,32359,32349,32342,32350,32345,32346,32377,
32362,32361,32380,32379,32387,32213,32381,36782,32383,32392,32393,32396,32402,
32400,32403,32404,32406,32398,32411,32412,32568,32570,32581,32588,32589,32590,
32592,32593,32597,32596,32600,32607,32608,32616,32617,32615,32632,32642,32646,
32643,32648,32647,32652,32660,32670,32669,32666,32675,32687,32690,32697,32686,
32694,32696,35697,32709,32710,32714,32725,32724,32737,32742,32745,32755,32761,
39132,32774,32772,32779,32786,32792,32793,32796,32801,32808,32831,32827,32842,
32838,32850,32856,32858,32863,32866,32872,32883,32882,32880,32886,32889,32893,
32895,32900,32902,32901,32923,32915,32922,32941,20880,32940,32987,32997,32985,
32989,32964,32986,32982,33033,33007,33009,33051,33065,33059,33071,33099,38539,
33094,33086,33107,33105,33020,33137,33134,33125,33126,33140,33155,33160,33162,
33152,33154,33184,33173,33188,33187,33119,33171,33193,33200,33205,33214,33208,
33213,33216,33218,33210,33225,33229,33233,33241,33240,33224,33242,33247,33248,
33255,33274,33275,33278,33281,33282,33285,33287,33290,33293,33296,33302,33321,
33323,33336,33331,33344,33369,33368,33373,33370,33375,33380,33378,33384,33386,
33387,33326,33393,33399,33400,33406,33421,33426,33451,
33439,33467,33452,33505,33507,33503,33490,33524,33523,33530,33683,33539,33531,
33529,33502,33542,33500,33545,33497,33589,33588,33558,33586,33585,33600,33593,
33616,33605,33583,33579,33559,33560,33669,33690,33706,33695,33698,33686,33571,
33678,33671,33674,33660,33717,33651,33653,33696,33673,33704,33780,33811,33771,
33742,33789,33795,33752,33803,33729,33783,33799,33760,33778,33805,33826,33824,
33725,33848,34054,33787,33901,33834,33852,34138,33924,33911,33899,33965,33902,
33922,33897,33862,33836,33903,33913,33845,33994,33890,33977,33983,33951,34009,
33997,33979,34010,34000,33985,33990,34006,33953,34081,34047,34036,34071,34072,
34092,34079,34069,34068,34044,34112,34147,34136,34120,34113,34306,34123,34133,
34176,34212,34184,34193,34186,34216,34157,34196,34203,34282,34183,34204,34167,
34174,34192,34249,34234,34255,34233,34256,34261,34269,34277,34268,34297,34314,
34323,34315,34302,34298,34310,34338,34330,34352,34367,34381,20053,34388,34399,
34407,34417,34451,34467,34473,34474,34443,34444,34486,34479,34500,34502,34480,
34505,34851,34475,34516,34526,34537,34540,34527,34523,34543,34578,34566,34568,
34560,34563,34555,34577,34569,34573,34553,34570,34612,34623,34615,34619,34597,
34601,34586,34656,34655,34680,34636,34638,34676,34647,34664,34670,34649,34643,
34659,34666,34821,34722,34719,34690,34735,34763,34749,34752,34768,38614,34731,
34756,34739,34759,34758,34747,34799,34802,34784,34831,34829,34814,34806,34807,
34830,34770,34833,34838,34837,34850,34849,34865,34870,34873,34855,34875,34884,
34882,34898,34905,34910,34914,34923,34945,34942,34974,
34933,34941,34997,34930,34946,34967,34962,34990,34969,34978,34957,34980,34992,
35007,34993,35011,35012,35028,35032,35033,35037,35065,35074,35068,35060,35048,
35058,35076,35084,35082,35091,35139,35102,35109,35114,35115,35137,35140,35131,
35126,35128,35148,35101,35168,35166,35174,35172,35181,35178,35183,35188,35191,
35198,35203,35208,35210,35219,35224,35233,35241,35238,35244,35247,35250,35258,
35261,35263,35264,35290,35292,35293,35303,35316,35320,35331,35350,35344,35340,
35355,35357,35365,35382,35393,35419,35410,35398,35400,35452,35437,35436,35426,
35461,35458,35460,35496,35489,35473,35493,35494,35482,35491,35524,35533,35522,
35546,35563,35571,35559,35556,35569,35604,35552,35554,35575,35550,35547,35596,
35591,35610,35553,35606,35600,35607,35616,35635,38827,35622,35627,35646,35624,
35649,35660,35663,35662,35657,35670,35675,35674,35691,35679,35692,35695,35700,
35709,35712,35724,35726,35730,35731,35734,35737,35738,35898,35905,35903,35912,
35916,35918,35920,35925,35938,35948,35960,35962,35970,35977,35973,35978,35981,
35982,35988,35964,35992,25117,36013,36010,36029,36018,36019,36014,36022,36040,
36033,36068,36067,36058,36093,36090,36091,36100,36101,36106,36103,36111,36109,
36112,40782,36115,36045,36116,36118,36199,36205,36209,36211,36225,36249,36290,
36286,36282,36303,36314,36310,36300,36315,36299,36330,36331,36319,36323,36348,
36360,36361,36351,36381,36382,36368,36383,36418,36405,36400,36404,36426,36423,
36425,36428,36432,36424,36441,36452,36448,36394,36451,36437,36470,36466,36476,
36481,36487,36485,36484,36491,36490,36499,36497,36500,
36505,36522,36513,36524,36528,36550,36529,36542,36549,36552,36555,36571,36579,
36604,36603,36587,36606,36618,36613,36629,36626,36633,36627,36636,36639,36635,
36620,36646,36659,36667,36665,36677,36674,36670,36684,36681,36678,36686,36695,
36700,36706,36707,36708,36764,36767,36771,36781,36783,36791,36826,36837,36834,
36842,36847,36999,36852,36869,36857,36858,36881,36885,36897,36877,36894,36886,
36875,36903,36918,36917,36921,36856,36943,36944,36945,36946,36878,36937,36926,
36950,36952,36958,36968,36975,36982,38568,36978,36994,36989,36993,36992,37002,
37001,37007,37032,37039,37041,37045,37090,37092,25160,37083,37122,37138,37145,
37170,37168,37194,37206,37208,37219,37221,37225,37235,37234,37259,37257,37250,
37282,37291,37295,37290,37301,37300,37306,37312,37313,37321,37323,37328,37334,
37343,37345,37339,37372,37365,37366,37406,37375,37396,37420,37397,37393,37470,
37463,37445,37449,37476,37448,37525,37439,37451,37456,37532,37526,37523,37531,
37466,37583,37561,37559,37609,37647,37626,37700,37678,37657,37666,37658,37667,
37690,37685,37691,37724,37728,37756,37742,37718,37808,37804,37805,37780,37817,
37846,37847,37864,37861,37848,37827,37853,37840,37832,37860,37914,37908,37907,
37891,37895,37904,37942,37931,37941,37921,37946,37953,37970,37956,37979,37984,
37986,37982,37994,37417,38000,38005,38007,38013,37978,38012,38014,38017,38015,
38274,38279,38282,38292,38294,38296,38297,38304,38312,38311,38317,38332,38331,
38329,38334,38346,28662,38339,38349,38348,38357,38356,38358,38364,38369,38373,
38370,38433,38440,38446,38447,38466,38476,38479,38475,
38519,38492,38494,38493,38495,38502,38514,38508,38541,38552,38549,38551,38570,
38567,38577,38578,38576,38580,38582,38584,38585,38606,38603,38601,38605,35149,
38620,38669,38613,38649,38660,38662,38664,38675,38670,38673,38671,38678,38681,
38692,38698,38704,38713,38717,38718,38724,38726,38728,38722,38729,38748,38752,
38756,38758,38760,21202,38763,38769,38777,38789,38780,38785,38778,38790,38795,
38799,38800,38812,38824,38822,38819,38835,38836,38851,38854,38856,38859,38876,
38893,40783,38898,31455,38902,38901,38927,38924,38968,38948,38945,38967,38973,
38982,38991,38987,39019,39023,39024,39025,39028,39027,39082,39087,39089,39094,
39108,39107,39110,39145,39147,39171,39177,39186,39188,39192,39201,39197,39198,
39204,39200,39212,39214,39229,39230,39234,39241,39237,39248,39243,39249,39250,
39244,39253,39319,39320,39333,39341,39342,39356,39391,39387,39389,39384,39377,
39405,39406,39409,39410,39419,39416,39425,39439,39429,39394,39449,39467,39479,
39493,39490,39488,39491,39486,39509,39501,39515,39511,39519,39522,39525,39524,
39529,39531,39530,39597,39600,39612,39616,39631,39633,39635,39636,39646,39647,
39650,39651,39654,39663,39659,39662,39668,39665,39671,39675,39686,39704,39706,
39711,39714,39715,39717,39719,39720,39721,39722,39726,39727,39730,39748,39747,
39759,39757,39758,39761,39768,39796,39827,39811,39825,39830,39831,39839,39840,
39848,39860,39872,39882,39865,39878,39887,39889,39890,39907,39906,39908,39892,
39905,39994,39922,39921,39920,39957,39956,39945,39955,39948,39942,39944,39954,
39946,39940,39982,39963,39973,39972,39969,39984,40007,
39986,40006,39998,40026,40032,40039,40054,40056,40167,40172,40176,40201,40200,
40171,40195,40198,40234,40230,40367,40227,40223,40260,40213,40210,40257,40255,
40254,40262,40264,40285,40286,40292,40273,40272,40281,40306,40329,40327,40363,
40303,40314,40346,40356,40361,40370,40388,40385,40379,40376,40378,40390,40399,
40386,40409,40403,40440,40422,40429,40431,40445,40474,40475,40478,40565,40569,
40573,40577,40584,40587,40588,40594,40597,40593,40605,40613,40617,40632,40618,
40621,38753,40652,40654,40655,40656,40660,40668,40670,40669,40672,40677,40680,
40687,40692,40694,40695,40697,40699,40700,40701,40711,40712,30391,40725,40737,
40748,40766,40778,40786,40788,40803,40799,40800,40801,40806,40807,40812,40810,
40823,40818,40822,40853,40860,40864,22575,27079,36953,29796,20956,29081,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,
| 43,577 | 564 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/xorshift.h | #ifndef COSMOPOLITAN_LIBC_RAND_XORSHIFT_H_
#define COSMOPOLITAN_LIBC_RAND_XORSHIFT_H_
#define kMarsagliaXorshift64Seed 88172645463325252
#define kMarsagliaXorshift32Seed 2463534242
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
uint32_t MarsagliaXorshift32(uint32_t[hasatleast 1]);
uint64_t MarsagliaXorshift64(uint64_t[hasatleast 1]);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_RAND_XORSHIFT_H_ */
| 468 | 16 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/setbuf.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/stdio/stdio.h"
/**
* Sets buffer on stdio stream.
*/
void setbuf(FILE *f, char *buf) {
setvbuf(f, buf, buf ? _IOFBF : _IONBF, BUFSIZ);
}
| 2,023 | 28 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/versionsort.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/struct/dirent.h"
#include "libc/str/str.h"
int versionsort(const struct dirent **a, const struct dirent **b) {
return strverscmp((*a)->d_name, (*b)->d_name);
}
| 2,020 | 25 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/mkostemps.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/temp.h"
/**
* Delegates to mkotempsm() w/ owner-only non-execute access.
*/
dontdiscard int mkostemps(char *template, int suffixlen, unsigned flags) {
return mkostempsm(template, suffixlen, flags, 0600);
}
| 2,068 | 27 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fputc.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=8 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/lock.internal.h"
#include "libc/stdio/stdio.h"
/**
* Writes byte to stream.
*
* @param c is byte to buffer or write, which is masked
* @return c as unsigned char if written or -1 w/ errno
* @threadsafe
*/
int fputc(int c, FILE *f) {
int rc;
flockfile(f);
rc = fputc_unlocked(c, f);
funlockfile(f);
return rc;
}
| 2,185 | 36 | jart/cosmopolitan | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.