Skip to content

Commit

Permalink
Merge pull request #81 from afxgroup/aio
Browse files Browse the repository at this point in the history
Added Aio POSIX functions
  • Loading branch information
afxgroup authored Mar 7, 2023
2 parents 992bb87 + 61cc6c5 commit ea6adcd
Show file tree
Hide file tree
Showing 151 changed files with 6,708 additions and 2,179 deletions.
30 changes: 16 additions & 14 deletions GNUmakefile.os4
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ WARNINGS := \
-Wall -W -Wextra -Wpointer-arith -Wsign-compare -Wmissing-prototypes \
-Wundef -Wmissing-declarations -Wunused -Wwrite-strings -Wno-array-bounds -Wno-missing-braces -Wno-unused-value -Wno-comment \
-Wno-deprecated-declarations -Wno-sign-compare -Wno-cast-function-type -Wno-unused-variable -Wno-parentheses -Wno-missing-prototypes \
-Wstrict-aliasing -Wno-shadow -Wno-implicit-fallthrough -Wno-prio-ctor-dtor # -Werror -Wbad-function-cast -Wconversion -Wformat
-Wstrict-aliasing -Wno-shadow -Wno-implicit-fallthrough -Wno-discarded-qualifiers -Wno-unused-function -Wno-unused-parameter -Wno-strict-aliasing \
-Wno-type-limits -Werror # -Wbad-function-cast -Wconversion -Wformat

PIC := -fPIC
PIC := -fPIC -DPIC
INCLUDES := -I$(LIB_DIR)/include \
-Ilibrary \
-I$(LIB_DIR)/external/include \
Expand Down Expand Up @@ -96,14 +97,14 @@ OPTIONS := $(LARGEDATA) -DHAVE_SYSV -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
OPTIMIZE := -O3 -mmultiple -mupdate -mstrict-align

ifndef DEBUG
OPTIMIZE := $(OPTIMIZE) -gstabs -DNDEBUG
OPTIMIZE += -gstabs -DNDEBUG
else
OPTIMIZE := $(OPTIMIZE) -gstabs -DDEBUG
OPTIMIZE += -gstabs -DDEBUG
endif

CFLAGS := $(COMPILER_VERSION) $(WARNINGS) $(OPTIMIZE) $(OPTIONS) $(INCLUDES) -D__USE_INLINE__
CFLAGS_N := $(COMPILER_VERSION) $(WARNINGS) $(OPTIMIZE) $(OPTIONS) $(INCLUDES)
AFLAGS := $(COMPILER_VERSION) -Wa,-mregnames
CFLAGS := $(WARNINGS) $(OPTIMIZE) $(OPTIONS) $(INCLUDES) -D__USE_INLINE__
CFLAGS_N := $(WARNINGS) $(OPTIMIZE) $(OPTIONS) $(INCLUDES)
AFLAGS := -Wa,-mregnames

VERBOSE := @

Expand Down Expand Up @@ -182,22 +183,22 @@ $(OUTPUT_LIB)/crt0.o : $(LIB_DIR)/crt0.S
$(VERBOSE)$(ASSEMBLE)
-$(COPY) $(OUTPUT_LIB)/crt0.o $(INSTALL_PREFIX)/lib/

$(OUTPUT_LIB)/crtbegin.o : CFLAGS += -fno-aggressive-loop-optimizations
$(OUTPUT_LIB)/crtbegin.o : CFLAGS += -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 += -fno-aggressive-loop-optimizations
$(OUTPUT_LIB)/crtend.o : CFLAGS += -O0 -fno-aggressive-loop-optimizations
$(OUTPUT_LIB)/crtend.o : $(LIB_DIR)/crtend.c
$(VERBOSE)$(COMPILE)
-$(COPY) $(OUTPUT_LIB)/crtend.o $(INSTALL_PREFIX)/lib/

$(OUTPUT_LIB)/shcrtbegin.o : CFLAGS += -O0 -fno-aggressive-loop-optimizations
$(OUTPUT_LIB)/shcrtbegin.o : CFLAGS += $(PIC) -O0 -fno-aggressive-loop-optimizations
$(OUTPUT_LIB)/shcrtbegin.o : $(LIB_DIR)/shcrtbegin.c
$(VERBOSE)$(COMPILE)
-$(COPY) $(OUTPUT_LIB)/shcrtbegin.o $(INSTALL_PREFIX)/lib/

