Skip to content

Commit

Permalink
SPE fixes. Some other fixes for gcc6
Browse files Browse the repository at this point in the history
  • Loading branch information
afxgroup committed Jul 13, 2023
1 parent e5e9b4f commit cf8c530
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 27 deletions.
10 changes: 8 additions & 2 deletions GNUmakefile.os4
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ AFLAGS := -Wa,-mregnames

ifdef SPE
CC := ppc-amigaos-gcc-6.4.0
CFLAGS := $(CFLAGS) -DSPE -mspe -mcpu=8540 -mfloat-gprs=double -mabi=spe -fno-inline-functions -fno-partial-inlining \
-fno-align-functions -fno-align-jumps -fno-align-loops -fno-align-labels -fno-inline-small-functions -fno-indirect-inlining
CFLAGS := $(CFLAGS) -DSPE -D_SOFT_FLOAT -D__SPE__ -mspe -mcpu=8540 -mfloat-gprs=double -mabi=spe -fno-inline-functions -fno-partial-inlining \
-fno-align-functions -fno-align-jumps -fno-align-loops -fno-align-labels -fno-inline-small-functions -fno-indirect-inlining -Wno-unused-but-set-variable -Wno-uninitialized
AFLAGS := $(AFLAGS) -mspe -mcpu=8540 -mfloat-gprs=double
endif

Expand Down Expand Up @@ -295,6 +295,12 @@ $(VERBOSE)echo -e "\rAssembling altivec \033[0;33m[$(@D)]\033[0m \r\t\t\t\t\t\t\
$(VERBOSE)$(CC) -maltivec -mabi=altivec -mvrsave -mregnames -DVRSAVE -o $@ -c $< $(LOG_COMMAND)
endef

define COMPILE_SPE_REG
$(VERBOSE)@$(MAKEDIR) $(@D)
$(VERBOSE)echo -e "\rAssembling with regnames \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) -mvrsave -mregnames -DVRSAVE -mspe -mcpu=8540 -mfloat-gprs=double -o $@ -c $< $(LOG_COMMAND)
endef

define COMPILE_SPE
$(VERBOSE)@$(MAKEDIR) $(@D)
$(VERBOSE)echo -e "\rCompiling SPE \033[0;33m[$(@D)]\033[0m \r\t\t\t\t\t\t\t\t\t\t\t \033[0;31m$(@F)\033[0m"
Expand Down
3 changes: 0 additions & 3 deletions libc.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -954,9 +954,6 @@ OBJ_C_SRC += $(patsubst %.o, $(LIB_DIR)/%.c, $(C_LIBRARY))
$(OUT_STATIC)/c.lib_rev.o : $(LIB_DIR)/c.lib_rev.c $(LIB_DIR)/c.lib_rev.h
$(OUT_SHARED)/c.lib_rev.o : $(LIB_DIR)/c.lib_rev.c $(LIB_DIR)/c.lib_rev.h

$(OUT_STATIC)/cpu/spe/%.o : $(LIB_DIR)/cpu/spe/%.S
$(VERBOSE)$(COMPILE_SPE)

$(OUT_STATIC)/%.o : $(LIB_DIR)/%.sx
$(VERBOSE)$(COMPILE_ALTIVEC_REG)
$(OUT_STATIC)/%.o : $(LIB_DIR)/%.S
Expand Down
2 changes: 1 addition & 1 deletion library/cpu/spe/memcmpE500.S
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
.file "memcmp.S"
.section ".text"
.align 4
#define FUNCTION e500_memcmp
#define FUNCTION __memcmp_e500
.globl FUNCTION
.type FUNCTION,@function
FUNCTION:
Expand Down
3 changes: 3 additions & 0 deletions library/include/dos.h
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,9 @@ struct _clib2 {

BPTR error;
BPTR old_error;

/* termcap */
char tgoto_buf[50];
};

