From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from sonic313-21.consmr.mail.ir2.yahoo.com (sonic313-21.consmr.mail.ir2.yahoo.com [77.238.179.188]) by sourceware.org (Postfix) with ESMTPS id E75603851C00 for ; Tue, 28 Apr 2020 19:57:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E75603851C00 X-YMail-OSG: EMwy_hUVM1nIcGa7yPclIE.nyfP.FMIQou7fFpLobx.gOlfn4xiACRi5JaXwiJR hjiAQTyMsPaw6BWTMgSqisOxILOIebgHyJTyH1.6SZDV6ahKa9HGkCONng9K2rHlQc38M._G_q8f yl_R6JgSnFfqLWVa7QrmKx.6L6n9WDX5Xlk2vxJN_qCBJTk1bFJb7.HswI30w6ExeyRba4A9MBl2 te3ksqDZ0bxmr9_5j8OOhEAAC3opiGGy_LZJSfi2Aw30i_r8KB8CcqC2UFuuQX.vtSmxzQKYHNaT JrHoKpbwocFS.oSo4kcA.XW36WDASnNt9taav7JVIvaTu9yVqT5E0uhfabqYfBodL5ogzcwohKs2 VNwUP.jRIpEAXu72qrp0xSv4Fr_NIuitMtcI3FnmHISRLs3EdH5xJSa2wvxe9w.0qEs3HYy86vIz .BkOzAh1JkNBqSTdlJWGR.RgTjIlUQKN6JDBNSVWTIB3U.qoIzmmbapimQ0jvIJjemySdnPnNGpw LTKK.uTcevPUXLPOgGqi3A7uzanK29TIeDLgJC0JNpUDv_C403FMC37pNoEFxkNx75_C.4OeVPmB CMhRrA6XYmJGhLaBifDmtO8IBnjmk6_ESxhelEndORmFvYDrdFQJ4Ffrirp.DGMqx.a_9G3.M5iW NtVztLEnaHpzjmg0hZqULp.IQRRyFvGvf6xzFli_V1Xt4FlGnAj3JR8xKaj085LmHgN8s2rNm1si lb7B_WRd6edJ6y6k5y8A8oMP3_aCROtVADmG7h0vIpFGNFVlhA0V427lv.IfOlEiM9rnkrlLGB0O KkrkYrfYk_WSHrOgzsO5Hs_YyYNPzua_FwUgE.8LvAr2PsFrN0O8qBCOh0eyxRChhjMzD4KV0x14 Wy7vIIX1Qc5Y.ULDMDDVzrSlfT7LID2ifAQdmn6Mc_cxd1t_Z08On6rVr5Z8UQIDQd9rtU0ug7ut RRHJMlIJykGoYCDHrf.FkXRxjaT8IYxHsTFqN4VicVgI9gAYMhhwSU6hdGDoKjQylEtjFh5RGIyH Bv2nmie6D5PNx1J4c9vsk7vaoTZJ_DMsxKeICVqgTpiuACy7PSm_9wjHfKGFF2b3YEI6.vRogla0 n9Ys0C4NeNVWO620FrNTM9hHC2mc0tCcFKKXAX2RhN8IxHIsDE9.EmR2hjHq8MupcWbueG_NcRzQ ZiwmCb_7rb3xKcHnCOTJzX9QpK1LAxwGVOogw3DmYaVJDBXCOWXWyHpLH0zcgL8.qcwT0B1HD84T Lepdb8RbM3ijIshHMGhRDQJYaji8DFSXkOLGkg8K93SMG.JdOKsgWYd9IAv9SDGGKkF1nufbOdGb .MTDcIZn0wFgcKU27fb3xIi1HYqVpcAlDWEbTSg-- Received: from sonic.gate.mail.ne1.yahoo.com by sonic313.consmr.mail.ir2.yahoo.com with HTTP; Tue, 28 Apr 2020 19:57:55 +0000 Date: Tue, 28 Apr 2020 19:57:55 +0000 (UTC) From: "R. Diez" To: Jeff Johnston Cc: "newlib@sourceware.org" Message-ID: <1088500099.3472913.1588103875027@mail.yahoo.com> In-Reply-To: References: <989180140.2023825.1588003097077.ref@mail.yahoo.com> <989180140.2023825.1588003097077@mail.yahoo.com> <1918742529.2295153.1588019348307@mail.yahoo.com> Subject: Re: _REENT_CHECK_VERIFY calls __assert_func even if NDEBUG is defined MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Mailer: WebService/1.1.15756 YMailNorrin Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:75.0) Gecko/20100101 Firefox/75.0 X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_2, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Apr 2020 19:58:01 -0000 Hallo again: After some further research and testing, I wanted to share a couple of hint= s that may help other people too: Point 1) Configuring with --disable-newlib-reent-small (which is actually t= he default) gets rid of the surprising malloc() on first touch from rand(),= and probably many other places. Note that sizeof( struct _reent=C2=A0 ) increases from 240 bytes to=C2=A010= 64 bytes (tested with Newlib version 3.3.0). I think Newlib should document that option --enable-newlib-reent-small is r= isky. Unless you are really tight on RAM, I strongly advise against this un= safe optimisation. Point 2) The documentation on this section is misleading: =C2=A0 https://sourceware.org/newlib/libc.html#Reentrancy That section states: -----------8<-----------8<-----------8<-----------8<----------- This means that you have two ways to achieve reentrancy. Both require that = each thread of execution control initialize a unique global variable of typ= e =E2=80=98struct _reent=E2=80=99: Use the reentrant versions of the library functions, after initializing a g= lobal reentrancy structure for 1.=C2=A0 each process. Use the pointer to th= is structure as the extra argument for all library functions. -----------8<-----------8<-----------8<-----------8<----------- This section gives you the impression that you are free to choose. But if y= ou have multithreading, you really need to implement _impure_ptr, mention i= n option (2). For example, the rand() function needs such a global state (t= hat was my impression by looking at the convoluted macros). Newlib does have a rand_r() counterpart, but it is not really equivalent (i= t is a much weaker pseudo-random generator), and Posix has declared it obso= lete. So there is no real xxx_r() equivalent for rand() in Newlib (that I c= ould see). All the best, =C2=A0 rdiez