libc.info-2 290 KB

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