Re: [Pharo-users] Bit Manipulation Challenge

2020-07-20 Thread David T. Lewis
On Tue, Jul 21, 2020 at 02:17:59AM +0800, Ben Coman wrote:
> On Mon, 20 Jul 2020 at 23:19, Sean P. DeNigris  wrote:
> >
> > I want to take an IP address routing prefix in CIDR [1] notation (i.e. the 
> > 24
> > in "192.168.100.14/24") and convert it into subnet form (i.e.
> > 255.255.255.0). I came up with 4 ways to do that (see below), but none stand
> > out as best (although #3 and #4 seem a bit more straightforward as they
> > avoid the `max` temp).
> >
> > How would you go about it?
> >
> > Here are the ways I came up with:
> > cidr := 24.
> > shift := 32 - cidr.
> > max := #[ 255 255 255 255 ] asInteger.
> > "1." ((max bitShift: shift negated) bitShift: shift) asByteArray.
> > "2." (max bitClear: (2 raisedTo: shift) - 1) asByteArray.
> > "3." ((2 raisedTo: shift) - 1) bitInvert32 asByteArray.
> > "4." (((2 raisedTo: cidr) - 1) bitShift: shift) asByteArray
> 
> To me the most complicated ones have the "subtract 1" - it makes it
> harder to reason about.  I'd also guess "3" and "4" are slowest.
> 
> "1." can be simplified by hardcoding max
> 5. (4294967295 bitShift: shift negated) bitShift: shift) asByteArray
> 
> Additional alternative...
> 6. ((4294967295 bitShift: shift) rem: 4294967296) asByteArray
> 
> And why not low-brow...
> 7. CIDRLookup at: cidr.
> 
> cheers -ben

This also seems to work for IPV4:

  (max << shift) asByteArray last: 4

Dave



[Pharo-users] [ANN] Willow-Bootstrap v12.1.1 [v12.1.1] released!

2020-07-20 Thread Buenos Aires Smalltalk
Willow-Bootstrap, integration between Willow & Bootstrap 3/4 reached it's v12.1.1 version.
Changelog

Pharo 9 compatibility
Minor improvements

Regards,
The Buenos Aires Smalltalk team



[Pharo-users] [ANN] RenoirSt v7.0.2 [v7.0.2] released!

2020-07-20 Thread Buenos Aires Smalltalk
RenoirSt, a DSL enabling programmatic cascading style sheet generation for Pharo Smalltalk reached it's v7.0.2 version.
Changelog

Updated dependencies
Removed unnecesary method
Update notification action

Regards,
The Buenos Aires Smalltalk team



Re: [Pharo-users] Bit Manipulation Challenge

2020-07-20 Thread Ben Coman
On Mon, 20 Jul 2020 at 23:19, Sean P. DeNigris  wrote:
>
> I want to take an IP address routing prefix in CIDR [1] notation (i.e. the 24
> in "192.168.100.14/24") and convert it into subnet form (i.e.
> 255.255.255.0). I came up with 4 ways to do that (see below), but none stand
> out as best (although #3 and #4 seem a bit more straightforward as they
> avoid the `max` temp).
>
> How would you go about it?
>
> Here are the ways I came up with:
> cidr := 24.
> shift := 32 - cidr.
> max := #[ 255 255 255 255 ] asInteger.
> "1." ((max bitShift: shift negated) bitShift: shift) asByteArray.
> "2." (max bitClear: (2 raisedTo: shift) - 1) asByteArray.
> "3." ((2 raisedTo: shift) - 1) bitInvert32 asByteArray.
> "4." (((2 raisedTo: cidr) - 1) bitShift: shift) asByteArray

To me the most complicated ones have the "subtract 1" - it makes it
harder to reason about.  I'd also guess "3" and "4" are slowest.

"1." can be simplified by hardcoding max
5. (4294967295 bitShift: shift negated) bitShift: shift) asByteArray

Additional alternative...
6. ((4294967295 bitShift: shift) rem: 4294967296) asByteArray

And why not low-brow...
7. CIDRLookup at: cidr.

cheers -ben



[Pharo-users] Bit Manipulation Challenge

2020-07-20 Thread Sean P. DeNigris
I want to take an IP address routing prefix in CIDR [1] notation (i.e. the 24
in "192.168.100.14/24") and convert it into subnet form (i.e.
255.255.255.0). I came up with 4 ways to do that (see below), but none stand
out as best (although #3 and #4 seem a bit more straightforward as they
avoid the `max` temp). 

How would you go about it?

Here are the ways I came up with:
cidr := 24.
shift := 32 - cidr.
max := #[ 255 255 255 255 ] asInteger.
"1." ((max bitShift: shift negated) bitShift: shift) asByteArray.
"2." (max bitClear: (2 raisedTo: shift) - 1) asByteArray.
"3." ((2 raisedTo: shift) - 1) bitInvert32 asByteArray.
"4." (((2 raisedTo: cidr) - 1) bitShift: shift) asByteArray

1. https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing



-
Cheers,
Sean
--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html



[Pharo-users] [ANN] Pharo Launcher 2.2 released!

2020-07-20 Thread Christophe Demarey
Hi all,

Pharo Launcher 2.2 has just been released! It is available from 
http://pharo.org/download.
It is mostly a bug fix release but it comes with some enhancements. Full log is 
available at 
https://github.com/pharo-project/pharo-launcher/releases/tag/2.2 and 
https://github.com/pharo-project/pharo-launcher/releases/tag/2.1 (not 
announced, was buggy).

Regards