$(OUTPUT_LIB)/shcrtend.o : CFLAGS += -O0 -fno-aggressive-loop-optimizations
$(OUTPUT_LIB)/shcrtend.o : CFLAGS += $(PIC) -O0 -fno-aggressive-loop-optimizations
$(OUTPUT_LIB)/shcrtend.o : $(LIB_DIR)/shcrtend.c
$(VERBOSE)$(COMPILE)
-$(COPY) $(OUTPUT_LIB)/shcrtend.o $(INSTALL_PREFIX)/lib/
Expand Down Expand Up @@ -225,13 +226,13 @@ endef
define COMPILE_SHARED
$(VERBOSE)@$(MAKEDIR) $(@D)
$(VERBOSE)echo -e "\rCompiling Shared \033[0;33m[$(@D)]\033[0m \r\t\t\t\t\t\t\t\t\t\t\t \033[0;31m$(@F)\033[0m"
$(VERBOSE)$(CC) $(CFLAGS) $(PIC) -o $@ -c $< $(LOG_COMMAND)
$(VERBOSE)$(CC) $(CFLAGS) $(PIC) -DSHARED -o $@ -c $< $(LOG_COMMAND)
endef

define COMPILE_SHARED_ASM
$(VERBOSE)@$(MAKEDIR) $(@D)
$(VERBOSE)echo -e "\rCompiling Shared Asm \033[0;33m[$(@D)]\033[0m \r\t\t\t\t\t\t\t\t\t\t\t \033[0;31m$(@F)\033[0m"
$(VERBOSE)$(CC) $(PIC) -o $@ -c $< $(LOG_COMMAND)
$(VERBOSE)$(CC) $(PIC) -DSHARED -o $@ -c $< $(LOG_COMMAND)
endef

define ASSEMBLE
Expand All @@ -258,7 +259,7 @@ define MAKESHARED
$(VERBOSE)@$(MAKEDIR) $(@D)
$(VERBOSE)@$(DELETE) $@
$(VERBOSE)echo -e "\rMaking Shared \033[0;31m$@\033[0m"
$(VERBOSE)$(CC) -mcrt=clib2 -shared -use-dynld -o $@ $^ $(LOG_COMMAND) -Lbuild/lib -lc
$(VERBOSE)$(CC) -nostdlib -mcrt=clib2 -shared -o $@ $(OUTPUT_LIB)/shcrtbegin.o $^ $(OUTPUT_LIB)/shcrtend.o $(LOG_COMMAND) -Wl,-soname,$(@F)
endef

