Skip to content

Commit f5dbfa8

Browse files
authored
Merge pull request #172 from AmigaLabs/beta10
Merge Beta10 into master
2 parents 63f6298 + 66a8072 commit f5dbfa8

39 files changed

+303
-124
lines changed

GNUmakefile.os4

+1
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ include libm.gmk
172172
include libamiga.gmk
173173
include libdebug.gmk
174174
include libpthread.gmk
175+
include libprofile.gmk
175176
include libcrypt.gmk
176177
include librt.gmk
177178
include shared.gmk

libc.gmk

+1-4
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ C_STDIO := \
350350
prng/srand.o \
351351
prng/srand48.o \
352352
prng/srandom.o \
353+
stdio/__std.o \
353354
stdio/asprintf.o \
354355
stdio/change_fd_action.o \
355356
stdio/change_fd_user_data.o \
@@ -952,10 +953,6 @@ C_LIBRARY := \
952953

953954
C_LIB := \
954955
c.lib_rev.o \
955-
profile/_mcount.o \
956-
profile/profil.o \
957-
profile/gmon.o \
958-
profile/mcount.o \
959956
shared_library/stubs.o \
960957
unistd/getopt.o \
961958
unistd/getopt_long.o \

libcrypt.gmk

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
#
22
# $Id: libcrypt.gmk,v 1.0 2022-07-09 10:09:48 clib4devs Exp $
33
#
4-
# :ts=8
5-
#
6-
# -*- mode: makefile; -*-
74

85
OUT_STATIC := $(BUILD_DIR)/obj/libcrypt
96
OUT_SHARED := $(BUILD_DIR)/obj.shared/libcrypt

libprofile.gmk

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#
2+
# $Id: libprofile.gmk,v 1.1 2006-09-17 17:37:27 clib2devs Exp $
3+
#
4+
5+
OUT_STATIC := $(BUILD_DIR)/obj/libprofile
6+
OUT_SHARED := $(BUILD_DIR)/obj.shared/libprofile
7+
8+
ifeq ($(SHARED),yes)
9+
LIBS += $(OUTPUT_LIB)/libprofile.so
10+
endif
11+
ifeq ($(STATIC),yes)
12+
LIBS += $(OUTPUT_LIB)/libprofile.a
13+
endif
14+
15+
PROFILE_LIB = \
16+
profile/_mcount.o \
17+
profile/profil.o \
18+
profile/gmon.o \
19+
profile/mcount.o
20+
21+
SOURCES_SHARED = $(addprefix $(OUT_SHARED)/, $(PROFILE_LIB))
22+
SOURCES_STATIC = $(addprefix $(OUT_STATIC)/, $(PROFILE_LIB))
23+
24+
# Dependencies to rebuild if the library version changes
25+
26+
$(OUT_STATIC)/profile.lib_rev.o : $(LIB_DIR)/profile/profile.lib_rev.c $(LIB_DIR)/profile/profile.lib_rev.h
27+
$(OUT_SHARED)/profile.lib_rev.o : $(LIB_DIR)/profile/profile.lib_rev.c $(LIB_DIR)/profile/profile.lib_rev.h
28+
29+
$(OUT_STATIC)/%.o : AFLAGS += $(LARGEDATA)
30+
$(OUT_SHARED)/%.o : AFLAGS += $(PIC) $(LARGEDATA)
31+
32+
$(OUT_STATIC)/%.o : $(LIB_DIR)/%.S
33+
$(VERBOSE)$(ASSEMBLE)
34+
35+
$(OUT_SHARED)/%.o : $(LIB_DIR)/%.S
36+
$(VERBOSE)$(ASSEMBLE)
37+
38+
$(OUT_STATIC)/%.o : CFLAGS += $(LARGEDATA)
39+
$(OUT_SHARED)/%.o : CFLAGS += $(PIC) $(LARGEDATA)
40+
41+
ifdef SPE
42+
$(OUT_STATIC)/%.o : $(LIB_DIR)/%.c
43+
$(VERBOSE)$(COMPILE_SPE)
44+
$(OUT_SHARED)/%.o : $(LIB_DIR)/%.c
45+
$(VERBOSE)$(COMPILE_SHARED_SPE)
46+
else
47+
$(OUT_STATIC)/%.o : $(LIB_DIR)/%.c
48+
$(VERBOSE)$(COMPILE)
49+
$(OUT_SHARED)/%.o : $(LIB_DIR)/%.c
50+
$(VERBOSE)$(COMPILE_SHARED)
51+
endif
52+
53+
$(OUTPUT_LIB)/libprofile.a : $(SOURCES_STATIC)
54+
$(VERBOSE)$(MAKELIB)
55+
56+
$(OUTPUT_LIB)/libprofile.so : $(OUTPUT_LIB)/libc.so $(SOURCES_SHARED)
57+
$(VERBOSE)$(MAKESHARED)

