├── .gitignore ├── sources ├── stubs │ ├── libbases │ │ ├── .keepme │ │ ├── asl.c │ │ ├── dos.c │ │ ├── icon.c │ │ ├── bullet.c │ │ ├── graphics.c │ │ ├── keymap.c │ │ ├── layers.c │ │ ├── locale.c │ │ ├── mathffp.c │ │ ├── commodities.c │ │ ├── nonvolatile.c │ │ ├── utility.c │ │ ├── diskfont.c │ │ ├── gadtools.c │ │ ├── iffparse.c │ │ ├── lowlevel.c │ │ ├── realtime.c │ │ ├── datatypes.c │ │ ├── expansion.c │ │ ├── intuition.c │ │ ├── mathtrans.c │ │ ├── rexxsyslib.c │ │ ├── workbench.c │ │ ├── amigaguide.c │ │ ├── translator.c │ │ ├── mathieeedoubbas.c │ │ ├── mathieeesingbas.c │ │ ├── mathieeedoubtrans.c │ │ └── mathieeesingtrans.c │ ├── libnames │ │ ├── .keepme │ │ ├── asl.c │ │ ├── dos.c │ │ ├── icon.c │ │ ├── bullet.c │ │ ├── keymap.c │ │ ├── layers.c │ │ ├── locale.c │ │ ├── mathffp.c │ │ ├── utility.c │ │ ├── datatypes.c │ │ ├── diskfont.c │ │ ├── expansion.c │ │ ├── gadtools.c │ │ ├── graphics.c │ │ ├── iffparse.c │ │ ├── intuition.c │ │ ├── lowlevel.c │ │ ├── mathtrans.c │ │ ├── realtime.c │ │ ├── workbench.c │ │ ├── amigaguide.c │ │ ├── commodities.c │ │ ├── nonvolatile.c │ │ ├── rexxsyslib.c │ │ ├── translator.c │ │ ├── mathieeedoubbas.c │ │ ├── mathieeesingbas.c │ │ ├── mathieeedoubtrans.c │ │ └── mathieeesingtrans.c │ ├── stubs │ │ ├── __priority.c │ │ ├── __stack.c │ │ ├── __ctor_list__.c │ │ ├── __dtor_list__.c │ │ ├── __exit_list__.c │ │ ├── __init_list__.c │ │ ├── __lib_list__.c │ │ ├── __procname.c │ │ └── __oslibversion.c │ ├── misc │ │ ├── __DOSBase.c │ │ ├── __UtilityBase.c │ │ ├── __MathIeeeDoubBasBase.c │ │ ├── __MathIeeeSingBasBase.c │ │ ├── __flush_cache.c │ │ ├── __MathIeeeDoubTransBase.c │ │ ├── __MathIeeeSingTransBase.c │ │ ├── __initcpp.c │ │ ├── __cpucheck.c │ │ └── __initlibraries.c │ ├── library.list │ └── Makefile.in ├── nix │ ├── errno │ │ └── errno.c │ ├── stdlib │ │ ├── abs.c │ │ ├── labs.c │ │ ├── _MSTEP.c │ │ ├── atoi.c │ │ ├── atol.c │ │ ├── rand.c │ │ ├── abort.c │ │ ├── calloc.c │ │ ├── realloc.c │ │ ├── system.c │ │ ├── getenv.c │ │ ├── bsearch.c │ │ ├── strtol.c │ │ ├── atexit.c │ │ ├── putenv.c │ │ ├── free.c │ │ └── strtoul.c │ ├── extra │ │ ├── bcmp.c │ │ ├── rmdir.c │ │ ├── unlink.c │ │ ├── getppid.c │ │ ├── setlinebuf.c │ │ ├── getpid.c │ │ ├── getwd.c │ │ ├── stpcpy.c │ │ ├── creat.c │ │ ├── setbuffer.c │ │ ├── timer.c │ │ ├── strdup.c │ │ ├── putw.c │ │ ├── sleep.c │ │ ├── strlower.c │ │ ├── strupper.c │ │ ├── getw.c │ │ ├── usleep.c │ │ ├── utime.c │ │ ├── fdtofh.c │ │ ├── mkdir.c │ │ ├── truncate.c │ │ ├── getcwd.c │ │ ├── access.c │ │ ├── mktemp.c │ │ ├── chdir.c │ │ ├── readlink.c │ │ ├── gettimeofday.c │ │ ├── times.c │ │ ├── chmod.c │ │ ├── stat.c │ │ ├── utimes.c │ │ ├── getrusage.c │ │ ├── __stat.c │ │ ├── dotimer.c │ │ └── fstat.c │ ├── locale │ │ ├── __decimalpoint.c │ │ ├── __lconv.c │ │ ├── localeconv.c │ │ └── __localevec.c │ ├── stdio │ │ ├── fileno.c │ │ ├── fgetc.c │ │ ├── fputc.c │ │ ├── rewind.c │ │ ├── clearerr.c │ │ ├── fgetpos.c │ │ ├── feof.c │ │ ├── fsetpos.c │ │ ├── ferror.c │ │ ├── setbuf.c │ │ ├── vprintf.c │ │ ├── vscanf.c │ │ ├── fputs.c │ │ ├── puts.c │ │ ├── putchar.c │ │ ├── printf.c │ │ ├── scanf.c │ │ ├── sprintf.c │ │ ├── fscanf.c │ │ ├── sscanf.c │ │ ├── fprintf.c │ │ ├── snprintf.c │ │ ├── wctomb.c │ │ ├── perror.c │ │ ├── gets.c │ │ ├── mbtowc.c │ │ ├── fgets.c │ │ ├── mblen.c │ │ ├── mbstowcs.c │ │ ├── wcstombs.c │ │ ├── vsscanf.c │ │ ├── vsprintf.c │ │ ├── remove.c │ │ ├── fflush.c │ │ ├── vsnprintf.c │ │ ├── ftell.c │ │ ├── tmpfile.c │ │ ├── tmpnam.c │ │ ├── __stdio.c │ │ ├── fseek.c │ │ ├── fread.c │ │ ├── fwrite.c │ │ ├── __fflush.c │ │ ├── setvbuf.c │ │ ├── rename.c │ │ ├── ungetc.c │ │ ├── fdopen.c │ │ ├── __swbuf.c │ │ └── __srget.c │ ├── ctype │ │ ├── isalnum.c │ │ ├── isalpha.c │ │ ├── iscntrl.c │ │ ├── isdigit.c │ │ ├── isgraph.c │ │ ├── islower.c │ │ ├── ispunct.c │ │ ├── isspace.c │ │ ├── isupper.c │ │ ├── isprint.c │ │ ├── isxdigit.c │ │ ├── tolower.c │ │ ├── toupper.c │ │ └── _ctype_.c │ ├── time │ │ ├── difftime.c │ │ ├── __gmtoffset.c │ │ ├── localtime.c │ │ ├── asctime.c │ │ ├── clock.c │ │ ├── time.c │ │ └── mktime.c │ ├── math │ │ ├── __negsf2.c │ │ ├── __negdf2.c │ │ ├── __addsf3.c │ │ ├── __divsf3.c │ │ ├── __fixdfsi.c │ │ ├── __fixsfsi.c │ │ ├── __mulsf3.c │ │ ├── __subsf3.c │ │ ├── __adddf3.c │ │ ├── __divdf3.c │ │ ├── __extendsfdf2.c │ │ ├── __floatsidf.c │ │ ├── __floatsisf.c │ │ ├── __muldf3.c │ │ ├── __subdf3.c │ │ ├── __truncdfsf2.c │ │ ├── __fixunsdfsi.c │ │ ├── __fixunssfsi.c │ │ ├── __eqsf2.c │ │ └── __eqdf2.c │ ├── signal │ │ ├── __signalfunc.c │ │ ├── __chkabort.c │ │ ├── signal.c │ │ └── raise.c │ ├── string │ │ ├── strlen.c │ │ ├── memcpy.c │ │ ├── memmove.c │ │ ├── strcmp.c │ │ ├── strchr.c │ │ ├── memcmp.c │ │ ├── strrchr.c │ │ ├── memchr.c │ │ ├── strncmp.c │ │ ├── strcspn.c │ │ ├── strstr.c │ │ ├── strtok.c │ │ ├── strspn.c │ │ ├── strpbrk.c │ │ ├── strxfrm.c │ │ ├── strcoll.c │ │ ├── strcpy.c │ │ ├── strcat.c │ │ ├── strncpy.c │ │ ├── strncat.c │ │ └── memset.c │ ├── assert │ │ └── __eprintf.c │ ├── setjmp │ │ ├── setjmp.c │ │ └── longjmp.c │ ├── misc │ │ ├── __request.c │ │ └── bzero.c │ └── Makefile.in ├── socket │ ├── extra │ │ ├── fdtofh.c │ │ ├── fstat.c │ │ ├── dup.c │ │ └── strsep.c │ ├── netdb │ │ ├── herrno.c │ │ ├── getnetbyname.c │ │ ├── gethostbyname.c │ │ ├── getnetbyaddr.c │ │ ├── getprotobyname.c │ │ ├── getprotobynumber.c │ │ ├── getservbyport.c │ │ ├── getservbyname.c │ │ ├── gethostbyaddr.c │ │ ├── gethostent.c │ │ └── herror.c │ ├── socket │ │ ├── __initsock.c │ │ ├── socketpair.c │ │ ├── obtain_socket.c │ │ ├── shutdown.c │ │ ├── recv.c │ │ ├── recvmsg.c │ │ ├── send.c │ │ ├── sendmsg.c │ │ ├── getpeername.c │ │ ├── getsockname.c │ │ ├── getsockopt.c │ │ ├── listen.c │ │ ├── recfrom.c │ │ ├── setsockopt.c │ │ ├── connect.c │ │ ├── sendto.c │ │ ├── release_socket.c │ │ ├── bind.c │ │ ├── accept.c │ │ └── socket.c │ ├── ft.c │ └── unistd │ │ ├── crypt.c │ │ ├── gethostid.c │ │ ├── getdomainname.c │ │ └── gethostname.c ├── stack │ ├── stk_argbytes.c │ ├── stk_minframe.c │ ├── stk_safezone.c │ ├── stkovf.c │ ├── xcovf.c │ ├── stkchk_d0.c │ ├── link_a5_0_f.c │ ├── longjmp.c │ ├── sub_d0_sp.c │ ├── link_a5_d0_f.c │ ├── stkrst_f.c │ ├── Makefile.in │ └── init_stk.c ├── amiga │ └── misc │ │ ├── DeleteTask.c │ │ ├── WaitBeam.c │ │ ├── DoPktn.c │ │ ├── LibAllocPooled.c │ │ ├── LibFreePooled.c │ │ ├── AbsExecBase.c │ │ ├── NewList.c │ │ ├── DoPktn.s │ │ ├── LibCreatePool.c │ │ ├── sprintf.c │ │ ├── BeginIO.c │ │ ├── FreeIEvents.c │ │ ├── FastRand.c │ │ ├── RangeRand.c │ │ ├── CallHook.c │ │ ├── DoMethod.c │ │ ├── HookEntry.c │ │ ├── HotKey.c │ │ ├── SetSuperAttrs.c │ │ ├── CoerceMethod.c │ │ ├── DoSuperMethod.c │ │ ├── AddTOF.c │ │ ├── AsmFreePooled.c │ │ ├── CreateIO.c │ │ ├── Cia.c │ │ ├── CreatePort.c │ │ ├── AsmCreatePool.c │ │ └── TimeDelay.c ├── startup │ ├── ncrt0.S │ ├── nrcrt0.S │ ├── nlrcrt0.S │ └── Makefile.in ├── nix_main │ ├── _main.c │ ├── Makefile.in │ └── __nocommandline.c ├── math │ ├── trans │ │ ├── acos.c │ │ ├── asin.c │ │ ├── atan.c │ │ ├── ceil.c │ │ ├── cos.c │ │ ├── cosh.c │ │ ├── exp.c │ │ ├── fabs.c │ │ ├── floor.c │ │ ├── log.c │ │ ├── sin.c │ │ ├── sinh.c │ │ ├── sqrt.c │ │ ├── tan.c │ │ ├── tanh.c │ │ ├── log10.c │ │ ├── pow.c │ │ ├── fmod.c │ │ └── atan2.c │ ├── stdlib │ │ ├── atof.c │ │ └── strtod.c │ ├── stdio │ │ ├── isinf.c │ │ └── isnan.c │ └── extra │ │ ├── modf.c │ │ ├── frexp.c │ │ └── ldexp.c ├── nixmain │ ├── __stdiowin.c │ └── Makefile.in ├── nix20 │ ├── math │ │ ├── __mulsi3.c │ │ ├── __udivsi3.c │ │ └── __divsi3.c │ ├── extra │ │ ├── stricmp.c │ │ └── strnicmp.c │ └── Makefile.in ├── headers │ ├── rand48.h │ ├── debuglib.h │ ├── dirent.h │ ├── bases.h │ ├── select.h │ ├── pool.h │ └── regparm.h ├── nix13 │ ├── math │ │ ├── __mulsi3.c │ │ ├── __divsi3.c │ │ └── __udivsi3.c │ ├── extra │ │ ├── stricmp.c │ │ └── strnicmp.c │ └── Makefile.in └── misc │ └── Makefile.in ├── libnix.texi ├── examples ├── helloworld.c └── Makefile.in ├── mkinstalldirs ├── configure.in ├── README.md ├── README.BETA └── Product-Info /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /sources/stubs/libbases/.keepme: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sources/stubs/libnames/.keepme: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sources/nix/errno/errno.c: -------------------------------------------------------------------------------- 1 | int errno=0; 2 | -------------------------------------------------------------------------------- /sources/stubs/stubs/__priority.c: -------------------------------------------------------------------------------- 1 | long __priority=0; 2 | -------------------------------------------------------------------------------- /sources/stubs/stubs/__stack.c: -------------------------------------------------------------------------------- 1 | unsigned long __stack=4000; 2 | -------------------------------------------------------------------------------- /sources/socket/extra/fdtofh.c: -------------------------------------------------------------------------------- 1 | #include "../nix/extra/fdtofh.c" 2 | -------------------------------------------------------------------------------- /sources/stack/stk_argbytes.c: -------------------------------------------------------------------------------- 1 | unsigned long __stk_argbytes=256; 2 | -------------------------------------------------------------------------------- /sources/stack/stk_minframe.c: -------------------------------------------------------------------------------- 1 | unsigned long __stk_minframe=32768; 2 | -------------------------------------------------------------------------------- /sources/stack/stk_safezone.c: -------------------------------------------------------------------------------- 1 | unsigned long __stk_safezone=2048; 2 | -------------------------------------------------------------------------------- /libnix.texi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adtools/libnix/HEAD/libnix.texi -------------------------------------------------------------------------------- /sources/nix/stdlib/abs.c: -------------------------------------------------------------------------------- 1 | int abs(int j) 2 | { return j>=0?j:-j; } 3 | -------------------------------------------------------------------------------- /sources/nix/stdlib/labs.c: -------------------------------------------------------------------------------- 1 | long labs(long j) 2 | { return j>=0?j:-j; } 3 | -------------------------------------------------------------------------------- /sources/stubs/stubs/__ctor_list__.c: -------------------------------------------------------------------------------- 1 | void *__CTOR_LIST__[2]={ 0,0 }; 2 | -------------------------------------------------------------------------------- /sources/stubs/stubs/__dtor_list__.c: -------------------------------------------------------------------------------- 1 | void *__DTOR_LIST__[2]={ 0,0 }; 2 | -------------------------------------------------------------------------------- /sources/stubs/stubs/__exit_list__.c: -------------------------------------------------------------------------------- 1 | void *__EXIT_LIST__[2]={ 0,0 }; 2 | -------------------------------------------------------------------------------- /sources/stubs/stubs/__init_list__.c: -------------------------------------------------------------------------------- 1 | void *__INIT_LIST__[2]={ 0,0 }; 2 | -------------------------------------------------------------------------------- /sources/stubs/stubs/__lib_list__.c: -------------------------------------------------------------------------------- 1 | void *__LIB_LIST__[2]={ 0,0 }; 2 | -------------------------------------------------------------------------------- /sources/nix/extra/bcmp.c: -------------------------------------------------------------------------------- 1 | #include "stabs.h" 2 | 3 | ALIAS(bcmp,memcmp); 4 | -------------------------------------------------------------------------------- /sources/nix/extra/rmdir.c: -------------------------------------------------------------------------------- 1 | #include "stabs.h" 2 | 3 | ALIAS(rmdir,remove); 4 | -------------------------------------------------------------------------------- /sources/nix/locale/__decimalpoint.c: -------------------------------------------------------------------------------- 1 | unsigned char *__decimalpoint="."; 2 | -------------------------------------------------------------------------------- /sources/stubs/stubs/__procname.c: -------------------------------------------------------------------------------- 1 | char *__procname="Background process"; 2 | -------------------------------------------------------------------------------- /sources/nix/extra/unlink.c: -------------------------------------------------------------------------------- 1 | #include "stabs.h" 2 | 3 | ALIAS(unlink,remove); 4 | -------------------------------------------------------------------------------- /sources/nix/locale/__lconv.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | struct lconv __lconv; 4 | -------------------------------------------------------------------------------- /sources/socket/netdb/herrno.c: -------------------------------------------------------------------------------- 1 | int h_errno = 0; 2 | int network_installed = 0; 3 | -------------------------------------------------------------------------------- /sources/amiga/misc/DeleteTask.c: -------------------------------------------------------------------------------- 1 | #include "stabs.h" 2 | 3 | ALIAS(DeleteTask,RemTask); 4 | -------------------------------------------------------------------------------- /sources/stubs/stubs/__oslibversion.c: -------------------------------------------------------------------------------- 1 | #include 2 | ULONG __oslibversion=37; 3 | -------------------------------------------------------------------------------- /sources/startup/ncrt0.S: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adtools/libnix/HEAD/sources/startup/ncrt0.S -------------------------------------------------------------------------------- /sources/startup/nrcrt0.S: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adtools/libnix/HEAD/sources/startup/nrcrt0.S -------------------------------------------------------------------------------- /sources/startup/nlrcrt0.S: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adtools/libnix/HEAD/sources/startup/nlrcrt0.S -------------------------------------------------------------------------------- /sources/nix/stdio/fileno.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int fileno(FILE *file) 4 | { return file->file; } 5 | -------------------------------------------------------------------------------- /sources/nix/stdlib/_MSTEP.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adtools/libnix/HEAD/sources/nix/stdlib/_MSTEP.c -------------------------------------------------------------------------------- /sources/nix/ctype/isalnum.c: -------------------------------------------------------------------------------- 1 | extern char *_ctype_; 2 | 3 | int isalnum(int c) 4 | { return _ctype_[1+c]&7; } 5 | -------------------------------------------------------------------------------- /sources/nix/ctype/isalpha.c: -------------------------------------------------------------------------------- 1 | extern char *_ctype_; 2 | 3 | int isalpha(int c) 4 | { return _ctype_[1+c]&3; } 5 | -------------------------------------------------------------------------------- /sources/nix/ctype/iscntrl.c: -------------------------------------------------------------------------------- 1 | extern char *_ctype_; 2 | 3 | int iscntrl(int c) 4 | { return _ctype_[1+c]&32; } 5 | -------------------------------------------------------------------------------- /sources/nix/ctype/isdigit.c: -------------------------------------------------------------------------------- 1 | extern char *_ctype_; 2 | 3 | int isdigit(int c) 4 | { return _ctype_[1+c]&4; } 5 | -------------------------------------------------------------------------------- /sources/nix/ctype/isgraph.c: -------------------------------------------------------------------------------- 1 | extern char *_ctype_; 2 | 3 | int isgraph(int c) 4 | { return _ctype_[1+c]&23; } 5 | -------------------------------------------------------------------------------- /sources/nix/ctype/islower.c: -------------------------------------------------------------------------------- 1 | extern char *_ctype_; 2 | 3 | int islower(int c) 4 | { return _ctype_[1+c]&2; } 5 | -------------------------------------------------------------------------------- /sources/nix/ctype/ispunct.c: -------------------------------------------------------------------------------- 1 | extern char *_ctype_; 2 | 3 | int ispunct(int c) 4 | { return _ctype_[1+c]&16; } 5 | -------------------------------------------------------------------------------- /sources/nix/ctype/isspace.c: -------------------------------------------------------------------------------- 1 | extern char *_ctype_; 2 | 3 | int isspace(int c) 4 | { return _ctype_[1+c]&8; } 5 | -------------------------------------------------------------------------------- /sources/nix/ctype/isupper.c: -------------------------------------------------------------------------------- 1 | extern char *_ctype_; 2 | 3 | int isupper(int c) 4 | { return _ctype_[1+c]&1; } 5 | -------------------------------------------------------------------------------- /sources/nix/stdio/fgetc.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int fgetc(FILE *stream) 4 | { return getc(stream); } 5 | -------------------------------------------------------------------------------- /sources/nix/time/difftime.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double difftime(time_t a,time_t b) 4 | { return a-b; } 5 | -------------------------------------------------------------------------------- /sources/nix_main/_main.c: -------------------------------------------------------------------------------- 1 | #include "stabs.h" 2 | 3 | /* main is now called _main! */ 4 | ALIAS(main,_main); 5 | -------------------------------------------------------------------------------- /sources/nix/ctype/isprint.c: -------------------------------------------------------------------------------- 1 | extern char *_ctype_; 2 | 3 | int isprint(int c) 4 | { return _ctype_[1+c]&151; } 5 | -------------------------------------------------------------------------------- /sources/nix/ctype/isxdigit.c: -------------------------------------------------------------------------------- 1 | extern char *_ctype_; 2 | 3 | int isxdigit(int c) 4 | { return _ctype_[1+c]&68; } 5 | -------------------------------------------------------------------------------- /sources/nix/stdio/fputc.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int fputc(int c,FILE *stream) 4 | { return putc(c,stream); } 5 | -------------------------------------------------------------------------------- /sources/nix/stdio/rewind.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void rewind(FILE *stream) 4 | { fseek(stream,0,SEEK_SET); } 5 | -------------------------------------------------------------------------------- /sources/socket/socket/__initsock.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adtools/libnix/HEAD/sources/socket/socket/__initsock.c -------------------------------------------------------------------------------- /sources/stubs/libnames/asl.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | char __aslname[]="asl.library"; 3 | -------------------------------------------------------------------------------- /sources/stubs/libnames/dos.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | char __dosname[]="dos.library"; 3 | -------------------------------------------------------------------------------- /sources/stubs/libnames/icon.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | char __iconname[]="icon.library"; 3 | -------------------------------------------------------------------------------- /sources/nix/extra/getppid.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | pid_t getppid(void) 4 | { 5 | return 1; /* init ;-) */ 6 | } 7 | -------------------------------------------------------------------------------- /sources/stubs/libnames/bullet.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | char __bulletname[]="bullet.library"; 3 | -------------------------------------------------------------------------------- /sources/stubs/libnames/keymap.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | char __keymapname[]="keymap.library"; 3 | -------------------------------------------------------------------------------- /sources/stubs/libnames/layers.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | char __layersname[]="layers.library"; 3 | -------------------------------------------------------------------------------- /sources/stubs/libnames/locale.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | char __localename[]="locale.library"; 3 | -------------------------------------------------------------------------------- /sources/math/trans/acos.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double acos(double x) 4 | { return IEEEDPAcos(x); } 5 | -------------------------------------------------------------------------------- /sources/math/trans/asin.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double asin(double x) 4 | { return IEEEDPAsin(x); } 5 | -------------------------------------------------------------------------------- /sources/math/trans/atan.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double atan(double x) 4 | { return IEEEDPAtan(x); } 5 | -------------------------------------------------------------------------------- /sources/math/trans/ceil.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double ceil(double x) 4 | { return IEEEDPCeil(x); } 5 | -------------------------------------------------------------------------------- /sources/math/trans/cos.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double cos(double x) 4 | { return IEEEDPCos(x); } 5 | -------------------------------------------------------------------------------- /sources/math/trans/cosh.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double cosh(double x) 4 | { return IEEEDPCosh(x); } 5 | -------------------------------------------------------------------------------- /sources/math/trans/exp.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double exp(double x) 4 | { return IEEEDPExp(x); } 5 | -------------------------------------------------------------------------------- /sources/math/trans/fabs.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double fabs(double x) 4 | { return IEEEDPAbs(x); } 5 | -------------------------------------------------------------------------------- /sources/math/trans/floor.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double floor(double x) 4 | { return IEEEDPFloor(x); } 5 | -------------------------------------------------------------------------------- /sources/math/trans/log.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double log(double x) 4 | { return IEEEDPLog(x); } 5 | -------------------------------------------------------------------------------- /sources/math/trans/sin.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double sin(double x) 4 | { return IEEEDPSin(x); } 5 | -------------------------------------------------------------------------------- /sources/math/trans/sinh.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double sinh(double x) 4 | { return IEEEDPSinh(x); } 5 | -------------------------------------------------------------------------------- /sources/math/trans/sqrt.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double sqrt(double x) 4 | { return IEEEDPSqrt(x); } 5 | -------------------------------------------------------------------------------- /sources/math/trans/tan.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double tan(double x) 4 | { return IEEEDPTan(x); } 5 | -------------------------------------------------------------------------------- /sources/math/trans/tanh.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double tanh(double x) 4 | { return IEEEDPTanh(x); } 5 | -------------------------------------------------------------------------------- /sources/nix/ctype/tolower.c: -------------------------------------------------------------------------------- 1 | extern char *_ctype_; 2 | 3 | int tolower(int c) 4 | { return _ctype_[1+c]&1?c+'a'-'A':c; } 5 | -------------------------------------------------------------------------------- /sources/nix/ctype/toupper.c: -------------------------------------------------------------------------------- 1 | extern char *_ctype_; 2 | 3 | int toupper(int c) 4 | { return _ctype_[1+c]&2?c+'A'-'a':c; } 5 | -------------------------------------------------------------------------------- /sources/nix/math/__negsf2.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | float __negsf2(float x) 4 | { return IEEESPNeg(x); } 5 | -------------------------------------------------------------------------------- /sources/stubs/libnames/mathffp.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | char __mathffpname[]="mathffp.library"; 3 | -------------------------------------------------------------------------------- /sources/stubs/libnames/utility.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | char __utilityname[]="utility.library"; 3 | -------------------------------------------------------------------------------- /sources/math/trans/log10.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double log10(double x) 4 | { return IEEEDPLog10(x); } 5 | -------------------------------------------------------------------------------- /sources/nix/math/__negdf2.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double __negdf2(double x) 4 | { return IEEEDPNeg(x); } 5 | -------------------------------------------------------------------------------- /sources/nix/stdio/clearerr.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void clearerr(FILE *stream) 4 | { stream->flags&=~(__SERR|__SEOF); } 5 | -------------------------------------------------------------------------------- /sources/nixmain/__stdiowin.c: -------------------------------------------------------------------------------- 1 | /* Replace this with your own if you want */ 2 | 3 | char __stdiowin[]="CON://///AUTO/CLOSE/WAIT"; 4 | -------------------------------------------------------------------------------- /sources/stubs/libnames/datatypes.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | char __datatypesname[]="datatypes.library"; 3 | -------------------------------------------------------------------------------- /sources/stubs/libnames/diskfont.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | char __diskfontname[]="diskfont.library"; 3 | -------------------------------------------------------------------------------- /sources/stubs/libnames/expansion.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | char __expansionname[]="expansion.library"; 3 | -------------------------------------------------------------------------------- /sources/stubs/libnames/gadtools.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | char __gadtoolsname[]="gadtools.library"; 3 | -------------------------------------------------------------------------------- /sources/stubs/libnames/graphics.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | char __graphicsname[]="graphics.library"; 3 | -------------------------------------------------------------------------------- /sources/stubs/libnames/iffparse.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | char __iffparsename[]="iffparse.library"; 3 | -------------------------------------------------------------------------------- /sources/stubs/libnames/intuition.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | char __intuitionname[]="intuition.library"; 3 | -------------------------------------------------------------------------------- /sources/stubs/libnames/lowlevel.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | char __lowlevelname[]="lowlevel.library"; 3 | -------------------------------------------------------------------------------- /sources/stubs/libnames/mathtrans.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | char __mathtransname[]="mathtrans.library"; 3 | -------------------------------------------------------------------------------- /sources/stubs/libnames/realtime.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | char __realtimename[]="realtime.library"; 3 | -------------------------------------------------------------------------------- /sources/stubs/libnames/workbench.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | char __workbenchname[]="workbench.library"; 3 | -------------------------------------------------------------------------------- /sources/math/trans/pow.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double pow(double x,double y) 4 | { return IEEEDPPow(y,x); } 5 | -------------------------------------------------------------------------------- /sources/nix/extra/setlinebuf.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int setlinebuf(FILE *stream) 4 | { return setvbuf(stream,NULL,_IOLBF,0); } 5 | -------------------------------------------------------------------------------- /sources/nix/math/__addsf3.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | float __addsf3(float x,float y) 4 | { return IEEESPAdd(x,y); } 5 | -------------------------------------------------------------------------------- /sources/nix/math/__divsf3.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | float __divsf3(float x,float y) 4 | { return IEEESPDiv(x,y); } 5 | -------------------------------------------------------------------------------- /sources/nix/math/__fixdfsi.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | signed long __fixdfsi(double x) 4 | { return IEEEDPFix(x); } 5 | -------------------------------------------------------------------------------- /sources/nix/math/__fixsfsi.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | signed long __fixsfsi(float x) 4 | { return IEEESPFix(x); } 5 | -------------------------------------------------------------------------------- /sources/nix/math/__mulsf3.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | float __mulsf3(float x,float y) 4 | { return IEEESPMul(x,y); } 5 | -------------------------------------------------------------------------------- /sources/nix/math/__subsf3.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | float __subsf3(float x,float y) 4 | { return IEEESPSub(x,y); } 5 | -------------------------------------------------------------------------------- /sources/nix/stdio/fgetpos.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int fgetpos(FILE *stream,fpos_t *pos) 4 | { *pos=ftell(stream); return 0; } 5 | -------------------------------------------------------------------------------- /sources/stubs/libnames/amigaguide.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | char __amigaguidename[]="amigaguide.library"; 3 | -------------------------------------------------------------------------------- /sources/stubs/libnames/commodities.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | char __commoditiesname[]="commodities.library"; 3 | -------------------------------------------------------------------------------- /sources/stubs/libnames/nonvolatile.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | char __nonvolatilename[]="nonvolatile.library"; 3 | -------------------------------------------------------------------------------- /sources/stubs/libnames/rexxsyslib.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | char __rexxsyslibname[]="rexxsyslib.library"; 3 | -------------------------------------------------------------------------------- /sources/stubs/libnames/translator.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | char __translatorname[]="translator.library"; 3 | -------------------------------------------------------------------------------- /sources/nix/math/__adddf3.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double __adddf3(double x,double y) 4 | { return IEEEDPAdd(x,y); } 5 | -------------------------------------------------------------------------------- /sources/nix/math/__divdf3.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double __divdf3(double x,double y) 4 | { return IEEEDPDiv(x,y); } 5 | -------------------------------------------------------------------------------- /sources/nix/math/__extendsfdf2.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double __extendsfdf2(float x) 4 | { return IEEEDPFieee(x); } 5 | -------------------------------------------------------------------------------- /sources/nix/math/__floatsidf.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double __floatsidf(signed long x) 4 | { return IEEEDPFlt(x); } 5 | -------------------------------------------------------------------------------- /sources/nix/math/__floatsisf.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | float __floatsisf(signed long x) 4 | { return IEEESPFlt(x); } 5 | -------------------------------------------------------------------------------- /sources/nix/math/__muldf3.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double __muldf3(double x,double y) 4 | { return IEEEDPMul(x,y); } 5 | -------------------------------------------------------------------------------- /sources/nix/math/__subdf3.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double __subdf3(double x,double y) 4 | { return IEEEDPSub(x,y); } 5 | -------------------------------------------------------------------------------- /sources/nix/math/__truncdfsf2.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | float __truncdfsf2(double x) 4 | { return IEEEDPTieee(x); } 5 | -------------------------------------------------------------------------------- /sources/nix/stdio/feof.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #undef feof 4 | 5 | int feof(FILE *stream) 6 | { return (stream->flags&__SEOF)!=0; } 7 | -------------------------------------------------------------------------------- /sources/nix/stdio/fsetpos.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int fsetpos(FILE *stream,fpos_t *pos) 4 | { return fseek(stream,*pos,SEEK_SET); } 5 | -------------------------------------------------------------------------------- /sources/nix/stdio/ferror.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #undef ferror 4 | 5 | int ferror(FILE *stream) 6 | { return (stream->flags&__SERR)!=0; } 7 | -------------------------------------------------------------------------------- /sources/nix/stdlib/atoi.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int atoi(const char *nptr) 5 | { return strtol(nptr,NULL,10); } 6 | -------------------------------------------------------------------------------- /sources/nix/stdlib/atol.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | long atol(const char *nptr) 5 | { return strtol(nptr,NULL,10); } 6 | -------------------------------------------------------------------------------- /sources/stubs/misc/__DOSBase.c: -------------------------------------------------------------------------------- 1 | #include "stabs.h" 2 | extern char __dosname[]; 3 | void *__DOSBase[2]={ 0l,__dosname }; 4 | ADD2LIB(__DOSBase); 5 | -------------------------------------------------------------------------------- /sources/stubs/libnames/mathieeedoubbas.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | char __mathieeedoubbasname[]="mathieeedoubbas.library"; 3 | -------------------------------------------------------------------------------- /sources/stubs/libnames/mathieeesingbas.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | char __mathieeesingbasname[]="mathieeesingbas.library"; 3 | -------------------------------------------------------------------------------- /sources/math/stdlib/atof.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double atof(const char *nptr) 4 | { double a; 5 | sscanf(nptr,"%lf",&a); 6 | return a; 7 | } 8 | -------------------------------------------------------------------------------- /sources/nix/extra/getpid.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | pid_t getpid(void) 5 | { 6 | return (pid_t)FindTask(NULL); 7 | } 8 | -------------------------------------------------------------------------------- /sources/nix/extra/getwd.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | char *getwd(char *buf) 5 | { 6 | return getcwd(buf,MAXPATHLEN); 7 | } 8 | -------------------------------------------------------------------------------- /sources/nix/locale/localeconv.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern struct lconv __lconv; 4 | 5 | struct lconv *localeconv(void) 6 | { return &__lconv; } 7 | -------------------------------------------------------------------------------- /sources/nix/stdio/setbuf.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int setbuf(FILE *stream,char *buf) 4 | { return setvbuf(stream,buf,buf?_IOFBF:_IONBF,BUFSIZ); } 5 | -------------------------------------------------------------------------------- /sources/nix/time/__gmtoffset.c: -------------------------------------------------------------------------------- 1 | /* Greenwich mean time offset and daylight savings time flag 2 | */ 3 | 4 | long __gmtoffset=0; 5 | int __dstflag=0; 6 | -------------------------------------------------------------------------------- /sources/stubs/libnames/mathieeedoubtrans.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | char __mathieeedoubtransname[]="mathieeedoubtrans.library"; 3 | -------------------------------------------------------------------------------- /sources/stubs/libnames/mathieeesingtrans.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | char __mathieeesingtransname[]="mathieeesingtrans.library"; 3 | -------------------------------------------------------------------------------- /sources/nix/extra/stpcpy.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | char *stpcpy(char *dest,const char *source) 4 | { 5 | while((*dest++=*source++)); return(dest-1); 6 | } 7 | -------------------------------------------------------------------------------- /sources/stubs/misc/__UtilityBase.c: -------------------------------------------------------------------------------- 1 | #include "stabs.h" 2 | extern char __utilityname[]; 3 | void *__UtilityBase[2]={ 0l,__utilityname }; 4 | ADD2LIB(__UtilityBase); 5 | -------------------------------------------------------------------------------- /sources/amiga/misc/WaitBeam.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | VOID waitbeam(LONG pos) 5 | { 6 | do{}while(pos>VBeamPos()); 7 | } 8 | -------------------------------------------------------------------------------- /sources/nix/extra/creat.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int creat(const char *path, mode_t mode) 4 | { 5 | return open(path, O_CREAT | O_TRUNC | O_WRONLY, mode); 6 | } 7 | -------------------------------------------------------------------------------- /sources/nix/extra/setbuffer.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void setbuffer(FILE *stream,char *buf,size_t size) 4 | { (void)setvbuf(stream,buf,buf?_IOFBF:_IONBF,size); } 5 | -------------------------------------------------------------------------------- /sources/nix/stdio/vprintf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int vprintf(const char *format,va_list args) 5 | { return vfprintf(stdout,format,args); } 6 | -------------------------------------------------------------------------------- /sources/nix/stdio/vscanf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int vscanf(const char *format,va_list args) 5 | { return vfscanf(stdin,format,args); } 6 | -------------------------------------------------------------------------------- /sources/math/stdio/isinf.c: -------------------------------------------------------------------------------- 1 | int isinf(double a) 2 | { 3 | unsigned long *b=(unsigned long *)&a; 4 | return (b[0]&0x7ff00000)==0x7ff00000&&!(b[0]&0xfffff)&&!b[1]; 5 | } 6 | -------------------------------------------------------------------------------- /sources/math/stdio/isnan.c: -------------------------------------------------------------------------------- 1 | int isnan(double a) 2 | { 3 | unsigned long *b=(unsigned long *)&a; 4 | return (b[0]&0x7ff00000)==0x7ff00000&&((b[0]&0xfffff)||b[1]); 5 | } 6 | -------------------------------------------------------------------------------- /sources/nix/signal/__signalfunc.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void (*__signalfunc[6])(int)={ NULL }; /* array of signalhandlers */ 4 | int __signalpending=0,__signalmask=0; 5 | -------------------------------------------------------------------------------- /sources/nix/string/strlen.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | size_t strlen(const char *string) 4 | { const char *s=string; 5 | 6 | do;while(*s++); return ~(string-s); 7 | } 8 | -------------------------------------------------------------------------------- /sources/amiga/misc/DoPktn.c: -------------------------------------------------------------------------------- 1 | #include "stabs.h" 2 | 3 | ALIAS(DoPkt0,DoPkt); 4 | ALIAS(DoPkt1,DoPkt); 5 | ALIAS(DoPkt2,DoPkt); 6 | ALIAS(DoPkt3,DoPkt); 7 | ALIAS(DoPkt4,DoPkt); 8 | -------------------------------------------------------------------------------- /sources/nix/string/memcpy.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void *memcpy(void *s1,const void *s2,size_t n) 5 | { 6 | CopyMem((APTR)s2,s1,n); return s1; 7 | } 8 | -------------------------------------------------------------------------------- /sources/amiga/misc/LibAllocPooled.c: -------------------------------------------------------------------------------- 1 | #include "pool.h" 2 | 3 | APTR LibAllocPooled(APTR poolHeader, ULONG memSize) 4 | { 5 | return AsmAllocPooled(poolHeader,memSize,*(APTR *)4L); 6 | } 7 | -------------------------------------------------------------------------------- /sources/stubs/libbases/asl.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | #include 3 | extern char __aslname[]; 4 | void *AslBase[2]={ 0l,__aslname }; 5 | ADD2LIB(AslBase); 6 | -------------------------------------------------------------------------------- /sources/stubs/libbases/dos.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | #include 3 | extern char __dosname[]; 4 | void *DOSBase[2]={ 0l,__dosname }; 5 | ADD2LIB(DOSBase); 6 | -------------------------------------------------------------------------------- /sources/stubs/libbases/icon.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | #include 3 | extern char __iconname[]; 4 | void *IconBase[2]={ 0l,__iconname }; 5 | ADD2LIB(IconBase); 6 | -------------------------------------------------------------------------------- /sources/amiga/misc/LibFreePooled.c: -------------------------------------------------------------------------------- 1 | #include "pool.h" 2 | 3 | VOID LibFreePooled(APTR poolHeader, APTR memory, ULONG memSize) 4 | { 5 | AsmFreePooled(poolHeader,memory,memSize,*(APTR *)4L); 6 | } 7 | -------------------------------------------------------------------------------- /sources/nix/stdio/fputs.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int fputs(const char *s,FILE *stream) 4 | { 5 | while(*s) 6 | if(fputc(*s++,stream)==EOF) 7 | return EOF; 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /sources/stubs/libbases/bullet.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | #include 3 | extern char __bulletname[]; 4 | void *BulletBase[2]={ 0l,__bulletname }; 5 | ADD2LIB(BulletBase); 6 | -------------------------------------------------------------------------------- /sources/stubs/libbases/graphics.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | #include 3 | extern char __graphicsname[]; 4 | void *GfxBase[2]={ 0l,__graphicsname }; 5 | ADD2LIB(GfxBase); 6 | -------------------------------------------------------------------------------- /sources/stubs/libbases/keymap.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | #include 3 | extern char __keymapname[]; 4 | void *KeymapBase[2]={ 0l,__keymapname }; 5 | ADD2LIB(KeymapBase); 6 | -------------------------------------------------------------------------------- /sources/stubs/libbases/layers.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | #include 3 | extern char __layersname[]; 4 | void *LayersBase[2]={ 0l,__layersname }; 5 | ADD2LIB(LayersBase); 6 | -------------------------------------------------------------------------------- /sources/stubs/libbases/locale.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | #include 3 | extern char __localename[]; 4 | void *LocaleBase[2]={ 0l,__localename }; 5 | ADD2LIB(LocaleBase); 6 | -------------------------------------------------------------------------------- /sources/stubs/libbases/mathffp.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | #include 3 | extern char __mathffpname[]; 4 | void *MathBase[2]={ 0l,__mathffpname }; 5 | ADD2LIB(MathBase); 6 | -------------------------------------------------------------------------------- /sources/stubs/misc/__MathIeeeDoubBasBase.c: -------------------------------------------------------------------------------- 1 | #include "stabs.h" 2 | extern char __mathieeedoubbasname[]; 3 | void *__MathIeeeDoubBasBase[2]={ 0l,__mathieeedoubbasname }; 4 | ADD2LIB(__MathIeeeDoubBasBase); 5 | -------------------------------------------------------------------------------- /sources/stubs/misc/__MathIeeeSingBasBase.c: -------------------------------------------------------------------------------- 1 | #include "stabs.h" 2 | extern char __mathieeesingbasname[]; 3 | void *__MathIeeeSingBasBase[2]={ 0l,__mathieeesingbasname }; 4 | ADD2LIB(__MathIeeeSingBasBase); 5 | -------------------------------------------------------------------------------- /sources/stubs/libbases/commodities.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | #include 3 | extern char __commoditiesname[]; 4 | void *CxBase[2]={ 0l,__commoditiesname }; 5 | ADD2LIB(CxBase); 6 | -------------------------------------------------------------------------------- /sources/stubs/libbases/nonvolatile.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | #include 3 | extern char __nonvolatilename[]; 4 | void *NVBase[2]={ 0l,__nonvolatilename }; 5 | ADD2LIB(NVBase); 6 | -------------------------------------------------------------------------------- /sources/stubs/libbases/utility.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | #include 3 | extern char __utilityname[]; 4 | void *UtilityBase[2]={ 0l,__utilityname }; 5 | ADD2LIB(UtilityBase); 6 | -------------------------------------------------------------------------------- /sources/stubs/misc/__flush_cache.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void __flush_cache(APTR adr, ULONG len) 5 | { 6 | CacheClearE(adr, len, CACRF_ClearD | CACRF_ClearI); 7 | } 8 | -------------------------------------------------------------------------------- /sources/nix/string/memmove.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern void bcopy(const void *s1,void *s2,size_t n); 4 | 5 | void *memmove(void *s1,const void *s2,size_t n) 6 | { 7 | bcopy(s2,s1,n); return s1; 8 | } 9 | -------------------------------------------------------------------------------- /sources/stubs/libbases/diskfont.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | #include 3 | extern char __diskfontname[]; 4 | void *DiskfontBase[2]={ 0l,__diskfontname }; 5 | ADD2LIB(DiskfontBase); 6 | -------------------------------------------------------------------------------- /sources/stubs/libbases/gadtools.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | #include 3 | extern char __gadtoolsname[]; 4 | void *GadToolsBase[2]={ 0l,__gadtoolsname }; 5 | ADD2LIB(GadToolsBase); 6 | -------------------------------------------------------------------------------- /sources/stubs/libbases/iffparse.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | #include 3 | extern char __iffparsename[]; 4 | void *IFFParseBase[2]={ 0l,__iffparsename }; 5 | ADD2LIB(IFFParseBase); 6 | -------------------------------------------------------------------------------- /sources/stubs/libbases/lowlevel.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | #include 3 | extern char __lowlevelname[]; 4 | void *LowLevelBase[2]={ 0l,__lowlevelname }; 5 | ADD2LIB(LowLevelBase); 6 | -------------------------------------------------------------------------------- /sources/stubs/libbases/realtime.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | #include 3 | extern char __realtimename[]; 4 | void *RealTimeBase[2]={ 0l,__realtimename }; 5 | ADD2LIB(RealTimeBase); 6 | -------------------------------------------------------------------------------- /sources/stubs/misc/__MathIeeeDoubTransBase.c: -------------------------------------------------------------------------------- 1 | #include "stabs.h" 2 | extern char __mathieeedoubtransname[]; 3 | void *__MathIeeeDoubTransBase[2]={ 0l,__mathieeedoubtransname }; 4 | ADD2LIB(__MathIeeeDoubTransBase); 5 | -------------------------------------------------------------------------------- /sources/stubs/misc/__MathIeeeSingTransBase.c: -------------------------------------------------------------------------------- 1 | #include "stabs.h" 2 | extern char __mathieeesingtransname[]; 3 | void *__MathIeeeSingTransBase[2]={ 0l,__mathieeesingtransname }; 4 | ADD2LIB(__MathIeeeSingTransBase); 5 | -------------------------------------------------------------------------------- /sources/nix/math/__fixunsdfsi.c: -------------------------------------------------------------------------------- 1 | unsigned long __fixunsdfsi(double x) 2 | { if(x<0) 3 | return 0; 4 | if(x>=0x80000000u) 5 | return (signed long)(x-0x80000000u)+0x80000000u; 6 | return (signed long)x; 7 | } 8 | -------------------------------------------------------------------------------- /sources/nix/math/__fixunssfsi.c: -------------------------------------------------------------------------------- 1 | unsigned long __fixunssfsi(float x) 2 | { if(x<0) 3 | return 0; 4 | if(x>=0x80000000u) 5 | return (signed long)(x-0x80000000u)+0x80000000u; 6 | return (signed long)x; 7 | } 8 | -------------------------------------------------------------------------------- /sources/nix/stdlib/rand.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static unsigned int a=1; 4 | 5 | int rand(void) 6 | { return (a=a*1103515245+12345)%RAND_MAX; } 7 | 8 | void srand(unsigned int seed) 9 | { a=seed; } 10 | -------------------------------------------------------------------------------- /sources/nix/time/localtime.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern long __gmtoffset; 4 | 5 | struct tm *localtime(const time_t *t) 6 | { time_t ti=*t; 7 | ti-=__gmtoffset*60; 8 | return gmtime(&ti); 9 | } 10 | -------------------------------------------------------------------------------- /sources/socket/socket/socketpair.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int socketpair(int d, int type, int protocol, int sv[2]) 6 | { 7 | errno = ENOSYS; return -1; 8 | } 9 | -------------------------------------------------------------------------------- /sources/stubs/libbases/datatypes.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | #include 3 | extern char __datatypesname[]; 4 | void *DataTypesBase[2]={ 0l,__datatypesname }; 5 | ADD2LIB(DataTypesBase); 6 | -------------------------------------------------------------------------------- /sources/stubs/libbases/expansion.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | #include 3 | extern char __expansionname[]; 4 | void *ExpansionBase[2]={ 0l,__expansionname }; 5 | ADD2LIB(ExpansionBase); 6 | -------------------------------------------------------------------------------- /sources/stubs/libbases/intuition.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | #include 3 | extern char __intuitionname[]; 4 | void *IntuitionBase[2]={ 0l,__intuitionname }; 5 | ADD2LIB(IntuitionBase); 6 | -------------------------------------------------------------------------------- /sources/stubs/libbases/mathtrans.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | #include 3 | extern char __mathtransname[]; 4 | void *MathTransBase[2]={ 0l,__mathtransname }; 5 | ADD2LIB(MathTransBase); 6 | -------------------------------------------------------------------------------- /sources/stubs/libbases/rexxsyslib.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | #include 3 | extern char __rexxsyslibname[]; 4 | void *RexxSysBase[2]={ 0l,__rexxsyslibname }; 5 | ADD2LIB(RexxSysBase); 6 | -------------------------------------------------------------------------------- /sources/stubs/libbases/workbench.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | #include 3 | extern char __workbenchname[]; 4 | void *WorkbenchBase[2]={ 0l,__workbenchname }; 5 | ADD2LIB(WorkbenchBase); 6 | -------------------------------------------------------------------------------- /sources/nix/stdlib/abort.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void abort(void) 6 | { 7 | raise(SIGABRT); 8 | fputs("Program aborted\n",stderr); 9 | exit(20); 10 | } 11 | -------------------------------------------------------------------------------- /sources/stubs/libbases/amigaguide.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | #include 3 | extern char __amigaguidename[]; 4 | void *AmigaGuideBase[2]={ 0l,__amigaguidename }; 5 | ADD2LIB(AmigaGuideBase); 6 | -------------------------------------------------------------------------------- /sources/stubs/libbases/translator.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | #include 3 | extern char __translatorname[]; 4 | void *TranslatorBase[2]={ 0l,__translatorname }; 5 | ADD2LIB(TranslatorBase); 6 | -------------------------------------------------------------------------------- /sources/nix/extra/timer.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern void dotimer(ULONG,ULONG,struct timeval *); 4 | 5 | void timer(long clock[2]) 6 | { 7 | dotimer(UNIT_VBLANK,TR_GETSYSTIME,(struct timeval *)&clock[0]); 8 | } 9 | -------------------------------------------------------------------------------- /sources/amiga/misc/AbsExecBase.c: -------------------------------------------------------------------------------- 1 | #include "stabs.h" 2 | 3 | ABSDEF(AbsExecBase,0x00000004); 4 | ABSDEF(cartridge, 0x00f00000); 5 | ABSDEF(bootrom, 0x00f80000); 6 | ABSDEF(romstart, 0x00fc0000); 7 | ABSDEF(romend, 0x00ffffff); 8 | -------------------------------------------------------------------------------- /sources/nix/extra/strdup.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | char *strdup(const char *s) 6 | { char *s1=malloc(strlen_plus_one(s)); 7 | if (s1) 8 | strcpy(s1,s); 9 | return s1; 10 | } 11 | -------------------------------------------------------------------------------- /sources/nix/signal/__chkabort.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void __chkabort(void) 6 | { 7 | if (SetSignal(0L,SIGBREAKF_CTRL_C) & SIGBREAKF_CTRL_C) 8 | raise(SIGINT); 9 | } 10 | -------------------------------------------------------------------------------- /sources/nix/stdio/puts.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int puts(const char *s) 4 | { 5 | while(*s) 6 | if(fputc(*s++,stdout)==EOF) 7 | return EOF; 8 | if(fputc('\n',stdout)==EOF) 9 | return EOF; 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /sources/nix20/math/__mulsi3.c: -------------------------------------------------------------------------------- 1 | #include "bases.h" 2 | 3 | asm( 4 | " .globl ___mulsi3;" 5 | 6 | /* D0 = D0 * D1 */ 7 | 8 | "___mulsi3: moveml sp@(4),d0/d1;" 9 | " movel "A4(_UtilityBase)",a0;" 10 | " jmp a0@(-138:W);" 11 | ); 12 | -------------------------------------------------------------------------------- /sources/stack/stkovf.c: -------------------------------------------------------------------------------- 1 | #include "bases.h" 2 | 3 | asm( 4 | " .text;" 5 | " .even;" 6 | " .globl ___stkovf;" 7 | 8 | "___stkovf:;" 9 | " clrl "A4(___stk_limit)";" /* generate no more stackoverflows */ 10 | " jra __XCOVF;" 11 | ); 12 | -------------------------------------------------------------------------------- /sources/nix/extra/putw.c: -------------------------------------------------------------------------------- 1 | /* Write a long word to a file */ 2 | 3 | #include 4 | 5 | int putw(int w, FILE *f) 6 | { 7 | if (fwrite((char *)&w, sizeof(w), 1, f) != 1) 8 | return EOF; 9 | else 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /sources/nix/stdio/putchar.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int puts(const char *s) 4 | { 5 | while(*s) 6 | if(fputc(*s++,stdout)==EOF) 7 | return EOF; 8 | if(fputc('\n',stdout)==EOF) 9 | return EOF; 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /sources/stack/xcovf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void __request(const char *text); 5 | 6 | void _XCOVF(void) /* stack overflow handler */ 7 | { 8 | __request("Stack overflow"); 9 | exit(RETURN_FAIL); 10 | } 11 | -------------------------------------------------------------------------------- /sources/stubs/libbases/mathieeedoubbas.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | #include 3 | extern char __mathieeedoubbasname[]; 4 | void *MathIeeeDoubBasBase[2]={ 0l,__mathieeedoubbasname }; 5 | ADD2LIB(MathIeeeDoubBasBase); 6 | -------------------------------------------------------------------------------- /sources/stubs/libbases/mathieeesingbas.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | #include 3 | extern char __mathieeesingbasname[]; 4 | void *MathIeeeSingBasBase[2]={ 0l,__mathieeesingbasname }; 5 | ADD2LIB(MathIeeeSingBasBase); 6 | -------------------------------------------------------------------------------- /sources/nix20/extra/stricmp.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "stabs.h" 4 | 5 | int stricmp(const char *s1,const char *s2) 6 | { 7 | return Stricmp((STRPTR)s1,(STRPTR)s2); 8 | } 9 | 10 | ALIAS(strcasecmp,stricmp); 11 | -------------------------------------------------------------------------------- /sources/stubs/libbases/mathieeedoubtrans.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | #include 3 | extern char __mathieeedoubtransname[]; 4 | void *MathIeeeDoubTransBase[2]={ 0l,__mathieeedoubtransname }; 5 | ADD2LIB(MathIeeeDoubTransBase); 6 | -------------------------------------------------------------------------------- /sources/stubs/libbases/mathieeesingtrans.c: -------------------------------------------------------------------------------- 1 | /* Machine-generated C-file- do not edit ! */ 2 | #include 3 | extern char __mathieeesingtransname[]; 4 | void *MathIeeeSingTransBase[2]={ 0l,__mathieeesingtransname }; 5 | ADD2LIB(MathIeeeSingTransBase); 6 | -------------------------------------------------------------------------------- /sources/math/stdlib/strtod.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double strtod(const char *nptr,char **endptr) 4 | { double a; 5 | unsigned long n=0; 6 | sscanf(nptr,"%lf%ln",&a,&n); 7 | if(endptr) 8 | *endptr=(char *)nptr+n; 9 | return a; 10 | } 11 | -------------------------------------------------------------------------------- /sources/nix/string/strcmp.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int strcmp(const char *s1,const char *s2) 4 | { unsigned char *p1=(unsigned char *)s1, *p2=(unsigned char *)s2; 5 | unsigned long r,c; 6 | 7 | do;while(r=*p1++,c=*p2++,!(r-=c) && (char)c); return r; 8 | } 9 | -------------------------------------------------------------------------------- /sources/nix/stdio/printf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int printf(const char *format,...) 5 | { int retval; 6 | va_list args; 7 | va_start(args,format); 8 | retval=vprintf(format,args); 9 | va_end(args); 10 | return retval; 11 | } 12 | -------------------------------------------------------------------------------- /sources/nix/stdio/scanf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int scanf(const char *format,...) 5 | { int retval; 6 | va_list args; 7 | va_start(args,format); 8 | retval=vscanf(format,args); 9 | va_end(args); 10 | return retval; 11 | } 12 | -------------------------------------------------------------------------------- /sources/nix/string/strchr.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "stabs.h" 3 | 4 | char *strchr(const char *s,int c) 5 | { 6 | while (*s!=(char)c) 7 | if (!*s++) 8 | { s = (char *)0; break; } 9 | return (char *)s; 10 | } 11 | 12 | ALIAS(index,strchr); 13 | -------------------------------------------------------------------------------- /sources/math/extra/modf.c: -------------------------------------------------------------------------------- 1 | #undef __HAVE_68881__ 2 | #include 3 | 4 | double modf(double x,double *p) 5 | { 6 | if(x<0){ 7 | *p=ceil(x); 8 | return(*p-x); 9 | }else{ 10 | *p=floor(x); 11 | return(x-*p); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /sources/nix/string/memcmp.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int memcmp(const void *s1,const void *s2,size_t n) 4 | { const unsigned char *p1=s1,*p2=s2; 5 | unsigned long r,c; 6 | 7 | if ((r=n)) 8 | do;while(r=*p1++,c=*p2++,!(r-=c) && --n); 9 | return r; 10 | } 11 | -------------------------------------------------------------------------------- /sources/nix/time/asctime.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static char buffer[26]; 4 | 5 | char *asctime(const struct tm *t) 6 | { strftime(buffer,sizeof(buffer),"%C\n",t); 7 | return buffer; 8 | } 9 | 10 | char *ctime(const time_t *t) 11 | { return asctime(localtime(t)); } 12 | -------------------------------------------------------------------------------- /sources/nix/stdio/sprintf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int sprintf(char *s,const char *format,...) 5 | { int retval; 6 | va_list args; 7 | va_start(args,format); 8 | retval=vsprintf(s,format,args); 9 | va_end(args); 10 | return retval; 11 | } 12 | -------------------------------------------------------------------------------- /sources/nix/string/strrchr.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "stabs.h" 3 | 4 | char *strrchr(const char *s,int c) 5 | { char *c1=(char *)0; 6 | do 7 | if (*s==(char)c) 8 | c1=(char *)s; 9 | while(*s++); 10 | return c1; 11 | } 12 | 13 | ALIAS(rindex,strrchr); 14 | -------------------------------------------------------------------------------- /sources/nix20/extra/strnicmp.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "stabs.h" 4 | 5 | int strnicmp(const char *s1,const char *s2,size_t len) 6 | { 7 | return Strnicmp((STRPTR)s1,(STRPTR)s2,(LONG)len); 8 | } 9 | 10 | ALIAS(strncasecmp,strnicmp); 11 | -------------------------------------------------------------------------------- /sources/nix/stdio/fscanf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int fscanf(FILE *stream,const char *format,...) 5 | { int retval; 6 | va_list args; 7 | va_start(args,format); 8 | retval=vfscanf(stream,format,args); 9 | va_end(args); 10 | return retval; 11 | } 12 | -------------------------------------------------------------------------------- /sources/nix/stdio/sscanf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int sscanf(const char *s,const char *format,...) 5 | { int retval; 6 | va_list args; 7 | va_start(args,format); 8 | retval=vsscanf(s,format,args); 9 | va_end(args); 10 | return retval; 11 | } 12 | -------------------------------------------------------------------------------- /sources/amiga/misc/NewList.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | VOID NewList(struct List *list) 5 | { LONG *p; 6 | 7 | list->lh_TailPred=(struct Node *)list; 8 | ((LONG *)list)++; 9 | *(LONG *)list=0; 10 | p=(LONG *)list; *--p=(LONG)list; 11 | } 12 | -------------------------------------------------------------------------------- /sources/nix/stdio/fprintf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int fprintf(FILE *stream,const char *format,...) 5 | { int retval; 6 | va_list args; 7 | va_start(args,format); 8 | retval=vfprintf(stream,format,args); 9 | va_end(args); 10 | return retval; 11 | } 12 | -------------------------------------------------------------------------------- /sources/socket/ft.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(void) 5 | { 6 | int fd1 = open("t:t1",O_TRUNC); 7 | int fd2 = open("t:t2",O_TRUNC); 8 | int fd3 = dup2(fd1,fd2); 9 | int fd4 = dup(fd1); 10 | close(fd2); 11 | fd2 = open("t:t2",O_RDONLY); 12 | } 13 | -------------------------------------------------------------------------------- /sources/nix/assert/__eprintf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void __eprintf(const char *format,...) /* for asserts */ 6 | { va_list args; 7 | va_start(args,format); 8 | vfprintf(stderr,format,args); 9 | va_end(args); 10 | abort(); 11 | } 12 | -------------------------------------------------------------------------------- /sources/nix/extra/sleep.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern void dotimer(ULONG,ULONG,struct timeval *); 4 | 5 | void sleep(int secs) 6 | { struct timeval tv; 7 | 8 | if ((int)(tv.tv_secs=secs)>0) 9 | { tv.tv_micro=0; 10 | dotimer(UNIT_VBLANK,TR_ADDREQUEST,&tv); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /sources/nix/stdio/snprintf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int snprintf(char *s,size_t size,const char *format,...) 5 | { int retval; 6 | va_list args; 7 | va_start(args,format); 8 | retval=vsnprintf(s,size,format,args); 9 | va_end(args); 10 | return retval; 11 | } 12 | -------------------------------------------------------------------------------- /sources/nix/stdio/wctomb.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* Sorry, the Amiga OS locale currently doesn't support 4 | * character sets other than ECMA Latin 1, so this is 5 | * just a "C" locale function 6 | */ 7 | int wctomb(char *s,wchar_t wc) 8 | { if(s) 9 | *s=wc; 10 | return 1; 11 | } 12 | -------------------------------------------------------------------------------- /sources/socket/extra/fstat.c: -------------------------------------------------------------------------------- 1 | #include 2 | // 3 | #include "stdio.h" 4 | 5 | int fstat(int d, struct stat *buf) 6 | { StdFileDes *fp = _lx_fhfromfd(d); 7 | if (fp) { 8 | return fp->lx_fstat(fp, buf); 9 | } 10 | else { 11 | errno = EBADF; 12 | return -1; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /sources/amiga/misc/DoPktn.s: -------------------------------------------------------------------------------- 1 | 2 | .stabs "_DoPkt0" ,11,0,0,0;.stabs "_DoPkt" ,1,0,0,0 3 | .stabs "_DoPkt1" ,11,0,0,0;.stabs "_DoPkt" ,1,0,0,0 4 | .stabs "_DoPkt2" ,11,0,0,0;.stabs "_DoPkt" ,1,0,0,0 5 | .stabs "_DoPkt3" ,11,0,0,0;.stabs "_DoPkt" ,1,0,0,0 6 | .stabs "_DoPkt4" ,11,0,0,0;.stabs "_DoPkt" ,1,0,0,0 7 | -------------------------------------------------------------------------------- /sources/socket/extra/dup.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | // 4 | #include "stdio.h" 5 | 6 | int dup(int d) 7 | { StdFileDes *sfd = _lx_fhfromfd(d); 8 | 9 | if (sfd) { 10 | return sfd->lx_dup(sfd); 11 | } 12 | else { 13 | errno = EBADF; 14 | return -1; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /sources/nix/math/__eqsf2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "stabs.h" 3 | 4 | signed long __eqsf2(float x,float y) 5 | { return IEEESPCmp(x,y); } 6 | 7 | ALIAS(__gesf2,__eqsf2); 8 | ALIAS(__nesf2,__eqsf2); 9 | ALIAS(__gtsf2,__eqsf2); 10 | ALIAS(__ltsf2,__eqsf2); 11 | ALIAS(__lesf2,__eqsf2); 12 | -------------------------------------------------------------------------------- /sources/nix/string/memchr.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void *memchr(const void *s,int c,size_t n) 4 | { 5 | if (n) { 6 | unsigned char *p=(unsigned char *)s; 7 | do { 8 | if (*p++==(unsigned char)c) 9 | return --p; 10 | } while (--n); 11 | } 12 | return (void *)n; 13 | } 14 | -------------------------------------------------------------------------------- /sources/nix/string/strncmp.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int strncmp(const char *s1,const char *s2,size_t n) 4 | { unsigned char *p1=(unsigned char *)s1,*p2=(unsigned char *)s2; 5 | unsigned long r,c; 6 | 7 | if ((r=n)) 8 | do;while(r=*p1++,c=*p2++,!(r-=c) && (char)c && --n); 9 | return r; 10 | } 11 | -------------------------------------------------------------------------------- /sources/nix/math/__eqdf2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "stabs.h" 3 | 4 | signed long __eqdf2(double x,double y) 5 | { return IEEEDPCmp(x,y); } 6 | 7 | ALIAS(__gedf2,__eqdf2); 8 | ALIAS(__nedf2,__eqdf2); 9 | ALIAS(__gtdf2,__eqdf2); 10 | ALIAS(__ltdf2,__eqdf2); 11 | ALIAS(__ledf2,__eqdf2); 12 | -------------------------------------------------------------------------------- /sources/nix/extra/strlower.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "stabs.h" 3 | 4 | char *strlower(char *s) 5 | { unsigned char *s1; 6 | 7 | s1=(unsigned char *)s; 8 | while(*s1) { 9 | if (isupper(*s1)) 10 | *s1+='a'-'A'; 11 | ++s1; 12 | } 13 | return s; 14 | } 15 | 16 | ALIAS(strlwr,strlower); 17 | -------------------------------------------------------------------------------- /sources/nix/extra/strupper.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "stabs.h" 3 | 4 | char *strupper(char *s) 5 | { unsigned char *s1; 6 | 7 | s1=(unsigned char *)s; 8 | while(*s1) { 9 | if (islower(*s1)) 10 | *s1-='a'-'A'; 11 | ++s1; 12 | } 13 | return s; 14 | } 15 | 16 | ALIAS(strupr,strupper); 17 | -------------------------------------------------------------------------------- /sources/socket/unistd/crypt.c: -------------------------------------------------------------------------------- 1 | #include 2 | // 3 | #include "socket.h" 4 | 5 | char *crypt(const char *key, const char *setting) 6 | { struct SocketSettings *lss = _lx_get_socket_settings(); 7 | 8 | if (lss->lx_network_type == LX_AMITCP) 9 | return UG_crypt(key,setting); 10 | return NULL; 11 | } 12 | -------------------------------------------------------------------------------- /sources/amiga/misc/LibCreatePool.c: -------------------------------------------------------------------------------- 1 | #include "pool.h" 2 | 3 | APTR LibCreatePool(ULONG requirements, ULONG puddleSize, ULONG threshSize) 4 | { 5 | return AsmCreatePool(requirements,puddleSize,threshSize,*(APTR *)4L); 6 | } 7 | 8 | VOID LibDeletePool(APTR poolHeader) 9 | { 10 | AsmDeletePool(poolHeader,*(APTR *)4L); 11 | } 12 | -------------------------------------------------------------------------------- /sources/nix/string/strcspn.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | size_t strcspn(const char *s1,const char *s2) 4 | { unsigned char *c2,*c1=(unsigned char *)s1; 5 | size_t i; 6 | for(i=0;;i++) { 7 | c2=(unsigned char *)s2; 8 | do 9 | if(c1[i]==*c2) 10 | return i; 11 | while(*c2++!='\0'); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /sources/nix/extra/getw.c: -------------------------------------------------------------------------------- 1 | /* Read a long word into a file -- returns EOF on error, or when the word 2 | that was read is equal to EOF!!! */ 3 | 4 | #include 5 | 6 | int getw(FILE *f) 7 | { 8 | int x; 9 | 10 | if (fread((char *)&x, sizeof(x), 1, f) != 1) 11 | return EOF; 12 | else 13 | return x; 14 | } 15 | -------------------------------------------------------------------------------- /sources/nix/stdio/perror.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void perror(const char *string) 6 | { int err=errno; 7 | if(string!=NULL) 8 | { fputs(string,stderr); 9 | fputc(':',stderr); 10 | fputc(' ',stderr); } 11 | fputs(strerror(err),stderr); 12 | fputc('\n',stderr); 13 | } 14 | -------------------------------------------------------------------------------- /sources/amiga/misc/sprintf.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | STATIC const ULONG tricky=0x16c04e75; /* move.b d0,(a3)+ ; rts */ 4 | 5 | VOID sprintf(STRPTR buffer,STRPTR fmt,...) 6 | { APTR SysBase = *(APTR *)4L; 7 | STRPTR *arg = &fmt+1; 8 | 9 | RawDoFmt(fmt,arg,(void (*)())&tricky,buffer); 10 | } /* Not very clean, but ... */ 11 | -------------------------------------------------------------------------------- /sources/nix/extra/usleep.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | extern void dotimer(ULONG,ULONG,struct timeval *); 5 | 6 | void usleep(unsigned int tim) 7 | { struct timeval tv; 8 | 9 | tv.tv_secs = tim / 1000000; 10 | tv.tv_micro = tim % 1000000; 11 | 12 | dotimer(UNIT_VBLANK,TR_ADDREQUEST,&tv); 13 | } 14 | -------------------------------------------------------------------------------- /sources/nix/string/strstr.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | char *strstr(const char *s1,const char *s2) 4 | { const char *c1,*c2; 5 | 6 | do { 7 | c1 = s1; c2 = s2; 8 | while(*c1 && *c1==*c2) { 9 | c1++; c2++; 10 | } 11 | if (!*c2) 12 | return (char *)s1; 13 | } while(*s1++); 14 | return (char *)0; 15 | } 16 | -------------------------------------------------------------------------------- /sources/nix/setjmp/setjmp.c: -------------------------------------------------------------------------------- 1 | asm( 2 | " .text;" 3 | " .even;" 4 | " .globl _setjmp;" 5 | 6 | "_setjmp:" 7 | " movel sp@(4),a0;" /* get address of jmp_buf */ 8 | " movel sp@,a0@+;" /* store returnaddress */ 9 | " moveml d2-d7/a2-a6/sp,a0@;" /* store all registers except scratch */ 10 | " moveql #0,d0;" /* return 0 */ 11 | " rts;" 12 | ); 13 | -------------------------------------------------------------------------------- /sources/nix/stdio/gets.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | char *gets(char *s) 4 | { char *s2=s; 5 | 6 | for(;;) 7 | { int c=fgetc(stdin); 8 | if(c==EOF) 9 | { if(s2==s) 10 | return NULL; 11 | break; 12 | } 13 | if(c=='\n') 14 | break; 15 | *s2++=c; 16 | } 17 | *s2++='\0'; 18 | return s; 19 | } 20 | -------------------------------------------------------------------------------- /sources/nix/string/strtok.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | char *strtok(char *s1,const char *s2) 4 | { static char *t; 5 | if(s1) 6 | t=s1; 7 | else 8 | s1=t; 9 | s1+=strspn(s1,s2); 10 | if(*s1=='\0') 11 | return (char *)0; 12 | t=s1; 13 | t+=strcspn(s1,s2); 14 | if(*t!='\0') 15 | *t++='\0'; 16 | return s1; 17 | } 18 | -------------------------------------------------------------------------------- /sources/nix/stdio/mbtowc.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* Sorry, the Amiga OS locale currently doesn't support 4 | * character sets other than ECMA Latin 1, so this is 5 | * just a "C" locale function 6 | */ 7 | int mbtowc(wchar_t *wc,const char *s,size_t n) 8 | { if(n&&s) 9 | { *wc=*s; 10 | return sizeof(wchar_t); } 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /sources/nix/string/strspn.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | size_t strspn(const char *s1,const char *s2) 4 | { size_t i; 5 | unsigned char *c1=(unsigned char *)s1; 6 | unsigned char *c2; 7 | for(i=0;;i++) 8 | { c2=(unsigned char *)s2; 9 | while(*c2!='\0'&&c1[i]!=*c2) 10 | c2++; 11 | if(*c2=='\0') 12 | return i; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /sources/amiga/misc/BeginIO.c: -------------------------------------------------------------------------------- 1 | #ifdef __GNUC__ 2 | #include 3 | #include 4 | 5 | void BeginIO(struct IORequest *iorequest) 6 | { register struct IORequest *a1 __asm("a1")=iorequest; 7 | register struct Device *a6 __asm("a6")=iorequest->io_Device; 8 | __asm volatile ("jsr a6@(-30:W)" :: "r" (a1), "r" (a6)); 9 | } 10 | #endif 11 | -------------------------------------------------------------------------------- /sources/amiga/misc/FreeIEvents.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | VOID FreeIEvents(struct InputEvent *events) 5 | { APTR SysBase = *(APTR *)4L; 6 | struct InputEvent *next; 7 | 8 | while (events != NULL) { 9 | next = events->ie_NextEvent; 10 | FreeMem(events,sizeof(*events)); 11 | events = next; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /sources/nix/stdio/fgets.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | char *fgets(char *s,int n,FILE *stream) 4 | { char *s2=s; 5 | 6 | while(--n) 7 | { int c=fgetc(stream); 8 | if(c==EOF) 9 | { if(s2==s) 10 | return NULL; 11 | break; 12 | } 13 | *s2++=c; 14 | if(c=='\n') 15 | break; 16 | } 17 | *s2++='\0'; 18 | return s; 19 | } 20 | -------------------------------------------------------------------------------- /sources/nix/string/strpbrk.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | char *strpbrk(const char *s1,const char *s2) 4 | { unsigned char *c1=(unsigned char *)s1; 5 | unsigned char *c2; 6 | while(*c1!='\0') 7 | { c2=(unsigned char *)s2; 8 | while(*c2!='\0') 9 | if(*c1==*c2++) 10 | return (char *)c1; 11 | c1++; 12 | } 13 | return (char *)0; 14 | } 15 | -------------------------------------------------------------------------------- /sources/math/trans/fmod.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static inline double floor(double x) 4 | { return IEEEDPFloor(x); } 5 | 6 | static inline double ceil(double x) 7 | { return IEEEDPCeil(x); } 8 | 9 | double fmod(double x,double y) 10 | { 11 | double a=x/y; 12 | if(a>=0) 13 | return x-y*floor(a); 14 | else 15 | return x-y*ceil(a); 16 | } 17 | -------------------------------------------------------------------------------- /sources/nix/stdio/mblen.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* Sorry, the Amiga OS locale currently doesn't support 4 | * character sets other than ECMA Latin 1, so this is 5 | * just a "C" locale function 6 | */ 7 | int mblen(const char *s,size_t n) 8 | { size_t l=0; 9 | while(n--&&*s++) 10 | l++; 11 | return sizeof(wchar_t)*(l+1); /* 1 for the NUL character */ 12 | } 13 | -------------------------------------------------------------------------------- /sources/nix/stdlib/calloc.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void *calloc(size_t nmemb,size_t size) 4 | { 5 | size_t l; 6 | size_t *a; 7 | void *b; 8 | l=(nmemb*size+(sizeof(size_t)-1))&~(sizeof(size_t)-1); 9 | a=(size_t *)(b=malloc(l)); 10 | if(b!=NULL) 11 | { 12 | do 13 | *a++=0; 14 | while((l-=sizeof(size_t))!=0); 15 | } 16 | return b; 17 | } 18 | -------------------------------------------------------------------------------- /sources/nix/stdio/mbstowcs.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* Sorry, the Amiga OS locale currently doesn't support 4 | * character sets other than ECMA Latin 1, so this is 5 | * just a "C" locale function 6 | */ 7 | size_t mbstowcs(wchar_t *wc,const char *s,size_t n) 8 | { size_t l=0; 9 | while(n--&&*s) 10 | { *wc++=*s++; 11 | l++; } 12 | *wc++='\0'; 13 | return l; 14 | } 15 | -------------------------------------------------------------------------------- /sources/nix/stdio/wcstombs.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* Sorry, the Amiga OS locale currently doesn't support 4 | * character sets other than ECMA Latin 1, so this is 5 | * just a "C" locale function 6 | */ 7 | size_t wcstombs(char *s,const wchar_t *wc,size_t n) 8 | { size_t l=0; 9 | while(n--&&*wc) 10 | { *s++=*wc++; 11 | l++; } 12 | *s++='\0'; 13 | return l; 14 | } 15 | -------------------------------------------------------------------------------- /sources/nix/stdio/vsscanf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int vsscanf(const char *s,const char *format,va_list args) 7 | { FILE buffer; 8 | buffer.p=(char *)s; 9 | buffer.incount=strlen(s); 10 | buffer.outcount=0; 11 | buffer.flags=__SSTR|__SRD; 12 | buffer.tmpp=NULL; 13 | return vfscanf(&buffer,format,args); 14 | } 15 | -------------------------------------------------------------------------------- /sources/stack/stkchk_d0.c: -------------------------------------------------------------------------------- 1 | #include "bases.h" 2 | 3 | asm( 4 | " .text;" 5 | " .even;" 6 | " .globl ___stkchk_d0;" 7 | " .globl ___stkchk_0;" 8 | 9 | "__stkchk_d0:;" 10 | " negl d0;" 11 | " addl sp,d0;" 12 | " cmpl "A4(___stk_limit)",d0;" 13 | " jcs L0;" 14 | " rts;" 15 | 16 | "___stkchk_0:;" 17 | " cmpl "A4(___stk_limit)",sp;" 18 | " jcs L0;" 19 | " rts;" 20 | 21 | "L0: jra ___stkovf;" 22 | ); 23 | -------------------------------------------------------------------------------- /sources/nix/extra/utime.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int utime(const char *file, const struct utimbuf *timep) 5 | { struct timeval times[2],*t=NULL; 6 | 7 | if (timep) { 8 | t = ×[0]; 9 | t[0].tv_sec = timep->actime; 10 | t[0].tv_usec = 0; 11 | t[1].tv_sec = timep->modtime; 12 | t[1].tv_usec = 0; 13 | } 14 | 15 | return utimes(file,t); 16 | } 17 | -------------------------------------------------------------------------------- /sources/amiga/misc/FastRand.c: -------------------------------------------------------------------------------- 1 | #if 1 2 | 3 | #include 4 | 5 | ULONG FastRand(ULONG seed) 6 | { ULONG a=seed<<1; 7 | if((LONG)seed<=0) 8 | a^=0x1d872b41; 9 | return a; 10 | } 11 | 12 | #else 13 | 14 | asm(" 15 | .text 16 | 17 | .globl _FastRand 18 | 19 | _FastRand: movel sp@(4:W),d0 20 | addl d0,d0 21 | bhis L1 22 | eoril #0x1D872B41,d0 23 | L1: rts 24 | "); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /sources/amiga/misc/RangeRand.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | ULONG RangeSeed; 4 | 5 | ULONG RangeRand(ULONG maxValue) 6 | { ULONG a=RangeSeed; 7 | UWORD i=maxValue-1; 8 | do 9 | { ULONG b=a; 10 | a<<=1; 11 | if((LONG)b<=0) 12 | a^=0x1d872b41; 13 | }while((i>>=1)); 14 | RangeSeed=a; 15 | if((UWORD)maxValue) 16 | return (UWORD)((UWORD)a*(UWORD)maxValue>>16); 17 | return (UWORD)a; 18 | } 19 | -------------------------------------------------------------------------------- /sources/headers/rand48.h: -------------------------------------------------------------------------------- 1 | #ifndef _HEADERS_RAND48_H 2 | #define _HEADERS_RAND48_H 3 | 4 | void srand48(long); 5 | unsigned short *seed48(unsigned short *); 6 | void lcong48(unsigned short *); 7 | long lrand48(void); 8 | long nrand48(unsigned short *); 9 | long mrand48(void); 10 | long jrand48(unsigned short *); 11 | double drand48(void); 12 | double erand48(unsigned short *seed); 13 | 14 | #endif /* _HEADERS_RAND48_H */ 15 | -------------------------------------------------------------------------------- /sources/math/trans/atan2.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define PI 3.14159265358979323846 4 | 5 | static inline double atan(double x) 6 | { return IEEEDPAtan(x); } 7 | 8 | double atan2(double y,double x) 9 | { return x>=y?(x>=-y? atan(y/x): -PI/2-atan(x/y)): 10 | (x>=-y? PI/2-atan(x/y):y>=0? PI +atan(y/x): 11 | -PI +atan(y/x)); 12 | } 13 | -------------------------------------------------------------------------------- /sources/headers/debuglib.h: -------------------------------------------------------------------------------- 1 | #ifndef _DEBUGLIB_H 2 | #define _DEBUGLIB_H 3 | 4 | #ifdef DEBUG_LIB 5 | extern int KPrintF(const char *, ...); 6 | #define DB(x) x 7 | #define BUG KPrintF 8 | #define ASSERT(x) { if (!(x)) KPrintF("Assertion failed: " #x " at file " __FILE__ ", line %ld\n", __LINE__); } 9 | #else 10 | #define DB(x) 11 | #define BUG 12 | #define ASSERT(x) 13 | #endif /* DEBUG_LIB */ 14 | 15 | #endif /* _DEBUGLIB_H */ 16 | -------------------------------------------------------------------------------- /sources/nix/stdio/vsprintf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int vsprintf(char *s,const char *format,va_list args) 6 | { int retval; 7 | FILE buffer; 8 | buffer.p=s; 9 | buffer.incount=0; 10 | buffer.outcount=INT_MAX; 11 | buffer.flags=__SSTR|__SWR; 12 | buffer.linebufsize=0; 13 | retval=vfprintf(&buffer,format,args); 14 | fputc('\0',&buffer); 15 | return retval; 16 | } 17 | -------------------------------------------------------------------------------- /sources/nix/extra/fdtofh.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Get the AmigaDOS FileHandle from the filedescriptor. 3 | * Be careful when mixing both kinds of I/O (flush() between changing). 4 | * 5 | * DICE has such a function SAS has not. 6 | * It's not ANSI but it's encapsulated and may be useful - so why not :-). 7 | * 8 | */ 9 | 10 | #include "stdio.h" 11 | 12 | long fdtofh(int filedescriptor) 13 | { return _lx_fhfromfd(filedescriptor)->lx_fh; } 14 | -------------------------------------------------------------------------------- /sources/nix20/math/__udivsi3.c: -------------------------------------------------------------------------------- 1 | #include "bases.h" 2 | 3 | asm( 4 | " .globl ___umodsi3;" 5 | " .globl ___udivsi3;" 6 | 7 | /* D1.L = D0.L % D1.L unsigned */ 8 | 9 | "___umodsi3: moveml sp@(4:W),d0/d1;" 10 | " jbsr ___udivsi4;" 11 | " movel d1,d0;" 12 | " rts;" 13 | 14 | /* D0.L = D0.L / D1.L unsigned */ 15 | 16 | "___udivsi3: moveml sp@(4:W),d0/d1;" 17 | "___udivsi4: movel "A4(_UtilityBase)",a0;" 18 | " jmp a0@(-156:W);" 19 | ); 20 | -------------------------------------------------------------------------------- /sources/nix/extra/mkdir.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "stabs.h" 5 | 6 | extern void __seterrno(void); 7 | 8 | int mkdir(const char *name, mode_t mode) 9 | { 10 | BPTR fl; 11 | int ret; 12 | 13 | if ((fl=CreateDir((STRPTR)name))) 14 | { 15 | UnLock(fl); ret=chmod(name,mode); 16 | } 17 | else 18 | { 19 | __seterrno(); ret=-1; 20 | } 21 | return ret; 22 | } 23 | -------------------------------------------------------------------------------- /sources/nix/extra/truncate.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | int truncate(const char *path, off_t length) { 6 | int retval; 7 | BPTR fd = Open(path, MODE_OLDFILE); 8 | if (fd != NULL) { 9 | retval = (SetFileSize(fd, length, OFFSET_BEGINNING) >= 0) ? 0 : -1; 10 | Close(fd); 11 | } else { 12 | errno = ENOENT; 13 | retval = -1; 14 | } 15 | 16 | return retval; 17 | } 18 | -------------------------------------------------------------------------------- /sources/nix/stdio/remove.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | extern void __seterrno(void); 6 | extern char *__amigapath(const char *path); 7 | 8 | int remove(const char *filename) 9 | { 10 | #ifdef IXPATHS 11 | if((filename=__amigapath(filename))==NULL) 12 | return -1; 13 | #endif 14 | 15 | if(DeleteFile((char *)filename)) 16 | return 0; 17 | else 18 | { __seterrno(); return -1; } 19 | } 20 | -------------------------------------------------------------------------------- /sources/socket/netdb/getnetbyname.c: -------------------------------------------------------------------------------- 1 | #include 2 | // 3 | #include "socket.h" 4 | 5 | struct netent *getnetbyname(const char *name) 6 | { struct SocketSettings *lss; 7 | 8 | switch (lss=_lx_get_socket_settings(),lss->lx_network_type) { 9 | case LX_AS225: 10 | return SOCK_getnetbyname(name); 11 | 12 | case LX_AMITCP: 13 | return TCP_GetNetByName(name); 14 | 15 | default: 16 | return NULL; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /sources/socket/netdb/gethostbyname.c: -------------------------------------------------------------------------------- 1 | #include 2 | // 3 | #include "socket.h" 4 | 5 | struct hostent *gethostbyname(const char *name) 6 | { struct SocketSettings *lss; 7 | 8 | switch (lss=_lx_get_socket_settings(),lss->lx_network_type) { 9 | case LX_AS225: 10 | return SOCK_gethostbyname(name); 11 | 12 | case LX_AMITCP: 13 | return TCP_GetHostByName(name); 14 | 15 | default: 16 | return NULL; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /sources/nix/extra/getcwd.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | extern void __seterrno(); 7 | 8 | char *getcwd(char *buf,size_t size) 9 | { 10 | if (buf!=NULL || (buf=(char *)malloc(size))!=NULL) 11 | { 12 | if (GetCurrentDirName(buf,(ULONG)size)==DOSFALSE) 13 | { 14 | __seterrno(); buf=NULL; 15 | } 16 | } 17 | else 18 | errno=ENOMEM; 19 | return buf; 20 | } 21 | -------------------------------------------------------------------------------- /sources/nix/string/strxfrm.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | extern struct Locale *__localevec[]; 8 | 9 | size_t strxfrm(char *buffer,const char *s,size_t n) 10 | { if (!__localevec[LC_COLLATE-1]) 11 | { strncpy(buffer,s,n); return strlen(s); } 12 | else 13 | return StrConvert(__localevec[LC_COLLATE-1],(char *)s,buffer,n,SC_COLLATE1); 14 | } 15 | -------------------------------------------------------------------------------- /sources/socket/netdb/getnetbyaddr.c: -------------------------------------------------------------------------------- 1 | #include 2 | // 3 | #include "socket.h" 4 | 5 | struct netent *getnetbyaddr(long net, int type) 6 | { struct SocketSettings *lss; 7 | 8 | switch (lss=_lx_get_socket_settings(),lss->lx_network_type) { 9 | case LX_AS225: 10 | return SOCK_getnetbyaddr(net,type); 11 | 12 | case LX_AMITCP: 13 | return TCP_GetNetByAddr(net,type); 14 | 15 | default: 16 | return NULL; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /sources/socket/netdb/getprotobyname.c: -------------------------------------------------------------------------------- 1 | #include 2 | // 3 | #include "socket.h" 4 | 5 | struct protoent *getprotobyname(const char *name) 6 | { struct SocketSettings *lss; 7 | 8 | switch (lss=_lx_get_socket_settings(),lss->lx_network_type) { 9 | case LX_AS225: 10 | return SOCK_getprotobyname(name); 11 | 12 | case LX_AMITCP: 13 | return TCP_GetProtoByName(name); 14 | 15 | default: 16 | return NULL; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /sources/socket/netdb/getprotobynumber.c: -------------------------------------------------------------------------------- 1 | #include 2 | // 3 | #include "socket.h" 4 | 5 | struct protoent *getprotobynumber(int proto) 6 | { struct SocketSettings *lss; 7 | 8 | switch (lss=_lx_get_socket_settings(),lss->lx_network_type) { 9 | case LX_AS225: 10 | return SOCK_getprotobynumber(proto); 11 | 12 | case LX_AMITCP: 13 | return TCP_GetProtoByNumber(proto); 14 | 15 | default: 16 | return NULL; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /sources/nix/stdlib/realloc.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void *realloc(void *ptr,size_t size) 5 | { 6 | void *a; 7 | size_t l; 8 | if(size) 9 | a=malloc(size); 10 | else 11 | a=NULL; 12 | if(ptr!=NULL) 13 | { if(a!=NULL) 14 | { l=((ULONG *)ptr)[-1]-sizeof(ULONG); 15 | l=l 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | extern struct Locale *__localevec[]; 9 | 10 | int strcoll(const char *s1,const char *s2) 11 | { if (!__localevec[LC_COLLATE-1]) 12 | return strcmp(s1,s2); 13 | else 14 | return StrnCmp(__localevec[LC_COLLATE-1],(char *)s1,(char *)s2,LONG_MAX,SC_COLLATE1); 15 | } 16 | -------------------------------------------------------------------------------- /sources/math/extra/frexp.c: -------------------------------------------------------------------------------- 1 | #undef __HAVE_68881__ 2 | #include 3 | 4 | double frexp(double x,int *p) 5 | { 6 | int neg,j; 7 | j=neg=0; 8 | 9 | if(x<0){ 10 | x=-x; 11 | neg=1; 12 | } 13 | if(x>=1){ 14 | while(x>=1){ 15 | j++; 16 | x/=2; 17 | } 18 | }else if(x<0.5&&x!=0){ 19 | while(x<0.5){ 20 | j--; 21 | x*=2; 22 | } 23 | } 24 | *p = j; 25 | if(neg) x=-x; 26 | return x; 27 | } 28 | -------------------------------------------------------------------------------- /sources/nix/signal/signal.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern void (*__signalfunc[])(int); 4 | extern int __signalmask,__signalpending; 5 | 6 | void (*signal(int sig,void (*func)(int)))(int) 7 | { 8 | void (*oldfunc)(int); 9 | if(sig<1||sig>6) 10 | return SIG_ERR; 11 | oldfunc=__signalfunc[sig-1]; 12 | __signalfunc[sig-1]=func; 13 | __signalmask&=~(1<<(sig-1)); 14 | if(__signalpending&(1<<(sig-1))) 15 | raise(sig); 16 | return oldfunc; 17 | } 18 | -------------------------------------------------------------------------------- /sources/nix/string/strcpy.c: -------------------------------------------------------------------------------- 1 | #ifndef mc68000 2 | 3 | #include 4 | 5 | char *strcpy(char *s1,const char *s2) 6 | { char *s=s1; 7 | #if 0 8 | do;while(*s1++=*s2,*s2++!='\0'); 9 | #else 10 | do;while((*s1++=*s2++)); 11 | #endif 12 | return s; 13 | } 14 | 15 | #else 16 | 17 | asm( 18 | " .globl _strcpy;" 19 | "_strcpy:;" 20 | " moveml sp@(4:W),d0/a0;" 21 | " movel d0,a1;" 22 | "L1: moveb a0@+,a1@+;" 23 | " jne L1;" 24 | " rts;" 25 | ); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /sources/nix/string/strcat.c: -------------------------------------------------------------------------------- 1 | #ifndef mc68000 2 | 3 | #include 4 | 5 | char *strcat(char *s1,const char *s2) 6 | { char *s=s1; 7 | 8 | do;while(*s++); --s; do;while((*s++=*s2++)); return s1; 9 | } 10 | 11 | #else 12 | 13 | asm( 14 | " .globl _strcat;" 15 | "_strcat:;" 16 | " movml sp@(4:W),d0/a0;" 17 | " movel d0,a1;" 18 | "L2: tstb a1@+;" 19 | " jne L2;" 20 | " subql #1,a1;" 21 | "L1: moveb a0@+,a1@+;" 22 | " jne L1;" 23 | " rts;" 24 | ); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /sources/socket/netdb/getservbyport.c: -------------------------------------------------------------------------------- 1 | #include 2 | // 3 | #include "socket.h" 4 | 5 | struct servent *getservbyport(int port, const char *proto) 6 | { struct SocketSettings *lss = _lx_get_socket_settings(); 7 | 8 | switch (lss->lx_network_type) { 9 | case LX_AS225: 10 | return SOCK_getservbyport(port,proto); 11 | 12 | case LX_AMITCP: 13 | return TCP_GetServByPort(port,proto); 14 | 15 | default: 16 | return NULL; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /sources/nix/stdio/fflush.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int fflush(FILE *stream) /* fflush one or all files */ 5 | { struct MinNode *node,*nextnode; 6 | int retval; 7 | 8 | if(stream!=NULL) 9 | return __fflush(stream); 10 | retval=0; 11 | node=__filelist.mlh_Head; 12 | while((nextnode=node->mln_Succ)!=NULL) 13 | { if(__fflush(&((struct filenode *)node)->FILE)) 14 | retval=EOF; 15 | node=nextnode; } 16 | return retval; 17 | } 18 | -------------------------------------------------------------------------------- /sources/amiga/misc/CallHook.c: -------------------------------------------------------------------------------- 1 | asm( 2 | " .text;" 3 | 4 | " .globl _CallHook;" 5 | " .globl _CallHookA;" 6 | 7 | "_CallHook: lea sp@(12:W),a1;" 8 | " jra L_CallHook;" 9 | 10 | "_CallHookA: movel sp@(12:W),a1;" 11 | 12 | "L_CallHook: movel a6,sp@-;" 13 | " movel a2,sp@-;" 14 | " movel sp@(12:W),a0;" 15 | " movel sp@(16:W),a2;" 16 | " jbsr L_callit;" 17 | " movel sp@+,a2;" 18 | " movel sp@+,a6;" 19 | " rts;" 20 | 21 | "L_callit: movel a0@(8:W),sp@-;" 22 | " rts;" 23 | ); 24 | -------------------------------------------------------------------------------- /sources/amiga/misc/DoMethod.c: -------------------------------------------------------------------------------- 1 | asm( 2 | " .text;" 3 | 4 | " .globl _DoMethod;" 5 | " .globl _DoMethodA;" 6 | 7 | 8 | "_DoMethod: lea sp@(8:W),a1;" 9 | " jra L_DoMethod;" 10 | 11 | "_DoMethodA: movel sp@(8:W),a1;" 12 | "L_DoMethod: movel sp@(4:W),d0;" 13 | " beqs L_Null;" 14 | " movel a2,sp@-;" 15 | " movel d0,a2;" 16 | " movel a2@(-4:W),a0;" 17 | " jbsr L_Invoke;" 18 | " movel sp@+,a2;" 19 | "L_Null: rts;" 20 | 21 | "L_Invoke: movel a0@(8:W),sp@-;" 22 | " rts;" 23 | ); 24 | -------------------------------------------------------------------------------- /sources/socket/netdb/getservbyname.c: -------------------------------------------------------------------------------- 1 | #include 2 | // 3 | #include "socket.h" 4 | 5 | struct servent *getservbyname(const char *name, const char *proto) 6 | { struct SocketSettings *lss; 7 | 8 | switch (lss=_lx_get_socket_settings(),lss->lx_network_type) { 9 | case LX_AS225: 10 | return SOCK_getservbyname(name,proto); 11 | 12 | case LX_AMITCP: 13 | return TCP_GetServByName(name,proto); 14 | 15 | default: 16 | return NULL; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /sources/socket/netdb/gethostbyaddr.c: -------------------------------------------------------------------------------- 1 | #include 2 | // 3 | #include "socket.h" 4 | 5 | struct hostent *gethostbyaddr(const char *addr, int len, int type) 6 | { struct SocketSettings *lss; 7 | 8 | switch (lss=_lx_get_socket_settings(),lss->lx_network_type) { 9 | case LX_AS225: 10 | return SOCK_gethostbyaddr(addr,len,type); 11 | 12 | case LX_AMITCP: 13 | return TCP_GetHostByAddr(addr,len,type); 14 | 15 | default: 16 | return NULL; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /sources/nix13/math/__mulsi3.c: -------------------------------------------------------------------------------- 1 | asm( 2 | " .globl ___mulsi3;" 3 | 4 | /* D0 = D0 * D1 */ 5 | 6 | "___mulsi3: moveml sp@(4),d0/d1;" 7 | " movel d3,sp@-;" 8 | " movel d2,sp@-;" 9 | " movew d1,d2;" 10 | " mulu d0,d2;" 11 | " movel d1,d3;" 12 | " swap d3;" 13 | " mulu d0,d3;" 14 | " swap d3;" 15 | " clrw d3;" 16 | " addl d3,d2;" 17 | " swap d0;" 18 | " mulu d1,d0;" 19 | " swap d0;" 20 | " clrw d0;" 21 | " addl d2,d0;" 22 | " movel sp@+,d2;" 23 | " movel sp@+,d3;" 24 | " rts;" 25 | ); 26 | -------------------------------------------------------------------------------- /sources/nix20/math/__divsi3.c: -------------------------------------------------------------------------------- 1 | #include "bases.h" 2 | 3 | asm( 4 | " .globl _div;" 5 | " .globl _ldiv;" 6 | " .globl ___modsi3;" 7 | " .globl ___divsi3;" 8 | 9 | /* D1.L = D0.L % D1.L signed */ 10 | 11 | "___modsi3: moveml sp@(4:W),d0/d1;" 12 | " jbsr ___divsi4;" 13 | " movel d1,d0;" 14 | " rts;" 15 | 16 | /* D0.L = D0.L / D1.L signed */ 17 | 18 | "_div:" 19 | "_ldiv:" 20 | "___divsi3: moveml sp@(4:W),d0/d1;" 21 | "___divsi4: movel "A4(_UtilityBase)",a0;" 22 | " jmp a0@(-150:W);" 23 | ); 24 | -------------------------------------------------------------------------------- /sources/amiga/misc/HookEntry.c: -------------------------------------------------------------------------------- 1 | #if 0 2 | 3 | #include 4 | 5 | ULONG HookEntry(struct Hook *hook asm("a0"),APTR obj asm("a2"),APTR msg asm("a1")) 6 | { 7 | return (*hook->h_SubEntry)(hook,obj,msg); 8 | } 9 | 10 | #else 11 | 12 | asm( 13 | " .text;" 14 | 15 | " .globl _HookEntry;" 16 | 17 | "_HookEntry: movel a1,sp@-;" 18 | " movel a2,sp@-;" 19 | " movel a0,sp@-;" 20 | " movel a0@(12:W),a0;" 21 | " jsr a0@;" 22 | " lea sp@(12:W),sp;" 23 | " rts;" 24 | ); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /sources/nix/locale/__localevec.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* This is the vector of Locales for the different locale types. 4 | * Since the default locale is not NULL, NULL means "C" locale. 5 | * This is the default if locale.library could not be opened 6 | * or setlocale is never referenced. 7 | */ 8 | 9 | struct Locale *__localevec[5]= 10 | { NULL,NULL,NULL,NULL,NULL }; 11 | 12 | /* If you need __localevec you need LocaleBase and vice versa. 13 | */ 14 | struct Library *LocaleBase=NULL; 15 | -------------------------------------------------------------------------------- /sources/nix/stdlib/system.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int system(const char *string) 7 | { static struct TagItem notags[]={ { TAG_END,0 } }; 8 | 9 | if(string == NULL) { 10 | errno = EINVAL; 11 | return -1; 12 | } 13 | 14 | if (((struct Library *)DOSBase)->lib_Version >= 36) 15 | return SystemTagList((char *)string, notags); 16 | else 17 | return (int)~Execute((STRPTR)string, 0l, Output()); 18 | } 19 | -------------------------------------------------------------------------------- /sources/nix13/extra/stricmp.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "stabs.h" 4 | 5 | int stricmp(const char *s1,const char *s2) 6 | { unsigned char c1,c2; 7 | int r; 8 | 9 | for(;;) { 10 | c1=*s1++; 11 | if (isupper(c1)) 12 | c1+='a'-'A'; 13 | c2=*s2; 14 | if (isupper(c2)) 15 | c2+='a'-'A'; 16 | if ((r=(char)c1-(char)c2)!=0) 17 | break; 18 | if (!*s2++) 19 | break; 20 | } 21 | return r; 22 | } 23 | 24 | ALIAS(strcasecmp,stricmp); 25 | -------------------------------------------------------------------------------- /sources/stubs/misc/__initcpp.c: -------------------------------------------------------------------------------- 1 | #include "stabs.h" 2 | 3 | typedef void (*func_ptr) (void); 4 | 5 | extern func_ptr __CTOR_LIST__[]; 6 | extern func_ptr __DTOR_LIST__[]; 7 | 8 | void __initcpp() { 9 | func_ptr *p0 = __CTOR_LIST__ + 1; 10 | func_ptr *p; 11 | for (p = p0; *p; p++); 12 | while (p > p0) 13 | (*--p)(); 14 | } 15 | 16 | void __exitcpp() { 17 | func_ptr *p = __DTOR_LIST__ + 1; 18 | while (*p) 19 | (*p++)(); 20 | } 21 | 22 | ADD2INIT(__initcpp,100); 23 | ADD2EXIT(__exitcpp,100); 24 | -------------------------------------------------------------------------------- /sources/amiga/misc/HotKey.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | CxObj *HotKey(STRPTR description,struct MsgPort *port,LONG id) 5 | { CxObj *filter; 6 | 7 | if ((filter=CreateCxObj(CX_FILTER,(LONG)description,NULL))) { 8 | AttachCxObj(filter,CreateCxObj(CX_SEND,(LONG)port,id)); 9 | AttachCxObj(filter,CreateCxObj(CX_TRANSLATE,NULL,NULL)); 10 | if (CxObjError(filter)) { 11 | DeleteCxObjAll(filter); filter=NULL; 12 | } 13 | } 14 | return filter; 15 | } 16 | -------------------------------------------------------------------------------- /sources/nix/stdio/vsnprintf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int vsnprintf(char *s,size_t size,const char *format,va_list args) 5 | { if ((int)size>0) { 6 | int retval; 7 | FILE buffer; 8 | buffer.p=s; 9 | buffer.incount=0; 10 | buffer.outcount=size-1; 11 | buffer.flags=__SSTR|__SWR; 12 | buffer.linebufsize=0; 13 | retval=vfprintf(&buffer,format,args); 14 | buffer.outcount++; 15 | fputc('\0',&buffer); 16 | return retval; 17 | } 18 | return EOF; 19 | } 20 | -------------------------------------------------------------------------------- /sources/amiga/misc/SetSuperAttrs.c: -------------------------------------------------------------------------------- 1 | asm( 2 | " .text;" 3 | 4 | " .globl _SetSuperAttrs;" 5 | 6 | "_SetSuperAttrs: movel a2,sp@-;" 7 | " moveml sp@(8:W),a0/a2;" 8 | " movel a2,d0;" 9 | " beqs L_Null;" 10 | " movel a0,d0;" 11 | " beqs L_Null;" 12 | " clrl sp@-;" 13 | " pea sp@(20:W);" 14 | " pea 259:W;" 15 | " movel sp,a1;" 16 | " movel sp@(24:W),a0;" 17 | " jbsr L_Invoke;" 18 | " lea sp@(12:W),sp;" 19 | "L_Null: movel sp@+,a2;" 20 | " rts;" 21 | 22 | "L_Invoke: movel a0@(8:W),sp@-;" 23 | " rts;" 24 | ); 25 | -------------------------------------------------------------------------------- /sources/nix/setjmp/longjmp.c: -------------------------------------------------------------------------------- 1 | asm( 2 | " .text;" 3 | " .even;" 4 | " .globl _longjmp;" 5 | 6 | "_longjmp:;" 7 | " addql #4,sp;" /* returns to another address */ 8 | " movel sp@+,a0;" /* get address of jmp_buf */ 9 | " movel sp@+,d0;" /* get returncode */ 10 | " jne l0;" /* != 0 -> ok */ 11 | " moveql #1,d0;" 12 | "l0: movel a0@(48:W),sp;" /* restore sp */ 13 | " movel a0@+,sp@;" /* set returnaddress */ 14 | " moveml a0@,d2-d7/a2-a6;" /* restore all registers except scratch and sp */ 15 | " rts;" 16 | ); 17 | -------------------------------------------------------------------------------- /sources/stack/link_a5_0_f.c: -------------------------------------------------------------------------------- 1 | #include "bases.h" 2 | 3 | asm( 4 | " .text;" 5 | " .even;" 6 | " .globl ___link_a5_0_f;" 7 | " .globl ___sub_0_sp_f;" 8 | 9 | "___link_a5_0_f:" 10 | " movel sp@+,a0;" 11 | " cmpl "A4(___stk_limit)",sp;" 12 | " jcc l0;" 13 | " jbsr l2;" 14 | "l0: link a5,#0:W;" 15 | " jmp a0@;" 16 | 17 | "___sub_0_sp_f:" 18 | " movel sp@+,a0;" 19 | " cmpl "A4(___stk_limit)",sp;" 20 | " jcc l1;" 21 | " jbsr l2;" 22 | "l1: jmp a0@;" 23 | 24 | "l2: moveq #0,d0;" 25 | " moveq #0,d1;" 26 | " jra ___stkext_f;" 27 | ); 28 | -------------------------------------------------------------------------------- /sources/amiga/misc/CoerceMethod.c: -------------------------------------------------------------------------------- 1 | asm( 2 | " .text;" 3 | 4 | " .globl _CoerceMethod;" 5 | " .globl _CoerceMethodA;" 6 | 7 | "_CoerceMethod: lea sp@(12:W),a1;" 8 | " jra L_CoerceMethod;" 9 | 10 | "_CoerceMethodA: movel sp@(12:W),a1;" 11 | 12 | "L_CoerceMethod: movel a2,sp@-;" 13 | " moveml sp@(8:W),a0/a2;" 14 | " movel a0,d0;" 15 | " beqs L_Null;" 16 | " movel a2,d0;" 17 | " beqs L_Null;" 18 | " jbsr L_Invoke;" 19 | "L_Null: movel sp@+,a2;" 20 | " rts;" 21 | 22 | "L_Invoke: movel a0@(8:W),sp@-;" 23 | " rts;" 24 | ); 25 | -------------------------------------------------------------------------------- /sources/socket/socket/obtain_socket.c: -------------------------------------------------------------------------------- 1 | #include "socket.h" 2 | 3 | int obtain_socket(long id, int inet, int stream, int protocol) 4 | { struct SocketSettings *lss; 5 | int rc; 6 | 7 | switch (lss=_lx_get_socket_settings(),lss->lx_network_type) { 8 | case LX_AS225: 9 | rc = SOCK_inherit((void *)id); 10 | break; 11 | 12 | case LX_AMITCP: 13 | rc = TCP_ObtainSocket(id, inet, stream, protocol); 14 | break; 15 | 16 | default: 17 | rc = -1; 18 | break; 19 | } 20 | 21 | return rc; 22 | } 23 | -------------------------------------------------------------------------------- /sources/nix/stdio/ftell.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | long ftell(FILE *stream) 6 | { long pos; 7 | if(stream->flags&__SERR) /* Error on stream */ 8 | { errno=EPERM; 9 | return EOF; } 10 | if((pos=lseek(stream->file,0,SEEK_CUR))==EOF) 11 | { stream->flags|=__SERR; 12 | return pos; } 13 | if(stream->flags&__SRD) 14 | pos-=stream->incount+(stream->tmpp!=NULL?stream->tmpinc:0); 15 | else if(stream->flags&__SWR) 16 | pos+=stream->p-stream->buffer; 17 | return pos; 18 | } 19 | -------------------------------------------------------------------------------- /sources/nix/time/clock.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "stabs.h" 6 | 7 | static struct DateStamp ds; 8 | 9 | void __initclock(void) 10 | { DateStamp(&ds); } 11 | 12 | ADD2INIT(__initclock,-10); 13 | 14 | clock_t clock(void) 15 | { struct DateStamp ds2; 16 | DateStamp(&ds2); 17 | return (((ds2.ds_Days-ds.ds_Days)*(24*60)+ 18 | ds2.ds_Minute-ds.ds_Minute)*(60*TICKS_PER_SECOND)+ 19 | ds2.ds_Tick-ds.ds_Tick)*CLOCKS_PER_SEC/TICKS_PER_SECOND; 20 | } 21 | -------------------------------------------------------------------------------- /sources/stack/longjmp.c: -------------------------------------------------------------------------------- 1 | asm( 2 | " .text;" 3 | " .even;" 4 | " .globl _longjmp;" 5 | 6 | "_longjmp:" 7 | " addql #4,sp;" /* returns to another address */ 8 | " movel sp@+,a0;" /* get address of jmp_buf */ 9 | " movel sp@+,d2;" /* get returncode */ 10 | " movel a0@(48:W),d0;" 11 | " jbsr ___stkrst;" /* restore sp */ 12 | " movel d2,d0;" 13 | " jne l0;" /* != 0 -> ok */ 14 | " moveql #1,d0;" 15 | "l0: movel a0@+,sp@;" /* set returnaddress */ 16 | " moveml a0@,#0x7cfc;" /* restore all registers except scratch and sp */ 17 | " rts" 18 | ); 19 | -------------------------------------------------------------------------------- /sources/stack/sub_d0_sp.c: -------------------------------------------------------------------------------- 1 | #include "bases.h" 2 | #include "stabs.h" 3 | 4 | asm( 5 | " .text;" 6 | " .even;" 7 | " .globl ___sub_d0_sp;" 8 | " .globl ___unlk_a5_rts;" 9 | 10 | "___sub_d0_sp:;" 11 | " movel sp@+,a0;" 12 | " movel sp,d1;" 13 | " subl d0,d1;" 14 | " cmpl "A4(___stk_limit)",d1;" 15 | " jcc l0;" 16 | " jbsr ___stkext;" 17 | "l0: subl d0,sp;" 18 | " jmp a0@;" 19 | 20 | "___unlk_a5_rts:;" 21 | " movel d0,a0;" 22 | " movel a5,d0;" 23 | " jbsr ___stkrst;" 24 | " movel a0,d0;" 25 | " movel sp@+,a5;" 26 | " rts;" 27 | ); 28 | 29 | ALIAS(__move_d0_sp,__stkrst); 30 | -------------------------------------------------------------------------------- /sources/nix/extra/access.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | extern void __seterrno(void); 7 | extern char *__amigapath(const char *path); 8 | 9 | int access (const char *name,int mode) 10 | { BPTR lock; 11 | 12 | #ifdef IXPATHS 13 | if((name=__amigapath(name))==NULL) 14 | return -1; 15 | #endif 16 | 17 | lock=Lock((char *)name,mode&(O_WRONLY|O_RDWR)?ACCESS_WRITE:ACCESS_READ); 18 | if(lock!=0l) 19 | { UnLock(lock); 20 | return 0; 21 | }else 22 | { __seterrno(); 23 | return -1; } 24 | } 25 | -------------------------------------------------------------------------------- /sources/nix/stdio/tmpfile.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | /* NOTE: NOT thread-safe */ 6 | FILE *tmpfile(void) 7 | { 8 | char *name = malloc(PATH_MAX); 9 | FILE *file; 10 | 11 | if (name == NULL) 12 | goto error; 13 | 14 | if (tmpnam(name) == NULL) { 15 | goto error; 16 | } 17 | 18 | file = fopen(name,"w+b"); 19 | if (file == NULL) 20 | goto error; 21 | 22 | file->name = name; 23 | return file; 24 | error: 25 | if (name != NULL) 26 | free(name); 27 | 28 | return NULL; 29 | } 30 | -------------------------------------------------------------------------------- /sources/socket/unistd/gethostid.c: -------------------------------------------------------------------------------- 1 | #include 2 | // 3 | #include "socket.h" 4 | 5 | long gethostid(void) 6 | { struct SocketSettings *lss; 7 | char hostname[MAXPATHLEN]; 8 | struct hostent *ht; 9 | 10 | switch (lss=_lx_get_socket_settings(),lss->lx_network_type) { 11 | case LX_AS225: 12 | gethostname(hostname,MAXPATHLEN); 13 | if ((ht=SOCK_gethostbyname(hostname))) 14 | return (long)ht->h_addr; 15 | return 0; 16 | 17 | case LX_AMITCP: 18 | return (long)TCP_GetHostId(); 19 | 20 | default: 21 | return -1; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /sources/amiga/misc/DoSuperMethod.c: -------------------------------------------------------------------------------- 1 | asm( 2 | " .text;" 3 | 4 | " .globl _DoSuperMethod;" 5 | " .globl _DoSuperMethodA;" 6 | 7 | 8 | "_DoSuperMethod: lea sp@(12:W),a1;" 9 | " jra L_DoSuperMethod;" 10 | 11 | "_DoSuperMethodA:" 12 | " movel sp@(12:W),a1;" 13 | 14 | "L_DoSuperMethod:" 15 | " movel a2,sp@-;" 16 | " moveml sp@(8:W),a0/a2;" 17 | " movel a2,d0;" 18 | " beqs L_Null;" 19 | " movel a0,d0;" 20 | " beqs L_Null;" 21 | " movel a0@(24:W),a0;" 22 | " jbsr L_Invoke;" 23 | "L_Null: movel sp@+,a2;" 24 | " rts;" 25 | 26 | "L_Invoke: movel a0@(8:W),sp@-;" 27 | " rts;" 28 | ); 29 | -------------------------------------------------------------------------------- /sources/socket/socket/shutdown.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | // 4 | #include "socket.h" 5 | 6 | int shutdown(int s, int how) 7 | { struct SocketSettings *lss; 8 | StdFileDes *fp = _lx_fhfromfd(s); 9 | int rc; 10 | 11 | switch (lss=_lx_get_socket_settings(),lss->lx_network_type) { 12 | case LX_AS225: 13 | rc = SOCK_shutdown(fp->lx_sock,how); 14 | break; 15 | 16 | case LX_AMITCP: 17 | rc = TCP_ShutDown(fp->lx_sock,how); 18 | break; 19 | 20 | default: 21 | rc = 0; 22 | break; 23 | } 24 | 25 | return rc; 26 | } 27 | -------------------------------------------------------------------------------- /sources/nix13/extra/strnicmp.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "stabs.h" 4 | 5 | int strnicmp(const char *s1,const char *s2,size_t len) 6 | { unsigned char c1,c2; 7 | int r; 8 | 9 | if ((r=(int)len)) 10 | for(;;) { 11 | c1=*s1++; 12 | if (isupper(c1)) 13 | c1+='a'-'A'; 14 | c2=*s2; 15 | if (isupper(c2)) 16 | c2+='a'-'A'; 17 | if ((r=(char)c1-(char)c2)!=0) 18 | break; 19 | if (!*s2++) 20 | break; 21 | if (!--len) 22 | break; 23 | } 24 | return r; 25 | } 26 | 27 | ALIAS(strncasecmp,strnicmp); 28 | -------------------------------------------------------------------------------- /examples/helloworld.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int __nocommandline=1; /* Disable commandline parsing */ 7 | int __initlibraries=0; /* Disable auto-library-opening */ 8 | 9 | struct DosLibrary *DOSBase=NULL; 10 | 11 | extern struct WBStartup *_WBenchMsg; 12 | 13 | int main(void) 14 | { if(_WBenchMsg==NULL) 15 | { if((DOSBase=(struct DosLibrary *)OpenLibrary("dos.library",33))!=NULL) 16 | { Write(Output(),"Hello world\n",12); 17 | CloseLibrary((struct Library *)DOSBase); } } 18 | return 0; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /sources/nix/stdio/tmpnam.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | static char namebuffer[34]; 8 | 9 | char *tmpnam(char *s) 10 | { BPTR filelock; 11 | static unsigned long filecount=0; 12 | if(s==NULL) 13 | s=namebuffer; 14 | do /* generate a filename that doesn't exist */ 15 | { sprintf(s,"T:tempfile_2_%p_%lu",FindTask(NULL),filecount++); 16 | filelock=Lock(s,ACCESS_WRITE); 17 | if(filelock!=0) 18 | UnLock(filelock); 19 | }while(filelock!=0||IoErr()==ERROR_OBJECT_IN_USE); 20 | return s; 21 | } 22 | -------------------------------------------------------------------------------- /sources/nix/time/time.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | extern long __gmtoffset; 6 | 7 | time_t time(time_t *tloc) 8 | { struct DateStamp t; 9 | time_t ti; 10 | DateStamp(&t); /* Get timestamp */ 11 | ti=((t.ds_Days+2922)*1440+t.ds_Minute+__gmtoffset)*60+ 12 | t.ds_Tick/TICKS_PER_SECOND; 13 | if(tloc!=NULL) 14 | *tloc=ti; 15 | return ti; 16 | } 17 | 18 | /* 19 | * 2922 is the number of days between 1.1.1970 and 1.1.1978 (2 leap years and 6 normal) 20 | * 1440 is the number of minutes per day 21 | * 60 is the number of seconds per minute 22 | */ 23 | -------------------------------------------------------------------------------- /sources/socket/socket/recv.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | // 4 | #include "socket.h" 5 | 6 | int recv(int s, void *buf, size_t len, int flags) 7 | { struct SocketSettings *lss; 8 | StdFileDes *fp = _lx_fhfromfd(s); 9 | int rc; 10 | 11 | switch (lss=_lx_get_socket_settings(),lss->lx_network_type) { 12 | case LX_AS225: 13 | rc = SOCK_recv(fp->lx_sock,buf,len,flags); 14 | break; 15 | 16 | case LX_AMITCP: 17 | rc = TCP_Recv(fp->lx_sock,buf,len,flags); 18 | break; 19 | 20 | default: 21 | rc = -1; 22 | break; 23 | } 24 | 25 | return rc; 26 | } 27 | -------------------------------------------------------------------------------- /sources/socket/socket/recvmsg.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | // 4 | #include "socket.h" 5 | 6 | int recvmsg(int s, struct msghdr *msg, int flags) 7 | { struct SocketSettings *lss; 8 | StdFileDes *fp = _lx_fhfromfd(s); 9 | int rc; 10 | 11 | switch (lss=_lx_get_socket_settings(),lss->lx_network_type) { 12 | case LX_AS225: 13 | rc = SOCK_recvmsg(fp->lx_sock,msg,flags); 14 | break; 15 | 16 | case LX_AMITCP: 17 | rc = TCP_RecvMsg(fp->lx_sock,msg,flags); 18 | break; 19 | 20 | default: 21 | rc = -1; 22 | break; 23 | } 24 | 25 | return rc; 26 | } 27 | -------------------------------------------------------------------------------- /sources/socket/socket/send.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | // 4 | #include "socket.h" 5 | 6 | int send(int s, const void *buf, size_t len, int flags) 7 | { struct SocketSettings *lss; 8 | StdFileDes *fp = _lx_fhfromfd(s); 9 | int rc; 10 | 11 | switch (lss=_lx_get_socket_settings(),lss->lx_network_type) { 12 | case LX_AS225: 13 | rc = SOCK_send(fp->lx_sock,buf,len,flags); 14 | break; 15 | 16 | case LX_AMITCP: 17 | rc = TCP_Send(fp->lx_sock,buf,len,flags); 18 | break; 19 | 20 | default: 21 | rc = -1; 22 | break; 23 | } 24 | 25 | return rc; 26 | } 27 | -------------------------------------------------------------------------------- /sources/socket/socket/sendmsg.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | // 4 | #include "socket.h" 5 | 6 | int sendmsg(int s, const struct msghdr *msg, int flags) 7 | { struct SocketSettings *lss; 8 | StdFileDes *fp = _lx_fhfromfd(s); 9 | int rc; 10 | 11 | switch (lss=_lx_get_socket_settings(),lss->lx_network_type) { 12 | case LX_AS225: 13 | rc = SOCK_sendmsg(fp->lx_sock,msg,flags); 14 | break; 15 | 16 | case LX_AMITCP: 17 | rc = TCP_SendMsg(fp->lx_sock,msg,flags); 18 | break; 19 | 20 | default: 21 | rc = -1; 22 | break; 23 | } 24 | 25 | return rc; 26 | } 27 | -------------------------------------------------------------------------------- /sources/stack/link_a5_d0_f.c: -------------------------------------------------------------------------------- 1 | #include "bases.h" 2 | 3 | asm( 4 | " .text;" 5 | " .even;" 6 | " .globl ___link_a5_d0_f;" 7 | " .globl ___sub_d0_sp_f;" 8 | 9 | "___link_a5_d0_f:" 10 | " movel sp@+,a0;" 11 | " movel sp,d1;" 12 | " subl d0,d1;" 13 | " cmpl "A4(___stk_limit)",d1;" 14 | " jcc l0;" 15 | " jbsr l2;" 16 | "l0: link a5,#0:W;" 17 | " subl d0,sp;" 18 | " jmp a0@;" 19 | 20 | "___sub_d0_sp_f:" 21 | " movel sp@+,a0;" 22 | " movel sp,d1;" 23 | " subl d0,d1;" 24 | " cmpl "A4(___stk_limit)",d1;" 25 | " jcc l1;" 26 | " jbsr l2;" 27 | "l1: subl d0,sp;" 28 | " jmp a0@;" 29 | 30 | "l2: moveq #0,d1;" 31 | " jra ___stkext_f;" 32 | ); 33 | -------------------------------------------------------------------------------- /sources/socket/socket/getpeername.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | // 4 | #include "socket.h" 5 | 6 | int getpeername(int s, struct sockaddr *asa, int *alen) 7 | { struct SocketSettings *lss; 8 | StdFileDes *fp = _lx_fhfromfd(s); 9 | int rc; 10 | 11 | switch (lss=_lx_get_socket_settings(),lss->lx_network_type) { 12 | case LX_AS225: 13 | rc = SOCK_getpeername(fp->lx_sock,asa,alen); 14 | break; 15 | 16 | case LX_AMITCP: 17 | rc = TCP_GetPeerName(fp->lx_sock,asa,alen); 18 | break; 19 | 20 | default: 21 | rc = -1; 22 | break; 23 | } 24 | 25 | return rc; 26 | } 27 | -------------------------------------------------------------------------------- /sources/socket/socket/getsockname.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | // 4 | #include "socket.h" 5 | 6 | int getsockname(int s, struct sockaddr *asa, int *alen) 7 | { struct SocketSettings *lss; 8 | StdFileDes *fp = _lx_fhfromfd(s); 9 | int rc; 10 | 11 | switch (lss=_lx_get_socket_settings(),lss->lx_network_type) { 12 | case LX_AS225: 13 | rc = SOCK_getsockname(fp->lx_sock,asa,alen); 14 | break; 15 | 16 | case LX_AMITCP: 17 | rc = TCP_GetSockName(fp->lx_sock,asa,alen); 18 | break; 19 | 20 | default: 21 | rc = -1; 22 | break; 23 | } 24 | 25 | return rc; 26 | } 27 | -------------------------------------------------------------------------------- /sources/nix/stdio/__stdio.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "stabs.h" 5 | 6 | static FILE *__files[3]; 7 | 8 | FILE **__sF=__files; /* stdin, stdout, stderr */ 9 | 10 | void __initstdfio(void) 11 | { FILE **f=__sF, *err; 12 | 13 | if(((*f++=fdopen(STDIN_FILENO,"r"))==NULL)|| 14 | ((*f++=fdopen(STDOUT_FILENO,"w"))==NULL)|| 15 | ((*f=err=fdopen(STDERR_FILENO,"w"))==NULL)) 16 | exit(20); 17 | free(err->buffer); 18 | err->flags&=~(__SMBF|__SLBF); err->flags|=__SNBF; 19 | err->buffer=NULL; 20 | } 21 | 22 | /* Call our private constructor */ 23 | ADD2INIT(__initstdfio,-20); 24 | -------------------------------------------------------------------------------- /sources/nix/string/strncpy.c: -------------------------------------------------------------------------------- 1 | #ifndef mc68000 2 | 3 | #include 4 | 5 | char *strncpy(char *s1,const char *s2,size_t n) 6 | { 7 | if (n) { 8 | char *s=s1; 9 | do;while((*s++=*s2++) && --n); 10 | if (n) 11 | while(--n) *s++=0; 12 | } 13 | return s1; 14 | } 15 | 16 | #else 17 | 18 | asm( 19 | " .globl _strncpy;" 20 | "_strncpy:;" 21 | " moveml sp@(4:W),d0/a0;" 22 | " movel d0,a1;" 23 | " movel sp@(12:W),d1;" 24 | "L4: subql #1,d1;" 25 | " bcs L1;" 26 | " moveb a0@+,a1@+;" 27 | " bne L4;" 28 | " .word 0x0c40;" 29 | "L3: clrb a1@+;" 30 | " subql #1,d1;" 31 | " bcc L3;" 32 | "L1: rts;" 33 | ); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /sources/nix/extra/mktemp.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | char *mktemp(char *buf) 6 | { long pid = (long)FindTask(0L); 7 | char *c = buf; 8 | 9 | while(*c++); --c; 10 | 11 | while(*--c == 'X') { 12 | *c = pid % 10 + '0'; 13 | pid /= 10; 14 | } 15 | 16 | if (++c,*c) { 17 | for(*c='A'; *c <= 'Z'; (*c)++) { 18 | if (access(buf,0)) { 19 | return buf; 20 | } 21 | } 22 | *c = 0; 23 | } 24 | 25 | return buf; 26 | } 27 | 28 | int mkstemp(char *template) { 29 | char *buf = mktemp(template); 30 | return open(buf, O_CREAT | O_TRUNC | O_EXCL); 31 | } 32 | -------------------------------------------------------------------------------- /sources/nix/stdio/fseek.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int fseek(FILE *stream,long int offset,int whence) 6 | { 7 | if(stream->flags&__SERR) /* Error on stream */ 8 | { errno=EPERM; 9 | return EOF; } 10 | if(stream->flags&__SWR) 11 | if(__fflush(stream)) 12 | return EOF; 13 | if(whence==SEEK_CUR) 14 | offset-=stream->incount+(stream->tmpp!=NULL?stream->tmpinc:0); 15 | stream->incount=0; 16 | stream->tmpp=NULL; 17 | stream->flags&=~(__SEOF|__SRD); 18 | if(lseek(stream->file,offset,whence)==EOF) 19 | { stream->flags|=__SERR; 20 | return EOF; } 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /sources/stack/stkrst_f.c: -------------------------------------------------------------------------------- 1 | #include "bases.h" 2 | 3 | asm( 4 | " .text;" 5 | " .even;" 6 | " .globl ___stkrst_f;" 7 | 8 | "___stkrst_f:;" 9 | " movel a2,sp@-;" 10 | " moveml #0xc0c2,sp@-;" /* Preserve all registers; */ 11 | " movel sp,a2;" 12 | " lea "A4(___used_stack)",a1;" /* Move current stackframe to the spares list */ 13 | " movel a1@,a0;" 14 | " movel a0@,a1@+;" 15 | " movel a1@,a0@;" 16 | " movel a0,a1@;" 17 | " addql #4,a0;" /* Return to old stackframe */ 18 | " movel a0@(12:W),"A4(___stk_limit)";" 19 | " movel "A4(_SysBase)",a6;" 20 | " jsr a6@(-0x2dc);" /* StackSwap(sss:a0) */ 21 | " moveml a2@+,#0x4303;" 22 | " movel a2@,a2;" 23 | " rts;" 24 | ); 25 | -------------------------------------------------------------------------------- /sources/nix/stdlib/getenv.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | char *getenv(const char *name) 7 | { static char *var=NULL; 8 | size_t len,i=0; 9 | do 10 | { i+=256; 11 | if(var!=NULL) /* free old buffer */ 12 | free(var); 13 | var=malloc(i); /* and get a new one */ 14 | if(var==NULL) /* Oh, dear */ 15 | return NULL; 16 | len=GetVar((char *)name,var,i,GVF_BINARY_VAR)+1; 17 | }while(len>=i); /* just to be sure we got everything, we _require_ 1 unused byte */ 18 | if(len==0) /* Variable doesn't exist */ 19 | return NULL; 20 | else 21 | return var; 22 | } 23 | -------------------------------------------------------------------------------- /sources/socket/socket/getsockopt.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | // 4 | #include "socket.h" 5 | 6 | int getsockopt(int s, int level, int name, void *val, int *valsize) 7 | { struct SocketSettings *lss; 8 | StdFileDes *fp = _lx_fhfromfd(s); 9 | int rc; 10 | 11 | switch (lss=_lx_get_socket_settings(),lss->lx_network_type) { 12 | case LX_AS225: 13 | rc = SOCK_getsockopt(fp->lx_sock,level,name,val, valsize); 14 | break; 15 | 16 | case LX_AMITCP: 17 | rc = TCP_GetSockOpt(fp->lx_sock,level,name,val, valsize); 18 | break; 19 | 20 | default: 21 | rc = 0; 22 | break; 23 | } 24 | 25 | return rc; 26 | } 27 | -------------------------------------------------------------------------------- /sources/socket/socket/listen.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | // 4 | #include "socket.h" 5 | 6 | int listen(int s, int backlog) 7 | { struct SocketSettings *lss; 8 | register StdFileDes *fp; 9 | int rc; 10 | 11 | if ((fp=_lx_fhfromfd(s))) { 12 | switch (lss=_lx_get_socket_settings(),lss->lx_network_type) { 13 | case LX_AS225: 14 | rc = SOCK_listen(fp->lx_sock, backlog); 15 | break; 16 | 17 | case LX_AMITCP: 18 | rc = TCP_Listen(fp->lx_sock, backlog); 19 | break; 20 | 21 | default: 22 | rc = -1; 23 | break; 24 | } 25 | } 26 | else rc = -1; 27 | 28 | return rc; 29 | } 30 | -------------------------------------------------------------------------------- /sources/nix/misc/__request.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | extern char __intuitionname[]; 6 | 7 | void __request(const char *msg) 8 | { 9 | APTR IntuitionBase, SysBase=*(APTR *)4L; 10 | static struct IntuiText body = { 0,0,0, 15,5, NULL, NULL, NULL }; 11 | static struct IntuiText ok = { 0,0,0, 6,3, NULL, "Ok", NULL }; 12 | 13 | if (((struct Process *)FindTask(NULL))->pr_WindowPtr != (APTR)-1L) { 14 | if ((IntuitionBase=OpenLibrary(__intuitionname,0))) { 15 | body.IText = (UBYTE *)msg; 16 | AutoRequest(NULL,&body,NULL,&ok,0,0,640,72); 17 | CloseLibrary(IntuitionBase); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /sources/nix/stdlib/bsearch.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /* sample compar function: int cmp(void *a,void *b){ return *(int *)a-*(int *)b; } */ 5 | 6 | void *bsearch 7 | (const void *key,const void *base,size_t nmemb,size_t size, 8 | int (*compar)(const void *,const void *)) 9 | { char *base2=(char *)base; 10 | size_t a=0; 11 | size_t b=nmemb; 12 | size_t c; 13 | int d; 14 | if(nmemb!=0) 15 | for(;;) 16 | { c=(a+b)/2; 17 | if((d=(*compar)(key,&base2[size*c]))==0) 18 | return &base2[size*c]; 19 | if(c==a) 20 | break; 21 | if(d<0) 22 | b=c; 23 | else 24 | a=c; 25 | } 26 | return NULL; 27 | } 28 | -------------------------------------------------------------------------------- /sources/socket/socket/recfrom.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | // 4 | #include "socket.h" 5 | 6 | int recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, int *fromlen) 7 | { struct SocketSettings *lss; 8 | StdFileDes *fp = _lx_fhfromfd(s); 9 | int rc; 10 | 11 | switch (lss=_lx_get_socket_settings(),lss->lx_network_type) { 12 | case LX_AS225: 13 | rc = SOCK_recvfrom(fp->lx_sock,buf,len,flags, from, fromlen); 14 | break; 15 | 16 | case LX_AMITCP: 17 | rc = TCP_RecvFrom(fp->lx_sock,buf,len,flags, from, fromlen); 18 | break; 19 | 20 | default: 21 | rc = -1; 22 | break; 23 | } 24 | 25 | return rc; 26 | } 27 | -------------------------------------------------------------------------------- /sources/socket/socket/setsockopt.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | // 4 | #include "socket.h" 5 | 6 | int setsockopt(int s, int level, int name, const void *val, int valsize) 7 | { struct SocketSettings *lss = _lx_get_socket_settings(); 8 | StdFileDes *fp = _lx_fhfromfd(s); 9 | int rc; 10 | 11 | switch (lss=_lx_get_socket_settings(),lss->lx_network_type) { 12 | case LX_AS225: 13 | rc = SOCK_setsockopt(fp->lx_sock,level,name,val, valsize); 14 | break; 15 | 16 | case LX_AMITCP: 17 | rc = TCP_SetSockOpt(fp->lx_sock,level,name,val, valsize); 18 | break; 19 | 20 | default: 21 | rc = 0; 22 | break; 23 | } 24 | 25 | return rc; 26 | } 27 | -------------------------------------------------------------------------------- /sources/nix/string/strncat.c: -------------------------------------------------------------------------------- 1 | #ifndef mc68000 2 | 3 | #include 4 | 5 | char *strncat(char *s1,const char *s2,size_t n) 6 | { 7 | if (n) { 8 | char *s=s1; 9 | do;while(*s++); --s; 10 | for(;;) { 11 | if (!(*s++=*s2++)) 12 | break; 13 | if (!--n) { 14 | *s=0; break; 15 | } 16 | } 17 | } 18 | return s1; 19 | } 20 | 21 | #else 22 | 23 | asm( 24 | " .globl _strncat;" 25 | "_strncat:;" 26 | " moveml sp@(4:W),d0/a0;" 27 | " movel d0,a1;" 28 | " movel sp@(12),d1;" 29 | " jeq L1;" 30 | "L3: tstb a1@+;" 31 | " jne L3;" 32 | " subql #1,a1;" 33 | "L2: moveb a0@+,a1@+;" 34 | " jeq L1;" 35 | " subql #1,d1;" 36 | " jne L2;" 37 | " clrb a1@;" 38 | "L1: rts;" 39 | ); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /sources/nix/stdlib/strtol.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | signed long strtol(const char *nptr,char **endptr,int base) 8 | { const char *p=nptr; 9 | char *q; 10 | unsigned long r; 11 | while(isspace(*p)) 12 | p++; 13 | r=strtoul(p,&q,base); 14 | if(endptr!=NULL) 15 | { if(q==p) 16 | *endptr=(char *)nptr; 17 | else 18 | *endptr=q; 19 | } 20 | if(*p=='-') 21 | { if((signed long)r>0) 22 | { errno=ERANGE; 23 | return LONG_MIN; } 24 | else 25 | return r; 26 | }else 27 | { if((signed long)r<0) 28 | { errno=ERANGE; 29 | return LONG_MAX; } 30 | else 31 | return r; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /mkinstalldirs: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # mkinstalldirs --- make directory hierarchy 3 | # Author: Noah Friedman 4 | # Created: 1993-05-16 5 | # Last modified: 1994-03-25 6 | # Public domain 7 | 8 | errstatus=0 9 | 10 | for file in ${1+"$@"} ; do 11 | set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` 12 | shift 13 | 14 | pathcomp= 15 | for d in ${1+"$@"} ; do 16 | pathcomp="$pathcomp$d" 17 | case "$pathcomp" in 18 | -* ) pathcomp=./$pathcomp ;; 19 | esac 20 | 21 | if test ! -d "$pathcomp"; then 22 | echo "mkdir $pathcomp" 1>&2 23 | mkdir "$pathcomp" || errstatus=$? 24 | fi 25 | 26 | pathcomp="$pathcomp/" 27 | done 28 | done 29 | 30 | exit $errstatus 31 | -------------------------------------------------------------------------------- /sources/socket/unistd/getdomainname.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | // 4 | #include "socket.h" 5 | 6 | static inline int tcp_getdomainname(char *domainname, int dsize) 7 | { char hname[MAXHOSTNAMELEN+1], *dn; 8 | 9 | gethostname(hname, MAXHOSTNAMELEN); 10 | strncpy(domainname, (dn=strchr(hname,'.')) ? dn+1 : hname, dsize-1); 11 | domainname[dsize-1] = '\0'; return 0; 12 | } 13 | 14 | int getdomainname(char *name, int namelen) 15 | { struct SocketSettings *lss = _lx_get_socket_settings(); 16 | 17 | switch (lss->lx_network_type) { 18 | case LX_AMITCP: 19 | return tcp_getdomainname(name, namelen); 20 | 21 | case LX_AS225: 22 | return SOCK_getdomainname(name, namelen); 23 | 24 | default: 25 | return -1; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /sources/socket/socket/connect.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | // 4 | #include "socket.h" 5 | 6 | int connect(int s, const struct sockaddr *name, int namelen) 7 | { struct SocketSettings *lss; 8 | StdFileDes *fp = _lx_fhfromfd(s); 9 | int oldlen,rc; 10 | 11 | switch (lss=_lx_get_socket_settings(),lss->lx_network_type) { 12 | case LX_AS225: 13 | oldlen = name->sa_len; 14 | ((struct sockaddr *)name)->sa_len = 0; 15 | rc = SOCK_connect(fp->lx_sock, name,namelen); 16 | ((struct sockaddr *)name)->sa_len = oldlen; 17 | break; 18 | 19 | case LX_AMITCP: 20 | rc = TCP_Connect(fp->lx_sock, name,namelen); 21 | break; 22 | 23 | default: 24 | rc = -1; 25 | break; 26 | } 27 | 28 | return rc; 29 | } 30 | -------------------------------------------------------------------------------- /examples/Makefile.in: -------------------------------------------------------------------------------- 1 | #### Start of system configuration section. #### 2 | 3 | srcdir = @srcdir@ 4 | VPATH = @srcdir@ 5 | 6 | CC = @CC@ 7 | 8 | #### End system configuration section #### 9 | 10 | # Some examples 11 | 12 | .PHONY: all 13 | 14 | all: lib libr dev helloworld 15 | 16 | # normal library 17 | lib: libinit.o simplelib.c 18 | $(CC) -nostdlib -O3 -fomit-frame-pointer -fbaserel $^ -o $@ 19 | 20 | # multibase library 21 | libr: libinitr.o simplelib.c 22 | $(CC) -nostdlib -O3 -fomit-frame-pointer -resident $^ -o $@ 23 | 24 | # device 25 | dev: devinit.o simpledev.c 26 | $(CC) -nostdlib -O3 -fomit-frame-pointer -fbaserel $^ -o $@ 27 | 28 | # helloworld 29 | helloworld: nbcrt0.o helloworld.c libstubs.a 30 | $(CC) -nostdlib -O3 -fomit-frame-pointer -s -fbaserel $^ -o $@ 31 | -------------------------------------------------------------------------------- /sources/amiga/misc/AddTOF.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | STATIC int stub(struct Isrvstr *intr asm("a1")) 9 | { 10 | (*intr->ccode)(intr->Carg); return 0; 11 | } 12 | 13 | VOID AddTOF(struct Isrvstr *intr,LONG (*code)(APTR),APTR arg) 14 | { APTR SysBase = *(APTR *)4L; 15 | 16 | intr->Iptr = intr; 17 | intr->code = (int (*)())stub; 18 | intr->ccode = (int (*)())code; 19 | intr->Carg = (int)arg; 20 | AddIntServer(INTB_VERTB,(struct Interrupt *)intr); 21 | } 22 | 23 | VOID RemTOF(struct Isrvstr *intr) 24 | { APTR SysBase = *(APTR *)4L; 25 | 26 | RemIntServer(INTB_VERTB,(struct Interrupt *)intr); 27 | } 28 | -------------------------------------------------------------------------------- /sources/nix/extra/chdir.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "stabs.h" 5 | 6 | extern void __seterrno(void); 7 | 8 | static BPTR oldlock; 9 | static int havelock=0; 10 | 11 | int chdir(const char *path) 12 | { 13 | BPTR fl; 14 | int ret; 15 | 16 | if ((fl=Lock((STRPTR)path,SHARED_LOCK))) 17 | { 18 | UnLock(CurrentDir(fl)); ret=0; 19 | } 20 | else 21 | { 22 | __seterrno(); ret=-1; 23 | } 24 | return ret; 25 | } 26 | 27 | void __initchdir(void) 28 | { 29 | BPTR fl; 30 | 31 | if (!(fl=Lock("",SHARED_LOCK))) 32 | exit(20); 33 | oldlock=CurrentDir(fl); 34 | havelock=1; 35 | } 36 | 37 | void __exitchdir(void) 38 | { 39 | if (havelock) UnLock(CurrentDir(oldlock)); 40 | } 41 | 42 | ADD2INIT(__initchdir,-35); 43 | ADD2EXIT(__exitchdir,-35); 44 | -------------------------------------------------------------------------------- /sources/socket/socket/sendto.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | // 4 | #include "socket.h" 5 | 6 | int sendto(int s, const void *buf, size_t len, int flags, const struct sockaddr *to, int tolen) 7 | { struct SocketSettings *lss; 8 | StdFileDes *fp = _lx_fhfromfd(s); 9 | int oldlen,rc; 10 | 11 | switch (lss=_lx_get_socket_settings(),lss->lx_network_type) { 12 | case LX_AS225: 13 | oldlen = to->sa_len; 14 | ((struct sockaddr *)to)->sa_len = 0; 15 | rc = SOCK_sendto(fp->lx_sock,buf,len,flags,to,tolen); 16 | ((struct sockaddr *)to)->sa_len = oldlen; 17 | break; 18 | 19 | case LX_AMITCP: 20 | rc = TCP_SendTo(fp->lx_sock,buf,len,flags,to,tolen); 21 | break; 22 | 23 | default: 24 | rc = -1; 25 | break; 26 | } 27 | 28 | return rc; 29 | } 30 | -------------------------------------------------------------------------------- /configure.in: -------------------------------------------------------------------------------- 1 | dnl Process this file with autoconf to produce a configure script. 2 | 3 | AC_INIT() 4 | 5 | AC_PROG_CC 6 | AC_PROG_RANLIB 7 | AC_CHECK_PROG(AR, ar, ar, ar) 8 | AC_CHECK_PROG(AS, as, as, as) 9 | 10 | AC_PROG_CPP 11 | AC_PROG_AWK 12 | AC_PROG_RANLIB 13 | AC_PROG_INSTALL 14 | 15 | AC_OUTPUT(Makefile 16 | sources/Makefile 17 | sources/amiga/Makefile 18 | sources/math/Makefile 19 | sources/misc/Makefile 20 | sources/nix/Makefile 21 | sources/nix13/Makefile 22 | sources/nix20/Makefile 23 | sources/nixmain/Makefile 24 | sources/nix_main/Makefile 25 | sources/socket/Makefile 26 | sources/stack/Makefile 27 | sources/startup/Makefile 28 | sources/stubs/Makefile 29 | examples/Makefile) 30 | -------------------------------------------------------------------------------- /sources/socket/socket/release_socket.c: -------------------------------------------------------------------------------- 1 | #include 2 | // 3 | #include "socket.h" 4 | 5 | /* TODO: fix me */ 6 | int release_socket(int s) 7 | { struct SocketSettings *lss; 8 | /* TODO: Finish me */ 9 | /* dup the socket first, since for AmiTCP, we can only release once */ 10 | int s2 = dup(s); 11 | /*StdFileDes *fp = _lx_fhfromfd(s);*/ 12 | int rc = -1; 13 | 14 | if (s2 >= 0) { 15 | switch (lss=_lx_get_socket_settings(),lss->lx_network_type) { 16 | case LX_AS225: 17 | rc = (int)SOCK_release(s2); 18 | SOCK_close(s2); 19 | break; 20 | 21 | case LX_AMITCP: 22 | rc = TCP_ReleaseSocket(s2, -1); 23 | TCP_CloseSocket(s2); 24 | break; 25 | 26 | default: 27 | /* silence compiler */ 28 | break; 29 | } 30 | } 31 | 32 | return rc; 33 | } 34 | -------------------------------------------------------------------------------- /sources/nix/stdlib/atexit.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "stabs.h" 5 | 6 | struct atexitnode 7 | { 8 | struct atexitnode *next; 9 | void (*func)(void); 10 | }; 11 | 12 | static struct atexitnode *__funclist=NULL; /* List of functions to call at exit */ 13 | 14 | int atexit(void (*func)(void)) 15 | { 16 | struct atexitnode *node; 17 | if((node=(struct atexitnode *)malloc(sizeof(struct atexitnode)))==NULL) 18 | { errno=ENOMEM; 19 | return -1; } 20 | else 21 | { node->next=__funclist; 22 | node->func=func; 23 | __funclist=node; 24 | return 0; } 25 | } 26 | 27 | void __exitatexit(void) 28 | { 29 | struct atexitnode *thisf=__funclist; 30 | while(thisf!=NULL) 31 | { (*thisf->func)(); 32 | thisf=thisf->next; } 33 | } 34 | 35 | ADD2EXIT(__exitatexit,0); 36 | -------------------------------------------------------------------------------- /sources/socket/socket/bind.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | // 4 | #include "socket.h" 5 | 6 | int bind(int s, const struct sockaddr *name, int namelen) 7 | { struct SocketSettings *lss; 8 | StdFileDes *fp; 9 | int oldlen,rc; 10 | 11 | if ((fp=_lx_fhfromfd(s))) { 12 | switch (lss=_lx_get_socket_settings(),lss->lx_network_type) { 13 | case LX_AS225: 14 | oldlen = name->sa_len; 15 | ((struct sockaddr *)name)->sa_len = 0; 16 | rc = SOCK_bind(fp->lx_sock, name, namelen); 17 | ((struct sockaddr *)name)->sa_len = oldlen; 18 | break; 19 | 20 | case LX_AMITCP: 21 | rc = TCP_Bind(fp->lx_sock, name, namelen); 22 | break; 23 | 24 | default: 25 | rc = -1; 26 | break; 27 | } 28 | } 29 | else rc = -1; 30 | 31 | return rc; 32 | } 33 | -------------------------------------------------------------------------------- /sources/nix/extra/readlink.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | int readlink(const char *path, char *buf, int bufsiz) 8 | { 9 | struct DevProc *dp = NULL; 10 | BPTR lock = NULL; 11 | int retval = -1; 12 | 13 | lock = Open(path, MODE_OLDFILE); 14 | if (lock == NULL) { 15 | errno = ENOENT; 16 | goto done; 17 | } 18 | 19 | dp = GetDeviceProc(path, NULL); 20 | if (dp == NULL) { 21 | errno = EINVAL; 22 | goto done; 23 | } 24 | 25 | retval = ReadLink(dp->dvp_Port, lock, path, buf, bufsiz); 26 | if (retval == TRUE) 27 | retval = strlen(buf); 28 | else 29 | retval = -1; 30 | 31 | done: 32 | if (dp != NULL) 33 | FreeDeviceProc(dp); 34 | 35 | if (lock != NULL) 36 | UnLock(lock); 37 | return retval; 38 | } 39 | -------------------------------------------------------------------------------- /sources/nix13/math/__divsi3.c: -------------------------------------------------------------------------------- 1 | asm( 2 | " .globl _div;" 3 | " .globl _ldiv;" 4 | " .globl ___modsi3;" 5 | " .globl ___divsi3;" 6 | 7 | /* D1.L = D0.L % D1.L signed */ 8 | 9 | "___modsi3: moveml sp@(4:W),d0/d1;" 10 | " jbsr ___divsi4;" 11 | " movel d1,d0;" 12 | " rts;" 13 | 14 | /* D0.L = D0.L / D1.L signed */ 15 | 16 | "_div:;" 17 | "_ldiv:;" 18 | "___divsi3: moveml sp@(4:W),d0/d1;" 19 | "___divsi4: movel d3,sp@-;" 20 | " movel d2,sp@-;" 21 | " moveq #0,d2;" 22 | " tstl d0;" 23 | " bpls LC5;" 24 | " negl d0;" 25 | " addql #1,d2;" 26 | "LC5: movel d2,d3;" 27 | " tstl d1;" 28 | " bpls LC4;" 29 | " negl d1;" 30 | " eoriw #1,d3;" 31 | "LC4: jbsr ___udivsi4;" 32 | "LC3: tstw d2;" 33 | " beqs LC2;" 34 | " negl d0;" 35 | "LC2: tstw d3;" 36 | " beqs LC1;" 37 | " negl d1;" 38 | "LC1: movel sp@+,d2;" 39 | " movel sp@+,d3;" 40 | " rts;" 41 | ); 42 | -------------------------------------------------------------------------------- /sources/nix/stdio/fread.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int fread(void *ptr,size_t size,size_t nmemb,FILE *stream) 7 | { 8 | signed long subsize; 9 | unsigned long total; 10 | unsigned char *b=(unsigned char *)ptr; 11 | if(!(total=size*nmemb)) /* Just in case size==0 */ 12 | return total; 13 | do 14 | { 15 | if(stream->incount>0) 16 | { 17 | subsize=total>stream->incount?stream->incount:total; 18 | memcpy(b,stream->p,subsize); 19 | stream->p+=subsize; 20 | stream->incount-=subsize; 21 | b+=subsize; 22 | total-=subsize; 23 | }else 24 | { 25 | int c; 26 | if((c=__srget(stream))==EOF) 27 | break; 28 | *b++=c; 29 | total--; 30 | } 31 | }while(total); 32 | return (b-(unsigned char *)ptr)/size; 33 | } 34 | -------------------------------------------------------------------------------- /sources/headers/dirent.h: -------------------------------------------------------------------------------- 1 | #ifndef _HEADERS_DIRENT_H 2 | #define _HEADERS_DIRENT_H 3 | 4 | #include 5 | #include 6 | 7 | struct dirent { 8 | ULONG d_fileno; 9 | USHORT d_reclen; 10 | USHORT d_namlen; 11 | BYTE d_name[256]; 12 | }; 13 | 14 | typedef struct _dirdesc { 15 | int dd_fd; 16 | struct dirent dd_ent; 17 | BPTR d_lock; 18 | ULONG d_count; 19 | LONG d_more; 20 | struct ExAllControl *d_eac; 21 | struct ExAllData *current; 22 | union { 23 | char ead[2048]; 24 | struct FileInfoBlock fib; 25 | } _dirun; 26 | } DIR; 27 | 28 | #define d_ead _dirun.ead 29 | #define d_info _dirun.fib 30 | 31 | /* 32 | ** prototypes 33 | */ 34 | 35 | DIR *opendir(const char *dirname); 36 | struct dirent *readdir(DIR *dirp); 37 | void rewinddir(DIR *dirp); 38 | int closedir(DIR *dirp); 39 | 40 | #endif /* _HEADERS_DIRENT_H */ 41 | -------------------------------------------------------------------------------- /sources/nix/stdio/fwrite.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int fwrite(const void *ptr,size_t size,size_t nmemb,FILE *stream) 7 | { 8 | signed long subsize; 9 | unsigned long total; 10 | unsigned char *b=(unsigned char *)ptr; 11 | if(!(total=size*nmemb)) /* Just in case size==0 */ 12 | return total; 13 | do 14 | { 15 | if(stream->outcount>0) 16 | { 17 | subsize=total>stream->outcount?stream->outcount:total; 18 | memcpy(stream->p,b,subsize); 19 | stream->p+=subsize; 20 | stream->outcount-=subsize; 21 | b+=subsize; 22 | total-=subsize; 23 | }else 24 | { 25 | int c; 26 | c=*b++; 27 | if(putc(c,stream)==EOF) 28 | break; 29 | total--; 30 | } 31 | }while(total); 32 | return (b-(unsigned char *)ptr)/size; 33 | } 34 | -------------------------------------------------------------------------------- /sources/nix/misc/bzero.c: -------------------------------------------------------------------------------- 1 | #include 2 | typedef union { 3 | void *v; 4 | char *c; 5 | short *s; 6 | long *l; 7 | } val; 8 | 9 | void bzero(void *b,size_t n) 10 | { 11 | val v; 12 | size_t m; 13 | v.v = b; 14 | 15 | if(!n) 16 | return; 17 | if(n > 15) { 18 | if((long)v.l & 1) { 19 | *v.c++ = 0; 20 | n--; 21 | } 22 | if((long)v.l & 2) { 23 | *v.s++ = 0; 24 | n-= 2; 25 | } 26 | for(m = n / (8 * sizeof(long)); m; --m) { 27 | *v.l++ = 0; 28 | *v.l++ = 0; 29 | *v.l++ = 0; 30 | *v.l++ = 0; 31 | *v.l++ = 0; 32 | *v.l++ = 0; 33 | *v.l++ = 0; 34 | *v.l++ = 0; 35 | } 36 | n &= 8 * sizeof(long) - 1; 37 | for(m = n / sizeof(long); m; --m) 38 | *v.l++ = 0; 39 | if((n &= sizeof(long) - 1)==0) 40 | return; 41 | } 42 | do; 43 | while(*v.c++ = 0, --n); 44 | } 45 | -------------------------------------------------------------------------------- /sources/nix/stdio/__fflush.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int __fflush(FILE *stream) /* fflush exactly one file */ 6 | { unsigned char *subbuf; 7 | long size,subsize; 8 | 9 | if(stream->flags&__SERR) /* Error on stream */ 10 | { errno=EPERM; 11 | return EOF; } 12 | if(stream->flags&__SWR) /* Works only on output streams */ 13 | { size=stream->p-stream->buffer; /* calculate size */ 14 | subbuf=stream->buffer; 15 | while(size) 16 | { if((subsize=write(stream->file,subbuf,size))<0) 17 | { stream->flags|=__SERR; /* error flag */ 18 | return EOF; } 19 | size-=subsize; 20 | subbuf+=subsize; 21 | } 22 | stream->flags&=~__SWR; /* unset write state */ 23 | stream->outcount=0; 24 | stream->linebufsize=0; 25 | } /* Nothing to be done for input streams */ 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /sources/nix/time/mktime.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | time_t mktime(struct tm *t) 4 | { static const char monthtable[] = { 5 | 31,29,31,30,31,30,31,31,30,31,30 6 | }; 7 | time_t tim,year; 8 | int leapyear=0,i; 9 | year=t->tm_year+1899; /* years from year 1 */ 10 | tim=year/400*146097; 11 | year%=400; 12 | if(year==399) 13 | leapyear++; 14 | tim+=year/100*36524; 15 | year%=100; 16 | if(year==99) 17 | leapyear--; 18 | tim+=year/4*1461; 19 | year%=4; 20 | if(year==3) 21 | leapyear++; 22 | tim+=year*365-719162+t->tm_mday-1; 23 | for(i=0;itm_mon;i++) 24 | tim+=monthtable[i]; 25 | if(!leapyear&&t->tm_mon>1) /* Sub 1 if no leap year */ 26 | tim--; /* tim contains now the number of days since 1.1.1970 */ 27 | tim=((tim*24+t->tm_hour)*60+t->tm_min)*60+t->tm_sec; 28 | return tim; 29 | } 30 | 31 | /* See gmtime.c for more details on the magic numbers :-) */ 32 | -------------------------------------------------------------------------------- /sources/socket/netdb/gethostent.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | // 7 | #include "socket.h" 8 | 9 | void sethostent(int stayopen) 10 | { struct SocketSettings *lss = _lx_get_socket_settings(); 11 | 12 | if (lss->lx_network_type == LX_AS225) { 13 | SOCK_sethostent(stayopen); 14 | } 15 | else if (stayopen && lss->lx_res) { 16 | lss->lx_res->options |= RES_STAYOPEN | RES_USEVC; 17 | } 18 | } 19 | 20 | void endhostent(void) 21 | { struct SocketSettings *lss = _lx_get_socket_settings(); 22 | 23 | if (lss->lx_network_type == LX_AS225) { 24 | SOCK_endhostent(); 25 | } 26 | else if (lss->lx_res) { 27 | lss->lx_res->options &= ~(RES_STAYOPEN | RES_USEVC); 28 | if (*lss->lx_res_socket >= 0) { 29 | close(*lss->lx_res_socket); *lss->lx_res_socket = -1; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /sources/headers/bases.h: -------------------------------------------------------------------------------- 1 | #ifndef _HEADERS_BASE_H 2 | #define _HEADERS_BASE_H 3 | 4 | #ifndef SMALL_DATA 5 | #define A4(x) #x 6 | #elif defined(mc68020) 7 | #define A4(x) "a4@(" #x ":L)" 8 | #else 9 | #define A4(x) "a4@(" #x ":W)" 10 | #endif 11 | 12 | #define GETAGBASE movel A4(_AmigaGuideBase),a6 13 | #define GETASLBASE movel A4(_AslBase),a6 14 | #define GETBULBASE movel A4(_BulletBase),a6 15 | #define GETDOSBASE movel A4(_DOSBase),a6 16 | #define GETDTBASE movel A4(_DataTypesBase),a6 17 | #define GETGADBASE movel A4(_GadToolsBase),a6 18 | #define GETGFXBASE movel A4(_GfxBase),a6 19 | #define GETINTBASE movel A4(_IntuitionBase),a6 20 | #define GETLOCBASE movel A4(_LocaleBase),a6 21 | #define GETLOWBASE movel A4(_LowLevelBase),a6 22 | #define GETRETBASE movel A4(_RealTimeBase),a6 23 | #define GETUTLBASE movel A4(_UtilityBase),a6 24 | #define GETWBBASE movel A4(_WorkbenchBase),a6 25 | 26 | #endif /* _HEADERS_BASE_H */ 27 | -------------------------------------------------------------------------------- /sources/nix/extra/gettimeofday.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | extern long __gmtoffset; 6 | 7 | int gettimeofday(struct timeval *tv, struct timezone *tzp) 8 | { 9 | if (tv) { 10 | struct DateStamp t; 11 | DateStamp(&t); /* Get timestamp */ 12 | tv->tv_sec=((t.ds_Days+2922)*1440+t.ds_Minute+__gmtoffset)*60+ 13 | t.ds_Tick/TICKS_PER_SECOND; 14 | tv->tv_usec=(t.ds_Tick%TICKS_PER_SECOND)*1000000/TICKS_PER_SECOND; 15 | } 16 | if (tzp) { 17 | /* since AmigaOS doesn't support timezones, we always return 18 | * GMT... 19 | */ 20 | tzp->tz_minuteswest = 0; 21 | tzp->tz_dsttime = 0; 22 | } 23 | 24 | return 0; 25 | } 26 | 27 | /* 28 | * 2922 is the number of days between 1.1.1970 and 1.1.1978 (2 leap years and 6 normal) 29 | * 1440 is the number of minutes per day 30 | * 60 is the number of seconds per minute 31 | */ 32 | -------------------------------------------------------------------------------- /sources/nix/string/memset.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | typedef union { 4 | void *v; 5 | char *c; 6 | short *s; 7 | long *l; 8 | } val; 9 | void *memset(void *s,int c,size_t n) 10 | { 11 | size_t m; 12 | val v; 13 | v.v = s; 14 | 15 | if(n) { 16 | if(n > 15) { 17 | c *= 0x01010101; 18 | if((long)v.l & 1) { 19 | *v.c++ = c; 20 | n--; 21 | } 22 | if((long)v.l & 2) { 23 | *v.s++ = c; 24 | n-=2; 25 | } 26 | for(m= n / (8 * sizeof(long)); m; --m) { 27 | *v.l++ = c; 28 | *v.l++ = c; 29 | *v.l++ = c; 30 | *v.l++ = c; 31 | *v.l++ = c; 32 | *v.l++ = c; 33 | *v.l++ = c; 34 | *v.l++ = c; 35 | } 36 | n &= (8 * sizeof(long)-1); 37 | for(m = n / sizeof(long); m; --m) 38 | *v.l++ = c; 39 | if((n &= sizeof(long) - 1)==0) 40 | goto leave; 41 | } 42 | do; 43 | while(*v.c++ = c, --n); 44 | } 45 | leave: 46 | return s; 47 | } 48 | -------------------------------------------------------------------------------- /sources/nix/extra/times.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | clock_t times(struct tms *tp) 7 | { struct rusage r; 8 | time_t tim; 9 | 10 | if (getrusage(RUSAGE_SELF, &r) < 0) 11 | return (clock_t)-1; 12 | 13 | tp->tms_utime = r.ru_utime.tv_sec * CLK_TCK + 14 | (r.ru_utime.tv_usec * CLK_TCK) / 1000000; 15 | tp->tms_stime = r.ru_stime.tv_sec * CLK_TCK + 16 | (r.ru_stime.tv_usec * CLK_TCK) / 1000000; 17 | 18 | if (getrusage(RUSAGE_CHILDREN, &r) < 0) 19 | return (clock_t)-1; 20 | 21 | tp->tms_cutime = 0; 22 | tp->tms_cstime = 0; 23 | 24 | if ((tim=time(NULL)) == (time_t)-1) 25 | return (clock_t)-1; 26 | 27 | /* The value we are supposed to return does not fit in 32 bits. 28 | Still, it is useful if you are interested in time differences 29 | in CLK_TCKths of a second. 30 | */ 31 | return tim * CLK_TCK; 32 | } 33 | -------------------------------------------------------------------------------- /sources/socket/socket/accept.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | // 4 | #include "socket.h" 5 | 6 | int accept(int s, struct sockaddr *name, int *namelen) 7 | { struct SocketSettings *lss = _lx_get_socket_settings(); 8 | StdFileDes *fp,*fp2; 9 | int rc; 10 | 11 | if ((fp=_lx_fhfromfd(s)) == NULL) 12 | return NULL; 13 | 14 | if ((fp2=_create_socket(fp->lx_family, fp->lx_domain, fp->lx_protocol)) == NULL) 15 | return -1; 16 | 17 | switch (lss=_lx_get_socket_settings(),lss->lx_network_type) { 18 | case LX_AS225: 19 | rc = SOCK_accept(fp->lx_sock, name, namelen); 20 | break; 21 | 22 | case LX_AMITCP: 23 | rc = TCP_Accept(fp->lx_sock, name, namelen); 24 | break; 25 | 26 | default: 27 | rc = -1; 28 | break; 29 | } 30 | 31 | if (rc >= 0) { 32 | fp2->lx_sock = rc; rc = fp2->lx_pos; 33 | } 34 | else { 35 | fp2->lx_inuse = 0; 36 | } 37 | 38 | return rc; 39 | } 40 | -------------------------------------------------------------------------------- /sources/nix/stdlib/putenv.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int setenv(const char *name, const char *value, int overwrite) { 7 | char *old = getenv(name); 8 | int retval = 0; 9 | if (old == NULL || overwrite) { 10 | retval = SetVar(name, value, strlen(value), GVF_LOCAL_ONLY) == TRUE ? 0 : -1; 11 | } 12 | return retval; 13 | } 14 | 15 | void unsetenv(const char *name) { 16 | DeleteVar(name, GVF_LOCAL_ONLY); 17 | } 18 | int putenv(const char *str) { 19 | char *tmp = malloc(strlen(str) + 1); 20 | int retval = -1; 21 | char *pos; 22 | if (tmp == NULL) { 23 | goto end; 24 | } 25 | strcpy(tmp, str); 26 | pos = strchr(tmp, '='); 27 | if (pos == NULL) 28 | goto end; 29 | *pos++ = '\0'; 30 | 31 | retval = setenv(str, pos, 1); 32 | 33 | end: 34 | if (tmp != NULL) 35 | free(tmp); 36 | return retval; 37 | } 38 | 39 | -------------------------------------------------------------------------------- /sources/nix/stdio/setvbuf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int setvbuf(FILE *stream,char *buf,int mode,size_t size) 6 | { short flags=stream->flags&~(__SNBF|__SLBF); 7 | if(mode==_IONBF) 8 | flags|=__SNBF; 9 | else if(mode==_IOLBF) 10 | flags|=__SLBF; 11 | if(size!=(size_t)stream->bufsize||buf!=(char *)stream->buffer) 12 | { if(__fflush(stream)) 13 | return -1; 14 | stream->incount=0; 15 | stream->flags=(flags&=~__SRD); 16 | stream->tmpp=0; 17 | mode=(buf==NULL); 18 | if(mode&&(buf=malloc(size=size?size:1))==NULL) 19 | { errno=ENOMEM; 20 | return -1; } 21 | if(flags&__SMBF) 22 | free(stream->buffer); 23 | if(mode) 24 | flags|=__SMBF; 25 | else 26 | flags&=~__SMBF; 27 | stream->buffer=buf; 28 | stream->bufsize=size; 29 | } /* Need not adjust outcount, since setvbuf affects only the NEXT full buffer */ 30 | stream->flags=flags; return 0; 31 | } 32 | -------------------------------------------------------------------------------- /sources/headers/select.h: -------------------------------------------------------------------------------- 1 | #ifndef _HEADERS_SELECT_H 2 | #define _HEADERS_SELECT_H 3 | 4 | #define SELCMD_PREPARE 0 5 | #define SELCMD_CHECK 1 6 | #define SELCMD_POLL 2 7 | 8 | #define SELMODE_IN 0 9 | #define SELMODE_OUT 1 10 | #define SELMODE_EXC 2 11 | 12 | #define SELPKT_IN_USE(fp) ((fp)->lx_packet->sp_Pkt.dp_Port != NULL) 13 | 14 | #define SelLastResult(fp) ((fp)->lx_packet->sp_Pkt.dp_Res1) 15 | #define SelLastError(fp) ((fp)->lx_packet->sp_Pkt.dp_Res2) 16 | 17 | #define PutPacket(port,pack) PutMsg((port),(pack)) 18 | #define GetPacket(port) ((struct StandardPacket *)GetMsg(port)) 19 | #define SelSendPacket1(fp,port,act,arg1) \ 20 | do { \ 21 | struct StandardPacket *sp = (fp)->lx_packet; \ 22 | sp->sp_Pkt.dp_Port = (port); \ 23 | sp->sp_Pkt.dp_Type = (act); \ 24 | sp->sp_Pkt.dp_Arg1 = (arg1); \ 25 | PutPacket(((struct FileHandle *)BADDR((fp)->lx_fh))->fh_Type,&sp->sp_Msg); \ 26 | } while(0) 27 | 28 | #endif /* _HEADERS_SELECT_H */ 29 | -------------------------------------------------------------------------------- /sources/socket/socket/socket.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | // 4 | #include "debuglib.h" 5 | #include "socket.h" 6 | 7 | int socket(int domain, int type, int protocol) 8 | { struct SocketSettings *lss; 9 | StdFileDes *fp; 10 | int rc; 11 | 12 | if ((fp=_create_socket(domain, type, protocol)) == NULL) 13 | return -1; 14 | 15 | switch (lss=_lx_get_socket_settings(),lss->lx_network_type) { 16 | case LX_AS225: 17 | rc = SOCK_socket(domain, type, protocol); 18 | break; 19 | 20 | case LX_AMITCP: 21 | rc = TCP_Socket(domain, type, protocol); 22 | break; 23 | 24 | default: 25 | rc = -1; 26 | break; 27 | } 28 | DB( BUG("Return from net_socket is %ld\n", rc); ) 29 | 30 | if (rc >= 0) { 31 | fp->lx_sock = rc; rc = fp->lx_pos; 32 | } 33 | else { 34 | fp->lx_inuse = 0; 35 | } 36 | 37 | DB( BUG("Return fd from socket() is %ld, inuse is %ld\n", fp->lx_pos, fp->lx_inuse); ) 38 | return rc; 39 | } 40 | -------------------------------------------------------------------------------- /sources/nix/signal/raise.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | extern void (*__signalfunc[])(int); 6 | extern int __signalmask,__signalpending; 7 | 8 | #define wlen(s) s,sizeof(s)-1 9 | 10 | int raise(int sig) 11 | { int ret=-1; 12 | 13 | if (!(sig<1||sig>6)) 14 | { 15 | int *mask=&__signalmask,*pending=&__signalpending; 16 | 17 | *pending|=1<<(sig-1); 18 | while(!(*mask&(1<<(sig-1)))&& 19 | (*pending&(1<<(sig-1)))) 20 | { 21 | *pending&=~(1<<(sig-1)); 22 | if(__signalfunc[sig-1]!=SIG_IGN) 23 | { 24 | int oldmask=*mask; 25 | *mask|=1<<(sig-1); 26 | if(__signalfunc[sig-1]==SIG_DFL) 27 | { 28 | if(sig==SIGINT) 29 | { 30 | write(2,wlen("***Break\n")); exit(20); 31 | } 32 | }else 33 | (*__signalfunc[sig-1])(sig); 34 | *mask=oldmask; 35 | } 36 | } 37 | ret=0; 38 | } 39 | return ret; 40 | } 41 | -------------------------------------------------------------------------------- /sources/stack/Makefile.in: -------------------------------------------------------------------------------- 1 | #### Start of system configuration section. #### 2 | 3 | srcdir = @srcdir@ 4 | VPATH = @srcdir@ 5 | 6 | CC = @CC@ 7 | CPP = @CPP@ 8 | AS = @AS@ 9 | 10 | AR = @AR@ 11 | RANLIB = @RANLIB@ 12 | AWK = @AWK@ 13 | 14 | #### End system configuration section #### 15 | 16 | ifneq ($(TARGET),clean) 17 | include ../../sources/stack/filelist 18 | endif 19 | 20 | OPTIONS=-I$(srcdir)/../headers $(CFLAGS) 21 | 22 | REDEF=-D_DOSBase=___DOSBase 23 | 24 | %.o: %.c 25 | $(CC) $(OPTIONS) -S $^ -o $*.S 2>&1|tee $*.err 26 | $(CPP) -traditional $(REDEF) $*.S -o $*2.S 27 | $(CC) $(OPTIONS) $*2.S -c -o $*.o 28 | -rm $*.S $*2.S 29 | -if test ! -s $*.err; then rm $*.err; fi 30 | 31 | .PHONY: all clean veryclean 32 | 33 | all: libstack.a 34 | 35 | clean: 36 | -rm -rf *.o 37 | 38 | veryclean: 39 | -rm -rf * 40 | 41 | libstack.a: $(OBJECTS) ../../sources/stack/Makefile ../../sources/stack/filelist 42 | -rm -f $@ 43 | $(AR) -q $@ $(OBJECTS) 44 | $(RANLIB) $@ 45 | echo "\$$$(V)" >>$@ 46 | -------------------------------------------------------------------------------- /sources/stubs/misc/__cpucheck.c: -------------------------------------------------------------------------------- 1 | #include "bases.h" 2 | #include "stabs.h" 3 | 4 | #if defined(mc68020) || defined(__HAVE_68881__) 5 | 6 | #ifdef mc68020 7 | const char errtext1[]="Need a 68020 or higher CPU"; 8 | #endif 9 | 10 | #ifdef __HAVE_68881__ 11 | const char errtext2[]="Need some FPU to run"; 12 | #endif 13 | 14 | asm( 15 | " .text;" 16 | " .even;" 17 | 18 | " .globl ___cpucheck;" 19 | "___cpucheck:;" 20 | " movel "A4(_SysBase)",a1;" 21 | " movew a1@(0x128:W),d0;" 22 | 23 | #ifdef mc68020 24 | 25 | " lea _errtext1,a0;" 26 | " btst #1,d0;" 27 | " jeq error;" 28 | 29 | #endif 30 | #ifdef __HAVE_68881__ 31 | 32 | " lea _errtext2,a0;" 33 | " btst #4,d0;" 34 | " jeq error;" 35 | 36 | #endif 37 | 38 | " rts;" 39 | "error:" 40 | " movel a0,sp@-;" 41 | " jsr ___request;" /* jbsr translates to jra which doesn't work on 68000 */ 42 | " pea 20:W;" 43 | " jsr _exit;" /* dito */ 44 | ); 45 | 46 | ADD2INIT(__cpucheck,-80); /* Highest priority */ 47 | 48 | #else 49 | 50 | int __cpucheck; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | libnix: C link library for AmigaOS/m68k 2 | === 3 | 4 | **Short description:** Fork of [libnix](http://sourceforge.net/projects/libnix/) from [sourceforge.net](http://sourceforge.net). 5 | 6 | ## Overview 7 | 8 | **libnix** is used in conjuction with [m68k-amigaos-toolchain](https://github.com/cahirwpz/m68k-amigaos-toolchain) project. It's standard C link library (similar to glibc or newlib, but quite incomplete) for gcc cross compiler targeting AmigaOS/m68k systems. 9 | 10 | There are several initiatives trying to bring up an updated C link library for AmigaOS/m68k systems: 11 | 12 | * [libnix-3.0](https://github.com/diegocr/libnix) by Diego Casorran 13 | * [clib2](http://clib2.cvs.sourceforge.net/) by Olaf Barthel 14 | * [arosc.library](http://repo.or.cz/w/AROS.git/tree/HEAD:/compiler/stdc) in [Amiga Research Operating System](http://aros.sf.net) source tree 15 | 16 | For now I decided to use original sources by Jeff Shepher et al., perhaps I'll merge Diego Casorran's changes if I find them indispensable. 17 | -------------------------------------------------------------------------------- /sources/stubs/library.list: -------------------------------------------------------------------------------- 1 | AmigaGuideBase amigaguide.library 2 | AslBase asl.library 3 | BulletBase bullet.library 4 | CxBase commodities.library 5 | DataTypesBase datatypes.library 6 | DiskfontBase diskfont.library 7 | DOSBase dos.library 8 | ExpansionBase expansion.library 9 | GadToolsBase gadtools.library 10 | GfxBase graphics.library 11 | IconBase icon.library 12 | IFFParseBase iffparse.library 13 | IntuitionBase intuition.library 14 | KeymapBase keymap.library 15 | LayersBase layers.library 16 | LocaleBase locale.library 17 | LowLevelBase lowlevel.library 18 | MathBase mathffp.library 19 | MathIeeeDoubBasBase mathieeedoubbas.library 20 | MathIeeeDoubTransBase mathieeedoubtrans.library 21 | MathIeeeSingBasBase mathieeesingbas.library 22 | MathIeeeSingTransBase mathieeesingtrans.library 23 | MathTransBase mathtrans.library 24 | NVBase nonvolatile.library 25 | RealTimeBase realtime.library 26 | RexxSysBase rexxsyslib.library 27 | TranslatorBase translator.library 28 | UtilityBase utility.library 29 | WorkbenchBase workbench.library 30 | -------------------------------------------------------------------------------- /sources/math/extra/ldexp.c: -------------------------------------------------------------------------------- 1 | #undef __HAVE_68881__ 2 | #include 3 | 4 | #define MANT_MASK 0x800FFFFF /* Mantissa extraction mask */ 5 | #define ZPOS_MASK 0x3FF00000 /* Positive # mask for exp = 0 */ 6 | #define ZNEG_MASK 0x3FF00000 /* Negative # mask for exp = 0 */ 7 | 8 | #define EXP_MASK 0x7FF00000 /* Mask for exponent */ 9 | #define EXP_SHIFTS 20 /* Shifts to get into LSB's */ 10 | #define EXP_BIAS 1023 /* Exponent bias */ 11 | 12 | 13 | union dtol 14 | { 15 | double dval; 16 | int ival[2]; 17 | }; 18 | 19 | double ldexp (double x,int n) 20 | { 21 | union dtol number; 22 | int *iptr, cn; 23 | 24 | if (x == 0.0) 25 | return (0.0); 26 | else 27 | { 28 | number.dval = x; 29 | iptr = &number.ival[0]; 30 | cn = (((*iptr) & EXP_MASK) >> EXP_SHIFTS) - EXP_BIAS; 31 | *iptr &= ~EXP_MASK; 32 | n += EXP_BIAS; 33 | *iptr |= ((n + cn) << EXP_SHIFTS) & EXP_MASK; 34 | return (number.dval); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /sources/headers/pool.h: -------------------------------------------------------------------------------- 1 | #ifndef _HEADERS_POOL_H 2 | #define _HEADERS_POOL_H 3 | 4 | #include 5 | 6 | #if defined(__GNUC__) 7 | #define ASM 8 | #define REG(reg,arg) arg __asm(#reg) 9 | #else 10 | #define ASM __asm 11 | #define REG(reg,arg) register __##reg arg 12 | #endif 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | /* 19 | ** our PRIVATE! memory pool structure 20 | ** (_NOT_ compatible with original amiga.lib!) 21 | */ 22 | 23 | typedef struct Pool { 24 | struct MinList PuddleList; 25 | ULONG MemoryFlags; 26 | ULONG PuddleSize; 27 | ULONG ThreshSize; 28 | } POOL; 29 | 30 | /* 31 | ** required prototypes 32 | */ 33 | 34 | APTR ASM AsmCreatePool(REG(d0,ULONG),REG(d1,ULONG),REG(d2,ULONG),REG(a6,APTR)); 35 | APTR ASM AsmAllocPooled(REG(a0,POOL *),REG(d0,ULONG),REG(a6,APTR)); 36 | VOID ASM AsmFreePooled(REG(a0,POOL *),REG(a1,APTR),REG(d0,ULONG),REG(a6,APTR)); 37 | VOID ASM AsmDeletePool(REG(a0,POOL *),REG(a6,APTR)); 38 | 39 | #endif /* _HEADERS_POOL_H */ 40 | -------------------------------------------------------------------------------- /sources/socket/extra/strsep.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Get next token from string *stringp, where tokens are nonempty 3 | * strings separated by characters from delim. 4 | * 5 | * Writes NULs into the string at *stringp to end tokens. 6 | * delim need not remain constant from call to call. 7 | * On return, *stringp points past the last NUL written (if there might 8 | * be further tokens), or is NULL (if there are definitely no more tokens). 9 | * 10 | * If *stringp is NULL, strsep returns NULL. 11 | */ 12 | 13 | #include 14 | 15 | char *strsep(char **stringp, const char *delim) 16 | { char *s,*tok; 17 | 18 | if ((tok=*stringp)) 19 | for (s=tok;;) { 20 | const char *spanp=delim; 21 | int sc,c=*s++; 22 | do { 23 | if ((sc = *spanp++) == c) { 24 | if (c) 25 | s[-1] = 0; 26 | else 27 | s = NULL; 28 | tok = *stringp; 29 | *stringp = s; 30 | return tok; 31 | } 32 | } while (sc != 0); 33 | } 34 | return tok; 35 | } 36 | -------------------------------------------------------------------------------- /sources/nix/stdio/rename.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | extern void __seterrno(void); 7 | extern char *__amigapath(const char *path); 8 | 9 | int rename(const char *old,const char *new) 10 | { int ret=-1; 11 | 12 | #ifdef IXPATHS 13 | if((old=__amigapath(old))!=NULL) 14 | { 15 | if((old=strdup(old))!=NULL) 16 | { 17 | if((new=__amigapath(new))!=NULL) 18 | { 19 | #endif 20 | BPTR lnew=Lock((char *)new,SHARED_LOCK); 21 | if(lnew) { 22 | BPTR lold=Lock((char *)old,SHARED_LOCK); 23 | if(lold) 24 | ret=SameLock(lold,lnew),UnLock(lold); 25 | UnLock(lnew); 26 | } 27 | 28 | if(ret) { 29 | if(ret==1) 30 | DeleteFile((char *)new); 31 | if(ret=0,!Rename((char *)old,(char *)new)) 32 | __seterrno(),ret=-1; 33 | } 34 | 35 | #ifdef IXPATHS 36 | } 37 | free(old); 38 | } 39 | } 40 | #endif 41 | 42 | return ret; 43 | } 44 | -------------------------------------------------------------------------------- /sources/nix13/math/__udivsi3.c: -------------------------------------------------------------------------------- 1 | asm( 2 | " .globl ___umodsi3;" 3 | " .globl ___udivsi3;" 4 | " .globl ___udivsi4;" 5 | 6 | /* D1.L = D0.L % D1.L unsigned */ 7 | 8 | "___umodsi3: moveml sp@(4:W),d0/d1;" 9 | " jbsr ___udivsi4;" 10 | " movel d1,d0;" 11 | " rts;" 12 | 13 | /* D0.L = D0.L / D1.L unsigned */ 14 | 15 | "___udivsi3: moveml sp@(4:W),d0/d1;" 16 | "___udivsi4: movel d3,sp@-;" 17 | " movel d2,sp@-;" 18 | " movel d1,d3;" 19 | " swap d1;" 20 | " tstw d1;" 21 | " bnes LC4;" 22 | " movew d0,d2;" 23 | " clrw d0;" 24 | " swap d0;" 25 | " divu d3,d0;" 26 | " movel d0,d1;" 27 | " swap d0;" 28 | " movew d2,d1;" 29 | " divu d3,d1;" 30 | " movew d1,d0;" 31 | " clrw d1;" 32 | " swap d1;" 33 | " jra LC1;" 34 | "LC4: movel d0,d1;" 35 | " swap d0;" 36 | " clrw d0;" 37 | " clrw d1;" 38 | " swap d1;" 39 | " moveq #16-1,d2;" 40 | "LC3: addl d0,d0;" 41 | " addxl d1,d1;" 42 | " cmpl d1,d3;" 43 | " bhis LC2;" 44 | " subl d3,d1;" 45 | " addqw #1,d0;" 46 | "LC2: dbra d2,LC3;" 47 | "LC1: movel sp@+,d2;" 48 | " movel sp@+,d3;" 49 | " rts;" 50 | ); 51 | -------------------------------------------------------------------------------- /sources/amiga/misc/AsmFreePooled.c: -------------------------------------------------------------------------------- 1 | #include "pool.h" 2 | 3 | VOID ASM AsmFreePooled(REG(a0,POOL *poolHeader),REG(a1,APTR memory),REG(d0,ULONG memSize),REG(a6,APTR SysBase)) 4 | { 5 | if (((struct Library *)SysBase)->lib_Version>=39) 6 | return (FreePooled(poolHeader,memory,memSize)); 7 | else if (poolHeader!=NULL && memory!=NULL) { 8 | 9 | ULONG size,*puddle=(ULONG *)((struct MinNode *)memory-1)-1; 10 | 11 | if (poolHeader->ThreshSize>memSize) { 12 | 13 | struct MemHeader *a=(struct MemHeader *)&poolHeader->PuddleList.mlh_Head; 14 | 15 | for(;;) { 16 | a=(struct MemHeader *)a->mh_Node.ln_Succ; 17 | if (a->mh_Node.ln_Succ==NULL) 18 | return; 19 | if (a->mh_Node.ln_Type && memory>=a->mh_Lower && memorymh_Upper) 20 | break; 21 | } 22 | Deallocate(a,memory,memSize); 23 | if (a->mh_Free!=poolHeader->PuddleSize) 24 | return; 25 | puddle=(ULONG *)&a->mh_Node; 26 | } 27 | Remove((struct Node *)puddle); 28 | size=*--puddle; FreeMem(puddle,size); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /sources/nix/stdio/ungetc.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int ungetc(int c,FILE *stream) 5 | { 6 | if(c==EOF) 7 | return EOF; 8 | if(stream->flags&__SERR)/* Error on stream */ 9 | { errno=EPERM; 10 | return EOF; } 11 | if(stream->flags&__SWR) /* File is in write mode */ 12 | if(__fflush(stream)) /* write buffer */ 13 | return EOF; 14 | if(stream->tmpp==NULL) 15 | { if(stream->flags&__SRD) /* File is in read mode */ 16 | { stream->tmpp=stream->p; /* store actual position */ 17 | stream->tmpinc=stream->incount; 18 | stream->p=&stream->unget[4]; /* and use other buffer */ 19 | stream->incount=0; 20 | }else /* File is in indeterminated state */ 21 | { stream->tmpp=(unsigned char *)2; /* Dummy */ 22 | stream->tmpinc=0; 23 | stream->p=&stream->unget[4]; /* use other buffer */ 24 | stream->incount=0; 25 | stream->flags|=__SRD; 26 | } 27 | } 28 | if(stream->incount==4) /* ungetc buffer overflow */ 29 | return EOF; 30 | stream->incount++; 31 | return *--stream->p=c; 32 | } 33 | -------------------------------------------------------------------------------- /sources/nix/stdio/fdopen.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | FILE *fdopen(int filedes,const char *mode) 9 | { extern int _lx_addflags(int,int); 10 | if (mode!=NULL) 11 | { struct filenode *node = (struct filenode *)calloc(1,sizeof(*node)); 12 | if(node!=NULL) 13 | { if((node->FILE.buffer=(char *)malloc(BUFSIZ))!=NULL) 14 | { node->FILE.bufsize=BUFSIZ; 15 | node->FILE.file=filedes; 16 | node->FILE.flags|=__SMBF; /* Buffer is malloc'ed */ 17 | if(isatty(filedes)) 18 | node->FILE.flags|=__SLBF; /* set linebuffered flag */ 19 | if(_lx_addflags(filedes,*mode=='a'?O_APPEND:0)&O_WRONLY) 20 | node->FILE.flags|=__SWO; /* set write-only flag */ 21 | AddHead((struct List *)&__filelist,(struct Node *)&node->node); 22 | return &node->FILE; 23 | } 24 | else 25 | errno=ENOMEM; 26 | free(node); 27 | } 28 | else 29 | errno=ENOMEM; 30 | } 31 | return NULL; 32 | } 33 | -------------------------------------------------------------------------------- /sources/stubs/Makefile.in: -------------------------------------------------------------------------------- 1 | #### Start of system configuration section. #### 2 | 3 | srcdir = @srcdir@ 4 | VPATH = @srcdir@ 5 | 6 | CC = @CC@ 7 | CPP = @CPP@ 8 | AS = @AS@ 9 | 10 | AR = @AR@ 11 | RANLIB = @RANLIB@ 12 | AWK = @AWK@ 13 | 14 | #### End system configuration section #### 15 | 16 | ifneq ($(TARGET),clean) 17 | include ../../sources/stubs/filelist 18 | endif 19 | 20 | CURDIR = $(shell pwd) 21 | 22 | OPTIONS=-I$(srcdir)/../headers $(CFLAGS) 23 | 24 | OBJECTS2=$(OBJECTS) ../nix/misc/__request.o 25 | 26 | SUBDIRS2=$(SUBDIRS) ../nix/misc 27 | 28 | %.o: %.c 29 | $(CC) $(OPTIONS) -c $^ -o $@ 2>&1|tee $*.err 30 | -if test ! -s $*.err; then rm $*.err; fi 31 | 32 | .PHONY: all clean veryclean 33 | 34 | all: libstubs.a 35 | 36 | clean: 37 | rm -rf $(SUBDIRS) 38 | 39 | veryclean: 40 | rm -rf * 41 | 42 | $(foreach f,$(SUBDIRS2),$(CURDIR)/$(f)): 43 | mkdir $@ 44 | 45 | libstubs.a: $(foreach f,$(SUBDIRS2),$(CURDIR)/$(f)) $(OBJECTS2) ../../sources/stubs/Makefile ../../sources/stubs/filelist 46 | rm -f $@ 47 | $(AR) -q $@ $(OBJECTS2) 48 | $(RANLIB) $@ 49 | echo "\$$$(V)" >>$@ 50 | -------------------------------------------------------------------------------- /sources/amiga/misc/CreateIO.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "stabs.h" 6 | 7 | struct IORequest *CreateExtIO(CONST struct MsgPort *port,LONG iosize) 8 | { APTR SysBase = *(APTR *)4L; 9 | struct IORequest *ioreq = NULL; 10 | 11 | if (port && (ioreq=AllocMem(iosize,MEMF_CLEAR|MEMF_PUBLIC))) { 12 | ioreq->io_Message.mn_Node.ln_Type = NT_REPLYMSG; 13 | ioreq->io_Message.mn_ReplyPort = port; 14 | ioreq->io_Message.mn_Length = iosize; 15 | } 16 | return ioreq; 17 | } 18 | 19 | struct IOStdReq *CreateStdIO(CONST struct MsgPort *port) 20 | { 21 | return (struct IOStdReq *)CreateExtIO(port,sizeof(struct IOStdReq)); 22 | } 23 | 24 | VOID DeleteExtIO(struct IORequest *ioreq) 25 | { APTR SysBase = *(APTR *)4L; 26 | LONG i; 27 | 28 | i = -1; 29 | ioreq->io_Message.mn_Node.ln_Type = i; 30 | ioreq->io_Device = (struct Device *)i; 31 | ioreq->io_Unit = (struct Unit *)i; 32 | FreeMem(ioreq,ioreq->io_Message.mn_Length); 33 | } 34 | 35 | ALIAS(DeleteStdIO,DeleteExtIO); 36 | -------------------------------------------------------------------------------- /sources/nix/extra/chmod.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | extern void __seterrno(void); 9 | extern char *__amigapath(const char *path); 10 | 11 | int chmod(const char *name, mode_t mode) 12 | { 13 | #ifdef IXPATHS 14 | if((name=__amigapath(name))==NULL) 15 | return -1; 16 | #endif 17 | if(!SetProtection((STRPTR)name,((mode&S_IRUSR?0:FIBF_READ)| 18 | (mode&S_IWUSR?0:FIBF_WRITE|FIBF_DELETE)| 19 | (mode&S_IXUSR?0:FIBF_EXECUTE)| 20 | (mode&S_IRGRP?FIBF_GRP_READ:0)| 21 | (mode&S_IWGRP?FIBF_GRP_WRITE|FIBF_GRP_DELETE:0)| 22 | (mode&S_IXGRP?FIBF_GRP_EXECUTE:0)| 23 | (mode&S_IROTH?FIBF_OTR_READ:0)| 24 | (mode&S_IWOTH?FIBF_OTR_WRITE|FIBF_OTR_DELETE:0)| 25 | (mode&S_IXOTH?FIBF_OTR_EXECUTE:0)))) 26 | if(__seterrno(),errno!=ETXTBSY) 27 | return -1; 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /sources/nix/stdio/__swbuf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int __swbuf(int c,FILE *stream) /* Get next output block */ 5 | { int out,lbs; 6 | 7 | if(stream->flags&(__SSTR|__SERR)) /* sprintf buffer | error on stream */ 8 | { stream->outcount=0; 9 | errno=EPERM; 10 | return EOF; 11 | }else if(stream->flags&__SRD) 12 | { 13 | stream->incount=0; /* throw away input buffer */ 14 | stream->tmpp=NULL; 15 | stream->flags&=~__SRD; 16 | } 17 | lbs=stream->flags&__SLBF?-stream->bufsize:0; 18 | out=(stream->flags&__SNBF?0:stream->bufsize-1)+lbs; 19 | if(!(stream->flags&__SWR)) /* File wasn't in write mode */ 20 | { stream->p=stream->buffer; /* set buffer */ 21 | stream->outcount=--out; /* and buffercount */ 22 | stream->flags|=__SWR; } /* and write mode */ 23 | *stream->p++=c; /* put this character */ 24 | if(stream->outcount<0&&(stream->outcountp=stream->buffer; /* Set new buffer */ 28 | } 29 | stream->linebufsize=lbs; 30 | stream->outcount=out; 31 | stream->flags|=__SWR; 32 | return c; 33 | } 34 | -------------------------------------------------------------------------------- /sources/nix/stdlib/free.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "debuglib.h" 6 | 7 | extern struct MinList __memorylist; 8 | extern struct SignalSemaphore *__memsema; 9 | 10 | void free(void *ptr) 11 | { struct MemHeader *a; 12 | 13 | if(!ptr) /* What does that mean ????? */ 14 | { DB( BUG("NULL pointer free'd\n"); ) 15 | return; } 16 | 17 | ObtainSemaphore(__memsema); 18 | a=(struct MemHeader *)__memorylist.mlh_Head; 19 | for(;;) 20 | { 21 | if(((struct MinNode *)a)->mln_Succ==NULL) /* Is not in list ????? */ 22 | { DB( BUG("Fake memory free'd\n"); ) 23 | return; } 24 | 25 | if(ptr>=a->mh_Lower&&ptrmh_Upper) /* Entry found */ 26 | break; 27 | 28 | a=(struct MemHeader *)((struct MinNode *)a)->mln_Succ; 29 | } 30 | 31 | DB( memset(ptr,0xcc,((ULONG *)ptr)[-1]); ) /* Destroy contents */ 32 | 33 | Deallocate(a,(ULONG *)ptr-1,((ULONG *)ptr)[-1]); 34 | if(a->mh_Free==(char *)a->mh_Upper-(char *)a->mh_Lower) /* All free ? */ 35 | { Remove(&a->mh_Node); 36 | FreeMem(a,(char *)a->mh_Upper-(char *)a); 37 | } 38 | ReleaseSemaphore(__memsema); 39 | } 40 | -------------------------------------------------------------------------------- /sources/stack/init_stk.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "stabs.h" 4 | 5 | extern ULONG __stk_safezone; 6 | 7 | APTR *__stackborders=0,__stk_limit=0; 8 | 9 | /* 10 | * This way to find the bottom of the current stackframe 11 | * is the way descibed in the amiga-guru-book. 12 | * 13 | * Note that it's of no use to check if the actual parameters are set 14 | * correctly (disabling stackextension if not) because a program will 15 | * crash anyway in that case (if you check against the wrong border or 16 | * not at all). 17 | * But with wrong parameters you can probably raise a stackextend too 18 | * soon - thus gaining *correct* (for following stackextends) stackbounds 19 | * at the cost of only some memory. 20 | */ 21 | 22 | void __init_stk(void) 23 | { 24 | struct Process *me = (struct Process *)FindTask(NULL); 25 | UBYTE *sl; 26 | 27 | __stackborders = (APTR *)(sl = (UBYTE *)&me->pr_Task.tc_SPLower); 28 | if (me->pr_CLI) 29 | sl = /*sizeof(ULONG)+*/ (UBYTE *)me->pr_ReturnAddr - *(ULONG *)me->pr_ReturnAddr; 30 | /*^^^^^^^^^^^^^^ need not be that precise */ 31 | __stk_limit = (sl += __stk_safezone); 32 | } 33 | 34 | ADD2INIT(__init_stk,-50); 35 | -------------------------------------------------------------------------------- /sources/nix/extra/stat.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "stabs.h" 7 | 8 | extern int __stat(struct stat *buf,struct FileInfoBlock *fib); 9 | extern void __seterrno(void); 10 | extern char *__amigapath(const char *path); 11 | 12 | int stat(const char *name,struct stat *buf) 13 | { APTR oldwin,*wptr=&((struct Process *)FindTask(NULL))->pr_WindowPtr; 14 | struct FileInfoBlock *fib; 15 | BPTR lock; 16 | int ret=-1; 17 | 18 | #ifdef IXPATHS 19 | if((name=__amigapath(name))==NULL) 20 | return -1; 21 | #endif 22 | 23 | /* avoid possible dos-requesters ;-( */ 24 | 25 | oldwin=*wptr; *wptr=(APTR)ret; 26 | 27 | if((lock=Lock((STRPTR)name,SHARED_LOCK))!=0) 28 | { 29 | if((fib=(struct FileInfoBlock *)AllocDosObject(DOS_FIB,NULL))!=NULL) 30 | { if(Examine(lock,fib)!=DOSFALSE) 31 | ret=__stat(buf,fib); 32 | else 33 | __seterrno(); 34 | FreeDosObject(DOS_FIB,fib); 35 | } 36 | else 37 | __seterrno(); 38 | UnLock(lock); 39 | } 40 | else 41 | __seterrno(); 42 | 43 | *wptr=oldwin; 44 | 45 | return ret; 46 | } 47 | 48 | ALIAS(lstat,stat); 49 | -------------------------------------------------------------------------------- /sources/nix/extra/utimes.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #define SECSPERDAY (24L * 60L * 60L) 9 | 10 | int utimes(const char *file, const struct timeval *times) 11 | { struct DateStamp d; 12 | 13 | if (times) { 14 | struct timeval modtime = times[1]; 15 | time_t t; 16 | 17 | if (modtime.tv_usec > 1000000) { 18 | modtime.tv_sec += (modtime.tv_usec / 1000000); 19 | modtime.tv_usec %= 1000000; 20 | } 21 | t = modtime.tv_sec; 22 | #if 0 23 | extern long timezone; 24 | #endif 25 | t -= (2922L * SECSPERDAY); /* Datestamps start from Jan 1, 1978, unix 26 | time from Jan 1, 1970, i.e., 2922 days 27 | earlier! */ 28 | #if 0 29 | t -= timezone; /* Adjust for local time */ 30 | #endif 31 | d.ds_Days = t / SECSPERDAY; 32 | t %= SECSPERDAY; 33 | d.ds_Minute = t / 60L; 34 | t %= 60L; 35 | d.ds_Tick = t * 50 + (modtime.tv_usec / 20000); 36 | }else{ 37 | DateStamp(&d); 38 | } 39 | 40 | if (SetFileDate((STRPTR)file, &d)) { 41 | errno = 0; 42 | return 0; 43 | }else{ 44 | errno = ENOENT; 45 | return -1; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /sources/socket/netdb/herror.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | // 5 | #include "socket.h" 6 | 7 | char *hstrerror(int err) 8 | { static char *const h_errlist[] = { 9 | "Resolver Error 0 (no error)", 10 | "Unknown host", /* 1 HOST_NOT_FOUND */ 11 | "Host name lookup failure", /* 2 TRY_AGAIN */ 12 | "Unknown server error", /* 3 NO_RECOVERY */ 13 | "No address associated with name", /* 4 NO_ADDRESS */ 14 | }; 15 | struct SocketSettings *lss = _lx_get_socket_settings(); 16 | 17 | if (lss->lx_network_type == LX_AMITCP) { 18 | struct TagItem list[] = { 19 | {SBTM_GETREF(SBTC_HERRNOSTRPTR),0}, {TAG_END,TAG_END} 20 | }; 21 | list[0].ti_Data=(ULONG)&err; return (char *)TCP_SocketBaseTagList(list); 22 | } 23 | else if (err < 0) 24 | return "Resolver internal error"; 25 | else if (err < (int)(sizeof(h_errlist)/sizeof(h_errlist[0]))) 26 | return h_errlist[err]; 27 | return "Unknown resolver error"; 28 | } 29 | 30 | void herror(const char *s) 31 | { 32 | if (s && *s) 33 | write(STDERR_FILENO,s,strlen(s)),write(STDERR_FILENO,": ",2); 34 | s = hstrerror(h_errno); 35 | write(STDERR_FILENO,s,strlen(s)),write(STDERR_FILENO,"\n",1); 36 | } 37 | -------------------------------------------------------------------------------- /sources/misc/Makefile.in: -------------------------------------------------------------------------------- 1 | #### Start of system configuration section. #### 2 | 3 | srcdir = @srcdir@ 4 | VPATH = @srcdir@ 5 | 6 | CC = @CC@ 7 | CPP = @CPP@ 8 | AS = @AS@ 9 | 10 | AR = @AR@ 11 | RANLIB = @RANLIB@ 12 | AWK = @AWK@ 13 | 14 | #### End system configuration section #### 15 | 16 | OBJECTS=detach.o swapstack.o 17 | 18 | OPTIONS=-I$(srcdir)/../headers $(CFLAGS) 19 | 20 | vpath %.c $(SOURCEDIR) 21 | 22 | REDEF=-D_DOSBase=___DOSBase \ 23 | -D_UtilityBase=___UtilityBase \ 24 | -D_MathIeeeSingBasBase=___MathIeeeSingBasBase \ 25 | -D_MathIeeeSingTransBase=___MathIeeeSingTransBase \ 26 | -D_MathIeeeDoubBasBase=___MathIeeeDoubBasBase \ 27 | -D_MathIeeeDoubTransBase=___MathIeeeDoubTransBase \ 28 | -D_LocaleBase=___LocaleBase 29 | 30 | #Use private library bases to avoid naming collisions 31 | %.o: %.c 32 | $(CC) $(OPTIONS) -S $^ -o $*.S 2>&1|tee $*.err 33 | $(CPP) -traditional $(REDEF) $*.S -o $*2.S 34 | $(CC) $(OPTIONS) $*2.S -c -o $*.o 35 | -rm $*.S $*2.S 36 | -if test ! -s $*.err; then rm $*.err; fi 37 | echo "\$$$(V)" >>$*.o 38 | 39 | .PHONY: all filelist subdirs clean veryclean 40 | 41 | all: $(OBJECTS) 42 | 43 | filelist: 44 | 45 | subdirs: 46 | 47 | clean: 48 | -rm -f *.o *.err 49 | 50 | veryclean: clean 51 | -------------------------------------------------------------------------------- /sources/nix/stdlib/strtoul.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | unsigned long strtoul(const char *nptr,char **endptr,int base) 8 | { const char *p=nptr,*q; 9 | char c=0; 10 | unsigned long r=0; 11 | if(base<0||base==1||base>36) 12 | { if(endptr!=NULL) 13 | *endptr=(char *)nptr; 14 | return 0; 15 | } 16 | while(isspace(*p)) 17 | p++; 18 | if(*p=='-'||*p=='+') 19 | c=*p++; 20 | if(base==0) 21 | { if(p[0]=='0') 22 | { if(tolower(p[1])=='x'&&isxdigit(p[2])) 23 | { p+=2; 24 | base=16; } 25 | else 26 | base=8; 27 | }else 28 | base=10; 29 | } 30 | q=p; 31 | for(;;) 32 | { int a; 33 | if(!isalnum(*q)) 34 | break; 35 | a=isdigit(*q)?*q-'0':tolower(*q)-('a'-10); 36 | if(a>=base) 37 | break; 38 | if(r>(ULONG_MAX-a)/base||r*base>ULONG_MAX-a) 39 | { errno=ERANGE; /* overflow */ 40 | r=ULONG_MAX; } 41 | else 42 | r=r*base+a; 43 | q++; 44 | } 45 | if(q==p) /* Not a single number read */ 46 | { if(endptr!=NULL) 47 | *endptr=(char *)nptr; 48 | return 0; 49 | } 50 | if(c=='-') 51 | r=-r; 52 | if(endptr!=NULL) 53 | *endptr=(char *)q; 54 | return r; 55 | } 56 | -------------------------------------------------------------------------------- /sources/headers/regparm.h: -------------------------------------------------------------------------------- 1 | #ifndef _HEADERS_REGPARM_H 2 | #define _HEADERS_REGPARM_H 3 | 4 | #define ___PUSH(a) "movel\t" #a ",sp@-\n" 5 | #define ___POP(a) "movel\tsp@+," #a "\n" 6 | 7 | #ifndef SMALL_DATA 8 | 9 | #define __REGP(functype,funcname,pushlist,popval) \ 10 | asm(".even\n" ".globl _" #funcname "\n" "_" #funcname ":\n" \ 11 | pushlist "jbsr\t___" #funcname "\n" "addqw\t#" #popval ",sp\n" \ 12 | "rts\n"); functype __##funcname 13 | 14 | #else 15 | 16 | #define __REGP(functype,funcname,pushlist,popval) \ 17 | asm(".even\n" ".globl _" #funcname "\n" "_" #funcname ":\n" ___PUSH(a4) \ 18 | pushlist "jbsr\t_geta4\n" "jbsr\t___" #funcname "\n" "addqw\t#" #popval ",sp\n" \ 19 | ___POP(a4) "rts\n"); functype __##funcname 20 | 21 | #endif 22 | 23 | #define REGPARM1(functype,funcname,a1,r1) \ 24 | __REGP(functype,funcname,___PUSH(r1),4) (a1) 25 | 26 | #define REGPARM2(functype,funcname,a1,r1,a2,r2) \ 27 | __REGP(functype,funcname,___PUSH(r2)___PUSH(r1),8) (a1,a2) 28 | 29 | #define REGPARM3(functype,funcname,a1,r1,a2,r2,a3,r3) \ 30 | __REGP(functype,funcname,___PUSH(r3)___PUSH(r2)___PUSH(r1),12) (a1,a2,a3) 31 | 32 | #define REGPARM4(functype,funcname,a1,r1,a2,r2,a3,r3,a4,r4) \ 33 | __REGP(functype,funcname,___PUSH(r4)___PUSH(r3)___PUSH(r2)___PUSH(r1),16) (a1,a2,a3,a4) 34 | 35 | #endif /* _HEADERS_REGPARM_H */ 36 | -------------------------------------------------------------------------------- /sources/socket/unistd/gethostname.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | // 5 | #include "socket.h" 6 | 7 | int gethostname(char *name, int namelen) 8 | { struct SocketSettings *lss = _lx_get_socket_settings(); 9 | 10 | if (lss->lx_network_type == LX_AMITCP) { 11 | return TCP_GetHostName(name,namelen); 12 | } 13 | else { /* LX_AS225, default */ 14 | char *host, domain[257+1]; 15 | int len; 16 | if ((host=getenv("HOSTNAME")) || (host=getenv("hostname"))) { 17 | if (!strchr(host, '.')) { 18 | strcpy(domain, host); 19 | domain[len=strlen(domain)] = '.'; 20 | if (++len,!getdomainname(domain+len,sizeof(domain)-len)) 21 | domain[len]=0,host=domain; 22 | } 23 | } 24 | else 25 | host = "localhost"; 26 | strncpy(name, host, namelen); return 0; 27 | } 28 | } 29 | 30 | int 31 | sethostname (const char *name, int namelen) 32 | { 33 | #if 0 // XXX 34 | static char hostname[MAXHOSTNAMELEN] = "localhost"; 35 | struct SocketSettings *lss = _lx_get_socket_settings(); 36 | 37 | if (lss->lx_network_type != LX_AMITCP) { 38 | int len = namelen < sizeof (hostname) - 1 ? namelen : sizeof (hostname) - 1; 39 | strncpy (hostname, name, len); 40 | hostname[len] = 0; 41 | } 42 | #endif 43 | return 0; 44 | } 45 | -------------------------------------------------------------------------------- /sources/amiga/misc/Cia.c: -------------------------------------------------------------------------------- 1 | #include "stabs.h" 2 | 3 | /* Absolute definitions for the cia registers 4 | * some of the are recommended to use 5 | * and very useful when hacking hardware ;-) 6 | */ 7 | 8 | ABSDEF(ciab, 0x00bfd000); 9 | ABSDEF(ciabpra, 0x00bfd000); 10 | ABSDEF(ciabprb, 0x00bfd100); 11 | ABSDEF(ciabddra, 0x00bfd200); 12 | ABSDEF(ciabddrb, 0x00bfd300); 13 | ABSDEF(ciabtalo, 0x00bfd400); 14 | ABSDEF(ciabtahi, 0x00bfd500); 15 | ABSDEF(ciabtblo, 0x00bfd600); 16 | ABSDEF(ciabtbhi, 0x00bfd700); 17 | ABSDEF(ciabtodlow,0x00bfd800); 18 | ABSDEF(ciabtodmid,0x00bfd900); 19 | ABSDEF(ciabtodhi, 0x00bfda00); 20 | ABSDEF(ciabsdr, 0x00bfdc00); 21 | ABSDEF(ciabicr, 0x00bfdd00); 22 | ABSDEF(ciabcra, 0x00bfde00); 23 | ABSDEF(ciabcrb, 0x00bfdf00); 24 | ABSDEF(ciaa, 0x00bfe001); 25 | ABSDEF(ciaapra, 0x00bfe001); 26 | ABSDEF(ciaaprb, 0x00bfe101); 27 | ABSDEF(ciaaddra, 0x00bfe201); 28 | ABSDEF(ciaaddrb, 0x00bfe301); 29 | ABSDEF(ciaatalo, 0x00bfe401); 30 | ABSDEF(ciaatahi, 0x00bfe501); 31 | ABSDEF(ciaatblo, 0x00bfe601); 32 | ABSDEF(ciaatbhi, 0x00bfe701); 33 | ABSDEF(ciaatodlow,0x00bfe801); 34 | ABSDEF(ciaatodmid,0x00bfe901); 35 | ABSDEF(ciaatodhi, 0x00bfea01); 36 | ABSDEF(ciaasdr, 0x00bfec01); 37 | ABSDEF(ciaaicr, 0x00bfed01); 38 | ABSDEF(ciaacra, 0x00bfee01); 39 | ABSDEF(ciaacrb, 0x00bfef01); 40 | -------------------------------------------------------------------------------- /sources/amiga/misc/CreatePort.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #define NEWLIST(l) ((l)->lh_Head = (struct Node *)&(l)->lh_Tail, \ 7 | /*(l)->lh_Tail = NULL,*/ \ 8 | (l)->lh_TailPred = (struct Node *)&(l)->lh_Head) 9 | 10 | struct MsgPort *CreatePort(CONST_STRPTR name,LONG pri) 11 | { APTR SysBase = *(APTR *)4L; 12 | struct MsgPort *port = NULL; 13 | UBYTE portsig; 14 | 15 | if ((BYTE)(portsig=AllocSignal(-1)) >= 0) { 16 | if (!(port=AllocMem(sizeof(*port),MEMF_CLEAR|MEMF_PUBLIC))) 17 | FreeSignal(portsig); 18 | else { 19 | port->mp_Node.ln_Type = NT_MSGPORT; 20 | port->mp_Node.ln_Pri = pri; 21 | port->mp_Node.ln_Name = name; 22 | /* done via AllocMem 23 | port->mp_Flags = PA_SIGNAL; 24 | */ 25 | port->mp_SigBit = portsig; 26 | port->mp_SigTask = FindTask(NULL); 27 | NEWLIST(&port->mp_MsgList); 28 | if (port->mp_Node.ln_Name) 29 | AddPort(port); 30 | } 31 | } 32 | return port; 33 | } 34 | 35 | VOID DeletePort(struct MsgPort *port) 36 | { APTR SysBase = *(APTR *)4L; 37 | 38 | if (port->mp_Node.ln_Name) 39 | RemPort(port); 40 | FreeSignal(port->mp_SigBit); FreeMem(port,sizeof(*port)); 41 | } 42 | -------------------------------------------------------------------------------- /sources/nix/extra/getrusage.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "stabs.h" 8 | 9 | extern void timer(long *); 10 | 11 | /* 12 | ** store system time at startup. getrusage will return 13 | ** (system time - time at startup) as the user time. 14 | */ 15 | 16 | static long initclock[2]; 17 | 18 | void __inittimer() 19 | { 20 | timer(initclock); 21 | } 22 | 23 | ADD2INIT(__inittimer,1); 24 | 25 | int getrusage(int who, struct rusage *rusage) 26 | { 27 | static struct rusage r0 = 28 | { {0, 0}, {0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; 29 | long clock[2]; 30 | int status = 0; 31 | 32 | switch(who) { 33 | case RUSAGE_SELF: 34 | timer(clock); 35 | clock[0] -= initclock[0]; 36 | clock[1] -= initclock[1]; 37 | if (clock[1] < 0) { 38 | clock[1] += 1000000; 39 | clock[0] --; 40 | } 41 | memcpy(rusage,&r0,sizeof(struct rusage)); 42 | rusage->ru_utime.tv_sec = clock[0]; 43 | rusage->ru_utime.tv_usec = clock[1]; 44 | break; 45 | case RUSAGE_CHILDREN: 46 | memcpy(rusage,&r0,sizeof(struct rusage)); 47 | break; 48 | default: 49 | errno = EINVAL; 50 | status = -1; 51 | } 52 | return status; 53 | } 54 | -------------------------------------------------------------------------------- /sources/amiga/misc/AsmCreatePool.c: -------------------------------------------------------------------------------- 1 | #include "pool.h" 2 | 3 | #define NEWLIST(l) ((l)->mlh_Head = (struct MinNode *)&(l)->mlh_Tail, \ 4 | (l)->mlh_Tail = NULL, \ 5 | (l)->mlh_TailPred = (struct MinNode *)&(l)->mlh_Head) 6 | 7 | APTR ASM AsmCreatePool(REG(d0,ULONG requirements),REG(d1,ULONG puddleSize),REG(d2,ULONG threshSize),REG(a6,APTR SysBase)) 8 | { 9 | if (((struct Library *)SysBase)->lib_Version>=39) 10 | return (CreatePool(requirements,puddleSize,threshSize)); 11 | else { 12 | POOL *pool=NULL; 13 | if (threshSize<=puddleSize) { 14 | puddleSize+=7; 15 | if ((pool=(POOL *)AllocMem(sizeof(POOL),MEMF_ANY))!=NULL) { 16 | NEWLIST(&pool->PuddleList); 17 | pool->MemoryFlags=requirements; 18 | pool->PuddleSize=puddleSize&~7; 19 | pool->ThreshSize=threshSize; 20 | } 21 | } 22 | return pool; 23 | } 24 | } 25 | 26 | VOID ASM AsmDeletePool(REG(a0,POOL *poolHeader),REG(a6,APTR SysBase)) 27 | { ULONG *pool,size; 28 | 29 | if (((struct Library *)SysBase)->lib_Version>=39) 30 | DeletePool(poolHeader); 31 | else if (poolHeader!=NULL) { 32 | while((pool=(ULONG *)RemHead((struct List *)&poolHeader->PuddleList))!=NULL) { 33 | size=*--pool; FreeMem(pool,size); 34 | } 35 | FreeMem(poolHeader,sizeof(POOL)); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /sources/nix/extra/__stat.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int __stat(struct stat *buf,struct FileInfoBlock *fib) 6 | { 7 | buf->st_dev=0; 8 | buf->st_ino=fib->fib_DiskKey; 9 | buf->st_mode= 10 | (fib->fib_DirEntryType<0?S_IFREG: 11 | (fib->fib_DirEntryType!=ST_SOFTLINK?S_IFDIR:S_IFLNK))| 12 | (fib->fib_Protection&FIBF_READ?0:S_IRUSR)| 13 | (fib->fib_Protection&FIBF_WRITE?0:S_IWUSR)| 14 | (fib->fib_Protection&FIBF_EXECUTE?0:S_IXUSR)| 15 | (fib->fib_Protection&FIBF_GRP_READ?S_IRGRP:0)| 16 | (fib->fib_Protection&FIBF_GRP_WRITE?S_IWGRP:0)| 17 | (fib->fib_Protection&FIBF_GRP_EXECUTE?S_IXGRP:0)| 18 | (fib->fib_Protection&FIBF_OTR_READ?S_IROTH:0)| 19 | (fib->fib_Protection&FIBF_OTR_WRITE?S_IWOTH:0)| 20 | (fib->fib_Protection&FIBF_OTR_EXECUTE?S_IXOTH:0); 21 | buf->st_nlink=0; 22 | buf->st_uid=fib->fib_OwnerUID; 23 | buf->st_gid=fib->fib_OwnerGID; 24 | buf->st_rdev=0; 25 | buf->st_size=fib->fib_Size; 26 | buf->st_atime=buf->st_mtime=buf->st_ctime= 27 | ((fib->fib_Date.ds_Days+2922)*1440+fib->fib_Date.ds_Minute)*60+ 28 | fib->fib_Date.ds_Tick/TICKS_PER_SECOND; 29 | buf->st_spare1=buf->st_spare2=buf->st_spare3=0; 30 | buf->st_blksize=512; 31 | buf->st_blocks=fib->fib_NumBlocks; 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /sources/nix_main/Makefile.in: -------------------------------------------------------------------------------- 1 | #### Start of system configuration section. #### 2 | 3 | srcdir = @srcdir@ 4 | VPATH = @srcdir@ 5 | 6 | CC = @CC@ 7 | CPP = @CPP@ 8 | AS = @AS@ 9 | 10 | AR = @AR@ 11 | RANLIB = @RANLIB@ 12 | AWK = @AWK@ 13 | 14 | #### End system configuration section #### 15 | 16 | OBJECTS=__nocommandline.o _main.o 17 | 18 | OPTIONS=-I$(srcdir)/../headers $(CFLAGS) 19 | 20 | REDEF=-D_DOSBase=___DOSBase \ 21 | -D_UtilityBase=___UtilityBase \ 22 | -D_MathIeeeSingBasBase=___MathIeeeSingBasBase \ 23 | -D_MathIeeeSingTransBase=___MathIeeeSingTransBase \ 24 | -D_MathIeeeDoubBasBase=___MathIeeeDoubBasBase \ 25 | -D_MathIeeeDoubTransBase=___MathIeeeDoubTransBase \ 26 | -D_LocaleBase=___LocaleBase 27 | 28 | #Use private library bases to avoid naming collisions 29 | %.o: %.c 30 | $(CC) $(OPTIONS) -S $^ -o $*.S 2>&1|tee $*.err 31 | $(CPP) -traditional $(REDEF) $*.S -o $*2.S 32 | $(CC) $(OPTIONS) $*2.S -c -o $*.o 33 | -rm $*.S $*2.S 34 | -if test ! -s $*.err; then rm $*.err; fi 35 | 36 | .PHONY: all filelist subdirs clean veryclean 37 | 38 | all: libnix_main.a 39 | 40 | filelist: 41 | 42 | subdirs: 43 | 44 | clean: 45 | -rm -f *.o *.err 46 | 47 | veryclean: clean 48 | -rm -f libnix_main.a 49 | 50 | libnix_main.a: $(OBJECTS) ../../sources/nix_main/Makefile 51 | -rm -f $@ 52 | $(AR) -q $@ $(OBJECTS) 53 | $(RANLIB) $@ 54 | echo "\$$$(V)" >>$@ 55 | -------------------------------------------------------------------------------- /sources/nixmain/Makefile.in: -------------------------------------------------------------------------------- 1 | #### Start of system configuration section. #### 2 | 3 | srcdir = @srcdir@ 4 | VPATH = @srcdir@ 5 | 6 | CC = @CC@ 7 | CPP = @CPP@ 8 | AS = @AS@ 9 | 10 | AR = @AR@ 11 | RANLIB = @RANLIB@ 12 | AWK = @AWK@ 13 | 14 | #### End system configuration section #### 15 | 16 | OBJECTS=__nocommandline.o __stdiowin.o 17 | 18 | OPTIONS=-I$(srcdir)/../headers $(CFLAGS) 19 | 20 | REDEF=-D_DOSBase=___DOSBase \ 21 | -D_UtilityBase=___UtilityBase \ 22 | -D_MathIeeeSingBasBase=___MathIeeeSingBasBase \ 23 | -D_MathIeeeSingTransBase=___MathIeeeSingTransBase \ 24 | -D_MathIeeeDoubBasBase=___MathIeeeDoubBasBase \ 25 | -D_MathIeeeDoubTransBase=___MathIeeeDoubTransBase \ 26 | -D_LocaleBase=___LocaleBase 27 | 28 | #Use private library bases to avoid naming collisions 29 | %.o: %.c 30 | $(CC) $(OPTIONS) -S $^ -o $*.S 2>&1|tee $*.err 31 | $(CPP) -traditional $(REDEF) $*.S -o $*2.S 32 | $(CC) $(OPTIONS) $*2.S -c -o $*.o 33 | -rm $*.S $*2.S 34 | -if test ! -s $*.err; then rm $*.err; fi 35 | 36 | .PHONY: all filelist subdirs clean veryclean 37 | 38 | all: libnixmain.a 39 | 40 | subdirs: 41 | 42 | filelist: 43 | 44 | clean: 45 | -rm -f *.o *.err 46 | 47 | veryclean: clean 48 | -rm -f libnixmain.a 49 | 50 | libnixmain.a: $(OBJECTS) ../../sources/nixmain/Makefile 51 | -rm -f $@ 52 | $(AR) -q $@ $(OBJECTS) 53 | $(RANLIB) $@ 54 | echo "\$$$(V)" >>$@ 55 | -------------------------------------------------------------------------------- /sources/startup/Makefile.in: -------------------------------------------------------------------------------- 1 | # make startup-files 2 | # 13-Apr-94 G. Nikl 3 | # 14-Apr-94 M. Fleischer clean+veryclean added 4 | 5 | #### Start of system configuration section. #### 6 | 7 | srcdir = @srcdir@ 8 | VPATH = @srcdir@ 9 | 10 | CC = @CC@ 11 | CPP = @CPP@ 12 | AS = @AS@ 13 | 14 | AR = @AR@ 15 | RANLIB = @RANLIB@ 16 | AWK = @AWK@ 17 | 18 | #### End system configuration section #### 19 | 20 | OPTIONS=-I$(srcdir)/../headers -O -fomit-frame-pointer 21 | 22 | %.o: %.c 23 | $(CC) $(OPTIONS) -c $^ 2>&1|tee $*.err 24 | -if test ! -s $*.err; then rm $*.err; fi 25 | echo "\$$$(V)" >>$@ 26 | 27 | .PHONY: all filelist subdirs clean veryclean 28 | 29 | all: nrcrt0.o nbcrt0.o nlrcrt0.o nlbcrt0.o ncrt0.o libinit.o libinitr.o devinit.o 30 | 31 | subdirs: 32 | 33 | filelist: 34 | 35 | clean: 36 | 37 | veryclean: 38 | -rm *.o 39 | 40 | # baserelative resident startup-code 41 | 42 | nrcrt0.o: nrcrt0.S 43 | $(CC) -c $^ 44 | echo "\$$$(V)" >>$@ 45 | 46 | # large baserelative resident startup-code 47 | 48 | nlrcrt0.o: nlrcrt0.S 49 | $(CC) -m68020 -c $^ 50 | echo "\$$$(V)" >>$@ 51 | # baserelative startup code 52 | 53 | nbcrt0.o: nbcrt0.S 54 | $(CC) -c $^ 55 | echo "\$$$(V)" >>$@ 56 | 57 | # large baserelative startup code 58 | 59 | nlbcrt0.o: nlbcrt0.S 60 | $(CC) -m68020 -c $^ 61 | echo "\$$$(V)" >>$@ 62 | 63 | 64 | # normal (=large) startup code 65 | 66 | ncrt0.o: ncrt0.S 67 | $(CC) -c $^ 68 | echo "\$$$(V)" >>$@ 69 | -------------------------------------------------------------------------------- /sources/nix/Makefile.in: -------------------------------------------------------------------------------- 1 | #### Start of system configuration section. #### 2 | 3 | srcdir = @srcdir@ 4 | VPATH = @srcdir@ 5 | 6 | CC = @CC@ 7 | CPP = @CPP@ 8 | AS = @AS@ 9 | 10 | AR = @AR@ 11 | RANLIB = @RANLIB@ 12 | AWK = @AWK@ 13 | 14 | #### End system configuration section #### 15 | 16 | ifneq ($(TARGET),clean) 17 | include ../../sources/nix/filelist 18 | endif 19 | 20 | CURDIR = $(shell pwd) 21 | 22 | OPTIONS=-I$(srcdir)/../headers $(CFLAGS) 23 | 24 | REDEF=-D_DOSBase=___DOSBase \ 25 | -D_UtilityBase=___UtilityBase \ 26 | -D_MathIeeeSingBasBase=___MathIeeeSingBasBase \ 27 | -D_MathIeeeSingTransBase=___MathIeeeSingTransBase \ 28 | -D_MathIeeeDoubBasBase=___MathIeeeDoubBasBase \ 29 | -D_MathIeeeDoubTransBase=___MathIeeeDoubTransBase \ 30 | -D_LocaleBase=___LocaleBase 31 | 32 | %.o: %.c 33 | $(CC) $(OPTIONS) -S $^ -o $*.S 2>&1|tee $*.err 34 | $(CPP) -traditional $(REDEF) $*.S -o $*2.S 35 | $(CC) $(OPTIONS) $*2.S -c -o $*.o 36 | -rm $*.S $*2.S 37 | -if test ! -s $*.err; then rm $*.err; fi 38 | 39 | .PHONY: all clean veryclean 40 | 41 | all: libnix.a 42 | 43 | clean: 44 | -rm -rf $(SUBDIRS) 45 | 46 | veryclean: 47 | -rm -rf * 48 | 49 | $(foreach f,$(SUBDIRS),$(CURDIR)/$(f)): 50 | mkdir $@ 51 | 52 | libnix.a: $(foreach f,$(SUBDIRS),$(CURDIR)/$(f)) $(OBJECTS) ../../sources/nix/Makefile ../../sources/nix/filelist 53 | -rm -f $@ 54 | $(AR) -q $@ $(OBJECTS) 55 | $(RANLIB) $@ 56 | echo "\$$$(V)" >>$@ 57 | -------------------------------------------------------------------------------- /sources/nix/extra/dotimer.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #define NEWLIST(l) ((l)->lh_Head = (struct Node *)&(l)->lh_Tail, \ 6 | (l)->lh_TailPred = (struct Node *)&(l)->lh_Head) 7 | 8 | void dotimer(ULONG unit,ULONG timercmd,struct timeval *t) 9 | { struct PortIO { 10 | struct timerequest treq; 11 | struct MsgPort port; 12 | } *portio; 13 | 14 | if ((portio=(struct PortIO *)AllocMem(sizeof(*portio),MEMF_CLEAR|MEMF_PUBLIC))) { 15 | portio->port.mp_Node.ln_Type=NT_MSGPORT; 16 | if ((BYTE)(portio->port.mp_SigBit=AllocSignal(-1))>=0) { 17 | portio->port.mp_SigTask=FindTask(NULL); 18 | NEWLIST(&portio->port.mp_MsgList); 19 | portio->treq.tr_node.io_Message.mn_Node.ln_Type=NT_REPLYMSG; 20 | portio->treq.tr_node.io_Message.mn_ReplyPort=&portio->port; 21 | if (!(OpenDevice(TIMERNAME,unit,&portio->treq.tr_node,0))) { 22 | portio->treq.tr_node.io_Command=timercmd; 23 | portio->treq.tr_time.tv_secs =t->tv_secs; 24 | portio->treq.tr_time.tv_micro=t->tv_micro; 25 | if (!DoIO(&portio->treq.tr_node)) { 26 | t->tv_secs =portio->treq.tr_time.tv_secs; 27 | t->tv_micro=portio->treq.tr_time.tv_micro; 28 | } 29 | CloseDevice(&portio->treq.tr_node); 30 | } 31 | FreeSignal(portio->port.mp_SigBit); 32 | } 33 | FreeMem(portio,sizeof(struct PortIO)); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /sources/amiga/misc/TimeDelay.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #define NEWLIST(l) ((l)->lh_Head = (struct Node *)&(l)->lh_Tail, \ 6 | /*(l)->lh_Tail = NULL,*/ \ 7 | (l)->lh_TailPred = (struct Node *)&(l)->lh_Head) 8 | 9 | LONG TimeDelay(LONG unit,ULONG secs,ULONG microsecs) 10 | { APTR SysBase = *(APTR *)4L; 11 | struct PortIO { 12 | struct timerequest treq; 13 | struct MsgPort port; 14 | } *portio; 15 | LONG ret=-1; 16 | 17 | if ((portio=(struct PortIO *)AllocMem(sizeof(*portio),MEMF_CLEAR|MEMF_PUBLIC))) { 18 | portio->port.mp_Node.ln_Type=NT_MSGPORT; 19 | if ((BYTE)(portio->port.mp_SigBit=AllocSignal(-1))>=0) { 20 | portio->port.mp_SigTask=FindTask(NULL); 21 | NEWLIST(&portio->port.mp_MsgList); 22 | portio->treq.tr_node.io_Message.mn_Node.ln_Type=NT_REPLYMSG; 23 | portio->treq.tr_node.io_Message.mn_ReplyPort=&portio->port; 24 | if (!(OpenDevice(TIMERNAME,unit,&portio->treq.tr_node,0))) { 25 | portio->treq.tr_node.io_Command=TR_ADDREQUEST; 26 | portio->treq.tr_time.tv_secs=secs; 27 | portio->treq.tr_time.tv_micro=microsecs; 28 | if (!DoIO(&portio->treq.tr_node)) 29 | ret=0; 30 | CloseDevice(&portio->treq.tr_node); 31 | } 32 | FreeSignal(portio->port.mp_SigBit); 33 | } 34 | FreeMem(portio,sizeof(*portio)); 35 | } 36 | 37 | return ret; 38 | } 39 | -------------------------------------------------------------------------------- /sources/nix13/Makefile.in: -------------------------------------------------------------------------------- 1 | #### Start of system configuration section. #### 2 | 3 | srcdir = @srcdir@ 4 | VPATH = @srcdir@ 5 | 6 | CC = @CC@ 7 | CPP = @CPP@ 8 | AS = @AS@ 9 | 10 | AR = @AR@ 11 | RANLIB = @RANLIB@ 12 | AWK = @AWK@ 13 | 14 | #### End system configuration section #### 15 | 16 | ifneq ($(TARGET),clean) 17 | include ../../sources/nix13/filelist 18 | endif 19 | 20 | CURDIR = $(shell pwd) 21 | 22 | OPTIONS=-I$(srcdir)/../headers $(CFLAGS) -msmall-code 23 | 24 | REDEF=-D_DOSBase=___DOSBase \ 25 | -D_UtilityBase=___UtilityBase \ 26 | -D_MathIeeeSingBasBase=___MathIeeeSingBasBase \ 27 | -D_MathIeeeSingTransBase=___MathIeeeSingTransBase \ 28 | -D_MathIeeeDoubBasBase=___MathIeeeDoubBasBase \ 29 | -D_MathIeeeDoubTransBase=___MathIeeeDoubTransBase \ 30 | -D_LocaleBase=___LocaleBase 31 | 32 | %.o: %.c 33 | $(CC) $(OPTIONS) -S $^ -o $*.S 2>&1|tee $*.err 34 | $(CPP) -traditional $(REDEF) $*.S -o $*2.S 35 | $(CC) $(OPTIONS) $*2.S -c -o $*.o 36 | -rm $*.S $*2.S 37 | -if test ! -s $*.err; then rm $*.err; fi 38 | 39 | .PHONY: all clean veryclean 40 | 41 | all: libnix13.a 42 | 43 | clean: 44 | -rm -rf $(SUBDIRS) 45 | 46 | veryclean: 47 | -rm -rf * 48 | 49 | $(foreach f,$(SUBDIRS),$(CURDIR)/$(f)): 50 | mkdir $@ 51 | 52 | libnix13.a: $(foreach f,$(SUBDIRS),$(CURDIR)/$(f)) $(OBJECTS) ../../sources/nix13/Makefile ../../sources/nix13/filelist 53 | -rm -f $@ 54 | $(AR) -q $@ $(OBJECTS) 55 | $(RANLIB) $@ 56 | echo "\$$$(V)" >>$@ 57 | -------------------------------------------------------------------------------- /sources/nix20/Makefile.in: -------------------------------------------------------------------------------- 1 | #### Start of system configuration section. #### 2 | 3 | srcdir = @srcdir@ 4 | VPATH = @srcdir@ 5 | 6 | CC = @CC@ 7 | CPP = @CPP@ 8 | AS = @AS@ 9 | 10 | AR = @AR@ 11 | RANLIB = @RANLIB@ 12 | AWK = @AWK@ 13 | 14 | #### End system configuration section #### 15 | 16 | ifneq ($(TARGET),clean) 17 | include ../../sources/nix20/filelist 18 | endif 19 | 20 | CURDIR = $(shell pwd) 21 | 22 | OPTIONS=-I$(srcdir)/../headers $(CFLAGS) -msmall-code 23 | 24 | REDEF=-D_DOSBase=___DOSBase \ 25 | -D_UtilityBase=___UtilityBase \ 26 | -D_MathIeeeSingBasBase=___MathIeeeSingBasBase \ 27 | -D_MathIeeeSingTransBase=___MathIeeeSingTransBase \ 28 | -D_MathIeeeDoubBasBase=___MathIeeeDoubBasBase \ 29 | -D_MathIeeeDoubTransBase=___MathIeeeDoubTransBase \ 30 | -D_LocaleBase=___LocaleBase 31 | 32 | %.o: %.c 33 | $(CC) $(OPTIONS) -S $^ -o $*.S 2>&1|tee $*.err 34 | $(CPP) -traditional $(REDEF) $*.S -o $*2.S 35 | $(CC) $(OPTIONS) $*2.S -c -o $*.o 36 | -rm $*.S $*2.S 37 | -if test ! -s $*.err; then rm $*.err; fi 38 | 39 | .PHONY: all clean veryclean 40 | 41 | all: libnix20.a 42 | 43 | clean: 44 | -rm -rf $(SUBDIRS) 45 | 46 | veryclean: 47 | -rm -rf * 48 | 49 | $(foreach f,$(SUBDIRS),$(CURDIR)/$(f)): 50 | mkdir $@ 51 | 52 | libnix20.a: $(foreach f,$(SUBDIRS),$(CURDIR)/$(f)) $(OBJECTS) ../../sources/nix20/Makefile ../../sources/nix20/filelist 53 | -rm -f $@ 54 | $(AR) -q $@ $(OBJECTS) 55 | $(RANLIB) $@ 56 | echo "\$$$(V)" >>$@ 57 | -------------------------------------------------------------------------------- /README.BETA: -------------------------------------------------------------------------------- 1 | This is BETA 2 of libnix and its considered final. Changes compared with 2 | the previous BETA are completed append mode (now works for fdopen()), 3 | stderr behavoir according to the standard (always unbuffered; previosly 4 | it had the normal fopen() mode) since write-only streams are now optimized 5 | (as in *BSD ;-). The internal socket i/o interface was changed for better 6 | system compatibility (used a packet in private memory, now its DOS alloced) 7 | The only change that I consider is a makefile change: changing the 8 | optimization level from -O3 to -O2 or -Os. 9 | 10 | ---old--- 11 | 12 | This libnix version is BETA!!! The final version will certainly contain 13 | changes compared to this snapshot. 14 | Its intended for those who are interested and are able to recompile the 15 | libraries. This packaged can be compiled under a cross compiler environment. 16 | The configure script MUST be invoked through an absolute pathname! If you 17 | configure it with a relative pathname you have to modify VPATH and srcdir 18 | in startup/Makefile (remove the first ../). 19 | 20 | libnix 2.0 finally offers support for networking. The network support is 21 | in a new link library called libsocket.a. This code is based on work by 22 | Jeff Sheperd. For a more changes consult sources/history. The list is 23 | probably no complete. 24 | 25 | Send comments and bugreports to: 26 | 27 | gnikl@informatik.uni-rostock.de 28 | 29 | with a subject including "libnix BETA". 30 | 31 | Flames to dev/null :-) 32 | -------------------------------------------------------------------------------- /sources/nix/ctype/_ctype_.c: -------------------------------------------------------------------------------- 1 | unsigned char __ctype[]= 2 | { 0x00, 3 | 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x28,0x28,0x28,0x28,0x28,0x20,0x20, 4 | 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 5 | 0x88,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10, 6 | 0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x10,0x10,0x10,0x10,0x10,0x10, 7 | 0x10,0x41,0x41,0x41,0x41,0x41,0x41,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, 8 | 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x10,0x10,0x10,0x10,0x10, 9 | 0x10,0x42,0x42,0x42,0x42,0x42,0x42,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02, 10 | 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x10,0x10,0x10,0x10,0x20, 11 | 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 12 | 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 13 | 0x08,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10, 14 | 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10, 15 | 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, 16 | 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x10,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02, 17 | 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02, 18 | 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x10,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02, 19 | 0x00,0x00,0x00 20 | }; 21 | 22 | const unsigned char *_ctype_=__ctype; 23 | -------------------------------------------------------------------------------- /sources/stubs/misc/__initlibraries.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "stabs.h" 3 | 4 | extern struct lib /* These are the elements pointed to by __LIB_LIST__ */ 5 | { struct Library *base; 6 | char *name; 7 | } *__LIB_LIST__[]; 8 | 9 | extern ULONG __oslibversion; 10 | extern void __request(const char *text); 11 | extern void exit(int returncode); 12 | 13 | static void __openliberror(ULONG,...) __attribute__ ((noreturn)); 14 | 15 | static void __openliberror(ULONG version,...) 16 | { static const ULONG tricky=0x16c04e75; /* move.b d0,(a3)+ ; rts */ 17 | char buf[60]; 18 | 19 | RawDoFmt("Need version %.10ld of %.32s",(APTR)&version,(void (*)())&tricky,buf); 20 | __request(buf); 21 | exit(20); 22 | } 23 | 24 | void __initlibraries(void) 25 | { 26 | ULONG version=__oslibversion; 27 | struct lib **list=__LIB_LIST__; 28 | ULONG numbases=(ULONG)*list++; 29 | 30 | if(numbases) 31 | do { 32 | struct lib *l=*list++; 33 | if((l->base=OpenLibrary(l->name,version))==NULL) 34 | __openliberror(version,l->name); 35 | } while(--numbases); 36 | } 37 | 38 | void __exitlibraries(void) 39 | { 40 | struct lib **list=__LIB_LIST__; 41 | ULONG numbases=(ULONG)*list++; 42 | 43 | if(numbases) 44 | do { 45 | struct lib *l=*list++; 46 | struct Library *lb=l->base; 47 | if(lb!=NULL) { 48 | /* l->base=NULL; */ 49 | CloseLibrary(lb); 50 | } 51 | } while(--numbases); 52 | } 53 | 54 | ADD2INIT(__initlibraries,-60); 55 | ADD2EXIT(__exitlibraries,-60); 56 | -------------------------------------------------------------------------------- /sources/nix/extra/fstat.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | extern void __seterrno(void); 10 | 11 | int fstat(int d,struct stat *buf) 12 | { extern int __stat(struct stat *buf,struct FileInfoBlock *fib); 13 | StdFileDes *fp = _lx_fhfromfd(d); 14 | struct FileInfoBlock *fib; 15 | LONG pos,len,fh; 16 | 17 | if (fp && (fh=fp->lx_fh)) { 18 | if ((fib=(struct FileInfoBlock *)AllocDosObject(DOS_FIB,NULL)) == NULL) { 19 | __seterrno(); return -1; 20 | } 21 | } else return -1; 22 | 23 | memset(buf,0,sizeof(*buf)); 24 | 25 | buf->st_mode = S_IFCHR | 0777; 26 | buf->st_nlink = 1; 27 | buf->st_blksize = 512; 28 | /*buf->st_blocks = 0;*/ 29 | 30 | if (((struct FileHandle *)BADDR(fh))->fh_Type) { 31 | 32 | if (!ExamineFH(fh,fib)) { 33 | 34 | len = 0; pos = Seek(fh,0,OFFSET_END); 35 | if (pos >= 0 && (IoErr() != ERROR_ACTION_NOT_KNOWN)) 36 | len = Seek(fh,pos,OFFSET_BEGINNING); 37 | 38 | fib->fib_DiskKey = (ino_t)~((LONG)fh); 39 | fib->fib_DirEntryType = -1; 40 | fib->fib_Size = len; 41 | fib->fib_Protection = 0xff0; 42 | fib->fib_NumBlocks = (len+=511,len>>=9); 43 | DateStamp(&fib->fib_Date); 44 | } 45 | 46 | __stat(buf,fib); 47 | 48 | if (Seek(fh,0,OFFSET_CURRENT),IoErr()) 49 | buf->st_mode = ((buf->st_mode & ~S_IFREG) | S_IFCHR); 50 | } 51 | 52 | FreeDosObject(DOS_FIB,fib); return 0; 53 | } 54 | -------------------------------------------------------------------------------- /sources/nix_main/__nocommandline.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a different calling convention for main (actually it's _main): 3 | * 4 | * int main(char *commandline); 5 | * void exit(int returncode); 6 | * 7 | */ 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "stabs.h" 15 | 16 | extern char *__argc; /* Defined in startup */ 17 | extern char *__commandline; 18 | extern unsigned long __commandlen; 19 | extern struct WBStartup *_WBenchMsg; 20 | 21 | /* This guarantees that this module gets linked in. 22 | If you replace this by an own reference called 23 | __nocommandline you get no commandline arguments */ 24 | ALIAS(__nocommandline,__initcommandline); 25 | 26 | void __initcommandline(void) 27 | { if(_WBenchMsg==NULL) 28 | { unsigned long len,i; 29 | char *a; 30 | 31 | for(len=__commandlen,i=256;;i+=256) /* try in steps of 256 bytes */ 32 | { if(!(__argc=a=(char *)AllocVec(i+len+4,MEMF_ANY))) 33 | exit(20); 34 | GetProgramName(a+1,i); /* Who am I ? */ 35 | if(IoErr()!=ERROR_LINE_TOO_LONG) 36 | break; 37 | FreeVec(a); 38 | } 39 | *a++='\"'; 40 | while(*a++) 41 | ; 42 | a[-1]='\"'; 43 | *a++=' '; 44 | a[len]=0; 45 | CopyMem(__commandline,a,len); 46 | } 47 | } 48 | 49 | void __exitcommandline(void) 50 | { char **ac; 51 | 52 | if(*(ac=&__argc)!=NULL) 53 | FreeVec(*ac); 54 | } 55 | 56 | /* Add these two functions to the lists */ 57 | ADD2INIT(__initcommandline,-40); 58 | ADD2EXIT(__exitcommandline,-40); 59 | -------------------------------------------------------------------------------- /Product-Info: -------------------------------------------------------------------------------- 1 | .name 2 | libnix 3 | .aminet-dir 4 | dev/gcc 5 | .type 6 | Library 7 | .short 8 | A library for amiga specific gcc develp. 9 | .description 10 | This is libnix, a static (i.e. link) library for gcc 2.3.3 or above. 11 | It's not a replacement for ixemul.library (though it's possible to 12 | recompile most of the gcc environment with libnix) but a good thing 13 | for amiga specific development on gcc: 14 | 15 | * It's mostly compatible to SAS's way of handling things, i.e. 16 | you get even an automatic shared library opening feature and 17 | some other things you may miss in ixemul.library. 18 | This also means it's ANSI compliant. 19 | 20 | * It doesn't need any shared libraries than normal Amiga OS ones. 21 | 22 | * It is not copyrighted by the FSF. Therefore you neither need 23 | to include sources nor objects together with your executable. 24 | (read the GLGPL _before_ flaming on this statement) 25 | 26 | * And it's short! I was able to compile a 492 byte 'hello, world' 27 | using normal main. 28 | 29 | * It uses OS20 features whenever necessary. 30 | 31 | To cut it short: 32 | 33 | Use ixemul.library for porting Un*x programs, libnix for compiling 34 | amiga-only programs and gcc becomes one of the best Amiga compilers. 35 | .version 36 | 1.2 37 | .author 38 | Matthias Fleischer 39 | Gunther Nikl 40 | .distribution 41 | Public Domain 42 | .email 43 | fleischr@izfm.uni-stuttgart.de 44 | gnikl@informatik.uni-rostock.de 45 | .docs 46 | libnix.guide 47 | libnix.readme 48 | .described-by 49 | Fred Fish (fnf@amigalib.com) 50 | .submittal 51 | Downloaded via ftp from aminet (wuarchive.wustl.edu). 52 | -------------------------------------------------------------------------------- /sources/nix/stdio/__srget.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int __srget(FILE *stream) /* Get next input block */ 6 | { 7 | if(stream->flags&(__SERR|__SEOF)) /* Error on stream / EOF */ 8 | { 9 | stream->incount=0; 10 | errno=EPERM; 11 | return EOF; 12 | } 13 | if(stream->flags&__SWR) 14 | { 15 | if(__fflush(stream)) 16 | return EOF; 17 | }else if(stream->tmpp!=NULL) /* File is in ungetc mode */ 18 | { 19 | stream->p=stream->tmpp; 20 | stream->incount=stream->tmpinc; 21 | stream->tmpp=NULL; 22 | if(--stream->incount>=0) 23 | return *stream->p++; 24 | } 25 | if(stream->flags&__SSTR) /* it's a sscanf buffer */ 26 | return EOF; 27 | if(stream->flags&(__SNBF|__SLBF)) /* Before reading from line- or unbuffered input file */ 28 | { /* fflush all line buffered output files (ANSI) */ 29 | struct filenode *fp=(struct filenode *)__filelist.mlh_Head; 30 | while(fp->node.mln_Succ) 31 | { 32 | if((fp->FILE.flags&(__SWR|__SLBF))==(__SWR|__SLBF)) 33 | __fflush(&fp->FILE); /* Don't return EOF if this fails */ 34 | fp=(struct filenode *)fp->node.mln_Succ; 35 | } 36 | } 37 | stream->flags|=__SRD; 38 | stream->incount=read(stream->file,stream->buffer,stream->bufsize); 39 | if(!stream->incount) /* EOF found */ 40 | { 41 | stream->flags|=__SEOF; 42 | return EOF; 43 | }else if(stream->incount<0) /* Error */ 44 | { 45 | stream->incount=0; 46 | stream->flags|=__SERR; 47 | return EOF; 48 | } 49 | stream->incount--; 50 | stream->p=stream->buffer; 51 | return *stream->p++; 52 | } 53 | --------------------------------------------------------------------------------