Skip to content

Commit

Permalink
Merge pull request #147 from afxgroup/clib4
Browse files Browse the repository at this point in the history
Renamed clib2 to clib4
  • Loading branch information
afxgroup authored Sep 28, 2023
2 parents 3250444 + d136175 commit 1a05ce7
Show file tree
Hide file tree
Showing 1,463 changed files with 4,820 additions and 4,841 deletions.
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
*.lha
*.bak
/library/compiler.log
clib2.info
clib4.info
compiler.log
*.map
.vscode
build/
clib2.lha
clib4.lha
.idea/
clib2_1.0_amd64
clib4_1.0_amd64
*.deb
clib2/
clib4/
70 changes: 35 additions & 35 deletions GNUmakefile.os4
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# $Id: Makefile,v 2.1 2021-03-26 11:28:07 clib2devs Exp $
# $Id: Makefile,v 2.1 2021-03-26 11:28:07 clib4devs Exp $
#
# :ts=8
#
Expand All @@ -23,7 +23,7 @@
# called "netinclude".
UNAME := $(shell uname)

INSTALL_PREFIX ?= /usr/ppc-amigaos/SDK/clib2
INSTALL_PREFIX ?= /usr/ppc-amigaos/SDK/clib4
SDK_INCLUDE ?= /usr/ppc-amigaos/SDK/include

CC := ppc-amigaos-gcc
Expand Down Expand Up @@ -54,7 +54,7 @@ LIB_ROOT ?= $(shell pwd)
LIB_DIR = $(LIB_ROOT)/library
BUILD_DIR = $(LIB_ROOT)/build
OUTPUT_LIB = $(BUILD_DIR)/lib
DPKG_LIB = clib2_1.0_amd64
DPKG_LIB = clib4_1.0_amd64

##############################################################################

Expand Down Expand Up @@ -102,7 +102,7 @@ STATIC := $(if $(STATIC),$(STATIC),yes)

LARGEDATA :=
OPTIONS += $(LARGEDATA) -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D__CLIB2__ -Wa,-mregnames -fno-builtin -nostdlib -D_GNU_SOURCE -D_XOPEN_SOURCE -D_USE_GNU -pipe
OPTIMIZE := -O3 -mregnames -mmultiple -mupdate -mstrict-align
OPTIMIZE := -O3 -mregnames -mmultiple -mupdate -ffp-contract=fast -mstrict-align

STABS :=
DLIBS :=
Expand Down Expand Up @@ -133,7 +133,7 @@ VERBOSE ?= @

# This is the first target: it depends on all the targets

all: prepare all-targets all-libs clib2.library.debug clib2.library
all: prepare all-targets all-libs clib4.library.debug clib4.library

##############################################################################

Expand Down Expand Up @@ -166,7 +166,7 @@ ALL_TARGETS = \
$(OUTPUT_LIB)/crtend.o \
$(OUTPUT_LIB)/shcrtbegin.o \
$(OUTPUT_LIB)/shcrtend.o \
$(OUT_SHARED_LIB)/shared_library/clib2.o \
$(OUT_SHARED_LIB)/shared_library/clib4.o \
$(OUT_SHARED_LIB)/shared_library/math.o \
$(MAIN_LIB)

Expand All @@ -188,9 +188,9 @@ clean:
-$(DELETE) $(BUILD_DIR)/PatchForSPE
-$(DELETE) $(OUTPUT_LIB)
-$(DELETE) $(BUILD_DIR)/compiler.log
-$(DELETE) $(BUILD_DIR)/clib2.library*
-$(DELETE) clib2.lha
-$(DELETE) clib2.bak
-$(DELETE) $(BUILD_DIR)/clib4.library*
-$(DELETE) clib4.lha
-$(DELETE) clib4.bak
-$(DELETE) $(DPKG_LIB)
-$(DELETE) $(DPKG_LIB).deb
-cd test_programs; make clean
Expand All @@ -211,12 +211,12 @@ version:
bumprev crypt.lib
bumprev pthread.lib

# Shared clib2.library rules
# Shared clib4.library rules

clib2.library.debug: $(OBJ_C_LIB)
$(VERBOSE)$(CC) -o $(BUILD_DIR)/$@ $(CFLAGS) $(BUILD_DIR)/shared/shared_library/clib2.o $(BUILD_DIR)/shared/shared_library/math.o $(OBJ_C_LIB) $(DLIBS) -Wl,--cref,-M,-Map=$(BUILD_DIR)/[email protected] -nostartfiles -nostdlib
clib4.library.debug: $(OBJ_C_LIB)
$(VERBOSE)$(CC) -o $(BUILD_DIR)/$@ $(CFLAGS) $(BUILD_DIR)/shared/shared_library/clib4.o $(BUILD_DIR)/shared/shared_library/math.o $(OBJ_C_LIB) $(DLIBS) -Wl,--cref,-M,-Map=$(BUILD_DIR)/[email protected] -nostartfiles -nostdlib

