bebbo / ixemul Goto Github PK
View Code? Open in Web Editor NEWLicense: GNU General Public License v2.0
License: GNU General Public License v2.0
In WCS I stumbled over fgetc() recently. First I thought WCS had crashed but it is just extremely slow when using fgetc().
The problem happens when an ASCII elevations file should be converted to another format. The ASCII file is read char by char until a number string is complete, then the string is converted using atoi()
I extracted a little example. When compiled with SAS/C it needs about a second to complete on WinUAE (JIT).
When compiled with gcc and noixemul (as of 8.March23) it needs about 100(!) seconds to complete on the same WinUAE.
When I replace fopen(), fgetc() and fclose() by Open(), FGetC() and Close it becomes as fast as the SAS/C version - but I would not really like to change the original code when it is not absolutely necessary.
Is there anything you could do about that? Please find the source and the ASCII data file in attached archive.
/*
sc fgetc_test.c OPTIMIZE LINK
m68k-amigaos-gcc -O2 -Wall -noixemul -c -o fgetc_test_68k.o fgetc_test.c
m68k-amigaos-gcc -noixemul -o fgetc_test_68k fgetc_test_68k.o
gcc -O2 -Wall -o fgetc_test_linux fgetc_test.c
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#ifdef __AMIGA__
#include <exec/types.h>
#else
#define ULONG int
#endif
#define INPUT_ROWS 258
#define INPUT_COLS 258
//#define ADOS_FUNCTIONS // use FGetc() instead of fgetc -> HUGE speed boos in GCC version
#ifdef ADOS_FUNCTIONS
#include <proto/dos.h>
#define fgetc FGetC
#define fopen Open
#define fclose Close
#endif
int main(void)
{
long InputValues, ct;
char InputChar, InValue[64];
short error=0,j;
char * filename="AF_ALPS_Float.txt"; // ASCII data
ULONG TotalSum=0;
time_t StartTime=time(NULL);
#ifdef ADOS_FUNCTIONS
BPTR fAscii;
if ((fAscii = fopen(filename, MODE_OLDFILE)) == 0)
#else
FILE* fAscii;
if ((fAscii = fopen(filename, "r")) == NULL)
#endif
{
error = 2;
printf("Could not open file %s\n",filename);
goto Cleanup;
} /* if open fail */
InputValues = INPUT_ROWS * INPUT_COLS;
for (ct=0; ct<InputValues; ct++)
{
ReadMore:
if ((InputChar = fgetc(fAscii)) == EOF)
{
error = 3;
break;
}
if (InputChar < 45 || InputChar > 57) // AF: < '-' || > '9' i.e. not in "-0123456789"
goto ReadMore;
InValue[0] = InputChar;
j = 0;
while (j < 63 && InValue[j] > 44 && InValue[j] < 58 && InValue[j] != EOF) //AF: > ',' && < ':' i.e. in "-0123456789"
{
j ++;
InValue[j] = fgetc(fAscii);
} /*while */
if (j >= 63) // max 63 characters + final \0
{
error = 3;
break;
}
InValue[j] = '\0';
if((ct%1000)==0){ printf("ct=%ld, InValue=%s \r",ct,InValue); }
TotalSum += (ULONG)(atoi(InValue));
} /* for i=0... */
printf("\n");
printf("Sum of all values is %d\n",TotalSum);
if(TotalSum==60286033)
{
printf("OK\n");
}
else
{
error=3;
printf("Wrong sum!\n");
}
printf("Duration: %u seconds\n",(ULONG)(time(NULL) - StartTime));
Cleanup:
fclose(fAscii);
return error;
}
Their types need to match that of a signal handler, otherwise this call will not compile:
signal(SIGINT, SIG_IGN);
These are declared in ./ixemul/include/sys/signal.h
(in the installed toolchain I can see the definition of SIG_IGN in multiple places:
/home/matze/amigatoolchain/amiga-gcc-out/m68k-amigaos/clib2/include/signal.h:#define SIG_IGN ((void (*)(int))0)
/home/matze/amigatoolchain/amiga-gcc-out/m68k-amigaos/sys-include/sys/signal.h:#define SIG_IGN (__stdargs void (*)(int))1
/home/matze/amigatoolchain/amiga-gcc-out/m68k-amigaos/sys-include/sys/signal.h:#define SIG_IGN (__stdargs void (*)())1
/home/matze/amigatoolchain/amiga-gcc-out/lib/gcc/m68k-amigaos/6.4.1b/include-fixed/sys/signal.h:#define SIG_IGN (void (*)(int))1
/home/matze/amigatoolchain/amiga-gcc-out/lib/gcc/m68k-amigaos/6.4.1b/include-fixed/sys/signal.h:#define SIG_IGN (void (*)(int))1
Hi bebbo! It's me again...
I have been trying to compile to Python 2.4.6 using your amiga-gcc.
After excluding posix and commenting out a single nl_langinfo() in pythonrun.c, I got a Python executable (using the flag -noixemul). However, the file just freezes my amiga when I try it.
Since other Python ports on Aminet use ixemul, I figured that I shouldn't exclude it from the build process. However, in such case I get error messages like:
/home/ant_t/Python-2.4.6/Modules/main.c:471: undefined reference to `isatty'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: /home/ant_t/Python-2.4.6/Modules/main.c:471: undefined reference to `isatty'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: /home/ant_t/Python-2.4.6/Modules/main.c:365: undefined reference to `fstat'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: libpython2.4.a(import.o): in function `load_source_module':
/home/ant_t/Python-2.4.6/Python/import.c:801: undefined reference to `unlink'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: libpython2.4.a(import.o): in function `find_module':
/home/ant_t/Python-2.4.6/Python/import.c:1266: undefined reference to `stat'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: libpython2.4.a(import.o): in function `find_module.constprop.9':
/home/ant_t/Python-2.4.6/Python/import.c:1266: undefined reference to `stat'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: libpython2.4.a(import.o): in function `load_source_module':
/home/ant_t/Python-2.4.6/Python/import.c:802: undefined reference to `open'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: libpython2.4.a(marshal.o): in function `PyMarshal_ReadLastObjectFromFile':
/home/ant_t/Python-2.4.6/Python/marshal.c:748: undefined reference to `fstat'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: libpython2.4.a(pythonrun.o): in function `PyRun_AnyFile':
/home/ant_t/Python-2.4.6/Python/pythonrun.c:1625: undefined reference to `isatty'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: libpython2.4.a(pythonrun.o): in function `PyRun_AnyFileFlags':
/home/ant_t/Python-2.4.6/Python/pythonrun.c:1625: undefined reference to `isatty'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: libpython2.4.a(pythonrun.o): in function `PyRun_AnyFileEx':
/home/ant_t/Python-2.4.6/Python/pythonrun.c:1625: undefined reference to `isatty'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: libpython2.4.a(pythonrun.o): in function `PyRun_AnyFileExFlags':
/home/ant_t/Python-2.4.6/Python/pythonrun.c:1625: undefined reference to `isatty'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: libpython2.4.a(pythonrun.o): in function `Py_FdIsInteractive':
/home/ant_t/Python-2.4.6/Python/pythonrun.c:1625: undefined reference to `isatty'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: libpython2.4.a(pythonrun.o): in function `PyOS_setsig':
/home/ant_t/Python-2.4.6/Python/pythonrun.c:1699: undefined reference to `signal'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: libpython2.4.a(pythonrun.o): in function `PyOS_getsig':
/home/ant_t/Python-2.4.6/Python/pythonrun.c:1679: undefined reference to `signal'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: libpython2.4.a(pythonrun.o): in function `Py_InitializeEx.part.5':
/home/ant_t/Python-2.4.6/Python/pythonrun.c:1699: undefined reference to `signal'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: libpython2.4.a(sysmodule.o): in function `_PySys_Init':
/home/ant_t/Python-2.4.6/Python/sysmodule.c:954: undefined reference to `fstat'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: libpython2.4.a(getpath.o): in function `calculate_path':
/home/ant_t/Python-2.4.6/./Modules/getpath.c:143: undefined reference to `stat'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: /home/ant_t/Python-2.4.6/./Modules/getpath.c:143: undefined reference to `stat'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: /home/ant_t/Python-2.4.6/./Modules/getpath.c:412: undefined reference to `stat'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: /home/ant_t/Python-2.4.6/./Modules/getpath.c:230: undefined reference to `getcwd'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: /home/ant_t/Python-2.4.6/./Modules/getpath.c:230: undefined reference to `getcwd'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: /home/ant_t/Python-2.4.6/./Modules/getpath.c:230: undefined reference to `getcwd'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: libpython2.4.a(pwdmodule.o): in function `pwd_getpwuid':
/home/ant_t/Python-2.4.6/./Modules/pwdmodule.c:109: undefined reference to `getpwuid'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: libpython2.4.a(pwdmodule.o): in function `pwd_getpwnam':
/home/ant_t/Python-2.4.6/./Modules/pwdmodule.c:130: undefined reference to `getpwnam'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: libpython2.4.a(zipimport.o): in function `zipimporter_init':
/home/ant_t/Python-2.4.6/./Modules/zipimport.c:95: undefined reference to `stat'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: libpython2.4.a(fileobject.o): in function `file_read':
/home/ant_t/Python-2.4.6/Objects/fileobject.c:696: undefined reference to `fstat'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: libpython2.4.a(fileobject.o): in function `PyFile_FromFile':
/home/ant_t/Python-2.4.6/Objects/fileobject.c:79: undefined reference to `fstat'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: libpython2.4.a(fileobject.o): in function `open_the_file':
/home/ant_t/Python-2.4.6/Objects/fileobject.c:79: undefined reference to `fstat'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: libpython2.4.a(fileobject.o): in function `file_read':
/home/ant_t/Python-2.4.6/Objects/fileobject.c:696: undefined reference to `fstat'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: libpython2.4.a(fileobject.o): in function `file_isatty':
/home/ant_t/Python-2.4.6/Objects/fileobject.c:672: undefined reference to `isatty'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: libpython2.4.a(bltinmodule.o): in function `builtin_execfile':
/home/ant_t/Python-2.4.6/Python/bltinmodule.c:599: undefined reference to `stat'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: /home/ant_t/Python-2.4.6/Python/bltinmodule.c:599: undefined reference to `stat'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: libpython2.4.a(bltinmodule.o): in function `builtin_raw_input':
/home/ant_t/Python-2.4.6/Python/bltinmodule.c:1613: undefined reference to `isatty'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: libpython2.4.a(getmtime.o): in function `PyOS_GetLastModificationTime':
/home/ant_t/Python-2.4.6/Python/getmtime.c:13: undefined reference to `fstat'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: libpython2.4.a(myreadline.o): in function `PyOS_Readline':
/home/ant_t/Python-2.4.6/Parser/myreadline.c:205: undefined reference to `isatty'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: /home/ant_t/Python-2.4.6/Parser/myreadline.c:205: undefined reference to `isatty'
/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ld: /opt/amiga/m68k-amigaos/lib/libc.a(lib_a-timesr.o): in function `_times_r':
lib_a-timesr.o:(.text+0x8): undefined reference to `_times'
collect2: error: ld returned 1 exit status
make: *** [Makefile:332: python.exe] Error 1
From what I understand, ixemul gives unix like support, which sounds good for compiling Python. But I don't understand this problem with undefined references... Could you enlighten me on what the problem is?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.