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:
/* 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(shmid, 0, 0);
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
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.
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
@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..
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
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
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.
Here's a detailed answer about ixemul.library and its capabilities regarding vfork() and fork():
On AmigaOS 4.x something similar to the MorphOS -mresident32 is -fbaserel (32 bit, R2 based, replacement of the 16 bit R13 based -msdata). As Piro wrote "Replacing fork() is doable", but requires individual solutions with additional work for each program, unless is's a simple fork() + exec*() which can be replaced by vfork() + exec*(). But implementing fork() in a C library for any AmigaOS-like OS which does everything automatically isn't possible, especially the "Any malloc() memory and local variables and structures that are used by the child must be cloned" part isn't: local and static variables are no problem (check the elf.library/CopyDataSegment() autodoc), but malloc()ed memory is and an automatic fork() implementation, which works the same way as on BSD and SysV Unix systems, would have to duplicate it, with the same virtual addresses but different physical addresses and content in parent and child and switching MMU tables on each task switch between parent and child.
clib4 is generic for all machines. There are no specific machines so if you want for example an optimized version compiled with -maltivec you need to compile it yourself using that switch. But since we are creating libraries automatically also for SPE maybe we can also create the altivec version