Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
51 user(s) are online (32 user(s) are browsing Forums)

Members: 0
Guests: 51

more...

Support us!

Headlines

 
  Register To Post  

clean way howto use clib4
Quite a regular
Quite a regular


See User information
Hi,
after ten years I reinstalled from scratch AmigaOS on X1000. Now I want to compile some code which using pthreads and ipc. Clib4 has it.

And I want to ask, what is easiest or most (system) friendly way to install latest clib4.

I found:
- SDK addon from walkero
- apt-os4 from afxgroup
- clib4 from walkero, afxgroup and elfpipe

Thank you all for your work! And please, can you advice me what package is most convenient to future upgrades ?

And, howto use clib4 correctly? With -mcrt=clib4? Is it enough, or something else should be done?

Many thanks!!


Edited by sailor on 2026/2/2 13:33:20
AmigaOS3: Amiga 1200
AmigaOS4: Micro A1-C, AmigaOne XE, Pegasos II, Sam440ep, Sam440ep-flex, AmigaOne X1000
MorphOS: Efika 5200b, Pegasos I, Pegasos II, Powerbook, Mac Mini, iMac, Powermac Quad
Go to top
Re: clean way howto use clib4
Amigans Defender
Amigans Defender


See User information
Once you download the SDK_addon you will have already gcc that is able to compile clib4 code.
And yes. just use -mcrt=clib4.
At moment however i suggest to clone and compile development branch on clib4 so you have all latest changes not yet released.
And of course you have to put clib4.library in LIBS:

i'm really tired...
Go to top
Re: clean way howto use clib4
Quite a regular
Quite a regular


See User information
@afxgroup
many thanks, just downladed.

AmigaOS3: Amiga 1200
AmigaOS4: Micro A1-C, AmigaOne XE, Pegasos II, Sam440ep, Sam440ep-flex, AmigaOne X1000
MorphOS: Efika 5200b, Pegasos I, Pegasos II, Powerbook, Mac Mini, iMac, Powermac Quad
Go to top
Re: clean way howto use clib4
Quite a regular
Quite a regular


See User information
I tried to compile the code:
for(cnt 0cnt fproccnt++) fork();

    
/* every process initialises itself and attaches the SHM segment to its
     * virtual memory space */
    
mypid getpid();
    
shmid shmget(shmkey, (sizeof(STL) << 11), 0666);
    
shm = (UTL *) shmat(shmid00);