library/c.lib_rev.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define REVISION 0
33
#define SUBREVISION 0
44

5-
#define DATE "27.09.2023"
5+
#define DATE "21.03.2024"
66
#define VERS "clib4.library 1.0.0"
7-
#define VSTRING "clib4.library 1.0.0 (27.09.2023)\r\n"
8-
#define VERSTAG "\0$VER: clib4.library 1.0.0 (27.09.2023)"
7+
#define VSTRING "clib4.library 1.0.0 (21.03.2024)\r\n"
8+
#define VERSTAG "\0$VER: clib4.library 1.0.0 (21.03.2024)"

library/include/ctype.h

+11-13
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#define _CTYPE_H
77

88
#include <features.h>
9-
#include <dos.h>
109

1110
__BEGIN_DECLS
1211

@@ -48,18 +47,17 @@ extern int toascii(int c);
4847

4948
/****************************************************************************/
5049

51-
#define isalnum(c) ((__CLIB4->__ctype_table[(c) & 255] & (__CTYPE_DIGIT|__CTYPE_LOWER_CASE|__CTYPE_UPPER_CASE)) != 0)
52-
#define isalpha(c) ((__CLIB4->__ctype_table[(c) & 255] & (__CTYPE_LOWER_CASE|__CTYPE_UPPER_CASE)) != 0)
53-
#define iscntrl(c) ((__CLIB4->__ctype_table[(c) & 255] & __CTYPE_CONTROL) != 0)
54-
#define isdigit(c) ((__CLIB4->__ctype_table[(c) & 255] & __CTYPE_DIGIT) != 0)
55-
#define isxdigit(c) ((__CLIB4->__ctype_table[(c) & 255] & __CTYPE_HEX_DIGIT) != 0)
56-
#define isgraph(c) ((__CLIB4->__ctype_table[(c) & 255] & (__CTYPE_DIGIT|__CTYPE_PUNCTUATION|__CTYPE_LOWER_CASE|__CTYPE_UPPER_CASE)) != 0)
57-
#define ispunct(c) ((__CLIB4->__ctype_table[(c) & 255] & __CTYPE_PUNCTUATION) != 0)
58-
#define isprint(c) ((__CLIB4->__ctype_table[(c) & 255] & __CTYPE_PRINTABLE) != 0)
59-
#define islower(c) ((__CLIB4->__ctype_table[(c) & 255] & __CTYPE_LOWER_CASE) != 0)
60-
#define isupper(c) ((__CLIB4->__ctype_table[(c) & 255] & __CTYPE_UPPER_CASE) != 0)
61-
#define isspace(c) ((__CLIB4->__ctype_table[(c) & 255] & __CTYPE_WHITE_SPACE) != 0)
62-
#define isblank(c) ((c) == ' ' || (c) == '\t')
50+
static __inline int __isspace(int _c) {
51+
return _c == ' ' || (unsigned)_c-'\t' < 5;
52+
}
53+
54+
#define isalpha(a) (0 ? isalpha(a) : (((unsigned)(a)|32)-'a') < 26)
55+
#define isdigit(a) (0 ? isdigit(a) : ((unsigned)(a)-'0') < 10)
56+
#define islower(a) (0 ? islower(a) : ((unsigned)(a)-'a') < 26)
57+
#define isupper(a) (0 ? isupper(a) : ((unsigned)(a)-'A') < 26)
58+
#define isprint(a) (0 ? isprint(a) : ((unsigned)(a)-0x20) < 0x5f)
59+
#define isgraph(a) (0 ? isgraph(a) : ((unsigned)(a)-0x21) < 0x5e)
60+
#define isspace(a) __isspace(a)
6361