clib2.library: clib2.library.debug
clib4.library: clib4.library.debug
cp $(BUILD_DIR)/$< $(BUILD_DIR)/$@
$(STRIP) -R.comment -R.sdata2 --strip-unneeded-rel-relocs $(BUILD_DIR)/$@

Expand All @@ -236,12 +236,12 @@ $(OUTPUT_LIB)/crt0.o : $(LIB_DIR)/crt0.S
$(VERBOSE)$(ASSEMBLE)
-$(COPY) $(OUTPUT_LIB)/crt0.o $(INSTALL_PREFIX)/lib/

$(OUTPUT_LIB)/crtbegin.o : CFLAGS = -mcrt=clib2 $(STABS) $(OPTIONS) $(INCLUDES) -O0 -fno-aggressive-loop-optimizations
$(OUTPUT_LIB)/crtbegin.o : CFLAGS = -mcrt=clib4 $(STABS) $(OPTIONS) $(INCLUDES) -O0 -fno-aggressive-loop-optimizations
$(OUTPUT_LIB)/crtbegin.o : $(LIB_DIR)/crtbegin.c
$(VERBOSE)$(COMPILE)
-$(COPY) $(OUTPUT_LIB)/crtbegin.o $(INSTALL_PREFIX)/lib/

$(OUTPUT_LIB)/crtend.o : CFLAGS = -mcrt=clib2 -O0 $(OPTIONS) $(INCLUDES) -fno-aggressive-loop-optimizations
$(OUTPUT_LIB)/crtend.o : CFLAGS = -mcrt=clib4 -O0 $(OPTIONS) $(INCLUDES) -fno-aggressive-loop-optimizations
$(OUTPUT_LIB)/crtend.o : $(LIB_DIR)/crtend.c
$(VERBOSE)$(COMPILE)
-$(COPY) $(OUTPUT_LIB)/crtend.o $(INSTALL_PREFIX)/lib/
Expand Down Expand Up @@ -342,7 +342,7 @@ define MAKESHARED
$(VERBOSE)@$(MAKEDIR) $(@D)
$(VERBOSE)@$(DELETE) $@
$(VERBOSE)echo -e "\rMaking Shared \033[0;31m$@\033[0m"
$(VERBOSE)$(CC) -nostdlib -mcrt=clib2 -shared -o $@ $(OUTPUT_LIB)/shcrtbegin.o $^ $(OUTPUT_LIB)/shcrtend.o $(LOG_COMMAND) -Wl,-soname,$(@F)
$(VERBOSE)$(CC) -nostdlib -mcrt=clib4 -shared -o $@ $(OUTPUT_LIB)/shcrtbegin.o $^ $(OUTPUT_LIB)/shcrtend.o $(LOG_COMMAND) -Wl,-soname,$(@F)
endef

