libc.info-2 299 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586
  1. This is libc.info, produced by makeinfo version 7.3 from libc.texinfo.
  2. This is ‘The GNU C Library Reference Manual’, for version 2.43.
  3. Copyright © 1993-2026 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Free Software Needs Free Documentation" and
  8. "GNU Lesser General Public License", the Front-Cover texts being "A GNU
  9. Manual", and with the Back-Cover Texts as in (a) below. A copy of the
  10. license is included in the section entitled "GNU Free Documentation
  11. License".
  12. (a) The FSF's Back-Cover Text is: "You have the freedom to copy and
  13. modify this GNU manual. Buying copies from the FSF supports it in
  14. developing GNU and promoting software freedom."
  15. INFO-DIR-SECTION Software libraries
  16. START-INFO-DIR-ENTRY
  17. * Libc: (libc). C library.
  18. END-INFO-DIR-ENTRY
  19. INFO-DIR-SECTION GNU C library functions and macros
  20. START-INFO-DIR-ENTRY
  21. * ALTWERASE: (libc)Local Modes.
  22. * ARGP_ERR_UNKNOWN: (libc)Argp Parser Functions.
  23. * ARG_MAX: (libc)General Limits.
  24. * BAUD_MAX: (libc)Line Speed.
  25. * BC_BASE_MAX: (libc)Utility Limits.
  26. * BC_DIM_MAX: (libc)Utility Limits.
  27. * BC_SCALE_MAX: (libc)Utility Limits.
  28. * BC_STRING_MAX: (libc)Utility Limits.
  29. * BRKINT: (libc)Input Modes.
  30. * BUFSIZ: (libc)Controlling Buffering.
  31. * CCTS_OFLOW: (libc)Control Modes.
  32. * CHAR_BIT: (libc)Width of Type.
  33. * CHILD_MAX: (libc)General Limits.
  34. * CIGNORE: (libc)Control Modes.
  35. * CLK_TCK: (libc)Processor Time.
  36. * CLOCAL: (libc)Control Modes.
  37. * CLOCKS_PER_SEC: (libc)CPU Time.
  38. * CLOCK_BOOTTIME: (libc)Getting the Time.
  39. * CLOCK_BOOTTIME_ALARM: (libc)Getting the Time.
  40. * CLOCK_MONOTONIC: (libc)Getting the Time.
  41. * CLOCK_MONOTONIC_COARSE: (libc)Getting the Time.
  42. * CLOCK_MONOTONIC_RAW: (libc)Getting the Time.
  43. * CLOCK_PROCESS_CPUTIME_ID: (libc)Getting the Time.
  44. * CLOCK_REALTIME: (libc)Getting the Time.
  45. * CLOCK_REALTIME_ALARM: (libc)Getting the Time.
  46. * CLOCK_REALTIME_COARSE: (libc)Getting the Time.
  47. * CLOCK_TAI: (libc)Getting the Time.
  48. * CLOCK_THREAD_CPUTIME_ID: (libc)Getting the Time.
  49. * COLL_WEIGHTS_MAX: (libc)Utility Limits.
  50. * CPU_ALLOC: (libc)CPU Affinity.
  51. * CPU_ALLOC_SIZE: (libc)CPU Affinity.
  52. * CPU_AND: (libc)CPU Affinity.
  53. * CPU_AND_S: (libc)CPU Affinity.
  54. * CPU_CLR: (libc)CPU Affinity.
  55. * CPU_CLR_S: (libc)CPU Affinity.
  56. * CPU_COUNT: (libc)CPU Affinity.
  57. * CPU_COUNT_S: (libc)CPU Affinity.
  58. * CPU_EQUAL: (libc)CPU Affinity.
  59. * CPU_EQUAL_S: (libc)CPU Affinity.
  60. * CPU_FEATURE_ACTIVE: (libc)X86.
  61. * CPU_FEATURE_PRESENT: (libc)X86.
  62. * CPU_FREE: (libc)CPU Affinity.
  63. * CPU_ISSET: (libc)CPU Affinity.
  64. * CPU_ISSET_S: (libc)CPU Affinity.
  65. * CPU_OR: (libc)CPU Affinity.
  66. * CPU_OR_S: (libc)CPU Affinity.
  67. * CPU_SET: (libc)CPU Affinity.
  68. * CPU_SETSIZE: (libc)CPU Affinity.
  69. * CPU_SET_S: (libc)CPU Affinity.
  70. * CPU_XOR: (libc)CPU Affinity.
  71. * CPU_XOR_S: (libc)CPU Affinity.
  72. * CPU_ZERO: (libc)CPU Affinity.
  73. * CPU_ZERO_S: (libc)CPU Affinity.
  74. * CREAD: (libc)Control Modes.
  75. * CRTS_IFLOW: (libc)Control Modes.
  76. * CS5: (libc)Control Modes.
  77. * CS6: (libc)Control Modes.
  78. * CS7: (libc)Control Modes.
  79. * CS8: (libc)Control Modes.
  80. * CSIZE: (libc)Control Modes.
  81. * CSTOPB: (libc)Control Modes.
  82. * DLFO_EH_SEGMENT_TYPE: (libc)Dynamic Linker Introspection.
  83. * DLFO_STRUCT_HAS_EH_COUNT: (libc)Dynamic Linker Introspection.
  84. * DLFO_STRUCT_HAS_EH_DBASE: (libc)Dynamic Linker Introspection.
  85. * DTTOIF: (libc)Directory Entries.
  86. * E2BIG: (libc)Error Codes.
  87. * EACCES: (libc)Error Codes.
  88. * EADDRINUSE: (libc)Error Codes.
  89. * EADDRNOTAVAIL: (libc)Error Codes.
  90. * EADV: (libc)Error Codes.
  91. * EAFNOSUPPORT: (libc)Error Codes.
  92. * EAGAIN: (libc)Error Codes.
  93. * EALREADY: (libc)Error Codes.
  94. * EAUTH: (libc)Error Codes.
  95. * EBACKGROUND: (libc)Error Codes.
  96. * EBADE: (libc)Error Codes.
  97. * EBADF: (libc)Error Codes.
  98. * EBADFD: (libc)Error Codes.
  99. * EBADMSG: (libc)Error Codes.
  100. * EBADR: (libc)Error Codes.
  101. * EBADRPC: (libc)Error Codes.
  102. * EBADRQC: (libc)Error Codes.
  103. * EBADSLT: (libc)Error Codes.
  104. * EBFONT: (libc)Error Codes.
  105. * EBUSY: (libc)Error Codes.
  106. * ECANCELED: (libc)Error Codes.
  107. * ECHILD: (libc)Error Codes.
  108. * ECHO: (libc)Local Modes.
  109. * ECHOCTL: (libc)Local Modes.
  110. * ECHOE: (libc)Local Modes.
  111. * ECHOK: (libc)Local Modes.
  112. * ECHOKE: (libc)Local Modes.
  113. * ECHONL: (libc)Local Modes.
  114. * ECHOPRT: (libc)Local Modes.
  115. * ECHRNG: (libc)Error Codes.
  116. * ECOMM: (libc)Error Codes.
  117. * ECONNABORTED: (libc)Error Codes.
  118. * ECONNREFUSED: (libc)Error Codes.
  119. * ECONNRESET: (libc)Error Codes.
  120. * ED: (libc)Error Codes.
  121. * EDEADLK: (libc)Error Codes.
  122. * EDEADLOCK: (libc)Error Codes.
  123. * EDESTADDRREQ: (libc)Error Codes.
  124. * EDIED: (libc)Error Codes.
  125. * EDOM: (libc)Error Codes.
  126. * EDOTDOT: (libc)Error Codes.
  127. * EDQUOT: (libc)Error Codes.
  128. * EEXIST: (libc)Error Codes.
  129. * EFAULT: (libc)Error Codes.
  130. * EFBIG: (libc)Error Codes.
  131. * EFTYPE: (libc)Error Codes.
  132. * EGRATUITOUS: (libc)Error Codes.
  133. * EGREGIOUS: (libc)Error Codes.
  134. * EHOSTDOWN: (libc)Error Codes.
  135. * EHOSTUNREACH: (libc)Error Codes.
  136. * EHWPOISON: (libc)Error Codes.
  137. * EIDRM: (libc)Error Codes.
  138. * EIEIO: (libc)Error Codes.
  139. * EILSEQ: (libc)Error Codes.
  140. * EINPROGRESS: (libc)Error Codes.
  141. * EINTR: (libc)Error Codes.
  142. * EINVAL: (libc)Error Codes.
  143. * EIO: (libc)Error Codes.
  144. * EISCONN: (libc)Error Codes.
  145. * EISDIR: (libc)Error Codes.
  146. * EISNAM: (libc)Error Codes.
  147. * EKEYEXPIRED: (libc)Error Codes.
  148. * EKEYREJECTED: (libc)Error Codes.
  149. * EKEYREVOKED: (libc)Error Codes.
  150. * EL2HLT: (libc)Error Codes.
  151. * EL2NSYNC: (libc)Error Codes.
  152. * EL3HLT: (libc)Error Codes.
  153. * EL3RST: (libc)Error Codes.
  154. * ELIBACC: (libc)Error Codes.
  155. * ELIBBAD: (libc)Error Codes.
  156. * ELIBEXEC: (libc)Error Codes.
  157. * ELIBMAX: (libc)Error Codes.
  158. * ELIBSCN: (libc)Error Codes.
  159. * ELNRNG: (libc)Error Codes.
  160. * ELOOP: (libc)Error Codes.
  161. * EMEDIUMTYPE: (libc)Error Codes.
  162. * EMFILE: (libc)Error Codes.
  163. * EMLINK: (libc)Error Codes.
  164. * EMSGSIZE: (libc)Error Codes.
  165. * EMULTIHOP: (libc)Error Codes.
  166. * ENAMETOOLONG: (libc)Error Codes.
  167. * ENAVAIL: (libc)Error Codes.
  168. * ENEEDAUTH: (libc)Error Codes.
  169. * ENETDOWN: (libc)Error Codes.
  170. * ENETRESET: (libc)Error Codes.
  171. * ENETUNREACH: (libc)Error Codes.
  172. * ENFILE: (libc)Error Codes.
  173. * ENOANO: (libc)Error Codes.
  174. * ENOBUFS: (libc)Error Codes.
  175. * ENOCSI: (libc)Error Codes.
  176. * ENODATA: (libc)Error Codes.
  177. * ENODEV: (libc)Error Codes.
  178. * ENOENT: (libc)Error Codes.
  179. * ENOEXEC: (libc)Error Codes.
  180. * ENOKEY: (libc)Error Codes.
  181. * ENOLCK: (libc)Error Codes.
  182. * ENOLINK: (libc)Error Codes.
  183. * ENOMEDIUM: (libc)Error Codes.
  184. * ENOMEM: (libc)Error Codes.
  185. * ENOMSG: (libc)Error Codes.
  186. * ENONET: (libc)Error Codes.
  187. * ENOPKG: (libc)Error Codes.
  188. * ENOPROTOOPT: (libc)Error Codes.
  189. * ENOSPC: (libc)Error Codes.
  190. * ENOSR: (libc)Error Codes.
  191. * ENOSTR: (libc)Error Codes.
  192. * ENOSYS: (libc)Error Codes.
  193. * ENOTBLK: (libc)Error Codes.
  194. * ENOTCONN: (libc)Error Codes.
  195. * ENOTDIR: (libc)Error Codes.
  196. * ENOTEMPTY: (libc)Error Codes.
  197. * ENOTNAM: (libc)Error Codes.
  198. * ENOTRECOVERABLE: (libc)Error Codes.
  199. * ENOTSOCK: (libc)Error Codes.
  200. * ENOTSUP: (libc)Error Codes.
  201. * ENOTTY: (libc)Error Codes.
  202. * ENOTUNIQ: (libc)Error Codes.
  203. * ENXIO: (libc)Error Codes.
  204. * EOF: (libc)EOF and Errors.
  205. * EOPNOTSUPP: (libc)Error Codes.
  206. * EOVERFLOW: (libc)Error Codes.
  207. * EOWNERDEAD: (libc)Error Codes.
  208. * EPERM: (libc)Error Codes.
  209. * EPFNOSUPPORT: (libc)Error Codes.
  210. * EPIPE: (libc)Error Codes.
  211. * EPROCLIM: (libc)Error Codes.
  212. * EPROCUNAVAIL: (libc)Error Codes.
  213. * EPROGMISMATCH: (libc)Error Codes.
  214. * EPROGUNAVAIL: (libc)Error Codes.
  215. * EPROTO: (libc)Error Codes.
  216. * EPROTONOSUPPORT: (libc)Error Codes.
  217. * EPROTOTYPE: (libc)Error Codes.
  218. * EQUIV_CLASS_MAX: (libc)Utility Limits.
  219. * ERANGE: (libc)Error Codes.
  220. * EREMCHG: (libc)Error Codes.
  221. * EREMOTE: (libc)Error Codes.
  222. * EREMOTEIO: (libc)Error Codes.
  223. * ERESTART: (libc)Error Codes.
  224. * ERFKILL: (libc)Error Codes.
  225. * EROFS: (libc)Error Codes.
  226. * ERPCMISMATCH: (libc)Error Codes.
  227. * ESHUTDOWN: (libc)Error Codes.
  228. * ESOCKTNOSUPPORT: (libc)Error Codes.
  229. * ESPIPE: (libc)Error Codes.
  230. * ESRCH: (libc)Error Codes.
  231. * ESRMNT: (libc)Error Codes.
  232. * ESTALE: (libc)Error Codes.
  233. * ESTRPIPE: (libc)Error Codes.
  234. * ETIME: (libc)Error Codes.
  235. * ETIMEDOUT: (libc)Error Codes.
  236. * ETOOMANYREFS: (libc)Error Codes.
  237. * ETXTBSY: (libc)Error Codes.
  238. * EUCLEAN: (libc)Error Codes.
  239. * EUNATCH: (libc)Error Codes.
  240. * EUSERS: (libc)Error Codes.
  241. * EWOULDBLOCK: (libc)Error Codes.
  242. * EXDEV: (libc)Error Codes.
  243. * EXFULL: (libc)Error Codes.
  244. * EXIT_FAILURE: (libc)Exit Status.
  245. * EXIT_SUCCESS: (libc)Exit Status.
  246. * EXPR_NEST_MAX: (libc)Utility Limits.
  247. * FD_CLOEXEC: (libc)Descriptor Flags.
  248. * FD_CLR: (libc)Waiting for I/O.
  249. * FD_ISSET: (libc)Waiting for I/O.
  250. * FD_SET: (libc)Waiting for I/O.
  251. * FD_SETSIZE: (libc)Waiting for I/O.
  252. * FD_ZERO: (libc)Waiting for I/O.
  253. * FE_SNANS_ALWAYS_SIGNAL: (libc)Infinity and NaN.
  254. * FILENAME_MAX: (libc)Limits for Files.
  255. * FLUSHO: (libc)Local Modes.
  256. * FOPEN_MAX: (libc)Opening Streams.
  257. * FP_ILOGB0: (libc)Exponents and Logarithms.
  258. * FP_ILOGBNAN: (libc)Exponents and Logarithms.
  259. * FP_LLOGB0: (libc)Exponents and Logarithms.
  260. * FP_LLOGBNAN: (libc)Exponents and Logarithms.
  261. * F_DUPFD: (libc)Duplicating Descriptors.
  262. * F_GETFD: (libc)Descriptor Flags.
  263. * F_GETFL: (libc)Getting File Status Flags.
  264. * F_GETLK: (libc)File Locks.
  265. * F_GETOWN: (libc)Interrupt Input.
  266. * F_OFD_GETLK: (libc)Open File Description Locks.
  267. * F_OFD_SETLK: (libc)Open File Description Locks.
  268. * F_OFD_SETLKW: (libc)Open File Description Locks.
  269. * F_OK: (libc)Testing File Access.
  270. * F_SETFD: (libc)Descriptor Flags.
  271. * F_SETFL: (libc)Getting File Status Flags.
  272. * F_SETLK: (libc)File Locks.
  273. * F_SETLKW: (libc)File Locks.
  274. * F_SETOWN: (libc)Interrupt Input.
  275. * HUGE_VAL: (libc)Math Error Reporting.
  276. * HUGE_VALF: (libc)Math Error Reporting.
  277. * HUGE_VALL: (libc)Math Error Reporting.
  278. * HUGE_VAL_FN: (libc)Math Error Reporting.
  279. * HUGE_VAL_FNx: (libc)Math Error Reporting.
  280. * HUPCL: (libc)Control Modes.
  281. * I: (libc)Complex Numbers.
  282. * ICANON: (libc)Local Modes.
  283. * ICRNL: (libc)Input Modes.
  284. * IEXTEN: (libc)Local Modes.
  285. * IFNAMSIZ: (libc)Interface Naming.
  286. * IFTODT: (libc)Directory Entries.
  287. * IGNBRK: (libc)Input Modes.
  288. * IGNCR: (libc)Input Modes.
  289. * IGNPAR: (libc)Input Modes.
  290. * IMAXBEL: (libc)Input Modes.
  291. * INADDR_ANY: (libc)Host Address Data Type.
  292. * INADDR_BROADCAST: (libc)Host Address Data Type.
  293. * INADDR_LOOPBACK: (libc)Host Address Data Type.
  294. * INADDR_NONE: (libc)Host Address Data Type.
  295. * INFINITY: (libc)Infinity and NaN.
  296. * INLCR: (libc)Input Modes.
  297. * INPCK: (libc)Input Modes.
  298. * IPPORT_RESERVED: (libc)Ports.
  299. * IPPORT_USERRESERVED: (libc)Ports.
  300. * ISIG: (libc)Local Modes.
  301. * ISTRIP: (libc)Input Modes.
  302. * IXANY: (libc)Input Modes.
  303. * IXOFF: (libc)Input Modes.
  304. * IXON: (libc)Input Modes.
  305. * LINE_MAX: (libc)Utility Limits.
  306. * LINK_MAX: (libc)Limits for Files.
  307. * L_ctermid: (libc)Identifying the Terminal.
  308. * L_cuserid: (libc)Who Logged In.
  309. * L_tmpnam: (libc)Temporary Files.
  310. * MAXNAMLEN: (libc)Limits for Files.
  311. * MAXSYMLINKS: (libc)Symbolic Links.
  312. * MAX_CANON: (libc)Limits for Files.
  313. * MAX_INPUT: (libc)Limits for Files.
  314. * MB_CUR_MAX: (libc)Selecting the Conversion.
  315. * MB_LEN_MAX: (libc)Selecting the Conversion.
  316. * MDMBUF: (libc)Control Modes.
  317. * MSG_DONTROUTE: (libc)Socket Data Options.
  318. * MSG_OOB: (libc)Socket Data Options.
  319. * MSG_PEEK: (libc)Socket Data Options.
  320. * NAME_MAX: (libc)Limits for Files.
  321. * NAN: (libc)Infinity and NaN.
  322. * NCCS: (libc)Mode Data Types.
  323. * NGROUPS_MAX: (libc)General Limits.
  324. * NOFLSH: (libc)Local Modes.
  325. * NOKERNINFO: (libc)Local Modes.
  326. * NSIG: (libc)Standard Signals.
  327. * NULL: (libc)Null Pointer Constant.
  328. * ONLCR: (libc)Output Modes.
  329. * ONOEOT: (libc)Output Modes.
  330. * OPEN_MAX: (libc)General Limits.
  331. * OPOST: (libc)Output Modes.
  332. * OXTABS: (libc)Output Modes.
  333. * O_ACCMODE: (libc)Access Modes.
  334. * O_APPEND: (libc)Operating Modes.
  335. * O_ASYNC: (libc)Operating Modes.
  336. * O_CREAT: (libc)Open-time Flags.
  337. * O_DIRECTORY: (libc)Open-time Flags.
  338. * O_EXCL: (libc)Open-time Flags.
  339. * O_EXEC: (libc)Access Modes.
  340. * O_EXLOCK: (libc)Open-time Flags.
  341. * O_FSYNC: (libc)Operating Modes.
  342. * O_IGNORE_CTTY: (libc)Open-time Flags.
  343. * O_NDELAY: (libc)Operating Modes.
  344. * O_NOATIME: (libc)Operating Modes.
  345. * O_NOCTTY: (libc)Open-time Flags.
  346. * O_NOFOLLOW: (libc)Open-time Flags.
  347. * O_NOLINK: (libc)Open-time Flags.
  348. * O_NONBLOCK: (libc)Open-time Flags.
  349. * O_NONBLOCK: (libc)Operating Modes.
  350. * O_NOTRANS: (libc)Open-time Flags.
  351. * O_PATH: (libc)Access Modes.
  352. * O_RDONLY: (libc)Access Modes.
  353. * O_RDWR: (libc)Access Modes.
  354. * O_READ: (libc)Access Modes.
  355. * O_SHLOCK: (libc)Open-time Flags.
  356. * O_SYNC: (libc)Operating Modes.
  357. * O_TMPFILE: (libc)Open-time Flags.
  358. * O_TRUNC: (libc)Open-time Flags.
  359. * O_WRITE: (libc)Access Modes.
  360. * O_WRONLY: (libc)Access Modes.
  361. * PARENB: (libc)Control Modes.
  362. * PARMRK: (libc)Input Modes.
  363. * PARODD: (libc)Control Modes.
  364. * PATH_MAX: (libc)Limits for Files.
  365. * PA_FLAG_MASK: (libc)Parsing a Template String.
  366. * PENDIN: (libc)Local Modes.
  367. * PF_FILE: (libc)Local Namespace Details.
  368. * PF_INET6: (libc)Internet Namespace.
  369. * PF_INET: (libc)Internet Namespace.
  370. * PF_LOCAL: (libc)Local Namespace Details.
  371. * PF_UNIX: (libc)Local Namespace Details.
  372. * PIPE_BUF: (libc)Limits for Files.
  373. * PTHREAD_ATTR_NO_SIGMASK_NP: (libc)Initial Thread Signal Mask.
  374. * P_tmpdir: (libc)Temporary Files.
  375. * RAND_MAX: (libc)ISO Random.
  376. * RE_DUP_MAX: (libc)General Limits.
  377. * RLIM_INFINITY: (libc)Limits on Resources.
  378. * RSEQ_SIG: (libc)Restartable Sequences.
  379. * R_OK: (libc)Testing File Access.
  380. * SA_NOCLDSTOP: (libc)Flags for Sigaction.
  381. * SA_NOCLDWAIT: (libc)Flags for Sigaction.
  382. * SA_NODEFER: (libc)Flags for Sigaction.
  383. * SA_ONSTACK: (libc)Flags for Sigaction.
  384. * SA_RESETHAND: (libc)Flags for Sigaction.
  385. * SA_RESTART: (libc)Flags for Sigaction.
  386. * SA_SIGINFO: (libc)Flags for Sigaction.
  387. * SEEK_CUR: (libc)File Positioning.
  388. * SEEK_END: (libc)File Positioning.
  389. * SEEK_SET: (libc)File Positioning.
  390. * SIGABRT: (libc)Program Error Signals.
  391. * SIGALRM: (libc)Alarm Signals.
  392. * SIGBUS: (libc)Program Error Signals.
  393. * SIGCHLD: (libc)Job Control Signals.
  394. * SIGCLD: (libc)Job Control Signals.
  395. * SIGCONT: (libc)Job Control Signals.
  396. * SIGEMT: (libc)Program Error Signals.
  397. * SIGFPE: (libc)Program Error Signals.
  398. * SIGHUP: (libc)Termination Signals.
  399. * SIGILL: (libc)Program Error Signals.
  400. * SIGINFO: (libc)Miscellaneous Signals.
  401. * SIGINT: (libc)Termination Signals.
  402. * SIGIO: (libc)Asynchronous I/O Signals.
  403. * SIGIOT: (libc)Program Error Signals.
  404. * SIGKILL: (libc)Termination Signals.
  405. * SIGLOST: (libc)Operation Error Signals.
  406. * SIGPIPE: (libc)Operation Error Signals.
  407. * SIGPOLL: (libc)Asynchronous I/O Signals.
  408. * SIGPROF: (libc)Alarm Signals.
  409. * SIGPWR: (libc)Miscellaneous Signals.
  410. * SIGQUIT: (libc)Termination Signals.
  411. * SIGSEGV: (libc)Program Error Signals.
  412. * SIGSTKFLT: (libc)Program Error Signals.
  413. * SIGSTOP: (libc)Job Control Signals.
  414. * SIGSYS: (libc)Program Error Signals.
  415. * SIGTERM: (libc)Termination Signals.
  416. * SIGTRAP: (libc)Program Error Signals.
  417. * SIGTSTP: (libc)Job Control Signals.
  418. * SIGTTIN: (libc)Job Control Signals.
  419. * SIGTTOU: (libc)Job Control Signals.
  420. * SIGURG: (libc)Asynchronous I/O Signals.
  421. * SIGUSR1: (libc)Miscellaneous Signals.
  422. * SIGUSR2: (libc)Miscellaneous Signals.
  423. * SIGVTALRM: (libc)Alarm Signals.
  424. * SIGWINCH: (libc)Miscellaneous Signals.
  425. * SIGXCPU: (libc)Operation Error Signals.
  426. * SIGXFSZ: (libc)Operation Error Signals.
  427. * SIG_ERR: (libc)Basic Signal Handling.
  428. * SNAN: (libc)Infinity and NaN.
  429. * SNANF: (libc)Infinity and NaN.
  430. * SNANFN: (libc)Infinity and NaN.
  431. * SNANFNx: (libc)Infinity and NaN.
  432. * SNANL: (libc)Infinity and NaN.
  433. * SOCK_DGRAM: (libc)Communication Styles.
  434. * SOCK_RAW: (libc)Communication Styles.
  435. * SOCK_RDM: (libc)Communication Styles.
  436. * SOCK_SEQPACKET: (libc)Communication Styles.
  437. * SOCK_STREAM: (libc)Communication Styles.
  438. * SOL_SOCKET: (libc)Socket-Level Options.
  439. * SPEED_MAX: (libc)Line Speed.
  440. * SSIZE_MAX: (libc)General Limits.
  441. * STREAM_MAX: (libc)General Limits.
  442. * SUN_LEN: (libc)Local Namespace Details.
  443. * S_IFMT: (libc)Testing File Type.
  444. * S_ISBLK: (libc)Testing File Type.
  445. * S_ISCHR: (libc)Testing File Type.
  446. * S_ISDIR: (libc)Testing File Type.
  447. * S_ISFIFO: (libc)Testing File Type.
  448. * S_ISLNK: (libc)Testing File Type.
  449. * S_ISREG: (libc)Testing File Type.
  450. * S_ISSOCK: (libc)Testing File Type.
  451. * S_TYPEISMQ: (libc)Testing File Type.
  452. * S_TYPEISSEM: (libc)Testing File Type.
  453. * S_TYPEISSHM: (libc)Testing File Type.
  454. * TIME_UTC: (libc)Getting the Time.
  455. * TMP_MAX: (libc)Temporary Files.
  456. * TOSTOP: (libc)Local Modes.
  457. * TZNAME_MAX: (libc)General Limits.
  458. * VDISCARD: (libc)Other Special.
  459. * VDSUSP: (libc)Signal Characters.
  460. * VEOF: (libc)Editing Characters.
  461. * VEOL2: (libc)Editing Characters.
  462. * VEOL: (libc)Editing Characters.
  463. * VERASE: (libc)Editing Characters.
  464. * VINTR: (libc)Signal Characters.
  465. * VKILL: (libc)Editing Characters.
  466. * VLNEXT: (libc)Other Special.
  467. * VMIN: (libc)Noncanonical Input.
  468. * VQUIT: (libc)Signal Characters.
  469. * VREPRINT: (libc)Editing Characters.
  470. * VSTART: (libc)Start/Stop Characters.
  471. * VSTATUS: (libc)Other Special.
  472. * VSTOP: (libc)Start/Stop Characters.
  473. * VSUSP: (libc)Signal Characters.
  474. * VTIME: (libc)Noncanonical Input.
  475. * VWERASE: (libc)Editing Characters.
  476. * WCHAR_MAX: (libc)Extended Char Intro.
  477. * WCHAR_MIN: (libc)Extended Char Intro.
  478. * WCOREDUMP: (libc)Process Completion Status.
  479. * WEOF: (libc)EOF and Errors.
  480. * WEOF: (libc)Extended Char Intro.
  481. * WEXITSTATUS: (libc)Process Completion Status.
  482. * WIFEXITED: (libc)Process Completion Status.
  483. * WIFSIGNALED: (libc)Process Completion Status.
  484. * WIFSTOPPED: (libc)Process Completion Status.
  485. * WSTOPSIG: (libc)Process Completion Status.
  486. * WTERMSIG: (libc)Process Completion Status.
  487. * W_OK: (libc)Testing File Access.
  488. * X_OK: (libc)Testing File Access.
  489. * _Complex_I: (libc)Complex Numbers.
  490. * _Exit: (libc)Termination Internals.
  491. * _Fork: (libc)Creating a Process.
  492. * _IOFBF: (libc)Controlling Buffering.
  493. * _IOLBF: (libc)Controlling Buffering.
  494. * _IONBF: (libc)Controlling Buffering.
  495. * _Imaginary_I: (libc)Complex Numbers.
  496. * _PATH_UTMP: (libc)Manipulating the Database.
  497. * _PATH_WTMP: (libc)Manipulating the Database.
  498. * _POSIX2_C_DEV: (libc)System Options.
  499. * _POSIX2_C_VERSION: (libc)Version Supported.
  500. * _POSIX2_FORT_DEV: (libc)System Options.
  501. * _POSIX2_FORT_RUN: (libc)System Options.
  502. * _POSIX2_LOCALEDEF: (libc)System Options.
  503. * _POSIX2_SW_DEV: (libc)System Options.
  504. * _POSIX_CHOWN_RESTRICTED: (libc)Options for Files.
  505. * _POSIX_JOB_CONTROL: (libc)System Options.
  506. * _POSIX_NO_TRUNC: (libc)Options for Files.
  507. * _POSIX_SAVED_IDS: (libc)System Options.
  508. * _POSIX_VDISABLE: (libc)Options for Files.
  509. * _POSIX_VERSION: (libc)Version Supported.
  510. * __fbufsize: (libc)Controlling Buffering.
  511. * __flbf: (libc)Controlling Buffering.
  512. * __fpending: (libc)Controlling Buffering.
  513. * __fpurge: (libc)Flushing Buffers.
  514. * __freadable: (libc)Opening Streams.
  515. * __freading: (libc)Opening Streams.
  516. * __fsetlocking: (libc)Streams and Threads.
  517. * __fwritable: (libc)Opening Streams.
  518. * __fwriting: (libc)Opening Streams.
  519. * __gconv_end_fct: (libc)glibc iconv Implementation.
  520. * __gconv_fct: (libc)glibc iconv Implementation.
  521. * __gconv_init_fct: (libc)glibc iconv Implementation.
  522. * __ppc_get_timebase: (libc)PowerPC.
  523. * __ppc_get_timebase_freq: (libc)PowerPC.
  524. * __ppc_mdoio: (libc)PowerPC.
  525. * __ppc_mdoom: (libc)PowerPC.
  526. * __ppc_set_ppr_low: (libc)PowerPC.
  527. * __ppc_set_ppr_med: (libc)PowerPC.
  528. * __ppc_set_ppr_med_high: (libc)PowerPC.
  529. * __ppc_set_ppr_med_low: (libc)PowerPC.
  530. * __ppc_set_ppr_very_low: (libc)PowerPC.
  531. * __ppc_yield: (libc)PowerPC.
  532. * __riscv_flush_icache: (libc)RISC-V.
  533. * __va_copy: (libc)Argument Macros.
  534. * __x86_get_cpuid_feature_leaf: (libc)X86.
  535. * _dl_find_object: (libc)Dynamic Linker Introspection.
  536. * _exit: (libc)Termination Internals.
  537. * _flushlbf: (libc)Flushing Buffers.
  538. * _tolower: (libc)Case Conversion.
  539. * _toupper: (libc)Case Conversion.
  540. * a64l: (libc)Encode Binary Data.
  541. * abort: (libc)Aborting a Program.
  542. * abs: (libc)Absolute Value.
  543. * accept: (libc)Accepting Connections.
  544. * access: (libc)Testing File Access.
  545. * acos: (libc)Inverse Trig Functions.
  546. * acosf: (libc)Inverse Trig Functions.
  547. * acosfN: (libc)Inverse Trig Functions.
  548. * acosfNx: (libc)Inverse Trig Functions.
  549. * acosh: (libc)Hyperbolic Functions.
  550. * acoshf: (libc)Hyperbolic Functions.
  551. * acoshfN: (libc)Hyperbolic Functions.
  552. * acoshfNx: (libc)Hyperbolic Functions.
  553. * acoshl: (libc)Hyperbolic Functions.
  554. * acosl: (libc)Inverse Trig Functions.
  555. * acospi: (libc)Inverse Trig Functions.
  556. * acospif: (libc)Inverse Trig Functions.
  557. * acospifN: (libc)Inverse Trig Functions.
  558. * acospifNx: (libc)Inverse Trig Functions.
  559. * acospil: (libc)Inverse Trig Functions.
  560. * addmntent: (libc)mtab.
  561. * addseverity: (libc)Adding Severity Classes.
  562. * adjtime: (libc)Setting and Adjusting the Time.
  563. * adjtimex: (libc)Setting and Adjusting the Time.
  564. * aio_cancel64: (libc)Cancel AIO Operations.
  565. * aio_cancel: (libc)Cancel AIO Operations.
  566. * aio_error64: (libc)Status of AIO Operations.
  567. * aio_error: (libc)Status of AIO Operations.
  568. * aio_fsync64: (libc)Synchronizing AIO Operations.
  569. * aio_fsync: (libc)Synchronizing AIO Operations.
  570. * aio_init: (libc)Configuration of AIO.
  571. * aio_read64: (libc)Asynchronous Reads/Writes.
  572. * aio_read: (libc)Asynchronous Reads/Writes.
  573. * aio_return64: (libc)Status of AIO Operations.
  574. * aio_return: (libc)Status of AIO Operations.
  575. * aio_suspend64: (libc)Synchronizing AIO Operations.
  576. * aio_suspend: (libc)Synchronizing AIO Operations.
  577. * aio_write64: (libc)Asynchronous Reads/Writes.
  578. * aio_write: (libc)Asynchronous Reads/Writes.
  579. * alarm: (libc)Setting an Alarm.
  580. * aligned_alloc: (libc)Aligned Memory Blocks.
  581. * alloca: (libc)Variable Size Automatic.
  582. * alphasort64: (libc)Scanning Directory Content.
  583. * alphasort: (libc)Scanning Directory Content.
  584. * arc4random: (libc)High Quality Random.
  585. * arc4random_buf: (libc)High Quality Random.
  586. * arc4random_uniform: (libc)High Quality Random.
  587. * argp_error: (libc)Argp Helper Functions.
  588. * argp_failure: (libc)Argp Helper Functions.
  589. * argp_help: (libc)Argp Help.
  590. * argp_parse: (libc)Argp.
  591. * argp_state_help: (libc)Argp Helper Functions.
  592. * argp_usage: (libc)Argp Helper Functions.
  593. * argz_add: (libc)Argz Functions.
  594. * argz_add_sep: (libc)Argz Functions.
  595. * argz_append: (libc)Argz Functions.
  596. * argz_count: (libc)Argz Functions.
  597. * argz_create: (libc)Argz Functions.
  598. * argz_create_sep: (libc)Argz Functions.
  599. * argz_delete: (libc)Argz Functions.
  600. * argz_extract: (libc)Argz Functions.
  601. * argz_insert: (libc)Argz Functions.
  602. * argz_next: (libc)Argz Functions.
  603. * argz_replace: (libc)Argz Functions.
  604. * argz_stringify: (libc)Argz Functions.
  605. * asctime: (libc)Formatting Calendar Time.
  606. * asctime_r: (libc)Formatting Calendar Time.
  607. * asin: (libc)Inverse Trig Functions.
  608. * asinf: (libc)Inverse Trig Functions.
  609. * asinfN: (libc)Inverse Trig Functions.
  610. * asinfNx: (libc)Inverse Trig Functions.
  611. * asinh: (libc)Hyperbolic Functions.
  612. * asinhf: (libc)Hyperbolic Functions.
  613. * asinhfN: (libc)Hyperbolic Functions.
  614. * asinhfNx: (libc)Hyperbolic Functions.
  615. * asinhl: (libc)Hyperbolic Functions.
  616. * asinl: (libc)Inverse Trig Functions.
  617. * asinpi: (libc)Inverse Trig Functions.
  618. * asinpif: (libc)Inverse Trig Functions.
  619. * asinpifN: (libc)Inverse Trig Functions.
  620. * asinpifNx: (libc)Inverse Trig Functions.
  621. * asinpil: (libc)Inverse Trig Functions.
  622. * asprintf: (libc)Dynamic Output.
  623. * assert: (libc)Consistency Checking.
  624. * assert_perror: (libc)Consistency Checking.
  625. * atan2: (libc)Inverse Trig Functions.
  626. * atan2f: (libc)Inverse Trig Functions.
  627. * atan2fN: (libc)Inverse Trig Functions.
  628. * atan2fNx: (libc)Inverse Trig Functions.
  629. * atan2l: (libc)Inverse Trig Functions.
  630. * atan2pi: (libc)Inverse Trig Functions.
  631. * atan2pif: (libc)Inverse Trig Functions.
  632. * atan2pifN: (libc)Inverse Trig Functions.
  633. * atan2pifNx: (libc)Inverse Trig Functions.
  634. * atan2pil: (libc)Inverse Trig Functions.
  635. * atan: (libc)Inverse Trig Functions.
  636. * atanf: (libc)Inverse Trig Functions.
  637. * atanfN: (libc)Inverse Trig Functions.
  638. * atanfNx: (libc)Inverse Trig Functions.
  639. * atanh: (libc)Hyperbolic Functions.
  640. * atanhf: (libc)Hyperbolic Functions.
  641. * atanhfN: (libc)Hyperbolic Functions.
  642. * atanhfNx: (libc)Hyperbolic Functions.
  643. * atanhl: (libc)Hyperbolic Functions.
  644. * atanl: (libc)Inverse Trig Functions.
  645. * atanpi: (libc)Inverse Trig Functions.
  646. * atanpif: (libc)Inverse Trig Functions.
  647. * atanpifN: (libc)Inverse Trig Functions.
  648. * atanpifNx: (libc)Inverse Trig Functions.
  649. * atanpil: (libc)Inverse Trig Functions.
  650. * atexit: (libc)Cleanups on Exit.
  651. * atof: (libc)Parsing of Floats.
  652. * atoi: (libc)Parsing of Integers.
  653. * atol: (libc)Parsing of Integers.
  654. * atoll: (libc)Parsing of Integers.
  655. * backtrace: (libc)Backtraces.
  656. * backtrace_symbols: (libc)Backtraces.
  657. * backtrace_symbols_fd: (libc)Backtraces.
  658. * basename: (libc)Finding Tokens in a String.
  659. * basename: (libc)Finding Tokens in a String.
  660. * bcmp: (libc)String/Array Comparison.
  661. * bcopy: (libc)Copying Strings and Arrays.
  662. * bind: (libc)Setting Address.
  663. * bind_textdomain_codeset: (libc)Charset conversion in gettext.
  664. * bindtextdomain: (libc)Locating gettext catalog.
  665. * brk: (libc)Resizing the Data Segment.
  666. * bsearch: (libc)Array Search Function.
  667. * btowc: (libc)Converting a Character.
  668. * bzero: (libc)Copying Strings and Arrays.
  669. * cabs: (libc)Absolute Value.
  670. * cabsf: (libc)Absolute Value.
  671. * cabsfN: (libc)Absolute Value.
  672. * cabsfNx: (libc)Absolute Value.
  673. * cabsl: (libc)Absolute Value.
  674. * cacos: (libc)Inverse Trig Functions.
  675. * cacosf: (libc)Inverse Trig Functions.
  676. * cacosfN: (libc)Inverse Trig Functions.
  677. * cacosfNx: (libc)Inverse Trig Functions.
  678. * cacosh: (libc)Hyperbolic Functions.
  679. * cacoshf: (libc)Hyperbolic Functions.
  680. * cacoshfN: (libc)Hyperbolic Functions.
  681. * cacoshfNx: (libc)Hyperbolic Functions.
  682. * cacoshl: (libc)Hyperbolic Functions.
  683. * cacosl: (libc)Inverse Trig Functions.
  684. * call_once: (libc)Call Once.
  685. * calloc: (libc)Allocating Cleared Space.
  686. * canonicalize: (libc)FP Bit Twiddling.
  687. * canonicalize_file_name: (libc)Symbolic Links.
  688. * canonicalizef: (libc)FP Bit Twiddling.
  689. * canonicalizefN: (libc)FP Bit Twiddling.
  690. * canonicalizefNx: (libc)FP Bit Twiddling.
  691. * canonicalizel: (libc)FP Bit Twiddling.
  692. * carg: (libc)Operations on Complex.
  693. * cargf: (libc)Operations on Complex.
  694. * cargfN: (libc)Operations on Complex.
  695. * cargfNx: (libc)Operations on Complex.
  696. * cargl: (libc)Operations on Complex.
  697. * casin: (libc)Inverse Trig Functions.
  698. * casinf: (libc)Inverse Trig Functions.
  699. * casinfN: (libc)Inverse Trig Functions.
  700. * casinfNx: (libc)Inverse Trig Functions.
  701. * casinh: (libc)Hyperbolic Functions.
  702. * casinhf: (libc)Hyperbolic Functions.
  703. * casinhfN: (libc)Hyperbolic Functions.
  704. * casinhfNx: (libc)Hyperbolic Functions.
  705. * casinhl: (libc)Hyperbolic Functions.
  706. * casinl: (libc)Inverse Trig Functions.
  707. * catan: (libc)Inverse Trig Functions.
  708. * catanf: (libc)Inverse Trig Functions.
  709. * catanfN: (libc)Inverse Trig Functions.
  710. * catanfNx: (libc)Inverse Trig Functions.
  711. * catanh: (libc)Hyperbolic Functions.
  712. * catanhf: (libc)Hyperbolic Functions.
  713. * catanhfN: (libc)Hyperbolic Functions.
  714. * catanhfNx: (libc)Hyperbolic Functions.
  715. * catanhl: (libc)Hyperbolic Functions.
  716. * catanl: (libc)Inverse Trig Functions.
  717. * catclose: (libc)The catgets Functions.
  718. * catgets: (libc)The catgets Functions.
  719. * catopen: (libc)The catgets Functions.
  720. * cbrt: (libc)Exponents and Logarithms.
  721. * cbrtf: (libc)Exponents and Logarithms.
  722. * cbrtfN: (libc)Exponents and Logarithms.
  723. * cbrtfNx: (libc)Exponents and Logarithms.
  724. * cbrtl: (libc)Exponents and Logarithms.
  725. * ccos: (libc)Trig Functions.
  726. * ccosf: (libc)Trig Functions.
  727. * ccosfN: (libc)Trig Functions.
  728. * ccosfNx: (libc)Trig Functions.
  729. * ccosh: (libc)Hyperbolic Functions.
  730. * ccoshf: (libc)Hyperbolic Functions.
  731. * ccoshfN: (libc)Hyperbolic Functions.
  732. * ccoshfNx: (libc)Hyperbolic Functions.
  733. * ccoshl: (libc)Hyperbolic Functions.
  734. * ccosl: (libc)Trig Functions.
  735. * ceil: (libc)Rounding Functions.
  736. * ceilf: (libc)Rounding Functions.
  737. * ceilfN: (libc)Rounding Functions.
  738. * ceilfNx: (libc)Rounding Functions.
  739. * ceill: (libc)Rounding Functions.
  740. * cexp: (libc)Exponents and Logarithms.
  741. * cexpf: (libc)Exponents and Logarithms.
  742. * cexpfN: (libc)Exponents and Logarithms.
  743. * cexpfNx: (libc)Exponents and Logarithms.
  744. * cexpl: (libc)Exponents and Logarithms.
  745. * cfgetibaud: (libc)Line Speed.
  746. * cfgetispeed: (libc)Line Speed.
  747. * cfgetobaud: (libc)Line Speed.
  748. * cfgetospeed: (libc)Line Speed.
  749. * cfmakeraw: (libc)Noncanonical Input.
  750. * cfsetbaud: (libc)Line Speed.
  751. * cfsetibaud: (libc)Line Speed.
  752. * cfsetispeed: (libc)Line Speed.
  753. * cfsetobaud: (libc)Line Speed.
  754. * cfsetospeed: (libc)Line Speed.
  755. * cfsetspeed: (libc)Line Speed.
  756. * chdir: (libc)Working Directory.
  757. * chmod: (libc)Setting Permissions.
  758. * chown: (libc)File Owner.
  759. * cimag: (libc)Operations on Complex.
  760. * cimagf: (libc)Operations on Complex.
  761. * cimagfN: (libc)Operations on Complex.
  762. * cimagfNx: (libc)Operations on Complex.
  763. * cimagl: (libc)Operations on Complex.
  764. * clearenv: (libc)Environment Access.
  765. * clearerr: (libc)Error Recovery.
  766. * clearerr_unlocked: (libc)Error Recovery.
  767. * clock: (libc)CPU Time.
  768. * clock_getres: (libc)Getting the Time.
  769. * clock_gettime: (libc)Getting the Time.
  770. * clock_nanosleep: (libc)Sleeping.
  771. * clock_settime: (libc)Setting and Adjusting the Time.
  772. * clog10: (libc)Exponents and Logarithms.
  773. * clog10f: (libc)Exponents and Logarithms.
  774. * clog10fN: (libc)Exponents and Logarithms.
  775. * clog10fNx: (libc)Exponents and Logarithms.
  776. * clog10l: (libc)Exponents and Logarithms.
  777. * clog: (libc)Exponents and Logarithms.
  778. * clogf: (libc)Exponents and Logarithms.
  779. * clogfN: (libc)Exponents and Logarithms.
  780. * clogfNx: (libc)Exponents and Logarithms.
  781. * clogl: (libc)Exponents and Logarithms.
  782. * close: (libc)Opening and Closing Files.
  783. * close_range: (libc)Opening and Closing Files.
  784. * closedir: (libc)Reading/Closing Directory.
  785. * closefrom: (libc)Opening and Closing Files.
  786. * closelog: (libc)closelog.
  787. * cnd_broadcast: (libc)ISO C Condition Variables.
  788. * cnd_destroy: (libc)ISO C Condition Variables.
  789. * cnd_init: (libc)ISO C Condition Variables.
  790. * cnd_signal: (libc)ISO C Condition Variables.
  791. * cnd_timedwait: (libc)ISO C Condition Variables.
  792. * cnd_wait: (libc)ISO C Condition Variables.
  793. * compoundn: (libc)Exponents and Logarithms.
  794. * compoundnf: (libc)Exponents and Logarithms.
  795. * compoundnfN: (libc)Exponents and Logarithms.
  796. * compoundnfNx: (libc)Exponents and Logarithms.
  797. * compoundnl: (libc)Exponents and Logarithms.
  798. * confstr: (libc)String Parameters.
  799. * conj: (libc)Operations on Complex.
  800. * conjf: (libc)Operations on Complex.
  801. * conjfN: (libc)Operations on Complex.
  802. * conjfNx: (libc)Operations on Complex.
  803. * conjl: (libc)Operations on Complex.
  804. * connect: (libc)Connecting.
  805. * copy_file_range: (libc)Copying File Data.
  806. * copysign: (libc)FP Bit Twiddling.
  807. * copysignf: (libc)FP Bit Twiddling.
  808. * copysignfN: (libc)FP Bit Twiddling.
  809. * copysignfNx: (libc)FP Bit Twiddling.
  810. * copysignl: (libc)FP Bit Twiddling.
  811. * cos: (libc)Trig Functions.
  812. * cosf: (libc)Trig Functions.
  813. * cosfN: (libc)Trig Functions.
  814. * cosfNx: (libc)Trig Functions.
  815. * cosh: (libc)Hyperbolic Functions.
  816. * coshf: (libc)Hyperbolic Functions.
  817. * coshfN: (libc)Hyperbolic Functions.
  818. * coshfNx: (libc)Hyperbolic Functions.
  819. * coshl: (libc)Hyperbolic Functions.
  820. * cosl: (libc)Trig Functions.
  821. * cospi: (libc)Trig Functions.
  822. * cospif: (libc)Trig Functions.
  823. * cospifN: (libc)Trig Functions.
  824. * cospifNx: (libc)Trig Functions.
  825. * cospil: (libc)Trig Functions.
  826. * cpow: (libc)Exponents and Logarithms.
  827. * cpowf: (libc)Exponents and Logarithms.
  828. * cpowfN: (libc)Exponents and Logarithms.
  829. * cpowfNx: (libc)Exponents and Logarithms.
  830. * cpowl: (libc)Exponents and Logarithms.
  831. * cproj: (libc)Operations on Complex.
  832. * cprojf: (libc)Operations on Complex.
  833. * cprojfN: (libc)Operations on Complex.
  834. * cprojfNx: (libc)Operations on Complex.
  835. * cprojl: (libc)Operations on Complex.
  836. * creal: (libc)Operations on Complex.
  837. * crealf: (libc)Operations on Complex.
  838. * crealfN: (libc)Operations on Complex.
  839. * crealfNx: (libc)Operations on Complex.
  840. * creall: (libc)Operations on Complex.
  841. * creat64: (libc)Opening and Closing Files.
  842. * creat: (libc)Opening and Closing Files.
  843. * csin: (libc)Trig Functions.
  844. * csinf: (libc)Trig Functions.
  845. * csinfN: (libc)Trig Functions.
  846. * csinfNx: (libc)Trig Functions.
  847. * csinh: (libc)Hyperbolic Functions.
  848. * csinhf: (libc)Hyperbolic Functions.
  849. * csinhfN: (libc)Hyperbolic Functions.
  850. * csinhfNx: (libc)Hyperbolic Functions.
  851. * csinhl: (libc)Hyperbolic Functions.
  852. * csinl: (libc)Trig Functions.
  853. * csqrt: (libc)Exponents and Logarithms.
  854. * csqrtf: (libc)Exponents and Logarithms.
  855. * csqrtfN: (libc)Exponents and Logarithms.
  856. * csqrtfNx: (libc)Exponents and Logarithms.
  857. * csqrtl: (libc)Exponents and Logarithms.
  858. * ctan: (libc)Trig Functions.
  859. * ctanf: (libc)Trig Functions.
  860. * ctanfN: (libc)Trig Functions.
  861. * ctanfNx: (libc)Trig Functions.
  862. * ctanh: (libc)Hyperbolic Functions.
  863. * ctanhf: (libc)Hyperbolic Functions.
  864. * ctanhfN: (libc)Hyperbolic Functions.
  865. * ctanhfNx: (libc)Hyperbolic Functions.
  866. * ctanhl: (libc)Hyperbolic Functions.
  867. * ctanl: (libc)Trig Functions.
  868. * ctermid: (libc)Identifying the Terminal.
  869. * ctime: (libc)Formatting Calendar Time.
  870. * ctime_r: (libc)Formatting Calendar Time.
  871. * cuserid: (libc)Who Logged In.
  872. * daddl: (libc)Misc FP Arithmetic.
  873. * dcgettext: (libc)Translation with gettext.
  874. * dcngettext: (libc)Advanced gettext functions.
  875. * ddivl: (libc)Misc FP Arithmetic.
  876. * dfmal: (libc)Misc FP Arithmetic.
  877. * dgettext: (libc)Translation with gettext.
  878. * difftime: (libc)Calculating Elapsed Time.
  879. * dirfd: (libc)Opening a Directory.
  880. * dirname: (libc)Finding Tokens in a String.
  881. * div: (libc)Integer Division.
  882. * dlinfo: (libc)Dynamic Linker Introspection.
  883. * dmull: (libc)Misc FP Arithmetic.
  884. * dngettext: (libc)Advanced gettext functions.
  885. * dprintf: (libc)Formatted Output Functions.
  886. * drand48: (libc)SVID Random.
  887. * drand48_r: (libc)SVID Random.
  888. * drem: (libc)Remainder Functions.
  889. * dremf: (libc)Remainder Functions.
  890. * dreml: (libc)Remainder Functions.
  891. * dsqrtl: (libc)Misc FP Arithmetic.
  892. * dsubl: (libc)Misc FP Arithmetic.
  893. * dup2: (libc)Duplicating Descriptors.
  894. * dup3: (libc)Duplicating Descriptors.
  895. * dup: (libc)Duplicating Descriptors.
  896. * ecvt: (libc)System V Number Conversion.
  897. * ecvt_r: (libc)System V Number Conversion.
  898. * endfsent: (libc)fstab.
  899. * endgrent: (libc)Scanning All Groups.
  900. * endhostent: (libc)Host Names.
  901. * endmntent: (libc)mtab.
  902. * endnetent: (libc)Networks Database.
  903. * endnetgrent: (libc)Lookup Netgroup.
  904. * endprotoent: (libc)Protocols Database.
  905. * endpwent: (libc)Scanning All Users.
  906. * endservent: (libc)Services Database.
  907. * endutent: (libc)Manipulating the Database.
  908. * endutxent: (libc)XPG Functions.
  909. * envz_add: (libc)Envz Functions.
  910. * envz_entry: (libc)Envz Functions.
  911. * envz_get: (libc)Envz Functions.
  912. * envz_merge: (libc)Envz Functions.
  913. * envz_remove: (libc)Envz Functions.
  914. * envz_strip: (libc)Envz Functions.
  915. * epoll_create: (libc)Other Low-Level I/O APIs.
  916. * epoll_wait: (libc)Other Low-Level I/O APIs.
  917. * erand48: (libc)SVID Random.
  918. * erand48_r: (libc)SVID Random.
  919. * erf: (libc)Special Functions.
  920. * erfc: (libc)Special Functions.
  921. * erfcf: (libc)Special Functions.
  922. * erfcfN: (libc)Special Functions.
  923. * erfcfNx: (libc)Special Functions.
  924. * erfcl: (libc)Special Functions.
  925. * erff: (libc)Special Functions.
  926. * erffN: (libc)Special Functions.
  927. * erffNx: (libc)Special Functions.
  928. * erfl: (libc)Special Functions.
  929. * err: (libc)Error Messages.
  930. * errno: (libc)Checking for Errors.
  931. * error: (libc)Error Messages.
  932. * error_at_line: (libc)Error Messages.
  933. * errx: (libc)Error Messages.
  934. * execl: (libc)Executing a File.
  935. * execle: (libc)Executing a File.
  936. * execlp: (libc)Executing a File.
  937. * execv: (libc)Executing a File.
  938. * execve: (libc)Executing a File.
  939. * execvp: (libc)Executing a File.
  940. * exit: (libc)Normal Termination.
  941. * exp10: (libc)Exponents and Logarithms.
  942. * exp10f: (libc)Exponents and Logarithms.
  943. * exp10fN: (libc)Exponents and Logarithms.
  944. * exp10fNx: (libc)Exponents and Logarithms.
  945. * exp10l: (libc)Exponents and Logarithms.
  946. * exp10m1: (libc)Exponents and Logarithms.
  947. * exp10m1f: (libc)Exponents and Logarithms.
  948. * exp10m1fN: (libc)Exponents and Logarithms.
  949. * exp10m1fNx: (libc)Exponents and Logarithms.
  950. * exp10m1l: (libc)Exponents and Logarithms.
  951. * exp2: (libc)Exponents and Logarithms.
  952. * exp2f: (libc)Exponents and Logarithms.
  953. * exp2fN: (libc)Exponents and Logarithms.
  954. * exp2fNx: (libc)Exponents and Logarithms.
  955. * exp2l: (libc)Exponents and Logarithms.
  956. * exp2m1: (libc)Exponents and Logarithms.
  957. * exp2m1f: (libc)Exponents and Logarithms.
  958. * exp2m1fN: (libc)Exponents and Logarithms.
  959. * exp2m1fNx: (libc)Exponents and Logarithms.
  960. * exp2m1l: (libc)Exponents and Logarithms.
  961. * exp: (libc)Exponents and Logarithms.
  962. * expf: (libc)Exponents and Logarithms.
  963. * expfN: (libc)Exponents and Logarithms.
  964. * expfNx: (libc)Exponents and Logarithms.
  965. * expl: (libc)Exponents and Logarithms.
  966. * explicit_bzero: (libc)Erasing Sensitive Data.
  967. * expm1: (libc)Exponents and Logarithms.
  968. * expm1f: (libc)Exponents and Logarithms.
  969. * expm1fN: (libc)Exponents and Logarithms.
  970. * expm1fNx: (libc)Exponents and Logarithms.
  971. * expm1l: (libc)Exponents and Logarithms.
  972. * fMaddfN: (libc)Misc FP Arithmetic.
  973. * fMaddfNx: (libc)Misc FP Arithmetic.
  974. * fMdivfN: (libc)Misc FP Arithmetic.
  975. * fMdivfNx: (libc)Misc FP Arithmetic.
  976. * fMfmafN: (libc)Misc FP Arithmetic.
  977. * fMfmafNx: (libc)Misc FP Arithmetic.
  978. * fMmulfN: (libc)Misc FP Arithmetic.
  979. * fMmulfNx: (libc)Misc FP Arithmetic.
  980. * fMsqrtfN: (libc)Misc FP Arithmetic.
  981. * fMsqrtfNx: (libc)Misc FP Arithmetic.
  982. * fMsubfN: (libc)Misc FP Arithmetic.
  983. * fMsubfNx: (libc)Misc FP Arithmetic.
  984. * fMxaddfN: (libc)Misc FP Arithmetic.
  985. * fMxaddfNx: (libc)Misc FP Arithmetic.
  986. * fMxdivfN: (libc)Misc FP Arithmetic.
  987. * fMxdivfNx: (libc)Misc FP Arithmetic.
  988. * fMxfmafN: (libc)Misc FP Arithmetic.
  989. * fMxfmafNx: (libc)Misc FP Arithmetic.
  990. * fMxmulfN: (libc)Misc FP Arithmetic.
  991. * fMxmulfNx: (libc)Misc FP Arithmetic.
  992. * fMxsqrtfN: (libc)Misc FP Arithmetic.
  993. * fMxsqrtfNx: (libc)Misc FP Arithmetic.
  994. * fMxsubfN: (libc)Misc FP Arithmetic.
  995. * fMxsubfNx: (libc)Misc FP Arithmetic.
  996. * fabs: (libc)Absolute Value.
  997. * fabsf: (libc)Absolute Value.
  998. * fabsfN: (libc)Absolute Value.
  999. * fabsfNx: (libc)Absolute Value.
  1000. * fabsl: (libc)Absolute Value.
  1001. * faccessat: (libc)Testing File Access.
  1002. * fadd: (libc)Misc FP Arithmetic.
  1003. * faddl: (libc)Misc FP Arithmetic.
  1004. * fchdir: (libc)Working Directory.
  1005. * fchmod: (libc)Setting Permissions.
  1006. * fchown: (libc)File Owner.
  1007. * fclose: (libc)Closing Streams.
  1008. * fcloseall: (libc)Closing Streams.
  1009. * fcntl: (libc)Control Operations.
  1010. * fcvt: (libc)System V Number Conversion.
  1011. * fcvt_r: (libc)System V Number Conversion.
  1012. * fdatasync: (libc)Synchronizing I/O.
  1013. * fdim: (libc)Misc FP Arithmetic.
  1014. * fdimf: (libc)Misc FP Arithmetic.
  1015. * fdimfN: (libc)Misc FP Arithmetic.
  1016. * fdimfNx: (libc)Misc FP Arithmetic.
  1017. * fdiml: (libc)Misc FP Arithmetic.
  1018. * fdiv: (libc)Misc FP Arithmetic.
  1019. * fdivl: (libc)Misc FP Arithmetic.
  1020. * fdopen: (libc)Descriptors and Streams.
  1021. * fdopendir: (libc)Opening a Directory.
  1022. * feclearexcept: (libc)Status bit operations.
  1023. * fedisableexcept: (libc)Control Functions.
  1024. * feenableexcept: (libc)Control Functions.
  1025. * fegetenv: (libc)Control Functions.
  1026. * fegetexcept: (libc)Control Functions.
  1027. * fegetexceptflag: (libc)Status bit operations.
  1028. * fegetmode: (libc)Control Functions.
  1029. * fegetround: (libc)Rounding.
  1030. * feholdexcept: (libc)Control Functions.
  1031. * feof: (libc)EOF and Errors.
  1032. * feof_unlocked: (libc)EOF and Errors.
  1033. * feraiseexcept: (libc)Status bit operations.
  1034. * ferror: (libc)EOF and Errors.
  1035. * ferror_unlocked: (libc)EOF and Errors.
  1036. * fesetenv: (libc)Control Functions.
  1037. * fesetexcept: (libc)Status bit operations.
  1038. * fesetexceptflag: (libc)Status bit operations.
  1039. * fesetmode: (libc)Control Functions.
  1040. * fesetround: (libc)Rounding.
  1041. * fetestexcept: (libc)Status bit operations.
  1042. * fetestexceptflag: (libc)Status bit operations.
  1043. * feupdateenv: (libc)Control Functions.
  1044. * fexecve: (libc)Executing a File.
  1045. * fflush: (libc)Flushing Buffers.
  1046. * fflush_unlocked: (libc)Flushing Buffers.
  1047. * ffma: (libc)Misc FP Arithmetic.
  1048. * ffmal: (libc)Misc FP Arithmetic.
  1049. * fgetc: (libc)Character Input.
  1050. * fgetc_unlocked: (libc)Character Input.
  1051. * fgetgrent: (libc)Scanning All Groups.
  1052. * fgetgrent_r: (libc)Scanning All Groups.
  1053. * fgetpos64: (libc)Portable Positioning.
  1054. * fgetpos: (libc)Portable Positioning.
  1055. * fgetpwent: (libc)Scanning All Users.
  1056. * fgetpwent_r: (libc)Scanning All Users.
  1057. * fgets: (libc)Line Input.
  1058. * fgets_unlocked: (libc)Line Input.
  1059. * fgetwc: (libc)Character Input.
  1060. * fgetwc_unlocked: (libc)Character Input.
  1061. * fgetws: (libc)Line Input.
  1062. * fgetws_unlocked: (libc)Line Input.
  1063. * fileno: (libc)Descriptors and Streams.
  1064. * fileno_unlocked: (libc)Descriptors and Streams.
  1065. * finite: (libc)Floating Point Classes.
  1066. * finitef: (libc)Floating Point Classes.
  1067. * finitel: (libc)Floating Point Classes.
  1068. * flockfile: (libc)Streams and Threads.
  1069. * floor: (libc)Rounding Functions.
  1070. * floorf: (libc)Rounding Functions.
  1071. * floorfN: (libc)Rounding Functions.
  1072. * floorfNx: (libc)Rounding Functions.
  1073. * floorl: (libc)Rounding Functions.
  1074. * fma: (libc)Misc FP Arithmetic.
  1075. * fmaf: (libc)Misc FP Arithmetic.
  1076. * fmafN: (libc)Misc FP Arithmetic.
  1077. * fmafNx: (libc)Misc FP Arithmetic.
  1078. * fmal: (libc)Misc FP Arithmetic.
  1079. * fmax: (libc)Misc FP Arithmetic.
  1080. * fmaxf: (libc)Misc FP Arithmetic.
  1081. * fmaxfN: (libc)Misc FP Arithmetic.
  1082. * fmaxfNx: (libc)Misc FP Arithmetic.
  1083. * fmaximum: (libc)Misc FP Arithmetic.
  1084. * fmaximum_mag: (libc)Misc FP Arithmetic.
  1085. * fmaximum_mag_num: (libc)Misc FP Arithmetic.
  1086. * fmaximum_mag_numf: (libc)Misc FP Arithmetic.
  1087. * fmaximum_mag_numfN: (libc)Misc FP Arithmetic.
  1088. * fmaximum_mag_numfNx: (libc)Misc FP Arithmetic.
  1089. * fmaximum_mag_numl: (libc)Misc FP Arithmetic.
  1090. * fmaximum_magf: (libc)Misc FP Arithmetic.
  1091. * fmaximum_magfN: (libc)Misc FP Arithmetic.
  1092. * fmaximum_magfNx: (libc)Misc FP Arithmetic.
  1093. * fmaximum_magl: (libc)Misc FP Arithmetic.
  1094. * fmaximum_num: (libc)Misc FP Arithmetic.
  1095. * fmaximum_numf: (libc)Misc FP Arithmetic.
  1096. * fmaximum_numfN: (libc)Misc FP Arithmetic.
  1097. * fmaximum_numfNx: (libc)Misc FP Arithmetic.
  1098. * fmaximum_numl: (libc)Misc FP Arithmetic.
  1099. * fmaximumf: (libc)Misc FP Arithmetic.
  1100. * fmaximumfN: (libc)Misc FP Arithmetic.
  1101. * fmaximumfNx: (libc)Misc FP Arithmetic.
  1102. * fmaximuml: (libc)Misc FP Arithmetic.
  1103. * fmaxl: (libc)Misc FP Arithmetic.
  1104. * fmaxmag: (libc)Misc FP Arithmetic.
  1105. * fmaxmagf: (libc)Misc FP Arithmetic.
  1106. * fmaxmagfN: (libc)Misc FP Arithmetic.
  1107. * fmaxmagfNx: (libc)Misc FP Arithmetic.
  1108. * fmaxmagl: (libc)Misc FP Arithmetic.
  1109. * fmemopen: (libc)String Streams.
  1110. * fmin: (libc)Misc FP Arithmetic.
  1111. * fminf: (libc)Misc FP Arithmetic.
  1112. * fminfN: (libc)Misc FP Arithmetic.
  1113. * fminfNx: (libc)Misc FP Arithmetic.
  1114. * fminimum: (libc)Misc FP Arithmetic.
  1115. * fminimum_mag: (libc)Misc FP Arithmetic.
  1116. * fminimum_mag_num: (libc)Misc FP Arithmetic.
  1117. * fminimum_mag_numf: (libc)Misc FP Arithmetic.
  1118. * fminimum_mag_numfN: (libc)Misc FP Arithmetic.
  1119. * fminimum_mag_numfNx: (libc)Misc FP Arithmetic.
  1120. * fminimum_mag_numl: (libc)Misc FP Arithmetic.
  1121. * fminimum_magf: (libc)Misc FP Arithmetic.
  1122. * fminimum_magfN: (libc)Misc FP Arithmetic.
  1123. * fminimum_magfNx: (libc)Misc FP Arithmetic.
  1124. * fminimum_magl: (libc)Misc FP Arithmetic.
  1125. * fminimum_num: (libc)Misc FP Arithmetic.
  1126. * fminimum_numf: (libc)Misc FP Arithmetic.
  1127. * fminimum_numfN: (libc)Misc FP Arithmetic.
  1128. * fminimum_numfNx: (libc)Misc FP Arithmetic.
  1129. * fminimum_numl: (libc)Misc FP Arithmetic.
  1130. * fminimumf: (libc)Misc FP Arithmetic.
  1131. * fminimumfN: (libc)Misc FP Arithmetic.
  1132. * fminimumfNx: (libc)Misc FP Arithmetic.
  1133. * fminimuml: (libc)Misc FP Arithmetic.
  1134. * fminl: (libc)Misc FP Arithmetic.
  1135. * fminmag: (libc)Misc FP Arithmetic.
  1136. * fminmagf: (libc)Misc FP Arithmetic.
  1137. * fminmagfN: (libc)Misc FP Arithmetic.
  1138. * fminmagfNx: (libc)Misc FP Arithmetic.
  1139. * fminmagl: (libc)Misc FP Arithmetic.
  1140. * fmod: (libc)Remainder Functions.
  1141. * fmodf: (libc)Remainder Functions.
  1142. * fmodfN: (libc)Remainder Functions.
  1143. * fmodfNx: (libc)Remainder Functions.
  1144. * fmodl: (libc)Remainder Functions.
  1145. * fmtmsg: (libc)Printing Formatted Messages.
  1146. * fmul: (libc)Misc FP Arithmetic.
  1147. * fmull: (libc)Misc FP Arithmetic.
  1148. * fnmatch: (libc)Wildcard Matching.
  1149. * fopen64: (libc)Opening Streams.
  1150. * fopen: (libc)Opening Streams.
  1151. * fopencookie: (libc)Streams and Cookies.
  1152. * fork: (libc)Creating a Process.
  1153. * forkpty: (libc)Pseudo-Terminal Pairs.
  1154. * fpathconf: (libc)Pathconf.
  1155. * fpclassify: (libc)Floating Point Classes.
  1156. * fprintf: (libc)Formatted Output Functions.
  1157. * fputc: (libc)Simple Output.
  1158. * fputc_unlocked: (libc)Simple Output.
  1159. * fputs: (libc)Simple Output.
  1160. * fputs_unlocked: (libc)Simple Output.
  1161. * fputwc: (libc)Simple Output.
  1162. * fputwc_unlocked: (libc)Simple Output.
  1163. * fputws: (libc)Simple Output.
  1164. * fputws_unlocked: (libc)Simple Output.
  1165. * fread: (libc)Block Input/Output.
  1166. * fread_unlocked: (libc)Block Input/Output.
  1167. * free: (libc)Freeing after Malloc.
  1168. * free_aligned_sized: (libc)Freeing after Malloc.
  1169. * free_sized: (libc)Freeing after Malloc.
  1170. * freopen64: (libc)Opening Streams.
  1171. * freopen: (libc)Opening Streams.
  1172. * frexp: (libc)Normalization Functions.
  1173. * frexpf: (libc)Normalization Functions.
  1174. * frexpfN: (libc)Normalization Functions.
  1175. * frexpfNx: (libc)Normalization Functions.
  1176. * frexpl: (libc)Normalization Functions.
  1177. * fromfp: (libc)Rounding Functions.
  1178. * fromfpf: (libc)Rounding Functions.
  1179. * fromfpfN: (libc)Rounding Functions.
  1180. * fromfpfNx: (libc)Rounding Functions.
  1181. * fromfpl: (libc)Rounding Functions.
  1182. * fromfpx: (libc)Rounding Functions.
  1183. * fromfpxf: (libc)Rounding Functions.
  1184. * fromfpxfN: (libc)Rounding Functions.
  1185. * fromfpxfNx: (libc)Rounding Functions.
  1186. * fromfpxl: (libc)Rounding Functions.
  1187. * fscanf: (libc)Formatted Input Functions.
  1188. * fseek: (libc)File Positioning.
  1189. * fseeko64: (libc)File Positioning.
  1190. * fseeko: (libc)File Positioning.
  1191. * fsetpos64: (libc)Portable Positioning.
  1192. * fsetpos: (libc)Portable Positioning.
  1193. * fsqrt: (libc)Misc FP Arithmetic.
  1194. * fsqrtl: (libc)Misc FP Arithmetic.
  1195. * fstat64: (libc)Reading Attributes.
  1196. * fstat: (libc)Reading Attributes.
  1197. * fstatat64: (libc)Reading Attributes.
  1198. * fstatat: (libc)Reading Attributes.
  1199. * fsub: (libc)Misc FP Arithmetic.
  1200. * fsubl: (libc)Misc FP Arithmetic.
  1201. * fsync: (libc)Synchronizing I/O.
  1202. * ftell: (libc)File Positioning.
  1203. * ftello64: (libc)File Positioning.
  1204. * ftello: (libc)File Positioning.
  1205. * ftruncate64: (libc)File Size.
  1206. * ftruncate: (libc)File Size.
  1207. * ftrylockfile: (libc)Streams and Threads.
  1208. * ftw64: (libc)Working with Directory Trees.
  1209. * ftw: (libc)Working with Directory Trees.
  1210. * funlockfile: (libc)Streams and Threads.
  1211. * futimens: (libc)File Times.
  1212. * futimes: (libc)File Times.
  1213. * fwide: (libc)Streams and I18N.
  1214. * fwprintf: (libc)Formatted Output Functions.
  1215. * fwrite: (libc)Block Input/Output.
  1216. * fwrite_unlocked: (libc)Block Input/Output.
  1217. * fwscanf: (libc)Formatted Input Functions.
  1218. * gamma: (libc)Special Functions.
  1219. * gammaf: (libc)Special Functions.
  1220. * gammal: (libc)Special Functions.
  1221. * gcvt: (libc)System V Number Conversion.
  1222. * get_avphys_pages: (libc)Query Memory Parameters.
  1223. * get_current_dir_name: (libc)Working Directory.
  1224. * get_nprocs: (libc)Processor Resources.
  1225. * get_nprocs_conf: (libc)Processor Resources.
  1226. * get_phys_pages: (libc)Query Memory Parameters.
  1227. * getauxval: (libc)Auxiliary Vector.
  1228. * getc: (libc)Character Input.
  1229. * getc_unlocked: (libc)Character Input.
  1230. * getchar: (libc)Character Input.
  1231. * getchar_unlocked: (libc)Character Input.
  1232. * getcontext: (libc)System V contexts.
  1233. * getcpu: (libc)CPU Affinity.
  1234. * getcwd: (libc)Working Directory.
  1235. * getdate: (libc)General Time String Parsing.
  1236. * getdate_r: (libc)General Time String Parsing.
  1237. * getdelim: (libc)Line Input.
  1238. * getdents64: (libc)Low-level Directory Access.
  1239. * getdomainname: (libc)Host Identification.
  1240. * getegid: (libc)Reading Persona.
  1241. * getentropy: (libc)Unpredictable Bytes.
  1242. * getenv: (libc)Environment Access.
  1243. * geteuid: (libc)Reading Persona.
  1244. * getfsent: (libc)fstab.
  1245. * getfsfile: (libc)fstab.
  1246. * getfsspec: (libc)fstab.
  1247. * getgid: (libc)Reading Persona.
  1248. * getgrent: (libc)Scanning All Groups.
  1249. * getgrent_r: (libc)Scanning All Groups.
  1250. * getgrgid: (libc)Lookup Group.
  1251. * getgrgid_r: (libc)Lookup Group.
  1252. * getgrnam: (libc)Lookup Group.
  1253. * getgrnam_r: (libc)Lookup Group.
  1254. * getgrouplist: (libc)Setting Groups.
  1255. * getgroups: (libc)Reading Persona.
  1256. * gethostbyaddr: (libc)Host Names.
  1257. * gethostbyaddr_r: (libc)Host Names.
  1258. * gethostbyname2: (libc)Host Names.
  1259. * gethostbyname2_r: (libc)Host Names.
  1260. * gethostbyname: (libc)Host Names.
  1261. * gethostbyname_r: (libc)Host Names.
  1262. * gethostent: (libc)Host Names.
  1263. * gethostid: (libc)Host Identification.
  1264. * gethostname: (libc)Host Identification.
  1265. * getitimer: (libc)Setting an Alarm.
  1266. * getline: (libc)Line Input.
  1267. * getloadavg: (libc)Processor Resources.
  1268. * getlogin: (libc)Who Logged In.
  1269. * getmntent: (libc)mtab.
  1270. * getmntent_r: (libc)mtab.
  1271. * getnetbyaddr: (libc)Networks Database.
  1272. * getnetbyname: (libc)Networks Database.
  1273. * getnetent: (libc)Networks Database.
  1274. * getnetgrent: (libc)Lookup Netgroup.
  1275. * getnetgrent_r: (libc)Lookup Netgroup.
  1276. * getopt: (libc)Using Getopt.
  1277. * getopt_long: (libc)Getopt Long Options.
  1278. * getopt_long_only: (libc)Getopt Long Options.
  1279. * getpagesize: (libc)Query Memory Parameters.
  1280. * getpass: (libc)getpass.
  1281. * getpayload: (libc)FP Bit Twiddling.
  1282. * getpayloadf: (libc)FP Bit Twiddling.
  1283. * getpayloadfN: (libc)FP Bit Twiddling.
  1284. * getpayloadfNx: (libc)FP Bit Twiddling.
  1285. * getpayloadl: (libc)FP Bit Twiddling.
  1286. * getpeername: (libc)Who is Connected.
  1287. * getpgid: (libc)Process Group Functions.
  1288. * getpgrp: (libc)Process Group Functions.
  1289. * getpid: (libc)Process Identification.
  1290. * getppid: (libc)Process Identification.
  1291. * getpriority: (libc)Traditional Scheduling Functions.
  1292. * getprotobyname: (libc)Protocols Database.
  1293. * getprotobynumber: (libc)Protocols Database.
  1294. * getprotoent: (libc)Protocols Database.
  1295. * getpt: (libc)Allocation.
  1296. * getpwent: (libc)Scanning All Users.
  1297. * getpwent_r: (libc)Scanning All Users.
  1298. * getpwnam: (libc)Lookup User.
  1299. * getpwnam_r: (libc)Lookup User.
  1300. * getpwuid: (libc)Lookup User.
  1301. * getpwuid_r: (libc)Lookup User.
  1302. * getrandom: (libc)Unpredictable Bytes.
  1303. * getrlimit64: (libc)Limits on Resources.
  1304. * getrlimit: (libc)Limits on Resources.
  1305. * getrusage: (libc)Resource Usage.
  1306. * gets: (libc)Line Input.
  1307. * getservbyname: (libc)Services Database.
  1308. * getservbyport: (libc)Services Database.
  1309. * getservent: (libc)Services Database.
  1310. * getsid: (libc)Process Group Functions.
  1311. * getsockname: (libc)Reading Address.
  1312. * getsockopt: (libc)Socket Option Functions.
  1313. * getsubopt: (libc)Suboptions.
  1314. * gettext: (libc)Translation with gettext.
  1315. * gettid: (libc)Process Identification.
  1316. * gettimeofday: (libc)Getting the Time.
  1317. * getuid: (libc)Reading Persona.
  1318. * getumask: (libc)Setting Permissions.
  1319. * getutent: (libc)Manipulating the Database.
  1320. * getutent_r: (libc)Manipulating the Database.
  1321. * getutid: (libc)Manipulating the Database.
  1322. * getutid_r: (libc)Manipulating the Database.
  1323. * getutline: (libc)Manipulating the Database.
  1324. * getutline_r: (libc)Manipulating the Database.
  1325. * getutmp: (libc)XPG Functions.
  1326. * getutmpx: (libc)XPG Functions.
  1327. * getutxent: (libc)XPG Functions.
  1328. * getutxid: (libc)XPG Functions.
  1329. * getutxline: (libc)XPG Functions.
  1330. * getw: (libc)Character Input.
  1331. * getwc: (libc)Character Input.
  1332. * getwc_unlocked: (libc)Character Input.
  1333. * getwchar: (libc)Character Input.
  1334. * getwchar_unlocked: (libc)Character Input.
  1335. * getwd: (libc)Working Directory.
  1336. * glob64: (libc)Calling Glob.
  1337. * glob: (libc)Calling Glob.
  1338. * globfree64: (libc)More Flags for Globbing.
  1339. * globfree: (libc)More Flags for Globbing.
  1340. * gmtime: (libc)Broken-down Time.
  1341. * gmtime_r: (libc)Broken-down Time.
  1342. * grantpt: (libc)Allocation.
  1343. * gsignal: (libc)Signaling Yourself.
  1344. * gtty: (libc)BSD Terminal Modes.
  1345. * hasmntopt: (libc)mtab.
  1346. * hcreate: (libc)Hash Search Function.
  1347. * hcreate_r: (libc)Hash Search Function.
  1348. * hdestroy: (libc)Hash Search Function.
  1349. * hdestroy_r: (libc)Hash Search Function.
  1350. * hsearch: (libc)Hash Search Function.
  1351. * hsearch_r: (libc)Hash Search Function.
  1352. * htonl: (libc)Byte Order.
  1353. * htons: (libc)Byte Order.
  1354. * hypot: (libc)Exponents and Logarithms.
  1355. * hypotf: (libc)Exponents and Logarithms.
  1356. * hypotfN: (libc)Exponents and Logarithms.
  1357. * hypotfNx: (libc)Exponents and Logarithms.
  1358. * hypotl: (libc)Exponents and Logarithms.
  1359. * iconv: (libc)Generic Conversion Interface.
  1360. * iconv_close: (libc)Generic Conversion Interface.
  1361. * iconv_open: (libc)Generic Conversion Interface.
  1362. * if_freenameindex: (libc)Interface Naming.
  1363. * if_indextoname: (libc)Interface Naming.
  1364. * if_nameindex: (libc)Interface Naming.
  1365. * if_nametoindex: (libc)Interface Naming.
  1366. * ilogb: (libc)Exponents and Logarithms.
  1367. * ilogbf: (libc)Exponents and Logarithms.
  1368. * ilogbfN: (libc)Exponents and Logarithms.
  1369. * ilogbfNx: (libc)Exponents and Logarithms.
  1370. * ilogbl: (libc)Exponents and Logarithms.
  1371. * imaxabs: (libc)Absolute Value.
  1372. * imaxdiv: (libc)Integer Division.
  1373. * in6addr_any: (libc)Host Address Data Type.
  1374. * in6addr_loopback: (libc)Host Address Data Type.
  1375. * index: (libc)Search Functions.
  1376. * inet_addr: (libc)Host Address Functions.
  1377. * inet_aton: (libc)Host Address Functions.
  1378. * inet_lnaof: (libc)Host Address Functions.
  1379. * inet_makeaddr: (libc)Host Address Functions.
  1380. * inet_netof: (libc)Host Address Functions.
  1381. * inet_network: (libc)Host Address Functions.
  1382. * inet_ntoa: (libc)Host Address Functions.
  1383. * inet_ntop: (libc)Host Address Functions.
  1384. * inet_pton: (libc)Host Address Functions.
  1385. * initgroups: (libc)Setting Groups.
  1386. * initstate: (libc)BSD Random.
  1387. * initstate_r: (libc)BSD Random.
  1388. * innetgr: (libc)Netgroup Membership.
  1389. * ioctl: (libc)IOCTLs.
  1390. * isalnum: (libc)Classification of Characters.
  1391. * isalpha: (libc)Classification of Characters.
  1392. * isascii: (libc)Classification of Characters.
  1393. * isatty: (libc)Is It a Terminal.
  1394. * isblank: (libc)Classification of Characters.
  1395. * iscanonical: (libc)Floating Point Classes.
  1396. * iscntrl: (libc)Classification of Characters.
  1397. * isdigit: (libc)Classification of Characters.
  1398. * iseqsig: (libc)FP Comparison Functions.
  1399. * isfinite: (libc)Floating Point Classes.
  1400. * isgraph: (libc)Classification of Characters.
  1401. * isgreater: (libc)FP Comparison Functions.
  1402. * isgreaterequal: (libc)FP Comparison Functions.
  1403. * isinf: (libc)Floating Point Classes.
  1404. * isinff: (libc)Floating Point Classes.
  1405. * isinfl: (libc)Floating Point Classes.
  1406. * isless: (libc)FP Comparison Functions.
  1407. * islessequal: (libc)FP Comparison Functions.
  1408. * islessgreater: (libc)FP Comparison Functions.
  1409. * islower: (libc)Classification of Characters.
  1410. * isnan: (libc)Floating Point Classes.
  1411. * isnan: (libc)Floating Point Classes.
  1412. * isnanf: (libc)Floating Point Classes.
  1413. * isnanl: (libc)Floating Point Classes.
  1414. * isnormal: (libc)Floating Point Classes.
  1415. * isprint: (libc)Classification of Characters.
  1416. * ispunct: (libc)Classification of Characters.
  1417. * issignaling: (libc)Floating Point Classes.
  1418. * isspace: (libc)Classification of Characters.
  1419. * issubnormal: (libc)Floating Point Classes.
  1420. * isunordered: (libc)FP Comparison Functions.
  1421. * isupper: (libc)Classification of Characters.
  1422. * iswalnum: (libc)Classification of Wide Characters.
  1423. * iswalpha: (libc)Classification of Wide Characters.
  1424. * iswblank: (libc)Classification of Wide Characters.
  1425. * iswcntrl: (libc)Classification of Wide Characters.
  1426. * iswctype: (libc)Classification of Wide Characters.
  1427. * iswdigit: (libc)Classification of Wide Characters.
  1428. * iswgraph: (libc)Classification of Wide Characters.
  1429. * iswlower: (libc)Classification of Wide Characters.
  1430. * iswprint: (libc)Classification of Wide Characters.
  1431. * iswpunct: (libc)Classification of Wide Characters.
  1432. * iswspace: (libc)Classification of Wide Characters.
  1433. * iswupper: (libc)Classification of Wide Characters.
  1434. * iswxdigit: (libc)Classification of Wide Characters.
  1435. * isxdigit: (libc)Classification of Characters.
  1436. * iszero: (libc)Floating Point Classes.
  1437. * j0: (libc)Special Functions.
  1438. * j0f: (libc)Special Functions.
  1439. * j0fN: (libc)Special Functions.
  1440. * j0fNx: (libc)Special Functions.
  1441. * j0l: (libc)Special Functions.
  1442. * j1: (libc)Special Functions.
  1443. * j1f: (libc)Special Functions.
  1444. * j1fN: (libc)Special Functions.
  1445. * j1fNx: (libc)Special Functions.
  1446. * j1l: (libc)Special Functions.
  1447. * jn: (libc)Special Functions.
  1448. * jnf: (libc)Special Functions.
  1449. * jnfN: (libc)Special Functions.
  1450. * jnfNx: (libc)Special Functions.
  1451. * jnl: (libc)Special Functions.
  1452. * jrand48: (libc)SVID Random.
  1453. * jrand48_r: (libc)SVID Random.
  1454. * kill: (libc)Signaling Another Process.
  1455. * killpg: (libc)Signaling Another Process.
  1456. * l64a: (libc)Encode Binary Data.
  1457. * labs: (libc)Absolute Value.
  1458. * lcong48: (libc)SVID Random.
  1459. * lcong48_r: (libc)SVID Random.
  1460. * ldexp: (libc)Normalization Functions.
  1461. * ldexpf: (libc)Normalization Functions.
  1462. * ldexpfN: (libc)Normalization Functions.
  1463. * ldexpfNx: (libc)Normalization Functions.
  1464. * ldexpl: (libc)Normalization Functions.
  1465. * ldiv: (libc)Integer Division.
  1466. * lfind: (libc)Array Search Function.
  1467. * lgamma: (libc)Special Functions.
  1468. * lgamma_r: (libc)Special Functions.
  1469. * lgammaf: (libc)Special Functions.
  1470. * lgammafN: (libc)Special Functions.
  1471. * lgammafN_r: (libc)Special Functions.
  1472. * lgammafNx: (libc)Special Functions.
  1473. * lgammafNx_r: (libc)Special Functions.
  1474. * lgammaf_r: (libc)Special Functions.
  1475. * lgammal: (libc)Special Functions.
  1476. * lgammal_r: (libc)Special Functions.
  1477. * link: (libc)Hard Links.
  1478. * linkat: (libc)Hard Links.
  1479. * lio_listio64: (libc)Asynchronous Reads/Writes.
  1480. * lio_listio: (libc)Asynchronous Reads/Writes.
  1481. * listen: (libc)Listening.
  1482. * llabs: (libc)Absolute Value.
  1483. * lldiv: (libc)Integer Division.
  1484. * llogb: (libc)Exponents and Logarithms.
  1485. * llogbf: (libc)Exponents and Logarithms.
  1486. * llogbfN: (libc)Exponents and Logarithms.
  1487. * llogbfNx: (libc)Exponents and Logarithms.
  1488. * llogbl: (libc)Exponents and Logarithms.
  1489. * llrint: (libc)Rounding Functions.
  1490. * llrintf: (libc)Rounding Functions.
  1491. * llrintfN: (libc)Rounding Functions.
  1492. * llrintfNx: (libc)Rounding Functions.
  1493. * llrintl: (libc)Rounding Functions.
  1494. * llround: (libc)Rounding Functions.
  1495. * llroundf: (libc)Rounding Functions.
  1496. * llroundfN: (libc)Rounding Functions.
  1497. * llroundfNx: (libc)Rounding Functions.
  1498. * llroundl: (libc)Rounding Functions.
  1499. * localeconv: (libc)The Lame Way to Locale Data.
  1500. * localtime: (libc)Broken-down Time.
  1501. * localtime_r: (libc)Broken-down Time.
  1502. * log10: (libc)Exponents and Logarithms.
  1503. * log10f: (libc)Exponents and Logarithms.
  1504. * log10fN: (libc)Exponents and Logarithms.
  1505. * log10fNx: (libc)Exponents and Logarithms.
  1506. * log10l: (libc)Exponents and Logarithms.
  1507. * log10p1: (libc)Exponents and Logarithms.
  1508. * log10p1f: (libc)Exponents and Logarithms.
  1509. * log10p1fN: (libc)Exponents and Logarithms.
  1510. * log10p1fNx: (libc)Exponents and Logarithms.
  1511. * log10p1l: (libc)Exponents and Logarithms.
  1512. * log1p: (libc)Exponents and Logarithms.
  1513. * log1pf: (libc)Exponents and Logarithms.
  1514. * log1pfN: (libc)Exponents and Logarithms.
  1515. * log1pfNx: (libc)Exponents and Logarithms.
  1516. * log1pl: (libc)Exponents and Logarithms.
  1517. * log2: (libc)Exponents and Logarithms.
  1518. * log2f: (libc)Exponents and Logarithms.
  1519. * log2fN: (libc)Exponents and Logarithms.
  1520. * log2fNx: (libc)Exponents and Logarithms.
  1521. * log2l: (libc)Exponents and Logarithms.
  1522. * log2p1: (libc)Exponents and Logarithms.
  1523. * log2p1f: (libc)Exponents and Logarithms.
  1524. * log2p1fN: (libc)Exponents and Logarithms.
  1525. * log2p1fNx: (libc)Exponents and Logarithms.
  1526. * log2p1l: (libc)Exponents and Logarithms.
  1527. * log: (libc)Exponents and Logarithms.
  1528. * logb: (libc)Exponents and Logarithms.
  1529. * logbf: (libc)Exponents and Logarithms.
  1530. * logbfN: (libc)Exponents and Logarithms.
  1531. * logbfNx: (libc)Exponents and Logarithms.
  1532. * logbl: (libc)Exponents and Logarithms.
  1533. * logf: (libc)Exponents and Logarithms.
  1534. * logfN: (libc)Exponents and Logarithms.
  1535. * logfNx: (libc)Exponents and Logarithms.
  1536. * login: (libc)Logging In and Out.
  1537. * login_tty: (libc)Logging In and Out.
  1538. * logl: (libc)Exponents and Logarithms.
  1539. * logout: (libc)Logging In and Out.
  1540. * logp1: (libc)Exponents and Logarithms.
  1541. * logp1f: (libc)Exponents and Logarithms.
  1542. * logp1fN: (libc)Exponents and Logarithms.
  1543. * logp1fNx: (libc)Exponents and Logarithms.
  1544. * logp1l: (libc)Exponents and Logarithms.
  1545. * logwtmp: (libc)Logging In and Out.
  1546. * longjmp: (libc)Non-Local Details.
  1547. * lrand48: (libc)SVID Random.
  1548. * lrand48_r: (libc)SVID Random.
  1549. * lrint: (libc)Rounding Functions.
  1550. * lrintf: (libc)Rounding Functions.
  1551. * lrintfN: (libc)Rounding Functions.
  1552. * lrintfNx: (libc)Rounding Functions.
  1553. * lrintl: (libc)Rounding Functions.
  1554. * lround: (libc)Rounding Functions.
  1555. * lroundf: (libc)Rounding Functions.
  1556. * lroundfN: (libc)Rounding Functions.
  1557. * lroundfNx: (libc)Rounding Functions.
  1558. * lroundl: (libc)Rounding Functions.
  1559. * lsearch: (libc)Array Search Function.
  1560. * lseek64: (libc)File Position Primitive.
  1561. * lseek: (libc)File Position Primitive.
  1562. * lstat64: (libc)Reading Attributes.
  1563. * lstat: (libc)Reading Attributes.
  1564. * lutimes: (libc)File Times.
  1565. * madvise: (libc)Memory-mapped I/O.
  1566. * makecontext: (libc)System V contexts.
  1567. * mallinfo2: (libc)Statistics of Malloc.
  1568. * malloc: (libc)Basic Allocation.
  1569. * mallopt: (libc)Malloc Tunable Parameters.
  1570. * mblen: (libc)Non-reentrant Character Conversion.
  1571. * mbrlen: (libc)Converting a Character.
  1572. * mbrtowc: (libc)Converting a Character.
  1573. * mbsinit: (libc)Keeping the state.
  1574. * mbsnrtowcs: (libc)Converting Strings.
  1575. * mbsrtowcs: (libc)Converting Strings.
  1576. * mbstowcs: (libc)Non-reentrant String Conversion.
  1577. * mbtowc: (libc)Non-reentrant Character Conversion.
  1578. * mcheck: (libc)Heap Consistency Checking.
  1579. * memalign: (libc)Aligned Memory Blocks.
  1580. * memalignment: (libc)Aligned Memory Blocks.
  1581. * memccpy: (libc)Copying Strings and Arrays.
  1582. * memchr: (libc)Search Functions.
  1583. * memcmp: (libc)String/Array Comparison.
  1584. * memcpy: (libc)Copying Strings and Arrays.
  1585. * memfd_create: (libc)Memory-mapped I/O.
  1586. * memfrob: (libc)Obfuscating Data.
  1587. * memmem: (libc)Search Functions.
  1588. * memmove: (libc)Copying Strings and Arrays.
  1589. * mempcpy: (libc)Copying Strings and Arrays.
  1590. * memrchr: (libc)Search Functions.
  1591. * memset: (libc)Copying Strings and Arrays.
  1592. * memset_explicit: (libc)Erasing Sensitive Data.
  1593. * mkdir: (libc)Creating Directories.
  1594. * mkdirat: (libc)Creating Directories.
  1595. * mkdtemp: (libc)Temporary Files.
  1596. * mkfifo: (libc)FIFO Special Files.
  1597. * mknod: (libc)Making Special Files.
  1598. * mkstemp: (libc)Temporary Files.
  1599. * mktemp: (libc)Temporary Files.
  1600. * mktime: (libc)Broken-down Time.
  1601. * mlock2: (libc)Page Lock Functions.
  1602. * mlock: (libc)Page Lock Functions.
  1603. * mlockall: (libc)Page Lock Functions.
  1604. * mmap64: (libc)Memory-mapped I/O.
  1605. * mmap: (libc)Memory-mapped I/O.
  1606. * modf: (libc)Rounding Functions.
  1607. * modff: (libc)Rounding Functions.
  1608. * modffN: (libc)Rounding Functions.
  1609. * modffNx: (libc)Rounding Functions.
  1610. * modfl: (libc)Rounding Functions.
  1611. * mount: (libc)Mount-Unmount-Remount.
  1612. * mprobe: (libc)Heap Consistency Checking.
  1613. * mprotect: (libc)Memory Protection.
  1614. * mrand48: (libc)SVID Random.
  1615. * mrand48_r: (libc)SVID Random.
  1616. * mremap: (libc)Memory-mapped I/O.
  1617. * mseal: (libc)Memory Protection.
  1618. * msync: (libc)Memory-mapped I/O.
  1619. * mtrace: (libc)Tracing malloc.
  1620. * mtx_destroy: (libc)ISO C Mutexes.
  1621. * mtx_init: (libc)ISO C Mutexes.
  1622. * mtx_lock: (libc)ISO C Mutexes.
  1623. * mtx_timedlock: (libc)ISO C Mutexes.
  1624. * mtx_trylock: (libc)ISO C Mutexes.
  1625. * mtx_unlock: (libc)ISO C Mutexes.
  1626. * munlock: (libc)Page Lock Functions.
  1627. * munlockall: (libc)Page Lock Functions.
  1628. * munmap: (libc)Memory-mapped I/O.
  1629. * muntrace: (libc)Tracing malloc.
  1630. * nan: (libc)FP Bit Twiddling.
  1631. * nanf: (libc)FP Bit Twiddling.
  1632. * nanfN: (libc)FP Bit Twiddling.
  1633. * nanfNx: (libc)FP Bit Twiddling.
  1634. * nanl: (libc)FP Bit Twiddling.
  1635. * nanosleep: (libc)Sleeping.
  1636. * nearbyint: (libc)Rounding Functions.
  1637. * nearbyintf: (libc)Rounding Functions.
  1638. * nearbyintfN: (libc)Rounding Functions.
  1639. * nearbyintfNx: (libc)Rounding Functions.
  1640. * nearbyintl: (libc)Rounding Functions.
  1641. * nextafter: (libc)FP Bit Twiddling.
  1642. * nextafterf: (libc)FP Bit Twiddling.
  1643. * nextafterfN: (libc)FP Bit Twiddling.
  1644. * nextafterfNx: (libc)FP Bit Twiddling.
  1645. * nextafterl: (libc)FP Bit Twiddling.
  1646. * nextdown: (libc)FP Bit Twiddling.
  1647. * nextdownf: (libc)FP Bit Twiddling.
  1648. * nextdownfN: (libc)FP Bit Twiddling.
  1649. * nextdownfNx: (libc)FP Bit Twiddling.
  1650. * nextdownl: (libc)FP Bit Twiddling.
  1651. * nexttoward: (libc)FP Bit Twiddling.
  1652. * nexttowardf: (libc)FP Bit Twiddling.
  1653. * nexttowardl: (libc)FP Bit Twiddling.
  1654. * nextup: (libc)FP Bit Twiddling.
  1655. * nextupf: (libc)FP Bit Twiddling.
  1656. * nextupfN: (libc)FP Bit Twiddling.
  1657. * nextupfNx: (libc)FP Bit Twiddling.
  1658. * nextupl: (libc)FP Bit Twiddling.
  1659. * nftw64: (libc)Working with Directory Trees.
  1660. * nftw: (libc)Working with Directory Trees.
  1661. * ngettext: (libc)Advanced gettext functions.
  1662. * nice: (libc)Traditional Scheduling Functions.
  1663. * nl_langinfo: (libc)The Elegant and Fast Way.
  1664. * nrand48: (libc)SVID Random.
  1665. * nrand48_r: (libc)SVID Random.
  1666. * ntohl: (libc)Byte Order.
  1667. * ntohs: (libc)Byte Order.
  1668. * ntp_adjtime: (libc)Setting and Adjusting the Time.
  1669. * ntp_gettime: (libc)Setting and Adjusting the Time.
  1670. * obstack_1grow: (libc)Growing Objects.
  1671. * obstack_1grow_fast: (libc)Extra Fast Growing.
  1672. * obstack_alignment_mask: (libc)Obstacks Data Alignment.
  1673. * obstack_alloc: (libc)Allocation in an Obstack.
  1674. * obstack_base: (libc)Status of an Obstack.
  1675. * obstack_blank: (libc)Growing Objects.
  1676. * obstack_blank_fast: (libc)Extra Fast Growing.
  1677. * obstack_chunk_size: (libc)Obstack Chunks.
  1678. * obstack_copy0: (libc)Allocation in an Obstack.
  1679. * obstack_copy: (libc)Allocation in an Obstack.
  1680. * obstack_finish: (libc)Growing Objects.
  1681. * obstack_free: (libc)Freeing Obstack Objects.
  1682. * obstack_grow0: (libc)Growing Objects.
  1683. * obstack_grow: (libc)Growing Objects.
  1684. * obstack_init: (libc)Preparing for Obstacks.
  1685. * obstack_int_grow: (libc)Growing Objects.
  1686. * obstack_int_grow_fast: (libc)Extra Fast Growing.
  1687. * obstack_next_free: (libc)Status of an Obstack.
  1688. * obstack_object_size: (libc)Growing Objects.
  1689. * obstack_object_size: (libc)Status of an Obstack.
  1690. * obstack_printf: (libc)Dynamic Output.
  1691. * obstack_ptr_grow: (libc)Growing Objects.
  1692. * obstack_ptr_grow_fast: (libc)Extra Fast Growing.
  1693. * obstack_room: (libc)Extra Fast Growing.
  1694. * obstack_vprintf: (libc)Variable Arguments Output.
  1695. * offsetof: (libc)Structure Measurement.
  1696. * on_exit: (libc)Cleanups on Exit.
  1697. * open64: (libc)Opening and Closing Files.
  1698. * open: (libc)Opening and Closing Files.
  1699. * open_memstream: (libc)String Streams.
  1700. * openat2: (libc)Opening and Closing Files.
  1701. * openat64: (libc)Opening and Closing Files.
  1702. * openat: (libc)Opening and Closing Files.
  1703. * opendir: (libc)Opening a Directory.
  1704. * openlog: (libc)openlog.
  1705. * openpty: (libc)Pseudo-Terminal Pairs.
  1706. * parse_printf_format: (libc)Parsing a Template String.
  1707. * pathconf: (libc)Pathconf.
  1708. * pause: (libc)Using Pause.
  1709. * pclose: (libc)Pipe to a Subprocess.
  1710. * perror: (libc)Error Messages.
  1711. * pidfd_getpid: (libc)Querying a Process.
  1712. * pipe: (libc)Creating a Pipe.
  1713. * pkey_alloc: (libc)Memory Protection.
  1714. * pkey_free: (libc)Memory Protection.
  1715. * pkey_get: (libc)Memory Protection.
  1716. * pkey_mprotect: (libc)Memory Protection.
  1717. * pkey_set: (libc)Memory Protection.
  1718. * poll: (libc)Other Low-Level I/O APIs.
  1719. * popen: (libc)Pipe to a Subprocess.
  1720. * posix_fallocate64: (libc)Storage Allocation.
  1721. * posix_fallocate: (libc)Storage Allocation.
  1722. * posix_memalign: (libc)Aligned Memory Blocks.
  1723. * posix_openpt: (libc)Allocation.
  1724. * pow: (libc)Exponents and Logarithms.
  1725. * powf: (libc)Exponents and Logarithms.
  1726. * powfN: (libc)Exponents and Logarithms.
  1727. * powfNx: (libc)Exponents and Logarithms.
  1728. * powl: (libc)Exponents and Logarithms.
  1729. * pown: (libc)Exponents and Logarithms.
  1730. * pownf: (libc)Exponents and Logarithms.
  1731. * pownfN: (libc)Exponents and Logarithms.
  1732. * pownfNx: (libc)Exponents and Logarithms.
  1733. * pownl: (libc)Exponents and Logarithms.
  1734. * powr: (libc)Exponents and Logarithms.
  1735. * powrf: (libc)Exponents and Logarithms.
  1736. * powrfN: (libc)Exponents and Logarithms.
  1737. * powrfNx: (libc)Exponents and Logarithms.
  1738. * powrl: (libc)Exponents and Logarithms.
  1739. * pread64: (libc)I/O Primitives.
  1740. * pread: (libc)I/O Primitives.
  1741. * preadv2: (libc)Scatter-Gather.
  1742. * preadv64: (libc)Scatter-Gather.
  1743. * preadv64v2: (libc)Scatter-Gather.
  1744. * preadv: (libc)Scatter-Gather.
  1745. * printf: (libc)Formatted Output Functions.
  1746. * printf_size: (libc)Predefined Printf Handlers.
  1747. * printf_size_info: (libc)Predefined Printf Handlers.
  1748. * psignal: (libc)Signal Messages.
  1749. * pthread_attr_destroy: (libc)Creating and Destroying Threads.
  1750. * pthread_attr_getaffinity_np: (libc)Thread CPU Affinity.
  1751. * pthread_attr_getdetachstate: (libc)Creating and Destroying Threads.
  1752. * pthread_attr_getsigmask_np: (libc)Initial Thread Signal Mask.
  1753. * pthread_attr_init: (libc)Creating and Destroying Threads.
  1754. * pthread_attr_setaffinity_np: (libc)Thread CPU Affinity.
  1755. * pthread_attr_setdetachstate: (libc)Creating and Destroying Threads.
  1756. * pthread_attr_setsigmask_np: (libc)Initial Thread Signal Mask.
  1757. * pthread_barrier_destroy: (libc)POSIX Barriers.
  1758. * pthread_barrier_init: (libc)POSIX Barriers.
  1759. * pthread_barrier_wait: (libc)POSIX Barriers.
  1760. * pthread_clockjoin_np: (libc)Joining Threads.
  1761. * pthread_cond_clockwait: (libc)Waiting with Explicit Clocks.
  1762. * pthread_create: (libc)Creating and Destroying Threads.
  1763. * pthread_detach: (libc)Creating and Destroying Threads.
  1764. * pthread_equal: (libc)POSIX Threads Other APIs.
  1765. * pthread_getaffinity_np: (libc)Thread CPU Affinity.
  1766. * pthread_getattr_default_np: (libc)Default Thread Attributes.
  1767. * pthread_getcpuclockid: (libc)POSIX Threads Other APIs.
  1768. * pthread_getname_np: (libc)Thread Names.
  1769. * pthread_getspecific: (libc)Thread-specific Data.
  1770. * pthread_gettid_np: (libc)Process Identification.
  1771. * pthread_join: (libc)Creating and Destroying Threads.
  1772. * pthread_key_create: (libc)Thread-specific Data.
  1773. * pthread_key_delete: (libc)Thread-specific Data.
  1774. * pthread_kill: (libc)Creating and Destroying Threads.
  1775. * pthread_mutex_clocklock: (libc)POSIX Mutexes.
  1776. * pthread_mutex_destroy: (libc)POSIX Mutexes.
  1777. * pthread_mutex_init: (libc)POSIX Mutexes.
  1778. * pthread_mutex_lock: (libc)POSIX Mutexes.
  1779. * pthread_mutex_timedlock: (libc)POSIX Mutexes.
  1780. * pthread_mutex_trylock: (libc)POSIX Mutexes.
  1781. * pthread_mutex_unlock: (libc)POSIX Mutexes.
  1782. * pthread_mutexattr_destroy: (libc)POSIX Mutexes.
  1783. * pthread_mutexattr_gettype: (libc)POSIX Mutexes.
  1784. * pthread_mutexattr_init: (libc)POSIX Mutexes.
  1785. * pthread_mutexattr_settype: (libc)POSIX Mutexes.
  1786. * pthread_once: (libc)POSIX Threads Other APIs.
  1787. * pthread_rwlock_clockrdlock: (libc)Waiting with Explicit Clocks.
  1788. * pthread_rwlock_clockwrlock: (libc)Waiting with Explicit Clocks.
  1789. * pthread_self: (libc)Creating and Destroying Threads.
  1790. * pthread_setaffinity_np: (libc)Thread CPU Affinity.
  1791. * pthread_setattr_default_np: (libc)Default Thread Attributes.
  1792. * pthread_setname_np: (libc)Thread Names.
  1793. * pthread_setspecific: (libc)Thread-specific Data.
  1794. * pthread_sigmask: (libc)POSIX Threads Other APIs.
  1795. * pthread_spin_destroy: (libc)POSIX Spin Locks.
  1796. * pthread_spin_init: (libc)POSIX Spin Locks.
  1797. * pthread_spin_lock: (libc)POSIX Spin Locks.
  1798. * pthread_spin_trylock: (libc)POSIX Spin Locks.
  1799. * pthread_spin_unlock: (libc)POSIX Spin Locks.
  1800. * pthread_timedjoin_np: (libc)Joining Threads.
  1801. * pthread_tryjoin_np: (libc)Joining Threads.
  1802. * ptsname: (libc)Allocation.
  1803. * ptsname_r: (libc)Allocation.
  1804. * putc: (libc)Simple Output.
  1805. * putc_unlocked: (libc)Simple Output.
  1806. * putchar: (libc)Simple Output.
  1807. * putchar_unlocked: (libc)Simple Output.
  1808. * putenv: (libc)Environment Access.
  1809. * putpwent: (libc)Writing a User Entry.
  1810. * puts: (libc)Simple Output.
  1811. * pututline: (libc)Manipulating the Database.
  1812. * pututxline: (libc)XPG Functions.
  1813. * putw: (libc)Simple Output.
  1814. * putwc: (libc)Simple Output.
  1815. * putwc_unlocked: (libc)Simple Output.
  1816. * putwchar: (libc)Simple Output.
  1817. * putwchar_unlocked: (libc)Simple Output.
  1818. * pwrite64: (libc)I/O Primitives.
  1819. * pwrite: (libc)I/O Primitives.
  1820. * pwritev2: (libc)Scatter-Gather.
  1821. * pwritev64: (libc)Scatter-Gather.
  1822. * pwritev64v2: (libc)Scatter-Gather.
  1823. * pwritev: (libc)Scatter-Gather.
  1824. * qecvt: (libc)System V Number Conversion.
  1825. * qecvt_r: (libc)System V Number Conversion.
  1826. * qfcvt: (libc)System V Number Conversion.
  1827. * qfcvt_r: (libc)System V Number Conversion.
  1828. * qgcvt: (libc)System V Number Conversion.
  1829. * qsort: (libc)Array Sort Function.
  1830. * raise: (libc)Signaling Yourself.
  1831. * rand: (libc)ISO Random.
  1832. * rand_r: (libc)ISO Random.
  1833. * random: (libc)BSD Random.
  1834. * random_r: (libc)BSD Random.
  1835. * rawmemchr: (libc)Search Functions.
  1836. * read: (libc)I/O Primitives.
  1837. * readdir64: (libc)Reading/Closing Directory.
  1838. * readdir64_r: (libc)Reading/Closing Directory.
  1839. * readdir: (libc)Reading/Closing Directory.
  1840. * readdir_r: (libc)Reading/Closing Directory.
  1841. * readlink: (libc)Symbolic Links.
  1842. * readv: (libc)Scatter-Gather.
  1843. * realloc: (libc)Changing Block Size.
  1844. * reallocarray: (libc)Changing Block Size.
  1845. * realpath: (libc)Symbolic Links.
  1846. * recv: (libc)Receiving Data.
  1847. * recvfrom: (libc)Receiving Datagrams.
  1848. * recvmsg: (libc)Other Socket APIs.
  1849. * regcomp: (libc)POSIX Regexp Compilation.
  1850. * regerror: (libc)Regexp Cleanup.
  1851. * regexec: (libc)Matching POSIX Regexps.
  1852. * regfree: (libc)Regexp Cleanup.
  1853. * register_printf_function: (libc)Registering New Conversions.
  1854. * remainder: (libc)Remainder Functions.
  1855. * remainderf: (libc)Remainder Functions.
  1856. * remainderfN: (libc)Remainder Functions.
  1857. * remainderfNx: (libc)Remainder Functions.
  1858. * remainderl: (libc)Remainder Functions.
  1859. * remove: (libc)Deleting Files.
  1860. * rename: (libc)Renaming Files.
  1861. * renameat: (libc)Renaming Files.
  1862. * rewind: (libc)File Positioning.
  1863. * rewinddir: (libc)Random Access Directory.
  1864. * rindex: (libc)Search Functions.
  1865. * rint: (libc)Rounding Functions.
  1866. * rintf: (libc)Rounding Functions.
  1867. * rintfN: (libc)Rounding Functions.
  1868. * rintfNx: (libc)Rounding Functions.
  1869. * rintl: (libc)Rounding Functions.
  1870. * rmdir: (libc)Deleting Files.
  1871. * rootn: (libc)Exponents and Logarithms.
  1872. * rootnf: (libc)Exponents and Logarithms.
  1873. * rootnfN: (libc)Exponents and Logarithms.
  1874. * rootnfNx: (libc)Exponents and Logarithms.
  1875. * rootnl: (libc)Exponents and Logarithms.
  1876. * round: (libc)Rounding Functions.
  1877. * roundeven: (libc)Rounding Functions.
  1878. * roundevenf: (libc)Rounding Functions.
  1879. * roundevenfN: (libc)Rounding Functions.
  1880. * roundevenfNx: (libc)Rounding Functions.
  1881. * roundevenl: (libc)Rounding Functions.
  1882. * roundf: (libc)Rounding Functions.
  1883. * roundfN: (libc)Rounding Functions.
  1884. * roundfNx: (libc)Rounding Functions.
  1885. * roundl: (libc)Rounding Functions.
  1886. * rpmatch: (libc)Yes-or-No Questions.
  1887. * rsqrt: (libc)Exponents and Logarithms.
  1888. * rsqrtf: (libc)Exponents and Logarithms.
  1889. * rsqrtfN: (libc)Exponents and Logarithms.
  1890. * rsqrtfNx: (libc)Exponents and Logarithms.
  1891. * rsqrtl: (libc)Exponents and Logarithms.
  1892. * sbrk: (libc)Resizing the Data Segment.
  1893. * scalb: (libc)Normalization Functions.
  1894. * scalbf: (libc)Normalization Functions.
  1895. * scalbl: (libc)Normalization Functions.
  1896. * scalbln: (libc)Normalization Functions.
  1897. * scalblnf: (libc)Normalization Functions.
  1898. * scalblnfN: (libc)Normalization Functions.
  1899. * scalblnfNx: (libc)Normalization Functions.
  1900. * scalblnl: (libc)Normalization Functions.
  1901. * scalbn: (libc)Normalization Functions.
  1902. * scalbnf: (libc)Normalization Functions.
  1903. * scalbnfN: (libc)Normalization Functions.
  1904. * scalbnfNx: (libc)Normalization Functions.
  1905. * scalbnl: (libc)Normalization Functions.
  1906. * scandir64: (libc)Scanning Directory Content.
  1907. * scandir: (libc)Scanning Directory Content.
  1908. * scanf: (libc)Formatted Input Functions.
  1909. * sched_get_priority_max: (libc)Basic Scheduling Functions.
  1910. * sched_get_priority_min: (libc)Basic Scheduling Functions.
  1911. * sched_getaffinity: (libc)CPU Affinity.
  1912. * sched_getattr: (libc)Extensible Scheduling.
  1913. * sched_getcpu: (libc)CPU Affinity.
  1914. * sched_getparam: (libc)Basic Scheduling Functions.
  1915. * sched_getscheduler: (libc)Basic Scheduling Functions.
  1916. * sched_rr_get_interval: (libc)Basic Scheduling Functions.
  1917. * sched_setaffinity: (libc)CPU Affinity.
  1918. * sched_setattr: (libc)Extensible Scheduling.
  1919. * sched_setparam: (libc)Basic Scheduling Functions.
  1920. * sched_setscheduler: (libc)Basic Scheduling Functions.
  1921. * sched_yield: (libc)Basic Scheduling Functions.
  1922. * secure_getenv: (libc)Environment Access.
  1923. * seed48: (libc)SVID Random.
  1924. * seed48_r: (libc)SVID Random.
  1925. * seekdir: (libc)Random Access Directory.
  1926. * select: (libc)Waiting for I/O.
  1927. * sem_clockwait: (libc)POSIX Semaphores.
  1928. * sem_close: (libc)POSIX Semaphores.
  1929. * sem_destroy: (libc)POSIX Semaphores.
  1930. * sem_getvalue: (libc)POSIX Semaphores.
  1931. * sem_init: (libc)POSIX Semaphores.
  1932. * sem_open: (libc)POSIX Semaphores.
  1933. * sem_post: (libc)POSIX Semaphores.
  1934. * sem_timedwait: (libc)POSIX Semaphores.
  1935. * sem_trywait: (libc)POSIX Semaphores.
  1936. * sem_unlink: (libc)POSIX Semaphores.
  1937. * sem_wait: (libc)POSIX Semaphores.
  1938. * semctl: (libc)Semaphores.
  1939. * semget: (libc)Semaphores.
  1940. * semop: (libc)Semaphores.
  1941. * semtimedop: (libc)Semaphores.
  1942. * send: (libc)Sending Data.
  1943. * sendmsg: (libc)Other Socket APIs.
  1944. * sendto: (libc)Sending Datagrams.
  1945. * setbuf: (libc)Controlling Buffering.
  1946. * setbuffer: (libc)Controlling Buffering.
  1947. * setcontext: (libc)System V contexts.
  1948. * setdomainname: (libc)Host Identification.
  1949. * setegid: (libc)Setting Groups.
  1950. * setenv: (libc)Environment Access.
  1951. * seteuid: (libc)Setting User ID.
  1952. * setfsent: (libc)fstab.
  1953. * setgid: (libc)Setting Groups.
  1954. * setgrent: (libc)Scanning All Groups.
  1955. * setgroups: (libc)Setting Groups.
  1956. * sethostent: (libc)Host Names.
  1957. * sethostid: (libc)Host Identification.
  1958. * sethostname: (libc)Host Identification.
  1959. * setitimer: (libc)Setting an Alarm.
  1960. * setjmp: (libc)Non-Local Details.
  1961. * setlinebuf: (libc)Controlling Buffering.
  1962. * setlocale: (libc)Setting the Locale.
  1963. * setlogmask: (libc)setlogmask.
  1964. * setmntent: (libc)mtab.
  1965. * setnetent: (libc)Networks Database.
  1966. * setnetgrent: (libc)Lookup Netgroup.
  1967. * setpayload: (libc)FP Bit Twiddling.
  1968. * setpayloadf: (libc)FP Bit Twiddling.
  1969. * setpayloadfN: (libc)FP Bit Twiddling.
  1970. * setpayloadfNx: (libc)FP Bit Twiddling.
  1971. * setpayloadl: (libc)FP Bit Twiddling.
  1972. * setpayloadsig: (libc)FP Bit Twiddling.
  1973. * setpayloadsigf: (libc)FP Bit Twiddling.
  1974. * setpayloadsigfN: (libc)FP Bit Twiddling.
  1975. * setpayloadsigfNx: (libc)FP Bit Twiddling.
  1976. * setpayloadsigl: (libc)FP Bit Twiddling.
  1977. * setpgid: (libc)Process Group Functions.
  1978. * setpgrp: (libc)Process Group Functions.
  1979. * setpriority: (libc)Traditional Scheduling Functions.
  1980. * setprotoent: (libc)Protocols Database.
  1981. * setpwent: (libc)Scanning All Users.
  1982. * setregid: (libc)Setting Groups.
  1983. * setreuid: (libc)Setting User ID.
  1984. * setrlimit64: (libc)Limits on Resources.
  1985. * setrlimit: (libc)Limits on Resources.
  1986. * setservent: (libc)Services Database.
  1987. * setsid: (libc)Process Group Functions.
  1988. * setsockopt: (libc)Socket Option Functions.
  1989. * setstate: (libc)BSD Random.
  1990. * setstate_r: (libc)BSD Random.
  1991. * settimeofday: (libc)Setting and Adjusting the Time.
  1992. * setuid: (libc)Setting User ID.
  1993. * setutent: (libc)Manipulating the Database.
  1994. * setutxent: (libc)XPG Functions.
  1995. * setvbuf: (libc)Controlling Buffering.
  1996. * shm_open: (libc)Memory-mapped I/O.
  1997. * shm_unlink: (libc)Memory-mapped I/O.
  1998. * shutdown: (libc)Closing a Socket.
  1999. * sigabbrev_np: (libc)Signal Messages.
  2000. * sigaction: (libc)Advanced Signal Handling.
  2001. * sigaddset: (libc)Signal Sets.
  2002. * sigaltstack: (libc)Signal Stack.
  2003. * sigblock: (libc)BSD Signal Handling.
  2004. * sigdelset: (libc)Signal Sets.
  2005. * sigdescr_np: (libc)Signal Messages.
  2006. * sigemptyset: (libc)Signal Sets.
  2007. * sigfillset: (libc)Signal Sets.
  2008. * siginterrupt: (libc)BSD Signal Handling.
  2009. * sigismember: (libc)Signal Sets.
  2010. * siglongjmp: (libc)Non-Local Exits and Signals.
  2011. * sigmask: (libc)BSD Signal Handling.
  2012. * signal: (libc)Basic Signal Handling.
  2013. * signbit: (libc)FP Bit Twiddling.
  2014. * significand: (libc)Normalization Functions.
  2015. * significandf: (libc)Normalization Functions.
  2016. * significandl: (libc)Normalization Functions.
  2017. * sigpause: (libc)BSD Signal Handling.
  2018. * sigpending: (libc)Checking for Pending Signals.
  2019. * sigprocmask: (libc)Process Signal Mask.
  2020. * sigsetjmp: (libc)Non-Local Exits and Signals.
  2021. * sigsetmask: (libc)BSD Signal Handling.
  2022. * sigstack: (libc)Signal Stack.
  2023. * sigsuspend: (libc)Sigsuspend.
  2024. * sin: (libc)Trig Functions.
  2025. * sincos: (libc)Trig Functions.
  2026. * sincosf: (libc)Trig Functions.
  2027. * sincosfN: (libc)Trig Functions.
  2028. * sincosfNx: (libc)Trig Functions.
  2029. * sincosl: (libc)Trig Functions.
  2030. * sinf: (libc)Trig Functions.
  2031. * sinfN: (libc)Trig Functions.
  2032. * sinfNx: (libc)Trig Functions.
  2033. * sinh: (libc)Hyperbolic Functions.
  2034. * sinhf: (libc)Hyperbolic Functions.
  2035. * sinhfN: (libc)Hyperbolic Functions.
  2036. * sinhfNx: (libc)Hyperbolic Functions.
  2037. * sinhl: (libc)Hyperbolic Functions.
  2038. * sinl: (libc)Trig Functions.
  2039. * sinpi: (libc)Trig Functions.
  2040. * sinpif: (libc)Trig Functions.
  2041. * sinpifN: (libc)Trig Functions.
  2042. * sinpifNx: (libc)Trig Functions.
  2043. * sinpil: (libc)Trig Functions.
  2044. * sleep: (libc)Sleeping.
  2045. * snprintf: (libc)Formatted Output Functions.
  2046. * socket: (libc)Creating a Socket.
  2047. * socketpair: (libc)Socket Pairs.
  2048. * sprintf: (libc)Formatted Output Functions.
  2049. * sqrt: (libc)Exponents and Logarithms.
  2050. * sqrtf: (libc)Exponents and Logarithms.
  2051. * sqrtfN: (libc)Exponents and Logarithms.
  2052. * sqrtfNx: (libc)Exponents and Logarithms.
  2053. * sqrtl: (libc)Exponents and Logarithms.
  2054. * srand48: (libc)SVID Random.
  2055. * srand48_r: (libc)SVID Random.
  2056. * srand: (libc)ISO Random.
  2057. * srandom: (libc)BSD Random.
  2058. * srandom_r: (libc)BSD Random.
  2059. * sscanf: (libc)Formatted Input Functions.
  2060. * ssignal: (libc)Basic Signal Handling.
  2061. * stat64: (libc)Reading Attributes.
  2062. * stat: (libc)Reading Attributes.
  2063. * stdc_bit_ceil_uc: (libc)Bit Manipulation.
  2064. * stdc_bit_ceil_ui: (libc)Bit Manipulation.
  2065. * stdc_bit_ceil_ul: (libc)Bit Manipulation.
  2066. * stdc_bit_ceil_ull: (libc)Bit Manipulation.
  2067. * stdc_bit_ceil_us: (libc)Bit Manipulation.
  2068. * stdc_bit_floor_uc: (libc)Bit Manipulation.
  2069. * stdc_bit_floor_ui: (libc)Bit Manipulation.
  2070. * stdc_bit_floor_ul: (libc)Bit Manipulation.
  2071. * stdc_bit_floor_ull: (libc)Bit Manipulation.
  2072. * stdc_bit_floor_us: (libc)Bit Manipulation.
  2073. * stdc_bit_width_uc: (libc)Bit Manipulation.
  2074. * stdc_bit_width_ui: (libc)Bit Manipulation.
  2075. * stdc_bit_width_ul: (libc)Bit Manipulation.
  2076. * stdc_bit_width_ull: (libc)Bit Manipulation.
  2077. * stdc_bit_width_us: (libc)Bit Manipulation.
  2078. * stdc_count_ones_uc: (libc)Bit Manipulation.
  2079. * stdc_count_ones_ui: (libc)Bit Manipulation.
  2080. * stdc_count_ones_ul: (libc)Bit Manipulation.
  2081. * stdc_count_ones_ull: (libc)Bit Manipulation.
  2082. * stdc_count_ones_us: (libc)Bit Manipulation.
  2083. * stdc_count_zeros_uc: (libc)Bit Manipulation.
  2084. * stdc_count_zeros_ui: (libc)Bit Manipulation.
  2085. * stdc_count_zeros_ul: (libc)Bit Manipulation.
  2086. * stdc_count_zeros_ull: (libc)Bit Manipulation.
  2087. * stdc_count_zeros_us: (libc)Bit Manipulation.
  2088. * stdc_first_leading_one_uc: (libc)Bit Manipulation.
  2089. * stdc_first_leading_one_ui: (libc)Bit Manipulation.
  2090. * stdc_first_leading_one_ul: (libc)Bit Manipulation.
  2091. * stdc_first_leading_one_ull: (libc)Bit Manipulation.
  2092. * stdc_first_leading_one_us: (libc)Bit Manipulation.
  2093. * stdc_first_leading_zero_uc: (libc)Bit Manipulation.
  2094. * stdc_first_leading_zero_ui: (libc)Bit Manipulation.
  2095. * stdc_first_leading_zero_ul: (libc)Bit Manipulation.
  2096. * stdc_first_leading_zero_ull: (libc)Bit Manipulation.
  2097. * stdc_first_leading_zero_us: (libc)Bit Manipulation.
  2098. * stdc_first_trailing_one_uc: (libc)Bit Manipulation.
  2099. * stdc_first_trailing_one_ui: (libc)Bit Manipulation.
  2100. * stdc_first_trailing_one_ul: (libc)Bit Manipulation.
  2101. * stdc_first_trailing_one_ull: (libc)Bit Manipulation.
  2102. * stdc_first_trailing_one_us: (libc)Bit Manipulation.
  2103. * stdc_first_trailing_zero_uc: (libc)Bit Manipulation.
  2104. * stdc_first_trailing_zero_ui: (libc)Bit Manipulation.
  2105. * stdc_first_trailing_zero_ul: (libc)Bit Manipulation.
  2106. * stdc_first_trailing_zero_ull: (libc)Bit Manipulation.
  2107. * stdc_first_trailing_zero_us: (libc)Bit Manipulation.
  2108. * stdc_has_single_bit_uc: (libc)Bit Manipulation.
  2109. * stdc_has_single_bit_ui: (libc)Bit Manipulation.
  2110. * stdc_has_single_bit_ul: (libc)Bit Manipulation.
  2111. * stdc_has_single_bit_ull: (libc)Bit Manipulation.
  2112. * stdc_has_single_bit_us: (libc)Bit Manipulation.
  2113. * stdc_leading_ones_uc: (libc)Bit Manipulation.
  2114. * stdc_leading_ones_ui: (libc)Bit Manipulation.
  2115. * stdc_leading_ones_ul: (libc)Bit Manipulation.
  2116. * stdc_leading_ones_ull: (libc)Bit Manipulation.
  2117. * stdc_leading_ones_us: (libc)Bit Manipulation.
  2118. * stdc_leading_zeros_uc: (libc)Bit Manipulation.
  2119. * stdc_leading_zeros_ui: (libc)Bit Manipulation.
  2120. * stdc_leading_zeros_ul: (libc)Bit Manipulation.
  2121. * stdc_leading_zeros_ull: (libc)Bit Manipulation.
  2122. * stdc_leading_zeros_us: (libc)Bit Manipulation.
  2123. * stdc_trailing_ones_uc: (libc)Bit Manipulation.
  2124. * stdc_trailing_ones_ui: (libc)Bit Manipulation.
  2125. * stdc_trailing_ones_ul: (libc)Bit Manipulation.
  2126. * stdc_trailing_ones_ull: (libc)Bit Manipulation.
  2127. * stdc_trailing_ones_us: (libc)Bit Manipulation.
  2128. * stdc_trailing_zeros_uc: (libc)Bit Manipulation.
  2129. * stdc_trailing_zeros_ui: (libc)Bit Manipulation.
  2130. * stdc_trailing_zeros_ul: (libc)Bit Manipulation.
  2131. * stdc_trailing_zeros_ull: (libc)Bit Manipulation.
  2132. * stdc_trailing_zeros_us: (libc)Bit Manipulation.
  2133. * stime: (libc)Setting and Adjusting the Time.
  2134. * stpcpy: (libc)Copying Strings and Arrays.
  2135. * stpncpy: (libc)Truncating Strings.
  2136. * strcasecmp: (libc)String/Array Comparison.
  2137. * strcasestr: (libc)Search Functions.
  2138. * strcat: (libc)Concatenating Strings.
  2139. * strchr: (libc)Search Functions.
  2140. * strchrnul: (libc)Search Functions.
  2141. * strcmp: (libc)String/Array Comparison.
  2142. * strcoll: (libc)Collation Functions.
  2143. * strcpy: (libc)Copying Strings and Arrays.
  2144. * strcspn: (libc)Search Functions.
  2145. * strdup: (libc)Copying Strings and Arrays.
  2146. * strdupa: (libc)Copying Strings and Arrays.
  2147. * strerror: (libc)Error Messages.
  2148. * strerror_l: (libc)Error Messages.
  2149. * strerror_r: (libc)Error Messages.
  2150. * strerror_r: (libc)Error Messages.
  2151. * strerrordesc_np: (libc)Error Messages.
  2152. * strerrorname_np: (libc)Error Messages.
  2153. * strfmon: (libc)Formatting Numbers.
  2154. * strfromd: (libc)Printing of Floats.
  2155. * strfromf: (libc)Printing of Floats.
  2156. * strfromfN: (libc)Printing of Floats.
  2157. * strfromfNx: (libc)Printing of Floats.
  2158. * strfroml: (libc)Printing of Floats.
  2159. * strfry: (libc)Shuffling Bytes.
  2160. * strftime: (libc)Formatting Calendar Time.
  2161. * strftime_l: (libc)Formatting Calendar Time.
  2162. * strlcat: (libc)Truncating Strings.
  2163. * strlcpy: (libc)Truncating Strings.
  2164. * strlen: (libc)String Length.
  2165. * strncasecmp: (libc)String/Array Comparison.
  2166. * strncat: (libc)Truncating Strings.
  2167. * strncmp: (libc)String/Array Comparison.
  2168. * strncpy: (libc)Truncating Strings.
  2169. * strndup: (libc)Truncating Strings.
  2170. * strndupa: (libc)Truncating Strings.
  2171. * strnlen: (libc)String Length.
  2172. * strpbrk: (libc)Search Functions.
  2173. * strptime: (libc)Low-Level Time String Parsing.
  2174. * strrchr: (libc)Search Functions.
  2175. * strsep: (libc)Finding Tokens in a String.
  2176. * strsignal: (libc)Signal Messages.
  2177. * strspn: (libc)Search Functions.
  2178. * strstr: (libc)Search Functions.
  2179. * strtod: (libc)Parsing of Floats.
  2180. * strtof: (libc)Parsing of Floats.
  2181. * strtofN: (libc)Parsing of Floats.
  2182. * strtofNx: (libc)Parsing of Floats.
  2183. * strtoimax: (libc)Parsing of Integers.
  2184. * strtok: (libc)Finding Tokens in a String.
  2185. * strtok_r: (libc)Finding Tokens in a String.
  2186. * strtol: (libc)Parsing of Integers.
  2187. * strtold: (libc)Parsing of Floats.
  2188. * strtoll: (libc)Parsing of Integers.
  2189. * strtoq: (libc)Parsing of Integers.
  2190. * strtoul: (libc)Parsing of Integers.
  2191. * strtoull: (libc)Parsing of Integers.
  2192. * strtoumax: (libc)Parsing of Integers.
  2193. * strtouq: (libc)Parsing of Integers.
  2194. * strverscmp: (libc)String/Array Comparison.
  2195. * strxfrm: (libc)Collation Functions.
  2196. * stty: (libc)BSD Terminal Modes.
  2197. * swapcontext: (libc)System V contexts.
  2198. * swprintf: (libc)Formatted Output Functions.
  2199. * swscanf: (libc)Formatted Input Functions.
  2200. * symlink: (libc)Symbolic Links.
  2201. * sync: (libc)Synchronizing I/O.
  2202. * syscall: (libc)System Calls.
  2203. * sysconf: (libc)Sysconf Definition.
  2204. * syslog: (libc)syslog; vsyslog.
  2205. * system: (libc)Running a Command.
  2206. * sysv_signal: (libc)Basic Signal Handling.
  2207. * tan: (libc)Trig Functions.
  2208. * tanf: (libc)Trig Functions.
  2209. * tanfN: (libc)Trig Functions.
  2210. * tanfNx: (libc)Trig Functions.
  2211. * tanh: (libc)Hyperbolic Functions.
  2212. * tanhf: (libc)Hyperbolic Functions.
  2213. * tanhfN: (libc)Hyperbolic Functions.
  2214. * tanhfNx: (libc)Hyperbolic Functions.
  2215. * tanhl: (libc)Hyperbolic Functions.
  2216. * tanl: (libc)Trig Functions.
  2217. * tanpi: (libc)Trig Functions.
  2218. * tanpif: (libc)Trig Functions.
  2219. * tanpifN: (libc)Trig Functions.
  2220. * tanpifNx: (libc)Trig Functions.
  2221. * tanpil: (libc)Trig Functions.
  2222. * tcdrain: (libc)Line Control.
  2223. * tcflow: (libc)Line Control.
  2224. * tcflush: (libc)Line Control.
  2225. * tcgetattr: (libc)Mode Functions.
  2226. * tcgetpgrp: (libc)Terminal Access Functions.
  2227. * tcgetsid: (libc)Terminal Access Functions.
  2228. * tcsendbreak: (libc)Line Control.
  2229. * tcsetattr: (libc)Mode Functions.
  2230. * tcsetpgrp: (libc)Terminal Access Functions.
  2231. * tdelete: (libc)Tree Search Function.
  2232. * tdestroy: (libc)Tree Search Function.
  2233. * telldir: (libc)Random Access Directory.
  2234. * tempnam: (libc)Temporary Files.
  2235. * textdomain: (libc)Locating gettext catalog.
  2236. * tfind: (libc)Tree Search Function.
  2237. * tgamma: (libc)Special Functions.
  2238. * tgammaf: (libc)Special Functions.
  2239. * tgammafN: (libc)Special Functions.
  2240. * tgammafNx: (libc)Special Functions.
  2241. * tgammal: (libc)Special Functions.
  2242. * tgkill: (libc)Signaling Another Process.
  2243. * thrd_create: (libc)ISO C Thread Management.
  2244. * thrd_current: (libc)ISO C Thread Management.
  2245. * thrd_detach: (libc)ISO C Thread Management.
  2246. * thrd_equal: (libc)ISO C Thread Management.
  2247. * thrd_exit: (libc)ISO C Thread Management.
  2248. * thrd_join: (libc)ISO C Thread Management.
  2249. * thrd_sleep: (libc)ISO C Thread Management.
  2250. * thrd_yield: (libc)ISO C Thread Management.
  2251. * time: (libc)Getting the Time.
  2252. * timegm: (libc)Broken-down Time.
  2253. * timelocal: (libc)Broken-down Time.
  2254. * times: (libc)Processor Time.
  2255. * timespec_get: (libc)Getting the Time.
  2256. * timespec_getres: (libc)Getting the Time.
  2257. * tmpfile64: (libc)Temporary Files.
  2258. * tmpfile: (libc)Temporary Files.
  2259. * tmpnam: (libc)Temporary Files.
  2260. * tmpnam_r: (libc)Temporary Files.
  2261. * toascii: (libc)Case Conversion.
  2262. * tolower: (libc)Case Conversion.
  2263. * totalorder: (libc)FP Comparison Functions.
  2264. * totalorderf: (libc)FP Comparison Functions.
  2265. * totalorderfN: (libc)FP Comparison Functions.
  2266. * totalorderfNx: (libc)FP Comparison Functions.
  2267. * totalorderl: (libc)FP Comparison Functions.
  2268. * totalordermag: (libc)FP Comparison Functions.
  2269. * totalordermagf: (libc)FP Comparison Functions.
  2270. * totalordermagfN: (libc)FP Comparison Functions.
  2271. * totalordermagfNx: (libc)FP Comparison Functions.
  2272. * totalordermagl: (libc)FP Comparison Functions.
  2273. * toupper: (libc)Case Conversion.
  2274. * towctrans: (libc)Wide Character Case Conversion.
  2275. * towlower: (libc)Wide Character Case Conversion.
  2276. * towupper: (libc)Wide Character Case Conversion.
  2277. * trunc: (libc)Rounding Functions.
  2278. * truncate64: (libc)File Size.
  2279. * truncate: (libc)File Size.
  2280. * truncf: (libc)Rounding Functions.
  2281. * truncfN: (libc)Rounding Functions.
  2282. * truncfNx: (libc)Rounding Functions.
  2283. * truncl: (libc)Rounding Functions.
  2284. * tsearch: (libc)Tree Search Function.
  2285. * tss_create: (libc)ISO C Thread-local Storage.
  2286. * tss_delete: (libc)ISO C Thread-local Storage.
  2287. * tss_get: (libc)ISO C Thread-local Storage.
  2288. * tss_set: (libc)ISO C Thread-local Storage.
  2289. * ttyname: (libc)Is It a Terminal.
  2290. * ttyname_r: (libc)Is It a Terminal.
  2291. * twalk: (libc)Tree Search Function.
  2292. * twalk_r: (libc)Tree Search Function.
  2293. * tzset: (libc)Time Zone State.
  2294. * uabs: (libc)Absolute Value.
  2295. * ufromfp: (libc)Rounding Functions.
  2296. * ufromfpf: (libc)Rounding Functions.
  2297. * ufromfpfN: (libc)Rounding Functions.
  2298. * ufromfpfNx: (libc)Rounding Functions.
  2299. * ufromfpl: (libc)Rounding Functions.
  2300. * ufromfpx: (libc)Rounding Functions.
  2301. * ufromfpxf: (libc)Rounding Functions.
  2302. * ufromfpxfN: (libc)Rounding Functions.
  2303. * ufromfpxfNx: (libc)Rounding Functions.
  2304. * ufromfpxl: (libc)Rounding Functions.
  2305. * ulabs: (libc)Absolute Value.
  2306. * ulimit: (libc)Limits on Resources.
  2307. * ullabs: (libc)Absolute Value.
  2308. * umask: (libc)Setting Permissions.
  2309. * umaxabs: (libc)Absolute Value.
  2310. * umount2: (libc)Mount-Unmount-Remount.
  2311. * umount: (libc)Mount-Unmount-Remount.
  2312. * uname: (libc)Platform Type.
  2313. * ungetc: (libc)How Unread.
  2314. * ungetwc: (libc)How Unread.
  2315. * unlink: (libc)Deleting Files.
  2316. * unlinkat: (libc)Deleting Files.
  2317. * unlockpt: (libc)Allocation.
  2318. * unsetenv: (libc)Environment Access.
  2319. * updwtmp: (libc)Manipulating the Database.
  2320. * utime: (libc)File Times.
  2321. * utimensat: (libc)File Times.
  2322. * utimes: (libc)File Times.
  2323. * utmpname: (libc)Manipulating the Database.
  2324. * utmpxname: (libc)XPG Functions.
  2325. * va_arg: (libc)Argument Macros.
  2326. * va_copy: (libc)Argument Macros.
  2327. * va_end: (libc)Argument Macros.
  2328. * va_start: (libc)Argument Macros.
  2329. * valloc: (libc)Aligned Memory Blocks.
  2330. * vasprintf: (libc)Variable Arguments Output.
  2331. * vdprintf: (libc)Variable Arguments Output.
  2332. * verr: (libc)Error Messages.
  2333. * verrx: (libc)Error Messages.
  2334. * versionsort64: (libc)Scanning Directory Content.
  2335. * versionsort: (libc)Scanning Directory Content.
  2336. * vfork: (libc)Creating a Process.
  2337. * vfprintf: (libc)Variable Arguments Output.
  2338. * vfscanf: (libc)Variable Arguments Input.
  2339. * vfwprintf: (libc)Variable Arguments Output.
  2340. * vfwscanf: (libc)Variable Arguments Input.
  2341. * vlimit: (libc)Limits on Resources.
  2342. * vprintf: (libc)Variable Arguments Output.
  2343. * vscanf: (libc)Variable Arguments Input.
  2344. * vsnprintf: (libc)Variable Arguments Output.
  2345. * vsprintf: (libc)Variable Arguments Output.
  2346. * vsscanf: (libc)Variable Arguments Input.
  2347. * vswprintf: (libc)Variable Arguments Output.
  2348. * vswscanf: (libc)Variable Arguments Input.
  2349. * vsyslog: (libc)syslog; vsyslog.
  2350. * vwarn: (libc)Error Messages.
  2351. * vwarnx: (libc)Error Messages.
  2352. * vwprintf: (libc)Variable Arguments Output.
  2353. * vwscanf: (libc)Variable Arguments Input.
  2354. * wait3: (libc)BSD Wait Functions.
  2355. * wait4: (libc)Process Completion.
  2356. * wait: (libc)Process Completion.
  2357. * waitpid: (libc)Process Completion.
  2358. * warn: (libc)Error Messages.
  2359. * warnx: (libc)Error Messages.
  2360. * wcpcpy: (libc)Copying Strings and Arrays.
  2361. * wcpncpy: (libc)Truncating Strings.
  2362. * wcrtomb: (libc)Converting a Character.
  2363. * wcscasecmp: (libc)String/Array Comparison.
  2364. * wcscat: (libc)Concatenating Strings.
  2365. * wcschr: (libc)Search Functions.
  2366. * wcschrnul: (libc)Search Functions.
  2367. * wcscmp: (libc)String/Array Comparison.
  2368. * wcscoll: (libc)Collation Functions.
  2369. * wcscpy: (libc)Copying Strings and Arrays.
  2370. * wcscspn: (libc)Search Functions.
  2371. * wcsdup: (libc)Copying Strings and Arrays.
  2372. * wcsftime: (libc)Formatting Calendar Time.
  2373. * wcslcat: (libc)Truncating Strings.
  2374. * wcslcpy: (libc)Truncating Strings.
  2375. * wcslen: (libc)String Length.
  2376. * wcsncasecmp: (libc)String/Array Comparison.
  2377. * wcsncat: (libc)Truncating Strings.
  2378. * wcsncmp: (libc)String/Array Comparison.
  2379. * wcsncpy: (libc)Truncating Strings.
  2380. * wcsnlen: (libc)String Length.
  2381. * wcsnrtombs: (libc)Converting Strings.
  2382. * wcspbrk: (libc)Search Functions.
  2383. * wcsrchr: (libc)Search Functions.
  2384. * wcsrtombs: (libc)Converting Strings.
  2385. * wcsspn: (libc)Search Functions.
  2386. * wcsstr: (libc)Search Functions.
  2387. * wcstod: (libc)Parsing of Floats.
  2388. * wcstof: (libc)Parsing of Floats.
  2389. * wcstofN: (libc)Parsing of Floats.
  2390. * wcstofNx: (libc)Parsing of Floats.
  2391. * wcstoimax: (libc)Parsing of Integers.
  2392. * wcstok: (libc)Finding Tokens in a String.
  2393. * wcstol: (libc)Parsing of Integers.
  2394. * wcstold: (libc)Parsing of Floats.
  2395. * wcstoll: (libc)Parsing of Integers.
  2396. * wcstombs: (libc)Non-reentrant String Conversion.
  2397. * wcstoq: (libc)Parsing of Integers.
  2398. * wcstoul: (libc)Parsing of Integers.
  2399. * wcstoull: (libc)Parsing of Integers.
  2400. * wcstoumax: (libc)Parsing of Integers.
  2401. * wcstouq: (libc)Parsing of Integers.
  2402. * wcswcs: (libc)Search Functions.
  2403. * wcsxfrm: (libc)Collation Functions.
  2404. * wctob: (libc)Converting a Character.
  2405. * wctomb: (libc)Non-reentrant Character Conversion.
  2406. * wctrans: (libc)Wide Character Case Conversion.
  2407. * wctype: (libc)Classification of Wide Characters.
  2408. * wmemchr: (libc)Search Functions.
  2409. * wmemcmp: (libc)String/Array Comparison.
  2410. * wmemcpy: (libc)Copying Strings and Arrays.
  2411. * wmemmove: (libc)Copying Strings and Arrays.
  2412. * wmempcpy: (libc)Copying Strings and Arrays.
  2413. * wmemset: (libc)Copying Strings and Arrays.
  2414. * wordexp: (libc)Calling Wordexp.
  2415. * wordfree: (libc)Calling Wordexp.
  2416. * wprintf: (libc)Formatted Output Functions.
  2417. * write: (libc)I/O Primitives.
  2418. * writev: (libc)Scatter-Gather.
  2419. * wscanf: (libc)Formatted Input Functions.
  2420. * y0: (libc)Special Functions.
  2421. * y0f: (libc)Special Functions.
  2422. * y0fN: (libc)Special Functions.
  2423. * y0fNx: (libc)Special Functions.
  2424. * y0l: (libc)Special Functions.
  2425. * y1: (libc)Special Functions.
  2426. * y1f: (libc)Special Functions.
  2427. * y1fN: (libc)Special Functions.
  2428. * y1fNx: (libc)Special Functions.
  2429. * y1l: (libc)Special Functions.
  2430. * yn: (libc)Special Functions.
  2431. * ynf: (libc)Special Functions.
  2432. * ynfN: (libc)Special Functions.
  2433. * ynfNx: (libc)Special Functions.
  2434. * ynl: (libc)Special Functions.
  2435. END-INFO-DIR-ENTRY
  2436. 
  2437. File: libc.info, Node: Unconstrained Allocation, Next: Allocation Debugging, Prev: The GNU Allocator, Up: Memory Allocation
  2438. 3.2.3 Unconstrained Allocation
  2439. ------------------------------
  2440. The most general dynamic allocation facility is ‘malloc’. It allows you
  2441. to allocate blocks of memory of any size at any time, make them bigger
  2442. or smaller at any time, and free the blocks individually at any time (or
  2443. never).
  2444. * Menu:
  2445. * Basic Allocation:: Simple use of ‘malloc’.
  2446. * Malloc Examples:: Examples of ‘malloc’. ‘xmalloc’.
  2447. * Freeing after Malloc:: Use ‘free’ to free a block you
  2448. got with ‘malloc’.
  2449. * Changing Block Size:: Use ‘realloc’ to make a block
  2450. bigger or smaller.
  2451. * Allocating Cleared Space:: Use ‘calloc’ to allocate a
  2452. block and clear it.
  2453. * Aligned Memory Blocks:: Allocating specially aligned memory.
  2454. * Malloc Tunable Parameters:: Use ‘mallopt’ to adjust allocation
  2455. parameters.
  2456. * Heap Consistency Checking:: Automatic checking for errors.
  2457. * Statistics of Malloc:: Getting information about how much
  2458. memory your program is using.
  2459. * Summary of Malloc:: Summary of ‘malloc’ and related functions.
  2460. 
  2461. File: libc.info, Node: Basic Allocation, Next: Malloc Examples, Up: Unconstrained Allocation
  2462. 3.2.3.1 Basic Memory Allocation
  2463. ...............................
  2464. To allocate a block of memory, call ‘malloc’. The prototype for this
  2465. function is in ‘stdlib.h’.
  2466. -- Function: void * malloc (size_t SIZE)
  2467. Preliminary: | MT-Safe | AS-Unsafe lock | AC-Unsafe lock fd mem |
  2468. *Note POSIX Safety Concepts::.
  2469. This function returns a pointer to a newly allocated block SIZE
  2470. bytes long, or a null pointer (setting ‘errno’) if the block could
  2471. not be allocated.
  2472. The contents of the block are undefined; you must initialize it
  2473. yourself (or use ‘calloc’ instead; *note Allocating Cleared Space::).
  2474. Normally you would convert the value to a pointer to the kind of object
  2475. that you want to store in the block. Here we show an example of doing
  2476. so, and of initializing the space with zeros using the library function
  2477. ‘memset’ (*note Copying Strings and Arrays::):
  2478. struct foo *ptr = malloc (sizeof *ptr);
  2479. if (ptr == 0) abort ();
  2480. memset (ptr, 0, sizeof (struct foo));
  2481. You can store the result of ‘malloc’ into any pointer variable
  2482. without a cast, because ISO C automatically converts the type ‘void *’
  2483. to another type of pointer when necessary. However, a cast is necessary
  2484. if the type is needed but not specified by context.
  2485. Remember that when allocating space for a string, the argument to
  2486. ‘malloc’ must be one plus the length of the string. This is because a
  2487. string is terminated with a null character that doesn't count in the
  2488. "length" of the string but does need space. For example:
  2489. char *ptr = malloc (length + 1);
  2490. *Note Representation of Strings::, for more information about this.
  2491. 
  2492. File: libc.info, Node: Malloc Examples, Next: Freeing after Malloc, Prev: Basic Allocation, Up: Unconstrained Allocation
  2493. 3.2.3.2 Examples of ‘malloc’
  2494. ............................
  2495. If no more space is available, ‘malloc’ returns a null pointer. You
  2496. should check the value of _every_ call to ‘malloc’. It is useful to
  2497. write a subroutine that calls ‘malloc’ and reports an error if the value
  2498. is a null pointer, returning only if the value is nonzero. This
  2499. function is conventionally called ‘xmalloc’. Here it is:
  2500. void *
  2501. xmalloc (size_t size)
  2502. {
  2503. void *value = malloc (size);
  2504. if (value == 0)
  2505. fatal ("virtual memory exhausted");
  2506. return value;
  2507. }
  2508. Here is a real example of using ‘malloc’ (by way of ‘xmalloc’). The
  2509. function ‘savestring’ will copy a sequence of characters into a newly
  2510. allocated null-terminated string:
  2511. char *
  2512. savestring (const char *ptr, size_t len)
  2513. {
  2514. char *value = xmalloc (len + 1);
  2515. value[len] = '\0';
  2516. return memcpy (value, ptr, len);
  2517. }
  2518. The block that ‘malloc’ gives you is guaranteed to be aligned so that
  2519. it can hold any type of data. On GNU systems, the address is always a
  2520. multiple of eight on 32-bit systems, and a multiple of 16 on 64-bit
  2521. systems. Only rarely is any higher boundary (such as a page boundary)
  2522. necessary; for those cases, use ‘aligned_alloc’ or ‘posix_memalign’
  2523. (*note Aligned Memory Blocks::).
  2524. Note that the memory located after the end of the block is likely to
  2525. be in use for something else; perhaps a block already allocated by
  2526. another call to ‘malloc’. If you attempt to treat the block as longer
  2527. than you asked for it to be, you are liable to destroy the data that
  2528. ‘malloc’ uses to keep track of its blocks, or you may destroy the
  2529. contents of another block. If you have already allocated a block and
  2530. discover you want it to be bigger, use ‘realloc’ (*note Changing Block
  2531. Size::).
  2532. *Portability Notes:*
  2533. • In the GNU C Library, a successful ‘malloc (0)’ returns a non-null
  2534. pointer to a newly allocated size-zero block; other implementations
  2535. may return ‘NULL’ instead. POSIX and the ISO C standard allow both
  2536. behaviors.
  2537. • In the GNU C Library, a failed ‘malloc’ call sets ‘errno’, but ISO
  2538. C does not require this and non-POSIX implementations need not set
  2539. ‘errno’ when failing.
  2540. • In the GNU C Library, ‘malloc’ always fails when SIZE exceeds
  2541. ‘PTRDIFF_MAX’, to avoid problems with programs that subtract
  2542. pointers or use signed indexes. Other implementations may succeed
  2543. in this case, leading to undefined behavior later.
  2544. 
  2545. File: libc.info, Node: Freeing after Malloc, Next: Changing Block Size, Prev: Malloc Examples, Up: Unconstrained Allocation
  2546. 3.2.3.3 Freeing Memory Allocated with ‘malloc’
  2547. ..............................................
  2548. When you no longer need a block that you got with ‘malloc’, use the
  2549. function ‘free’ to make the block available to be allocated again. The
  2550. prototype for this function is in ‘stdlib.h’.
  2551. -- Function: void free (void *PTR)
  2552. Preliminary: | MT-Safe | AS-Unsafe lock | AC-Unsafe lock fd mem |
  2553. *Note POSIX Safety Concepts::.
  2554. The ‘free’ function deallocates the block of memory pointed at by
  2555. PTR.
  2556. Freeing a block alters the contents of the block. *Do not expect to
  2557. find any data (such as a pointer to the next block in a chain of blocks)
  2558. in the block after freeing it.* Copy whatever you need out of the block
  2559. before freeing it! Here is an example of the proper way to free all the
  2560. blocks in a chain, and the strings that they point to:
  2561. struct chain
  2562. {
  2563. struct chain *next;
  2564. char *name;
  2565. }
  2566. void
  2567. free_chain (struct chain *chain)
  2568. {
  2569. while (chain != 0)
  2570. {
  2571. struct chain *next = chain->next;
  2572. free (chain->name);
  2573. free (chain);
  2574. chain = next;
  2575. }
  2576. }
  2577. Occasionally, ‘free’ can actually return memory to the operating
  2578. system and make the process smaller. Usually, all it can do is allow a
  2579. later call to ‘malloc’ to reuse the space. In the meantime, the space
  2580. remains in your program as part of a free-list used internally by
  2581. ‘malloc’.
  2582. The ‘free’ function preserves the value of ‘errno’, so that cleanup
  2583. code need not worry about saving and restoring ‘errno’ around a call to
  2584. ‘free’. Although neither ISO C nor POSIX.1-2017 requires ‘free’ to
  2585. preserve ‘errno’, a future version of POSIX is planned to require it.
  2586. There is no point in freeing blocks at the end of a program, because
  2587. all of the program's space is given back to the system when the process
  2588. terminates.
  2589. -- Function: void free_sized (void *PTR, size_t SIZE)
  2590. Preliminary: | MT-Safe | AS-Unsafe lock | AC-Unsafe lock fd mem |
  2591. *Note POSIX Safety Concepts::.
  2592. The ‘free_sized’ function deallocates the block of memory pointed
  2593. at by PTR that was previously allocated by ‘malloc’, ‘calloc’ or
  2594. ‘realloc’. The size SIZE must match the previously requested total
  2595. size provided to ‘malloc’, ‘calloc’ or ‘realloc’. Attempting to
  2596. deallocated memory allocated by ‘aligned_alloc’, ‘memalign’,
  2597. ‘posix_memalign’, ‘valloc’ or ‘pvalloc’ is undefined behavior. For
  2598. ‘aligned_alloc’, ‘memalign’ or ‘posix_memalign’ use
  2599. ‘free_aligned_sized’ instead. Additionally it is also undefined
  2600. behavior to call ‘free_sized’ for allocations which the caller did
  2601. not directly allocate but must still deallocate, such as the result
  2602. of ‘strdup’ or ‘strndup’. Instead continue using ‘free’ for these
  2603. cases.
  2604. -- Function: void free_aligned_sized (void *PTR, size_t ALIGNMENT,
  2605. size_t SIZE)
  2606. Preliminary: | MT-Safe | AS-Unsafe lock | AC-Unsafe lock fd mem |
  2607. *Note POSIX Safety Concepts::.
  2608. The ‘free_aligned_sized’ function deallocates the block of memory
  2609. pointed at by PTR that was previously allocated by ‘aligned_alloc’,
  2610. ‘memalign’ or ‘posix_memalign’. The size SIZE and alignment
  2611. ALIGNMENT must match the previously requested size and alignment
  2612. provided to ‘aligned_alloc’, ‘memalign’ or ‘posix_memalign’.
  2613. 
  2614. File: libc.info, Node: Changing Block Size, Next: Allocating Cleared Space, Prev: Freeing after Malloc, Up: Unconstrained Allocation
  2615. 3.2.3.4 Changing the Size of a Block
  2616. ....................................
  2617. Often you do not know for certain how big a block you will ultimately
  2618. need at the time you must begin to use the block. For example, the
  2619. block might be a buffer that you use to hold a line being read from a
  2620. file; no matter how long you make the buffer initially, you may
  2621. encounter a line that is longer.
  2622. You can make the block longer by calling ‘realloc’ or ‘reallocarray’.
  2623. These functions are declared in ‘stdlib.h’.
  2624. -- Function: void * realloc (void *PTR, size_t NEWSIZE)
  2625. Preliminary: | MT-Safe | AS-Unsafe lock | AC-Unsafe lock fd mem |
  2626. *Note POSIX Safety Concepts::.
  2627. The ‘realloc’ function changes the size of the block whose address
  2628. is PTR to be NEWSIZE.
  2629. Since the space after the end of the block may be in use, ‘realloc’
  2630. may find it necessary to copy the block to a new address where more
  2631. free space is available. The value of ‘realloc’ is the new address
  2632. of the block. If the block needs to be moved, ‘realloc’ copies the
  2633. old contents.
  2634. If you pass a null pointer for PTR, ‘realloc’ behaves just like
  2635. ‘malloc (NEWSIZE)’. Otherwise, if NEWSIZE is zero ‘realloc’ frees
  2636. the block and returns ‘NULL’. Otherwise, if ‘realloc’ cannot
  2637. reallocate the requested size it returns ‘NULL’ and sets ‘errno’;
  2638. the original block is left undisturbed.
  2639. -- Function: void * reallocarray (void *PTR, size_t NMEMB, size_t SIZE)
  2640. Preliminary: | MT-Safe | AS-Unsafe lock | AC-Unsafe lock fd mem |
  2641. *Note POSIX Safety Concepts::.
  2642. The ‘reallocarray’ function changes the size of the block whose
  2643. address is PTR to be long enough to contain a vector of NMEMB
  2644. elements, each of size SIZE. It is equivalent to ‘realloc (PTR,
  2645. NMEMB * SIZE)’, except that ‘reallocarray’ fails safely if the
  2646. multiplication overflows, by setting ‘errno’ to ‘ENOMEM’, returning
  2647. a null pointer, and leaving the original block unchanged.
  2648. ‘reallocarray’ should be used instead of ‘realloc’ when the new
  2649. size of the allocated block is the result of a multiplication that
  2650. might overflow.
  2651. This function was originally derived from OpenBSD 5.6, but was
  2652. added in POSIX.1-2024.
  2653. Like ‘malloc’, ‘realloc’ and ‘reallocarray’ may return a null pointer
  2654. if no memory space is available to make the block bigger. When this
  2655. happens, the original block is untouched; it has not been modified or
  2656. relocated.
  2657. In most cases it makes no difference what happens to the original
  2658. block when ‘realloc’ fails, because the application program cannot
  2659. continue when it is out of memory, and the only thing to do is to give a
  2660. fatal error message. Often it is convenient to write and use
  2661. subroutines, conventionally called ‘xrealloc’ and ‘xreallocarray’, that
  2662. take care of the error message as ‘xmalloc’ does for ‘malloc’:
  2663. void *
  2664. xreallocarray (void *ptr, size_t nmemb, size_t size)
  2665. {
  2666. void *value = reallocarray (ptr, nmemb, size);
  2667. if (value == 0)
  2668. fatal ("Virtual memory exhausted");
  2669. return value;
  2670. }
  2671. void *
  2672. xrealloc (void *ptr, size_t size)
  2673. {
  2674. return xreallocarray (ptr, 1, size);
  2675. }
  2676. You can also use ‘realloc’ or ‘reallocarray’ to make a block smaller.
  2677. The reason you would do this is to avoid tying up a lot of memory space
  2678. when only a little is needed. In several allocation implementations,
  2679. making a block smaller sometimes necessitates copying it, so it can fail
  2680. if no other space is available.
  2681. *Portability Notes:*
  2682. • Portable programs should not attempt to reallocate blocks to be
  2683. size zero. On other implementations if PTR is non-null, ‘realloc
  2684. (ptr, 0)’ might free the block and return a non-null pointer to a
  2685. size-zero object, or it might fail and return ‘NULL’ without
  2686. freeing the block. The ISO C17 standard allows these variations.
  2687. • In the GNU C Library, reallocation fails if the resulting block
  2688. would exceed ‘PTRDIFF_MAX’ in size, to avoid problems with programs
  2689. that subtract pointers or use signed indexes. Other
  2690. implementations may succeed, leading to undefined behavior later.
  2691. • In the GNU C Library, if the new size is the same as the old,
  2692. ‘realloc’ and ‘reallocarray’ are guaranteed to change nothing and
  2693. return the same address that you gave. However, POSIX and ISO C
  2694. allow the functions to relocate the object or fail in this
  2695. situation.
  2696. 
  2697. File: libc.info, Node: Allocating Cleared Space, Next: Aligned Memory Blocks, Prev: Changing Block Size, Up: Unconstrained Allocation
  2698. 3.2.3.5 Allocating Cleared Space
  2699. ................................
  2700. The function ‘calloc’ allocates memory and clears it to zero. It is
  2701. declared in ‘stdlib.h’.
  2702. -- Function: void * calloc (size_t COUNT, size_t ELTSIZE)
  2703. Preliminary: | MT-Safe | AS-Unsafe lock | AC-Unsafe lock fd mem |
  2704. *Note POSIX Safety Concepts::.
  2705. This function allocates a block long enough to contain a vector of
  2706. COUNT elements, each of size ELTSIZE. Its contents are cleared to
  2707. zero before ‘calloc’ returns.
  2708. You could define ‘calloc’ as follows:
  2709. void *
  2710. calloc (size_t count, size_t eltsize)
  2711. {
  2712. void *value = reallocarray (0, count, eltsize);
  2713. if (value != 0)
  2714. memset (value, 0, count * eltsize);
  2715. return value;
  2716. }
  2717. But in general, it is not guaranteed that ‘calloc’ calls
  2718. ‘reallocarray’ and ‘memset’ internally. For example, if the ‘calloc’
  2719. implementation knows for other reasons that the new memory block is
  2720. zero, it need not zero out the block again with ‘memset’. Also, if an
  2721. application provides its own ‘reallocarray’ outside the C library,
  2722. ‘calloc’ might not use that redefinition. *Note Replacing malloc::.
  2723. 
  2724. File: libc.info, Node: Aligned Memory Blocks, Next: Malloc Tunable Parameters, Prev: Allocating Cleared Space, Up: Unconstrained Allocation
  2725. 3.2.3.6 Allocating Aligned Memory Blocks
  2726. ........................................
  2727. The address of a block returned by ‘malloc’ or ‘realloc’ in GNU systems
  2728. is always a multiple of eight (or sixteen on 64-bit systems). If you
  2729. need a block whose address is a multiple of a higher power of two than
  2730. that, use ‘aligned_alloc’ or ‘posix_memalign’. ‘aligned_alloc’ and
  2731. ‘posix_memalign’ are declared in ‘stdlib.h’.
  2732. -- Function: void * aligned_alloc (size_t ALIGNMENT, size_t SIZE)
  2733. Preliminary: | MT-Safe | AS-Unsafe lock | AC-Unsafe lock fd mem |
  2734. *Note POSIX Safety Concepts::.
  2735. The ‘aligned_alloc’ function allocates a block of SIZE bytes whose
  2736. address is a multiple of ALIGNMENT. The ALIGNMENT must be a power
  2737. of two.
  2738. The ‘aligned_alloc’ function returns a null pointer on error and
  2739. sets ‘errno’ to one of the following values:
  2740. ‘ENOMEM’
  2741. There was insufficient memory available to satisfy the
  2742. request.
  2743. ‘EINVAL’
  2744. ALIGNMENT is not a power of two.
  2745. This function was introduced in ISO C11 and hence may have
  2746. better portability to modern non-POSIX systems than
  2747. ‘posix_memalign’.
  2748. -- Function: void * memalign (size_t BOUNDARY, size_t SIZE)
  2749. Preliminary: | MT-Safe | AS-Unsafe lock | AC-Unsafe lock fd mem |
  2750. *Note POSIX Safety Concepts::.
  2751. The ‘memalign’ function allocates a block of SIZE bytes whose
  2752. address is a multiple of BOUNDARY. The BOUNDARY must be a power of
  2753. two! The function ‘memalign’ works by allocating a somewhat larger
  2754. block, and then returning an address within the block that is on
  2755. the specified boundary.
  2756. The ‘memalign’ function returns a null pointer on error and sets
  2757. ‘errno’ to one of the following values:
  2758. ‘ENOMEM’
  2759. There was insufficient memory available to satisfy the
  2760. request.
  2761. ‘EINVAL’
  2762. BOUNDARY is not a power of two.
  2763. The ‘memalign’ function is obsolete and ‘aligned_alloc’ or
  2764. ‘posix_memalign’ should be used instead.
  2765. -- Function: int posix_memalign (void **MEMPTR, size_t ALIGNMENT,
  2766. size_t SIZE)
  2767. Preliminary: | MT-Safe | AS-Unsafe lock | AC-Unsafe lock fd mem |
  2768. *Note POSIX Safety Concepts::.
  2769. The ‘posix_memalign’ function is similar to the ‘memalign’ function
  2770. in that it returns a buffer of SIZE bytes aligned to a multiple of
  2771. ALIGNMENT. But it adds one requirement to the parameter ALIGNMENT:
  2772. the value must be a power of two multiple of ‘sizeof (void *)’.
  2773. If the function succeeds in allocation memory a pointer to the
  2774. allocated memory is returned in ‘*MEMPTR’ and the return value is
  2775. zero. Otherwise the function returns an error value indicating the
  2776. problem. The possible error values returned are:
  2777. ‘ENOMEM’
  2778. There was insufficient memory available to satisfy the
  2779. request.
  2780. ‘EINVAL’
  2781. ALIGNMENT is not a power of two multiple of ‘sizeof (void *)’.
  2782. This function was introduced in POSIX 1003.1d. Although this
  2783. function is superseded by ‘aligned_alloc’, it is more portable to
  2784. older POSIX systems that do not support ISO C11.
  2785. -- Function: void * valloc (size_t SIZE)
  2786. Preliminary: | MT-Unsafe init | AS-Unsafe init lock | AC-Unsafe
  2787. init lock fd mem | *Note POSIX Safety Concepts::.
  2788. Using ‘valloc’ is like using ‘memalign’ and passing the page size
  2789. as the value of the first argument. It is implemented like this:
  2790. void *
  2791. valloc (size_t size)
  2792. {
  2793. return memalign (getpagesize (), size);
  2794. }
  2795. *note Query Memory Parameters:: for more information about the
  2796. memory subsystem.
  2797. The ‘valloc’ function is obsolete and ‘aligned_alloc’ or
  2798. ‘posix_memalign’ should be used instead.
  2799. You can determine the alignment of a pointer with the ‘memalignment’
  2800. function.
  2801. -- Function: size_t memalignment (void *P)
  2802. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2803. Concepts::.
  2804. This function, defined in C23, returns the alignment of P, as a
  2805. power of two. If P is a null pointer, it returns zero. C23
  2806. requires P to be a valid pointer to an object or a null pointer; as
  2807. a GNU extension, the GNU C Library supports this function on
  2808. arbitrary bit patterns of pointer type.
  2809. This function was added to the C23 standard to support
  2810. unconventional platforms where a pointer's low-order bits are
  2811. unrelated to alignment. For conventional platforms, one can
  2812. instead cast the pointer to ‘uintptr_t’ and then test the low order
  2813. bits: this is portable to pre-C23 and is typically a bit faster.
  2814. For example, if you want to read an ‘int’ addressed by
  2815. possibly-misaligned pointer ‘p’, the following pre-C23 code works
  2816. on all conventional platforms:
  2817. int i;
  2818. if (((uintptr_t) p & (alignof (int) - 1)) != 0)
  2819. memcpy (&i, p, sizeof i);
  2820. else
  2821. i = *p;
  2822. However, it might not work on unconventional platforms, where one
  2823. would need something like the following C23 code:
  2824. int i;
  2825. if (memalignment (p) < alignof (int))
  2826. memcpy (&i, p, sizeof i);
  2827. else
  2828. i = *p;
  2829. However, for this particular case, performance does not improve if
  2830. different code is used for aligned and unaligned pointers, and the
  2831. following code is preferable:
  2832. int i;
  2833. memcpy (&i, p, sizeof i);
  2834. The compiler will generate the most efficient way to access
  2835. unaligned data for the architecture, optimizing away the ‘memcpy’
  2836. call.
  2837. 
  2838. File: libc.info, Node: Malloc Tunable Parameters, Next: Heap Consistency Checking, Prev: Aligned Memory Blocks, Up: Unconstrained Allocation
  2839. 3.2.3.7 Malloc Tunable Parameters
  2840. .................................
  2841. You can adjust some parameters for dynamic memory allocation with the
  2842. ‘mallopt’ function. This function is the general SVID/XPG interface,
  2843. defined in ‘malloc.h’.
  2844. -- Function: int mallopt (int PARAM, int VALUE)
  2845. Preliminary: | MT-Unsafe init const:mallopt | AS-Unsafe init lock |
  2846. AC-Unsafe init lock | *Note POSIX Safety Concepts::.
  2847. When calling ‘mallopt’, the PARAM argument specifies the parameter
  2848. to be set, and VALUE the new value to be set. Possible choices for
  2849. PARAM, as defined in ‘malloc.h’, are:
  2850. ‘M_MMAP_MAX’
  2851. The maximum number of chunks to allocate with ‘mmap’. Setting
  2852. this to zero disables all use of ‘mmap’.
  2853. The default value of this parameter is ‘65536’.
  2854. This parameter can also be set for the process at startup by
  2855. setting the environment variable ‘MALLOC_MMAP_MAX_’ to the
  2856. desired value.
  2857. ‘M_MMAP_THRESHOLD’
  2858. All chunks larger than this value are allocated outside the
  2859. normal heap, using the ‘mmap’ system call. This way it is
  2860. guaranteed that the memory for these chunks can be returned to
  2861. the system on ‘free’. Note that requests smaller than this
  2862. threshold might still be allocated via ‘mmap’.
  2863. If this parameter is not set, the default value is set as 128
  2864. KiB and the threshold is adjusted dynamically to suit the
  2865. allocation patterns of the program. If the parameter is set,
  2866. the dynamic adjustment is disabled and the value is set
  2867. statically to the input value.
  2868. This parameter can also be set for the process at startup by
  2869. setting the environment variable ‘MALLOC_MMAP_THRESHOLD_’ to
  2870. the desired value.
  2871. ‘M_PERTURB’
  2872. If non-zero, memory blocks are filled with values depending on
  2873. some low order bits of this parameter when they are allocated
  2874. (except when allocated by ‘calloc’) and freed. This can be
  2875. used to debug the use of uninitialized or freed heap memory.
  2876. Note that this option does not guarantee that the freed block
  2877. will have any specific values. It only guarantees that the
  2878. content the block had before it was freed will be overwritten.
  2879. The default value of this parameter is ‘0’.
  2880. This parameter can also be set for the process at startup by
  2881. setting the environment variable ‘MALLOC_PERTURB_’ to the
  2882. desired value.
  2883. ‘M_TOP_PAD’
  2884. This parameter determines the amount of extra memory to obtain
  2885. from the system when an arena needs to be extended. It also
  2886. specifies the number of bytes to retain when shrinking an
  2887. arena. This provides the necessary hysteresis in heap size
  2888. such that excessive amounts of system calls can be avoided.
  2889. The default value of this parameter is ‘0’.
  2890. This parameter can also be set for the process at startup by
  2891. setting the environment variable ‘MALLOC_TOP_PAD_’ to the
  2892. desired value.
  2893. ‘M_TRIM_THRESHOLD’
  2894. This is the minimum size (in bytes) of the top-most,
  2895. releasable chunk that will trigger a system call in order to
  2896. return memory to the system.
  2897. If this parameter is not set, the default value is set as 128
  2898. KiB and the threshold is adjusted dynamically to suit the
  2899. allocation patterns of the program. If the parameter is set,
  2900. the dynamic adjustment is disabled and the value is set
  2901. statically to the provided input.
  2902. This parameter can also be set for the process at startup by
  2903. setting the environment variable ‘MALLOC_TRIM_THRESHOLD_’ to
  2904. the desired value.
  2905. ‘M_ARENA_TEST’
  2906. This parameter specifies the number of arenas that can be
  2907. created before the test on the limit to the number of arenas
  2908. is conducted. The value is ignored if ‘M_ARENA_MAX’ is set.
  2909. The default value of this parameter is 2 on 32-bit systems and
  2910. 8 on 64-bit systems.
  2911. This parameter can also be set for the process at startup by
  2912. setting the environment variable ‘MALLOC_ARENA_TEST’ to the
  2913. desired value.
  2914. ‘M_ARENA_MAX’
  2915. This parameter sets the number of arenas to use regardless of
  2916. the number of cores in the system.
  2917. The default value of this tunable is ‘0’, meaning that the
  2918. limit on the number of arenas is determined by the number of
  2919. CPU cores online. For 32-bit systems the limit is twice the
  2920. number of cores online and on 64-bit systems, it is eight
  2921. times the number of cores online. Note that the default value
  2922. is not derived from the default value of M_ARENA_TEST and is
  2923. computed independently.
  2924. This parameter can also be set for the process at startup by
  2925. setting the environment variable ‘MALLOC_ARENA_MAX’ to the
  2926. desired value.
  2927. 
  2928. File: libc.info, Node: Heap Consistency Checking, Next: Statistics of Malloc, Prev: Malloc Tunable Parameters, Up: Unconstrained Allocation
  2929. 3.2.3.8 Heap Consistency Checking
  2930. .................................
  2931. You can ask ‘malloc’ to check the consistency of dynamic memory by using
  2932. the ‘mcheck’ function and preloading the malloc debug library
  2933. ‘libc_malloc_debug’ using the LD_PRELOAD environment variable. This
  2934. function is a GNU extension, declared in ‘mcheck.h’.
  2935. -- Function: int mcheck (void (*ABORTFN) (enum mcheck_status STATUS))
  2936. Preliminary: | MT-Unsafe race:mcheck const:malloc_hooks | AS-Unsafe
  2937. corrupt | AC-Unsafe corrupt | *Note POSIX Safety Concepts::.
  2938. Calling ‘mcheck’ tells ‘malloc’ to perform occasional consistency
  2939. checks. These will catch things such as writing past the end of a
  2940. block that was allocated with ‘malloc’.
  2941. The ABORTFN argument is the function to call when an inconsistency
  2942. is found. If you supply a null pointer, then ‘mcheck’ uses a
  2943. default function which prints a message and calls ‘abort’ (*note
  2944. Aborting a Program::). The function you supply is called with one
  2945. argument, which says what sort of inconsistency was detected; its
  2946. type is described below.
  2947. It is too late to begin allocation checking once you have allocated
  2948. anything with ‘malloc’. So ‘mcheck’ does nothing in that case.
  2949. The function returns ‘-1’ if you call it too late, and ‘0’
  2950. otherwise (when it is successful).
  2951. The easiest way to arrange to call ‘mcheck’ early enough is to use
  2952. the option ‘-lmcheck’ when you link your program; then you don't
  2953. need to modify your program source at all. Alternatively you might
  2954. use a debugger to insert a call to ‘mcheck’ whenever the program is
  2955. started, for example these gdb commands will automatically call
  2956. ‘mcheck’ whenever the program starts:
  2957. (gdb) break main
  2958. Breakpoint 1, main (argc=2, argv=0xbffff964) at whatever.c:10
  2959. (gdb) command 1
  2960. Type commands for when breakpoint 1 is hit, one per line.
  2961. End with a line saying just "end".
  2962. >call mcheck(0)
  2963. >continue
  2964. >end
  2965. (gdb) ...
  2966. This will however only work if no initialization function of any
  2967. object involved calls any of the ‘malloc’ functions since ‘mcheck’
  2968. must be called before the first such function.
  2969. -- Function: enum mcheck_status mprobe (void *POINTER)
  2970. Preliminary: | MT-Unsafe race:mcheck const:malloc_hooks | AS-Unsafe
  2971. corrupt | AC-Unsafe corrupt | *Note POSIX Safety Concepts::.
  2972. The ‘mprobe’ function lets you explicitly check for inconsistencies
  2973. in a particular allocated block. You must have already called
  2974. ‘mcheck’ at the beginning of the program, to do its occasional
  2975. checks; calling ‘mprobe’ requests an additional consistency check
  2976. to be done at the time of the call.
  2977. The argument POINTER must be a pointer returned by ‘malloc’ or
  2978. ‘realloc’. ‘mprobe’ returns a value that says what inconsistency,
  2979. if any, was found. The values are described below.
  2980. -- Data Type: enum mcheck_status
  2981. This enumerated type describes what kind of inconsistency was
  2982. detected in an allocated block, if any. Here are the possible
  2983. values:
  2984. ‘MCHECK_DISABLED’
  2985. ‘mcheck’ was not called before the first allocation. No
  2986. consistency checking can be done.
  2987. ‘MCHECK_OK’
  2988. No inconsistency detected.
  2989. ‘MCHECK_HEAD’
  2990. The data immediately before the block was modified. This
  2991. commonly happens when an array index or pointer is decremented
  2992. too far.
  2993. ‘MCHECK_TAIL’
  2994. The data immediately after the block was modified. This
  2995. commonly happens when an array index or pointer is incremented
  2996. too far.
  2997. ‘MCHECK_FREE’
  2998. The block was already freed.
  2999. Another possibility to check for and guard against bugs in the use of
  3000. ‘malloc’, ‘realloc’ and ‘free’ is to set the environment variable
  3001. ‘MALLOC_CHECK_’. When ‘MALLOC_CHECK_’ is set to a non-zero value less
  3002. than 4, a special (less efficient) implementation is used which is
  3003. designed to be tolerant against simple errors, such as double calls of
  3004. ‘free’ with the same argument, or overruns of a single byte (off-by-one
  3005. bugs). Not all such errors can be protected against, however, and
  3006. memory leaks can result. Like in the case of ‘mcheck’, one would need
  3007. to preload the ‘libc_malloc_debug’ library to enable ‘MALLOC_CHECK_’
  3008. functionality. Without this preloaded library, setting ‘MALLOC_CHECK_’
  3009. will have no effect.
  3010. Any detected heap corruption results in immediate termination of the
  3011. process.
  3012. There is one problem with ‘MALLOC_CHECK_’: in SUID or SGID binaries
  3013. it could possibly be exploited since diverging from the normal programs
  3014. behavior it now writes something to the standard error descriptor.
  3015. Therefore the use of ‘MALLOC_CHECK_’ is disabled by default for SUID and
  3016. SGID binaries.
  3017. So, what's the difference between using ‘MALLOC_CHECK_’ and linking
  3018. with ‘-lmcheck’? ‘MALLOC_CHECK_’ is orthogonal with respect to
  3019. ‘-lmcheck’. ‘-lmcheck’ has been added for backward compatibility. Both
  3020. ‘MALLOC_CHECK_’ and ‘-lmcheck’ should uncover the same bugs - but using
  3021. ‘MALLOC_CHECK_’ you don't need to recompile your application.
  3022. 
  3023. File: libc.info, Node: Statistics of Malloc, Next: Summary of Malloc, Prev: Heap Consistency Checking, Up: Unconstrained Allocation
  3024. 3.2.3.9 Statistics for Memory Allocation with ‘malloc’
  3025. ......................................................
  3026. You can get information about dynamic memory allocation by calling the
  3027. ‘mallinfo2’ function. This function and its associated data type are
  3028. declared in ‘malloc.h’; they are an extension of the standard SVID/XPG
  3029. version.
  3030. -- Data Type: struct mallinfo2
  3031. This structure type is used to return information about the dynamic
  3032. memory allocator. It contains the following members:
  3033. ‘size_t arena’
  3034. This is the total size of memory allocated with ‘sbrk’ by
  3035. ‘malloc’, in bytes.
  3036. ‘size_t ordblks’
  3037. This is the number of chunks not in use. (The memory
  3038. allocator internally gets chunks of memory from the operating
  3039. system, and then carves them up to satisfy individual ‘malloc’
  3040. requests; *note The GNU Allocator::.)
  3041. ‘size_t smblks’
  3042. This field is unused.
  3043. ‘size_t hblks’
  3044. This is the total number of chunks allocated with ‘mmap’.
  3045. ‘size_t hblkhd’
  3046. This is the total size of memory allocated with ‘mmap’, in
  3047. bytes.
  3048. ‘size_t usmblks’
  3049. This field is unused and always 0.
  3050. ‘size_t fsmblks’
  3051. This field is unused.
  3052. ‘size_t uordblks’
  3053. This is the total size of memory occupied by chunks handed out
  3054. by ‘malloc’.
  3055. ‘size_t fordblks’
  3056. This is the total size of memory occupied by free (not in use)
  3057. chunks.
  3058. ‘size_t keepcost’
  3059. This is the size of the top-most releasable chunk that
  3060. normally borders the end of the heap (i.e., the high end of
  3061. the virtual address space's data segment).
  3062. -- Function: struct mallinfo2 mallinfo2 (void)
  3063. Preliminary: | MT-Unsafe init const:mallopt | AS-Unsafe init lock |
  3064. AC-Unsafe init lock | *Note POSIX Safety Concepts::.
  3065. This function returns information about the current dynamic memory
  3066. usage in a structure of type ‘struct mallinfo2’.
  3067. 
  3068. File: libc.info, Node: Summary of Malloc, Prev: Statistics of Malloc, Up: Unconstrained Allocation
  3069. 3.2.3.10 Summary of ‘malloc’-Related Functions
  3070. ..............................................
  3071. Here is a summary of the functions that work with ‘malloc’:
  3072. ‘void *malloc (size_t SIZE)’
  3073. Allocate a block of SIZE bytes. *Note Basic Allocation::.
  3074. ‘void free (void *ADDR)’
  3075. Free a block previously allocated by ‘malloc’. *Note Freeing after
  3076. Malloc::.
  3077. ‘void *realloc (void *ADDR, size_t SIZE)’
  3078. Make a block previously allocated by ‘malloc’ larger or smaller,
  3079. possibly by copying it to a new location. *Note Changing Block
  3080. Size::.
  3081. ‘void *reallocarray (void *PTR, size_t NMEMB, size_t SIZE)’
  3082. Change the size of a block previously allocated by ‘malloc’ to
  3083. ‘NMEMB * SIZE’ bytes as with ‘realloc’. *Note Changing Block
  3084. Size::.
  3085. ‘void *calloc (size_t COUNT, size_t ELTSIZE)’
  3086. Allocate a block of COUNT * ELTSIZE bytes using ‘malloc’, and set
  3087. its contents to zero. *Note Allocating Cleared Space::.
  3088. ‘void *valloc (size_t SIZE)’
  3089. Allocate a block of SIZE bytes, starting on a page boundary. *Note
  3090. Aligned Memory Blocks::.
  3091. ‘void *aligned_alloc (size_t ALIGNMENT, size_t SIZE)’
  3092. Allocate a block of SIZE bytes, starting on an address that is a
  3093. multiple of ALIGNMENT. *Note Aligned Memory Blocks::.
  3094. ‘int posix_memalign (void **MEMPTR, size_t ALIGNMENT, size_t SIZE)’
  3095. Allocate a block of SIZE bytes, starting on an address that is a
  3096. multiple of ALIGNMENT. *Note Aligned Memory Blocks::.
  3097. ‘void *memalign (size_t BOUNDARY, size_t SIZE)’
  3098. Allocate a block of SIZE bytes, starting on an address that is a
  3099. multiple of BOUNDARY. *Note Aligned Memory Blocks::.
  3100. ‘int mallopt (int PARAM, int VALUE)’
  3101. Adjust a tunable parameter. *Note Malloc Tunable Parameters::.
  3102. ‘int mcheck (void (*ABORTFN) (void))’
  3103. Tell ‘malloc’ to perform occasional consistency checks on
  3104. dynamically allocated memory, and to call ABORTFN when an
  3105. inconsistency is found. *Note Heap Consistency Checking::.
  3106. ‘struct mallinfo2 mallinfo2 (void)’
  3107. Return information about the current dynamic memory usage. *Note
  3108. Statistics of Malloc::.
  3109. 
  3110. File: libc.info, Node: Allocation Debugging, Next: Replacing malloc, Prev: Unconstrained Allocation, Up: Memory Allocation
  3111. 3.2.4 Allocation Debugging
  3112. --------------------------
  3113. A complicated task when programming with languages which do not use
  3114. garbage collected dynamic memory allocation is to find memory leaks.
  3115. Long running programs must ensure that dynamically allocated objects are
  3116. freed at the end of their lifetime. If this does not happen the system
  3117. runs out of memory, sooner or later.
  3118. The ‘malloc’ implementation in the GNU C Library provides some simple
  3119. means to detect such leaks and obtain some information to find the
  3120. location. To do this the application must be started in a special mode
  3121. which is enabled by an environment variable. There are no speed
  3122. penalties for the program if the debugging mode is not enabled.
  3123. * Menu:
  3124. * Tracing malloc:: How to install the tracing functionality.
  3125. * Using the Memory Debugger:: Example programs excerpts.
  3126. * Tips for the Memory Debugger:: Some more or less clever ideas.
  3127. * Interpreting the traces:: What do all these lines mean?
  3128. 
  3129. File: libc.info, Node: Tracing malloc, Next: Using the Memory Debugger, Up: Allocation Debugging
  3130. 3.2.4.1 How to install the tracing functionality
  3131. ................................................
  3132. -- Function: void mtrace (void)
  3133. Preliminary: | MT-Unsafe env race:mtrace init | AS-Unsafe init heap
  3134. corrupt lock | AC-Unsafe init corrupt lock fd mem | *Note POSIX
  3135. Safety Concepts::.
  3136. The ‘mtrace’ function provides a way to trace memory allocation
  3137. events in the program that calls it. It is disabled by default in
  3138. the library and can be enabled by preloading the debugging library
  3139. ‘libc_malloc_debug’ using the ‘LD_PRELOAD’ environment variable.
  3140. When the ‘mtrace’ function is called it looks for an environment
  3141. variable named ‘MALLOC_TRACE’. This variable is supposed to
  3142. contain a valid file name. The user must have write access. If
  3143. the file already exists it is truncated. If the environment
  3144. variable is not set or it does not name a valid file which can be
  3145. opened for writing nothing is done. The behavior of ‘malloc’ etc.
  3146. is not changed. For obvious reasons this also happens if the
  3147. application is installed with the SUID or SGID bit set.
  3148. If the named file is successfully opened, ‘mtrace’ installs special
  3149. handlers for the functions ‘malloc’, ‘realloc’, and ‘free’. From
  3150. then on, all uses of these functions are traced and protocolled
  3151. into the file. There is now of course a speed penalty for all
  3152. calls to the traced functions so tracing should not be enabled
  3153. during normal use.
  3154. This function is a GNU extension and generally not available on
  3155. other systems. The prototype can be found in ‘mcheck.h’.
  3156. -- Function: void muntrace (void)
  3157. Preliminary: | MT-Unsafe race:mtrace locale | AS-Unsafe corrupt
  3158. heap | AC-Unsafe corrupt mem lock fd | *Note POSIX Safety
  3159. Concepts::.
  3160. The ‘muntrace’ function can be called after ‘mtrace’ was used to
  3161. enable tracing the ‘malloc’ calls. If no (successful) call of
  3162. ‘mtrace’ was made ‘muntrace’ does nothing.
  3163. Otherwise it deinstalls the handlers for ‘malloc’, ‘realloc’, and
  3164. ‘free’ and then closes the protocol file. No calls are protocolled
  3165. anymore and the program runs again at full speed.
  3166. This function is a GNU extension and generally not available on
  3167. other systems. The prototype can be found in ‘mcheck.h’.
  3168. 
  3169. File: libc.info, Node: Using the Memory Debugger, Next: Tips for the Memory Debugger, Prev: Tracing malloc, Up: Allocation Debugging
  3170. 3.2.4.2 Example program excerpts
  3171. ................................
  3172. Even though the tracing functionality does not influence the runtime
  3173. behavior of the program it is not a good idea to call ‘mtrace’ in all
  3174. programs. Just imagine that you debug a program using ‘mtrace’ and all
  3175. other programs used in the debugging session also trace their ‘malloc’
  3176. calls. The output file would be the same for all programs and thus is
  3177. unusable. Therefore one should call ‘mtrace’ only if compiled for
  3178. debugging. A program could therefore start like this:
  3179. #include <mcheck.h>
  3180. int
  3181. main (int argc, char *argv[])
  3182. {
  3183. #ifdef DEBUGGING
  3184. mtrace ();
  3185. #endif
  3186. ...
  3187. }
  3188. This is all that is needed if you want to trace the calls during the
  3189. whole runtime of the program. Alternatively you can stop the tracing at
  3190. any time with a call to ‘muntrace’. It is even possible to restart the
  3191. tracing again with a new call to ‘mtrace’. But this can cause
  3192. unreliable results since there may be calls of the functions which are
  3193. not called. Please note that not only the application uses the traced
  3194. functions, also libraries (including the C library itself) use these
  3195. functions.
  3196. This last point is also why it is not a good idea to call ‘muntrace’
  3197. before the program terminates. The libraries are informed about the
  3198. termination of the program only after the program returns from ‘main’ or
  3199. calls ‘exit’ and so cannot free the memory they use before this time.
  3200. So the best thing one can do is to call ‘mtrace’ as the very first
  3201. function in the program and never call ‘muntrace’. So the program
  3202. traces almost all uses of the ‘malloc’ functions (except those calls
  3203. which are executed by constructors of the program or used libraries).
  3204. 
  3205. File: libc.info, Node: Tips for the Memory Debugger, Next: Interpreting the traces, Prev: Using the Memory Debugger, Up: Allocation Debugging
  3206. 3.2.4.3 Some more or less clever ideas
  3207. ......................................
  3208. You know the situation. The program is prepared for debugging and in
  3209. all debugging sessions it runs well. But once it is started without
  3210. debugging the error shows up. A typical example is a memory leak that
  3211. becomes visible only when we turn off the debugging. If you foresee
  3212. such situations you can still win. Simply use something equivalent to
  3213. the following little program:
  3214. #include <mcheck.h>
  3215. #include <signal.h>
  3216. static void
  3217. enable (int sig)
  3218. {
  3219. mtrace ();
  3220. signal (SIGUSR1, enable);
  3221. }
  3222. static void
  3223. disable (int sig)
  3224. {
  3225. muntrace ();
  3226. signal (SIGUSR2, disable);
  3227. }
  3228. int
  3229. main (int argc, char *argv[])
  3230. {
  3231. ...
  3232. signal (SIGUSR1, enable);
  3233. signal (SIGUSR2, disable);
  3234. ...
  3235. }
  3236. I.e., the user can start the memory debugger any time s/he wants if
  3237. the program was started with ‘MALLOC_TRACE’ set in the environment. The
  3238. output will of course not show the allocations which happened before the
  3239. first signal but if there is a memory leak this will show up
  3240. nevertheless.
  3241. 
  3242. File: libc.info, Node: Interpreting the traces, Prev: Tips for the Memory Debugger, Up: Allocation Debugging
  3243. 3.2.4.4 Interpreting the traces
  3244. ...............................
  3245. If you take a look at the output it will look similar to this:
  3246. = Start
  3247. [0x8048209] - 0x8064cc8
  3248. [0x8048209] - 0x8064ce0
  3249. [0x8048209] - 0x8064cf8
  3250. [0x80481eb] + 0x8064c48 0x14
  3251. [0x80481eb] + 0x8064c60 0x14
  3252. [0x80481eb] + 0x8064c78 0x14
  3253. [0x80481eb] + 0x8064c90 0x14
  3254. = End
  3255. What this all means is not really important since the trace file is
  3256. not meant to be read by a human. Therefore no attention is given to
  3257. readability. Instead there is a program which comes with the GNU C
  3258. Library which interprets the traces and outputs a summary in an
  3259. user-friendly way. The program is called ‘mtrace’ (it is in fact a Perl
  3260. script) and it takes one or two arguments. In any case the name of the
  3261. file with the trace output must be specified. If an optional argument
  3262. precedes the name of the trace file this must be the name of the program
  3263. which generated the trace.
  3264. drepper$ mtrace tst-mtrace log
  3265. No memory leaks.
  3266. In this case the program ‘tst-mtrace’ was run and it produced a trace
  3267. file ‘log’. The message printed by ‘mtrace’ shows there are no problems
  3268. with the code, all allocated memory was freed afterwards.
  3269. If we call ‘mtrace’ on the example trace given above we would get a
  3270. different output:
  3271. drepper$ mtrace errlog
  3272. - 0x08064cc8 Free 2 was never alloc'd 0x8048209
  3273. - 0x08064ce0 Free 3 was never alloc'd 0x8048209
  3274. - 0x08064cf8 Free 4 was never alloc'd 0x8048209
  3275. Memory not freed:
  3276. -----------------
  3277. Address Size Caller
  3278. 0x08064c48 0x14 at 0x80481eb
  3279. 0x08064c60 0x14 at 0x80481eb
  3280. 0x08064c78 0x14 at 0x80481eb
  3281. 0x08064c90 0x14 at 0x80481eb
  3282. We have called ‘mtrace’ with only one argument and so the script has
  3283. no chance to find out what is meant with the addresses given in the
  3284. trace. We can do better:
  3285. drepper$ mtrace tst errlog
  3286. - 0x08064cc8 Free 2 was never alloc'd /home/drepper/tst.c:39
  3287. - 0x08064ce0 Free 3 was never alloc'd /home/drepper/tst.c:39
  3288. - 0x08064cf8 Free 4 was never alloc'd /home/drepper/tst.c:39
  3289. Memory not freed:
  3290. -----------------
  3291. Address Size Caller
  3292. 0x08064c48 0x14 at /home/drepper/tst.c:33
  3293. 0x08064c60 0x14 at /home/drepper/tst.c:33
  3294. 0x08064c78 0x14 at /home/drepper/tst.c:33
  3295. 0x08064c90 0x14 at /home/drepper/tst.c:33
  3296. Suddenly the output makes much more sense and the user can see
  3297. immediately where the function calls causing the trouble can be found.
  3298. Interpreting this output is not complicated. There are at most two
  3299. different situations being detected. First, ‘free’ was called for
  3300. pointers which were never returned by one of the allocation functions.
  3301. This is usually a very bad problem and what this looks like is shown in
  3302. the first three lines of the output. Situations like this are quite
  3303. rare and if they appear they show up very drastically: the program
  3304. normally crashes.
  3305. The other situation which is much harder to detect are memory leaks.
  3306. As you can see in the output the ‘mtrace’ function collects all this
  3307. information and so can say that the program calls an allocation function
  3308. from line 33 in the source file ‘/home/drepper/tst-mtrace.c’ four times
  3309. without freeing this memory before the program terminates. Whether this
  3310. is a real problem remains to be investigated.
  3311. 
  3312. File: libc.info, Node: Replacing malloc, Next: Obstacks, Prev: Allocation Debugging, Up: Memory Allocation
  3313. 3.2.5 Replacing ‘malloc’
  3314. ------------------------
  3315. The GNU C Library supports replacing the built-in ‘malloc’
  3316. implementation with a different allocator with the same interface. For
  3317. dynamically linked programs, this happens through ELF symbol
  3318. interposition, either using shared object dependencies or ‘LD_PRELOAD’.
  3319. For static linking, the ‘malloc’ replacement library must be linked in
  3320. before linking against ‘libc.a’ (explicitly or implicitly).
  3321. Care must be taken not to use functionality from the GNU C Library
  3322. that uses ‘malloc’ internally. For example, the ‘fopen’, ‘opendir’,
  3323. ‘dlopen’, and ‘pthread_setspecific’ functions currently use the ‘malloc’
  3324. subsystem internally. If the replacement ‘malloc’ or its dependencies
  3325. use thread-local storage (TLS), it must use the initial-exec TLS model,
  3326. and not one of the dynamic TLS variants.
  3327. *Note:* Failure to provide a complete set of replacement functions
  3328. (that is, all the functions used by the application, the GNU C Library,
  3329. and other linked-in libraries) can lead to static linking failures, and,
  3330. at run time, to heap corruption and application crashes. Replacement
  3331. functions should implement the behavior documented for their
  3332. counterparts in the GNU C Library; for example, the replacement ‘free’
  3333. should also preserve ‘errno’.
  3334. The minimum set of functions which has to be provided by a custom
  3335. ‘malloc’ is given in the table below.
  3336. ‘malloc’
  3337. ‘free’
  3338. ‘calloc’
  3339. ‘realloc’
  3340. These ‘malloc’-related functions are required for the GNU C Library
  3341. to work.(1)
  3342. The ‘malloc’ implementation in the GNU C Library provides additional
  3343. functionality not used by the library itself, but which is often used by
  3344. other system libraries and applications. A general-purpose replacement
  3345. ‘malloc’ implementation should provide definitions of these functions,
  3346. too. Their names are listed in the following table.
  3347. ‘aligned_alloc’
  3348. ‘free_aligned_sized’
  3349. ‘free_sized’
  3350. ‘malloc_usable_size’
  3351. ‘memalign’
  3352. ‘posix_memalign’
  3353. ‘pvalloc’
  3354. ‘valloc’
  3355. In addition, very old applications may use the obsolete ‘cfree’
  3356. function.
  3357. Further ‘malloc’-related functions such as ‘mallopt’ or ‘mallinfo2’
  3358. will not have any effect or return incorrect statistics when a
  3359. replacement ‘malloc’ is in use. However, failure to replace these
  3360. functions typically does not result in crashes or other incorrect
  3361. application behavior, but may result in static linking failures.
  3362. There are other functions (‘reallocarray’, ‘strdup’, etc.) in the
  3363. GNU C Library that are not listed above but return newly allocated
  3364. memory to callers. Replacement of these functions is not supported and
  3365. may produce incorrect results. The GNU C Library implementations of
  3366. these functions call the replacement allocator functions whenever
  3367. available, so they will work correctly with ‘malloc’ replacement.
  3368. ---------- Footnotes ----------
  3369. (1) Versions of the GNU C Library before 2.25 required that a custom
  3370. ‘malloc’ defines ‘__libc_memalign’ (with the same interface as the
  3371. ‘memalign’ function).
  3372. 
  3373. File: libc.info, Node: Obstacks, Next: Variable Size Automatic, Prev: Replacing malloc, Up: Memory Allocation
  3374. 3.2.6 Obstacks
  3375. --------------
  3376. An “obstack” is a pool of memory containing a stack of objects. You can
  3377. create any number of separate obstacks, and then allocate objects in
  3378. specified obstacks. Within each obstack, the last object allocated must
  3379. always be the first one freed, but distinct obstacks are independent of
  3380. each other.
  3381. Aside from this one constraint of order of freeing, obstacks are
  3382. totally general: an obstack can contain any number of objects of any
  3383. size. They are implemented with macros, so allocation is usually very
  3384. fast as long as the objects are usually small. And the only space
  3385. overhead per object is the padding needed to start each object on a
  3386. suitable boundary.
  3387. * Menu:
  3388. * Creating Obstacks:: How to declare an obstack in your program.
  3389. * Preparing for Obstacks:: Preparations needed before you can
  3390. use obstacks.
  3391. * Allocation in an Obstack:: Allocating objects in an obstack.
  3392. * Freeing Obstack Objects:: Freeing objects in an obstack.
  3393. * Obstack Functions:: The obstack functions are both
  3394. functions and macros.
  3395. * Growing Objects:: Making an object bigger by stages.
  3396. * Extra Fast Growing:: Extra-high-efficiency (though more
  3397. complicated) growing objects.
  3398. * Status of an Obstack:: Inquiries about the status of an obstack.
  3399. * Obstacks Data Alignment:: Controlling alignment of objects in obstacks.
  3400. * Obstack Chunks:: How obstacks obtain and release chunks;
  3401. efficiency considerations.
  3402. * Summary of Obstacks::
  3403. 
  3404. File: libc.info, Node: Creating Obstacks, Next: Preparing for Obstacks, Up: Obstacks
  3405. 3.2.6.1 Creating Obstacks
  3406. .........................
  3407. The utilities for manipulating obstacks are declared in the header file
  3408. ‘obstack.h’.
  3409. -- Data Type: struct obstack
  3410. An obstack is represented by a data structure of type ‘struct
  3411. obstack’. This structure has a small fixed size; it records the
  3412. status of the obstack and how to find the space in which objects
  3413. are allocated. It does not contain any of the objects themselves.
  3414. You should not try to access the contents of the structure
  3415. directly; use only the functions described in this chapter.
  3416. You can declare variables of type ‘struct obstack’ and use them as
  3417. obstacks, or you can allocate obstacks dynamically like any other kind
  3418. of object. Dynamic allocation of obstacks allows your program to have a
  3419. variable number of different stacks. (You can even allocate an obstack
  3420. structure in another obstack, but this is rarely useful.)
  3421. All the functions that work with obstacks require you to specify
  3422. which obstack to use. You do this with a pointer of type ‘struct
  3423. obstack *’. In the following, we often say "an obstack" when strictly
  3424. speaking the object at hand is such a pointer.
  3425. The objects in the obstack are packed into large blocks called
  3426. “chunks”. The ‘struct obstack’ structure points to a chain of the
  3427. chunks currently in use.
  3428. The obstack library obtains a new chunk whenever you allocate an
  3429. object that won't fit in the previous chunk. Since the obstack library
  3430. manages chunks automatically, you don't need to pay much attention to
  3431. them, but you do need to supply a function which the obstack library
  3432. should use to get a chunk. Usually you supply a function which uses
  3433. ‘malloc’ directly or indirectly. You must also supply a function to
  3434. free a chunk. These matters are described in the following section.
  3435. 
  3436. File: libc.info, Node: Preparing for Obstacks, Next: Allocation in an Obstack, Prev: Creating Obstacks, Up: Obstacks
  3437. 3.2.6.2 Preparing for Using Obstacks
  3438. ....................................
  3439. Each source file in which you plan to use the obstack functions must
  3440. include the header file ‘obstack.h’, like this:
  3441. #include <obstack.h>
  3442. Also, if the source file uses the macro ‘obstack_init’, it must
  3443. declare or define two functions or macros that will be called by the
  3444. obstack library. One, ‘obstack_chunk_alloc’, is used to allocate the
  3445. chunks of memory into which objects are packed. The other,
  3446. ‘obstack_chunk_free’, is used to return chunks when the objects in them
  3447. are freed. These macros should appear before any use of obstacks in the
  3448. source file.
  3449. Usually these are defined to use ‘malloc’ via the intermediary
  3450. ‘xmalloc’ (*note Unconstrained Allocation::). This is done with the
  3451. following pair of macro definitions:
  3452. #define obstack_chunk_alloc xmalloc
  3453. #define obstack_chunk_free free
  3454. Though the memory you get using obstacks really comes from ‘malloc’,
  3455. using obstacks is faster because ‘malloc’ is called less often, for
  3456. larger blocks of memory. *Note Obstack Chunks::, for full details.
  3457. At run time, before the program can use a ‘struct obstack’ object as
  3458. an obstack, it must initialize the obstack by calling ‘obstack_init’.
  3459. -- Function: int obstack_init (struct obstack *OBSTACK-PTR)
  3460. Preliminary: | MT-Safe race:obstack-ptr | AS-Safe | AC-Safe mem |
  3461. *Note POSIX Safety Concepts::.
  3462. Initialize obstack OBSTACK-PTR for allocation of objects. This
  3463. function calls the obstack's ‘obstack_chunk_alloc’ function. If
  3464. allocation of memory fails, the function pointed to by
  3465. ‘obstack_alloc_failed_handler’ is called. The ‘obstack_init’
  3466. function always returns 1 (Compatibility notice: Former versions of
  3467. obstack returned 0 if allocation failed).
  3468. Here are two examples of how to allocate the space for an obstack and
  3469. initialize it. First, an obstack that is a static variable:
  3470. static struct obstack myobstack;
  3471. ...
  3472. obstack_init (&myobstack);
  3473. Second, an obstack that is itself dynamically allocated:
  3474. struct obstack *myobstack_ptr
  3475. = (struct obstack *) xmalloc (sizeof (struct obstack));
  3476. obstack_init (myobstack_ptr);
  3477. -- Variable: obstack_alloc_failed_handler
  3478. The value of this variable is a pointer to a function that
  3479. ‘obstack’ uses when ‘obstack_chunk_alloc’ fails to allocate memory.
  3480. The default action is to print a message and abort. You should
  3481. supply a function that either calls ‘exit’ (*note Program
  3482. Termination::) or ‘longjmp’ (*note Non-Local Exits::) and doesn't
  3483. return.
  3484. void my_obstack_alloc_failed (void)
  3485. ...
  3486. obstack_alloc_failed_handler = &my_obstack_alloc_failed;
  3487. 
  3488. File: libc.info, Node: Allocation in an Obstack, Next: Freeing Obstack Objects, Prev: Preparing for Obstacks, Up: Obstacks
  3489. 3.2.6.3 Allocation in an Obstack
  3490. ................................
  3491. The most direct way to allocate an object in an obstack is with
  3492. ‘obstack_alloc’, which is invoked almost like ‘malloc’.
  3493. -- Function: void * obstack_alloc (struct obstack *OBSTACK-PTR, int
  3494. SIZE)
  3495. Preliminary: | MT-Safe race:obstack-ptr | AS-Safe | AC-Unsafe
  3496. corrupt mem | *Note POSIX Safety Concepts::.
  3497. This allocates an uninitialized block of SIZE bytes in an obstack
  3498. and returns its address. Here OBSTACK-PTR specifies which obstack
  3499. to allocate the block in; it is the address of the ‘struct obstack’
  3500. object which represents the obstack. Each obstack function or
  3501. macro requires you to specify an OBSTACK-PTR as the first argument.
  3502. This function calls the obstack's ‘obstack_chunk_alloc’ function if
  3503. it needs to allocate a new chunk of memory; it calls
  3504. ‘obstack_alloc_failed_handler’ if allocation of memory by
  3505. ‘obstack_chunk_alloc’ failed.
  3506. For example, here is a function that allocates a copy of a string STR
  3507. in a specific obstack, which is in the variable ‘string_obstack’:
  3508. struct obstack string_obstack;
  3509. char *
  3510. copystring (char *string)
  3511. {
  3512. size_t len = strlen (string) + 1;
  3513. char *s = (char *) obstack_alloc (&string_obstack, len);
  3514. memcpy (s, string, len);
  3515. return s;
  3516. }
  3517. To allocate a block with specified contents, use the function
  3518. ‘obstack_copy’, declared like this:
  3519. -- Function: void * obstack_copy (struct obstack *OBSTACK-PTR, void
  3520. *ADDRESS, int SIZE)
  3521. Preliminary: | MT-Safe race:obstack-ptr | AS-Safe | AC-Unsafe
  3522. corrupt mem | *Note POSIX Safety Concepts::.
  3523. This allocates a block and initializes it by copying SIZE bytes of
  3524. data starting at ADDRESS. It calls ‘obstack_alloc_failed_handler’
  3525. if allocation of memory by ‘obstack_chunk_alloc’ failed.
  3526. -- Function: void * obstack_copy0 (struct obstack *OBSTACK-PTR, void
  3527. *ADDRESS, int SIZE)
  3528. Preliminary: | MT-Safe race:obstack-ptr | AS-Safe | AC-Unsafe
  3529. corrupt mem | *Note POSIX Safety Concepts::.
  3530. Like ‘obstack_copy’, but appends an extra byte containing a null
  3531. character. This extra byte is not counted in the argument SIZE.
  3532. The ‘obstack_copy0’ function is convenient for copying a sequence of
  3533. characters into an obstack as a null-terminated string. Here is an
  3534. example of its use:
  3535. char *
  3536. obstack_savestring (char *addr, int size)
  3537. {
  3538. return obstack_copy0 (&myobstack, addr, size);
  3539. }
  3540. Contrast this with the previous example of ‘savestring’ using ‘malloc’
  3541. (*note Basic Allocation::).
  3542. 
  3543. File: libc.info, Node: Freeing Obstack Objects, Next: Obstack Functions, Prev: Allocation in an Obstack, Up: Obstacks
  3544. 3.2.6.4 Freeing Objects in an Obstack
  3545. .....................................
  3546. To free an object allocated in an obstack, use the function
  3547. ‘obstack_free’. Since the obstack is a stack of objects, freeing one
  3548. object automatically frees all other objects allocated more recently in
  3549. the same obstack.
  3550. -- Function: void obstack_free (struct obstack *OBSTACK-PTR, void
  3551. *OBJECT)
  3552. Preliminary: | MT-Safe race:obstack-ptr | AS-Safe | AC-Unsafe
  3553. corrupt | *Note POSIX Safety Concepts::.
  3554. If OBJECT is a null pointer, everything allocated in the obstack is
  3555. freed. Otherwise, OBJECT must be the address of an object
  3556. allocated in the obstack. Then OBJECT is freed, along with
  3557. everything allocated in OBSTACK-PTR since OBJECT.
  3558. Note that if OBJECT is a null pointer, the result is an uninitialized
  3559. obstack. To free all memory in an obstack but leave it valid for
  3560. further allocation, call ‘obstack_free’ with the address of the first
  3561. object allocated on the obstack:
  3562. obstack_free (obstack_ptr, first_object_allocated_ptr);
  3563. Recall that the objects in an obstack are grouped into chunks. When
  3564. all the objects in a chunk become free, the obstack library
  3565. automatically frees the chunk (*note Preparing for Obstacks::). Then
  3566. other obstacks, or non-obstack allocation, can reuse the space of the
  3567. chunk.
  3568. 
  3569. File: libc.info, Node: Obstack Functions, Next: Growing Objects, Prev: Freeing Obstack Objects, Up: Obstacks
  3570. 3.2.6.5 Obstack Functions and Macros
  3571. ....................................
  3572. The interfaces for using obstacks may be defined either as functions or
  3573. as macros, depending on the compiler. The obstack facility works with
  3574. all C compilers, including both ISO C and traditional C, but there are
  3575. precautions you must take if you plan to use compilers other than GNU C.
  3576. If you are using an old-fashioned non-ISO C compiler, all the obstack
  3577. "functions" are actually defined only as macros. You can call these
  3578. macros like functions, but you cannot use them in any other way (for
  3579. example, you cannot take their address).
  3580. Calling the macros requires a special precaution: namely, the first
  3581. operand (the obstack pointer) may not contain any side effects, because
  3582. it may be computed more than once. For example, if you write this:
  3583. obstack_alloc (get_obstack (), 4);
  3584. you will find that ‘get_obstack’ may be called several times. If you
  3585. use ‘*obstack_list_ptr++’ as the obstack pointer argument, you will get
  3586. very strange results since the incrementation may occur several times.
  3587. In ISO C, each function has both a macro definition and a function
  3588. definition. The function definition is used if you take the address of
  3589. the function without calling it. An ordinary call uses the macro
  3590. definition by default, but you can request the function definition
  3591. instead by writing the function name in parentheses, as shown here:
  3592. char *x;
  3593. void *(*funcp) ();
  3594. /* Use the macro. */
  3595. x = (char *) obstack_alloc (obptr, size);
  3596. /* Call the function. */
  3597. x = (char *) (obstack_alloc) (obptr, size);
  3598. /* Take the address of the function. */
  3599. funcp = obstack_alloc;
  3600. This is the same situation that exists in ISO C for the standard library
  3601. functions. *Note Macro Definitions::.
  3602. *Warning:* When you do use the macros, you must observe the
  3603. precaution of avoiding side effects in the first operand, even in ISO C.
  3604. If you use the GNU C compiler, this precaution is not necessary,
  3605. because various language extensions in GNU C permit defining the macros
  3606. so as to compute each argument only once.
  3607. 
  3608. File: libc.info, Node: Growing Objects, Next: Extra Fast Growing, Prev: Obstack Functions, Up: Obstacks
  3609. 3.2.6.6 Growing Objects
  3610. .......................
  3611. Because memory in obstack chunks is used sequentially, it is possible to
  3612. build up an object step by step, adding one or more bytes at a time to
  3613. the end of the object. With this technique, you do not need to know how
  3614. much data you will put in the object until you come to the end of it.
  3615. We call this the technique of “growing objects”. The special functions
  3616. for adding data to the growing object are described in this section.
  3617. You don't need to do anything special when you start to grow an
  3618. object. Using one of the functions to add data to the object
  3619. automatically starts it. However, it is necessary to say explicitly
  3620. when the object is finished. This is done with the function
  3621. ‘obstack_finish’.
  3622. The actual address of the object thus built up is not known until the
  3623. object is finished. Until then, it always remains possible that you
  3624. will add so much data that the object must be copied into a new chunk.
  3625. While the obstack is in use for a growing object, you cannot use it
  3626. for ordinary allocation of another object. If you try to do so, the
  3627. space already added to the growing object will become part of the other
  3628. object.
  3629. -- Function: void obstack_blank (struct obstack *OBSTACK-PTR, int SIZE)
  3630. Preliminary: | MT-Safe race:obstack-ptr | AS-Safe | AC-Unsafe
  3631. corrupt mem | *Note POSIX Safety Concepts::.
  3632. The most basic function for adding to a growing object is
  3633. ‘obstack_blank’, which adds space without initializing it.
  3634. -- Function: void obstack_grow (struct obstack *OBSTACK-PTR, void
  3635. *DATA, int SIZE)
  3636. Preliminary: | MT-Safe race:obstack-ptr | AS-Safe | AC-Unsafe
  3637. corrupt mem | *Note POSIX Safety Concepts::.
  3638. To add a block of initialized space, use ‘obstack_grow’, which is
  3639. the growing-object analogue of ‘obstack_copy’. It adds SIZE bytes
  3640. of data to the growing object, copying the contents from DATA.
  3641. -- Function: void obstack_grow0 (struct obstack *OBSTACK-PTR, void
  3642. *DATA, int SIZE)
  3643. Preliminary: | MT-Safe race:obstack-ptr | AS-Safe | AC-Unsafe
  3644. corrupt mem | *Note POSIX Safety Concepts::.
  3645. This is the growing-object analogue of ‘obstack_copy0’. It adds
  3646. SIZE bytes copied from DATA, followed by an additional null
  3647. character.
  3648. -- Function: void obstack_1grow (struct obstack *OBSTACK-PTR, char C)
  3649. Preliminary: | MT-Safe race:obstack-ptr | AS-Safe | AC-Unsafe
  3650. corrupt mem | *Note POSIX Safety Concepts::.
  3651. To add one character at a time, use the function ‘obstack_1grow’.
  3652. It adds a single byte containing C to the growing object.
  3653. -- Function: void obstack_ptr_grow (struct obstack *OBSTACK-PTR, void
  3654. *DATA)
  3655. Preliminary: | MT-Safe race:obstack-ptr | AS-Safe | AC-Unsafe
  3656. corrupt mem | *Note POSIX Safety Concepts::.
  3657. Adding the value of a pointer one can use the function
  3658. ‘obstack_ptr_grow’. It adds ‘sizeof (void *)’ bytes containing the
  3659. value of DATA.
  3660. -- Function: void obstack_int_grow (struct obstack *OBSTACK-PTR, int
  3661. DATA)
  3662. Preliminary: | MT-Safe race:obstack-ptr | AS-Safe | AC-Unsafe
  3663. corrupt mem | *Note POSIX Safety Concepts::.
  3664. A single value of type ‘int’ can be added by using the
  3665. ‘obstack_int_grow’ function. It adds ‘sizeof (int)’ bytes to the
  3666. growing object and initializes them with the value of DATA.
  3667. -- Function: void * obstack_finish (struct obstack *OBSTACK-PTR)
  3668. Preliminary: | MT-Safe race:obstack-ptr | AS-Safe | AC-Unsafe
  3669. corrupt | *Note POSIX Safety Concepts::.
  3670. When you are finished growing the object, use the function
  3671. ‘obstack_finish’ to close it off and return its final address.
  3672. Once you have finished the object, the obstack is available for
  3673. ordinary allocation or for growing another object.
  3674. This function can return a null pointer under the same conditions
  3675. as ‘obstack_alloc’ (*note Allocation in an Obstack::).
  3676. When you build an object by growing it, you will probably need to
  3677. know afterward how long it became. You need not keep track of this as
  3678. you grow the object, because you can find out the length from the
  3679. obstack just before finishing the object with the function
  3680. ‘obstack_object_size’, declared as follows:
  3681. -- Function: int obstack_object_size (struct obstack *OBSTACK-PTR)
  3682. Preliminary: | MT-Safe race:obstack-ptr | AS-Safe | AC-Safe | *Note
  3683. POSIX Safety Concepts::.
  3684. This function returns the current size of the growing object, in
  3685. bytes. Remember to call this function _before_ finishing the
  3686. object. After it is finished, ‘obstack_object_size’ will return
  3687. zero.
  3688. If you have started growing an object and wish to cancel it, you
  3689. should finish it and then free it, like this:
  3690. obstack_free (obstack_ptr, obstack_finish (obstack_ptr));
  3691. This has no effect if no object was growing.
  3692. You can use ‘obstack_blank’ with a negative size argument to make the
  3693. current object smaller. Just don't try to shrink it beyond zero
  3694. length--there's no telling what will happen if you do that.
  3695. 
  3696. File: libc.info, Node: Extra Fast Growing, Next: Status of an Obstack, Prev: Growing Objects, Up: Obstacks
  3697. 3.2.6.7 Extra Fast Growing Objects
  3698. ..................................
  3699. The usual functions for growing objects incur overhead for checking
  3700. whether there is room for the new growth in the current chunk. If you
  3701. are frequently constructing objects in small steps of growth, this
  3702. overhead can be significant.
  3703. You can reduce the overhead by using special "fast growth" functions
  3704. that grow the object without checking. In order to have a robust
  3705. program, you must do the checking yourself. If you do this checking in
  3706. the simplest way each time you are about to add data to the object, you
  3707. have not saved anything, because that is what the ordinary growth
  3708. functions do. But if you can arrange to check less often, or check more
  3709. efficiently, then you make the program faster.
  3710. The function ‘obstack_room’ returns the amount of room available in
  3711. the current chunk. It is declared as follows:
  3712. -- Function: int obstack_room (struct obstack *OBSTACK-PTR)
  3713. Preliminary: | MT-Safe race:obstack-ptr | AS-Safe | AC-Safe | *Note
  3714. POSIX Safety Concepts::.
  3715. This returns the number of bytes that can be added safely to the
  3716. current growing object (or to an object about to be started) in
  3717. obstack OBSTACK-PTR using the fast growth functions.
  3718. While you know there is room, you can use these fast growth functions
  3719. for adding data to a growing object:
  3720. -- Function: void obstack_1grow_fast (struct obstack *OBSTACK-PTR, char
  3721. C)
  3722. Preliminary: | MT-Safe race:obstack-ptr | AS-Safe | AC-Unsafe
  3723. corrupt mem | *Note POSIX Safety Concepts::.
  3724. The function ‘obstack_1grow_fast’ adds one byte containing the
  3725. character C to the growing object in obstack OBSTACK-PTR.
  3726. -- Function: void obstack_ptr_grow_fast (struct obstack *OBSTACK-PTR,
  3727. void *DATA)
  3728. Preliminary: | MT-Safe race:obstack-ptr | AS-Safe | AC-Safe | *Note
  3729. POSIX Safety Concepts::.
  3730. The function ‘obstack_ptr_grow_fast’ adds ‘sizeof (void *)’ bytes
  3731. containing the value of DATA to the growing object in obstack
  3732. OBSTACK-PTR.
  3733. -- Function: void obstack_int_grow_fast (struct obstack *OBSTACK-PTR,
  3734. int DATA)
  3735. Preliminary: | MT-Safe race:obstack-ptr | AS-Safe | AC-Safe | *Note
  3736. POSIX Safety Concepts::.
  3737. The function ‘obstack_int_grow_fast’ adds ‘sizeof (int)’ bytes
  3738. containing the value of DATA to the growing object in obstack
  3739. OBSTACK-PTR.
  3740. -- Function: void obstack_blank_fast (struct obstack *OBSTACK-PTR, int
  3741. SIZE)
  3742. Preliminary: | MT-Safe race:obstack-ptr | AS-Safe | AC-Safe | *Note
  3743. POSIX Safety Concepts::.
  3744. The function ‘obstack_blank_fast’ adds SIZE bytes to the growing
  3745. object in obstack OBSTACK-PTR without initializing them.
  3746. When you check for space using ‘obstack_room’ and there is not enough
  3747. room for what you want to add, the fast growth functions are not safe.
  3748. In this case, simply use the corresponding ordinary growth function
  3749. instead. Very soon this will copy the object to a new chunk; then there
  3750. will be lots of room available again.
  3751. So, each time you use an ordinary growth function, check afterward
  3752. for sufficient space using ‘obstack_room’. Once the object is copied to
  3753. a new chunk, there will be plenty of space again, so the program will
  3754. start using the fast growth functions again.
  3755. Here is an example:
  3756. void
  3757. add_string (struct obstack *obstack, const char *ptr, int len)
  3758. {
  3759. while (len > 0)
  3760. {
  3761. int room = obstack_room (obstack);
  3762. if (room == 0)
  3763. {
  3764. /* Not enough room. Add one character slowly,
  3765. which may copy to a new chunk and make room. */
  3766. obstack_1grow (obstack, *ptr++);
  3767. len--;
  3768. }
  3769. else
  3770. {
  3771. if (room > len)
  3772. room = len;
  3773. /* Add fast as much as we have room for. */
  3774. len -= room;
  3775. while (room-- > 0)
  3776. obstack_1grow_fast (obstack, *ptr++);
  3777. }
  3778. }
  3779. }
  3780. 
  3781. File: libc.info, Node: Status of an Obstack, Next: Obstacks Data Alignment, Prev: Extra Fast Growing, Up: Obstacks
  3782. 3.2.6.8 Status of an Obstack
  3783. ............................
  3784. Here are functions that provide information on the current status of
  3785. allocation in an obstack. You can use them to learn about an object
  3786. while still growing it.
  3787. -- Function: void * obstack_base (struct obstack *OBSTACK-PTR)
  3788. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Safe | *Note POSIX
  3789. Safety Concepts::.
  3790. This function returns the tentative address of the beginning of the
  3791. currently growing object in OBSTACK-PTR. If you finish the object
  3792. immediately, it will have that address. If you make it larger
  3793. first, it may outgrow the current chunk--then its address will
  3794. change!
  3795. If no object is growing, this value says where the next object you
  3796. allocate will start (once again assuming it fits in the current
  3797. chunk).
  3798. -- Function: void * obstack_next_free (struct obstack *OBSTACK-PTR)
  3799. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Safe | *Note POSIX
  3800. Safety Concepts::.
  3801. This function returns the address of the first free byte in the
  3802. current chunk of obstack OBSTACK-PTR. This is the end of the
  3803. currently growing object. If no object is growing,
  3804. ‘obstack_next_free’ returns the same value as ‘obstack_base’.
  3805. -- Function: int obstack_object_size (struct obstack *OBSTACK-PTR)
  3806. Preliminary: | MT-Safe race:obstack-ptr | AS-Safe | AC-Safe | *Note
  3807. POSIX Safety Concepts::.
  3808. This function returns the size in bytes of the currently growing
  3809. object. This is equivalent to
  3810. obstack_next_free (OBSTACK-PTR) - obstack_base (OBSTACK-PTR)
  3811. 
  3812. File: libc.info, Node: Obstacks Data Alignment, Next: Obstack Chunks, Prev: Status of an Obstack, Up: Obstacks
  3813. 3.2.6.9 Alignment of Data in Obstacks
  3814. .....................................
  3815. Each obstack has an “alignment boundary”; each object allocated in the
  3816. obstack automatically starts on an address that is a multiple of the
  3817. specified boundary. By default, this boundary is aligned so that the
  3818. object can hold any type of data.
  3819. To access an obstack's alignment boundary, use the macro
  3820. ‘obstack_alignment_mask’, whose function prototype looks like this:
  3821. -- Macro: int obstack_alignment_mask (struct obstack *OBSTACK-PTR)
  3822. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3823. Concepts::.
  3824. The value is a bit mask; a bit that is 1 indicates that the
  3825. corresponding bit in the address of an object should be 0. The
  3826. mask value should be one less than a power of 2; the effect is that
  3827. all object addresses are multiples of that power of 2. The default
  3828. value of the mask is a value that allows aligned objects to hold
  3829. any type of data: for example, if its value is 3, any type of data
  3830. can be stored at locations whose addresses are multiples of 4. A
  3831. mask value of 0 means an object can start on any multiple of 1
  3832. (that is, no alignment is required).
  3833. The expansion of the macro ‘obstack_alignment_mask’ is an lvalue,
  3834. so you can alter the mask by assignment. For example, this
  3835. statement:
  3836. obstack_alignment_mask (obstack_ptr) = 0;
  3837. has the effect of turning off alignment processing in the specified
  3838. obstack.
  3839. Note that a change in alignment mask does not take effect until
  3840. _after_ the next time an object is allocated or finished in the obstack.
  3841. If you are not growing an object, you can make the new alignment mask
  3842. take effect immediately by calling ‘obstack_finish’. This will finish a
  3843. zero-length object and then do proper alignment for the next object.
  3844. 
  3845. File: libc.info, Node: Obstack Chunks, Next: Summary of Obstacks, Prev: Obstacks Data Alignment, Up: Obstacks
  3846. 3.2.6.10 Obstack Chunks
  3847. .......................
  3848. Obstacks work by allocating space for themselves in large chunks, and
  3849. then parceling out space in the chunks to satisfy your requests. Chunks
  3850. are normally 4096 bytes long unless you specify a different chunk size.
  3851. The chunk size includes 8 bytes of overhead that are not actually used
  3852. for storing objects. Regardless of the specified size, longer chunks
  3853. will be allocated when necessary for long objects.
  3854. The obstack library allocates chunks by calling the function
  3855. ‘obstack_chunk_alloc’, which you must define. When a chunk is no longer
  3856. needed because you have freed all the objects in it, the obstack library
  3857. frees the chunk by calling ‘obstack_chunk_free’, which you must also
  3858. define.
  3859. These two must be defined (as macros) or declared (as functions) in
  3860. each source file that uses ‘obstack_init’ (*note Creating Obstacks::).
  3861. Most often they are defined as macros like this:
  3862. #define obstack_chunk_alloc malloc
  3863. #define obstack_chunk_free free
  3864. Note that these are simple macros (no arguments). Macro definitions
  3865. with arguments will not work! It is necessary that
  3866. ‘obstack_chunk_alloc’ or ‘obstack_chunk_free’, alone, expand into a
  3867. function name if it is not itself a function name.
  3868. If you allocate chunks with ‘malloc’, the chunk size should be a
  3869. power of 2. The default chunk size, 4096, was chosen because it is long
  3870. enough to satisfy many typical requests on the obstack yet short enough
  3871. not to waste too much memory in the portion of the last chunk not yet
  3872. used.
  3873. -- Macro: int obstack_chunk_size (struct obstack *OBSTACK-PTR)
  3874. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3875. Concepts::.
  3876. This returns the chunk size of the given obstack.
  3877. Since this macro expands to an lvalue, you can specify a new chunk
  3878. size by assigning it a new value. Doing so does not affect the chunks
  3879. already allocated, but will change the size of chunks allocated for that
  3880. particular obstack in the future. It is unlikely to be useful to make
  3881. the chunk size smaller, but making it larger might improve efficiency if
  3882. you are allocating many objects whose size is comparable to the chunk
  3883. size. Here is how to do so cleanly:
  3884. if (obstack_chunk_size (obstack_ptr) < NEW-CHUNK-SIZE)
  3885. obstack_chunk_size (obstack_ptr) = NEW-CHUNK-SIZE;
  3886. 
  3887. File: libc.info, Node: Summary of Obstacks, Prev: Obstack Chunks, Up: Obstacks
  3888. 3.2.6.11 Summary of Obstack Functions
  3889. .....................................
  3890. Here is a summary of all the functions associated with obstacks. Each
  3891. takes the address of an obstack (‘struct obstack *’) as its first
  3892. argument.
  3893. ‘void obstack_init (struct obstack *OBSTACK-PTR)’
  3894. Initialize use of an obstack. *Note Creating Obstacks::.
  3895. ‘void *obstack_alloc (struct obstack *OBSTACK-PTR, int SIZE)’
  3896. Allocate an object of SIZE uninitialized bytes. *Note Allocation
  3897. in an Obstack::.
  3898. ‘void *obstack_copy (struct obstack *OBSTACK-PTR, void *ADDRESS, int SIZE)’
  3899. Allocate an object of SIZE bytes, with contents copied from
  3900. ADDRESS. *Note Allocation in an Obstack::.
  3901. ‘void *obstack_copy0 (struct obstack *OBSTACK-PTR, void *ADDRESS, int SIZE)’
  3902. Allocate an object of SIZE+1 bytes, with SIZE of them copied from
  3903. ADDRESS, followed by a null character at the end. *Note Allocation
  3904. in an Obstack::.
  3905. ‘void obstack_free (struct obstack *OBSTACK-PTR, void *OBJECT)’
  3906. Free OBJECT (and everything allocated in the specified obstack more
  3907. recently than OBJECT). *Note Freeing Obstack Objects::.
  3908. ‘void obstack_blank (struct obstack *OBSTACK-PTR, int SIZE)’
  3909. Add SIZE uninitialized bytes to a growing object. *Note Growing
  3910. Objects::.
  3911. ‘void obstack_grow (struct obstack *OBSTACK-PTR, void *ADDRESS, int SIZE)’
  3912. Add SIZE bytes, copied from ADDRESS, to a growing object. *Note
  3913. Growing Objects::.
  3914. ‘void obstack_grow0 (struct obstack *OBSTACK-PTR, void *ADDRESS, int SIZE)’
  3915. Add SIZE bytes, copied from ADDRESS, to a growing object, and then
  3916. add another byte containing a null character. *Note Growing
  3917. Objects::.
  3918. ‘void obstack_1grow (struct obstack *OBSTACK-PTR, char DATA-CHAR)’
  3919. Add one byte containing DATA-CHAR to a growing object. *Note
  3920. Growing Objects::.
  3921. ‘void *obstack_finish (struct obstack *OBSTACK-PTR)’
  3922. Finalize the object that is growing and return its permanent
  3923. address. *Note Growing Objects::.
  3924. ‘int obstack_object_size (struct obstack *OBSTACK-PTR)’
  3925. Get the current size of the currently growing object. *Note
  3926. Growing Objects::.
  3927. ‘void obstack_blank_fast (struct obstack *OBSTACK-PTR, int SIZE)’
  3928. Add SIZE uninitialized bytes to a growing object without checking
  3929. that there is enough room. *Note Extra Fast Growing::.
  3930. ‘void obstack_1grow_fast (struct obstack *OBSTACK-PTR, char DATA-CHAR)’
  3931. Add one byte containing DATA-CHAR to a growing object without
  3932. checking that there is enough room. *Note Extra Fast Growing::.
  3933. ‘int obstack_room (struct obstack *OBSTACK-PTR)’
  3934. Get the amount of room now available for growing the current
  3935. object. *Note Extra Fast Growing::.
  3936. ‘int obstack_alignment_mask (struct obstack *OBSTACK-PTR)’
  3937. The mask used for aligning the beginning of an object. This is an
  3938. lvalue. *Note Obstacks Data Alignment::.
  3939. ‘int obstack_chunk_size (struct obstack *OBSTACK-PTR)’
  3940. The size for allocating chunks. This is an lvalue. *Note Obstack
  3941. Chunks::.
  3942. ‘void *obstack_base (struct obstack *OBSTACK-PTR)’
  3943. Tentative starting address of the currently growing object. *Note
  3944. Status of an Obstack::.
  3945. ‘void *obstack_next_free (struct obstack *OBSTACK-PTR)’
  3946. Address just after the end of the currently growing object. *Note
  3947. Status of an Obstack::.
  3948. 
  3949. File: libc.info, Node: Variable Size Automatic, Prev: Obstacks, Up: Memory Allocation
  3950. 3.2.7 Automatic Storage with Variable Size
  3951. ------------------------------------------
  3952. The function ‘alloca’ supports a kind of half-dynamic allocation in
  3953. which blocks are allocated dynamically but freed automatically.
  3954. Allocating a block with ‘alloca’ is an explicit action; you can
  3955. allocate as many blocks as you wish, and compute the size at run time.
  3956. But all the blocks are freed when you exit the function that ‘alloca’
  3957. was called from, just as if they were automatic variables declared in
  3958. that function. There is no way to free the space explicitly.
  3959. The prototype for ‘alloca’ is in ‘stdlib.h’. This function is a BSD
  3960. extension.
  3961. -- Function: void * alloca (size_t SIZE)
  3962. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3963. Concepts::.
  3964. The return value of ‘alloca’ is the address of a block of SIZE
  3965. bytes of memory, allocated in the stack frame of the calling
  3966. function.
  3967. Do not use ‘alloca’ inside the arguments of a function call--you will
  3968. get unpredictable results, because the stack space for the ‘alloca’
  3969. would appear on the stack in the middle of the space for the function
  3970. arguments. An example of what to avoid is ‘foo (x, alloca (4), y)’.
  3971. * Menu:
  3972. * Alloca Example:: Example of using ‘alloca’.
  3973. * Advantages of Alloca:: Reasons to use ‘alloca’.
  3974. * Disadvantages of Alloca:: Reasons to avoid ‘alloca’.
  3975. * GNU C Variable-Size Arrays:: Only in GNU C, here is an alternative
  3976. method of allocating dynamically and
  3977. freeing automatically.
  3978. 
  3979. File: libc.info, Node: Alloca Example, Next: Advantages of Alloca, Up: Variable Size Automatic
  3980. 3.2.7.1 ‘alloca’ Example
  3981. ........................
  3982. As an example of the use of ‘alloca’, here is a function that opens a
  3983. file name made from concatenating two argument strings, and returns a
  3984. file descriptor or minus one signifying failure:
  3985. int
  3986. open2 (char *str1, char *str2, int flags, int mode)
  3987. {
  3988. char *name = (char *) alloca (strlen (str1) + strlen (str2) + 1);
  3989. stpcpy (stpcpy (name, str1), str2);
  3990. return open (name, flags, mode);
  3991. }
  3992. Here is how you would get the same results with ‘malloc’ and ‘free’:
  3993. int
  3994. open2 (char *str1, char *str2, int flags, int mode)
  3995. {
  3996. char *name = malloc (strlen (str1) + strlen (str2) + 1);
  3997. int desc;
  3998. if (name == 0)
  3999. fatal ("virtual memory exceeded");
  4000. stpcpy (stpcpy (name, str1), str2);
  4001. desc = open (name, flags, mode);
  4002. free (name);
  4003. return desc;
  4004. }
  4005. As you can see, it is simpler with ‘alloca’. But ‘alloca’ has other,
  4006. more important advantages, and some disadvantages.
  4007. 
  4008. File: libc.info, Node: Advantages of Alloca, Next: Disadvantages of Alloca, Prev: Alloca Example, Up: Variable Size Automatic
  4009. 3.2.7.2 Advantages of ‘alloca’
  4010. ..............................
  4011. Here are the reasons why ‘alloca’ may be preferable to ‘malloc’:
  4012. • Using ‘alloca’ wastes very little space and is very fast. (It is
  4013. open-coded by the GNU C compiler.)
  4014. • Since ‘alloca’ does not have separate pools for different sizes of
  4015. blocks, space used for any size block can be reused for any other
  4016. size. ‘alloca’ does not cause memory fragmentation.
  4017. • Nonlocal exits done with ‘longjmp’ (*note Non-Local Exits::)
  4018. automatically free the space allocated with ‘alloca’ when they exit
  4019. through the function that called ‘alloca’. This is the most
  4020. important reason to use ‘alloca’.
  4021. To illustrate this, suppose you have a function
  4022. ‘open_or_report_error’ which returns a descriptor, like ‘open’, if
  4023. it succeeds, but does not return to its caller if it fails. If the
  4024. file cannot be opened, it prints an error message and jumps out to
  4025. the command level of your program using ‘longjmp’. Let's change
  4026. ‘open2’ (*note Alloca Example::) to use this subroutine:
  4027. int
  4028. open2 (char *str1, char *str2, int flags, int mode)
  4029. {
  4030. char *name = (char *) alloca (strlen (str1) + strlen (str2) + 1);
  4031. stpcpy (stpcpy (name, str1), str2);
  4032. return open_or_report_error (name, flags, mode);
  4033. }
  4034. Because of the way ‘alloca’ works, the memory it allocates is freed
  4035. even when an error occurs, with no special effort required.
  4036. By contrast, the previous definition of ‘open2’ (which uses
  4037. ‘malloc’ and ‘free’) would develop a memory leak if it were changed
  4038. in this way. Even if you are willing to make more changes to fix
  4039. it, there is no easy way to do so.
  4040. 
  4041. File: libc.info, Node: Disadvantages of Alloca, Next: GNU C Variable-Size Arrays, Prev: Advantages of Alloca, Up: Variable Size Automatic
  4042. 3.2.7.3 Disadvantages of ‘alloca’
  4043. .................................
  4044. These are the disadvantages of ‘alloca’ in comparison with ‘malloc’:
  4045. • If you try to allocate more memory than the machine can provide,
  4046. you don't get a clean error message. Instead you get a fatal
  4047. signal like the one you would get from an infinite recursion;
  4048. probably a segmentation violation (*note Program Error Signals::).
  4049. • Some non-GNU systems fail to support ‘alloca’, so it is less
  4050. portable. However, a slower emulation of ‘alloca’ written in C is
  4051. available for use on systems with this deficiency.
  4052. 
  4053. File: libc.info, Node: GNU C Variable-Size Arrays, Prev: Disadvantages of Alloca, Up: Variable Size Automatic
  4054. 3.2.7.4 GNU C Variable-Size Arrays
  4055. ..................................
  4056. In GNU C, you can replace most uses of ‘alloca’ with an array of
  4057. variable size. Here is how ‘open2’ would look then:
  4058. int open2 (char *str1, char *str2, int flags, int mode)
  4059. {
  4060. char name[strlen (str1) + strlen (str2) + 1];
  4061. stpcpy (stpcpy (name, str1), str2);
  4062. return open (name, flags, mode);
  4063. }
  4064. But ‘alloca’ is not always equivalent to a variable-sized array, for
  4065. several reasons:
  4066. • A variable size array's space is freed at the end of the scope of
  4067. the name of the array. The space allocated with ‘alloca’ remains
  4068. until the end of the function.
  4069. • It is possible to use ‘alloca’ within a loop, allocating an
  4070. additional block on each iteration. This is impossible with
  4071. variable-sized arrays.
  4072. *NB:* If you mix use of ‘alloca’ and variable-sized arrays within one
  4073. function, exiting a scope in which a variable-sized array was declared
  4074. frees all blocks allocated with ‘alloca’ during the execution of that
  4075. scope.
  4076. 
  4077. File: libc.info, Node: Resizing the Data Segment, Next: Memory Protection, Prev: Memory Allocation, Up: Memory
  4078. 3.3 Resizing the Data Segment
  4079. =============================
  4080. The symbols in this section are declared in ‘unistd.h’.
  4081. You will not normally use the functions in this section, because the
  4082. functions described in *note Memory Allocation:: are easier to use.
  4083. Those are interfaces to a GNU C Library memory allocator that uses the
  4084. functions below itself. The functions below are simple interfaces to
  4085. system calls.
  4086. -- Function: int brk (void *ADDR)
  4087. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4088. Concepts::.
  4089. ‘brk’ sets the high end of the calling process' data segment to
  4090. ADDR.
  4091. The address of the end of a segment is defined to be the address of
  4092. the last byte in the segment plus 1.
  4093. The function has no effect if ADDR is lower than the low end of the
  4094. data segment. (This is considered success, by the way.)
  4095. The function fails if it would cause the data segment to overlap
  4096. another segment or exceed the process' data storage limit (*note
  4097. Limits on Resources::).
  4098. The function is named for a common historical case where data
  4099. storage and the stack are in the same segment. Data storage
  4100. allocation grows upward from the bottom of the segment while the
  4101. stack grows downward toward it from the top of the segment and the
  4102. curtain between them is called the “break”.
  4103. The return value is zero on success. On failure, the return value
  4104. is ‘-1’ and ‘errno’ is set accordingly. The following ‘errno’
  4105. values are specific to this function:
  4106. ‘ENOMEM’
  4107. The request would cause the data segment to overlap another
  4108. segment or exceed the process' data storage limit.
  4109. -- Function: void * sbrk (ptrdiff_t DELTA)
  4110. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4111. Concepts::.
  4112. This function is the same as ‘brk’ except that you specify the new
  4113. end of the data segment as an offset DELTA from the current end and
  4114. on success the return value is the address of the resulting end of
  4115. the data segment instead of zero.
  4116. This means you can use ‘sbrk(0)’ to find out what the current end
  4117. of the data segment is.
  4118. 
  4119. File: libc.info, Node: Memory Protection, Next: Locking Pages, Prev: Resizing the Data Segment, Up: Memory
  4120. 3.4 Memory Protection
  4121. =====================
  4122. When a page is mapped using ‘mmap’, page protection flags can be
  4123. specified using the protection flags argument. *Note Memory-mapped
  4124. I/O::.
  4125. The following flags are available:
  4126. ‘PROT_WRITE’
  4127. The memory can be written to.
  4128. ‘PROT_READ’
  4129. The memory can be read. On some architectures, this flag implies
  4130. that the memory can be executed as well (as if ‘PROT_EXEC’ had been
  4131. specified at the same time).
  4132. ‘PROT_EXEC’
  4133. The memory can be used to store instructions which can then be
  4134. executed. On most architectures, this flag implies that the memory
  4135. can be read (as if ‘PROT_READ’ had been specified).
  4136. ‘PROT_NONE’
  4137. This flag must be specified on its own.
  4138. The memory is reserved, but cannot be read, written, or executed.
  4139. If this flag is specified in a call to ‘mmap’, a virtual memory
  4140. area will be set aside for future use in the process, and ‘mmap’
  4141. calls without the ‘MAP_FIXED’ flag will not use it for subsequent
  4142. allocations. For anonymous mappings, the kernel will not reserve
  4143. any physical memory for the allocation at the time the mapping is
  4144. created.
  4145. The operating system may keep track of these flags separately even if
  4146. the underlying hardware treats them the same for the purposes of access
  4147. checking (as happens with ‘PROT_READ’ and ‘PROT_EXEC’ on some
  4148. platforms). On GNU systems, ‘PROT_EXEC’ always implies ‘PROT_READ’, so
  4149. that users can view the machine code which is executing on their system.
  4150. Inappropriate access will cause a segfault (*note Program Error
  4151. Signals::).
  4152. After allocation, protection flags can be changed using the
  4153. ‘mprotect’ function.
  4154. -- Function: int mprotect (void *ADDRESS, size_t LENGTH, int
  4155. PROTECTION)
  4156. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4157. Concepts::.
  4158. A successful call to the ‘mprotect’ function changes the protection
  4159. flags of at least LENGTH bytes of memory, starting at ADDRESS.
  4160. ADDRESS must be aligned to the page size for the mapping. The
  4161. system page size can be obtained by calling ‘sysconf’ with the
  4162. ‘_SC_PAGESIZE’ parameter (*note Sysconf Definition::). The system
  4163. page size is the granularity in which the page protection of
  4164. anonymous memory mappings and most file mappings can be changed.
  4165. Memory which is mapped from special files or devices may have
  4166. larger page granularity than the system page size and may require
  4167. larger alignment.
  4168. LENGTH is the number of bytes whose protection flags must be
  4169. changed. It is automatically rounded up to the next multiple of
  4170. the system page size.
  4171. PROTECTION is a combination of the ‘PROT_*’ flags described above.
  4172. The ‘mprotect’ function returns 0 on success and -1 on failure.
  4173. The following ‘errno’ error conditions are defined for this
  4174. function:
  4175. ‘ENOMEM’
  4176. The system was not able to allocate resources to fulfill the
  4177. request. This can happen if there is not enough physical
  4178. memory in the system for the allocation of backing storage.
  4179. The error can also occur if the new protection flags would
  4180. cause the memory region to be split from its neighbors, and
  4181. the process limit for the number of such distinct memory
  4182. regions would be exceeded.
  4183. ‘EINVAL’
  4184. ADDRESS is not properly aligned to a page boundary for the
  4185. mapping, or LENGTH (after rounding up to the system page size)
  4186. is not a multiple of the applicable page size for the mapping,
  4187. or the combination of flags in PROTECTION is not valid.
  4188. ‘EACCES’
  4189. The file for a file-based mapping was not opened with open
  4190. flags which are compatible with PROTECTION.
  4191. ‘EPERM’
  4192. The system security policy does not allow a mapping with the
  4193. specified flags. For example, mappings which are both
  4194. ‘PROT_EXEC’ and ‘PROT_WRITE’ at the same time might not be
  4195. allowed.
  4196. If the ‘mprotect’ function is used to make a region of memory
  4197. inaccessible by specifying the ‘PROT_NONE’ protection flag and access is
  4198. later restored, the memory retains its previous contents.
  4199. On some systems, it may not be possible to specify additional flags
  4200. which were not present when the mapping was first created. For example,
  4201. an attempt to make a region of memory executable could fail if the
  4202. initial protection flags were ‘PROT_READ | PROT_WRITE’.
  4203. In general, the ‘mprotect’ function can be used to change any process
  4204. memory, no matter how it was allocated. However, portable use of the
  4205. function requires that it is only used with memory regions returned by
  4206. ‘mmap’ or ‘mmap64’.
  4207. -- Function: int mseal (void *ADDRESS, size_t LENGTH, unsigned long
  4208. FLAGS)
  4209. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4210. Concepts::.
  4211. A successful call to the ‘mseal’ function protects the memory range
  4212. ADDRESS of LENGTH bytes, previously allocated with ‘mmap’ or
  4213. ‘mremap’, against further metadata changes, such as:
  4214. • Unmapping, moving to another location, extending or shrinking
  4215. the size, via ‘munmap’ and ‘mremap’.
  4216. • Moving or expanding a different VMA into the current location,
  4217. via ‘mremap’.
  4218. • Modifying the memory range with ‘mmap’ along with the flag
  4219. ‘MAP_FIXED’.
  4220. • Change the protection flags with ‘mprotect’ or
  4221. ‘pkey_mprotect’. Also for certain destructive ‘madvise’
  4222. behaviours (‘MADV_DONTNEED’, ‘MADV_FREE’,
  4223. ‘MADV_DONTNEED_LOCKED’, and ‘MADV_WIPEONFORK’), ‘mseal’ only
  4224. blocks the operation if the protection key associated with the
  4225. memory denies write.
  4226. • Destructive behaviors on anonymous memory, such as ‘madvise’
  4227. with ‘MADV_DONTNEED’.
  4228. The ADDRESS must be an allocated virtual memory done by ‘mmap’ or
  4229. ‘mremap’, and it must be page-aligned. The end address (ADDRESS
  4230. plus LENGTH) must be within an allocated virtual memory range.
  4231. There should be no unallocated memory between the start and end of
  4232. the address range.
  4233. The FLAGS is currently unused.
  4234. The ‘mseal’ function returns 0 on success and -1 on failure.
  4235. The following ‘errno’ error conditions are defined for this
  4236. function:
  4237. ‘EPERM’
  4238. The system blocked the operation, and the given address range
  4239. is unmodified without a partial update. This error is also
  4240. returned when ‘mseal’ is issued on a 32-bit CPU (sealing is
  4241. currently supported only on 64-bit CPUs, although 32-bit
  4242. binaries running on a 64-bit kernel are supported).
  4243. ‘ENOMEM’
  4244. Either the ADDRESS is not allocated, or the end address is not
  4245. within the allocation, or there is unallocated memory between
  4246. the start and end address.
  4247. ‘ENOSYS’
  4248. The kernel does not support the ‘mseal’ syscall.
  4249. *NB:* The memory sealing changes the lifetime of a mapping, where the
  4250. sealing memory could not be unmapped until the process terminates or
  4251. replaces the process image through ‘execve’ function. The sealed
  4252. mappings are inherited through ‘fork’.
  4253. 3.4.1 Memory Protection Keys
  4254. ----------------------------
  4255. On some systems, further access restrictions can be added to specific
  4256. pages using “memory protection keys”. These restrictions work as
  4257. follows:
  4258. • All memory pages are associated with a protection key. The default
  4259. protection key does not cause any additional protections to be
  4260. applied during memory accesses. New keys can be allocated with the
  4261. ‘pkey_alloc’ function, and applied to pages using ‘pkey_mprotect’.
  4262. • Each thread has a set of separate access restrictions for each
  4263. protection key. These access restrictions can be manipulated using
  4264. the ‘pkey_set’ and ‘pkey_get’ functions.
  4265. • During a memory access, the system obtains the protection key for
  4266. the accessed page and uses that to determine the applicable access
  4267. restrictions, as configured for the current thread. If the access
  4268. is restricted, a segmentation fault is the result ((*note Program
  4269. Error Signals::). These checks happen in addition to the ‘PROT_’*
  4270. protection flags set by ‘mprotect’ or ‘pkey_mprotect’.
  4271. New threads and subprocesses inherit the access restrictions of the
  4272. current thread. If a protection key is allocated subsequently, existing
  4273. threads (except the current) will use an unspecified system default for
  4274. the access restrictions associated with newly allocated keys.
  4275. Upon entering a signal handler, the system resets the access
  4276. restrictions of the current thread so that pages with the default key
  4277. can be accessed, but the access restrictions for other protection keys
  4278. are unspecified.
  4279. Applications are expected to allocate a key once using ‘pkey_alloc’,
  4280. and apply the key to memory regions which need special protection with
  4281. ‘pkey_mprotect’:
  4282. int key = pkey_alloc (0, PKEY_DISABLE_ACCESS);
  4283. if (key < 0)
  4284. /* Perform error checking, including fallback for lack of support. */
  4285. ...;
  4286. /* Apply the key to a special memory region used to store critical
  4287. data. */
  4288. if (pkey_mprotect (region, region_length,
  4289. PROT_READ | PROT_WRITE, key) < 0)
  4290. ...; /* Perform error checking (generally fatal). */
  4291. If the key allocation fails due to lack of support for memory
  4292. protection keys, the ‘pkey_mprotect’ call can usually be skipped. In
  4293. this case, the region will not be protected by default. It is also
  4294. possible to call ‘pkey_mprotect’ with a key value of -1, in which case
  4295. it will behave in the same way as ‘mprotect’.
  4296. After key allocation assignment to memory pages, ‘pkey_set’ can be
  4297. used to temporarily acquire access to the memory region and relinquish
  4298. it again:
  4299. if (key >= 0 && pkey_set (key, PKEY_UNRESTRICTED) < 0)
  4300. ...; /* Perform error checking (generally fatal). */
  4301. /* At this point, the current thread has read-write access to the
  4302. memory region. */
  4303. ...
  4304. /* Revoke access again. */
  4305. if (key >= 0 && pkey_set (key, PKEY_DISABLE_ACCESS) < 0)
  4306. ...; /* Perform error checking (generally fatal). */
  4307. In this example, a negative key value indicates that no key had been
  4308. allocated, which means that the system lacks support for memory
  4309. protection keys and it is not necessary to change the the access
  4310. restrictions of the current thread (because it always has access).
  4311. Compared to using ‘mprotect’ to change the page protection flags,
  4312. this approach has two advantages: It is thread-safe in the sense that
  4313. the access restrictions are only changed for the current thread, so
  4314. another thread which changes its own access restrictions concurrently to
  4315. gain access to the mapping will not suddenly see its access restrictions
  4316. updated. And ‘pkey_set’ typically does not involve a call into the
  4317. kernel and a context switch, so it is more efficient.
  4318. -- Function: int pkey_alloc (unsigned int FLAGS, unsigned int
  4319. ACCESS_RESTRICTIONS)
  4320. Preliminary: | MT-Safe | AS-Safe | AC-Unsafe corrupt | *Note POSIX
  4321. Safety Concepts::.
  4322. Allocate a new protection key. The FLAGS argument is reserved and
  4323. must be zero. The ACCESS_RESTRICTIONS argument specifies access
  4324. restrictions which are applied to the current thread (as if with
  4325. ‘pkey_set’ below). Access restrictions of other threads are not
  4326. changed.
  4327. The function returns the new protection key, a non-negative number,
  4328. or -1 on error.
  4329. The following ‘errno’ error conditions are defined for this
  4330. function:
  4331. ‘ENOSYS’
  4332. The system does not implement memory protection keys.
  4333. ‘EINVAL’
  4334. The FLAGS argument is not zero.
  4335. The ACCESS_RESTRICTIONS argument is invalid.
  4336. The system does not implement memory protection keys or runs
  4337. in a mode in which memory protection keys are disabled.
  4338. ‘ENOSPC’
  4339. All available protection keys already have been allocated.
  4340. The system does not implement memory protection keys or runs
  4341. in a mode in which memory protection keys are disabled.
  4342. -- Function: int pkey_free (int KEY)
  4343. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4344. Concepts::.
  4345. Deallocate the protection key, so that it can be reused by
  4346. ‘pkey_alloc’.
  4347. Calling this function does not change the access restrictions of
  4348. the freed protection key. The calling thread and other threads may
  4349. retain access to it, even if it is subsequently allocated again.
  4350. For this reason, it is not recommended to call the ‘pkey_free’
  4351. function.
  4352. ‘ENOSYS’
  4353. The system does not implement memory protection keys.
  4354. ‘EINVAL’
  4355. The KEY argument is not a valid protection key.
  4356. -- Function: int pkey_mprotect (void *ADDRESS, size_t LENGTH, int
  4357. PROTECTION, int KEY)
  4358. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4359. Concepts::.
  4360. Similar to ‘mprotect’, but also set the memory protection key for
  4361. the memory region to ‘key’.
  4362. Some systems use memory protection keys to emulate certain
  4363. combinations of PROTECTION flags. Under such circumstances,
  4364. specifying an explicit protection key may behave as if additional
  4365. flags have been specified in PROTECTION, even though this does not
  4366. happen with the default protection key. For example, some systems
  4367. can support ‘PROT_EXEC’-only mappings only with a default
  4368. protection key, and memory with a key which was allocated using
  4369. ‘pkey_alloc’ will still be readable if ‘PROT_EXEC’ is specified
  4370. without ‘PROT_READ’.
  4371. If KEY is -1, the default protection key is applied to the mapping,
  4372. just as if ‘mprotect’ had been called.
  4373. The ‘pkey_mprotect’ function returns 0 on success and -1 on
  4374. failure. The same ‘errno’ error conditions as for ‘mprotect’ are
  4375. defined for this function, with the following addition:
  4376. ‘EINVAL’
  4377. The KEY argument is not -1 or a valid memory protection key
  4378. allocated using ‘pkey_alloc’.
  4379. ‘ENOSYS’
  4380. The system does not implement memory protection keys, and KEY
  4381. is not -1.
  4382. -- Function: int pkey_set (int KEY, unsigned int ACCESS_RESTRICTIONS)
  4383. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4384. Concepts::.
  4385. Change the access restrictions of the current thread for memory
  4386. pages with the protection key KEY to ACCESS_RESTRICTIONS. If
  4387. ACCESS_RESTRICTIONS is ‘PKEY_UNRESTRICTED’ (zero), no additional
  4388. access restrictions on top of the page protection flags are
  4389. applied. Otherwise, ACCESS_RESTRICTIONS is a combination of the
  4390. following flags:
  4391. ‘PKEY_DISABLE_READ’
  4392. Subsequent attempts to read from memory with the specified
  4393. protection key will fault. At present only AArch64 platforms
  4394. with enabled Stage 1 permission overlays feature support this
  4395. type of restriction.
  4396. ‘PKEY_DISABLE_WRITE’
  4397. Subsequent attempts to write to memory with the specified
  4398. protection key will fault.
  4399. ‘PKEY_DISABLE_ACCESS’
  4400. Subsequent attempts to write to or read from memory with the
  4401. specified protection key will fault. On AArch64 platforms
  4402. with enabled Stage 1 permission overlays feature this
  4403. restriction value has the same effect as combination of
  4404. ‘PKEY_DISABLE_READ’ and ‘PKEY_DISABLE_WRITE’.
  4405. ‘PKEY_DISABLE_EXECUTE’
  4406. Subsequent attempts to execute from memory with the specified
  4407. protection key will fault. At present only AArch64 platforms
  4408. with enabled Stage 1 permission overlays feature support this
  4409. type of restriction.
  4410. Operations not specified as flags are not restricted. In
  4411. particular, this means that the memory region will remain
  4412. executable if it was mapped with the ‘PROT_EXEC’ protection flag
  4413. and ‘PKEY_DISABLE_ACCESS’ has been specified.
  4414. Calling the ‘pkey_set’ function with a protection key which was not
  4415. allocated by ‘pkey_alloc’ results in undefined behavior. This
  4416. means that calling this function on systems which do not support
  4417. memory protection keys is undefined.
  4418. The ‘pkey_set’ function returns 0 on success and -1 on failure.
  4419. The following ‘errno’ error conditions are defined for this
  4420. function:
  4421. ‘EINVAL’
  4422. The system does not support the access restrictions expressed
  4423. in the ACCESS_RESTRICTIONS argument.
  4424. -- Function: int pkey_get (int KEY)
  4425. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4426. Concepts::.
  4427. Return the access restrictions of the current thread for memory
  4428. pages with protection key KEY. The return value is zero or a
  4429. combination of the ‘PKEY_DISABLE_’* flags; see the ‘pkey_set’
  4430. function.
  4431. The returned value should be checked for presence or absence of
  4432. specific flags using bitwise operations. Comparing the returned
  4433. value with any of the flags or their combination using equals will
  4434. almost certainly fail.
  4435. Calling the ‘pkey_get’ function with a protection key which was not
  4436. allocated by ‘pkey_alloc’ results in undefined behavior. This
  4437. means that calling this function on systems which do not support
  4438. memory protection keys is undefined.
  4439. 
  4440. File: libc.info, Node: Locking Pages, Prev: Memory Protection, Up: Memory
  4441. 3.5 Locking Pages
  4442. =================
  4443. You can tell the system to associate a particular virtual memory page
  4444. with a real page frame and keep it that way -- i.e., cause the page to
  4445. be paged in if it isn't already and mark it so it will never be paged
  4446. out and consequently will never cause a page fault. This is called
  4447. “locking” a page.
  4448. The functions in this chapter lock and unlock the calling process'
  4449. pages.
  4450. * Menu:
  4451. * Why Lock Pages:: Reasons to read this section.
  4452. * Locked Memory Details:: Everything you need to know locked
  4453. memory
  4454. * Page Lock Functions:: Here's how to do it.
  4455. 
  4456. File: libc.info, Node: Why Lock Pages, Next: Locked Memory Details, Up: Locking Pages
  4457. 3.5.1 Why Lock Pages
  4458. --------------------
  4459. Because page faults cause paged out pages to be paged in transparently,
  4460. a process rarely needs to be concerned about locking pages. However,
  4461. there are two reasons people sometimes are:
  4462. • Speed. A page fault is transparent only insofar as the process is
  4463. not sensitive to how long it takes to do a simple memory access.
  4464. Time-critical processes, especially realtime processes, may not be
  4465. able to wait or may not be able to tolerate variance in execution
  4466. speed.
  4467. A process that needs to lock pages for this reason probably also
  4468. needs priority among other processes for use of the CPU. *Note
  4469. Priority::.
  4470. In some cases, the programmer knows better than the system's demand
  4471. paging allocator which pages should remain in real memory to
  4472. optimize system performance. In this case, locking pages can help.
  4473. • Privacy. If you keep secrets in virtual memory and that virtual
  4474. memory gets paged out, that increases the chance that the secrets
  4475. will get out. If a passphrase gets written out to disk swap space,
  4476. for example, it might still be there long after virtual and real
  4477. memory have been wiped clean.
  4478. Be aware that when you lock a page, that's one fewer page frame that
  4479. can be used to back other virtual memory (by the same or other
  4480. processes), which can mean more page faults, which means the system runs
  4481. more slowly. In fact, if you lock enough memory, some programs may not
  4482. be able to run at all for lack of real memory.
  4483. 
  4484. File: libc.info, Node: Locked Memory Details, Next: Page Lock Functions, Prev: Why Lock Pages, Up: Locking Pages
  4485. 3.5.2 Locked Memory Details
  4486. ---------------------------
  4487. A memory lock is associated with a virtual page, not a real frame. The
  4488. paging rule is: If a frame backs at least one locked page, don't page it
  4489. out.
  4490. Memory locks do not stack. I.e., you can't lock a particular page
  4491. twice so that it has to be unlocked twice before it is truly unlocked.
  4492. It is either locked or it isn't.
  4493. A memory lock persists until the process that owns the memory
  4494. explicitly unlocks it. (But process termination and exec cause the
  4495. virtual memory to cease to exist, which you might say means it isn't
  4496. locked any more).
  4497. Memory locks are not inherited by child processes. (But note that on
  4498. a modern Unix system, immediately after a fork, the parent's and the
  4499. child's virtual address space are backed by the same real page frames,
  4500. so the child enjoys the parent's locks). *Note Creating a Process::.
  4501. Because of its ability to impact other processes, only the superuser
  4502. can lock a page. Any process can unlock its own page.
  4503. The system sets limits on the amount of memory a process can have
  4504. locked and the amount of real memory it can have dedicated to it. *Note
  4505. Limits on Resources::.
  4506. In Linux, locked pages aren't as locked as you might think. Two
  4507. virtual pages that are not shared memory can nonetheless be backed by
  4508. the same real frame. The kernel does this in the name of efficiency
  4509. when it knows both virtual pages contain identical data, and does it
  4510. even if one or both of the virtual pages are locked.
  4511. But when a process modifies one of those pages, the kernel must get
  4512. it a separate frame and fill it with the page's data. This is known as
  4513. a “copy-on-write page fault”. It takes a small amount of time and in a
  4514. pathological case, getting that frame may require I/O.
  4515. To make sure this doesn't happen to your program, don't just lock the
  4516. pages. Write to them as well, unless you know you won't write to them
  4517. ever. And to make sure you have pre-allocated frames for your stack,
  4518. enter a scope that declares a C automatic variable larger than the
  4519. maximum stack size you will need, set it to something, then return from
  4520. its scope.
  4521. 
  4522. File: libc.info, Node: Page Lock Functions, Prev: Locked Memory Details, Up: Locking Pages
  4523. 3.5.3 Functions To Lock And Unlock Pages
  4524. ----------------------------------------
  4525. The symbols in this section are declared in ‘sys/mman.h’. These
  4526. functions are defined by POSIX.1b, but their availability depends on
  4527. your kernel. If your kernel doesn't allow these functions, they exist
  4528. but always fail. They _are_ available with a Linux kernel.
  4529. *Portability Note:* POSIX.1b requires that when the ‘mlock’ and
  4530. ‘munlock’ functions are available, the file ‘unistd.h’ define the macro
  4531. ‘_POSIX_MEMLOCK_RANGE’ and the file ‘limits.h’ define the macro
  4532. ‘PAGESIZE’ to be the size of a memory page in bytes. It requires that
  4533. when the ‘mlockall’ and ‘munlockall’ functions are available, the
  4534. ‘unistd.h’ file define the macro ‘_POSIX_MEMLOCK’. The GNU C Library
  4535. conforms to this requirement.
  4536. -- Function: int mlock (const void *ADDR, size_t LEN)
  4537. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4538. Concepts::.
  4539. ‘mlock’ locks a range of the calling process' virtual pages.
  4540. The range of memory starts at address ADDR and is LEN bytes long.
  4541. Actually, since you must lock whole pages, it is the range of pages
  4542. that include any part of the specified range.
  4543. When the function returns successfully, each of those pages is
  4544. backed by (connected to) a real frame (is resident) and is marked
  4545. to stay that way. This means the function may cause page-ins and
  4546. have to wait for them.
  4547. When the function fails, it does not affect the lock status of any
  4548. pages.
  4549. The return value is zero if the function succeeds. Otherwise, it
  4550. is ‘-1’ and ‘errno’ is set accordingly. ‘errno’ values specific to
  4551. this function are:
  4552. ‘ENOMEM’
  4553. • At least some of the specified address range does not
  4554. exist in the calling process' virtual address space.
  4555. • The locking would cause the process to exceed its locked
  4556. page limit.
  4557. ‘EPERM’
  4558. The calling process is not superuser.
  4559. ‘EINVAL’
  4560. LEN is not positive.
  4561. ‘ENOSYS’
  4562. The kernel does not provide ‘mlock’ capability.
  4563. -- Function: int mlock2 (const void *ADDR, size_t LEN, unsigned int
  4564. FLAGS)
  4565. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4566. Concepts::.
  4567. This function is similar to ‘mlock’. If FLAGS is zero, a call to
  4568. ‘mlock2’ behaves exactly as the equivalent call to ‘mlock’.
  4569. The FLAGS argument must be a combination of zero or more of the
  4570. following flags:
  4571. ‘MLOCK_ONFAULT’
  4572. Only those pages in the specified address range which are
  4573. already in memory are locked immediately. Additional pages in
  4574. the range are automatically locked in case of a page fault and
  4575. allocation of memory.
  4576. Like ‘mlock’, ‘mlock2’ returns zero on success and ‘-1’ on failure,
  4577. setting ‘errno’ accordingly. Additional ‘errno’ values defined for
  4578. ‘mlock2’ are:
  4579. ‘EINVAL’
  4580. The specified (non-zero) FLAGS argument is not supported by
  4581. this system.
  4582. You can lock _all_ a process' memory with ‘mlockall’. You unlock
  4583. memory with ‘munlock’ or ‘munlockall’.
  4584. To avoid all page faults in a C program, you have to use ‘mlockall’,
  4585. because some of the memory a program uses is hidden from the C code,
  4586. e.g. the stack and automatic variables, and you wouldn't know what
  4587. address to tell ‘mlock’.
  4588. -- Function: int munlock (const void *ADDR, size_t LEN)
  4589. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4590. Concepts::.
  4591. ‘munlock’ unlocks a range of the calling process' virtual pages.
  4592. ‘munlock’ is the inverse of ‘mlock’ and functions completely
  4593. analogously to ‘mlock’, except that there is no ‘EPERM’ failure.
  4594. -- Function: int mlockall (int FLAGS)
  4595. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4596. Concepts::.
  4597. ‘mlockall’ locks all the pages in a process' virtual memory address
  4598. space, and/or any that are added to it in the future. This
  4599. includes the pages of the code, data and stack segment, as well as
  4600. shared libraries, user space kernel data, shared memory, and memory
  4601. mapped files.
  4602. FLAGS is a string of single bit flags represented by the following
  4603. macros. They tell ‘mlockall’ which of its functions you want. All
  4604. other bits must be zero.
  4605. ‘MCL_CURRENT’
  4606. Lock all pages which currently exist in the calling process'
  4607. virtual address space.
  4608. ‘MCL_FUTURE’
  4609. Set a mode such that any pages added to the process' virtual
  4610. address space in the future will be locked from birth. This
  4611. mode does not affect future address spaces owned by the same
  4612. process so exec, which replaces a process' address space,
  4613. wipes out ‘MCL_FUTURE’. *Note Executing a File::.
  4614. When the function returns successfully, and you specified
  4615. ‘MCL_CURRENT’, all of the process' pages are backed by (connected
  4616. to) real frames (they are resident) and are marked to stay that
  4617. way. This means the function may cause page-ins and have to wait
  4618. for them.
  4619. When the process is in ‘MCL_FUTURE’ mode because it successfully
  4620. executed this function and specified ‘MCL_CURRENT’, any system call
  4621. by the process that requires space be added to its virtual address
  4622. space fails with ‘errno’ = ‘ENOMEM’ if locking the additional space
  4623. would cause the process to exceed its locked page limit. In the
  4624. case that the address space addition that can't be accommodated is
  4625. stack expansion, the stack expansion fails and the kernel sends a
  4626. ‘SIGSEGV’ signal to the process.
  4627. When the function fails, it does not affect the lock status of any
  4628. pages or the future locking mode.
  4629. The return value is zero if the function succeeds. Otherwise, it
  4630. is ‘-1’ and ‘errno’ is set accordingly. ‘errno’ values specific to
  4631. this function are:
  4632. ‘ENOMEM’
  4633. • At least some of the specified address range does not
  4634. exist in the calling process' virtual address space.
  4635. • The locking would cause the process to exceed its locked
  4636. page limit.
  4637. ‘EPERM’
  4638. The calling process is not superuser.
  4639. ‘EINVAL’
  4640. Undefined bits in FLAGS are not zero.
  4641. ‘ENOSYS’
  4642. The kernel does not provide ‘mlockall’ capability.
  4643. You can lock just specific pages with ‘mlock’. You unlock pages
  4644. with ‘munlockall’ and ‘munlock’.
  4645. -- Function: int munlockall (void)
  4646. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4647. Concepts::.
  4648. ‘munlockall’ unlocks every page in the calling process' virtual
  4649. address space and turns off ‘MCL_FUTURE’ future locking mode.
  4650. The return value is zero if the function succeeds. Otherwise, it
  4651. is ‘-1’ and ‘errno’ is set accordingly. The only way this function
  4652. can fail is for generic reasons that all functions and system calls
  4653. can fail, so there are no specific ‘errno’ values.
  4654. 
  4655. File: libc.info, Node: Character Handling, Next: String and Array Utilities, Prev: Memory, Up: Top
  4656. 4 Character Handling
  4657. ********************
  4658. Programs that work with characters and strings often need to classify a
  4659. character--is it alphabetic, is it a digit, is it whitespace, and so
  4660. on--and perform case conversion operations on characters. The functions
  4661. in the header file ‘ctype.h’ are provided for this purpose.
  4662. Since the choice of locale and character set can alter the
  4663. classifications of particular character codes, all of these functions
  4664. are affected by the current locale. (More precisely, they are affected
  4665. by the locale currently selected for character classification--the
  4666. ‘LC_CTYPE’ category; see *note Locale Categories::.)
  4667. The ISO C standard specifies two different sets of functions. The
  4668. one set works on ‘char’ type characters, the other one on ‘wchar_t’ wide
  4669. characters (*note Extended Char Intro::).
  4670. * Menu:
  4671. * Classification of Characters:: Testing whether characters are
  4672. letters, digits, punctuation, etc.
  4673. * Case Conversion:: Case mapping, and the like.
  4674. * Classification of Wide Characters:: Character class determination for
  4675. wide characters.
  4676. * Using Wide Char Classes:: Notes on using the wide character
  4677. classes.
  4678. * Wide Character Case Conversion:: Mapping of wide characters.
  4679. 
  4680. File: libc.info, Node: Classification of Characters, Next: Case Conversion, Up: Character Handling
  4681. 4.1 Classification of Characters
  4682. ================================
  4683. This section explains the library functions for classifying characters.
  4684. For example, ‘isalpha’ is the function to test for an alphabetic
  4685. character. It takes one argument, the character to test as an ‘unsigned
  4686. char’ value, and returns a nonzero integer if the character is
  4687. alphabetic, and zero otherwise. You would use it like this:
  4688. if (isalpha ((unsigned char) c))
  4689. printf ("The character `%c' is alphabetic.\n", c);
  4690. Each of the functions in this section tests for membership in a
  4691. particular class of characters; each has a name starting with ‘is’.
  4692. Each of them takes one argument, which is a character to test. The
  4693. character argument must be in the value range of ‘unsigned char’ (0 to
  4694. 255 for the GNU C Library). On a machine where the ‘char’ type is
  4695. signed, it may be necessary to cast the argument to ‘unsigned char’, or
  4696. mask it with ‘& 0xff’. (On ‘unsigned char’ machines, this step is
  4697. harmless, so portable code should always perform it.) The ‘is’
  4698. functions return an ‘int’ which is treated as a boolean value.
  4699. All ‘is’ functions accept the special value ‘EOF’ and return zero.
  4700. (Note that ‘EOF’ must not be cast to ‘unsigned char’ for this to work.)
  4701. As an extension, the GNU C Library accepts signed ‘char’ values as
  4702. ‘is’ functions arguments in the range -128 to -2, and returns the result
  4703. for the corresponding unsigned character. However, as there might be an
  4704. actual character corresponding to the ‘EOF’ integer constant, doing so
  4705. may introduce bugs, and it is recommended to apply the conversion to the
  4706. unsigned character range as appropriate.
  4707. The attributes of any given character can vary between locales.
  4708. *Note Locales::, for more information on locales.
  4709. These functions are declared in the header file ‘ctype.h’.
  4710. -- Function: int islower (int C)
  4711. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4712. Concepts::.
  4713. Returns true if C is a lower-case letter. The letter need not be
  4714. from the Latin alphabet, any alphabet representable is valid.
  4715. -- Function: int isupper (int C)
  4716. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4717. Concepts::.
  4718. Returns true if C is an upper-case letter. The letter need not be
  4719. from the Latin alphabet, any alphabet representable is valid.
  4720. -- Function: int isalpha (int C)
  4721. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4722. Concepts::.
  4723. Returns true if C is an alphabetic character (a letter). If
  4724. ‘islower’ or ‘isupper’ is true of a character, then ‘isalpha’ is
  4725. also true.
  4726. In some locales, there may be additional characters for which
  4727. ‘isalpha’ is true--letters which are neither upper case nor lower
  4728. case. But in the standard ‘"C"’ locale, there are no such
  4729. additional characters.
  4730. -- Function: int isdigit (int C)
  4731. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4732. Concepts::.
  4733. Returns true if C is a decimal digit (‘0’ through ‘9’).
  4734. -- Function: int isalnum (int C)
  4735. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4736. Concepts::.
  4737. Returns true if C is an alphanumeric character (a letter or
  4738. number); in other words, if either ‘isalpha’ or ‘isdigit’ is true
  4739. of a character, then ‘isalnum’ is also true.
  4740. -- Function: int isxdigit (int C)
  4741. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4742. Concepts::.
  4743. Returns true if C is a hexadecimal digit. Hexadecimal digits
  4744. include the normal decimal digits ‘0’ through ‘9’ and the letters
  4745. ‘A’ through ‘F’ and ‘a’ through ‘f’.
  4746. -- Function: int ispunct (int C)
  4747. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4748. Concepts::.
  4749. Returns true if C is a punctuation character. This means any
  4750. printing character that is not alphanumeric or a space character.
  4751. -- Function: int isspace (int C)
  4752. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4753. Concepts::.
  4754. Returns true if C is a “whitespace” character. In the standard
  4755. ‘"C"’ locale, ‘isspace’ returns true for only the standard
  4756. whitespace characters:
  4757. ‘' '’
  4758. space
  4759. ‘'\f'’
  4760. formfeed
  4761. ‘'\n'’
  4762. newline
  4763. ‘'\r'’
  4764. carriage return
  4765. ‘'\t'’
  4766. horizontal tab
  4767. ‘'\v'’
  4768. vertical tab
  4769. -- Function: int isblank (int C)
  4770. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4771. Concepts::.
  4772. Returns true if C is a blank character; that is, a space or a tab.
  4773. This function was originally a GNU extension, but was added in
  4774. ISO C99.
  4775. -- Function: int isgraph (int C)
  4776. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4777. Concepts::.
  4778. Returns true if C is a graphic character; that is, a character that
  4779. has a glyph associated with it. The whitespace characters are not
  4780. considered graphic.
  4781. -- Function: int isprint (int C)
  4782. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4783. Concepts::.
  4784. Returns true if C is a printing character. Printing characters
  4785. include all the graphic characters, plus the space (‘ ’) character.
  4786. -- Function: int iscntrl (int C)
  4787. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4788. Concepts::.
  4789. Returns true if C is a control character (that is, a character that
  4790. is not a printing character).
  4791. -- Function: int isascii (int C)
  4792. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4793. Concepts::.
  4794. Returns true if C is a 7-bit ‘unsigned char’ value that fits into
  4795. the US/UK ASCII character set. This function is a BSD extension
  4796. and is also an SVID extension.
  4797. 
  4798. File: libc.info, Node: Case Conversion, Next: Classification of Wide Characters, Prev: Classification of Characters, Up: Character Handling
  4799. 4.2 Case Conversion
  4800. ===================
  4801. This section explains the library functions for performing conversions
  4802. such as case mappings on characters. For example, ‘toupper’ converts
  4803. any character to upper case if possible. If the character can't be
  4804. converted, ‘toupper’ returns it unchanged.
  4805. These functions take one argument of type ‘int’, which is the
  4806. character to convert, and return the converted character as an ‘int’.
  4807. If the conversion is not applicable to the argument given, the argument
  4808. is returned unchanged.
  4809. *Compatibility Note:* In pre-ISO C dialects, instead of returning the
  4810. argument unchanged, these functions may fail when the argument is not
  4811. suitable for the conversion. Thus for portability, you may need to
  4812. write ‘islower(c) ? toupper(c) : c’ rather than just ‘toupper(c)’.
  4813. These functions are declared in the header file ‘ctype.h’.
  4814. -- Function: int tolower (int C)
  4815. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4816. Concepts::.
  4817. If C is an upper-case letter, ‘tolower’ returns the corresponding
  4818. lower-case letter. If C is not an upper-case letter, C is returned
  4819. unchanged.
  4820. -- Function: int toupper (int C)
  4821. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4822. Concepts::.
  4823. If C is a lower-case letter, ‘toupper’ returns the corresponding
  4824. upper-case letter. Otherwise C is returned unchanged.
  4825. -- Function: int toascii (int C)
  4826. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4827. Concepts::.
  4828. This function converts C to a 7-bit ‘unsigned char’ value that fits
  4829. into the US/UK ASCII character set, by clearing the high-order
  4830. bits. This function is a BSD extension and is also an SVID
  4831. extension.
  4832. -- Function: int _tolower (int C)
  4833. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4834. Concepts::.
  4835. This is identical to ‘tolower’, and is provided for compatibility
  4836. with the SVID. *Note SVID::.
  4837. -- Function: int _toupper (int C)
  4838. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4839. Concepts::.
  4840. This is identical to ‘toupper’, and is provided for compatibility
  4841. with the SVID.
  4842. 
  4843. File: libc.info, Node: Classification of Wide Characters, Next: Using Wide Char Classes, Prev: Case Conversion, Up: Character Handling
  4844. 4.3 Character class determination for wide characters
  4845. =====================================================
  4846. Amendment 1 to ISO C90 defines functions to classify wide characters.
  4847. Although the original ISO C90 standard already defined the type
  4848. ‘wchar_t’, no functions operating on them were defined.
  4849. The general design of the classification functions for wide
  4850. characters is more general. It allows extensions to the set of
  4851. available classifications, beyond those which are always available. The
  4852. POSIX standard specifies how extensions can be made, and this is already
  4853. implemented in the GNU C Library implementation of the ‘localedef’
  4854. program.
  4855. The character class functions are normally implemented with bitsets,
  4856. with a bitset per character. For a given character, the appropriate
  4857. bitset is read from a table and a test is performed as to whether a
  4858. certain bit is set. Which bit is tested for is determined by the class.
  4859. For the wide character classification functions this is made visible.
  4860. There is a type classification type defined, a function to retrieve this
  4861. value for a given class, and a function to test whether a given
  4862. character is in this class, using the classification value. On top of
  4863. this the normal character classification functions as used for ‘char’
  4864. objects can be defined.
  4865. -- Data type: wctype_t
  4866. The ‘wctype_t’ can hold a value which represents a character class.
  4867. The only defined way to generate such a value is by using the
  4868. ‘wctype’ function.
  4869. This type is defined in ‘wctype.h’.
  4870. -- Function: wctype_t wctype (const char *PROPERTY)
  4871. Preliminary: | MT-Safe locale | AS-Safe | AC-Safe | *Note POSIX
  4872. Safety Concepts::.
  4873. ‘wctype’ returns a value representing a class of wide characters
  4874. which is identified by the string PROPERTY. Besides some standard
  4875. properties each locale can define its own ones. In case no
  4876. property with the given name is known for the current locale
  4877. selected for the ‘LC_CTYPE’ category, the function returns zero.
  4878. The properties known in every locale are:
  4879. ‘"alnum"’ ‘"alpha"’ ‘"cntrl"’ ‘"digit"’
  4880. ‘"graph"’ ‘"lower"’ ‘"print"’ ‘"punct"’
  4881. ‘"space"’ ‘"upper"’ ‘"xdigit"’
  4882. This function is declared in ‘wctype.h’.
  4883. To test the membership of a character to one of the non-standard
  4884. classes the ISO C standard defines a completely new function.
  4885. -- Function: int iswctype (wint_t WC, wctype_t DESC)
  4886. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4887. Concepts::.
  4888. This function returns a nonzero value if WC is in the character
  4889. class specified by DESC. DESC must previously be returned by a
  4890. successful call to ‘wctype’.
  4891. This function is declared in ‘wctype.h’.
  4892. To make it easier to use the commonly-used classification functions,
  4893. they are defined in the C library. There is no need to use ‘wctype’ if
  4894. the property string is one of the known character classes. In some
  4895. situations it is desirable to construct the property strings, and then
  4896. it is important that ‘wctype’ can also handle the standard classes.
  4897. -- Function: int iswalnum (wint_t WC)
  4898. Preliminary: | MT-Safe locale | AS-Safe | AC-Safe | *Note POSIX
  4899. Safety Concepts::.
  4900. This function returns a nonzero value if WC is an alphanumeric
  4901. character (a letter or number); in other words, if either
  4902. ‘iswalpha’ or ‘iswdigit’ is true of a character, then ‘iswalnum’ is
  4903. also true.
  4904. This function can be implemented using
  4905. iswctype (wc, wctype ("alnum"))
  4906. It is declared in ‘wctype.h’.
  4907. -- Function: int iswalpha (wint_t WC)
  4908. Preliminary: | MT-Safe locale | AS-Safe | AC-Safe | *Note POSIX
  4909. Safety Concepts::.
  4910. Returns true if WC is an alphabetic character (a letter). If
  4911. ‘iswlower’ or ‘iswupper’ is true of a character, then ‘iswalpha’ is
  4912. also true.
  4913. In some locales, there may be additional characters for which
  4914. ‘iswalpha’ is true--letters which are neither upper case nor lower
  4915. case. But in the standard ‘"C"’ locale, there are no such
  4916. additional characters.
  4917. This function can be implemented using
  4918. iswctype (wc, wctype ("alpha"))
  4919. It is declared in ‘wctype.h’.
  4920. -- Function: int iswcntrl (wint_t WC)
  4921. Preliminary: | MT-Safe locale | AS-Safe | AC-Safe | *Note POSIX
  4922. Safety Concepts::.
  4923. Returns true if WC is a control character (that is, a character
  4924. that is not a printing character).
  4925. This function can be implemented using
  4926. iswctype (wc, wctype ("cntrl"))
  4927. It is declared in ‘wctype.h’.
  4928. -- Function: int iswdigit (wint_t WC)
  4929. Preliminary: | MT-Safe locale | AS-Safe | AC-Safe | *Note POSIX
  4930. Safety Concepts::.
  4931. Returns true if WC is a digit (e.g., ‘0’ through ‘9’). Please note
  4932. that this function does not only return a nonzero value for
  4933. _decimal_ digits, but for all kinds of digits. A consequence is
  4934. that code like the following will *not* work unconditionally for
  4935. wide characters:
  4936. n = 0;
  4937. while (iswdigit (*wc))
  4938. {
  4939. n *= 10;
  4940. n += *wc++ - L'0';
  4941. }
  4942. This function can be implemented using
  4943. iswctype (wc, wctype ("digit"))
  4944. It is declared in ‘wctype.h’.
  4945. -- Function: int iswgraph (wint_t WC)
  4946. Preliminary: | MT-Safe locale | AS-Safe | AC-Safe | *Note POSIX
  4947. Safety Concepts::.
  4948. Returns true if WC is a graphic character; that is, a character
  4949. that has a glyph associated with it. The whitespace characters are
  4950. not considered graphic.
  4951. This function can be implemented using
  4952. iswctype (wc, wctype ("graph"))
  4953. It is declared in ‘wctype.h’.
  4954. -- Function: int iswlower (wint_t WC)
  4955. Preliminary: | MT-Safe locale | AS-Safe | AC-Safe | *Note POSIX
  4956. Safety Concepts::.
  4957. Returns true if WC is a lower-case letter. The letter need not be
  4958. from the Latin alphabet, any alphabet representable is valid.
  4959. This function can be implemented using
  4960. iswctype (wc, wctype ("lower"))
  4961. It is declared in ‘wctype.h’.
  4962. -- Function: int iswprint (wint_t WC)
  4963. Preliminary: | MT-Safe locale | AS-Safe | AC-Safe | *Note POSIX
  4964. Safety Concepts::.
  4965. Returns true if WC is a printing character. Printing characters
  4966. include all the graphic characters, plus the space (‘ ’) character.
  4967. This function can be implemented using
  4968. iswctype (wc, wctype ("print"))
  4969. It is declared in ‘wctype.h’.
  4970. -- Function: int iswpunct (wint_t WC)
  4971. Preliminary: | MT-Safe locale | AS-Safe | AC-Safe | *Note POSIX
  4972. Safety Concepts::.
  4973. Returns true if WC is a punctuation character. This means any
  4974. printing character that is not alphanumeric or a space character.
  4975. This function can be implemented using
  4976. iswctype (wc, wctype ("punct"))
  4977. It is declared in ‘wctype.h’.
  4978. -- Function: int iswspace (wint_t WC)
  4979. Preliminary: | MT-Safe locale | AS-Safe | AC-Safe | *Note POSIX
  4980. Safety Concepts::.
  4981. Returns true if WC is a “whitespace” character. In the standard
  4982. ‘"C"’ locale, ‘iswspace’ returns true for only the standard
  4983. whitespace characters:
  4984. ‘L' '’
  4985. space
  4986. ‘L'\f'’
  4987. formfeed
  4988. ‘L'\n'’
  4989. newline
  4990. ‘L'\r'’
  4991. carriage return
  4992. ‘L'\t'’
  4993. horizontal tab
  4994. ‘L'\v'’
  4995. vertical tab
  4996. This function can be implemented using
  4997. iswctype (wc, wctype ("space"))
  4998. It is declared in ‘wctype.h’.
  4999. -- Function: int iswupper (wint_t WC)
  5000. Preliminary: | MT-Safe locale | AS-Safe | AC-Safe | *Note POSIX
  5001. Safety Concepts::.
  5002. Returns true if WC is an upper-case letter. The letter need not be
  5003. from the Latin alphabet, any alphabet representable is valid.
  5004. This function can be implemented using
  5005. iswctype (wc, wctype ("upper"))
  5006. It is declared in ‘wctype.h’.
  5007. -- Function: int iswxdigit (wint_t WC)
  5008. Preliminary: | MT-Safe locale | AS-Safe | AC-Safe | *Note POSIX
  5009. Safety Concepts::.
  5010. Returns true if WC is a hexadecimal digit. Hexadecimal digits
  5011. include the normal decimal digits ‘0’ through ‘9’ and the letters
  5012. ‘A’ through ‘F’ and ‘a’ through ‘f’.
  5013. This function can be implemented using
  5014. iswctype (wc, wctype ("xdigit"))
  5015. It is declared in ‘wctype.h’.
  5016. The GNU C Library also provides a function which is not defined in
  5017. the ISO C standard but which is available as a version for single byte
  5018. characters as well.
  5019. -- Function: int iswblank (wint_t WC)
  5020. Preliminary: | MT-Safe locale | AS-Safe | AC-Safe | *Note POSIX
  5021. Safety Concepts::.
  5022. Returns true if WC is a blank character; that is, a space or a tab.
  5023. This function was originally a GNU extension, but was added in
  5024. ISO C99. It is declared in ‘wchar.h’.
  5025. 
  5026. File: libc.info, Node: Using Wide Char Classes, Next: Wide Character Case Conversion, Prev: Classification of Wide Characters, Up: Character Handling
  5027. 4.4 Notes on using the wide character classes
  5028. =============================================
  5029. The first note is probably not astonishing but still occasionally a
  5030. cause of problems. The ‘iswXXX’ functions can be implemented using
  5031. macros and in fact, the GNU C Library does this. They are still
  5032. available as real functions but when the ‘wctype.h’ header is included
  5033. the macros will be used. This is the same as the ‘char’ type versions
  5034. of these functions.
  5035. The second note covers something new. It can be best illustrated by
  5036. a (real-world) example. The first piece of code is an excerpt from the
  5037. original code. It is truncated a bit but the intention should be clear.
  5038. int
  5039. is_in_class (int c, const char *class)
  5040. {
  5041. if (strcmp (class, "alnum") == 0)
  5042. return isalnum (c);
  5043. if (strcmp (class, "alpha") == 0)
  5044. return isalpha (c);
  5045. if (strcmp (class, "cntrl") == 0)
  5046. return iscntrl (c);
  5047. ...
  5048. return 0;
  5049. }
  5050. Now, with the ‘wctype’ and ‘iswctype’ you can avoid the ‘if’
  5051. cascades, but rewriting the code as follows is wrong:
  5052. int
  5053. is_in_class (int c, const char *class)
  5054. {
  5055. wctype_t desc = wctype (class);
  5056. return desc ? iswctype ((wint_t) c, desc) : 0;
  5057. }
  5058. The problem is that it is not guaranteed that the wide character
  5059. representation of a single-byte character can be found using casting.
  5060. In fact, usually this fails miserably. The correct solution to this
  5061. problem is to write the code as follows:
  5062. int
  5063. is_in_class (int c, const char *class)
  5064. {
  5065. wctype_t desc = wctype (class);
  5066. return desc ? iswctype (btowc (c), desc) : 0;
  5067. }
  5068. *Note Converting a Character::, for more information on ‘btowc’.
  5069. Note that this change probably does not improve the performance of the
  5070. program a lot since the ‘wctype’ function still has to make the string
  5071. comparisons. It gets really interesting if the ‘is_in_class’ function
  5072. is called more than once for the same class name. In this case the
  5073. variable DESC could be computed once and reused for all the calls.
  5074. Therefore the above form of the function is probably not the final one.
  5075. 
  5076. File: libc.info, Node: Wide Character Case Conversion, Prev: Using Wide Char Classes, Up: Character Handling
  5077. 4.5 Mapping of wide characters.
  5078. ===============================
  5079. The classification functions are also generalized by the ISO C standard.
  5080. Instead of just allowing the two standard mappings, a locale can contain
  5081. others. Again, the ‘localedef’ program already supports generating such
  5082. locale data files.
  5083. -- Data Type: wctrans_t
  5084. This data type is defined as a scalar type which can hold a value
  5085. representing the locale-dependent character mapping. There is no
  5086. way to construct such a value apart from using the return value of
  5087. the ‘wctrans’ function.
  5088. This type is defined in ‘wctype.h’.
  5089. -- Function: wctrans_t wctrans (const char *PROPERTY)
  5090. Preliminary: | MT-Safe locale | AS-Safe | AC-Safe | *Note POSIX
  5091. Safety Concepts::.
  5092. The ‘wctrans’ function has to be used to find out whether a named
  5093. mapping is defined in the current locale selected for the
  5094. ‘LC_CTYPE’ category. If the returned value is non-zero, you can
  5095. use it afterwards in calls to ‘towctrans’. If the return value is
  5096. zero no such mapping is known in the current locale.
  5097. Beside locale-specific mappings there are two mappings which are
  5098. guaranteed to be available in every locale:
  5099. ‘"tolower"’ ‘"toupper"’
  5100. These functions are declared in ‘wctype.h’.
  5101. -- Function: wint_t towctrans (wint_t WC, wctrans_t DESC)
  5102. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5103. Concepts::.
  5104. ‘towctrans’ maps the input character WC according to the rules of
  5105. the mapping for which DESC is a descriptor, and returns the value
  5106. it finds. DESC must be obtained by a successful call to ‘wctrans’.
  5107. This function is declared in ‘wctype.h’.
  5108. For the generally available mappings, the ISO C standard defines
  5109. convenient shortcuts so that it is not necessary to call ‘wctrans’ for
  5110. them.
  5111. -- Function: wint_t towlower (wint_t WC)
  5112. Preliminary: | MT-Safe locale | AS-Safe | AC-Safe | *Note POSIX
  5113. Safety Concepts::.
  5114. If WC is an upper-case letter, ‘towlower’ returns the corresponding
  5115. lower-case letter. If WC is not an upper-case letter, WC is
  5116. returned unchanged.
  5117. ‘towlower’ can be implemented using
  5118. towctrans (wc, wctrans ("tolower"))
  5119. This function is declared in ‘wctype.h’.
  5120. -- Function: wint_t towupper (wint_t WC)
  5121. Preliminary: | MT-Safe locale | AS-Safe | AC-Safe | *Note POSIX
  5122. Safety Concepts::.
  5123. If WC is a lower-case letter, ‘towupper’ returns the corresponding
  5124. upper-case letter. Otherwise WC is returned unchanged.
  5125. ‘towupper’ can be implemented using
  5126. towctrans (wc, wctrans ("toupper"))
  5127. This function is declared in ‘wctype.h’.
  5128. The same warnings given in the last section for the use of the wide
  5129. character classification functions apply here. It is not possible to
  5130. simply cast a ‘char’ type value to a ‘wint_t’ and use it as an argument
  5131. to ‘towctrans’ calls.
  5132. 
  5133. File: libc.info, Node: String and Array Utilities, Next: Character Set Handling, Prev: Character Handling, Up: Top
  5134. 5 String and Array Utilities
  5135. ****************************
  5136. Operations on strings (null-terminated byte sequences) are an important
  5137. part of many programs. The GNU C Library provides an extensive set of
  5138. string utility functions, including functions for copying,
  5139. concatenating, comparing, and searching strings. Many of these
  5140. functions can also operate on arbitrary regions of storage; for example,
  5141. the ‘memcpy’ function can be used to copy the contents of any kind of
  5142. array.
  5143. It's fairly common for beginning C programmers to "reinvent the
  5144. wheel" by duplicating this functionality in their own code, but it pays
  5145. to become familiar with the library functions and to make use of them,
  5146. since this offers benefits in maintenance, efficiency, and portability.
  5147. For instance, you could easily compare one string to another in two
  5148. lines of C code, but if you use the built-in ‘strcmp’ function, you're
  5149. less likely to make a mistake. And, since these library functions are
  5150. typically highly optimized, your program may run faster too.
  5151. * Menu:
  5152. * Representation of Strings:: Introduction to basic concepts.
  5153. * String/Array Conventions:: Whether to use a string function or an
  5154. arbitrary array function.
  5155. * String Length:: Determining the length of a string.
  5156. * Copying Strings and Arrays:: Functions to copy strings and arrays.
  5157. * Concatenating Strings:: Functions to concatenate strings while copying.
  5158. * Truncating Strings:: Functions to truncate strings while copying.
  5159. * String/Array Comparison:: Functions for byte-wise and character-wise
  5160. comparison.
  5161. * Collation Functions:: Functions for collating strings.
  5162. * Search Functions:: Searching for a specific element or substring.
  5163. * Finding Tokens in a String:: Splitting a string into tokens by looking
  5164. for delimiters.
  5165. * Erasing Sensitive Data:: Clearing memory which contains sensitive
  5166. data, after it's no longer needed.
  5167. * Shuffling Bytes:: Or how to flash-cook a string.
  5168. * Obfuscating Data:: Reversibly obscuring data from casual view.
  5169. * Encode Binary Data:: Encoding and Decoding of Binary Data.
  5170. * Argz and Envz Vectors:: Null-separated string vectors.
  5171. 
  5172. File: libc.info, Node: Representation of Strings, Next: String/Array Conventions, Up: String and Array Utilities
  5173. 5.1 Representation of Strings
  5174. =============================
  5175. This section is a quick summary of string concepts for beginning C
  5176. programmers. It describes how strings are represented in C and some
  5177. common pitfalls. If you are already familiar with this material, you
  5178. can skip this section.
  5179. A “string” is a null-terminated array of bytes of type ‘char’,
  5180. including the terminating null byte. String-valued variables are
  5181. usually declared to be pointers of type ‘char *’. Such variables do not
  5182. include space for the contents of a string; that has to be stored
  5183. somewhere else--in an array variable, a string constant, or dynamically
  5184. allocated memory (*note Memory Allocation::). It's up to you to store
  5185. the address of the chosen memory space into the pointer variable.
  5186. Alternatively you can store a “null pointer” in the pointer variable.
  5187. The null pointer does not point anywhere, so attempting to reference the
  5188. string it points to gets an error.
  5189. A “multibyte character” is a sequence of one or more bytes that
  5190. represents a single character using the locale's encoding scheme; a null
  5191. byte always represents the null character. A “multibyte string” is a
  5192. string that consists entirely of multibyte characters. In contrast, a
  5193. “wide string” is a null-terminated sequence of ‘wchar_t’ objects. A
  5194. wide-string variable is usually declared to be a pointer of type
  5195. ‘wchar_t *’, by analogy with string variables and ‘char *’. *Note
  5196. Extended Char Intro::.
  5197. By convention, the “null byte”, ‘'\0'’, marks the end of a string and
  5198. the “null wide character”, ‘L'\0'’, marks the end of a wide string. For
  5199. example, in testing to see whether the ‘char *’ variable P points to a
  5200. null byte marking the end of a string, you can write ‘!*P’ or ‘*P ==
  5201. '\0'’.
  5202. A null byte is quite different conceptually from a null pointer,
  5203. although both are represented by the integer constant ‘0’.
  5204. A “string literal” appears in C program source as a multibyte string
  5205. between double-quote characters (‘"’). If the initial double-quote
  5206. character is immediately preceded by a capital ‘L’ (ell) character (as
  5207. in ‘L"foo"’), it is a wide string literal. String literals can also
  5208. contribute to “string concatenation”: ‘"a" "b"’ is the same as ‘"ab"’.
  5209. For wide strings one can use either ‘L"a" L"b"’ or ‘L"a" "b"’.
  5210. Modification of string literals is not allowed by the GNU C compiler,
  5211. because literals are placed in read-only storage.
  5212. Arrays that are declared ‘const’ cannot be modified either. It's
  5213. generally good style to declare non-modifiable string pointers to be of
  5214. type ‘const char *’, since this often allows the C compiler to detect
  5215. accidental modifications as well as providing some amount of
  5216. documentation about what your program intends to do with the string.
  5217. The amount of memory allocated for a byte array may extend past the
  5218. null byte that marks the end of the string that the array contains. In
  5219. this document, the term “allocated size” is always used to refer to the
  5220. total amount of memory allocated for an array, while the term “length”
  5221. refers to the number of bytes up to (but not including) the terminating
  5222. null byte. Wide strings are similar, except their sizes and lengths
  5223. count wide characters, not bytes.
  5224. A notorious source of program bugs is trying to put more bytes into a
  5225. string than fit in its allocated size. When writing code that extends
  5226. strings or moves bytes into a pre-allocated array, you should be very
  5227. careful to keep track of the length of the string and make explicit
  5228. checks for overflowing the array. Many of the library functions _do
  5229. not_ do this for you! Remember also that you need to allocate an extra
  5230. byte to hold the null byte that marks the end of the string.
  5231. Originally strings were sequences of bytes where each byte
  5232. represented a single character. This is still true today if the strings
  5233. are encoded using a single-byte character encoding. Things are
  5234. different if the strings are encoded using a multibyte encoding (for
  5235. more information on encodings see *note Extended Char Intro::). There
  5236. is no difference in the programming interface for these two kind of
  5237. strings; the programmer has to be aware of this and interpret the byte
  5238. sequences accordingly.
  5239. But since there is no separate interface taking care of these
  5240. differences the byte-based string functions are sometimes hard to use.
  5241. Since the count parameters of these functions specify bytes a call to
  5242. ‘memcpy’ could cut a multibyte character in the middle and put an
  5243. incomplete (and therefore unusable) byte sequence in the target buffer.
  5244. To avoid these problems later versions of the ISO C standard
  5245. introduce a second set of functions which are operating on “wide
  5246. characters” (*note Extended Char Intro::). These functions don't have
  5247. the problems the single-byte versions have since every wide character is
  5248. a legal, interpretable value. This does not mean that cutting wide
  5249. strings at arbitrary points is without problems. It normally is for
  5250. alphabet-based languages (except for non-normalized text) but languages
  5251. based on syllables still have the problem that more than one wide
  5252. character is necessary to complete a logical unit. This is a higher
  5253. level problem which the C library functions are not designed to solve.
  5254. But it is at least good that no invalid byte sequences can be created.
  5255. Also, the higher level functions can also much more easily operate on
  5256. wide characters than on multibyte characters so that a common strategy
  5257. is to use wide characters internally whenever text is more than simply
  5258. copied.
  5259. The remaining of this chapter will discuss the functions for handling
  5260. wide strings in parallel with the discussion of strings since there is
  5261. almost always an exact equivalent available.
  5262. 
  5263. File: libc.info, Node: String/Array Conventions, Next: String Length, Prev: Representation of Strings, Up: String and Array Utilities
  5264. 5.2 String and Array Conventions
  5265. ================================
  5266. This chapter describes both functions that work on arbitrary arrays or
  5267. blocks of memory, and functions that are specific to strings and wide
  5268. strings.
  5269. Functions that operate on arbitrary blocks of memory have names
  5270. beginning with ‘mem’ and ‘wmem’ (such as ‘memcpy’ and ‘wmemcpy’) and
  5271. invariably take an argument which specifies the size (in bytes and wide
  5272. characters respectively) of the block of memory to operate on. The
  5273. array arguments and return values for these functions have type ‘void *’
  5274. or ‘wchar_t *’. As a matter of style, the elements of the arrays used
  5275. with the ‘mem’ functions are referred to as "bytes". You can pass any
  5276. kind of pointer to these functions, and the ‘sizeof’ operator is useful
  5277. in computing the value for the size argument. Parameters to the ‘wmem’
  5278. functions must be of type ‘wchar_t *’. These functions are not really
  5279. usable with anything but arrays of this type.
  5280. In contrast, functions that operate specifically on strings and wide
  5281. strings have names beginning with ‘str’ and ‘wcs’ respectively (such as
  5282. ‘strcpy’ and ‘wcscpy’) and look for a terminating null byte or null wide
  5283. character instead of requiring an explicit size argument to be passed.
  5284. (Some of these functions accept a specified maximum length, but they
  5285. also check for premature termination.) The array arguments and return
  5286. values for these functions have type ‘char *’ and ‘wchar_t *’
  5287. respectively, and the array elements are referred to as "bytes" and
  5288. "wide characters".
  5289. In many cases, there are both ‘mem’ and ‘str’/‘wcs’ versions of a
  5290. function. The one that is more appropriate to use depends on the exact
  5291. situation. When your program is manipulating arbitrary arrays or blocks
  5292. of storage, then you should always use the ‘mem’ functions. On the
  5293. other hand, when you are manipulating strings it is usually more
  5294. convenient to use the ‘str’/‘wcs’ functions, unless you already know the
  5295. length of the string in advance. The ‘wmem’ functions should be used
  5296. for wide character arrays with known size.
  5297. Some of the memory and string functions take single characters as
  5298. arguments. Since a value of type ‘char’ is automatically promoted into
  5299. a value of type ‘int’ when used as a parameter, the functions are
  5300. declared with ‘int’ as the type of the parameter in question. In case
  5301. of the wide character functions the situation is similar: the parameter
  5302. type for a single wide character is ‘wint_t’ and not ‘wchar_t’. This
  5303. would for many implementations not be necessary since ‘wchar_t’ is large
  5304. enough to not be automatically promoted, but since the ISO C standard
  5305. does not require such a choice of types the ‘wint_t’ type is used.
  5306. 
  5307. File: libc.info, Node: String Length, Next: Copying Strings and Arrays, Prev: String/Array Conventions, Up: String and Array Utilities
  5308. 5.3 String Length
  5309. =================
  5310. You can get the length of a string using the ‘strlen’ function. This
  5311. function is declared in the header file ‘string.h’.
  5312. -- Function: size_t strlen (const char *S)
  5313. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5314. Concepts::.
  5315. The ‘strlen’ function returns the length of the string S in bytes.
  5316. (In other words, it returns the offset of the terminating null byte
  5317. within the array.)
  5318. For example,
  5319. strlen ("hello, world")
  5320. ⇒ 12
  5321. When applied to an array, the ‘strlen’ function returns the length
  5322. of the string stored there, not its allocated size. You can get
  5323. the allocated size of the array that holds a string using the
  5324. ‘sizeof’ operator:
  5325. char string[32] = "hello, world";
  5326. sizeof (string)
  5327. ⇒ 32
  5328. strlen (string)
  5329. ⇒ 12
  5330. But beware, this will not work unless STRING is the array itself,
  5331. not a pointer to it. For example:
  5332. char string[32] = "hello, world";
  5333. char *ptr = string;
  5334. sizeof (string)
  5335. ⇒ 32
  5336. sizeof (ptr)
  5337. ⇒ 4 /* (on a machine with 4 byte pointers) */
  5338. This is an easy mistake to make when you are working with functions
  5339. that take string arguments; those arguments are always pointers,
  5340. not arrays.
  5341. It must also be noted that for multibyte encoded strings the return
  5342. value does not have to correspond to the number of characters in
  5343. the string. To get this value the string can be converted to wide
  5344. characters and ‘wcslen’ can be used or something like the following
  5345. code can be used:
  5346. /* The input is in ‘string’.
  5347. The length is expected in ‘n’. */
  5348. {
  5349. mbstate_t t;
  5350. char *scopy = string;
  5351. /* In initial state. */
  5352. memset (&t, '\0', sizeof (t));
  5353. /* Determine number of characters. */
  5354. n = mbsrtowcs (NULL, &scopy, strlen (scopy), &t);
  5355. }
  5356. This is cumbersome to do so if the number of characters (as opposed
  5357. to bytes) is needed often it is better to work with wide
  5358. characters.
  5359. The wide character equivalent is declared in ‘wchar.h’.
  5360. -- Function: size_t wcslen (const wchar_t *WS)
  5361. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5362. Concepts::.
  5363. The ‘wcslen’ function is the wide character equivalent to ‘strlen’.
  5364. The return value is the number of wide characters in the wide
  5365. string pointed to by WS (this is also the offset of the terminating
  5366. null wide character of WS).
  5367. Since there are no multi wide character sequences making up one
  5368. wide character the return value is not only the offset in the
  5369. array, it is also the number of wide characters.
  5370. This function was introduced in Amendment 1 to ISO C90.
  5371. -- Function: size_t strnlen (const char *S, size_t MAXLEN)
  5372. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5373. Concepts::.
  5374. This returns the offset of the first null byte in the array S,
  5375. except that it returns MAXLEN if the first MAXLEN bytes are all
  5376. non-null. Therefore this function is equivalent to ‘(strlen (S) <
  5377. MAXLEN ? strlen (S) : MAXLEN)’ but it is more efficient and works
  5378. even if S is not null-terminated so long as MAXLEN does not exceed
  5379. the size of S's array.
  5380. char string[32] = "hello, world";
  5381. strnlen (string, 32)
  5382. ⇒ 12
  5383. strnlen (string, 5)
  5384. ⇒ 5
  5385. This function is part of POSIX.1-2008 and later editions, but was
  5386. available in the GNU C Library and other systems as an extension
  5387. long before it was standardized. It is declared in ‘string.h’.
  5388. -- Function: size_t wcsnlen (const wchar_t *WS, size_t MAXLEN)
  5389. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5390. Concepts::.
  5391. ‘wcsnlen’ is the wide character equivalent to ‘strnlen’. The
  5392. MAXLEN parameter specifies the maximum number of wide characters.
  5393. This function is part of POSIX.1-2008 and later editions, and is
  5394. declared in ‘wchar.h’.
  5395. 
  5396. File: libc.info, Node: Copying Strings and Arrays, Next: Concatenating Strings, Prev: String Length, Up: String and Array Utilities
  5397. 5.4 Copying Strings and Arrays
  5398. ==============================
  5399. You can use the functions described in this section to copy the contents
  5400. of strings, wide strings, and arrays. The ‘str’ and ‘mem’ functions are
  5401. declared in ‘string.h’ while the ‘w’ functions are declared in
  5402. ‘wchar.h’.
  5403. A helpful way to remember the ordering of the arguments to the
  5404. functions in this section is that it corresponds to an assignment
  5405. expression, with the destination array specified to the left of the
  5406. source array. Most of these functions return the address of the
  5407. destination array; a few return the address of the destination's
  5408. terminating null, or of just past the destination.
  5409. Most of these functions do not work properly if the source and
  5410. destination arrays overlap. For example, if the beginning of the
  5411. destination array overlaps the end of the source array, the original
  5412. contents of that part of the source array may get overwritten before it
  5413. is copied. Even worse, in the case of the string functions, the null
  5414. byte marking the end of the string may be lost, and the copy function
  5415. might get stuck in a loop trashing all the memory allocated to your
  5416. program.
  5417. All functions that have problems copying between overlapping arrays
  5418. are explicitly identified in this manual. In addition to functions in
  5419. this section, there are a few others like ‘sprintf’ (*note Formatted
  5420. Output Functions::) and ‘scanf’ (*note Formatted Input Functions::).
  5421. -- Function: void * memcpy (void *restrict TO, const void *restrict
  5422. FROM, size_t SIZE)
  5423. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5424. Concepts::.
  5425. The ‘memcpy’ function copies SIZE bytes from the object beginning
  5426. at FROM into the object beginning at TO. The behavior of this
  5427. function is undefined if the two arrays TO and FROM overlap; use
  5428. ‘memmove’ instead if overlapping is possible.
  5429. The value returned by ‘memcpy’ is the value of TO.
  5430. Here is an example of how you might use ‘memcpy’ to copy the
  5431. contents of an array:
  5432. struct foo *oldarray, *newarray;
  5433. int arraysize;
  5434. ...
  5435. memcpy (new, old, arraysize * sizeof (struct foo));
  5436. -- Function: wchar_t * wmemcpy (wchar_t *restrict WTO, const wchar_t
  5437. *restrict WFROM, size_t SIZE)
  5438. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5439. Concepts::.
  5440. The ‘wmemcpy’ function copies SIZE wide characters from the object
  5441. beginning at WFROM into the object beginning at WTO. The behavior
  5442. of this function is undefined if the two arrays WTO and WFROM
  5443. overlap; use ‘wmemmove’ instead if overlapping is possible.
  5444. The following is a possible implementation of ‘wmemcpy’ but there
  5445. are more optimizations possible.
  5446. wchar_t *
  5447. wmemcpy (wchar_t *restrict wto, const wchar_t *restrict wfrom,
  5448. size_t size)
  5449. {
  5450. return (wchar_t *) memcpy (wto, wfrom, size * sizeof (wchar_t));
  5451. }
  5452. The value returned by ‘wmemcpy’ is the value of WTO.
  5453. This function was introduced in Amendment 1 to ISO C90.
  5454. -- Function: void * mempcpy (void *restrict TO, const void *restrict
  5455. FROM, size_t SIZE)
  5456. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5457. Concepts::.
  5458. The ‘mempcpy’ function is nearly identical to the ‘memcpy’
  5459. function. It copies SIZE bytes from the object beginning at ‘from’
  5460. into the object pointed to by TO. But instead of returning the
  5461. value of TO it returns a pointer to the byte following the last
  5462. written byte in the object beginning at TO. I.e., the value is
  5463. ‘((void *) ((char *) TO + SIZE))’.
  5464. This function is useful in situations where a number of objects
  5465. shall be copied to consecutive memory positions.
  5466. void *
  5467. combine (void *o1, size_t s1, void *o2, size_t s2)
  5468. {
  5469. void *result = malloc (s1 + s2);
  5470. if (result != NULL)
  5471. mempcpy (mempcpy (result, o1, s1), o2, s2);
  5472. return result;
  5473. }
  5474. This function is a GNU extension.
  5475. -- Function: wchar_t * wmempcpy (wchar_t *restrict WTO, const wchar_t
  5476. *restrict WFROM, size_t SIZE)
  5477. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5478. Concepts::.
  5479. The ‘wmempcpy’ function is nearly identical to the ‘wmemcpy’
  5480. function. It copies SIZE wide characters from the object beginning
  5481. at ‘wfrom’ into the object pointed to by WTO. But instead of
  5482. returning the value of WTO it returns a pointer to the wide
  5483. character following the last written wide character in the object
  5484. beginning at WTO. I.e., the value is ‘WTO + SIZE’.
  5485. This function is useful in situations where a number of objects
  5486. shall be copied to consecutive memory positions.
  5487. The following is a possible implementation of ‘wmemcpy’ but there
  5488. are more optimizations possible.
  5489. wchar_t *
  5490. wmempcpy (wchar_t *restrict wto, const wchar_t *restrict wfrom,
  5491. size_t size)
  5492. {
  5493. return (wchar_t *) mempcpy (wto, wfrom, size * sizeof (wchar_t));
  5494. }
  5495. This function is a GNU extension.
  5496. -- Function: void * memmove (void *TO, const void *FROM, size_t SIZE)
  5497. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5498. Concepts::.
  5499. ‘memmove’ copies the SIZE bytes at FROM into the SIZE bytes at TO,
  5500. even if those two blocks of space overlap. In the case of overlap,
  5501. ‘memmove’ is careful to copy the original values of the bytes in
  5502. the block at FROM, including those bytes which also belong to the
  5503. block at TO.
  5504. The value returned by ‘memmove’ is the value of TO.
  5505. -- Function: wchar_t * wmemmove (wchar_t *WTO, const wchar_t *WFROM,
  5506. size_t SIZE)
  5507. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5508. Concepts::.
  5509. ‘wmemmove’ copies the SIZE wide characters at WFROM into the SIZE
  5510. wide characters at WTO, even if those two blocks of space overlap.
  5511. In the case of overlap, ‘wmemmove’ is careful to copy the original
  5512. values of the wide characters in the block at WFROM, including
  5513. those wide characters which also belong to the block at WTO.
  5514. The following is a possible implementation of ‘wmemcpy’ but there
  5515. are more optimizations possible.
  5516. wchar_t *
  5517. wmempcpy (wchar_t *restrict wto, const wchar_t *restrict wfrom,
  5518. size_t size)
  5519. {
  5520. return (wchar_t *) mempcpy (wto, wfrom, size * sizeof (wchar_t));
  5521. }
  5522. The value returned by ‘wmemmove’ is the value of WTO.
  5523. This function is a GNU extension.
  5524. -- Function: void * memccpy (void *restrict TO, const void *restrict
  5525. FROM, int C, size_t SIZE)
  5526. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5527. Concepts::.
  5528. This function copies no more than SIZE bytes from FROM to TO,
  5529. stopping if a byte matching C is found. The return value is a
  5530. pointer into TO one byte past where C was copied, or a null pointer
  5531. if no byte matching C appeared in the first SIZE bytes of FROM.
  5532. -- Function: void * memset (void *BLOCK, int C, size_t SIZE)
  5533. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5534. Concepts::.
  5535. This function copies the value of C (converted to an ‘unsigned
  5536. char’) into each of the first SIZE bytes of the object beginning at
  5537. BLOCK. It returns the value of BLOCK.
  5538. -- Function: wchar_t * wmemset (wchar_t *BLOCK, wchar_t WC, size_t
  5539. SIZE)
  5540. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5541. Concepts::.
  5542. This function copies the value of WC into each of the first SIZE
  5543. wide characters of the object beginning at BLOCK. It returns the
  5544. value of BLOCK.
  5545. -- Function: char * strcpy (char *restrict TO, const char *restrict
  5546. FROM)
  5547. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5548. Concepts::.
  5549. This copies bytes from the string FROM (up to and including the
  5550. terminating null byte) into the string TO. Like ‘memcpy’, this
  5551. function has undefined results if the strings overlap. The return
  5552. value is the value of TO.
  5553. -- Function: wchar_t * wcscpy (wchar_t *restrict WTO, const wchar_t
  5554. *restrict WFROM)
  5555. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5556. Concepts::.
  5557. This copies wide characters from the wide string WFROM (up to and
  5558. including the terminating null wide character) into the string WTO.
  5559. Like ‘wmemcpy’, this function has undefined results if the strings
  5560. overlap. The return value is the value of WTO.
  5561. -- Function: char * strdup (const char *S)
  5562. Preliminary: | MT-Safe | AS-Unsafe heap | AC-Unsafe mem | *Note
  5563. POSIX Safety Concepts::.
  5564. This function copies the string S into a newly allocated string.
  5565. The string is allocated using ‘malloc’; see *note Unconstrained
  5566. Allocation::. If ‘malloc’ cannot allocate space for the new
  5567. string, ‘strdup’ returns a null pointer. Otherwise it returns a
  5568. pointer to the new string.
  5569. -- Function: wchar_t * wcsdup (const wchar_t *WS)
  5570. Preliminary: | MT-Safe | AS-Unsafe heap | AC-Unsafe mem | *Note
  5571. POSIX Safety Concepts::.
  5572. This function copies the wide string WS into a newly allocated
  5573. string. The string is allocated using ‘malloc’; see *note
  5574. Unconstrained Allocation::. If ‘malloc’ cannot allocate space for
  5575. the new string, ‘wcsdup’ returns a null pointer. Otherwise it
  5576. returns a pointer to the new wide string.
  5577. This function is a GNU extension.
  5578. -- Function: char * stpcpy (char *restrict TO, const char *restrict
  5579. FROM)
  5580. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5581. Concepts::.
  5582. This function is like ‘strcpy’, except that it returns a pointer to
  5583. the end of the string TO (that is, the address of the terminating
  5584. null byte ‘to + strlen (from)’) rather than the beginning.
  5585. For example, this program uses ‘stpcpy’ to concatenate ‘foo’ and
  5586. ‘bar’ to produce ‘foobar’, which it then prints.
  5587. #include <string.h>
  5588. #include <stdio.h>
  5589. int
  5590. main (void)
  5591. {
  5592. char buffer[10];
  5593. char *to = buffer;
  5594. to = stpcpy (to, "foo");
  5595. to = stpcpy (to, "bar");
  5596. puts (buffer);
  5597. return 0;
  5598. }
  5599. This function is part of POSIX.1-2008 and later editions, but was
  5600. available in the GNU C Library and other systems as an extension
  5601. long before it was standardized.
  5602. Its behavior is undefined if the strings overlap. The function is
  5603. declared in ‘string.h’.
  5604. -- Function: wchar_t * wcpcpy (wchar_t *restrict WTO, const wchar_t
  5605. *restrict WFROM)
  5606. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5607. Concepts::.
  5608. This function is like ‘wcscpy’, except that it returns a pointer to
  5609. the end of the string WTO (that is, the address of the terminating
  5610. null wide character ‘wto + wcslen (wfrom)’) rather than the
  5611. beginning.
  5612. This function is not part of ISO or POSIX but was found useful
  5613. while developing the GNU C Library itself.
  5614. The behavior of ‘wcpcpy’ is undefined if the strings overlap.
  5615. ‘wcpcpy’ is a GNU extension and is declared in ‘wchar.h’.
  5616. -- Macro: char * strdupa (const char *S)
  5617. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5618. Concepts::.
  5619. This macro is similar to ‘strdup’ but allocates the new string
  5620. using ‘alloca’ instead of ‘malloc’ (*note Variable Size
  5621. Automatic::). This means of course the returned string has the
  5622. same limitations as any block of memory allocated using ‘alloca’.
  5623. For obvious reasons ‘strdupa’ is implemented only as a macro; you
  5624. cannot get the address of this function. Despite this limitation
  5625. it is a useful function. The following code shows a situation
  5626. where using ‘malloc’ would be a lot more expensive.
  5627. #define _GNU_SOURCE 1
  5628. #include <paths.h>
  5629. #include <string.h>
  5630. #include <stdio.h>
  5631. const char path[] = _PATH_STDPATH;
  5632. int
  5633. main (void)
  5634. {
  5635. char *wr_path = strdupa (path);
  5636. char *cp = strtok (wr_path, ":");
  5637. while (cp != NULL)
  5638. {
  5639. puts (cp);
  5640. cp = strtok (NULL, ":");
  5641. }
  5642. return 0;
  5643. }
  5644. Please note that calling ‘strtok’ using PATH directly is invalid.
  5645. It is also not allowed to call ‘strdupa’ in the argument list of
  5646. ‘strtok’ since ‘strdupa’ uses ‘alloca’ (*note Variable Size
  5647. Automatic::) can interfere with the parameter passing.
  5648. This function is only available if GNU CC is used.
  5649. -- Function: void bcopy (const void *FROM, void *TO, size_t SIZE)
  5650. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5651. Concepts::.
  5652. This is a partially obsolete alternative for ‘memmove’, derived
  5653. from BSD. Note that it is not quite equivalent to ‘memmove’,
  5654. because the arguments are not in the same order and there is no
  5655. return value.
  5656. -- Function: void bzero (void *BLOCK, size_t SIZE)
  5657. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5658. Concepts::.
  5659. This is a partially obsolete alternative for ‘memset’, derived from
  5660. BSD. Note that it is not as general as ‘memset’, because the only
  5661. value it can store is zero.
  5662. 
  5663. File: libc.info, Node: Concatenating Strings, Next: Truncating Strings, Prev: Copying Strings and Arrays, Up: String and Array Utilities
  5664. 5.5 Concatenating Strings
  5665. =========================
  5666. The functions described in this section concatenate the contents of a
  5667. string or wide string to another. They follow the string-copying
  5668. functions in their conventions. *Note Copying Strings and Arrays::.
  5669. ‘strcat’ is declared in the header file ‘string.h’ while ‘wcscat’ is
  5670. declared in ‘wchar.h’.
  5671. As noted below, these functions are problematic as their callers may
  5672. have performance issues.
  5673. -- Function: char * strcat (char *restrict TO, const char *restrict
  5674. FROM)
  5675. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5676. Concepts::.
  5677. The ‘strcat’ function is similar to ‘strcpy’, except that the bytes
  5678. from FROM are concatenated or appended to the end of TO, instead of
  5679. overwriting it. That is, the first byte from FROM overwrites the
  5680. null byte marking the end of TO.
  5681. An equivalent definition for ‘strcat’ would be:
  5682. char *
  5683. strcat (char *restrict to, const char *restrict from)
  5684. {
  5685. strcpy (to + strlen (to), from);
  5686. return to;
  5687. }
  5688. This function has undefined results if the strings overlap.
  5689. As noted below, this function has significant performance issues.
  5690. -- Function: wchar_t * wcscat (wchar_t *restrict WTO, const wchar_t
  5691. *restrict WFROM)
  5692. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5693. Concepts::.
  5694. The ‘wcscat’ function is similar to ‘wcscpy’, except that the wide
  5695. characters from WFROM are concatenated or appended to the end of
  5696. WTO, instead of overwriting it. That is, the first wide character
  5697. from WFROM overwrites the null wide character marking the end of
  5698. WTO.
  5699. An equivalent definition for ‘wcscat’ would be:
  5700. wchar_t *
  5701. wcscat (wchar_t *wto, const wchar_t *wfrom)
  5702. {
  5703. wcscpy (wto + wcslen (wto), wfrom);
  5704. return wto;
  5705. }
  5706. This function has undefined results if the strings overlap.
  5707. As noted below, this function has significant performance issues.
  5708. Programmers using the ‘strcat’ or ‘wcscat’ functions (or the
  5709. ‘strlcat’, ‘strncat’ and ‘wcsncat’ functions defined in a later section,
  5710. for that matter) can easily be recognized as lazy and reckless. In
  5711. almost all situations the lengths of the participating strings are known
  5712. (it better should be since how can one otherwise ensure the allocated
  5713. size of the buffer is sufficient?) Or at least, one could know them if
  5714. one keeps track of the results of the various function calls. But then
  5715. it is very inefficient to use ‘strcat’/‘wcscat’. A lot of time is
  5716. wasted finding the end of the destination string so that the actual
  5717. copying can start. This is a common example:
  5718. /* This function concatenates arbitrarily many strings. The last
  5719. parameter must be ‘NULL’. */
  5720. char *
  5721. concat (const char *str, ...)
  5722. {
  5723. va_list ap, ap2;
  5724. size_t total = 1;
  5725. va_start (ap, str);
  5726. va_copy (ap2, ap);
  5727. /* Determine how much space we need. */
  5728. for (const char *s = str; s != NULL; s = va_arg (ap, const char *))
  5729. total += strlen (s);
  5730. va_end (ap);
  5731. char *result = malloc (total);
  5732. if (result != NULL)
  5733. {
  5734. result[0] = '\0';
  5735. /* Copy the strings. */
  5736. for (s = str; s != NULL; s = va_arg (ap2, const char *))
  5737. strcat (result, s);
  5738. }
  5739. va_end (ap2);
  5740. return result;
  5741. }
  5742. This looks quite simple, especially the second loop where the strings
  5743. are actually copied. But these innocent lines hide a major performance
  5744. penalty. Just imagine that ten strings of 100 bytes each have to be
  5745. concatenated. For the second string we search the already stored 100
  5746. bytes for the end of the string so that we can append the next string.
  5747. For all strings in total the comparisons necessary to find the end of
  5748. the intermediate results sums up to 5500! If we combine the copying
  5749. with the search for the allocation we can write this function more
  5750. efficiently:
  5751. char *
  5752. concat (const char *str, ...)
  5753. {
  5754. size_t allocated = 100;
  5755. char *result = malloc (allocated);
  5756. if (result != NULL)
  5757. {
  5758. va_list ap;
  5759. size_t resultlen = 0;
  5760. char *newp;
  5761. va_start (ap, str);
  5762. for (const char *s = str; s != NULL; s = va_arg (ap, const char *))
  5763. {
  5764. size_t len = strlen (s);
  5765. /* Resize the allocated memory if necessary. */
  5766. if (resultlen + len + 1 > allocated)
  5767. {
  5768. allocated += len;
  5769. newp = reallocarray (result, allocated, 2);
  5770. allocated *= 2;
  5771. if (newp == NULL)
  5772. {
  5773. free (result);
  5774. return NULL;
  5775. }
  5776. result = newp;
  5777. }
  5778. memcpy (result + resultlen, s, len);
  5779. resultlen += len;
  5780. }
  5781. /* Terminate the result string. */
  5782. result[resultlen++] = '\0';
  5783. /* Resize memory to the optimal size. */
  5784. newp = realloc (result, resultlen);
  5785. if (newp != NULL)
  5786. result = newp;
  5787. va_end (ap);
  5788. }
  5789. return result;
  5790. }
  5791. With a bit more knowledge about the input strings one could fine-tune
  5792. the memory allocation. The difference we are pointing to here is that
  5793. we don't use ‘strcat’ anymore. We always keep track of the length of
  5794. the current intermediate result so we can save ourselves the search for
  5795. the end of the string and use ‘mempcpy’. Please note that we also don't
  5796. use ‘stpcpy’ which might seem more natural since we are handling
  5797. strings. But this is not necessary since we already know the length of
  5798. the string and therefore can use the faster memory copying function.
  5799. The example would work for wide characters the same way.
  5800. Whenever a programmer feels the need to use ‘strcat’ she or he should
  5801. think twice and look through the program to see whether the code cannot
  5802. be rewritten to take advantage of already calculated results. The
  5803. related functions ‘strlcat’, ‘strncat’, ‘wcscat’ and ‘wcsncat’ are
  5804. almost always unnecessary, too. Again: it is almost always unnecessary
  5805. to use functions like ‘strcat’.
  5806. 
  5807. File: libc.info, Node: Truncating Strings, Next: String/Array Comparison, Prev: Concatenating Strings, Up: String and Array Utilities
  5808. 5.6 Truncating Strings while Copying
  5809. ====================================
  5810. The functions described in this section copy or concatenate the
  5811. possibly-truncated contents of a string or array to another, and
  5812. similarly for wide strings. They follow the string-copying functions in
  5813. their header conventions. *Note Copying Strings and Arrays::. The
  5814. ‘str’ functions are declared in the header file ‘string.h’ and the ‘wc’
  5815. functions are declared in the file ‘wchar.h’.
  5816. As noted below, these functions are problematic as their callers may
  5817. have truncation-related bugs and performance issues.
  5818. -- Function: char * strncpy (char *restrict TO, const char *restrict
  5819. FROM, size_t SIZE)
  5820. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5821. Concepts::.
  5822. This function is similar to ‘strcpy’ but always copies exactly SIZE
  5823. bytes into TO.
  5824. If FROM does not contain a null byte in its first SIZE bytes,
  5825. ‘strncpy’ copies just the first SIZE bytes. In this case no null
  5826. terminator is written into TO.
  5827. Otherwise FROM must be a string with length less than SIZE. In
  5828. this case ‘strncpy’ copies all of FROM, followed by enough null
  5829. bytes to add up to SIZE bytes in all.
  5830. The behavior of ‘strncpy’ is undefined if the strings overlap.
  5831. This function was designed for now-rarely-used arrays consisting of
  5832. non-null bytes followed by zero or more null bytes. It needs to
  5833. set all SIZE bytes of the destination, even when SIZE is much
  5834. greater than the length of FROM. As noted below, this function is
  5835. generally a poor choice for processing strings.
  5836. -- Function: wchar_t * wcsncpy (wchar_t *restrict WTO, const wchar_t
  5837. *restrict WFROM, size_t SIZE)
  5838. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5839. Concepts::.
  5840. This function is similar to ‘wcscpy’ but always copies exactly SIZE
  5841. wide characters into WTO.
  5842. If WFROM does not contain a null wide character in its first SIZE
  5843. wide characters, then ‘wcsncpy’ copies just the first SIZE wide
  5844. characters. In this case no null terminator is written into WTO.
  5845. Otherwise WFROM must be a wide string with length less than SIZE.
  5846. In this case ‘wcsncpy’ copies all of WFROM, followed by enough null
  5847. wide characters to add up to SIZE wide characters in all.
  5848. The behavior of ‘wcsncpy’ is undefined if the strings overlap.
  5849. This function is the wide-character counterpart of ‘strncpy’ and
  5850. suffers from most of the problems that ‘strncpy’ does. For
  5851. example, as noted below, this function is generally a poor choice
  5852. for processing strings.
  5853. -- Function: char * strndup (const char *S, size_t SIZE)
  5854. Preliminary: | MT-Safe | AS-Unsafe heap | AC-Unsafe mem | *Note
  5855. POSIX Safety Concepts::.
  5856. This function is similar to ‘strdup’ but always copies at most SIZE
  5857. bytes into the newly allocated string.
  5858. If the length of S is more than SIZE, then ‘strndup’ copies just
  5859. the first SIZE bytes and adds a closing null byte. Otherwise all
  5860. bytes are copied and the string is terminated.
  5861. This function differs from ‘strncpy’ in that it always terminates
  5862. the destination string.
  5863. As noted below, this function is generally a poor choice for
  5864. processing strings.
  5865. ‘strndup’ is a GNU extension.
  5866. -- Macro: char * strndupa (const char *S, size_t SIZE)
  5867. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5868. Concepts::.
  5869. This function is similar to ‘strndup’ but like ‘strdupa’ it
  5870. allocates the new string using ‘alloca’ *note Variable Size
  5871. Automatic::. The same advantages and limitations of ‘strdupa’ are
  5872. valid for ‘strndupa’, too.
  5873. This function is implemented only as a macro, just like ‘strdupa’.
  5874. Just as ‘strdupa’ this macro also must not be used inside the
  5875. parameter list in a function call.
  5876. As noted below, this function is generally a poor choice for
  5877. processing strings.
  5878. ‘strndupa’ is only available if GNU CC is used.
  5879. -- Function: char * stpncpy (char *restrict TO, const char *restrict
  5880. FROM, size_t SIZE)
  5881. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5882. Concepts::.
  5883. This function is similar to ‘stpcpy’ but copies always exactly SIZE
  5884. bytes into TO.
  5885. If the length of FROM is more than SIZE, then ‘stpncpy’ copies just
  5886. the first SIZE bytes and returns a pointer to the byte directly
  5887. following the one which was copied last. Note that in this case
  5888. there is no null terminator written into TO.
  5889. If the length of FROM is less than SIZE, then ‘stpncpy’ copies all
  5890. of FROM, followed by enough null bytes to add up to SIZE bytes in
  5891. all. This behavior is rarely useful, but it is implemented to be
  5892. useful in contexts where this behavior of the ‘strncpy’ is used.
  5893. ‘stpncpy’ returns a pointer to the _first_ written null byte.
  5894. This function is not part of ISO or POSIX but was found useful
  5895. while developing the GNU C Library itself.
  5896. Its behavior is undefined if the strings overlap. The function is
  5897. declared in ‘string.h’.
  5898. As noted below, this function is generally a poor choice for
  5899. processing strings.
  5900. -- Function: wchar_t * wcpncpy (wchar_t *restrict WTO, const wchar_t
  5901. *restrict WFROM, size_t SIZE)
  5902. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5903. Concepts::.
  5904. This function is similar to ‘wcpcpy’ but copies always exactly
  5905. WSIZE wide characters into WTO.
  5906. If the length of WFROM is more than SIZE, then ‘wcpncpy’ copies
  5907. just the first SIZE wide characters and returns a pointer to the
  5908. wide character directly following the last non-null wide character
  5909. which was copied last. Note that in this case there is no null
  5910. terminator written into WTO.
  5911. If the length of WFROM is less than SIZE, then ‘wcpncpy’ copies all
  5912. of WFROM, followed by enough null wide characters to add up to SIZE
  5913. wide characters in all. This behavior is rarely useful, but it is
  5914. implemented to be useful in contexts where this behavior of the
  5915. ‘wcsncpy’ is used. ‘wcpncpy’ returns a pointer to the _first_
  5916. written null wide character.
  5917. This function is not part of ISO or POSIX but was found useful
  5918. while developing the GNU C Library itself.
  5919. Its behavior is undefined if the strings overlap.
  5920. As noted below, this function is generally a poor choice for
  5921. processing strings.
  5922. ‘wcpncpy’ is a GNU extension.
  5923. -- Function: char * strncat (char *restrict TO, const char *restrict
  5924. FROM, size_t SIZE)
  5925. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5926. Concepts::.
  5927. This function is like ‘strcat’ except that not more than SIZE bytes
  5928. from FROM are appended to the end of TO, and FROM need not be
  5929. null-terminated. A single null byte is also always appended to TO,
  5930. so the total allocated size of TO must be at least ‘SIZE + 1’ bytes
  5931. longer than its initial length.
  5932. The ‘strncat’ function could be implemented like this:
  5933. char *
  5934. strncat (char *to, const char *from, size_t size)
  5935. {
  5936. size_t len = strlen (to);
  5937. memcpy (to + len, from, strnlen (from, size));
  5938. to[len + strnlen (from, size)] = '\0';
  5939. return to;
  5940. }
  5941. The behavior of ‘strncat’ is undefined if the strings overlap.
  5942. As a companion to ‘strncpy’, ‘strncat’ was designed for
  5943. now-rarely-used arrays consisting of non-null bytes followed by
  5944. zero or more null bytes. However, As noted below, this function is
  5945. generally a poor choice for processing strings. Also, this
  5946. function has significant performance issues. *Note Concatenating
  5947. Strings::.
  5948. -- Function: wchar_t * wcsncat (wchar_t *restrict WTO, const wchar_t
  5949. *restrict WFROM, size_t SIZE)
  5950. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5951. Concepts::.
  5952. This function is like ‘wcscat’ except that not more than SIZE wide
  5953. characters from FROM are appended to the end of TO, and FROM need
  5954. not be null-terminated. A single null wide character is also
  5955. always appended to TO, so the total allocated size of TO must be at
  5956. least ‘wcsnlen (WFROM, SIZE) + 1’ wide characters longer than its
  5957. initial length.
  5958. The ‘wcsncat’ function could be implemented like this:
  5959. wchar_t *
  5960. wcsncat (wchar_t *restrict wto, const wchar_t *restrict wfrom,
  5961. size_t size)
  5962. {
  5963. size_t len = wcslen (wto);
  5964. memcpy (wto + len, wfrom, wcsnlen (wfrom, size) * sizeof (wchar_t));
  5965. wto[len + wcsnlen (wfrom, size)] = L'\0';
  5966. return wto;
  5967. }
  5968. The behavior of ‘wcsncat’ is undefined if the strings overlap.
  5969. As noted below, this function is generally a poor choice for
  5970. processing strings. Also, this function has significant
  5971. performance issues. *Note Concatenating Strings::.
  5972. -- Function: size_t strlcpy (char *restrict TO, const char *restrict
  5973. FROM, size_t SIZE)
  5974. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5975. Concepts::.
  5976. This function copies the string FROM to the destination array TO,
  5977. limiting the result's size (including the null terminator) to SIZE.
  5978. The caller should ensure that SIZE includes room for the result's
  5979. terminating null byte.
  5980. If SIZE is greater than the length of the string FROM, this
  5981. function copies the non-null bytes of the string FROM to the
  5982. destination array TO, and terminates the copy with a null byte.
  5983. Like other string functions such as ‘strcpy’, but unlike ‘strncpy’,
  5984. any remaining bytes in the destination array remain unchanged.
  5985. If SIZE is nonzero and less than or equal to the the length of the
  5986. string FROM, this function copies only the first ‘SIZE - 1’ bytes
  5987. to the destination array TO, and writes a terminating null byte to
  5988. the last byte of the array.
  5989. This function returns the length of the string FROM. This means
  5990. that truncation occurs if and only if the returned value is greater
  5991. than or equal to SIZE.
  5992. The behavior is undefined if TO or FROM is a null pointer, or if
  5993. the destination array's size is less than SIZE, or if the string
  5994. FROM overlaps the first SIZE bytes of the destination array.
  5995. As noted below, this function is generally a poor choice for
  5996. processing strings. Also, this function has a performance issue,
  5997. as its time cost is proportional to the length of FROM even when
  5998. SIZE is small.
  5999. This function was originally derived from OpenBSD 2.4, but was
  6000. added in POSIX.1-2024.
  6001. -- Function: size_t wcslcpy (wchar_t *restrict TO, const wchar_t
  6002. *restrict FROM, size_t SIZE)
  6003. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  6004. Concepts::.
  6005. This function is a variant of ‘strlcpy’ for wide strings. The SIZE
  6006. argument counts the length of the destination buffer in wide
  6007. characters (and not bytes).
  6008. This function was originally a BSD extension, but was added in
  6009. POSIX.1-2024.
  6010. -- Function: size_t strlcat (char *restrict TO, const char *restrict
  6011. FROM, size_t SIZE)
  6012. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  6013. Concepts::.
  6014. This function appends the string FROM to the string TO, limiting
  6015. the result's total size (including the null terminator) to SIZE.
  6016. The caller should ensure that SIZE includes room for the result's
  6017. terminating null byte.
  6018. This function copies as much as possible of the string FROM into
  6019. the array at TO of SIZE bytes, starting at the terminating null
  6020. byte of the original string TO. In effect, this appends the string
  6021. FROM to the string TO. Although the resulting string will contain
  6022. a null terminator, it can be truncated (not all bytes in FROM may
  6023. be copied).
  6024. This function returns the sum of the original length of TO and the
  6025. length of FROM. This means that truncation occurs if and only if
  6026. the returned value is greater than or equal to SIZE.
  6027. The behavior is undefined if TO or FROM is a null pointer, or if
  6028. the destination array's size is less than SIZE, or if the
  6029. destination array does not contain a null byte in its first SIZE
  6030. bytes, or if the string FROM overlaps the first SIZE bytes of the
  6031. destination array.
  6032. As noted below, this function is generally a poor choice for
  6033. processing strings. Also, this function has significant
  6034. performance issues. *Note Concatenating Strings::.
  6035. This function was originally derived from OpenBSD 2.4, but was
  6036. added in POSIX.1-2024.
  6037. -- Function: size_t wcslcat (wchar_t *restrict TO, const wchar_t
  6038. *restrict FROM, size_t SIZE)
  6039. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  6040. Concepts::.
  6041. This function is a variant of ‘strlcat’ for wide strings. The SIZE
  6042. argument counts the length of the destination buffer in wide
  6043. characters (and not bytes).
  6044. This function was originally a BSD extension, but was added in
  6045. POSIX.1-2024.
  6046. Because these functions can abruptly truncate strings or wide
  6047. strings, they are generally poor choices for processing them. When
  6048. copying or concatening multibyte strings, they can truncate within a
  6049. multibyte character so that the result is not a valid multibyte string.
  6050. When combining or concatenating multibyte or wide strings, they may
  6051. truncate the output after a combining character, resulting in a
  6052. corrupted grapheme. They can cause bugs even when processing
  6053. single-byte strings: for example, when calculating an ASCII-only user
  6054. name, a truncated name can identify the wrong user.
  6055. Although some buffer overruns can be prevented by manually replacing
  6056. calls to copying functions with calls to truncation functions, there are
  6057. often easier and safer automatic techniques, such as fortification
  6058. (*note Source Fortification::) and AddressSanitizer (*note Program
  6059. Instrumentation Options: (gcc)Instrumentation Options.). Because
  6060. truncation functions can mask application bugs that would otherwise be
  6061. caught by the automatic techniques, these functions should be used only
  6062. when the application's underlying logic requires truncation.
  6063. *Note:* GNU programs should not truncate strings or wide strings to
  6064. fit arbitrary size limits. *Note Writing Robust Programs:
  6065. (standards)Semantics. Instead of string-truncation functions, it is
  6066. usually better to use dynamic memory allocation (*note Unconstrained
  6067. Allocation::) and functions such as ‘strdup’ or ‘asprintf’ to construct
  6068. strings.
  6069. 
  6070. File: libc.info, Node: String/Array Comparison, Next: Collation Functions, Prev: Truncating Strings, Up: String and Array Utilities
  6071. 5.7 String/Array Comparison
  6072. ===========================
  6073. You can use the functions in this section to perform comparisons on the
  6074. contents of strings and arrays. As well as checking for equality, these
  6075. functions can also be used as the ordering functions for sorting
  6076. operations. *Note Searching and Sorting::, for an example of this.
  6077. Unlike most comparison operations in C, the string comparison
  6078. functions return a nonzero value if the strings are _not_ equivalent
  6079. rather than if they are. The sign of the value indicates the relative
  6080. ordering of the first part of the strings that are not equivalent: a
  6081. negative value indicates that the first string is "less" than the
  6082. second, while a positive value indicates that the first string is
  6083. "greater".
  6084. The most common use of these functions is to check only for equality.
  6085. This is canonically done with an expression like ‘! strcmp (s1, s2)’.
  6086. All of these functions are declared in the header file ‘string.h’.
  6087. -- Function: int memcmp (const void *A1, const void *A2, size_t SIZE)
  6088. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  6089. Concepts::.
  6090. The function ‘memcmp’ compares the SIZE bytes of memory beginning
  6091. at A1 against the SIZE bytes of memory beginning at A2. The value
  6092. returned has the same sign as the difference between the first
  6093. differing pair of bytes (interpreted as ‘unsigned char’ objects,
  6094. then promoted to ‘int’).
  6095. If the contents of the two blocks are equal, ‘memcmp’ returns ‘0’.
  6096. -- Function: int wmemcmp (const wchar_t *A1, const wchar_t *A2, size_t
  6097. SIZE)
  6098. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  6099. Concepts::.
  6100. The function ‘wmemcmp’ compares the SIZE wide characters beginning
  6101. at A1 against the SIZE wide characters beginning at A2. The value
  6102. returned is smaller than or larger than zero depending on whether
  6103. the first differing wide character is A1 is smaller or larger than
  6104. the corresponding wide character in A2.
  6105. If the contents of the two blocks are equal, ‘wmemcmp’ returns ‘0’.
  6106. On arbitrary arrays, the ‘memcmp’ function is mostly useful for
  6107. testing equality. It usually isn't meaningful to do byte-wise ordering
  6108. comparisons on arrays of things other than bytes. For example, a
  6109. byte-wise comparison on the bytes that make up floating-point numbers
  6110. isn't likely to tell you anything about the relationship between the
  6111. values of the floating-point numbers.
  6112. ‘wmemcmp’ is really only useful to compare arrays of type ‘wchar_t’
  6113. since the function looks at ‘sizeof (wchar_t)’ bytes at a time and this
  6114. number of bytes is system dependent.
  6115. You should also be careful about using ‘memcmp’ to compare objects
  6116. that can contain "holes", such as the padding inserted into structure
  6117. objects to enforce alignment requirements, extra space at the end of
  6118. unions, and extra bytes at the ends of strings whose length is less than
  6119. their allocated size. The contents of these "holes" are indeterminate
  6120. and may cause strange behavior when performing byte-wise comparisons.
  6121. For more predictable results, perform an explicit component-wise
  6122. comparison.
  6123. For example, given a structure type definition like:
  6124. struct foo
  6125. {
  6126. unsigned char tag;
  6127. union
  6128. {
  6129. double f;
  6130. long i;
  6131. char *p;
  6132. } value;
  6133. };
  6134. you are better off writing a specialized comparison function to compare
  6135. ‘struct foo’ objects instead of comparing them with ‘memcmp’.
  6136. -- Function: int strcmp (const char *S1, const char *S2)
  6137. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  6138. Concepts::.
  6139. The ‘strcmp’ function compares the string S1 against S2, returning
  6140. a value that has the same sign as the difference between the first
  6141. differing pair of bytes (interpreted as ‘unsigned char’ objects,
  6142. then promoted to ‘int’).
  6143. If the two strings are equal, ‘strcmp’ returns ‘0’.
  6144. A consequence of the ordering used by ‘strcmp’ is that if S1 is an
  6145. initial substring of S2, then S1 is considered to be "less than"
  6146. S2.
  6147. ‘strcmp’ does not take sorting conventions of the language the
  6148. strings are written in into account. To get that one has to use
  6149. ‘strcoll’.
  6150. -- Function: int wcscmp (const wchar_t *WS1, const wchar_t *WS2)
  6151. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  6152. Concepts::.
  6153. The ‘wcscmp’ function compares the wide string WS1 against WS2.
  6154. The value returned is smaller than or larger than zero depending on
  6155. whether the first differing wide character is WS1 is smaller or
  6156. larger than the corresponding wide character in WS2.
  6157. If the two strings are equal, ‘wcscmp’ returns ‘0’.
  6158. A consequence of the ordering used by ‘wcscmp’ is that if WS1 is an
  6159. initial substring of WS2, then WS1 is considered to be "less than"
  6160. WS2.
  6161. ‘wcscmp’ does not take sorting conventions of the language the
  6162. strings are written in into account. To get that one has to use
  6163. ‘wcscoll’.
  6164. -- Function: int strcasecmp (const char *S1, const char *S2)
  6165. Preliminary: | MT-Safe locale | AS-Safe | AC-Safe | *Note POSIX
  6166. Safety Concepts::.
  6167. This function is like ‘strcmp’, except that differences in case are
  6168. ignored, and its arguments must be multibyte strings. How
  6169. uppercase and lowercase characters are related is determined by the
  6170. currently selected locale. In the standard ‘"C"’ locale the
  6171. characters Ä and ä do not match but in a locale which regards these
  6172. characters as parts of the alphabet they do match.
  6173. ‘strcasecmp’ is derived from BSD.
  6174. -- Function: int wcscasecmp (const wchar_t *WS1, const wchar_t *WS2)
  6175. Preliminary: | MT-Safe locale | AS-Safe | AC-Safe | *Note POSIX
  6176. Safety Concepts::.
  6177. This function is like ‘wcscmp’, except that differences in case are
  6178. ignored. How uppercase and lowercase characters are related is
  6179. determined by the currently selected locale. In the standard ‘"C"’
  6180. locale the characters Ä and ä do not match but in a locale which
  6181. regards these characters as parts of the alphabet they do match.
  6182. ‘wcscasecmp’ is a GNU extension.
  6183. -- Function: int strncmp (const char *S1, const char *S2, size_t SIZE)
  6184. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  6185. Concepts::.
  6186. This function is the similar to ‘strcmp’, except that no more than
  6187. SIZE bytes are compared. In other words, if the two strings are
  6188. the same in their first SIZE bytes, the return value is zero.
  6189. -- Function: int wcsncmp (const wchar_t *WS1, const wchar_t *WS2,
  6190. size_t SIZE)
  6191. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  6192. Concepts::.
  6193. This function is similar to ‘wcscmp’, except that no more than SIZE
  6194. wide characters are compared. In other words, if the two strings
  6195. are the same in their first SIZE wide characters, the return value
  6196. is zero.
  6197. -- Function: int strncasecmp (const char *S1, const char *S2, size_t N)
  6198. Preliminary: | MT-Safe locale | AS-Safe | AC-Safe | *Note POSIX
  6199. Safety Concepts::.
  6200. This function is like ‘strncmp’, except that differences in case
  6201. are ignored, and the compared parts of the arguments should consist
  6202. of valid multibyte characters. Like ‘strcasecmp’, it is locale
  6203. dependent how uppercase and lowercase characters are related.
  6204. ‘strncasecmp’ is a GNU extension.
  6205. -- Function: int wcsncasecmp (const wchar_t *WS1, const wchar_t *S2,
  6206. size_t N)
  6207. Preliminary: | MT-Safe locale | AS-Safe | AC-Safe | *Note POSIX
  6208. Safety Concepts::.
  6209. This function is like ‘wcsncmp’, except that differences in case
  6210. are ignored. Like ‘wcscasecmp’, it is locale dependent how
  6211. uppercase and lowercase characters are related.
  6212. ‘wcsncasecmp’ is a GNU extension.
  6213. Here are some examples showing the use of ‘strcmp’ and ‘strncmp’
  6214. (equivalent examples can be constructed for the wide character
  6215. functions). These examples assume the use of the ASCII character set.
  6216. (If some other character set--say, EBCDIC--is used instead, then the
  6217. glyphs are associated with different numeric codes, and the return
  6218. values and ordering may differ.)
  6219. strcmp ("hello", "hello")
  6220. ⇒ 0 /* These two strings are the same. */
  6221. strcmp ("hello", "Hello")
  6222. ⇒ 32 /* Comparisons are case-sensitive. */
  6223. strcmp ("hello", "world")
  6224. ⇒ -15 /* The byte ‘'h'’ comes before ‘'w'’. */
  6225. strcmp ("hello", "hello, world")
  6226. ⇒ -44 /* Comparing a null byte against a comma. */
  6227. strncmp ("hello", "hello, world", 5)
  6228. ⇒ 0 /* The initial 5 bytes are the same. */
  6229. strncmp ("hello, world", "hello, stupid world!!!", 5)
  6230. ⇒ 0 /* The initial 5 bytes are the same. */
  6231. -- Function: int strverscmp (const char *S1, const char *S2)
  6232. Preliminary: | MT-Safe locale | AS-Safe | AC-Safe | *Note POSIX
  6233. Safety Concepts::.
  6234. The ‘strverscmp’ function compares the string S1 against S2,
  6235. considering them as holding indices/version numbers. The return
  6236. value follows the same conventions as found in the ‘strcmp’
  6237. function. In fact, if S1 and S2 contain no digits, ‘strverscmp’
  6238. behaves like ‘strcmp’ (in the sense that the sign of the result is
  6239. the same).
  6240. The comparison algorithm which the ‘strverscmp’ function implements
  6241. differs slightly from other version-comparison algorithms. The
  6242. implementation is based on a finite-state machine, whose behavior
  6243. is approximated below.
  6244. • The input strings are each split into sequences of non-digits
  6245. and digits. These sequences can be empty at the beginning and
  6246. end of the string. Digits are determined by the ‘isdigit’
  6247. function and are thus subject to the current locale.
  6248. • Comparison starts with a (possibly empty) non-digit sequence.
  6249. The first non-equal sequences of non-digits or digits
  6250. determines the outcome of the comparison.
  6251. • Corresponding non-digit sequences in both strings are compared
  6252. lexicographically if their lengths are equal. If the lengths
  6253. differ, the shorter non-digit sequence is extended with the
  6254. input string character immediately following it (which may be
  6255. the null terminator), the other sequence is truncated to be of
  6256. the same (extended) length, and these two sequences are
  6257. compared lexicographically. In the last case, the sequence
  6258. comparison determines the result of the function because the
  6259. extension character (or some character before it) is
  6260. necessarily different from the character at the same offset in
  6261. the other input string.
  6262. • For two sequences of digits, the number of leading zeros is
  6263. counted (which can be zero). If the count differs, the string
  6264. with more leading zeros in the digit sequence is considered
  6265. smaller than the other string.
  6266. • If the two sequences of digits have no leading zeros, they are
  6267. compared as integers, that is, the string with the longer
  6268. digit sequence is deemed larger, and if both sequences are of
  6269. equal length, they are compared lexicographically.
  6270. • If both digit sequences start with a zero and have an equal
  6271. number of leading zeros, they are compared lexicographically
  6272. if their lengths are the same. If the lengths differ, the
  6273. shorter sequence is extended with the following character in
  6274. its input string, and the other sequence is truncated to the
  6275. same length, and both sequences are compared lexicographically
  6276. (similar to the non-digit sequence case above).
  6277. The treatment of leading zeros and the tie-breaking extension
  6278. characters (which in effect propagate across non-digit/digit
  6279. sequence boundaries) differs from other version-comparison
  6280. algorithms.
  6281. strverscmp ("no digit", "no digit")
  6282. ⇒ 0 /* same behavior as strcmp. */
  6283. strverscmp ("item#99", "item#100")
  6284. ⇒ <0 /* same prefix, but 99 < 100. */
  6285. strverscmp ("alpha1", "alpha001")
  6286. ⇒ >0 /* different number of leading zeros (0 and 2). */
  6287. strverscmp ("part1_f012", "part1_f01")
  6288. ⇒ >0 /* lexicographical comparison with leading zeros. */
  6289. strverscmp ("foo.009", "foo.0")
  6290. ⇒ <0 /* different number of leading zeros (2 and 1). */
  6291. ‘strverscmp’ is a GNU extension.
  6292. -- Function: int bcmp (const void *A1, const void *A2, size_t SIZE)
  6293. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  6294. Concepts::.
  6295. This is an obsolete alias for ‘memcmp’, derived from BSD.