Skip to content

Commit ea6adcd

Browse files
authored
Merge pull request #81 from afxgroup/aio
Added Aio POSIX functions
2 parents 992bb87 + 61cc6c5 commit ea6adcd

File tree

151 files changed

+6708
-2179
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+6708
-2179
lines changed

GNUmakefile.os4

+16-14
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,10 @@ WARNINGS := \
5858
-Wall -W -Wextra -Wpointer-arith -Wsign-compare -Wmissing-prototypes \
5959
-Wundef -Wmissing-declarations -Wunused -Wwrite-strings -Wno-array-bounds -Wno-missing-braces -Wno-unused-value -Wno-comment \
6060
-Wno-deprecated-declarations -Wno-sign-compare -Wno-cast-function-type -Wno-unused-variable -Wno-parentheses -Wno-missing-prototypes \
61-
-Wstrict-aliasing -Wno-shadow -Wno-implicit-fallthrough -Wno-prio-ctor-dtor # -Werror -Wbad-function-cast -Wconversion -Wformat
61+
-Wstrict-aliasing -Wno-shadow -Wno-implicit-fallthrough -Wno-discarded-qualifiers -Wno-unused-function -Wno-unused-parameter -Wno-strict-aliasing \
62+
-Wno-type-limits -Werror # -Wbad-function-cast -Wconversion -Wformat
6263

63-
PIC := -fPIC
64+
PIC := -fPIC -DPIC
6465
INCLUDES := -I$(LIB_DIR)/include \
6566
-Ilibrary \
6667
-I$(LIB_DIR)/external/include \
@@ -96,14 +97,14 @@ OPTIONS := $(LARGEDATA) -DHAVE_SYSV -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
9697
OPTIMIZE := -O3 -mmultiple -mupdate -mstrict-align
9798

9899
ifndef DEBUG
99-
OPTIMIZE := $(OPTIMIZE) -gstabs -DNDEBUG
100+
OPTIMIZE += -gstabs -DNDEBUG
100101
else
101-
OPTIMIZE := $(OPTIMIZE) -gstabs -DDEBUG
102+
OPTIMIZE += -gstabs -DDEBUG
102103
endif
103104

104-
CFLAGS := $(COMPILER_VERSION) $(WARNINGS) $(OPTIMIZE) $(OPTIONS) $(INCLUDES) -D__USE_INLINE__
105-
CFLAGS_N := $(COMPILER_VERSION) $(WARNINGS) $(OPTIMIZE) $(OPTIONS) $(INCLUDES)
106-
AFLAGS := $(COMPILER_VERSION) -Wa,-mregnames
105+
CFLAGS := $(WARNINGS) $(OPTIMIZE) $(OPTIONS) $(INCLUDES) -D__USE_INLINE__
106+
CFLAGS_N := $(WARNINGS) $(OPTIMIZE) $(OPTIONS) $(INCLUDES)
107+
AFLAGS := -Wa,-mregnames
107108

108109
VERBOSE := @
109110

@@ -182,22 +183,22 @@ $(OUTPUT_LIB)/crt0.o : $(LIB_DIR)/crt0.S
182183
$(VERBOSE)$(ASSEMBLE)
183184
-$(COPY) $(OUTPUT_LIB)/crt0.o $(INSTALL_PREFIX)/lib/
184185

185-
$(OUTPUT_LIB)/crtbegin.o : CFLAGS += -fno-aggressive-loop-optimizations
186+
$(OUTPUT_LIB)/crtbegin.o : CFLAGS += -O0 -fno-aggressive-loop-optimizations
186187
$(OUTPUT_LIB)/crtbegin.o : $(LIB_DIR)/crtbegin.c
187188
$(VERBOSE)$(COMPILE)
188189
-$(COPY) $(OUTPUT_LIB)/crtbegin.o $(INSTALL_PREFIX)/lib/
189190

190-
$(OUTPUT_LIB)/crtend.o : CFLAGS += -fno-aggressive-loop-optimizations
191+
$(OUTPUT_LIB)/crtend.o : CFLAGS += -O0 -fno-aggressive-loop-optimizations
191192
$(OUTPUT_LIB)/crtend.o : $(LIB_DIR)/crtend.c
192193
$(VERBOSE)$(COMPILE)
193194
-$(COPY) $(OUTPUT_LIB)/crtend.o $(INSTALL_PREFIX)/lib/
194195

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