I received warning during compilation with -mcpu=powerpc -mcrt=clib4 -O3:
warning: implicit declaration of function 'fork' [-Wimplicit-function-declaration]
and error during linking with -mcrt=clib4 -lpthread:
undefined reference to `fork'

I am not found fork() in unistd.h
Is this function implemented?
And if not, can I use pthread_create instead? What should be workarounder in such case?

AmigaOS3: Amiga 1200
AmigaOS4: Micro A1-C, AmigaOne XE, Pegasos II, Sam440ep, Sam440ep-flex, AmigaOne X1000
MorphOS: Efika 5200b, Pegasos I, Pegasos II, Powerbook, Mac Mini, iMac, Powermac Quad
Go to top
Re: clean way howto use clib4
Not too shy to talk
Not too shy to talk


See User information
no Amiga has ever supported fork()

Can you make it work with vfork() ?

Go to top
Re: clean way howto use clib4
Home away from home
Home away from home


See User information
@NinjaCyborg
Quote:
Can you make it work with vfork() ?
Probably wouldn't help much, or does clib4 support vfork()?

The AmigaOS 2.x/3.x m68k ixemul C library did support vfork(), with several limitations and additional work required (for example using ix_vfork[2](), ix_vfork_setup_child(), etc.), but IIRC my AmigaOS 4.x port of ixemul doesn't support it, or maybe only for emulated m68k software but not for PPC native software.

Using pthreads instead should work with any AmigaOS 4.x C library.

Go to top
Re: clean way howto use clib4
Quite a regular
Quite a regular


See User information
@NinjaCyborgQuote:
NinjaCyborg wrote:no Amiga has ever supported fork()
Can you make it work with vfork() ?


MorphOS supports it
And vfork() also not supported in our clib4.

But if I know that, it is not big problem.
I will try to modify code with pthread_create().
Or I will compile only single-thread code for AmigaOS and both single-thread and multi-thread for MorphOS.

Thank you and @joerg for explanation.

AmigaOS3: Amiga 1200
AmigaOS4: Micro A1-C, AmigaOne XE, Pegasos II, Sam440ep, Sam440ep-flex, AmigaOne X1000
MorphOS: Efika 5200b, Pegasos I, Pegasos II, Powerbook, Mac Mini, iMac, Powermac Quad
Go to top
Re: clean way howto use clib4
Amigans Defender
Amigans Defender


See User information
@sailor
Take a look at spawnpe function. Most of the time you can replace fork with that. On git source code there is run-command/run-command-amiga where you can see how it is used. Also on cmake source code is used to spawn processes and communicate thru pipes

Regard fork/vfork at moment they are not implemented. Maybe one day..

i'm really tired...
Go to top
Re: clean way howto use clib4
Quite a regular
Quite a regular


See User information
@afxgroupQuote:
afxgroup wrote:@sailor
Take a look at spawnpe function. Most of the time you can replace fork with that. On git source code there is run-command/run-command-amiga where you can see how it is used. Also on cmake source code is used to spawn processes and communicate thru pipes

Regard fork/vfork at moment they are not implemented. Maybe one day..


Thak you, I will look at spawn. And fork/vfork is really not priority.

AmigaOS3: Amiga 1200
AmigaOS4: Micro A1-C, AmigaOne XE, Pegasos II, Sam440ep, Sam440ep-flex, AmigaOne X1000
MorphOS: Efika 5200b, Pegasos I, Pegasos II, Powerbook, Mac Mini, iMac, Powermac Quad
Go to top
Re: clean way howto use clib4
Site Builder
Site Builder


See User information
Quote:
At moment however i suggest to clone and compile development branch on clib4 so you have all latest changes not yet released.


afxgroup mentioned the above, which is not needed any more because we provide nightly builds at https://github.com/AmigaLabs/clib4/releases/tag/nightly

Follow me on
Ko-fi, Twitter, YouTube, Twitch
Go to top
Re: clean way howto use clib4
Amigans Defender
Amigans Defender


See User information
😅 Sorry..

i'm really tired...
Go to top
Re: clean way howto use clib4
Quite a regular
Quite a regular


See User information
I read readme.md and found some interesting info:
Quote:
Optimized AMCC functions
Some functions like (memchr, memcmp, memcpy and some other) are optimized for SAM440 and SAM460. Feel free to add other CPU versions.

Altivec
libmotovec has been added to clib4 and enable some altivec functions. Altivec optimizations are not enabled at program start except if you recompile clib4 with ENABLE_ALTIVEC_AT_START.
However two new methods (enableAltivec and disableAltivec) are present and you can use them to enable or disable optimizations at runtime.
Keep in mind that clib4 is not compiled with altivec optimizations for all files.

SPE
libcfsl_e500 (thanks to wayback machine..) has been added to clib4 providing some optimized functions. To compile e500 functions pass SPE=true at makefile.
However to compile these functions you need a compiler that supports SPE ABI. The latest gcc version that supports SPE is gcc8.


Please, what does it mean exactly? How I activate this optimizations when I use clib4? Or is this text valid only to clib4 devolopers ?
I normally only set -mcpu, -mspe or -maltivec... gcc parameters.

AmigaOS3: Amiga 1200
AmigaOS4: Micro A1-C, AmigaOne XE, Pegasos II, Sam440ep, Sam440ep-flex, AmigaOne X1000
MorphOS: Efika 5200b, Pegasos I, Pegasos II, Powerbook, Mac Mini, iMac, Powermac Quad
Go to top
Re: clean way howto use clib4
Home away from home
Home away from home


See User information
@sailor
Quote:
MorphOS supports it
A fork() implementation is impossible on any AmigaOS like OS, incl. AROS and MorphOS.
Maybe the MorphOS version of ixemul redirects fork() calls to vfork(), which does work, with several limitations, in the AmigaOS 2.x/3.x m68k and MorphOS PPC versions of ixemul.library.

Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )



Polls
Running AmigaOS 4 on?
AmigaOne SE/XE or microA1 12% (26)
Pegasos2 3% (8)
X5000 22% (48)
X1000 14% (30)
A1222 8% (19)
Sam 440/460 18% (40)
Classic PowerPC Amiga 2% (6)
WinUAE emulation 7% (16)
Qemu emulation 9% (21)
Total Votes: 214
The poll closed at 2025/12/1 12:00
6 Comments


Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project