From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id 57F4523C2A for ; Tue, 18 Jun 2024 02:17:05 +0200 (CEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1718669825; b=EgCxHH7n/xPeacdfOSF6EwR83L3ODdvYP7hofq9rVnEcH0aLB4xNpgeEKVtlmYg0zCkoWiCmjS wBJSk22SDiGpRX8GVYoVdi8Th6uclcD0OeO5S7eZZ7OZcggnS53OlBFkxdBaE1vmft/FaFJvET KiK2tnaJdbxzOuC/ynYX8hbZejhjnAVEmlNL0DwqG/3/M+zHACOgDL/EpfaVk/OddhNVN+yfZJ 2v0jvLrsl5PXnFd7h2c0v0LnmW9usOj0QiaMVL09LMZ7Id6tCvNKl5Rv53a7TOTYqX/HcQUQXS 74JhfL6plL+3Xz1igZcB0BleP5UCSLpxwB5Z9TYatHZfog==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (iris.zentaur.org) smtp.remote-ip=198.58.127.206; dkim=pass header.d=zentaur.org header.s=dkim20200120 header.a=rsa-sha256; dmarc=pass header.from=zentaur.org; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1718669825; bh=yhg9Y78DO+/utpSNKMRYIkkxCQ9P0xsYDmFdbXpqL6w=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:To:Subject:MIME-Version:Date:Message-ID:DKIM-Signature: DKIM-Signature; b=TowuyDJ2Dti8si/2iXS5SIaXIALBkWagHuOFXP5QfcS0lmK/HIksdRxi6M7JfodI4F6WAG52/D Ty02liqnpFpsAdQNzN1qdXhtqicp729NIp1KofE9HkPS6WGb3WJCtPxqwx7ikHHyed7cUZKBTn Ke7Os/fuWMvVP8QW+VM2wSuIcg+kswDp+mwtA7F3FeiN1+yIXpDd6N0Vqna2UvXXgCOhXFTXal 3UqKqwwIYxel1bCEDO5YFRKxQTxBWOffa+gp0Z7fx2nG+llYj9NbaoA8N6Qe4vbzMnoEHwo7Q8 X9h/I4MmSQg7Bi6y9D8TcXtqDwLGk98WEpV+WuZQW6Iq8Q==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=yhg9Y78DO+/utpSNKMRYIkkxCQ9P0xsYDmFdbXpqL6w=; b=F5yBtdk5PAuT8uCIZCpUAZE4qq yODB9hZMhKLFNS6Ok+TEwRRkwgVJiEZ5CWQE40dX2RgzFC3B55k3zts1lXVfo3BYBdVhjqa79ietx n0stGjI0CUyvO7gBP+SlOe2c5ah8ZCigc7nHyvRuz7h+2WaOG8X0dg3nM45vStBRDSs+WDRc0awWG xbrq64EAzXCNX3laTA0MHYmzeYperkddmAco9qowuu4fSGAYZfBUNY1lN/o88p4Yjt6nbWWRYK3Ir NIqqqz69eZOoTKxDYXTnh3oUc0jlt2jjyehyX+CNEL1iKSjPrLA3CwZsSH3gsWRLmiu6Mf7tWkt+C k4nN1eTw==; Received: by zero.zsh.org with local id 1sJMX3-000KUt-R0; Tue, 18 Jun 2024 00:17:05 +0000 Authentication-Results: zsh.org; iprev=pass (iris.zentaur.org) smtp.remote-ip=198.58.127.206; dkim=pass header.d=zentaur.org header.s=dkim20200120 header.a=rsa-sha256; dmarc=pass header.from=zentaur.org; arc=none Received: from iris.zentaur.org ([198.58.127.206]:38144) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1sJMWj-000KAt-Sa; Tue, 18 Jun 2024 00:16:47 +0000 Received: from iris.zentaur.org (localhost [127.0.0.1]) by iris.zentaur.org (Postfix) with ESMTP id 4W36kN65vrz3wZv for ; Tue, 18 Jun 2024 00:16:44 +0000 (UTC) Authentication-Results: iris.zentaur.org (amavis); dkim=pass (2048-bit key) reason="pass (just generated, assumed good)" header.d=zentaur.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=zentaur.org; h= content-transfer-encoding:content-type:in-reply-to:from :content-language:references:to:subject:user-agent:mime-version :date:message-id; s=dkim20200120; t=1718669804; x=1718673405; bh=yhg9Y78DO+/utpSNKMRYIkkxCQ9P0xsYDmFdbXpqL6w=; b=NxJxPCbmcoYu yZ2qGbvhmdFFew6IEOyPSP6enEF5j49rsT/xg8oR19IKnFAnrKPYaq4i/jxnk4Et Xzito4huMdDkPs7TRTveZFb4yJ1iyqp0hJ0nMZ2jU/euWDvjBkKU2Wm6bY6WUIHd J2YZPWSbnnrHiFRTK8wu3UCMOBXznh1vGQUphjwD28ZHWCkitV4PPAdpGJ7dvlvD O6ljxncnN8a+Oa7yPdiaTpa2YlV8GwdgO+aGC6D8n1lg0V2AR8gepNySE+Xdorvm UDYswNJy/hMfFwcD8R8a/N75n8QnDcMFmTZqL//r8Gyb1EJmiEqy7txrq+57QDr4 8+yEJPIT8g== X-Virus-Scanned: amavis at iris.zentaur.org Received: from iris.zentaur.org ([127.0.0.1]) by iris.zentaur.org (iris.zentaur.org [127.0.0.1]) (amavis, port 10026) with ESMTP id gHiGhIqPp8tE for ; Tue, 18 Jun 2024 00:16:44 +0000 (UTC) Received: from [IPV6:2605:a601:a57c:ee00::4000] (unknown [IPv6:2605:a601:a57c:ee00::4000]) by iris.zentaur.org (Postfix) with ESMTPSA id 4W36kN11Dhz3wZt for ; Tue, 18 Jun 2024 00:16:44 +0000 (UTC) Message-ID: <66b4e820-e741-4476-a7cc-5860d9929b7f@zentaur.org> Date: Mon, 17 Jun 2024 19:16:43 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/1] zsh/random To: zsh-workers@zsh.org References: <5be719d0-15b7-44ed-ac3c-61cb06357d51@zentaur.org> <8d1c4112-a099-4a3c-9d34-c16dc761ac82@zentaur.org> Content-Language: en-US From: Clinton Bunch In-Reply-To: <8d1c4112-a099-4a3c-9d34-c16dc761ac82@zentaur.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Seq: 52961 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: Also is anyone able to test on AIX or HP-UX?=C2=A0 Since neither have=20 getrandom or arc4random and would fall back to /dev/urandom, I'd like to=20 make sure they work.=C2=A0 I'm hoping someone else can test so I don't ha= ve=20 to spend money to rent an AIX or HPE VM. On 6/17/2024 18:52, Clinton Bunch wrote: > On 6/17/2024 09:43, Jun. T wrote: >> # Please do not separate a patch into [0/1] and [1/1]. >> # Some people reply to [0/1], others to [1/1]. >> >> What is the current status of this patch? > It's been waiting on feedback >> >> Here are my comments: >> >> >>> 2024/04/28 4:31, Clinton Bunch wrote: >>> Doc/Zsh/mod_random.yo >>> +item(tt(SRANDOM)) ( >>> +A random positive 32-bit integer between 0 and 4,294,967,295. >> 'between 0 and 4,294,967,295' >> I think $SRAND can be 0; can it be 4,294,967,295, or only to >> 4,294,967,295-1? > 4,294,967,295 is 2**32-1 (odd number) >> >>> +item(tt(zrand_float+LPAR()RPAR())) ( >>> +Returns a random floating point number between 0 and 1. >> 'between 0 and 1' Is this inclusive? >> Can zrand_float() return 1? > Yes. it can return both 0 and 1.=C2=A0 I've specified inclusive in the=20 > documentation. >>> +item(tt(zrand_int)+LPAR()tt(upper), tt(lower), tt(inclusive)RPAR()) = ( >>> +Returns a random integer between tt(lower) and tt(upper). All=20 >>> parameters are >>> +optional.=C2=A0 If none are specified it is equivalent to >>> +tt(SRANDOM). >>> +tt(inclusive) is a flag that controls whether the result is ever=20 >>> equal to >>> +tt(upper).=C2=A0 By default it is not. >> If 'inclusive' is 0 (off) by default, then >> 0 <=3D zrand_int() < 4,294,967,295 by default. >> Is this equivalent to $SRANDOM? > In the code it calls the same function as SRANDOM when no arguments=20 > are given. >> >>> Src/Modules/random.c >>> +#include >>> +#include >> I guess stdbool.h is not used? > Apparently I removed all places where I used a bool type >> >> I think including stdint.h (new in C99 but may exist in earlier >> compilers) without #ifdef HAVE_STDINT_H is OK now, since we >> are now using C99 as the C language standard, right? >> >>> +/* buffer to pre-load integers for SRANDOM to lessen the context=20 >>> switches */ >>> +uint32_t rand_buff[8]; >> static uint32_t rand_buff[8]; >> >>> +int >>> +boot_(Module m) >> UNUSED(m) >> >> >>> Src/Modules/random.mdd >>> +load=3Dyes >> Does this module really need be autoloadable? I don't know what are >> the criteria that a module should be autoloadable. > I would think we'd want at least the SRANDOM parameter autoloaded >> >> >>> Test/V15random.ztst >> I don't know whether zsh need to check the "quality" of the random >> number. I guess the simple $RANDOM would also pass these tests. > RANDOM would not pass these tests.=C2=A0 They test the difference betwe= en=20 > the distribution of the generated values against the ideal equal=20 > distribution. >> >> Maybe better to check that $SRANDOM is 'non-repeatable'? > Since SRANDOM can't be set how would you prove non-repeatable? >> >> If we will do the quality check, then: >> >>> +=C2=A0 print -ru $ZTST_fd 'This test may take two seconds...' >> Why two seconds? A few seconds, or something like that? > I believe that was the result of timings during testing.=C2=A0 As I rec= all=20 > the other tests were more specific than a few. >> >>> +=C2=A0 function calc_chi2() { >>> +# Calculate Chi Squared >> (snip) >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 #echo >>> +=C2=A0 } >> Please remove several '#echo' (for debugging?). > Yes, they were for debugging. >> >> You can convert the functions calc_chi2(), ligf() etc. into >> math-functions by using 'functions -M'. Then you can call them as, >> for example (( p =3D 1 - ligf(s, z)/gamma(s) )) >> >>> +0q:random integer $samples samples between 1-$n >> The flag 'q' works only for the lines starting with < > or ?. >> $samples and $n are not expanded. > Okay explicit values used in messages. >> >> --=20 >> Jun > > >