200-
$(OUTPUT_LIB)/shcrtend.o : CFLAGS += -O0 -fno-aggressive-loop-optimizations
201+
$(OUTPUT_LIB)/shcrtend.o : CFLAGS += $(PIC) -O0 -fno-aggressive-loop-optimizations
201202
$(OUTPUT_LIB)/shcrtend.o : $(LIB_DIR)/shcrtend.c
202203
$(VERBOSE)$(COMPILE)
203204
-$(COPY) $(OUTPUT_LIB)/shcrtend.o $(INSTALL_PREFIX)/lib/
@@ -225,13 +226,13 @@ endef
225226
define COMPILE_SHARED
226227
$(VERBOSE)@$(MAKEDIR) $(@D)
227228
$(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"
228-
$(VERBOSE)$(CC) $(CFLAGS) $(PIC) -o $@ -c $< $(LOG_COMMAND)
229+
$(VERBOSE)$(CC) $(CFLAGS) $(PIC) -DSHARED -o $@ -c $< $(LOG_COMMAND)
229230
endef
230231

231232
define COMPILE_SHARED_ASM
232233
$(VERBOSE)@$(MAKEDIR) $(@D)
233234
$(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"
234-
$(VERBOSE)$(CC) $(PIC) -o $@ -c $< $(LOG_COMMAND)
235+
$(VERBOSE)$(CC) $(PIC) -DSHARED -o $@ -c $< $(LOG_COMMAND)
235236
endef
236237

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

264265
compile-tests:
@@ -277,6 +278,7 @@ release:
277278
-$(MAKEDIR) clib2/lib
278279
-$(COPY) LICENSE* clib2/
279280
-$(COPY) misc clib2/
281+
-$(COPY) libs/libauto.a clib2/lib/
280282
-$(COPY) $(OUTPUT_LIB)/* clib2/lib/
281283
-$(COPY) $(LIB_ROOT)/library/include/* clib2/include/
282284
jlha -aqo7i clib2.lha clib2

POSIX.md

+82-82
Large diffs are not rendered by default.

README.md

+11-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ Keep in mind that clib2 is not compiled with altivec optimizations for all files
5656

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

6162
### Large file support
6263

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

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

106+
### libpthread
107+
108+
Clib2 now contain a native pthread implementation. However pthread functions are in libc and libpthread is just a stub.
109+
That's because pthread functions are used (and will be used more in the future) internally and they are needed by libc.
110+
libpthread.a is however present as stub to avoid old program stop compiling claiming this library
111+
112+
105113
### libresolv
106114

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

155163
### Known problems
156164

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

159168
### TODO
160169

libc.gmk

+119-9
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,20 @@ C_BASE := \
1818
libc_init_global.o \
1919
errno_data.o
2020

21+
C_AIO := \
22+
aio/aio_cancel.o \
23+
aio/aio_error.o \
24+
aio/aio_fsync.o \
25+
aio/aio_misc.o \
26+
aio/aio_notify.o \
27+
aio/aio_read.o \
28+
aio/aio_read64.o \
29+
aio/aio_return.o \
30+
aio/aio_sigqueue.o \
31+
aio/aio_suspend.o \
32+
aio/aio_write.o \
33+
aio/aio_write64.o \
34+
2135
C_ARGZ := \
2236
argz/add.o \
2337
argz/add_sep.o \
@@ -128,6 +142,9 @@ C_LOCALE := \
128142
locale/open_locale.o \
129143
locale/setlocale.o
130144

145+
C_MISC := \
146+
misc/clist.o \
147+
131148
C_MOUNT := \
132149
mount/convertinfo.o \
133150
mount/fstatfs.o \
@@ -188,6 +205,88 @@ C_POSIX := \
188205
posix/writev.o \
189206
posix/uname.o
190207

208+
C_PTHREAD := \
209+
pthread/common.o \
210+
pthread/pthread.o \
211+
pthread/pthread_attr_destroy.o \
212+
pthread/pthread_attr_getdetachstate.o \
213+
pthread/pthread_attr_getguardsize.o \
214+
pthread/pthread_attr_getschedparam.o \
215+
pthread/pthread_attr_getstack.o \
216+
pthread/pthread_attr_getstacksize.o \
217+
pthread/pthread_attr_init.o \
218+
pthread/pthread_attr_setdetachstate.o \
219+
pthread/pthread_attr_setguardsize.o \
220+
pthread/pthread_attr_setschedparam.o \
221+
pthread/pthread_attr_setstack.o \
222+
pthread/pthread_attr_setstacksize.o \
223+
pthread/pthread_barrier_destroy.o \
224+
pthread/pthread_barrier_init.o \
225+
pthread/pthread_barrier_wait.o \
226+
pthread/pthread_cancel.o \
227+
pthread/pthread_cleanup_pop.o \
228+
pthread/pthread_cleanup_push.o \
229+
pthread/pthread_cond_broadcast.o \
230+
pthread/pthread_cond_destroy.o \
231+
pthread/pthread_cond_init.o \
232+
pthread/pthread_cond_signal.o \
233+
pthread/pthread_cond_timedwait.o \
234+
pthread/pthread_cond_timedwait_relative_np.o \
235+
pthread/pthread_cond_wait.o \
236+
pthread/pthread_condattr_destroy.o \
237+
pthread/pthread_condattr_init.o \
238+
pthread/pthread_create.o \
239+
pthread/pthread_detach.o \
240+
pthread/pthread_equal.o \
241+
pthread/pthread_exit.o \
242+
pthread/pthread_getattr_np.o \
243+
pthread/pthread_getname_np.o \
244+
pthread/pthread_getschedparam.o \
245+
pthread/pthread_getspecific.o \
246+
pthread/pthread_join.o \
247+
pthread/pthread_key_create.o \
248+
pthread/pthread_key_delete.o \
249+
pthread/pthread_kill.o \
250+
pthread/pthread_mutex_destroy.o \
251+
pthread/pthread_mutex_init.o \
252+
pthread/pthread_mutex_lock.o \
253+
pthread/pthread_mutex_timedlock.o \
254+
pthread/pthread_mutex_trylock.o \
255+
pthread/pthread_mutex_unlock.o \
256+
pthread/pthread_mutexattr_destroy.o \
257+
pthread/pthread_mutexattr_gettype.o \
258+
pthread/pthread_mutexattr_init.o \
259+
pthread/pthread_mutexattr_settype.o \
260+
pthread/pthread_once.o \
261+
pthread/pthread_rwlock_destroy.o \
262+
pthread/pthread_rwlock_init.o \
263+
pthread/pthread_rwlock_rdlock.o \
264+
pthread/pthread_rwlock_timedrdlock.o \
265+
pthread/pthread_rwlock_timedwrlock.o \
266+
pthread/pthread_rwlock_tryrdlock.o \
267+
pthread/pthread_rwlock_trywrlock.o \
268+
pthread/pthread_rwlock_unlock.o \
269+
pthread/pthread_rwlock_wrlock.o \
270+
pthread/pthread_rwlockattr_destroy.o \
271+
pthread/pthread_rwlockattr_init.o \
272+
pthread/pthread_self.o \
273+
pthread/pthread_setcancelstate.o \
274+
pthread/pthread_setcanceltype.o \
275+
pthread/pthread_setname_np.o \
276+
pthread/pthread_setschedparam.o \
277+
pthread/pthread_setschedprio.o \
278+
pthread/pthread_setspecific.o \
279+
pthread/pthread_spin_destroy.o \
280+
pthread/pthread_spin_init.o \
281+
pthread/pthread_spin_lock.o \
282+
pthread/pthread_spin_trylock.o \
283+
pthread/pthread_spin_unlock.o \
284+
pthread/pthread_testcancel.o \
285+
pthread/sched_get_priority_max.o \
286+
pthread/sched_get_priority_min.o \
287+
pthread/sched_yield.o \
288+
pthread/semaphore.o
289+
191290
C_REGEX := \
192291
regex/regcomp.o \
193292
regex/regerror.o \
@@ -208,6 +307,14 @@ C_SEARCH := \
208307
search/tsearch.o \
209308
search/twalk.o
210309

310+
C_SETJMP := \
311+
setjmp/_longjmp.o \
312+
setjmp/longjmp.o \
313+
setjmp/setjmp.o \
314+
setjmp/sigjmp.o \
315+
setjmp/siglongjmp.o \
316+
setjmp/sigsetjmp.o
317+
211318
C_SOCKET := \
212319
resolv/dns_parse.o \
213320
resolv/lookup_ipliteral.o \
@@ -478,11 +585,11 @@ C_STDLIB := \
478585
stdlib/itoa.o \
479586
stdlib/l64a.o \
480587
stdlib/labs.o \
481-
stdlib/llabs.o \
482-
stdlib/lltoa.o \
483588
stdlib/ldiv.o \
484-
stdlib/lldiv.o \
485589
stdlib/lib_startup.o \
590+
stdlib/llabs.o \
591+
stdlib/lldiv.o \
592+
stdlib/lltoa.o \
486593
stdlib/main.o \
487594
stdlib/main_stub.o \
488595
stdlib/malloc.o \
@@ -510,7 +617,6 @@ C_STDLIB := \
510617
stdlib/secure_getenv.o \
511618
stdlib/semaphore.o \
512619
stdlib/setenv.o \
513-
stdlib/setjmp.o \
514620
stdlib/set_errno.o \
515621
stdlib/set_process_window.o \
516622
stdlib/shared_objs.o \
@@ -636,6 +742,7 @@ C_TIME := \
636742
time/clock.o \
637743
time/clock_getres.o \
638744
time/clock_gettime.o \
745+
time/clock_gettime64.o \
639746
time/clock_nanosleep.o \
640747
time/converttime.o \
641748
time/convert_datestamp.o \
@@ -734,7 +841,9 @@ C_UNISTD := \
734841
unistd/pipe.o \
735842
unistd/pipe2.o \
736843
unistd/pread.o \
844+
unistd/pread64.o \
737845
unistd/pwrite.o \
846+
unistd/pwrite64.o \
738847
unistd/readlink.o \
739848
unistd/reallocarray.o \
740849
unistd/realpath.o \
@@ -903,18 +1012,22 @@ C_WCHAR := \
9031012

9041013
C_LIB := \
9051014
$(C_BASE) \
906-
$(C_BYTESWAP) \
1015+
$(C_AIO) \
9071016
$(C_ARGZ) \
1017+
$(C_BYTESWAP) \
9081018
$(C_CTYPE) \
9091019
$(C_DIRENT) \
9101020
$(C_DEBUG) \
9111021
$(C_ICONV) \
9121022
$(C_INTTYPES) \
9131023
$(C_LOCALE) \
1024+
$(C_MISC) \
9141025
$(C_MOUNT) \
9151026
$(C_POSIX) \
1027+
$(C_PTHREAD) \
9161028
$(C_REGEX) \
9171029
$(C_SEARCH) \
1030+
$(C_SETJMP) \
9181031
$(C_SOCKET) \
9191032
$(C_STAT) \
9201033
$(C_STDIO) \
@@ -935,9 +1048,6 @@ SOURCES_STATIC = $(addprefix $(OUT_STATIC)/, $(C_LIB))
9351048
$(OUT_STATIC)/c.lib_rev.o : $(LIB_DIR)/c.lib_rev.c $(LIB_DIR)/c.lib_rev.h
9361049
$(BUILD_DIR)/obj.shared/c.lib_rev.o : $(LIB_DIR)/c.lib_rev.c $(LIB_DIR)/c.lib_rev.h
9371050

938-
$(OUT_STATIC)/%.o : CFLAGS += $(LARGEDATA)
939-
$(OUT_SHARED)/%.o : CFLAGS += $(PIC) $(LARGEDATA)
940-
9411051
$(OUT_STATIC)/%.o : $(LIB_DIR)/%.sx
9421052
$(VERBOSE)$(COMPILE_REG)
9431053
$(OUT_STATIC)/%.o : $(LIB_DIR)/%.S
@@ -960,5 +1070,5 @@ $(OUTPUT_LIB)/libc.so : $(SOURCES_SHARED)
9601070
@$(MAKEDIR) $(@D)
9611071
@$(DELETE) $@
9621072
$(VERBOSE)echo "Making Shared \033[0;31m$@\033[0m"
963-
$(VERBOSE)$(CC) -nostdlib -mcrt=clib2 -shared -o $@ $(OUTPUT_LIB)/shcrtbegin.o $^ $(OUTPUT_LIB)/shcrtend.o $(LOG_COMMAND)
1073+
$(VERBOSE)$(CC) -nostdlib -mcrt=clib2 -shared -o $@ $(OUTPUT_LIB)/shcrtbegin.o $^ $(OUTPUT_LIB)/shcrtend.o $(LOG_COMMAND) -Wl,-soname,$(@F)
9641074
$(COPY) $(OUTPUT_LIB)/libc.so $(INSTALL_PREFIX)/lib/

0 commit comments

Comments
 (0)