PatchForSPE : $(LIB_ROOT)/misc/PatchForSPE.cpp
Expand All @@ -358,30 +358,30 @@ compile-tests:
install:
$(DELETE) $(INSTALL_PREFIX)/include/*
$(DELETE) $(INSTALL_PREFIX)/lib/*
$(DELETE) $(INSTALL_PREFIX)/clib2.library*
$(DELETE) $(INSTALL_PREFIX)/clib4.library*
$(COPY) $(OUTPUT_LIB)/* $(INSTALL_PREFIX)/lib/
$(COPY) libs/libauto.a $(INSTALL_PREFIX)/lib/
$(COPY) $(BUILD_DIR)/clib2.library* $(INSTALL_PREFIX)
$(COPY) $(BUILD_DIR)/clib4.library* $(INSTALL_PREFIX)
$(COPY) $(LIB_ROOT)/library/include/* $(INSTALL_PREFIX)/include/

release:
-$(DELETE) clib2.lha
-$(DELETE) clib2.info
-$(MAKEDIR) clib2/include
-$(MAKEDIR) clib2/lib
-$(COPY) *.md clib2/
-$(COPY) LICENSE* clib2/
-$(COPY) installer/Install* clib2/
-$(COPY) installer/clib2.info .
-$(COPY) installer/README.md.info clib2/
-$(COPY) $(BUILD_DIR)/clib2.library clib2/
-$(COPY) misc clib2/
-$(COPY) libs/libauto.a clib2/lib/
-$(COPY) $(OUTPUT_LIB)/* clib2/lib/
-$(COPY) $(LIB_ROOT)/library/include/* clib2/include/
lha -ao5i clib2.lha clib2 clib2.info
-$(DELETE) clib2
-$(DELETE) clib2.info
-$(DELETE) clib4.lha
-$(DELETE) clib4.info
-$(MAKEDIR) clib4/include
-$(MAKEDIR) clib4/lib
-$(COPY) *.md clib4/
-$(COPY) LICENSE* clib4/
-$(COPY) installer/Install* clib4/
-$(COPY) installer/clib4.info .
-$(COPY) installer/README.md.info clib4/
-$(COPY) $(BUILD_DIR)/clib4.library clib4/
-$(COPY) misc clib4/
-$(COPY) libs/libauto.a clib4/lib/
-$(COPY) $(OUTPUT_LIB)/* clib4/lib/
-$(COPY) $(LIB_ROOT)/library/include/* clib4/include/
lha -ao5i clib4.lha clib4 clib4.info
-$(DELETE) clib4
-$(DELETE) clib4.info

dpkg:
-$(DELETE) $(DPKG_LIB)
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
BSD 3-Clause License

Copyright (c) 2016, Olaf Barthel
Copyright (c) 2021, Clib2Developers
Copyright (c) 2021, Clib4Developers
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
43 changes: 21 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,34 +26,34 @@ If you find any issue please <a href="https://github.com/afxgroup/clib2/issues">

## Shared library

`clib2` now is an AmigaOS4 shared library. This means that you have to install `clib2.library` in LIBS: folder.
`clib4` now is an AmigaOS4 shared library. This means that you have to install `clib4.library` in LIBS: folder.
Thanks to shared library now the exe files will be smaller since libc.a/so are just stubs to main library files.

### Libraries

Clib2 now has also a working shared version called `libc.so`. And of course also all other libs. Don't use newlib .so
Clib4 now has also a working shared version called `libc.so`. And of course also all other libs. Don't use newlib .so
files when linking because **it will not work**

If you want to use `dlopen`/`dlsym` with shared objects:

**YOU MUST** compile your Clib2 version of library you want to use!
**YOU MUST** compile your Clib4 version of library you want to use!
**DON'T TRY TO USE** newlib shared objects because it will crash badly!
**DON'T USE** static libraries otherwise you could have undefined symbols!

The plain `libc.a` now contains also `libnet.a`, `libunix.a`. Socket support and floating point support are always
enabled.
Soft float version is no longer available.

Clib2 define `__THREAD_SAFE` used to check if the library is thread safe
Clib4 define `__THREAD_SAFE` used to check if the library is thread safe

If you want to use the shared version of library remember to pack your OS4 software with all clib2 shared objects
If you want to use the shared version of library remember to pack your OS4 software with all clib4 shared objects
otherwise the elf loader will try to load objects from SOBJS: and it will load newlib one.
**DON'T overwrite SOBJS: files with your Clib2 files** otherwise OS4 most probably will not load them, and you could
**DON'T overwrite SOBJS: files with your Clib4 files** otherwise OS4 most probably will not load them, and you could
have problems running existent software!

### New memory allocator

Clib2 now use `Wheel Of Fortune` allocator that is faster than previous one, and it seems more robust and with a cleaner
Clib4 now use `Wheel Of Fortune` allocator that is faster than previous one, and it seems more robust and with a cleaner
and portable code

### Optimized AMCC functions
Expand All @@ -63,22 +63,22 @@ Feel free to add other CPU versions.

### Altivec

`libmotovec` has been added to clib2 and enable some altivec functions. Altivec optimizations are not enabled at program
start except if you recompile clib2 with *ENABLE_ALTIVEC_AT_START*.
`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 clib2 is not compiled with altivec optimizations for all files.
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 clib2 providing some optimized functions. To compile
`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.

### Shared objects

Shared objects **are working** also with clib2 (there is an example under test_programs/dlopen folder).
Shared objects **are working** also with clib4 (there is an example under test_programs/dlopen folder).
However shared objects needs the beta elf.library not yet released to public

### Large file support
Expand All @@ -88,10 +88,9 @@ problem).

### SYSV functions

Clib2 now contains **shm***, **msg*** and **sem*** functions.
Clib4 now contains **shm***, **msg*** and **sem*** functions.
<a href="http://www.os4depot.net/share/development/library/misc/sysvipc.lha">SYSV IPC</a> library is now fully
integrated into clib2 library and
doesn't need any external resource
integrated into clib4 library and doesn't need any external resource

### Unix path support

Expand Down Expand Up @@ -122,7 +121,7 @@ Accepted encodings are:
### Math library

Math library has been replaced with openlibm (https://github.com/JuliaMath/openlibm).
This version is faster and more compatible and contains also fenv support that wasn't implemented in clib2.
This version is faster and more compatible and contains also fenv support that wasn't implemented in clib4.

### Complex numbers

Expand All @@ -131,11 +130,11 @@ A lot of other functions has been added trying to make OS4 ports easier.

### libauto

Clib2 now contain also libauto with almost all OS4 components. We'll try to keep them updated.
Clib4 now contain also libauto with almost all OS4 components. We'll try to keep them updated.

### libpthread

Clib2 now contain a native pthread implementation with some functions are not present in the pthread.library.
Clib4 now contain a native pthread implementation with some functions are not present in the pthread.library.
All mutex* function now use OS4 Mutexes instead of Semaphores

### librt
Expand All @@ -154,7 +153,7 @@ Added crypt library that implements crypt and crypt_r

### UNIX sockets (AF_UNIX)

clib2 now supports emulated UNIX sockets. Since roadshow and OS4 doesn't support them natively, UNIX sockets are
clib4 now supports emulated UNIX sockets. Since roadshow and OS4 doesn't support them natively, UNIX sockets are
emulated via
native sockets. The user doesn't need to change anything in the linux code. Everything will be transparent for him

Expand Down Expand Up @@ -202,7 +201,7 @@ If you want to use `gstabs` to non debug version of library you can use the flag

### Misc

Clib2 now supports opening directories with open() and opendir() functions. There are also new other functions that are
Clib4 now supports opening directories with open() and opendir() functions. There are also new other functions that are
used with fd int files.
Check `fcntl.h` for details

Expand All @@ -214,7 +213,7 @@ constructors/destructors executions

### TODO

- There is a memory leak at clib2 end needs to be tracked down
- There are some memory leaks at clib4 end needs to be tracked down
- Try to use Microsoft <a href="https://github.com/microsoft/mimalloc">`mimalloc`</a> as memory allocator that should be
faster when there are multiple cores.
- Add a test suite
Expand All @@ -228,7 +227,7 @@ The BSD license would probably be appropriate here.
BSD 3-Clause License

Copyright (c) 2016, Olaf Barthel
Copyright (c) 2021, Clib2Developers
Copyright (c) 2021, Clib4Developers
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion documentation/BUILDING.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ <h1>Notes on building the library</h1>
Follow the instructions on adtools site and you are ready to go</p>

<p>There is a makefiles for GCC called(<tt>GNUmakefile.os4</tt>). The file is named in this way because the old
clib2 version that had both .os3 and .os4 versions and adtools is searching for it. <br>
clib4 version that had both .os3 and .os4 versions and adtools is searching for it. <br>
So to compile the lib just do a simply: <br/>
<pre>make -f GNUmakefile.os4</pre><br/>
and the ibrary will be built
Expand Down
8 changes: 4 additions & 4 deletions installer/Install
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
(welcome)
(complete 0)
(set @default-dest "LIBS:")
(set @default-sdk-dest "SDK:clib2")
(set @default-sdk-dest "SDK:clib4")
(set @default-dest
(askdir
(prompt "Where would you like to install clib2.library?\nA new Drawer will be created if necessary")
(prompt "Where would you like to install clib4.library?\nA new Drawer will be created if necessary")
(help @askdir-help)
(default @default-dest)
(newpath)
)
)
(complete 30)
(copyfiles
(prompt "clib2 installation")
(prompt "clib4 installation")
(help @copyfiles-help)
(source "")
(choices "clib2.library")
(choices "clib4.library")
(dest @default-dest)
(confirm)
)
Expand Down
2 changes: 1 addition & 1 deletion libamiga.gmk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# $Id: libamiga.gmk,v 1.1 2006-09-17 17:37:27 clib2devs Exp $
# $Id: libamiga.gmk,v 1.1 2006-09-17 17:37:27 clib4devs Exp $
#

OUT_STATIC := $(BUILD_DIR)/obj/libamiga
Expand Down
4 changes: 2 additions & 2 deletions libc.gmk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# $Id: libc.gmk,v 1.9 2010-10-20 13:50:17 clib2devs Exp $
# $Id: libc.gmk,v 1.9 2010-10-20 13:50:17 clib4devs Exp $
# :ts=8
# -*- mode: makefile; -*-

Expand All @@ -15,7 +15,7 @@ endif

C_BASE := \
libc_init_global.o \
getclib2.o \
getclib4.o \
errno_data.o

C_ARGZ := \
Expand Down
2 changes: 1 addition & 1 deletion libcrypt.gmk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# $Id: libcrypt.gmk,v 1.0 2022-07-09 10:09:48 clib2devs Exp $
# $Id: libcrypt.gmk,v 1.0 2022-07-09 10:09:48 clib4devs Exp $
#
# :ts=8
#
Expand Down
2 changes: 1 addition & 1 deletion libdebug.gmk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# $Id: libdebug.gmk,v 1.0 2022-07-09 10:09:48 clib2devs Exp $
# $Id: libdebug.gmk,v 1.0 2022-07-09 10:09:48 clib4devs Exp $
#

OUT_STATIC := $(BUILD_DIR)/obj/libdebug
Expand Down
Loading

0 comments on commit 1a05ce7

Please sign in to comment.