compile-tests:
Expand All @@ -277,6 +278,7 @@ release:
-$(MAKEDIR) clib2/lib
-$(COPY) LICENSE* clib2/
-$(COPY) misc clib2/
-$(COPY) libs/libauto.a clib2/lib/
-$(COPY) $(OUTPUT_LIB)/* clib2/lib/
-$(COPY) $(LIB_ROOT)/library/include/* clib2/include/
jlha -aqo7i clib2.lha clib2
Expand Down
164 changes: 82 additions & 82 deletions POSIX.md

Large diffs are not rendered by default.

13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ Keep in mind that clib2 is not compiled with altivec optimizations for all files

Shared objects **are working** also with clib2 (there is an example under test_programs/dlopen folder).
using dlopen/dlsym will not crash anymore however there is a bug in `libstdc++.so` that is causing a crash on program start.
So if you want to use libstdc++ it is better to remove it and link against the static version.
So if you want to use libstdc++ it is better to remove it and link against the static version.
However they needs the beta elf.library not yet released to public

### Large file support

Expand Down Expand Up @@ -102,6 +103,13 @@ A lot of other functions has been added trying to make OS4 ports easier.

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

### libpthread

Clib2 now contain a native pthread implementation. However pthread functions are in libc and libpthread is just a stub.
That's because pthread functions are used (and will be used more in the future) internally and they are needed by libc.
libpthread.a is however present as stub to avoid old program stop compiling claiming this library


### libresolv

Added resolv library to use dns functions. A lot of socket functions that was using bsdsocket.library now use this library.
Expand Down Expand Up @@ -154,7 +162,8 @@ Check `fcntl.h` for details

### Known problems

Don't call `exit()` function in an `alarm()` handler otherwise your program will be stuck at exit.
Don't call `exit()` function in an `alarm()` handler otherwise your program will be stuck at exit.
All *crt* files needs to be compiled with -fno-aggressive-loop-optimizations! Otherwise you will have problems during constructors/destructors executions

### TODO

Expand Down
128 changes: 119 additions & 9 deletions libc.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@ C_BASE := \
libc_init_global.o \
errno_data.o

C_AIO := \
aio/aio_cancel.o \
aio/aio_error.o \
aio/aio_fsync.o \
aio/aio_misc.o \
aio/aio_notify.o \
aio/aio_read.o \
aio/aio_read64.o \
aio/aio_return.o \
aio/aio_sigqueue.o \
aio/aio_suspend.o \
aio/aio_write.o \
aio/aio_write64.o \

C_ARGZ := \
argz/add.o \
argz/add_sep.o \
Expand Down Expand Up @@ -128,6 +142,9 @@ C_LOCALE := \
locale/open_locale.o \
locale/setlocale.o

C_MISC := \
misc/clist.o \

C_MOUNT := \
mount/convertinfo.o \
mount/fstatfs.o \
Expand Down Expand Up @@ -188,6 +205,88 @@ C_POSIX := \
posix/writev.o \
posix/uname.o

C_PTHREAD := \
pthread/common.o \
pthread/pthread.o \
pthread/pthread_attr_destroy.o \
pthread/pthread_attr_getdetachstate.o \
pthread/pthread_attr_getguardsize.o \
pthread/pthread_attr_getschedparam.o \
pthread/pthread_attr_getstack.o \
pthread/pthread_attr_getstacksize.o \
pthread/pthread_attr_init.o \
pthread/pthread_attr_setdetachstate.o \
pthread/pthread_attr_setguardsize.o \
pthread/pthread_attr_setschedparam.o \
pthread/pthread_attr_setstack.o \
pthread/pthread_attr_setstacksize.o \
pthread/pthread_barrier_destroy.o \
pthread/pthread_barrier_init.o \
pthread/pthread_barrier_wait.o \
pthread/pthread_cancel.o \
pthread/pthread_cleanup_pop.o \
pthread/pthread_cleanup_push.o \
pthread/pthread_cond_broadcast.o \
pthread/pthread_cond_destroy.o \
pthread/pthread_cond_init.o \
pthread/pthread_cond_signal.o \
pthread/pthread_cond_timedwait.o \
pthread/pthread_cond_timedwait_relative_np.o \
pthread/pthread_cond_wait.o \
pthread/pthread_condattr_destroy.o \
pthread/pthread_condattr_init.o \
pthread/pthread_create.o \
pthread/pthread_detach.o \
pthread/pthread_equal.o \
pthread/pthread_exit.o \
pthread/pthread_getattr_np.o \
pthread/pthread_getname_np.o \
pthread/pthread_getschedparam.o \
pthread/pthread_getspecific.o \
pthread/pthread_join.o \
pthread/pthread_key_create.o \
pthread/pthread_key_delete.o \
pthread/pthread_kill.o \
pthread/pthread_mutex_destroy.o \
pthread/pthread_mutex_init.o \
pthread/pthread_mutex_lock.o \
pthread/pthread_mutex_timedlock.o \
pthread/pthread_mutex_trylock.o \
pthread/pthread_mutex_unlock.o \
pthread/pthread_mutexattr_destroy.o \
pthread/pthread_mutexattr_gettype.o \
pthread/pthread_mutexattr_init.o \
pthread/pthread_mutexattr_settype.o \
pthread/pthread_once.o \
pthread/pthread_rwlock_destroy.o \
pthread/pthread_rwlock_init.o \
pthread/pthread_rwlock_rdlock.o \
pthread/pthread_rwlock_timedrdlock.o \
pthread/pthread_rwlock_timedwrlock.o \
pthread/pthread_rwlock_tryrdlock.o \
pthread/pthread_rwlock_trywrlock.o \
pthread/pthread_rwlock_unlock.o \
pthread/pthread_rwlock_wrlock.o \
pthread/pthread_rwlockattr_destroy.o \
pthread/pthread_rwlockattr_init.o \
pthread/pthread_self.o \
pthread/pthread_setcancelstate.o \
pthread/pthread_setcanceltype.o \
pthread/pthread_setname_np.o \
pthread/pthread_setschedparam.o \
pthread/pthread_setschedprio.o \
pthread/pthread_setspecific.o \
pthread/pthread_spin_destroy.o \
pthread/pthread_spin_init.o \
pthread/pthread_spin_lock.o \
pthread/pthread_spin_trylock.o \
pthread/pthread_spin_unlock.o \
pthread/pthread_testcancel.o \
pthread/sched_get_priority_max.o \
pthread/sched_get_priority_min.o \
pthread/sched_yield.o \
pthread/semaphore.o

C_REGEX := \
regex/regcomp.o \
regex/regerror.o \
Expand All @@ -208,6 +307,14 @@ C_SEARCH := \
search/tsearch.o \
search/twalk.o

C_SETJMP := \
setjmp/_longjmp.o \
setjmp/longjmp.o \
setjmp/setjmp.o \
setjmp/sigjmp.o \
setjmp/siglongjmp.o \
setjmp/sigsetjmp.o

C_SOCKET := \
resolv/dns_parse.o \
resolv/lookup_ipliteral.o \
Expand Down Expand Up @@ -478,11 +585,11 @@ C_STDLIB := \
stdlib/itoa.o \
stdlib/l64a.o \
stdlib/labs.o \
stdlib/llabs.o \
stdlib/lltoa.o \
stdlib/ldiv.o \
stdlib/lldiv.o \
stdlib/lib_startup.o \
stdlib/llabs.o \
stdlib/lldiv.o \
stdlib/lltoa.o \
stdlib/main.o \
stdlib/main_stub.o \
stdlib/malloc.o \
Expand Down Expand Up @@ -510,7 +617,6 @@ C_STDLIB := \
stdlib/secure_getenv.o \
stdlib/semaphore.o \
stdlib/setenv.o \
stdlib/setjmp.o \
stdlib/set_errno.o \
stdlib/set_process_window.o \
stdlib/shared_objs.o \
Expand Down Expand Up @@ -636,6 +742,7 @@ C_TIME := \
time/clock.o \
time/clock_getres.o \
time/clock_gettime.o \
time/clock_gettime64.o \
time/clock_nanosleep.o \
time/converttime.o \
time/convert_datestamp.o \
Expand Down Expand Up @@ -734,7 +841,9 @@ C_UNISTD := \
unistd/pipe.o \
unistd/pipe2.o \
unistd/pread.o \
unistd/pread64.o \
unistd/pwrite.o \
unistd/pwrite64.o \
unistd/readlink.o \
unistd/reallocarray.o \
unistd/realpath.o \
Expand Down Expand Up @@ -903,18 +1012,22 @@ C_WCHAR := \

C_LIB := \
$(C_BASE) \
$(C_BYTESWAP) \
$(C_AIO) \
$(C_ARGZ) \
$(C_BYTESWAP) \
$(C_CTYPE) \
$(C_DIRENT) \
$(C_DEBUG) \
$(C_ICONV) \
$(C_INTTYPES) \
$(C_LOCALE) \
$(C_MISC) \
$(C_MOUNT) \
$(C_POSIX) \
$(C_PTHREAD) \
$(C_REGEX) \
$(C_SEARCH) \
$(C_SETJMP) \
$(C_SOCKET) \
$(C_STAT) \
$(C_STDIO) \
Expand All @@ -935,9 +1048,6 @@ SOURCES_STATIC = $(addprefix $(OUT_STATIC)/, $(C_LIB))
$(OUT_STATIC)/c.lib_rev.o : $(LIB_DIR)/c.lib_rev.c $(LIB_DIR)/c.lib_rev.h
$(BUILD_DIR)/obj.shared/c.lib_rev.o : $(LIB_DIR)/c.lib_rev.c $(LIB_DIR)/c.lib_rev.h

$(OUT_STATIC)/%.o : CFLAGS += $(LARGEDATA)
$(OUT_SHARED)/%.o : CFLAGS += $(PIC) $(LARGEDATA)

$(OUT_STATIC)/%.o : $(LIB_DIR)/%.sx
$(VERBOSE)$(COMPILE_REG)
$(OUT_STATIC)/%.o : $(LIB_DIR)/%.S
Expand All @@ -960,5 +1070,5 @@ $(OUTPUT_LIB)/libc.so : $(SOURCES_SHARED)
@$(MAKEDIR) $(@D)
@$(DELETE) $@
$(VERBOSE)echo "Making Shared \033[0;31m$@\033[0m"
$(VERBOSE)$(CC) -nostdlib -mcrt=clib2 -shared -o $@ $(OUTPUT_LIB)/shcrtbegin.o $^ $(OUTPUT_LIB)/shcrtend.o $(LOG_COMMAND)
$(VERBOSE)$(CC) -nostdlib -mcrt=clib2 -shared -o $@ $(OUTPUT_LIB)/shcrtbegin.o $^ $(OUTPUT_LIB)/shcrtend.o $(LOG_COMMAND) -Wl,-soname,$(@F)
$(COPY) $(OUTPUT_LIB)/libc.so $(INSTALL_PREFIX)/lib/
Loading

0 comments on commit ea6adcd

Please sign in to comment.