Skip to content

Commit

Permalink
Merge pull request #159 from afxgroup/beta10
Browse files Browse the repository at this point in the history
Merhed beta10 into master
  • Loading branch information
afxgroup authored Oct 25, 2023
2 parents f00d201 + 98fef77 commit e9e1a01
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 27 deletions.
27 changes: 22 additions & 5 deletions GNUmakefile.os4
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

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

.PHONY : all all-targets clean version release dpkg
.PHONY : all prepare all-targets all-libs clean \
version compile-tests install release dpkg

# You may have to change the following sets of macro definitions which will
# be used throughout the build makefile. These definitions cover the paths
Expand All @@ -24,7 +25,6 @@
UNAME := $(shell uname)

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

CC := ppc-amigaos-gcc
AR := ppc-amigaos-ar -q
Expand All @@ -33,6 +33,7 @@ RANLIB := ppc-amigaos-ranlib
STRIP := ppc-amigaos-strip
RANLIB := ppc-amigaos-ranlib
HOST_CXX := g++
SDK_INCLUDE ?= $(abspath $(addsuffix ../ppc-amigaos/SDK/include/,$(dir $(shell which $(word 1,$(CC))))))

# On AmigaOS use native commands
ifeq ($(UNAME), AmigaOS)
Expand Down Expand Up @@ -69,7 +70,8 @@ PIC := -fPIC -DPIC
INCLUDES := -I$(LIB_DIR)/include \
-Ilibrary \
-I$(LIB_DIR)/external/include \
-I$(SDK_INCLUDE) \
-I$(SDK_INCLUDE)/include_h \
-I$(SDK_INCLUDE)/netinclude \
-I$(LIB_DIR)/amiga \
-I$(LIB_DIR)/argz \
-I$(LIB_DIR)/ctype \
Expand Down Expand Up @@ -101,7 +103,8 @@ SHARED := $(if $(SHARED),$(SHARED),yes)
STATIC := $(if $(STATIC),$(STATIC),yes)

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

STABS :=
Expand Down Expand Up @@ -158,6 +161,20 @@ prepare:
-$(MAKEDIR) $(BUILD_DIR)/shared
-$(MAKEDIR) $(INSTALL_PREFIX)/lib
-$(MAKEDIR) $(INSTALL_PREFIX)/include
# It may be the case that this makefile is invoked with an explicit CC
# assingment such as: "gcc -B /someDir/". In fact, this pattern is used within
# ADTOOLS - for that reason we take the first word and apply which on that,
# otherwise the extraneous options will cause a failure
$(VERBOSE)which $(word 1,$(CC)); \
if [ $$? -ne 0 ]; \
then \
echo "Could not locate cross compiler: '$(CC)'" 1>&2; \
exit 1; \
elif [ ! -d $(SDK_INCLUDE) ]; \
then \
echo "Could not locate SDK include folder: '$(SDK_INCLUDE)'" 1>&2; \
exit 1 ; \
fi

ALL_TARGETS = \
$(OUTPUT_LIB)/crt0.o \
Expand Down Expand Up @@ -211,7 +228,7 @@ version:
# Shared clib4.library rules

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)/$@.map -nostartfiles -nostdlib
$(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)/$@.map

clib4.library: clib4.library.debug
cp $(BUILD_DIR)/$< $(BUILD_DIR)/$@
Expand Down
6 changes: 3 additions & 3 deletions libc.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,6 @@ C_SOCKET := \
socket/hstrerror.o \
socket/if_indextoname.o \
socket/if_nametoindex.o \
socket/in6addr_any.o \
socket/in6addr_loopback.o \
socket/inet_addr.o \
socket/inet_aton.o \
socket/inet_lnaof.o \
Expand Down Expand Up @@ -960,7 +958,9 @@ C_LIB := \
profile/mcount.o \
shared_library/stubs.o \
unistd/getopt.o \
unistd/getopt_long.o
unistd/getopt_long.o \
socket/in6addr_any.o \
socket/in6addr_loopback.o \

SOURCES_SHARED = $(addprefix $(OUT_SHARED)/, $(C_LIB))
SOURCES_STATIC = $(addprefix $(OUT_STATIC)/, $(C_LIB))
Expand Down
8 changes: 6 additions & 2 deletions library/include/stdarg.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@

__BEGIN_DECLS

#undef _STDARG_H
#include_next "stdarg.h"
typedef __builtin_va_list va_list;

#define va_start(v,l) __builtin_va_start(v,l)
#define va_end(v) __builtin_va_end(v)
#define va_arg(v,l) __builtin_va_arg(v,l)
#define va_copy(d,s) __builtin_va_copy(d,s)

#include <sys/amigaos-va.h>

Expand Down
8 changes: 7 additions & 1 deletion library/include/sys/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,16 @@ struct cmsghdr
(((void *)(cmsg) + (cmsg)->cmsg_len + sizeof(struct cmsghdr) > \
(mhdr)->msg_control + (mhdr)->msg_controllen) ? \
(struct cmsghdr *)NULL : \
(struct cmsghdr *)((void *)(cmsg) + ALIGN((cmsg)->cmsg_len)))
(struct cmsghdr *)((void *)(cmsg) + CMSG_ALIGN((cmsg)->cmsg_len)))