#ifndef __getClib2
Expand Down
2 changes: 1 addition & 1 deletion library/include/fenv.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ fetestexcept(int __excepts) {

__fenv_static inline int
fegetround(void) {
union __fpscr __r;
union __fpscr __r = {0};

__mffs(&__r.__d);
return (__r.__bits.__reg & _ROUND_MASK);
Expand Down
1 change: 1 addition & 0 deletions library/libc_init_global.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ reent_init(struct _clib2 *__clib2) {
/* We use an invalid priority value to indicate "do not change the program's task priority". */
.__priority = 256,
.pipenum = 0,
.tgoto_buf = {0},
#ifdef DISABLE_OPTIMIZED_FUNCTIONS_AT_START
.__optimizedCPUFunctions = FALSE,
#else
Expand Down
34 changes: 20 additions & 14 deletions library/math/fabs.c
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
/*
* $Id: math_fabs.c,v 1.9 2021-01-31 12:04:23 clib2devs Exp $
* $Id: math_fabs.c,v 1.10 2023-07-13 12:04:23 clib2devs Exp $
*/

#ifndef _MATH_HEADERS_H
#include "math_headers.h"
#endif /* _MATH_HEADERS_H */

INLINE STATIC double
__fabs(double x)
{
double res;
inline static double
__fabs(double x) {
#ifndef _SOFT_FLOAT
double res;

__asm volatile("fabs %0, %1"
: "=f"(res)
: "f"(x));
__asm volatile("fabs %0, %1"
: "=f"(res)
: "f"(x));

return res;
return res;
#else
uint32_t high;
GET_HIGH_WORD(high, x);
SET_HIGH_WORD(x, high & 0x7fffffff);

return x;
#endif
}

double
fabs(double x)
{
double result;
fabs(double x) {
double result;

result = __fabs(x);
result = __fabs(x);

return (result);
return (result);
}
4 changes: 2 additions & 2 deletions library/ndbm/hash_buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ __get_buf(HTAB *hashp, uint32_t addr,
BUFHEAD *bp;
uint32_t is_disk_mask;
int is_disk, segment_ndx;
SEGMENT segp;
SEGMENT segp = NULL;

is_disk = 0;
is_disk_mask = 0;
Expand Down Expand Up @@ -92,7 +92,7 @@ __get_buf(HTAB *hashp, uint32_t addr,
if (!bp ||
__get_page(hashp, bp->page, addr, !prev_bp, is_disk, 0))
return (NULL);
if (!prev_bp)
if (!prev_bp && segp != NULL)
segp[segment_ndx] =
(BUFHEAD *) ((ptrdiff_t) bp | is_disk_mask);
} else {
Expand Down
3 changes: 2 additions & 1 deletion library/stat/utimensat.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ int utimensat(int fd, const char *path, const struct timespec times[2], int flag
* Changing symlink time or regular file will always change both files
*/
if (isLink && FLAG_IS_SET(flags, AT_SYMLINK_FOLLOW)) {
struct DevProc *dvp = GetDeviceProc(buffer, dvp);
struct DevProc *dvp = NULL;
dvp = GetDeviceProc(buffer, dvp);
if (dvp == NULL) {
free(buffer);
goto out;
Expand Down
4 changes: 1 addition & 3 deletions library/termcap/tparam.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ tparam(const char *string, char *outstring, int len, int arg0, int arg1, int arg
return tparam1(string, outstring, len, NULL, NULL, arg);
}

static char tgoto_buf[50] = {0};

char *
tgoto(const char *string, int hpos, int vpos) {
int args[2];
Expand All @@ -84,7 +82,7 @@ tgoto(const char *string, int hpos, int vpos) {

args[0] = vpos;
args[1] = hpos;
return tparam1(string, tgoto_buf, 50, __clib2->__UP, __clib2->__BC, args);
return tparam1(string, __clib2->tgoto_buf, 50, __clib2->__UP, __clib2->__BC, args);
}

static char *
Expand Down
3 changes: 3 additions & 0 deletions shared.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ $(OUT_SHARED_LIB)/%.o : $(LIB_DIR)/%.sx
$(OUT_SHARED_LIB)/cpu/generic/%.o : $(LIB_DIR)/cpu/generic/%.S
$(VERBOSE)$(COMPILE_REG)

$(OUT_SHARED_LIB)/cpu/spe/%.o : $(LIB_DIR)/cpu/spe/%.S
$(VERBOSE)$(COMPILE_SPE_REG)

$(OUT_SHARED_LIB)/%.o : $(LIB_DIR)/%.S
$(VERBOSE)$(COMPILE_ASM)

Expand Down

0 comments on commit cf8c530

Please sign in to comment.