6462
#endif /* __cplusplus */
6563

library/include/dos.h

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
#include <wchar.h>
1515
#include <setjmp.h>
1616
#include <resolv.h>
17+
#include <exec/types.h>
18+
#include <exec/lists.h>
19+
#include <exec/semaphores.h>
1720

1821
/* Category name handling variables. */
1922
#define NUM_LOCALES (LC_MAX + 1)

library/include/malloc.h

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
#include <stddef.h>
1111
#include <stdio.h>
12-
#include <exec/lists.h>
13-
#include <exec/nodes.h>
1412

1513
#define SIZE_ALIGN (4 * sizeof(size_t))
1614
#define SIZE_MASK (-SIZE_ALIGN)

library/include/math.h

+7-4
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ __BEGIN_DECLS
1313
#include <stdlib.h>
1414
#endif /* _STDLIB_H */
1515

16-
#include <dos.h>
17-
1816
/* Natural log of 2 */
1917
#define _M_LN2 (double) 0.693147180559945309417
2018

@@ -88,8 +86,13 @@ extern float ynf(int n, float x);
8886
/* HUGE_VALL is a 'long double' Infinity. */
8987
#define HUGE_VALL (1.0L / 0.0L)
9088

91-
#define INFINITY ((const float) __CLIB4->__infinity)
92-
#define NAN ((const float) __CLIB4->__nan)
89+
# ifndef INFINITY
90+
# define INFINITY (__builtin_inff())
91+
# endif
92+
93+
# ifndef NAN
94+
# define NAN (__builtin_nanf(""))
95+
# endif
9396

9497
#define FP_INFINITE 0x01 /* -/+ infinity */
9598
#define FP_NAN 0x02 /* not a number */

library/include/pthread.h

+8-25
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,10 @@
2626
#include <sys/types.h>
2727
#include <sys/time.h>
2828
#include <errno.h>
29-
#include <exec/types.h>
30-
#include <exec/semaphores.h>
3129
#include <sched.h>
3230
#include <features.h>
3331

