diff --git a/GNUmakefile.os4 b/GNUmakefile.os4 index 10317712..206cdfed 100644 --- a/GNUmakefile.os4 +++ b/GNUmakefile.os4 @@ -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 @@ -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 @@ -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) @@ -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 \ @@ -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 := @@ -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 \ @@ -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)/$@ diff --git a/libc.gmk b/libc.gmk index f9dad9da..5f36967c 100755 --- a/libc.gmk +++ b/libc.gmk @@ -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 \ @@ -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)) diff --git a/library/include/stdarg.h b/library/include/stdarg.h index 5afaf7e6..25a540e4 100755 --- a/library/include/stdarg.h +++ b/library/include/stdarg.h @@ -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 diff --git a/library/include/sys/socket.h b/library/include/sys/socket.h index d019fe73..a08c2530 100755 --- a/library/include/sys/socket.h +++ b/library/include/sys/socket.h @@ -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) */ diff --git a/library/profile/gmon.c b/library/profile/gmon.c index 84b2d1ac..db8e9137 100644 --- a/library/profile/gmon.c +++ b/library/profile/gmon.c @@ -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"); @@ -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; diff --git a/library/socket/freeifaddrs.c b/library/socket/freeifaddrs.c index 14599722..541989b3 100644 --- a/library/socket/freeifaddrs.c +++ b/library/socket/freeifaddrs.c @@ -14,8 +14,7 @@ #include void -freeifaddrs(struct ifaddrs *ifap) -{ +freeifaddrs(struct ifaddrs *ifap) { struct ifaddrs *c, *n; c = ifap; diff --git a/library/socket/getifaddrs.c b/library/socket/getifaddrs.c index 7fd5cf69..b3fdab46 100644 --- a/library/socket/getifaddrs.c +++ b/library/socket/getifaddrs.c @@ -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; @@ -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); @@ -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; } @@ -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(); diff --git a/library/socket/socket_headers.h b/library/socket/socket_headers.h index f2f46f76..5eed3d57 100755 --- a/library/socket/socket_headers.h +++ b/library/socket/socket_headers.h @@ -46,7 +46,7 @@ #endif /* _STDLIB_HEADERS_H */ #ifndef _SYSLOG_H -#include +#include #endif #ifndef _UN_H