> Le 17 avr. 2020 à 18:08, Christophe Demarey  a 
> écrit :
> 
> Hi all,
> 
> Pharo Launcher 2.0 has just been released! It is available from 
> http://pharo.org/download .
> 
> This new version introduces major changes:
> The UI has been fully rewritten using the new Spec2 framework 
>  and the Commander2 library 
> . UI has been revamped to increase 
> usability, especially for newcomers. The main window is now composed of a 
> toolbar and the list of images. The template list is now available when 
> clicking on the new image button.
> Documentation web site : All Pharo Launcher features are now explained in the 
> new documentation available at https://pharo-project.github.io/pharo-launcher 
> . You can contribute easily 
> by clicking the *edit on GitHub* button.
> You can now have many launch configurations for an image (VM to use, vm and 
> image arguments). It means you can use headless Pharo VM from Pharo Launcher.
> When creating a new image, you can specify an initialisation script that will 
> be run once at the first image launch. It is useful to load your project code 
> in a stock Pharo image for example. See 
> https://pharo-project.github.io/pharo-launcher/create-images/#image-initialization-script
>  
> 
> You can now define your own template sources in addition to official sources 
> (see 
> https://pharo-project.github.io/pharo-launcher/templates/#create-your-own-list-of-template-categories
>  
> ),
>  including authenticated sources.
> Improved image metadata. Pharo Launcher now manages all image metadata in a 
> single STON file (including description, Pharo version).
> 
> Big thanks to all contributors, including issue reports. It is also the 
> opportunity to thanks Damien Cassou, the original author of Pharo Launcher.
> 
> Here is the changelog:
> Pharo Launcher v2.0 
> 
> 
> The list of closed issue is too long (68) to be listed but you can browse it 
> here: 
> https://github.com/pharo-project/pharo-launcher/issues?q=is%3Aissue+is%3Aclosed+closed%3A2019-07-09..2020-04-17
>  
> 
> Here are some highlights:
> New features:
> 
> Documentation web site
> Image initialisation script
> Launch configurations, headless VM support
> User template file in addition to the official template file
> Jenkins server template now support pipeline projects
> Support of private Jenkins server
> Support of authenticated HTTP server
> Improvements:
> 
> Monitoring of image launch failures to give back the error message (if any)
> Newly created image is automatically selected in the image list
> Allow to set image description at creation time
> Better error management (you will have the choice to ignore them or debug 
> them)
> Add a poor version column in image list
> Speedup (especially when image repository has a lot of images)
> 
> Bug fixes:
> 
> Fix use of system unzip on Windows
> 
> Regards,
> The Pharo team.



Re: [Pharo-users] UFFI asynchronous callbacks

2020-07-20 Thread teso...@gmail.com
Hi, as Ben correctly pointed out there is the alternative of using a
Queue based approach for FFI.
It is available as a plugin for the headless VM and it can be used with Pharo 8.
It is here: https://github.com/pharo-project/threadedFFI-Plugin
The plugin is already compiled and shipped with the VM.
It is only required to load the Smalltalk side code with:

Metacello new
baseline: 'ThreadedFFI';
repository: 'github://pharo-project/threadedFFI-Plugin';
onConflictUseLoaded;
load.

This is fully integrated as a backend of UFFI, so all the code you
already have it will be working fine.
You need to give more information to select the callout strategy to
use (https://github.com/pharo-project/threadedFFI-Plugin/wiki/Using-with-UFFI)

 Using TFFI it is possible to receive callbacks from other threads and
process them in the VM thread.

If you need any help, please feel free to ask in the list, so it can
be useful for everybody.
Cheers,

Pablo

On Sun, Jul 19, 2020 at 6:32 PM Ben Coman  wrote:
>
> Hi Asam,
>
> On Sun, 19 Jul 2020 at 21:38, ASAM  wrote:
> >
> > Hello Ben,
> >
> > I quickly made a dummy DLL to limit the problem to the essentials.
>
> Great idea.  A more generic example is attractive for people to
> examine and help out.
> I browsed the code but I'm sorry it needs a deeper expertise than I have.
> Hopefully someone working on the threaded FFI will tune in.
>
> In the meantime, it won't solve your query but you may find this
> interesting to watch...
> Strategies for Non-Blocking FFI
> https://www.youtube.com/watch?v=L_QFwsNOMAc
>
> cheers -ben
>
> >
> > I think my problem comes more from how I use the semaphore.
> >
> > I wanted to do that:
> >
> > only "semaphore signal",
> > But that somehow doesn't work.
> > Now i'm doing that "[ Processor yield. semaphore signal ] fork" (it work's)
> > but i don't know if that's a good idea.
> >
> >
> > ffiCallback
> > ^ FFICallback signature: #( void #( uint32 foo ) ) block: [ :foo |
> >   Transcript
> >   show: 'API Funktion value: ' , foo asString, ' 
> > activePriority:',
> >   Processor activePriority asString; cr.
> >
> > "that's working"
> >   [ Processor yield. semaphore signal ] fork.
> >
> >   "that usually works 80%."
> >   "[ semaphore signal ] fork"
> >
> >   "that crashes pharo almost always."
> >   "semaphore signal"
> > ]
> >
> > I also have a little problem, too. Why can I use my own C-Type UNUM32 at
> > ...self ffiCall: #( T_ERROR StartMyThreadFunction(UNUM32 millisecondsToFire)
> > ).
> > But with FFICallback signature: # (void # (uint32 foo)) I get an error
> > "Unable to resolve external type: UNUM32. Why is that?
> >
> > Thanks for your help.
> >
> > testDllForAsyncCallback.dll
> > 
> > testDllForAsyncCallback.cpp
> > 
> > testDllForAsyncCallback.h
> > 
> > testDllForAsyncCallback.h
> > 
> > UFFICallback.st 
> > CTypes.st 
> > 
> >
> >
> >
> >
> > --
> > Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
> >
>


-- 
Pablo Tesone.
teso...@gmail.com