34-
#ifdef __cplusplus
35-
#ifdef __USE_AMIGAOS_NAMESPACE__
36-
namespace AmigaOS {
37-
#endif
38-
extern "C" {
39-
#endif
32+
__BEGIN_DECLS
4033

4134
//
4235
// POSIX options
@@ -150,7 +143,7 @@ struct pthread_mutexattr {
150143
typedef struct pthread_mutexattr pthread_mutexattr_t;
151144

152145
struct pthread_mutex {
153-
APTR mutex;
146+
void* mutex; // APTR
154147
int kind;
155148
int incond;
156149
struct Task *owner;
@@ -180,13 +173,13 @@ typedef struct pthread_condattr pthread_condattr_t;
180173

181174
struct pthread_cond {
182175
int pad1;
183-
struct SignalSemaphore semaphore;
184-
struct MinList waiters;
176+
void* semaphore; // SignalSemaphore
177+
void* waiters; // MinList
185178
};
186179

187180
typedef struct pthread_cond pthread_cond_t;
188181

189-
#define PTHREAD_COND_INITIALIZER {0, NULL_SEMAPHORE, NULL_MINLIST}
182+
#define PTHREAD_COND_INITIALIZER {0, 0, 0}
190183

191184
//
192185
// Barriers
@@ -200,12 +193,7 @@ struct pthread_barrierattr {
200193

201194
typedef struct pthread_barrierattr pthread_barrierattr_t;
202195

203-
struct pthread_barrier {
204-
unsigned int curr_height;
205-
unsigned int total_height;
206-
pthread_cond_t breeched;
207-
pthread_mutex_t lock;
208-
};
196+
struct pthread_barrier;
209197

210198
typedef struct pthread_barrier pthread_barrier_t;
211199

@@ -220,7 +208,7 @@ struct pthread_rwlockattr {
220208
typedef struct pthread_rwlockattr pthread_rwlockattr_t;
221209

222210
struct pthread_rwlock {
223-
struct SignalSemaphore semaphore;
211+
void* semaphore; // SignalSemaphore
224212
};
225213

226214
typedef struct pthread_rwlock pthread_rwlock_t;
@@ -414,11 +402,6 @@ extern void pthread_cleanup_pop(int execute);
414402

415403
extern int pthread_kill(pthread_t thread, int sig);
416404

417-
#ifdef __cplusplus
418-
}
419-
#ifdef __USE_AMIGAOS_NAMESPACE__
420-
}
421-
#endif
422-
#endif
405+
__END_DECLS
423406

424407
#endif

library/include/semaphore.h

+1-8
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,7 @@
4040
#undef SEM_FAILED
4141
#define SEM_FAILED ((sem_t *)(-1))
4242

43-
struct sema
44-
{
45-
struct Node node;
46-
int value;
47-
int waiters_count;
48-
pthread_mutex_t lock;
49-
pthread_cond_t count_nonzero;
50-
};
43+
struct sema;
5144

5245
typedef struct sema sem_t;
5346

library/include/signal.h

-6
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@
77

88
#include <features.h>
99

10-
#ifdef __cplusplus
11-
#ifdef __USE_AMIGAOS_NAMESPACE__
12-
#define pthread_attr_t AmigaOS::pthread_attr_t
13-
#endif
14-
#endif
15-
1610
__BEGIN_DECLS
1711

1812
typedef void (*_sig_func_ptr)(int);

library/include/stdio.h

+6-5
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
#include <sys/types.h>
1414
#include <wchar.h>
1515

16-
#include <dos.h>
17-
1816
__BEGIN_DECLS
1917

2018
/* 'End of file' indicator returned by, for example, fgetc() */
@@ -116,9 +114,12 @@ typedef struct __sFILE FILE;
116114
/****************************************************************************/
117115

118116
/* The three standard I/O streams */
119-
#define stdin ((FILE *) __CLIB4->__iob[0])
120-
#define stdout ((FILE *) __CLIB4->__iob[1])
121-
#define stderr ((FILE *) __CLIB4->__iob[2])
117+
extern FILE *__stdin();
118+
extern FILE *__stdout();
119+
extern FILE *__stderr();
120+
#define stdin (__stdin())
121+
#define stdout ( __stdout())
122+
#define stderr (__stderr())
122123

123124
/****************************************************************************/
124125

library/include/sys/cdefs.h

+14-6
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,21 @@
2323
#define __flexarr [0]
2424

2525
#ifdef __cplusplus
26-
#define __BEGIN_DECLS \
27-
extern "C" \
28-
{
29-
#define __END_DECLS }
26+
#ifdef __USE_AMIGAOS_NAMESPACE__
27+
#define __BEGIN_DECLS \
28+
namespace AmigaOS { \
29+
extern "C" \
30+
{
31+
#define __END_DECLS } }
32+
#else
33+
#define __BEGIN_DECLS \
34+
extern "C" \
35+
{
36+
#define __END_DECLS }
37+
#endif
3038
#else
31-
#define __BEGIN_DECLS
32-
#define __END_DECLS
39+
#define __BEGIN_DECLS
40+
#define __END_DECLS
3341
#endif
3442

3543
#ifndef __BOUNDED_POINTERS__

library/include/sys/times.h

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
__BEGIN_DECLS
77

8+
#include <sys/types.h>
9+
810
/* Structure describing CPU time used by a process and its children. */
911
struct tms
1012
{

library/include/unistd.h

-6
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,10 @@
1111
#include <fcntl.h>
1212
#endif /* _FCNTL_H */
1313

14-
#ifndef _STDIO_H
15-
#include <stdio.h>
16-
#endif /* _STDIO_H */
17-
1814
#ifndef _STDINT_H
1915
#include <stdint.h>
2016
#endif /* _STDINT_H */
2117

22-
#include <sys/select.h>
23-
2418
__BEGIN_DECLS
2519

2620
#define STDIN_FILENO 0

library/profile/gmon.c

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <proto/dos.h>
1010
#include <proto/elf.h>
1111
#include <stdio.h>
12+
#include <string.h>
1213
#include <unistd.h>
1314
#include <macros.h>
1415
#include <sys/uio.h>

0 commit comments

Comments
 (0)