#define CMSG_FIRSTHDR(mhdr) ((struct cmsghdr *)(mhdr)->msg_control)

#define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) \
& (size_t) ~(sizeof (size_t) - 1))
#define CMSG_SPACE(len) (CMSG_ALIGN (len) \
+ CMSG_ALIGN (sizeof (struct cmsghdr)))
#define CMSG_LEN(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len))

/* "Socket"-level control message types: */
#define SCM_RIGHTS 0x01 /* access rights (array of LONG) */

Expand Down
17 changes: 14 additions & 3 deletions library/profile/gmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ void monstartup(uint32 low_pc, uint32 high_pc) {
uint8 *cp;
uint32 lowpc, highpc, text_start;
struct gmonparam *p = &_gmonparam;
int o;

dprintf("in monstartup\n");

Expand Down Expand Up @@ -236,9 +237,19 @@ void monstartup(uint32 low_pc, uint32 high_pc) {
p->tos[0].link = 0;

/* Verify granularity for sampling */
if (p->kcountsize < p->textsize) {
/* FIXME Avoid floating point */
s_scale = ((float) p->kcountsize / p->textsize) * SCALE_1_TO_1;
o = p->highpc - p->lowpc;
if (p->kcountsize < (u_long) o) {
/* avoid floating point operations */
int quot = o / p->kcountsize;

if (quot >= 0x10000)
s_scale = 1;
else if (quot >= 0x100)
s_scale = 0x10000 / quot;
else if (o >= 0x800000)
s_scale = 0x1000000 / (o / (p->kcountsize >> 8));
else
s_scale = 0x1000000 / ((o << 8) / p->kcountsize);
}
else
s_scale = SCALE_1_TO_1;
Expand Down
3 changes: 1 addition & 2 deletions library/socket/freeifaddrs.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
#include <net/if.h>

void
freeifaddrs(struct ifaddrs *ifap)
{
freeifaddrs(struct ifaddrs *ifap) {
struct ifaddrs *c, *n;

c = ifap;
Expand Down
25 changes: 15 additions & 10 deletions library/socket/getifaddrs.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,20 @@ ifaddrs_add(struct ifawrap *ifawrap, char *name, unsigned int flags,

if ((new = malloc(nsize)) == NULL)
return -1; /* let caller free already allocated data */
if (ifawrap->ifaddrs == NULL)

if (ifawrap->ifaddrs == NULL || ifawrap->prev == NULL) {
ifawrap->ifaddrs = new;
else
}
else {
ifawrap->prev->ifa_next = new;
}

ifawrap->prev = new;

new->ifa_next = NULL;

p = (char *) new + nameoff;

strncpy(p, name, namelen - 1);
p[namelen - 1] = '\0';
new->ifa_name = p;
Expand Down Expand Up @@ -112,13 +117,13 @@ getifaddrs(struct ifaddrs **ifap) {

struct List *netiflist = NULL;
struct Node *node = NULL;
struct ifawrap ifawrap;
struct ifawrap _ifawrap, *ifawrap = &_ifawrap;
size_t addrlen;

DECLARE_SOCKETBASE();

memset(&ifawrap, 0, sizeof(struct ifawrap));
memset(ifawrap, 0, sizeof(*ifawrap));

ifawrap.ifaddrs = NULL;
netiflist = ObtainInterfaceList();
if (netiflist != NULL) {
node = GetHead(netiflist);
Expand Down Expand Up @@ -161,9 +166,9 @@ getifaddrs(struct ifaddrs **ifap) {
if (debug == TRUE)
flags |= IFF_DEBUG;

if (ifaddrs_add(&ifawrap, node->ln_Name, flags, &localAddress, (struct sockaddr*) &netmask, &broadcastAddress, NULL, addrlen) == -1) {
if (ifawrap.ifaddrs != NULL) {
freeifaddrs(ifawrap.ifaddrs);
if (ifaddrs_add(ifawrap, node->ln_Name, flags, &localAddress, (struct sockaddr*) &netmask, &broadcastAddress, NULL, addrlen) == -1) {
if (ifawrap->ifaddrs != NULL) {
freeifaddrs(ifawrap->ifaddrs);
success = -1;
break;
}
Expand All @@ -179,8 +184,8 @@ getifaddrs(struct ifaddrs **ifap) {
ReleaseInterfaceList(netiflist);
}

if (success == 0 && ifawrap.ifaddrs != NULL)
*ifap = ifawrap.ifaddrs;
if (success == 0 && ifawrap->ifaddrs != NULL)
*ifap = ifawrap->ifaddrs;

__check_abort();

Expand Down
2 changes: 1 addition & 1 deletion library/socket/socket_headers.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#endif /* _STDLIB_HEADERS_H */

#ifndef _SYSLOG_H
#include <syslog.h>
#include <sys/syslog.h>
#endif

#ifndef _UN_H
Expand Down

0 comments on commit e9e1a01

Please sign in to comment.