1
0
mirror of https://github.com/adtools/clib2.git synced 2025-12-08 14:59:05 +00:00

7 Commits

Author SHA1 Message Date
Olaf Barthel
428c82ed2e This commit was manufactured by cvs2svn to create tag 'V1_206'.
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/tags/V1_206@15216 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2015-04-24 14:00:24 +00:00
Olaf Barthel
718574aae5 m.lib 1.206 (24.4.2015)
- The fscanf() family failed to parse and convert %f parameters correctly
  if the respective number did not begin with a digit, but a decimal
  point. Hence ".7" would not be processed, but "0.7" would.

c.lib 1.206 (24.4.2015)

- Reworked the __putc() and putc() macros to reference the 'c' input
  parameter only once, and to be free of side-effects when tinkering
  with the buffer position.

- isatty() had the __fd_lock() call in the wrong place, which could have
  led to cleanup problems later.

- The close action in the stdio, socket and termios hook code now
  also zaps the fd pointer itself after cleaning up the file descriptor
  table entry.

- Removed the remains of all the stack extension and stack overflow/underflow
  checking code. It never actually worked. The bit that does work is the stack
  usage measurement code, plus the bit that sets up the the custom stack
  according to local setting or by calling a query function.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15215 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2015-04-24 14:00:23 +00:00
Olaf Barthel
bdfdd84e38 - Bumped math library versions, due to vfscanf() changes.
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15214 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2015-04-24 13:56:39 +00:00
Olaf Barthel
eeb4e5d7aa - Floating point numbers which do not begin with a digit, but with a decimal point, are now processed correctly.
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15213 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2015-04-24 13:00:12 +00:00
Olaf Barthel
a665fffff1 - Removed the remains of all the stack extension and stack overflow/underflow
checking code. It never actually worked. The bit that does work is the stack
  usage measurement code, plus the bit that sets up the the custom stack
  according to local setting or by calling a query function.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15212 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2010-10-20 13:50:17 +00:00
Olaf Barthel
a436ebdad1 - Reworked the __putc() and putc() macros to reference the 'c' input
parameter only once, and to be free of side-effects when tinkering
  with the buffer position.

- isatty() had the __fd_lock() call in the wrong place, which could have
  led to cleanup problems later.

- The close action in the stdio, socket and termios hook code now
  also zaps the fd pointer itself after cleaning up the file descriptor
  table entry.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15211 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2010-10-20 13:12:59 +00:00
Olaf Barthel
81e66075e2 - The fputc() and __putc() macros were not entirely free of side-effects. Ouch.
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15210 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2010-10-19 09:35:16 +00:00
73 changed files with 99 additions and 3947 deletions

View File

@@ -1,13 +0,0 @@
# The "checkoutlist" file is used to support additional version controlled
# administrative files in $CVSROOT/CVSROOT, such as template files.
#
# The first entry on a line is a filename which will be checked out from
# the corresponding RCS file in the $CVSROOT/CVSROOT directory.
# The remainder of the line is an error message to use if the file cannot
# be checked out.
#
# File format:
#
# [<whitespace>]<filename>[<whitespace><error message>]<end-of-line>
#
# comment lines begin with '#'

View File

@@ -1,15 +0,0 @@
# The "commitinfo" file is used to control pre-commit checks.
# The filter on the right is invoked with the repository and a list
# of files to check. A non-zero exit of the filter program will
# cause the commit to be aborted.
#
# The first entry on a line is a regular expression which is tested
# against the directory that the change is being committed to, relative
# to the $CVSROOT. For the first match that is found, then the remainder
# of the line is the name of the filter to run.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name "ALL" appears as a regular expression it is always used
# in addition to the first matching regex or "DEFAULT".

View File

@@ -1,21 +0,0 @@
# Set this to "no" if pserver shouldn't check system users/passwords
#SystemAuth=no
# Put CVS lock files in this directory rather than directly in the repository.
#LockDir=/var/lock/cvs
# Set `TopLevelAdmin' to `yes' to create a CVS directory at the top
# level of the new working directory when using the `cvs checkout'
# command.
#TopLevelAdmin=no
# Set `LogHistory' to `all' or `TOEFWUPCGMAR' to log all transactions to the
# history file, or a subset as needed (ie `TMAR' logs all write operations)
#LogHistory=TOEFWUPCGMAR
# Set `RereadLogAfterVerify' to `always' (the default) to allow the verifymsg
# script to change the log message. Set it to `stat' to force CVS to verify# that the file has changed before reading it (this can take up to an extra
# second per directory being committed, so it is not recommended for large
# repositories. Set it to `never' (the previous CVS behavior) to prevent
# verifymsg scripts from changing the log message.
#RereadLogAfterVerify=always

View File

@@ -1,19 +0,0 @@
# This file affects handling of files based on their names.
#
# The -m option specifies whether CVS attempts to merge files.
#
# The -k option specifies keyword expansion (e.g. -kb for binary).
#
# Format of wrapper file ($CVSROOT/CVSROOT/cvswrappers or .cvswrappers)
#
# wildcard [option value][option value]...
#
# where option is one of
# -f from cvs filter value: path to filter
# -t to cvs filter value: path to filter
# -m update methodology value: MERGE or COPY
# -k expansion mode value: b, o, kkv, &c
#
# and value is a single-quote delimited value.
# For example:
#*.gif -k 'b'

View File

@@ -1,21 +0,0 @@
# The "editinfo" file is used to allow verification of logging
# information. It works best when a template (as specified in the
# rcsinfo file) is provided for the logging procedure. Given a
# template with locations for, a bug-id number, a list of people who
# reviewed the code before it can be checked in, and an external
# process to catalog the differences that were code reviewed, the
# following test can be applied to the code:
#
# Making sure that the entered bug-id number is correct.
# Validating that the code that was reviewed is indeed the code being
# checked in (using the bug-id number or a seperate review
# number to identify this particular code set.).
#
# If any of the above test failed, then the commit would be aborted.
#
# Actions such as mailing a copy of the report to each reviewer are
# better handled by an entry in the loginfo file.
#
# One thing that should be noted is the the ALL keyword is not
# supported. There can be only one entry that matches a given
# repository.

View File

@@ -1,27 +0,0 @@
# The "loginfo" file controls where "cvs commit" log information
# is sent. The first entry on a line is a regular expression which must match
# the directory that the change is being made to, relative to the
# $CVSROOT. If a match is found, then the remainder of the line is a filter
# program that should expect log information on its standard input.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name ALL appears as a regular expression it is always used
# in addition to the first matching regex or DEFAULT.
#
# You may specify a format string as part of the
# filter. The string is composed of a `%' followed
# by a single format character, or followed by a set of format
# characters surrounded by `{' and `}' as separators. The format
# characters are:
#
# s = file name
# V = old version number (pre-checkin)
# v = new version number (post-checkin)
# t = tag or branch name
#
# For example:
#DEFAULT (echo ""; id; echo %s; date; cat) >> $CVSROOT/CVSROOT/commitlog
# or
#DEFAULT (echo ""; id; echo %{sVv}; date; cat) >> $CVSROOT/CVSROOT/commitlog

View File

@@ -1,26 +0,0 @@
# Three different line formats are valid:
# key -a aliases...
# key [options] directory
# key [options] directory files...
#
# Where "options" are composed of:
# -i prog Run "prog" on "cvs commit" from top-level of module.
# -o prog Run "prog" on "cvs checkout" of module.
# -e prog Run "prog" on "cvs export" of module.
# -t prog Run "prog" on "cvs rtag" of module.
# -u prog Run "prog" on "cvs update" of module.
# -d dir Place module in directory "dir" instead of module name.
# -l Top-level directory only -- do not recurse.
#
# NOTE: If you change any of the "Run" options above, you'll have to
# release and re-checkout any working directories of these modules.
#
# And "directory" is a path to a directory relative to $CVSROOT.
#
# The "-a" option specifies an alias. An alias is interpreted as if
# everything on the right of the "-a" had been typed on the command line.
#
# You can encode a module within a module by using the special '&'
# character to interpose another module into the current module. This
# can be useful for creating a module that consists of many directories
# spread out over the entire source repository.

View File

@@ -1,12 +0,0 @@
# The "notify" file controls where notifications from watches set by
# "cvs watch add" or "cvs edit" are sent. The first entry on a line is
# a regular expression which is tested against the directory that the
# change is being made to, relative to the $CVSROOT. If it matches,
# then the remainder of the line is a filter program that should contain
# one occurrence of %s for the user to notify, and information on its
# standard input.
#
# "ALL" or "DEFAULT" can be used in place of the regular expression.
#
# For example:
#ALL mail -s "CVS notification" %s

View File

@@ -1,13 +0,0 @@
# The "rcsinfo" file is used to control templates with which the editor
# is invoked on commit and import.
#
# The first entry on a line is a regular expression which is tested
# against the directory that the change is being made to, relative to the
# $CVSROOT. For the first match that is found, then the remainder of the
# line is the name of the file that contains the template.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name "ALL" appears as a regular expression it is always used
# in addition to the first matching regex or "DEFAULT".

View File

@@ -1,20 +0,0 @@
# The "taginfo" file is used to control pre-tag checks.
# The filter on the right is invoked with the following arguments:
#
# $1 -- tagname
# $2 -- operation "add" for tag, "mov" for tag -F, and "del" for tag -d
# $3 -- repository
# $4-> file revision [file revision ...]
#
# A non-zero exit of the filter program will cause the tag to be aborted.
#
# The first entry on a line is a regular expression which is tested
# against the directory that the change is being committed to, relative
# to the $CVSROOT. For the first match that is found, then the remainder
# of the line is the name of the filter to run.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name "ALL" appears as a regular expression it is always used
# in addition to the first matching regex or "DEFAULT".

View File

@@ -1,21 +0,0 @@
# The "verifymsg" file is used to allow verification of logging
# information. It works best when a template (as specified in the
# rcsinfo file) is provided for the logging procedure. Given a
# template with locations for, a bug-id number, a list of people who
# reviewed the code before it can be checked in, and an external
# process to catalog the differences that were code reviewed, the
# following test can be applied to the code:
#
# Making sure that the entered bug-id number is correct.
# Validating that the code that was reviewed is indeed the code being
# checked in (using the bug-id number or a seperate review
# number to identify this particular code set.).
#
# If any of the above test failed, then the commit would be aborted.
#
# Actions such as mailing a copy of the report to each reviewer are
# better handled by an entry in the loginfo file.
#
# One thing that should be noted is the the ALL keyword is not
# supported. There can be only one entry that matches a given
# repository.

View File

@@ -1,30 +0,0 @@
<!DOCTYPE html public "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<title>Notes on building the library</title>
<body>
<h1>Notes on building the library</h1>
<p>In order to build the library, you need a 'C' compiler (obvious, isn't it?) and
a set of header files for the networking API definitions. The networking header
files go into a directory <tt>netinclude</tt> which has to sit in the same directory as
the source code and the <tt>include</tt> directory you find in there. I'm not currently
supplying these header files here. Drop me a line, and I'll take care of that.</p>
<p>The SAS/C flavour (<tt>smakefile</tt>) should get the library built using the "large data"
model. This rules out the use of residentable programs as the startup code I'm
using is very primitive (<tt>startup.o</tt>) and doesn't tinker with A4 relative data
addressing (and how this may be set up).</p>
<p>There are two makefiles for GCC, each a different flavour. There is <tt>GNUmakefile.68k</tt>,
which will build the library for GCC on the 68k platform ("classic" Amiga). This
builds all variants of the library, for large data, small data, resident, whatever
model. It's a lot of work and I don't recommend you do this on a plain 68k machine.
It will literally (!) take hours. The other makefile flavour is for AmigaOS4 using
the PowerPC hosted GCC system (<tt>GNUmakefile.os4</tt>). This builds only the large data
version of the library, but this is usually all you need. Small data support is
currently not implemented but might follow in the future.</p>
</body>
</html>

View File

@@ -1,67 +0,0 @@
<!DOCTYPE html public "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<title>Notes on using the library with Amiga GCC (68k)</title>
<body>
<h1>Notes on using the library with Amiga GCC (68k)</h1>
<p>You can use the 68k build of clib2 with the existing Amiga 68k ports of the
GNU 'C' compiler. In order to do so, you need to modify the <tt>specs</tt> file which
controls how the compiler(s) and the linker interact, and where the linker
will look for the program startup code and library files. Also, you will need
to copy the header files, startup code and library files to the locations
where the 'C' compiler and linker expects them.</p>
<p>Please read the following description before you follow the instructions. The
changes suggested may have unexpected side-effects!</p>
<p>I have provided a working <tt>specs</tt> file with this documentation file. To switch
over an existing Amiga 68k port of GCC to use clib2, you would proceed as
follows:</p>
<ul>
<li> Locate the directory within which GCC is installed. For example, this
could be within a directory to which the name <tt>ADE:</tt>, <tt>GG:</tt> or <tt>GCC:</tt>
is assigned. For the sake of simplicity, the following notes assume
that the assignment name is <tt>GCC:</tt>
<li> Make backup copies of the following directories and files:
<ol>
<li> <tt>GCC:lib/gcc-lib/amigaos/2.95.3/specs</tt><br>
<p>(NOTE: Check the directory called <tt>GCC:lib/gcc-lib/amigaos</tt>
first; the "2.95.3" quoted above refers to the version,
revision and patch number of the GCC installed and your
version number may differ!)</p>
<li> <tt>GCC:include</tt>
<li> <tt>GCC:lib</tt>
</ol>
<li> Now you can proceed to install clib2; just copy the <tt>include</tt> and <tt>lib</tt>
directories over, like this:
<ol>
<li><kbd>Copy include GCC:include all quiet</kbd>
<li><kbd>Copy lib GCC:lib all quiet</kbd>
</ol>
<li> Finally, replace the <tt>specs</tt> file with the one provided:
<ol>
<li> <kbd>Copy specs GCC:lib/gcc-lib/amigaos/2.95.3/specs</kbd><br>
<p>(NOTE: Check the directory called <tt>GCC:lib/gcc-lib/amigaos</tt>
first; the "2.95.3" quoted above refers to the version,
revision and patch number of the GCC installed and your
version number may differ!)</p>
</ol>
</ul>
<p>Once you have completed these steps you should be able to build programs using
the 68k build of clib2 and you currently installed GCC. Note that these
changes may have the effect of rendering your C++ compiler unusable, so make
sure that you've made backup copies of all files and directories first!</p>
</body>
</html>

View File

@@ -1,517 +0,0 @@
<!DOCTYPE html public "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<title>An ISO 'C' (1994) compliant runtime library for the Amiga</title>
<body>
<h1>An ISO 'C' (1994) compliant runtime library for the Amiga</h1>
<h2>1. What is this?</h2>
<p>This is my attempt to get Samba 2.2.x ported to the Amiga. My first Amiga
port required SAS/C and a number of strange tricks had to be pulled to get
it to support the kind of environment Samba needed. But with the
introduction of Samba 2.2.x many of those tricks did not work any more,
which is why I decided to attack the problem at the root, namely the
runtime library.</p>
<p>Because it was no longer possible to build Samba with SAS/C on the new
Amiga platform, the idea came up to move development to the GNU 'C'
compiler. This turned out to be a challenge due to its somewhat
underdeveloped runtime library and header files. Eventually, I decided to
rewrite that library from scratch.</p>
<h2>2. What does it do?</h2>
<p>Using <i>'C' - A reference manual</i> (4th edition) as a reference I wrote a set of
header files, then proceeded to implement each single function referenced in
them. With few exceptions in the area of wide character support, the result
should be a feature complete implementation of the ISO 'C' (1994) runtime
library. The library was subsequently updated to offer functionality defined in
<i>ISO/IEC 9899:1999</i>, also known as <i>C99</i>.</p>
<p>Because Samba needs a few POSIX-like routines to be supported, the library
functionality is complemented by a set of routines described in <i>Advanced
programming in the Unix environent</i>.</p>
<p>This is not a portable implementation of the library in the sense that you
could move it from one 'C' compiler on one operating system to another.
This is an Amiga specific implementation.</p>
<p>The library supports floating point math, which, for the 68k platform, is
limited to IEEE single and double precision or M68881 inline math. There is no
support for the fast floating point (FFP) format or exclusive IEEE single
precision. You either get double precision (IEEE math) or extended precision
(M68881 inline math). What it is that you get is determined at compile time.
Use the <tt>IEEE_FLOATING_POINT_SUPPORT</tt> preprocessor symbol to activate IEEE math
code and the <tt>M68881_FLOATING_POINT_SUPPORT</tt> symbol for M68881 inline math.</p>
<p>For the PowerPC platform, the library uses code borrowed from <i>fdlibm 5.3</i>,
which is a portable library of arithmetic functions developed by Sun
Microsystems which, for example, is also used within the Java platform.</p>
<h2>3. What does it not do?</h2>
<p>This library is a departure from the typical 'C' runtime environments of the
past which had to run on all AmigaOS releases, down to Kickstart 1.1. This
very library was designed to take advantage of the routines available since
Kickstart 2.04 was introduced and virtually nobody ever put to use. This helps
to cut the code size, and it also helps to keep bugs out of the library by
falling back onto well-tested implementations. However, the catch is that the
code won't run under Kickstart 1.3 and below. But then these operating system
releases have been obsolete for more than a decade, and you can always go back
to a compiler environment which supports them.</p>
<p>There is very little support for <tt>amiga.lib</tt> functionality. There is <tt>NewList()</tt>,
<tt>HookEntry()</tt>, <tt>CallHook()</tt>, <tt>CallHookA()</tt>, the <tt>DoMethod()</tt> family, the RexxVars
family, but that's all. If you need more, you would have to implement it
yourself. Put another way, if you absolutely need functionality that is only
found in <tt>amiga.lib</tt>, you really shouldn't need it in the first place.</p>
<h2>4. Where does the source code come from?</h2>
<p>I originally thought that it might be helpful to piece this library together
from various sources, such as the BSD libc. It turned out that this code was so
'portable' that it became much more complex than it ought to be. Also, some
side-effects were present which considerably changed the behaviour of the
library. For example, the BSD libc uses <tt>bcopy()</tt> as an alias for <tt>memcpy()</tt>, and
unlike <tt>memcpy()</tt> is documented to, <tt>bcopy()</tt> supports overlapping copies.</p>
<p>Eventually, I wrote virtually all the code myself, borrowing algorithmic ideas
from the BSD libc and the Manx Aztec 'C' runtime library. Because I don't know
much about the environment GCC expects, I borrowed code snippets from libnix,
which was written by Matthias Fleischer and Gunther Nikl. This in particular
concerns the integer and floating point math support, the <tt>setjmp</tt>/<tt>longjmp</tt>
routines and the startup code. The M68881 inline math code comes from the
<tt>&lt;math-68881.h&gt;</tt> file written by Matthew Self <tt>(self [at] bayes&#46;arc&#46;nasa&#46;gov)</tt>.</p>
<h2>5. Limitations and caveats</h2>
<p>There is hardly any documentation on the code I wrote. In part this is due to
the fact that the code itself is very simple in design. It should speak for
itself. However, to make a usable runtime library you have to have a user
documentation as in man pages or AutoDocs. We will eventually have to have
autodocs for this library.</p>
<p>The exception handling in the math code is not particularly effective. For one
part this is due to the fact that there is no exception handler installed by
the runtime library when it starts up which could catch and process the error
conditions the CPU or FPU generates. The idea was to provide for a portable
runtime library with little to no assembly language involved. To make the
exception handling complete, such code would be necessary.</p>
<p>The library currently builds under SAS/C, but because the 'normal' program
startup code is not utilized, the base relative (A4) addressing does not work.
If you are going to test it, use the <tt>data=faronly</tt> option to compile the
library and the programs.</p>
<p>Different build makefiles are supplied for use with GCC. There is a
<tt>GNUmakefile.68k</tt> for the 68k platform and a <tt>GNUmakefile.os4</tt> for the AmigaOS4
PowerPC version.</p>
<h3>5.1 Floating point math and functions (<tt>scanf()</tt>, <tt>printf()</tt>, etc.) </h3>
<p>The plain <tt>libc.a</tt>, which your software would be linked against by default, does not contain
any floating point support code. This means, for example, that <tt>printf("%f",...)</tt> will not produce
the desired output and that <tt>scanf("%f",...)</tt> may not read any data at all. If your
program needs functions such as these or <tt>atod()</tt> then you must link against <tt>libm.a</tt> or
the equivalent.</p>
<p>To link the floating point support code with your software, use the <tt>-lm</tt> compiler option. <em>Careful!</em>
The order in which you specify the libraries to link against is important here. Thus, <tt>gcc -o test test.c -lm -lc</tt>
would correctly link the program <tt>test</tt> against the proper floating point math library, but
<tt>gcc -o test test.c -lc -lm</tt> would not.</p>
<h3>5.2 The thread-safe library</h3>
<p>Thread-safety does not imply that you can have multiple callers
access and close the same file. There is no resource tracking to that degree
yet. All that the thread-safety tries to afford you is not to get into big trouble
if simultaneous and overlapping accesses to files, memory allocation and other
resources are taking place.</p>
<p>The library code is supposed to be thread-safe if built with the <tt>__THREAD_SAFE</tt>
preprocesssor symbol defined. Note that 'thread-safe' does <em>not</em> mean
'reentrant'. Multiple callers for certain library functions are permitted, but
not for all of them. For example, <tt>mkdtemp()</tt> is not thread-safe, and neither is
<tt>rand()</tt> or <tt>localtime()</tt>. But as per <i>POSIX 1003.1c-1995</i> there are thread-safe
variants of <tt>rand()</tt> and <tt>localtime()</tt> called <tt>rand_r()</tt>, <tt>localtime_r()</tt>, and others.</p>
<p>The use of the socket I/O functions is problematic because the
underlying <tt>bsdsocket.library</tt> API is not supposed to be used by any process
other than the one which opened it. While one TCP/IP stack (my own "Roadshow") allows you
to share the library base among different processes, if so configured, it is the
exception. No other TCP/IP stack available for the Amiga robustly supports a similar
feature. If the TCP/IP stack supports this feature, then the global variable
<tt>__can_share_socket_library_base</tt> will be set to a non-zero value.</p>
<p>Errors reported by the socket I/O functions which modify the global variables
<tt>errno</tt> and <tt>h_errno</tt> may be directed to call the <tt>__set_errno()</tt>
and <tt>__set_h_errno()</tt> functions instead, if the TCP/IP stack supports this feature. The global
variable <tt>__thread_safe_errno_h_errno</tt> will be set to a non-zero value if it does.</p>
<p>A much more serious problem resides with the <tt>exit()</tt>, <tt>abort()</tt>,
<tt>assert()</tt> and <tt>raise()</tt> functions, and how the <tt>SIGINT</tt> signal is
processed. In the thread-safe library only the <tt>main()</tt> function may directly
or indirectly call the <tt>exit()</tt> function. No child process may do so, since this
would wreck its stack context, crashing it instantly; the main program would be very
likely to crash, too, because <tt>exit()</tt> will clean up after all memory allocations
and files currently in use. Functions such as <tt>abort()</tt> and <tt>raise()</tt> may
call the <tt>exit()</tt> function indirectly. And the <tt>raise()</tt> function may
be invoked as part of the <tt>Control+C</tt> checking. You should make sure that the
signal handling does not affect any child processes. This can be done by replacing the
<tt>__check_abort()</tt> function or by disabling <tt>SIGINT</tt> processing altogether,
such as through a <tt>signal(SIGINT,SIG_IGN)</tt> call.</p>
<p> Also take care with file I/O involving the <tt>stdin</tt>/<tt>stdout</tt>/<tt>stderr</tt>
streams; read/write operations on these streams will be mapped to the <tt>Input()</tt>/<tt>Output()</tt>/<tt>ErrorOutput()</tt>
file handles of the process performing these operations. Since only this small set of
operations is mapped, functions such as <tt>fcntl()</tt> or <tt>select()</tt> will not
work on the <tt>stdin</tt>/<tt>stdout</tt>/<tt>stderr</tt> streams and the corresponding
file descriptors <tt>STDIN_FILENO</tt>/<tt>STDOUT_FILENO</tt>/<tt>STDERR_FILENO</tt>.
It is therefore strongly recommended to use the thread-safe library only for applications
which can cope with the limitations described above.</p>
<h3>5.3 Using gmon (PowerPC only)</h3>
<p>To use profiling, two steps are required. First of all, your program must be compiled with
the gcc command line option <tt>-pg</tt>. This instructs the compiler to generate special
profiling code in the prologue and epilogue of each function. Additionally, the program
must be linked with <tt>libprofile.a</tt>. To do this, either manually add
<tt>-lprofile</tt> to the linker command line, or modify the specs file as follows.
Find the lines that look like this (it may actually differ silghtily from your specs file,
but the important thing is that the line before the line to be modified reads <tt>lib:</tt>):
<pre>
lib:
--start-group -lc --end-group
</pre>
You will have to modify this to look like this:
<pre>
lib:
%{pg: -lprofile} --start-group -lc --end-group
</pre>
<p>Normally, the specs file is located at the compilers installation directory. For cross-compilers,
this is <tt>/usr/local/amiga/lib/gcc/ppc-amigaos/<i>compiler-version</i>/specs</tt>. For a native compiler,
it's in <tt>gcc:lib/gcc/ppc-amigaos/<i>compiler-version</i>/specs</tt>. Most likely, your compiler will already have this added to it's specs file.</p>
<p>Profiling makes use of a special PowerPC facility called the Performance Monitor. It
allows to "mark" tasks and count only during while a marked task is running. This allows
performance analysis to be made independant of the actual system load. The Performace Monitor
is available on all PowerPC models supported by AmigaOS 4 except for the <tt>603e</tt>, and
embedded versions of the PowerPC like the <tt>405</tt> and <tt>440</tt> series. Consult the manual
of the appropriate chip for more information.</p>
<h3>5.4 Implementation defined behaviour</h3>
<h4>5.4.1. 'C' language</h4>
<h5>5.4.1.1. Environment</h5>
<p>The <tt>main(int argc,char **argv);</tt> function may be called with an <tt>argc</tt> value of 0,
in which case the <tt>argv</tt> variable will contain a pointer to the Amiga Workbench startup
message, which is of type <tt>struct WBStartup *</tt>, and is defined in the Amiga system header
file <tt>&lt;workbench/startup.h&gt;</tt>.</p>
<h5>5.4.1.2. Characters</h5>
<p>The current locale is derived from the current Amiga operating system locale settings. The
<tt>setlocale("")</tt> function call will choose the current Amiga operating system locale settings.
Any other name passed to the <tt>setlocale()</tt> function, with the exception of <tt>"C"</tt>,
which selects the 'C' locale, must be a locale name, as used by the Amiga operating system
function <tt>OpenLocale()</tt> in <tt>locale.library</tt>.</p>
<h5>5.4.1.3. Floating-point</h5>
<p>The 68k version of clib2 supports single and double precision floating point numbers,
according to the <i>IEEE 754</i> standard. The software floating point number support is built upon the Amiga
operating system libraries <tt>mathieeesingbas.library</tt>, <tt>mathieeedoubbas.library</tt>
and <tt>mathieeedoubtrans.library</tt>. The hardware floating point number support uses
the M68881/M68882/M68040/M68060 floating point unit intead.</p>
<p>The PowerPC version of clib2 supports only double precision floating point numbers, according to
the <i>IEEE 754</i> standard, because that is exactly what the PowerPC CPU supports. Single precision
numbers may be implicitly converted to double precision numbers. This also means that the <i>C99</i>
data type <tt>long double</tt> is identical to the <tt>double</tt> data type. Because there is no
difference between these two, the library omits support for <i>C99</i> functions specifically designed
to operate on <tt>long double</tt> data types, such as <tt>rintl()</tt>.</p>
<p>Both the 68k and the PowerPC versions of clib2 may call software floating point support
routines in order to perform double and single precision operations that go beyond
simple addition and multiplication, such as <tt>sqrt()</tt>. These functions come from
Sun Microsystems <i>fdlibm 5.3</i> library.</p>
<p>Unless your software is linked against <tt>libm.a</tt> no floating point functions will
be available to it, possibly causing a linker error. When using the GNU 'C' compiler, you will
want to add the option <tt>-lm -lc</tt> to the linker command line.</p>
<p>The exception handling is currently entirely out of control of the developer
and solely subject to the rules imposed by the operating system itself.</p>
<p>The <tt>fmod()</tt> function returns the value of the <tt>x</tt> parameter and
sets <tt>errno</tt> to <tt>EDOM</tt> if the <tt>y</tt> parameter value is 0.</p>
<h4>5.4.2. Library functions</h4>
<h5>5.4.2.1. <tt>NULL</tt></h5>
<p>The <tt>NULL</tt> pointer constant is defined in the <tt>&lt;stddef.h&gt;</tt> header and
will expand to <tt>((void *)0L)</tt> if the 'C' compiler is used. For a C++ compiler the constant
will expand to <tt>0L</tt> instead.</p>
<h5>5.4.2.2. <tt>assert()</tt> diagnostic messages</h5>
<p>The diagnostic messages printed by the <tt>assert()</tt> function take the following form:</p>
<blockquote><tt>[<i>program name</i>] <i>file</i>:<i>line</i>: failed assertion "<i>condition</i>".</tt></blockquote>
<p>where:</p>
<table border=0>
<tr><th align=right>program name</th><td>Optional program name; if the program name is not yet known, then the
entire text enclosed in square brackets will be omitted.</td></tr>
<tr><th align=right>file</th><td>The value of the <tt>__FILE__</tt> symbol at the location of the <tt>assert()</tt> call.</td></tr>
<tr><th align=right>line</th><td>The value of the <tt>__LINE__</tt> symbol at the location of the <tt>assert()</tt> call.</td></tr>
<tr><th align=right>condition</th><td>The condition passed to the <tt>assert()</tt> function.</td></tr>
</table>
<p>If available, the diagnostic messages will be sent to <tt>stderr</tt>.</p>
<p>If the program was launched from Workbench or if the global variable <tt>__no_standard_io</tt> is set
to a non-zero value, then the assertion failure message will not be displayed in the shell window, but
in a requester window. The diagnostic message shown in this window will take the following form:</p>
<blockquote><tt>Assertion of condition "<i>condition</i>" failed in file "<i>file</i>", line <i>line</i>.</tt></blockquote>
<p>The name of the program, if it is know at that time, will be displayed in the requester window title.</p>
<h5>5.4.2.3. Signal handling</h5>
<p>Only the minimum of required signals are supported by this library. These are <tt>SIGABRT</tt>, <tt>SIGFPE</tt>,
<tt>SIGILL</tt>, <tt>SIGINT</tt>, <tt>SIGSEGV</tt> and <tt>SIGTERM</tt>.</p>
<p>As of this writing <tt>SIGFPE</tt> is never called by the floating point library functions.</p>
<p>The <tt>Ctrl+C</tt> event is translated into <tt>SIGINT</tt>. Signal delivery may be delayed
until a library function which polls for the signal examines it. This means, for example, that
a runaway program caught in an infinite loop cannot be aborted by sending it a <tt>Ctrl+C</tt> event unless special code
is added which tests for the presence of the signal and calls the <tt>__check_abort()</tt> all on its own.</p>
<p>Processing of the <tt>Ctrl+C</tt> event involves the internal <tt>__check_abort()</tt> function which
polls for the presence of the event and which will call <tt>raise(SIGINT);</tt>. The <tt>__check_abort()</tt>
function may be replaced by user code.</p>
<h5>5.4.2.4. Files</h5>
<p>No new line characters are written unless specifically requested.</p>
<p>Space characters in a text stream before a new line character are read in and not discarded.</p>
<p>When data is read from a file, the last character does not have to be a new line character.</p>
<p>No NUL byte will be appended to data written to a binary stream.</p>
<p>There is no difference between text and binary streams.</p>
<p>Writing to a text or binary stream does not truncate the associated file. A stream may be
truncated by the initial <tt>fopen()</tt> call if the <tt>mode</tt> parameter starts with
the letter <tt>w</tt>.</p>
<p>The file position indicator is initially set to the end of an append mode stream.</p>
<h5>5.4.2.5. <tt>printf()</tt> family</h5>
<p>The <tt>%p</tt> conversion is the hexadecimal representation of the pointer, and
it is preceded by the string <tt>0x</tt>.</p>
<p>The <tt>%a</tt>, <tt>%e</tt>, <tt>%f</tt>, <tt>%g</tt>, <tt>%A</tt>,
<tt>%E</tt>, <tt>%F</tt> and <tt>%G</tt> specifiers will produce the string <tt>inf</tt>
for infinity.</p>
<h5>5.4.2.6. <tt>scanf()</tt> family</h5>
<p>The input for the <tt>%p</tt> conversion must be a hexadecimal number,
preceded by either the string <tt>0x</tt> or <tt>0X</tt>.</p>
<p>In the <tt>%[</tt> conversion a <tt>-</tt> (dash) character that is neither the
first nor the last character in the scanset indicates that a subrange of
characters should be used. Thus <tt>%[a-d]</tt> is equivalent to <tt>%[abcd]</tt>.</p>
<p>The period (.) is the decimal-point character. The locale specific decimal-point
character is accepted as an alternative to the period (.).</p>
<h5>5.4.2.7. <tt>malloc()</tt>, <tt>realloc()</tt> and <tt>calloc()</tt></h5>
<p>In the standard <tt>libc.a</tt> implementation any request to allocate
0 (zero) bytes will fail. A result value of <tt>NULL</tt> will be returned and
the global <tt>errno</tt> variable will be set to <tt>EINVAL</tt>.</p>
<p>In the <tt>libunix.a</tt> implementation a request to allocate
0 (zero) bytes will result in an allocation of at least 4 bytes, which will
be set to zero. Each zero length allocation will return a different
memory address.</p>
<h5>5.4.2.8. <tt>rename()</tt></h5>
<p>In the standard <tt>libc.a</tt> implementation the <tt>rename()</tt> function
will fail if there already is a file or directory by the new name to be used.</p>
<p>In the <tt>libunix.a</tt> implementation the <tt>rename()</tt> function will
delete any existing file or directory by the new name.</p>
<h5>5.4.2.9. <tt>remove()</tt></h5>
<p>In the standard <tt>libc.a</tt> implementation the <tt>remove()</tt> function
will fail if the file is protected by deletion or currently in use.</p>
<p>In the <tt>libunix.a</tt> implementation the <tt>remove()</tt> function
will remove the file when the program exits or the file is closed.</p>
<h5>5.4.2.10. <tt>abort()</tt></h5>
<p>The <tt>abort()</tt> function will flush all buffered files,
close all the files currently open and delete temporary files.</p>
<h5>5.4.2.11. <tt>exit()</tt> and <tt>_Exit()</tt></h5>
<p>The value passed to the <tt>exit()</tt> function will be passed to the
Amiga operating system. The value of <tt>EXIT_FAILURE</tt> is equivalent
to <tt>RETURN_FAIL</tt> as defined in the Amiga system header file
<tt>&lt;dos/dos.h&gt;</tt>; this value maps to the number 20. The value
of <tt>EXIT_SUCCESS</tt> is equivalent to <tt>RETURN_OK</tt> as defined in
the Amiga system header file <tt>&lt;dos/dos.h&gt;</tt>; this value maps to
the number 0.</p>
<p>The <tt>_Exit()</tt> function will flush all buffered files,
close all the files currently open and delete temporary files.</p>
<h5>5.4.2.12. <tt>getenv()</tt></h5>
<p>Environment data is retrieved from the global Amiga operating system environment
storage area through the <tt>dos.library/GetEnv()</tt> function. Global variables are
stored in files in the <tt>ENV:</tt> directory.</p>
<h5>5.4.2.13. <tt>system()</tt></h5>
<p>If the <tt>command</tt> parameter is not NULL and the <tt>system()</tt> function returns, then the result will
be equivalent to the exit code of the program invoked, or -1 if the program could not be started.
This follows the behaviour of the Amiga operating system function <tt>dos.library/System()</tt>.
A return value of 0 typically indicates successful execution and a value &gt; 0
typically indicates failure.</p>
<h5>5.4.2.14. Time</h5>
<p>The default time zone is derived from the Amiga operating system locale
settings and takes the form <tt>GMT+<i>hh</i></tt> or <tt>GMT-<i>hh</i></tt>,
respectively, in which <i>hh</i> stands for the difference between the local
time zone and Greenwich Mean Time.</p>
<p>The <tt>clock_t</tt> and <tt>time_t</tt> types are unsigned 32 bit integers.
The <tt>time_t</tt> epoch starts with midnight January 1st, 1970.</p>
<p>Daylight savings time is not supported.</p>
<p>The reference point used by the <tt>clock()</tt> function is the time
when the program was started.</p>
<h4>5.4.3. Locale specific behaviour</h4>
<p>The direction of printing is from left to right.</p>
<p>The period (.) is the decimal-point character.</p>
<p>The <tt>strftime()</tt> behaviour follows the Amiga operating system locale
settings. If the 'C' locale is in effect, then the output generated by the
<tt>%Z</tt> takes the form <tt>GMT+<i>hh</i></tt> or <tt>GMT-<i>hh</i></tt>,
respectively, in which <i>hh</i> stands for the difference between the local
time zone and Greenwich Mean Time.</p>
<h2>6. Conventions and design issues</h2>
<p>You will have noticed the 330+ files in this directory. This is not the best
way to organize a runtime library, but at least all the bits and pieces are in
plain sight. Each file stands for the one or two routines it contains. The
name indicates what routine(s) that might be. Each file name is prefixed by
the name of the header file in which the corresponding routine is defined. So,
for example, you will find that <tt>unistd_lchown.c</tt> contains the definition of
the <tt>lchown()</tt> routine, which has its prototype defined in the <tt>&lt;unistd.h&gt;</tt> header
file.</p>
<p>Internal function and variables which need to be visible across several
modules have names prefixed with two underscores, as in <tt>__stdio_init()</tt>.</p>
<p>By default all library routines follow the ISO 'C' conventions in that where
implementation defined behaviour is permitted, the AmigaOS rules are followed.
For example, <tt>unlink()</tt> will by default operate like <tt>DeleteFile()</tt> and <tt>rename()</tt>
will return with an error code set if the name of the file/directory to be
renamed would collide with an existing directory entry.</p>
<h2>7. The startup code</h2>
<p>There are three program startup files provided. The most simplistic is in
<tt>startup.c</tt> which I use for SAS/C. It just invokes the setup routine which
eventually calls <tt>main()</tt> and drops straight into <tt>exit()</tt>.</p>
<p>The <tt>ncrt0.S</tt> file was adapted from the libnix startup code which sets up the
base relative data area, if necessary (the <tt>SMALL_DATA</tt> preprocessor symbol must
be defined).</p>
<p>The <tt>nrcrt0.S</tt> file was adapted from libnix startup code, too, and sets up the
base relative data area for programs to be made resident. Note that the
<tt>geta4()</tt> stub is missing here; it wouldn't work in a resident program anyway.</p>
<p>The <tt>ncrt0.S</tt> and <tt>nrcrt0.S</tt> files are considerably smaller and less complex than
the libnix code they are based on. This is because in this library design all
the more complex tasks are performed in the <tt>stdlib_main.c</tt> file rather than in
assembly language.</p>
<h2>8. Documentation</h2>
<p>Well, you're reading it. There isn't anything much yet. You can consult the book
<i>'C' - A reference manual</i> and you could look at the
<a href="http://www.opengroup.org/onlinepubs/007904975">Open Group's Single Unix
Specification</a>.</p>
<p>It is recommended to browse the contents of the <tt>include</tt> directory. The
header files contain information on library behaviour and not just data type and
function prototype definitions. Specifically, the <tt>&lt;dos.h&gt;</tt> header file
contains documentation about special libraries and global variables which may be
used or replaced by user code.</p>
<h2>9. Legal status</h2>
<p>Because this library is in part based upon free software it would be
uncourteous not to make it free software itself. The BSD license would
probably be appropriate here.</p>
<p>The PowerPC math library is based in part on work by Sun Microsystems:</p>
<pre>
====================================================
Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
Developed at SunPro, a Sun Microsystems, Inc. business.
Permission to use, copy, modify, and distribute this
software is freely granted, provided that this notice
is preserved.
====================================================
</pre>
<h2>10. Contacting the author</h2>
<p>The basic work was done by Olaf Barthel during two weeks in July 2002. You
can reach me at:</p>
<p>Olaf Barthel<br>
Gneisenaustr. 43<br>
D-31275 Lehrte<br></p>
<p>Or via e-mail:</p>
<p>olsen [at] sourcery&#46;han&#46;de</p>
</body>
</html>

View File

@@ -1,64 +0,0 @@
*asm:
%{m68000:-mc68010} %{mc68000:-mc68010} %{m68020:-mc68020} %{mc68020:-mc68020} %{m68030:-mc68030} %{m68040:-mc68040} %{m68060:-mc68060} %{m68020-40:-mc68020} %{m68020-60:-mc68020} %{!mc68000:%{!m68000:%{!mc68020:%{!m68020:%{!m68030:%{!m68040:%{!m68060:%{!m68020-40:%{!m68020-60:-mc68010}}}}}}}}} %{msmall-code:-sc}
*asm_final:
*cpp:
%{m68881:-D__HAVE_68881__} %{!ansi:%{m68020:-Dmc68020} %{mc68020:-Dmc68020} %{m68020-40:-Dmc68020} %{m68020-60:-Dmc68020} %{m68030:-Dmc68030} %{m68040:-Dmc68040} %{m68060:-Dmc68060}} %{m68020:-D__mc68020__ -D__mc68020} %{mc68020:-D__mc68020__ -D__mc68020} %{m68020-40:-D__mc68020__ -D__mc68020} %{m68020-60:-D__mc68020__ -D__mc68020} %{m68030:-D__mc68030__ -D__mc68030} %{m68040:-D__mc68040__ -D__mc68040} %{m68060:-D__mc68060__ -D__mc68060}
*cc1:
%{resident:-fbaserel} %{resident32:-fbaserel32} %{msmall-code:-fno-function-cse}
*cc1plus:
*endfile:
*link:
%{fbaserel:%{!resident:-m amiga_bss -fl libb}} %{resident:-m amiga_bss -amiga-datadata-reloc -fl libb} %{fbaserel32:%{!resident32:-m amiga_bss -fl libb32}} %{resident32:-m amiga_bss -amiga-datadata-reloc -fl libb32} %{g:-amiga-debug-hunk} %{m68020:-fl libm020} %{mc68020:-fl libm020} %{m68030:-fl libm020} %{m68040:-fl libm020} %{m68060:-fl libm020} %{m68020-40:-fl libm020} %{m68020-60:-fl libm020} %{noixemul:}
*lib:
%{mstackextend:-lstack} -lc -lamiga -ldebug -lgcc -lc
*libgcc:
%{mstackextend:-lstack} -lc -lgcc
*startfile:
%{resident32:nr32crt0.o%s}%{!resident32:%{fbaserel32:nb32crt0.o%s}%{!fbaserel32:%{resident:nrcrt0.o%s}%{!resident:%{fbaserel:nbcrt0.o%s}%{!fbaserel:ncrt0.o%s}}}}
*switches_need_spaces:
*signed_char:
%{funsigned-char:-D__CHAR_UNSIGNED__}
*predefines:
-Dmc68000 -Damiga -Damigaos -DMCH_AMIGA -DAMIGA -D__CLIB2__ -D__chip=__attribute__((__chip__)) -D__saveds=__attribute__((__saveds__)) -D__interrupt=__attribute__((__interrupt__)) -D__stackext=__attribute__((__stackext__)) -D__regargs=__attribute__((__regparm__)) -D__stdargs=__attribute__((__stkparm__)) -D__aligned=__attribute__((__aligned__(4))) -Asystem(amigaos) -Acpu(m68k) -Amachine(m68k)
*cross_compile:
0
*version:
2.95.3
*multilib:
. ;
*multilib_defaults:
*multilib_extra:
*multilib_matches:
*linker:
collect2
*link_command:
%{!fsyntax-only: %{!c:%{!M:%{!MM:%{!E:%{!S:%(linker) %l %X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r} %{s} %{t} %{u*} %{x} %{z} %{Z} %{!A:%{!nostdlib:%{!nostartfiles:%S}}} %{static:} %{L*} %D %o %{!nostdlib:%{!nodefaultlibs:%G %L %G}} %{!A:%{!nostdlib:%{!nostartfiles:%E}}} %{T*}
}}}}}}

View File

@@ -1,5 +1,5 @@
#
# $Id: GNUmakefile.68k,v 1.106 2008-04-16 07:38:10 obarthel Exp $
# $Id: GNUmakefile.68k,v 1.107 2010-10-20 13:50:16 obarthel Exp $
#
# :ts=8
#
@@ -369,10 +369,6 @@ C_LIB = \
stdlib_shell_escape.o \
stdlib_showerror.o \
stdlib_srand.o \
stdlib_stackargbytes.o \
stdlib_stackcheck.o \
stdlib_stackoverflow.o \
stdlib_stacksafezone.o \
stdlib_stacksize.o \
stdlib_stack_usage.o \
stdlib_arg.o \
@@ -1314,8 +1310,6 @@ CONSTRUCTOR_FILES = \
stdlib_malloc.c \
stdlib_program_name.c \
stdlib_setenv.c \
stdlib_stackcheck.c \
stdlib_stackextension.c \
time_clock.c \
unistd_chdir_exit.c \
unistd_init_exit.c \

View File

@@ -1,6 +1,6 @@
#define VERSION 1
#define REVISION 205
#define DATE "21.8.2010"
#define VERS "c.lib 1.205"
#define VSTRING "c.lib 1.205 (21.8.2010)\r\n"
#define VERSTAG "\0$VER: c.lib 1.205 (21.8.2010)"
#define REVISION 206
#define DATE "24.4.2015"
#define VERS "c.lib 1.206"
#define VSTRING "c.lib 1.206 (24.4.2015)\r\n"
#define VERSTAG "\0$VER: c.lib 1.206 (24.4.2015)"

View File

@@ -1 +1 @@
205
206

View File

@@ -1,3 +1,28 @@
m.lib 1.206 (24.4.2015)
- The fscanf() family failed to parse and convert %f parameters correctly
if the respective number did not begin with a digit, but a decimal
point. Hence ".7" would not be processed, but "0.7" would.
c.lib 1.206 (24.4.2015)
- Reworked the __putc() and putc() macros to reference the 'c' input
parameter only once, and to be free of side-effects when tinkering
with the buffer position.
- isatty() had the __fd_lock() call in the wrong place, which could have
led to cleanup problems later.
- The close action in the stdio, socket and termios hook code now
also zaps the fd pointer itself after cleaning up the file descriptor
table entry.
- Removed the remains of all the stack extension and stack overflow/underflow
checking code. It never actually worked. The bit that does work is the stack
usage measurement code, plus the bit that sets up the the custom stack
according to local setting or by calling a query function.
c.lib 1.205 (21.8.2010)
- Added dlclose(), dlerror(), dlopen() and dlsym() functions, which are

View File

@@ -1,5 +1,5 @@
/*
* $Id: stdio.h,v 1.22 2006-03-06 08:43:48 obarthel Exp $
* $Id: stdio.h,v 1.24 2010-10-20 13:12:59 obarthel Exp $
*
* :ts=4
*
@@ -285,11 +285,11 @@ extern char *tmpnam(char *buf);
(((((FILE *)(f))->flags & (__FILE_IN_USE|__FILE_WRITABLE)) == (__FILE_IN_USE|__FILE_WRITABLE) && \
(((FILE *)(f))->flags & __FILE_BUFFER_MASK) != _IONBF && \
(((FILE *)(f))->num_write_bytes < ((FILE *)(f))->size)) ? \
(((FILE *)(f))->buffer[((FILE *)(f))->num_write_bytes++] = (c), \
(((FILE *)(f))->buffer[((FILE *)(f))->num_write_bytes] = (c), \
(((((FILE *)(f))->flags & __FILE_BUFFER_MASK) == _IOLBF && \
((FILE *)(f))->buffer[((FILE *)(f))->num_write_bytes-1] == '\n') ? \
__flush(f) : \
(((FILE *)(f))->buffer[((FILE *)(f))->num_write_bytes-1]))) : \
((FILE *)(f))->buffer[((FILE *)(f))->num_write_bytes] == '\n') ? \
((FILE *)(f))->num_write_bytes++, __flush(f) : \
((FILE *)(f))->buffer[((FILE *)(f))->num_write_bytes++])) : \
fputc((c),(f)))
/****************************************************************************/

View File

@@ -1,5 +1,5 @@
#
# $Id: libc.gmk,v 1.8 2010-08-21 11:37:03 obarthel Exp $
# $Id: libc.gmk,v 1.9 2010-10-20 13:50:17 obarthel Exp $
#
# :ts=8
#
@@ -256,10 +256,6 @@ C_LIB := \
stdlib_shell_escape.o \
stdlib_showerror.o \
stdlib_srand.o \
stdlib_stackargbytes.o \
stdlib_stackcheck.o \
stdlib_stackoverflow.o \
stdlib_stacksafezone.o \
stdlib_stacksize.o \
stdlib_stack_usage.o \
stdlib_arg.o \

View File

@@ -1,6 +1,6 @@
#define VERSION 1
#define REVISION 205
#define DATE "21.8.2010"
#define VERS "m.lib 1.205"
#define VSTRING "m.lib 1.205 (21.8.2010)\r\n"
#define VERSTAG "\0$VER: m.lib 1.205 (21.8.2010)"
#define REVISION 206
#define DATE "24.4.2015"
#define VERS "m.lib 1.206"
#define VSTRING "m.lib 1.206 (24.4.2015)\r\n"
#define VERSTAG "\0$VER: m.lib 1.206 (24.4.2015)"

View File

@@ -1 +1 @@
205
206

View File

@@ -1,6 +1,6 @@
#define VERSION 1
#define REVISION 205
#define DATE "21.8.2010"
#define VERS "m881.lib 1.205"
#define VSTRING "m881.lib 1.205 (21.8.2010)\r\n"
#define VERSTAG "\0$VER: m881.lib 1.205 (21.8.2010)"
#define REVISION 206
#define DATE "24.4.2015"
#define VERS "m881.lib 1.206"
#define VSTRING "m881.lib 1.206 (24.4.2015)\r\n"
#define VERSTAG "\0$VER: m881.lib 1.206 (24.4.2015)"

View File

@@ -1 +1 @@
205
206

View File

@@ -1,5 +1,5 @@
/*
* $Id: socket_hook_entry.c,v 1.17 2006-11-16 10:41:15 obarthel Exp $
* $Id: socket_hook_entry.c,v 1.18 2010-10-20 13:12:58 obarthel Exp $
*
* :ts=4
*
@@ -145,6 +145,8 @@ __socket_hook_entry(
/* And that's the last for this file descriptor. */
memset(fd,0,sizeof(*fd));
fd = NULL;
break;
case file_action_seek:

View File

@@ -1,38 +0,0 @@
/*
* $Id: stack.lib_rev.c,v 1.3 2006-01-08 12:04:24 obarthel Exp $
*
* :ts=4
*
* Portable ISO 'C' (1994) runtime library for the Amiga computer
* Copyright (c) 2002-2006 by Olaf Barthel <olsen (at) sourcery.han.de>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Neither the name of Olaf Barthel nor the names of contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "stack.lib_rev.h"
/****************************************************************************/
char __stack_lib_version[] = VERSTAG;

View File

@@ -1,6 +0,0 @@
#define VERSION 1
#define REVISION 202
#define DATE "16.1.2007"
#define VERS "stack.lib 1.202"
#define VSTRING "stack.lib 1.202 (16.1.2007)\r\n"
#define VERSTAG "\0$VER: stack.lib 1.202 (16.1.2007)"

View File

@@ -1 +0,0 @@
202

View File

@@ -1,5 +1,5 @@
/*
* $Id: stdio_fdhookentry.c,v 1.34 2006-11-16 14:39:23 obarthel Exp $
* $Id: stdio_fdhookentry.c,v 1.35 2010-10-20 13:12:58 obarthel Exp $
*
* :ts=4
*
@@ -367,6 +367,7 @@ __fd_hook_entry(
/* And that's the last for this file descriptor. */
memset(fd,0,sizeof(*fd));
fd = NULL;
break;

View File

@@ -1,5 +1,5 @@
/*
* $Id: stdio_fwrite.c,v 1.11 2006-09-25 15:38:21 obarthel Exp $
* $Id: stdio_fwrite.c,v 1.12 2010-10-20 13:12:58 obarthel Exp $
*
* :ts=4
*
@@ -134,7 +134,7 @@ fwrite(const void *ptr,size_t element_size,size_t count,FILE *stream)
{
c = (*data++);
if(__putc_line_buffered(c,(FILE *)file) < 0)
if(__putc_line_buffered(c,(FILE *)file) == EOF)
goto out;
total_bytes_written++;
@@ -146,7 +146,7 @@ fwrite(const void *ptr,size_t element_size,size_t count,FILE *stream)
{
c = (*data++);
if(__putc_fully_buffered(c,(FILE *)file) < 0)
if(__putc_fully_buffered(c,(FILE *)file) == EOF)
goto out;
total_bytes_written++;

View File

@@ -1,5 +1,5 @@
/*
* $Id: stdio_headers.h,v 1.31 2008-09-04 12:07:58 obarthel Exp $
* $Id: stdio_headers.h,v 1.33 2010-10-20 13:12:59 obarthel Exp $
*
* :ts=4
*
@@ -276,13 +276,13 @@ struct iob
((struct iob *)(f))->iob_Buffer[((struct iob *)(f))->iob_BufferPosition++] : \
__fgetc((FILE *)(f)))
/* Caution: this putc() variant will evaluate the 'c' parameter more than once. */
#define __putc(c,f,m) \
(((((struct iob *)(f))->iob_BufferWriteBytes < ((struct iob *)(f))->iob_BufferSize)) ? \
(((struct iob *)(f))->iob_Buffer[((struct iob *)(f))->iob_BufferWriteBytes++] = (c), \
(((m) == IOBF_BUFFER_MODE_LINE && \
((struct iob *)(f))->iob_Buffer[((struct iob *)(f))->iob_BufferWriteBytes-1] == '\n') ? \
(((m) == IOBF_BUFFER_MODE_LINE && (c) == '\n') ? \
__flush(f) : \
(((struct iob *)(f))->iob_Buffer[((struct iob *)(f))->iob_BufferWriteBytes-1]))) : \
((c) & 255))) : \
__fputc((c),(f),(m)))
#define __putc_fully_buffered(c,f) \
@@ -290,12 +290,13 @@ struct iob
(((struct iob *)(f))->iob_Buffer[((struct iob *)(f))->iob_BufferWriteBytes++] = (c)) : \
__fputc((c),(f),IOBF_BUFFER_MODE_FULL))
/* Caution: this putc() variant will evaluate the 'c' parameter more than once. */
#define __putc_line_buffered(c,f) \
(((((struct iob *)(f))->iob_BufferWriteBytes < ((struct iob *)(f))->iob_BufferSize)) ? \
(((struct iob *)(f))->iob_Buffer[((struct iob *)(f))->iob_BufferWriteBytes++] = (c), \
(((c) == '\n') ? \
__flush(f) : \
((c)))) : \
((c) & 255))) : \
__fputc((c),(f),IOBF_BUFFER_MODE_LINE))
/****************************************************************************/

View File

@@ -1,5 +1,5 @@
/*
* $Id: stdio_vfscanf.c,v 1.21 2006-09-25 14:51:15 obarthel Exp $
* $Id: stdio_vfscanf.c,v 1.22 2015-04-24 13:00:12 obarthel Exp $
*
* :ts=4
*
@@ -775,6 +775,8 @@ vfscanf(FILE *stream, const char *format, va_list arg)
/* Check if there's a hex prefix introducing this number. */
if(maximum_field_width != 0 && (c = __getc(stream)) != EOF)
{
D(("c = '%lc'",c));
if(c == '0')
{
/* Use the leading zero as is. */
@@ -889,6 +891,8 @@ vfscanf(FILE *stream, const char *format, va_list arg)
c = __getc(stream);
if(c != EOF)
{
D(("c = '%lc'",c));
__locale_lock();
/* Did we find the decimal point? We accept both the
@@ -963,6 +967,7 @@ vfscanf(FILE *stream, const char *format, va_list arg)
int digit;
SHOWMSG("found a decimal point");
num_chars_processed++;
/* Process all digits following the decimal point. */
while(maximum_field_width != 0 && (c = __getc(stream)) != EOF)
@@ -1004,6 +1009,7 @@ vfscanf(FILE *stream, const char *format, va_list arg)
}
total_num_chars_read++;
num_chars_processed++;
if(maximum_field_width > 0)
maximum_field_width--;
@@ -1014,6 +1020,7 @@ vfscanf(FILE *stream, const char *format, va_list arg)
SHOWMSG("found an exponent specifier");
total_num_chars_read++;
num_chars_processed++;
if(maximum_field_width > 0)
maximum_field_width--;
@@ -1056,12 +1063,15 @@ vfscanf(FILE *stream, const char *format, va_list arg)
{
int digit;
D(("c = '%lc'",c));
/* Skip the sign. */
if(c == '-')
{
exponent_is_negative = TRUE;
total_num_chars_read++;
num_chars_processed++;
if(maximum_field_width > 0)
maximum_field_width--;
@@ -1069,6 +1079,7 @@ vfscanf(FILE *stream, const char *format, va_list arg)
else if (c == '+')
{
total_num_chars_read++;
num_chars_processed++;
if(maximum_field_width > 0)
maximum_field_width--;
@@ -1097,6 +1108,8 @@ vfscanf(FILE *stream, const char *format, va_list arg)
new_exponent = (exponent_radix * exponent) + digit;
if(new_exponent < exponent) /* overflow? */
{
SHOWMSG("overflow!");
if(ungetc(c,stream) == EOF)
{
SHOWMSG("couldn't push this character back");
@@ -1109,12 +1122,15 @@ vfscanf(FILE *stream, const char *format, va_list arg)
exponent = new_exponent;
total_num_chars_read++;
num_chars_processed++;
if(maximum_field_width > 0)
maximum_field_width--;
}
else
{
SHOWMSG("invalid digit");
if(ungetc(c,stream) == EOF)
{
SHOWMSG("couldn't push this character back");
@@ -1178,9 +1194,17 @@ vfscanf(FILE *stream, const char *format, va_list arg)
}
num_assignments++;
D(("number of assignments = %ld\n", num_assignments));
}
num_conversions++;
D(("number of conversions = %ld\n", num_conversions));
}
else
{
SHOWMSG("no characters were actually processed");
}
}
#else

View File

@@ -1,5 +1,5 @@
/*
* $Id: stdlib_headers.h,v 1.21 2006-01-08 12:04:25 obarthel Exp $
* $Id: stdlib_headers.h,v 1.22 2010-10-20 13:50:17 obarthel Exp $
*
* :ts=4
*
@@ -162,21 +162,7 @@ extern unsigned int NOCOMMON (* __get_default_stack_size)(void);
/****************************************************************************/
extern unsigned int NOCOMMON __stack_size;
extern UBYTE * NOCOMMON __stk_limit;
extern UBYTE * NOCOMMON __base;
/****************************************************************************/
extern ULONG NOCOMMON __stk_extensions;
extern ULONG NOCOMMON __stk_maxsize;
/****************************************************************************/
extern ULONG NOCOMMON __stk_argbytes;
extern ULONG NOCOMMON __stk_safezone;
extern ULONG NOCOMMON __stk_size;
extern ULONG NOCOMMON __stk_minframe;
extern unsigned int NOCOMMON __stack_size;
/****************************************************************************/

View File

@@ -1,5 +1,5 @@
/*
* $Id: stdlib_protos.h,v 1.17 2006-01-08 12:04:26 obarthel Exp $
* $Id: stdlib_protos.h,v 1.18 2010-10-20 13:50:17 obarthel Exp $
*
* :ts=4
*
@@ -168,11 +168,6 @@ extern void __assertion_failure(const char *file_name,int line_number,const char
/****************************************************************************/
/* stdlib_stackoverflow.c */
extern void __stkovf(void);
/****************************************************************************/
/* stdlib_termination_message.c */
extern void __print_termination_message(const char * termination_message);

View File

@@ -1,5 +1,5 @@
/*
* $Id: stdlib_setjmp.c,v 1.5 2006-11-16 10:09:20 obarthel Exp $
* $Id: stdlib_setjmp.c,v 1.6 2010-10-20 13:50:17 obarthel Exp $
*
* :ts=4
*
@@ -81,55 +81,6 @@ l0: moveq #0,d0 | always return 0 \n\
/****************************************************************************/
#if defined(STACK_EXTENSION)
/****************************************************************************/
asm(" \n\
\n\
AFB_68881 = 4 \n\
AttnFlags = 297 \n\
\n\
.text \n\
.even \n\
\n\
.globl _longjmp \n\
.globl ___stkrst \n\
\n\
_longjmp: \n\
\n\
moveal sp@(4),a0 | (struct __jmp_buf *) env \n\
movel sp@(8),d2 | (int) status \n\
\n\
tstl d2 \n\
bne l1 | skip the following if result is non-zero \n\
\n\
moveq #1,d2 | make sure that the result is always non-zero \n\
\n\
l1: movel a0@(60:W),d0 | get the stack pointer address to restore \n\
jbsr ___stkrst | restore the stack frame \n\
movel d2,d0 | get the return code back \n\
\n\
moveal "A4(_SysBase)",a1 \n\
btst #AFB_68881,a1@(AttnFlags:W) | is there an FPU installed? \n\
beq l2 | skip the following if not \n\
\n\
fmovemx a0@(64:W),fp0-fp7 | restore all floating point registers \n\
\n\
l2: moveml a0@(4:W),d1-d7 | restore all data registers \n\
moveml a0@(36:W),a1-a7 | restore almost all address registers, except for A0 \n\
movel a0@,sp@ | restore A0 \n\
moveal a0@(32:W),a0 | and return to the address setjmp() was called from \n\
rts \n\
\n\
");
/****************************************************************************/
#else
/****************************************************************************/
asm(" \n\
\n\
AFB_68881 = 4 \n\
@@ -166,10 +117,6 @@ l2: moveml a0@(4:W),d1-d7 | restore all data registers \n\
/****************************************************************************/
#endif /* STACK_EXTENSION */
/****************************************************************************/
#elif defined(__mc68000__)
/****************************************************************************/
@@ -196,46 +143,6 @@ _setjmp: \n\
/****************************************************************************/
#if defined(STACK_EXTENSION)
/****************************************************************************/
asm(" \n\
\n\
.text \n\
.even \n\
\n\
.globl _longjmp \n\
.globl ___stkrst \n\
\n\
_longjmp: \n\
\n\
moveal sp@(4),a0 | (struct __jmp_buf *) env \n\
movel sp@(8),d2 | (int) status \n\
\n\
tstl d2 \n\
bne l1 | skip the following if result is non-zero \n\
\n\
moveq #1,d2 | make sure that the result is always non-zero \n\
\n\
l1: movel a0@(60:W),d0 | get the stack pointer address to restore \n\
jbsr ___stkrst | restore the stack frame \n\
movel d2,d0 | get the return code back \n\
\n\
moveml a0@(4:W),d1-d7 | restore all data registers \n\
moveml a0@(36:W),a1-a7 | restore almost all address registers, except for A0 \n\
movel a0@,sp@ | restore A0 \n\
moveal a0@(32:W),a0 | and return to the address setjmp() was called from \n\
rts \n\
\n\
");
/****************************************************************************/
#else
/****************************************************************************/
asm(" \n\
\n\
.text \n\
@@ -263,26 +170,10 @@ l1: moveml a0@(4:W),d1-d7 | restore all data registers \n\
/****************************************************************************/
#endif /* STACK_EXTENSION */
/****************************************************************************/
#elif defined(__PPC__)
/****************************************************************************/
#if defined(STACK_EXTENSION)
/****************************************************************************/
#error "STACK_EXTENSION is not supported on the PowerPC"
/****************************************************************************/
#else
/****************************************************************************/
#ifdef PPC_FLOATING_POINT_SUPPORT
__asm(" \n\
@@ -403,8 +294,6 @@ longjmp: \n\
#endif /* defined PPC_FLOATING_POINT_SUPPORT */
#endif /* defined STACK_EXTENSION */
/****************************************************************************/
#endif /* PPC */

View File

@@ -1,5 +1,5 @@
/*
* $Id: stdlib_stack_usage.c,v 1.7 2006-01-08 12:04:26 obarthel Exp $
* $Id: stdlib_stack_usage.c,v 1.8 2010-10-20 13:50:17 obarthel Exp $
*
* :ts=4
*
@@ -43,11 +43,6 @@ static struct StackSwapStruct stack_swap_struct;
/****************************************************************************/
ULONG __stk_extensions; /* number of stack extensions performed */
ULONG __stk_maxsize; /* maximum amount of memory allocated for stack extension */
/****************************************************************************/
#define STACK_FILL_COOKIE 0xA1
/****************************************************************************/
@@ -96,17 +91,6 @@ __stack_usage_exit(void)
stack_swap_struct.stk_Lower = NULL;
stack_swap_struct.stk_Upper = 0;
}
if(__stk_maxsize == 0)
{
kprintf("[%s] no stack extension was performed\n",
__program_name);
}
else
{
kprintf("[%s] maximum size of extended stack = %ld bytes, stack was extended %ld times\n",
__program_name,__stk_maxsize,__stk_extensions);
}
}
/****************************************************************************/

View File

@@ -1,40 +0,0 @@
/*
* $Id: stdlib_stackargbytes.c,v 1.4 2006-01-08 12:04:26 obarthel Exp $
*
* :ts=4
*
* Portable ISO 'C' (1994) runtime library for the Amiga computer
* Copyright (c) 2002-2006 by Olaf Barthel <olsen (at) sourcery.han.de>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Neither the name of Olaf Barthel nor the names of contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef EXEC_TYPES_H
#include <exec/types.h>
#endif /* EXEC_TYPES_H */
/****************************************************************************/
ULONG __stk_argbytes = 256;

View File

@@ -1,142 +0,0 @@
/*
* $Id: stdlib_stackcheck.c,v 1.10 2006-01-08 12:04:26 obarthel Exp $
*
* :ts=4
*
* Portable ISO 'C' (1994) runtime library for the Amiga computer
* Copyright (c) 2002-2006 by Olaf Barthel <olsen (at) sourcery.han.de>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Neither the name of Olaf Barthel nor the names of contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _STDLIB_HEADERS_H
#include "stdlib_headers.h"
#endif /* _STDLIB_HEADERS_H */
/****************************************************************************/
#ifndef _STDLIB_CONSTRUCTOR_H
#include "stdlib_constructor.h"
#endif /* _STDLIB_CONSTRUCTOR_H */
/****************************************************************************/
#if (defined(__GNUC__) && !defined(__PPC__))
/****************************************************************************/
/* The stack extension code has its own set of these routines. */
#ifndef STACK_EXTENSION
/****************************************************************************/
#if defined(SMALL_DATA)
#define A4(x) "a4@(" #x ":W)"
#elif defined(SMALL_DATA32)
#define A4(x) "a4@(" #x ":L)"
#else
#define A4(x) #x
#endif /* SMALL_DATA */
/****************************************************************************/
asm(" \n\
\n\
.text \n\
.even \n\
\n\
.globl ___stkovf \n\
.globl ___stk_limit \n\
\n\
.globl ___stkchk_d0 \n\
\n\
___stkchk_d0: \n\
\n\
negl d0 \n\
addl sp,d0 \n\
cmpl "A4(___stk_limit)",d0 \n\
jcs overflow | if (sp-d0) < __stk_limit then we have an overflow\n\
rts \n\
\n\
.globl ___stkchk_0 \n\
\n\
___stkchk_0: \n\
\n\
cmpl "A4(___stk_limit)",sp \n\
jcs overflow | if sp < __stk_limit then we have an overflow\n\
rts \n\
\n\
overflow: \n\
\n\
movel #0,"A4(___stk_limit)" | disable stack checking \n\
jra ___stkovf \n\
\n\
");
/****************************************************************************/
#endif /* STACK_EXTENSION && !__PPC__ */
/****************************************************************************/
#endif /* __GNUC__ */
/****************************************************************************/
UBYTE * NOCOMMON __stk_limit;
/****************************************************************************/
#if defined(__SASC)
UBYTE * __base;
#endif /* __SASC */
/****************************************************************************/
STK_CONSTRUCTOR(stk_init)
{
struct Task * this_task = FindTask(NULL);
ULONG lower = (ULONG)this_task->tc_SPLower;
ENTER();
#if defined(__GNUC__)
{
__stk_limit = (UBYTE *)(lower + __stk_safezone + __stk_argbytes);
}
#endif /* __GNUC__ */
#if defined(__SASC)
{
__base = (UBYTE *)(lower + __stk_safezone + __stk_argbytes);
}
#endif /* __SASC */
LEAVE();
CONSTRUCTOR_SUCCEED();
}

View File

@@ -1,649 +0,0 @@
/*
* $Id: stdlib_stackextension.c,v 1.13 2006-01-08 12:04:26 obarthel Exp $
*
* :ts=4
*
* Portable ISO 'C' (1994) runtime library for the Amiga computer
* Copyright (c) 2002-2006 by Olaf Barthel <olsen (at) sourcery.han.de>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Neither the name of Olaf Barthel nor the names of contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _STDLIB_HEADERS_H
#include "stdlib_headers.h"
#endif /* _STDLIB_HEADERS_H */
/****************************************************************************/
#ifndef _STDLIB_MEMORY_H
#include "stdlib_memory.h"
#endif /* _STDLIB_MEMORY_H */
/****************************************************************************/
#ifndef _STDLIB_CONSTRUCTOR_H
#include "stdlib_constructor.h"
#endif /* _STDLIB_CONSTRUCTOR_H */
/****************************************************************************/
#if (defined(__GNUC__) && !defined(__PPC__))
/****************************************************************************/
#if defined(STACK_EXTENSION)
/****************************************************************************/
/* internal structure used by the stackextend code */
struct stackframe
{
struct stackframe * next; /* NULL if there is no next one */
void * savesp; /* stored sp for next underlying stackframe */
void * upper; /* end of this stackframe+1 */
};
/****************************************************************************/
/* Local stack extension variables */
static void * __stk_sp_lower; /* original entries of task structure */
static void * __stk_sp_upper; /* to restore them at exit */
static void * __stk_initial_sp_lower; /* original stackborders */
static void * __stk_initial_sp_upper;
static struct stackframe * __stk_used; /* used stackframes */
static struct stackframe * __stk_spare; /* spare stackframes */
/****************************************************************************/
ULONG NOCOMMON __stk_extensions; /* number of stack extensions performed */
ULONG NOCOMMON __stk_maxsize; /* maximum amount of memory allocated for stack extension */
/****************************************************************************/
#if defined(SMALL_DATA)
#define A4(x) "a4@(" #x ":W)"
#elif defined(SMALL_DATA32)
#define A4(x) "a4@(" #x ":L)"
#else
#define A4(x) #x
#endif /* SMALL_DATA */
/****************************************************************************/
/* Glue code */
asm("
_LVOStackSwap = -0x2dc
StackSwapStruct_SIZEOF = 12
.globl _SysBase
.globl ___stk_limit
|-----------------------------------------------------------------------------
.globl ___link_a5_0_f
___link_a5_0_f:
movel sp@+,a0 | load the return address into A0
cmpl "A4(___stk_limit)",sp
jcc l0 | if SP >= __stk_limit then we are well within bounds
jbsr l2 | try to extend the stack
l0: link a5,#0:W | restore frame pointer
jmp a0@ | go to the return address
|-----------------------------------------------------------------------------
.globl ___sub_0_sp_f
___sub_0_sp_f:
movel sp@+,a0 | load the return address into A0
cmpl "A4(___stk_limit)",sp
jcc l1 | if SP >= __stk_limit then we are well within bounds
jbsr l2 | try to extend the stack
l1: jmp a0@ | go to the return address
l2: moveq #0,d0
moveq #0,d1
jra ___stkext_f | try stack extension
|-----------------------------------------------------------------------------
.globl ___link_a5_d0_f
___link_a5_d0_f:
movel sp@+,a0 | load the return address into A0
movel sp,d1
subl d0,d1 | D0 holds size of stack adjustment to make
cmpl "A4(___stk_limit)",d1
jcc l3 | if (SP-D0) >= __stk_limit then we are well within bounds
jbsr l5 | try stack extension
l3: link a5,#0:W | restore the frame pointer
subl d0,sp | adjust the stack pointer, as required
jmp a0@ | go to the return address
|-----------------------------------------------------------------------------
.globl ___sub_d0_sp_f
___sub_d0_sp_f:
movel sp@+,a0 | load the return address into A0
movel sp,d1
subl d0,d1 | D0 holds size of stack adjustment to make
cmpl "A4(___stk_limit)",d1
jcc l4 | if (SP-D0) >= __stk_limit then we are well within bounds
jbsr l5 | try stack extension
l4: subl d0,sp | adjust the stack pointer, as required
jmp a0@ | go to the return address
l5: moveq #0,d1
jra ___stkext_f | try stack extension
|-----------------------------------------------------------------------------
.globl ___sub_d0_sp
___sub_d0_sp:
movel sp@+,a0 | load the return address into A0
movel sp,d1
subl d0,d1 | D0 holds size of stack adjustment to make
cmpl "A4(___stk_limit)",d1
jcc l6 | if (SP-D0) >= __stk_limit then we are well within bounds
jbsr ___stkext | try stack extension
l6: subl d0,sp | adjust the stack pointer, as required
jmp a0@ | go to the return address
|-----------------------------------------------------------------------------
.globl ___move_d0_sp
___move_d0_sp:
jra ___stkrst | Straight jump into ___stkrst
|-----------------------------------------------------------------------------
.globl ___unlk_a5_rts
___unlk_a5_rts:
movel d0,a0 | Preserve D0
movel a5,d0 | A5 is stack pointer to be restored
jbsr ___stkrst
movel a0,d0 | Restore D0
movel sp@+,a5 | Restore A5, thus performing 'unlink A5'
rts
|-----------------------------------------------------------------------------
.globl ___stkext
___stkext:
moveml d0/d1/a0/a1/a6,sp@-
subw #StackSwapStruct_SIZEOF,sp
jbsr _stkext
tstl d0
jeq s_noext
movel "A4(_SysBase)",a6
movel sp,a0
jsr a6@(_LVOStackSwap)
s_ret:
moveml sp@+,d0/d1/a0/a1/a6
rts
s_noext:
addw #StackSwapStruct_SIZEOF,sp
jra s_ret
|-----------------------------------------------------------------------------
.globl ___stkext_f
___stkext_f:
moveml d0/d1/a0/a1/a6,sp@-
subw #StackSwapStruct_SIZEOF,sp
jbsr _stkext_f
tstl d0
jeq sf_noext
movel "A4(_SysBase)",a6
movel sp,a0
jsr a6@(_LVOStackSwap)
sf_ret:
moveml sp@+,d0/d1/a0/a1/a6
rts
sf_noext:
addw #StackSwapStruct_SIZEOF,sp
jra sf_ret
|-----------------------------------------------------------------------------
.globl ___stkrst_f
___stkrst_f:
moveml d0/d1/a0/a1/a6,sp@-
subw #StackSwapStruct_SIZEOF,sp
jbsr _stkrst_f
movel "A4(_SysBase)",a6
movel sp,a0
jsr a6@(_LVOStackSwap)
moveml sp@+,d0/d1/a0/a1/a6
rts
|-----------------------------------------------------------------------------
.globl ___stkrst
___stkrst:
moveml d0/d1/a0/a1/a6,sp@-
subw #StackSwapStruct_SIZEOF,sp
jbsr _stkrst | calculate either target sp or StackSwapStruct
tstl d0 | set target sp?
jeq swpfrm | jump if not
movel d0,a0 | I have a lot of preserved registers and
| returnadresses on the stack. It's necessary
| to copy them to the new location
moveq #6,d0 | 1 rts, 5 regs and 1 signal mask to copy (1+5+1)-1=6
lea sp@(40:W),a1 | get address of uppermost byte+1 (1+5+1)*4+StackSwapStruct_SIZEOF=40
cmpl a0,a1 | compare with target location
jls lp1 | jump if source<=target
lea a0@(-28:W),a0 | else start at lower bound (1+5+1)*4=28
lea a1@(-28:W),a1
movel a0,sp | set sp to reserve the room
lp0:
movel a1@+,a0@+ | copy with raising addresses
dbra d0,lp0 | as long as d0>=0.
jra endlp | ready
lp1:
movel a1@-,a0@- | copy with falling addresses
dbra d0,lp1 | as long as d0>=0
movel a0,sp | finally set sp
jra endlp | ready
swpfrm:
movel "A4(_SysBase)",a6
movel sp,a0
jsr a6@(_LVOStackSwap)
endlp:
moveml sp@+,d0/d1/a0/a1/a6 | restore registers
rts | and return
");
/****************************************************************************/
UBYTE * __stk_limit;
ULONG __stk_size;
/****************************************************************************/
STK_CONSTRUCTOR(stk_init)
{
struct Task *task = FindTask(NULL);
ENTER();
__stk_initial_sp_lower = __stk_sp_lower = task->tc_SPLower; /* Lower stack bound */
__stk_initial_sp_upper = __stk_sp_upper = task->tc_SPUpper; /* Upper stack bound +1 */
SHOWPOINTER(__stk_sp_lower);
SHOWPOINTER(__stk_sp_upper);
D(("stack size = %ld",(ULONG)__stk_sp_upper - (ULONG)__stk_sp_lower));
LEAVE();
CONSTRUCTOR_SUCCEED();
}
/****************************************************************************/
/* Free all spare stackframes */
STK_DESTRUCTOR(stk_exit)
{
ENTER();
if(__memory_pool == NULL)
{
struct stackframe *sf, *sf_next;
SHOWMSG("we don't have a memory pool; cleaning up the stack frames manually");
for(sf = __stk_spare ; sf != NULL ; sf = sf_next)
{
sf_next = sf->next;
FreeMem(sf, (char *)sf->upper - (char *)sf);
}
}
__stk_spare = NULL;
LEAVE();
}
/****************************************************************************/
/* Move a stackframe with a minimum of requiredstack bytes to the used list
and fill the StackSwapStruct structure. */
STATIC VOID
pushframe(ULONG requiredstack, struct StackSwapStruct *sss)
{
struct stackframe *sf;
ULONG recommendedstack;
ENTER();
requiredstack += __stk_safezone + __stk_argbytes;
if (requiredstack < __stk_minframe)
requiredstack = __stk_minframe;
SHOWVALUE(requiredstack);
recommendedstack = __stk_maxsize - __stk_size;
if (recommendedstack < requiredstack)
recommendedstack = requiredstack;
SHOWVALUE(recommendedstack);
for (;;)
{
sf = __stk_spare; /* get a stackframe from the spares list */
if (sf == NULL) /* stack overflown */
{
for ( ; recommendedstack >= requiredstack ; recommendedstack /= 2)
{
D(("allocating %ld bytes for a stack frame",recommendedstack + sizeof(struct stackframe)));
if(__memory_pool != NULL)
{
__memory_lock();
sf = AllocPooled(__memory_pool,recommendedstack + sizeof(struct stackframe));
__memory_unlock();
}
else
{
sf = AllocMem(recommendedstack + sizeof(struct stackframe), MEMF_ANY);
}
if (sf != NULL)
break;
SHOWMSG("that didn't work");
}
if (sf == NULL) /* and we have no way to extend it :-| */
{
SHOWMSG("bad luck... stack overflow!");
__stkovf();
}
sf->upper = (char *)(sf + 1) + recommendedstack;
break;
}
__stk_spare = sf->next;
if ((ULONG)((char *)sf->upper - (char *)(sf + 1)) >= recommendedstack)
break;
if(__memory_pool != NULL)
{
__memory_lock();
FreePooled(__memory_pool, sf, (char *)sf->upper - (char *)sf);
__memory_unlock();
}
else
{
FreeMem(sf, (char *)sf->upper - (char *)sf);
}
}
/* Add stackframe to the used list */
sf->next = __stk_used;
__stk_used = sf;
__stk_limit = (char *)(sf + 1) + __stk_safezone + __stk_argbytes;
/* prepare StackSwapStruct */
(void *)sss->stk_Pointer = (void *)sf->upper;
sss->stk_Lower = sf + 1;
(ULONG)sss->stk_Upper = (ULONG)sf->upper;
/* Update stack statistics. */
__stk_size += (char *)sf->upper - (char *)(sf + 1);
if (__stk_size > __stk_maxsize)
__stk_maxsize = __stk_size;
__stk_extensions++;
SHOWVALUE(__stk_size);
SHOWVALUE(__stk_maxsize);
SHOWVALUE(__stk_extensions);
LEAVE();
}
/****************************************************************************/
#define STK_UPPER (__stk_used != NULL ? __stk_used->upper : __stk_initial_sp_upper)
#define STK_LOWER (__stk_used != NULL ? (void *)(__stk_used + 1) : __stk_initial_sp_lower)
/****************************************************************************/
/* Allocate a new stackframe with d0 bytes minimum. */
int
stkext(struct StackSwapStruct sss, long d0, long d1, long a0, long a1, long a6, long ret1)
{
void *callsp = &ret1 + 1;
int cpsize = (char *)callsp - (char *)&d0;
int result;
ENTER();
D(("new stack frame with at least %ld bytes space is required", d0));
if (callsp >= STK_UPPER || callsp < STK_LOWER)
{
SHOWMSG("that didn't turn out right");
result = 0; /* User intentionally left area of stackextension */
}
else
{
pushframe((ULONG)d0, &sss);
*(char **)&sss.stk_Pointer -= cpsize;
CopyMem(&d0, sss.stk_Pointer, cpsize);
SHOWMSG("done");
result = 1;
}
RETURN (result);
return (result);
}
/****************************************************************************/
/* Defined in the glue code above. */
extern void __stkrst_f(void);
/****************************************************************************/
/* Allocate a new stackframe with d0 bytes minimum, copy the callers arguments
and set his returnaddress (offset d1 from the sp when called) to stk_rst_f */
int
stkext_f(struct StackSwapStruct sss, long d0, long d1, long a0, long a1, long a6, long ret1)
{
void *argtop, *callsp = &ret1 + 1;
int cpsize;
int result;
ENTER();
D(("new stack frame with at least %ld bytes space is required", d0));
if (callsp >= STK_UPPER || callsp < STK_LOWER)
{
SHOWMSG("that didn't turn out right");
result = 0; /* User intentionally left area of stackextension */
}
else
{
argtop = (char *)callsp + __stk_argbytes; /* Top of area with arguments */
if (argtop > STK_UPPER)
argtop = STK_UPPER;
cpsize = (char *)argtop - (char *)&d0;
pushframe((ULONG)d0, &sss);
*(char **)&sss.stk_Pointer -= cpsize;
CopyMem(&d0, sss.stk_Pointer, cpsize);
__stk_used->savesp = (char *)callsp + d1; /* store sp */
*(void **)((char *)sss.stk_Upper - ((char *)argtop - (char *)callsp) + d1) = &__stkrst_f; /* set returnaddress */
SHOWMSG("done");
result = 1;
}
RETURN (result);
return (result);
}
/****************************************************************************/
/* Move all used stackframes upto (and including) sf to the spares list
and fill the StackSwapStruct structure. */
STATIC VOID
popframes(struct stackframe *sf, struct StackSwapStruct *sss)
{
struct stackframe *sf2;
ENTER();
if (sf->next != NULL)
{
sss->stk_Lower = sf->next + 1;
(ULONG)sss->stk_Upper = (ULONG)sf->next->upper;
__stk_limit = (char *)(sf->next + 1) + __stk_safezone + __stk_argbytes;
}
else
{
sss->stk_Lower = __stk_sp_lower;
(ULONG)sss->stk_Upper = (ULONG)__stk_sp_upper;
__stk_limit = (char *)__stk_initial_sp_lower + __stk_safezone + __stk_argbytes;
}
sf2 = __stk_spare;
__stk_spare = __stk_used;
__stk_used = sf->next;
sf->next = sf2;
/* Update stack statistics. */
for (sf2 = __stk_spare ; sf2 != sf->next ; sf2 = sf2->next)
__stk_size -= (char *)sf2->upper - (char *)(sf2 + 1);
SHOWVALUE(__stk_size);
LEAVE();
}
/****************************************************************************/
/* Set stackpointer back to some previous value
!= NULL: on the same stackframe (returns sp)
== NULL: on another stackframe */
void *
stkrst(struct StackSwapStruct sss, void *d0, long d1, long a0, long a1, long a6, long ret1)
{
void *callsp = &ret1 + 1;
int cpsize = (char *)callsp - (char *)&d0;
struct stackframe *sf1, *sf2;
void * result = d0;
ENTER();
if (d0 >= STK_LOWER && d0 < STK_UPPER)
goto out;
sf1 = __stk_used;
if (sf1 == NULL)
goto out;
for (;;)
{
sf2 = sf1->next;
if (sf2 == NULL)
{
if (d0 < __stk_initial_sp_lower || d0 >= __stk_initial_sp_upper)
goto out;
break;
}
if (d0 >= (void *)(sf2 + 1) && d0 < sf2->upper) /* This stackframe fits */
break;
sf1 = sf2;
}
popframes(sf1, &sss);
sss.stk_Pointer = (char *)d0 - cpsize;
CopyMem(&d0, sss.stk_Pointer,cpsize);
result = NULL;
out:
RETURN (result);
return (result);
}
/****************************************************************************/
/* return to last stackframe */
void
stkrst_f(struct StackSwapStruct sss, long d0, long d1, long a0, long a1, long a6)
{
void *callsp = &a6 + 1; /* This one has no returnaddress - it's a fallback for rts */
int cpsize = (char *)callsp - (char *)&d0;
ENTER();
sss.stk_Pointer = (char *)__stk_used->savesp - cpsize;
popframes(__stk_used, &sss);
CopyMem(&d0, sss.stk_Pointer, cpsize);
LEAVE();
}
/****************************************************************************/
#endif /* STACK_EXTENSION */
/****************************************************************************/
#endif /* __GNUC__ && !__PPC__ */

View File

@@ -1,40 +0,0 @@
/*
* $Id: stdlib_stackminframe.c,v 1.4 2006-01-08 12:04:26 obarthel Exp $
*
* :ts=4
*
* Portable ISO 'C' (1994) runtime library for the Amiga computer
* Copyright (c) 2002-2006 by Olaf Barthel <olsen (at) sourcery.han.de>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Neither the name of Olaf Barthel nor the names of contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef EXEC_TYPES_H
#include <exec/types.h>
#endif /* EXEC_TYPES_H */
/****************************************************************************/
ULONG __stk_minframe = 32768;

View File

@@ -1,84 +0,0 @@
/*
* $Id: stdlib_stackoverflow.c,v 1.4 2006-01-08 12:04:26 obarthel Exp $
*
* :ts=4
*
* Portable ISO 'C' (1994) runtime library for the Amiga computer
* Copyright (c) 2002-2006 by Olaf Barthel <olsen (at) sourcery.han.de>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Neither the name of Olaf Barthel nor the names of contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _STDLIB_HEADERS_H
#include "stdlib_headers.h"
#endif /* _STDLIB_HEADERS_H */
/****************************************************************************/
extern BOOL NOCOMMON __stack_overflow;
/****************************************************************************/
#if defined(__GNUC__)
/****************************************************************************/
void
__stkovf(void)
{
/* We're in trouble. */
__stack_overflow = TRUE;
/* This will restore things to a sane state, display an
* error requester and drop into _exit().
*/
longjmp(__exit_jmp_buf,1);
}
/****************************************************************************/
#endif /* __GNUC__ */
/****************************************************************************/
#if defined(__SASC)
/****************************************************************************/
VOID
_XCOVF(VOID)
{
/* We're in trouble. */
__stack_overflow = TRUE;
/* This will restore things to a sane state, display an
* error requester and drop into _exit().
*/
longjmp(__exit_jmp_buf,1);
}
/****************************************************************************/
#endif /* __SASC */

View File

@@ -1,40 +0,0 @@
/*
* $Id: stdlib_stacksafezone.c,v 1.4 2006-01-08 12:04:26 obarthel Exp $
*
* :ts=4
*
* Portable ISO 'C' (1994) runtime library for the Amiga computer
* Copyright (c) 2002-2006 by Olaf Barthel <olsen (at) sourcery.han.de>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Neither the name of Olaf Barthel nor the names of contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef EXEC_TYPES_H
#include <exec/types.h>
#endif /* EXEC_TYPES_H */
/****************************************************************************/
ULONG __stk_safezone = 2048;

View File

@@ -1,5 +1,5 @@
/*
* $Id: termios_console_fdhookentry.c,v 1.5 2006-11-16 14:39:23 obarthel Exp $
* $Id: termios_console_fdhookentry.c,v 1.6 2010-10-20 13:12:59 obarthel Exp $
*
* :ts=4
*
@@ -474,6 +474,7 @@ __termios_console_hook(
/* And that's the last for this file descriptor. */
memset(fd,0,sizeof(*fd));
fd = NULL;
break;

View File

@@ -1,5 +1,5 @@
/*
* $Id: unistd_isatty.c,v 1.10 2008-04-16 07:46:05 obarthel Exp $
* $Id: unistd_isatty.c,v 1.11 2010-10-20 13:12:59 obarthel Exp $
*
* :ts=4
*
@@ -67,14 +67,14 @@ isatty(int file_descriptor)
goto out;
}
__fd_lock(fd);
if(FLAG_IS_SET(fd->fd_Flags,FDF_IS_SOCKET))
{
__set_errno(ENOTTY);
goto out;
}
__fd_lock(fd);
result = 1;
if(FLAG_IS_CLEAR(fd->fd_Flags,FDF_IS_INTERACTIVE))

View File

@@ -1,152 +0,0 @@
#
# $Id: GNUmakefile.68k,v 1.15 2006-09-25 18:20:09 obarthel Exp $
#
# :ts=8
#
##############################################################################
CC = gcc
DELETE = delete all quiet
##############################################################################
.c.o:
@echo "Compiling $<"
@$(CC) -c $(CFLAGS) $<
##############################################################################
#CODE_TYPE := -fbaserel -DSMALL_DATA -m68020-60 -DM68020
#CODE_TYPE := -fbaserel -DSMALL_DATA -m68000
#CODE_TYPE := -fbaserel32 -DSMALL_DATA32 -m68020-60 -DM68020
CODE_TYPE := -m68020-60 -DM68020
#CODE_TYPE := -m68000
##############################################################################
WARNINGS = \
-Wall -W -Wshadow -Wpointer-arith -Wsign-compare -Wmissing-prototypes \
-Wundef -Wbad-function-cast -Wmissing-declarations -Wconversion
INCLUDE = -I../library/include
LIB = -L../library/lib
OPTIONS = -DNDEBUG -fno-builtin -fwritable-strings -DNO_INLINE_STDARG -DIEEE_FLOATING_POINT_SUPPORT
#OPTIONS = -D__MEM_DEBUG -fno-builtin
#OPTIONS = -DDEBUG -D__MEM_DEBUG -DNO_INLINE_STDARG -fno-builtin
OPTIMIZE = -O
#OPTIMIZE = -O2 -fomit-frame-pointer
DEBUG = -ggdb
CFLAGS = $(WARNINGS) $(OPTIMIZE) $(DEBUG) $(OPTIONS) $(CODE_TYPE) $(INCLUDE) $(LIB)
##############################################################################
LIBS = -lm -lc -lgcc
##############################################################################
all: test fgets_test iotest sscanf_test printf_test sprintf_test \
stack_size_test translate_test strtok_test uname simple \
fstat_stdout_test simple_sprintf date_test sscanf_64 factorial \
execvp_test setlocale rand fstat_test base_dir_nametest
clean:
$(DELETE) #?.o #?.map test fgets_test iotest sscanf_test printf_test \
sprintf_test stack_size_test translate_test strtok_test uname \
simple fstat_stdout_test fstat_test simple_sprintf date_test sscanf_64 \
factorial execvp_test setlocale rand base_dir_nametest
##############################################################################
setlocale : setlocale.o
@echo "Linking $@"
$(CC) $(CFLAGS) -o $@ setlocale.o $(LIBS) -Wl,--cref,-M,-Map=$@.map
test : test.o
@echo "Linking $@"
$(CC) $(CFLAGS) -o $@ test.o $(LIBS) -Wl,--cref,-M,-Map=$@.map
fgets_test : fgets_test.o
@echo "Linking $@"
$(CC) $(CFLAGS) -o $@ fgets_test.o $(LIBS) -Wl,--cref,-M,-Map=$@.map
strtok_test : strtok_test.o
@echo "Linking $@"
$(CC) $(CFLAGS) -o $@ strtok_test.o $(LIBS) -Wl,--cref,-M,-Map=$@.map
iotest : iotest.o
@echo "Linking $@"
$(CC) $(CFLAGS) -o $@ iotest.o $(LIBS) -Wl,--cref,-M,-Map=$@.map
sscanf_test : sscanf_test.o
@echo "Linking $@"
$(CC) $(CFLAGS) -o $@ sscanf_test.o $(LIBS) -Wl,--cref,-M,-Map=$@.map
printf_test : printf_test.o
@echo "Linking $@"
$(CC) $(CFLAGS) -o $@ printf_test.o $(LIBS) -Wl,--cref,-M,-Map=$@.map
sprintf_test : sprintf_test.o
@echo "Linking $@"
$(CC) $(CFLAGS) -o $@ sprintf_test.o $(LIBS) -Wl,--cref,-M,-Map=$@.map
stack_size_test : stack_size_test.o
@echo "Linking $@"
$(CC) $(CFLAGS) -o $@ stack_size_test.o $(LIBS) -Wl,--cref,-M,-Map=$@.map
translate_test : translate_test.o
@echo "Linking $@"
$(CC) $(CFLAGS) -o $@ translate_test.o -lunix $(LIBS) -Wl,--cref,-M,-Map=$@.map
uname : uname.o
@echo "Linking $@"
$(CC) $(CFLAGS) -o $@ uname.o -lunix $(LIBS) -Wl,--cref,-M,-Map=$@.map
simple : simple.o
@echo "Linking $@"
$(CC) $(CFLAGS) -o $@ simple.o $(LIBS) -Wl,--cref,-M,-Map=$@.map
fstat_stdout_test : fstat_stdout_test.o
@echo "Linking $@"
$(CC) $(CFLAGS) -o $@ fstat_stdout_test.o $(LIBS) -Wl,--cref,-M,-Map=$@.map
fstat_test : fstat_test.o
@echo "Linking $@"
$(CC) $(CFLAGS) -o $@ fstat_test.o -lunix $(LIBS) -Wl,--cref,-M,-Map=$@.map
simple_sprintf : simple_sprintf.o
@echo "Linking $@"
$(CC) -nostdlib $(CFLAGS) -o $@ simple_sprintf.o -lc -Wl,--cref,-M,-Map=$@.map
date_test : date_test.o
@echo "Linking $@"
$(CC) $(CFLAGS) -o $@ date_test.o $(LIBS) -Wl,--cref,-M,-Map=$@.map
sscanf_64 : sscanf_64.o
@echo "Linking $@"
$(CC) $(CFLAGS) -o $@ sscanf_64.o $(LIBS) -Wl,--cref,-M,-Map=$@.map
factorial : factorial.o
@echo "Linking $@"
$(CC) $(CFLAGS) -o $@ factorial.o $(LIBS) -Wl,--cref,-M,-Map=$@.map
execvp_test : execvp_test.o
@echo "Linking $@"
$(CC) $(CFLAGS) -o $@ execvp_test.o -lunix $(LIBS) -Wl,--cref,-M,-Map=$@.map
base_dir_nametest : base_dir_nametest.o
@echo "Linking $@"
$(CC) $(CFLAGS) -o $@ base_dir_nametest.o -lunix $(LIBS) -Wl,--cref,-M,-Map=$@.map
rand : rand.o
@echo "Linking $@"
$(CC) $(CFLAGS) -o $@ rand.o $(LIBS) -Wl,--cref,-M,-Map=$@.map
##############################################################################
mkid:
mkid -v #?.(c|h|asm|i)
update:
mkid -v -u

View File

@@ -1,124 +0,0 @@
#
# $Id: GNUmakefile.os4,v 1.13 2006-04-18 08:29:46 obarthel Exp $
#
# :ts=8
#
##############################################################################
CC = ppc-amigaos-gcc
DELETE = rm -r
##############################################################################
.c.o:
@echo "Compiling $<"
@$(CC) -c $(CFLAGS) $<
##############################################################################
WARNINGS = \
-Wall -W -Wshadow -Wpointer-arith -Wsign-compare -Wmissing-prototypes \
-Wundef -Wbad-function-cast -Wmissing-declarations -Wconversion
INCLUDE = -I$(V)/include -I../library/include
LIB = -L../library/lib
#OPTIONS = -DNDEBUG -fno-builtin -DNO_INLINE_STDARG -DIEEE_FLOATING_POINT_SUPPORT
#OPTIONS = -D__MEM_DEBUG -fno-builtin
OPTIONS = -DDEBUG -DNO_INLINE_STDARG -fno-builtin
#OPTIMIZE = -O
#OPTIMIZE = -O2 -fomit-frame-pointer
DEBUG = -ggdb
CFLAGS = $(WARNINGS) $(OPTIMIZE) $(DEBUG) $(OPTIONS) $(CODE_TYPE) $(INCLUDE) $(LIB)
##############################################################################
LIBS = -lm -lc -ldebug -lgcc
##############################################################################
all: test fgets_test iotest sscanf_test printf_test sprintf_test \
stack_size_test translate_test strtok_test uname simple \
fstat_stdout_test simple_sprintf date_test sscanf_64 \
factorial setlocale
clean:
$(DELETE) *.o *.map test fgets_test iotest sscanf_test printf_test \
sprintf_test stack_size_test translate_test strtok_test \
uname simple fstat_stdout_test simple_sprintf date_test \
sscanf_64 factorial setlocale rand
##############################################################################
setlocale : setlocale.o
@echo "Linking $@"
$(CC) $(CFLAGS) -o $@ setlocale.o $(LIBS) -Wl,--cref,-M,-Map=$@.map
test : test.o
@echo "Linking $@"
$(CC) $(CFLAGS) -o $@ test.o $(LIBS) -Wl,--cref,-M,-Map=$@.map
date_test : date_test.o
@echo "Linking $@"
$(CC) $(CFLAGS) -o $@ test.o $(LIBS) -Wl,--cref,-M,-Map=$@.map
fgets_test : fgets_test.o
@echo "Linking $@"
$(CC) $(CFLAGS) -o $@ fgets_test.o $(LIBS) -Wl,--cref,-M,-Map=$@.map
strtok_test : strtok_test.o
@echo "Linking $@"
$(CC) $(CFLAGS) -o $@ strtok_test.o $(LIBS) -Wl,--cref,-M,-Map=$@.map
iotest : iotest.o
@echo "Linking $@"
$(CC) $(CFLAGS) -o $@ iotest.o $(LIBS) -Wl,--cref,-M,-Map=$@.map
sscanf_test : sscanf_test.o
@echo "Linking $@"
$(CC) $(CFLAGS) -o $@ sscanf_test.o $(LIBS) -Wl,--cref,-M,-Map=$@.map
printf_test : printf_test.o
@echo "Linking $@"
$(CC) $(CFLAGS) -o $@ printf_test.o $(LIBS) -Wl,--cref,-M,-Map=$@.map
sprintf_test : sprintf_test.o
@echo "Linking $@"
$(CC) $(CFLAGS) -o $@ sprintf_test.o $(LIBS) -Wl,--cref,-M,-Map=$@.map
stack_size_test : stack_size_test.o
@echo "Linking $@"
$(CC) $(CFLAGS) -o $@ stack_size_test.o $(LIBS) -Wl,--cref,-M,-Map=$@.map
translate_test : translate_test.o
@echo "Linking $@"
$(CC) $(CFLAGS) -o $@ translate_test.o -lunix $(LIBS) -Wl,--cref,-M,-Map=$@.map
uname : uname.o
@echo "Linking $@"
$(CC) $(CFLAGS) -o $@ uname.o -lunix $(LIBS) -Wl,--cref,-M,-Map=$@.map
simple : simple.o
@echo "Linking $@"
$(CC) $(CFLAGS) -o $@ simple.o $(LIBS) -Wl,--cref,-M,-Map=$@.map
fstat_stdout_test : fstat_stdout_test.o
@echo "Linking $@"
$(CC) $(CFLAGS) -o $@ fstat_stdout_test.o $(LIBS) -Wl,--cref,-M,-Map=$@.map
simple_sprintf : simple_sprintf.o
@echo "Linking $@"
$(CC) -nostdlib $(CFLAGS) -o $@ simple_sprintf.o -lc -lgcc -Wl,--cref,-M,-Map=$@.map
sscanf_64 : sscanf_64.o
@echo "Linking $@"
$(CC) -nostdlib $(CFLAGS) -o $@ sscanf_64.o -lc -lgcc -Wl,--cref,-M,-Map=$@.map
factorial : factorial.o
@echo "Linking $@"
$(CC) -nostdlib $(CFLAGS) -o $@ factorial.o -lc -lgcc -Wl,--cref,-M,-Map=$@.map
rand : rand.o
@echo "Linking $@"
$(CC) -nostdlib $(CFLAGS) -o $@ rand.o -lc -lgcc -Wl,--cref,-M,-Map=$@.map

View File

@@ -1,4 +0,0 @@
This is a collection of programs I'm using to test the library. These
are functional tests: the library is supposed to do something, and produce
a particular result. For example, "printf_test" exercises a bunch of
output formatting rules.

View File

@@ -1,20 +0,0 @@
/*
* $Id: base_dir_nametest.c,v 1.1 2006-09-25 18:20:09 obarthel Exp $
*
* :ts=4
*/
#include <unistd.h>
#include <libgen.h>
#include <stdio.h>
int
main(int argc,char ** argv)
{
int i;
for(i = 1 ; i < argc ; i++)
printf("%s\n\tbasename=%s\n\t dirname=%s\n",argv[i],basename(argv[i]),dirname(argv[i]));
return(0);
}

View File

@@ -1,74 +0,0 @@
#include <stdio.h>
#include <string.h>
#define LINEBUFLENGTH 180
#define STRIP_LF(str) (str[strlen(str)-1]=0)
void invert_str(char * in)
{
char t;
while(t=*in)
{
*in++=~t;
}
}
int main(int i, char *c[])
{
char dest_fname[80], in_linebuffer[LINEBUFLENGTH];
FILE * fileout, * filein;
if(i>1)
{
sprintf(dest_fname, "%s.c", c[1]);
fileout=fopen(dest_fname, "w");
filein =fopen(c[1], "r");
if(fileout && filein)
{
fgets(in_linebuffer, LINEBUFLENGTH, filein);
STRIP_LF(in_linebuffer);
invert_str(in_linebuffer);
fputs("char *s_leading=\"", fileout);
fputs(in_linebuffer, fileout);
fputs("\";\n", fileout);
fputs("char *s_messages[]={\n", fileout);
while(fgets(in_linebuffer, LINEBUFLENGTH, filein))
{
STRIP_LF(in_linebuffer);
invert_str(in_linebuffer);
fputs("\"", fileout);
fputs(in_linebuffer, fileout);
fputs("\",\n", fileout);
}
fputs("};\n", fileout);
fputs("unsigned s_mess_num = sizeof(s_messages)/sizeof(char *);\n", fileout);
fclose(filein);
fclose(fileout);
}
}
return 0;
}
/*
What's this stuff for ? I use it in SP_Engine to hide the usual bunch of "secret
messages". As you can see, the strings are simply not'ed .
This source shows both flaws: fgets() and the missing buffer flush. You can
change the while() statement with
while(!feof(filein))
{
fgets(in_linebuffer, LINEBUFLENGTH, filein);
....
This way you'll workaround the first problem.
The second issue manifests itself this way: the last two fputs() followed by the
fclose() don't do anything: no "};\n" and no "unsigned....." lines are output to
'fileout'. With SAS, it works perfectly. Converting the source to dos.library
calls also works perfectly. I wonder if there's some kind of strange interaction
with the dos/shell updates.
*/

View File

@@ -1,22 +0,0 @@
#include <time.h>
#include <stdio.h>
#include <locale.h>
int
main(void)
{
time_t tm;
struct tm *ptr;
char str[60];
setlocale(LC_ALL, "C");
tm = time(NULL);
ptr = localtime(&tm);
strftime(str, sizeof(str), "%x\n", ptr);
printf(str);
return 0;
}

View File

@@ -1,16 +0,0 @@
/*
* $Id: execvp_test.c,v 1.2 2006-08-07 08:39:56 obarthel Exp $
*
* :ts=4
*/
#include <unistd.h>
int
main(int argc,char ** argv)
{
if(argc > 1)
execvp(argv[1],&argv[1]);
return(0);
}

View File

@@ -1,25 +0,0 @@
#include <stdio.h>
/*
gcc -std=c99 -mcrt=clib2 -o factorial factorial.c -lm
output is:
16! = 20922789888 <- Wrong
gcc -std=c99 -mcrt=newlib -o factorial factorial.c
output is:
16! = 20922789888000 <- Correct
*/
int
main(void)
{
double result = 1.0;
int i;
for ( i = 2; i < 17; ++i )
result = result * i;
printf("16! = %.14g\n", result);
return 0;
}

View File

@@ -1,41 +0,0 @@
/*
* $Id: fgets_test.c,v 1.1.1.1 2004-07-26 16:36:07 obarthel Exp $
*
* :ts=4
*/
/****************************************************************************/
#include <string.h>
#include <stdio.h>
/****************************************************************************/
int
main(int argc,char ** argv)
{
char line[256];
size_t len;
FILE * in;
int i;
for(i = 1 ; i < argc ; i++)
{
in = fopen(argv[i],"rb");
if(in != NULL)
{
while(fgets(line,sizeof(line),in) != NULL)
{
len = strlen(line);
while(len > 0 && (line[len-1] == '\n' || line[len-1] == '\r'))
line[--len] = '\0';
printf("%s\n",line);
}
fclose(in);
}
}
return(0);
}

View File

@@ -1,36 +0,0 @@
/*
* $Id: fstat_stdout_test.c,v 1.1 2005-05-08 16:27:25 obarthel Exp $
*
* :ts=4
*/
#include <sys/stat.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
/****************************************************************************/
int
main(int argc,char ** argv)
{
struct stat st;
int fd;
fd = dup(STDOUT_FILENO);
if(fd < 0)
{
perror("dup(STDOUT_FILENO)");
return(EXIT_FAILURE);
}
if(fstat(fd,&st) < 0)
{
perror("fstat(fd,&st)");
return(EXIT_FAILURE);
}
return(EXIT_SUCCESS);
}

View File

@@ -1,39 +0,0 @@
/*
* $Id: fstat_test.c,v 1.1 2006-09-20 19:46:37 obarthel Exp $
*
* :ts=4
*/
#include <sys/stat.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
/****************************************************************************/
int
main(int argc,char ** argv)
{
struct stat st;
int fd;
if(argc <= 1)
return(EXIT_FAILURE);
fd = open(argv[1],O_RDONLY);
if(fd == -1)
{
perror("open");
return(EXIT_FAILURE);
}
if(fstat(fd,&st) == -1)
{
perror("fstat");
return(EXIT_FAILURE);
}
return(EXIT_SUCCESS);
}

View File

@@ -1,44 +0,0 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#define FILE_SIZE 2048
#define WRITE_SIZE 32
char FileData[FILE_SIZE];
void CreateFile(char *filename)
{
FILE *file;
if (file = fopen(filename,"w")) {
memset(FileData,'0',FILE_SIZE);
memset(FileData,'-',WRITE_SIZE);
fwrite(FileData,1,FILE_SIZE,file);
fclose(file);
}
}
void ReadWriteFile(char *filename)
{
FILE *file;
if (file = fopen(filename,"r+")) {
fseek(file,0,SEEK_SET);
fread(FileData,1,FILE_SIZE,file);
fseek(file,0,SEEK_SET);
memset(FileData,'1',WRITE_SIZE);
fwrite(FileData,1,WRITE_SIZE,file);
fclose(file);
}
}
int main(int argc, char **argv)
{
if (argc > 1) {
CreateFile(argv[1]);
ReadWriteFile(argv[1]);
}
return 0;
}

View File

@@ -1,12 +0,0 @@
#include <stdio.h>
int __debug_level = 2;
int main(void)
{
double val = 0.0001;
printf("%g\n", val);
return(0);
}

View File

@@ -1,238 +0,0 @@
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
double x;
void
print_format_int(const char * format_string,int parameter1,int parameter2)
{
printf("\"");
printf(format_string,parameter1);
printf("\"\t");
printf("Value = % d, Format = \"%s\"\n",parameter1,format_string);
printf("\"");
printf(format_string,parameter2);
printf("\"\t");
printf("Value = % d, Format = \"%s\"\n",parameter2,format_string);
}
void
print_format_char(const char * format_string,char parameter)
{
printf("\"");
printf(format_string,parameter);
printf("\"\t");
printf("Value = '%c', Format = \"%s\"\n",parameter,format_string);
}
void
print_format_string(const char * format_string,const char *parameter1,const char *parameter2)
{
printf("\"");
printf(format_string,parameter1);
printf("\"\t");
printf("Value = \"%s\", Format = \"%s\"\n",parameter1,format_string);
printf("\"");
printf(format_string,parameter2);
printf("\"\t");
printf("Value = \"%s\", Format = \"%s\"\n",parameter2,format_string);
}
void
print_format_float(const char * format_string,double parameter1,double parameter2)
{
printf("\"");
printf(format_string,parameter1);
printf("\"\t");
printf("Value = % f, Format = \"%s\"\n",parameter1,format_string);
printf("\"");
printf(format_string,parameter2);
printf("\"\t");
printf("Value = % f, Format = \"%s\"\n",parameter2,format_string);
}
int
main(void)
{
/*
unsigned long foo[2] = { 0x41f00000, 0 };
memcpy(&x,foo,sizeof(x));
printf("%.20g\n",x);
*/
print_format_int("%12d",45,-45);
print_format_int("%012d",45,-45);
print_format_int("% 012d",45,-45);
print_format_int("%+12d",45,-45);
print_format_int("%+012d",45,-45);
print_format_int("%-12d",45,-45);
print_format_int("%- 12d",45,-45);
print_format_int("%-+12d",45,-45);
print_format_int("%12.4d",45,-45);
print_format_int("%-12.4d",45,-45);
print_format_int("%12.0d",45,-45);
printf("\n");
print_format_int("%14u",45,-45);
print_format_int("%014u",45,-45);
print_format_int("%#14u",45,-45);
print_format_int("%#014u",45,-45);
print_format_int("%-14u",45,-45);
print_format_int("%-#14u",45,-45);
print_format_int("%14.4u",45,-45);
print_format_int("%-14.4u",45,-45);
print_format_int("%14.0u",45,-45);
printf("\n");
print_format_int("%14o",45,-45);
print_format_int("%014o",45,-45);
print_format_int("%#14o",45,-45);
print_format_int("%#014o",45,-45);
print_format_int("%-14o",45,-45);
print_format_int("%-#14o",45,-45);
print_format_int("%14.4o",45,-45);
print_format_int("%-14.4o",45,-45);
print_format_int("%14.0o",45,-45);
printf("\n");
print_format_int("%12x",45,-45);
print_format_int("%012x",45,-45);
print_format_int("%#12X",45,-45);
print_format_int("%#012X",45,-45);
print_format_int("%-12x",45,-45);
print_format_int("%-#12x",45,-45);
print_format_int("%12.4x",45,-45);
print_format_int("%-12.4x",45,-45);
print_format_int("%12.0x",45,-45);
printf("\n");
print_format_char("%12c",'*');
print_format_char("%012c",'*');
print_format_char("%-12c",'*');
print_format_char("%12.0c",'*');
printf("\n");
print_format_string("%12s","zap","longish");
print_format_string("%12.5s","zap","longish");
print_format_string("%012s","zap","longish");
print_format_string("%-12s","zap","longish");
print_format_string("%12.0s","zap","longish");
printf("\n");
print_format_float("%10.2f",12.678,-12.678);
print_format_float("%010.2f",12.678,-12.678);
print_format_float("% 010.2f",12.678,-12.678);
print_format_float("%+10.2f",12.678,-12.678);
print_format_float("%+010.2f",12.678,-12.678);
print_format_float("%-10.2f",12.678,-12.678);
print_format_float("%- 10.2f",12.678,-12.678);
print_format_float("%-+10.4f",12.678,-12.678);
print_format_float("%f",12.678,-12.678);
print_format_float("%10f",12.678,-12.678);
print_format_float("%10.0f",12.678,-12.678);
printf("\n");
print_format_float("%10.2e",12.678,-12.678);
print_format_float("%010.2e",12.678,-12.678);
print_format_float("% 010.2e",12.678,-12.678);
print_format_float("%+10.2E",12.678,-12.678);
print_format_float("%+010.2E",12.678,-12.678);
print_format_float("%-10.2e",12.678,-12.678);
print_format_float("%- 10.2e",12.678,-12.678);
print_format_float("%-+10.2e",12.678,-12.678);
print_format_float("%e",12.678,-12.678);
print_format_float("%10e",12.678,-12.678);
print_format_float("%10.0e",12.678,-12.678);
printf("\n");
print_format_float("%10.2a",12.678,-12.678);
print_format_float("%010.2a",12.678,-12.678);
print_format_float("% 010.2a",12.678,-12.678);
print_format_float("%+10.2A",12.678,-12.678);
print_format_float("%+010.2A",12.678,-12.678);
print_format_float("%-10.2a",12.678,-12.678);
print_format_float("%- 10.2a",12.678,-12.678);
print_format_float("%-+10.2a",12.678,-12.678);
print_format_float("%a",12.678,-12.678);
print_format_float("%10a",12.678,-12.678);
print_format_float("%10.0a",12.678,-12.678);
printf("\n");
print_format_float("%10.2g",12.678,-12.678);
print_format_float("%010.2g",12.678,-12.678);
print_format_float("% 010.2g",12.678,-12.678);
print_format_float("%+10.2G",12.678,-12.678);
print_format_float("%+010.2G",12.678,-12.678);
print_format_float("%-10.2g",12.678,-12.678);
print_format_float("%- 10.2g",12.678,-12.678);
print_format_float("%-+10.2g",12.678,-12.678);
print_format_float("%g",12.678,-12.678);
print_format_float("%10g",12.678,-12.678);
print_format_float("%10.0g",12.678,-12.678);
printf("\n");
print_format_float("%10.2g",0.678,-0.678);
print_format_float("%010.2g",0.678,-0.678);
print_format_float("% 010.2g",0.678,-0.678);
print_format_float("%+10.2G",0.678,-0.678);
print_format_float("%+010.2G",0.678,-0.678);
print_format_float("%-10.2g",0.678,-0.678);
print_format_float("%- 10.2g",0.678,-0.678);
print_format_float("%-+10.2g",0.678,-0.678);
print_format_float("%g",0.678,-0.678);
print_format_float("%10g",0.678,-0.678);
print_format_float("%10.0g",0.678,-0.678);
printf("\n");
print_format_float("%10.2g",strtod("infinity",NULL),strtod("-infinity",NULL));
print_format_float("%010.2g",strtod("infinity",NULL),strtod("-infinity",NULL));
print_format_float("% 010.2g",strtod("infinity",NULL),strtod("-infinity",NULL));
print_format_float("%+10.2G",strtod("infinity",NULL),strtod("-infinity",NULL));
print_format_float("%+010.2G",strtod("infinity",NULL),strtod("-infinity",NULL));
print_format_float("%-10.2g",strtod("infinity",NULL),strtod("-infinity",NULL));
print_format_float("%- 10.2g",strtod("infinity",NULL),strtod("-infinity",NULL));
print_format_float("%-+10.2g",strtod("infinity",NULL),strtod("-infinity",NULL));
print_format_float("%g",strtod("infinity",NULL),strtod("-infinity",NULL));
print_format_float("%10g",strtod("infinity",NULL),strtod("-infinity",NULL));
print_format_float("%10.0g",strtod("infinity",NULL),strtod("-infinity",NULL));
printf("\n");
print_format_float("%10.2g",strtod("nan",NULL),strtod("-nan",NULL));
print_format_float("%010.2g",strtod("nan",NULL),strtod("-nan",NULL));
print_format_float("% 010.2g",strtod("nan",NULL),strtod("-nan",NULL));
print_format_float("%+10.2G",strtod("nan",NULL),strtod("-nan",NULL));
print_format_float("%+010.2G",strtod("nan",NULL),strtod("-nan",NULL));
print_format_float("%-10.2g",strtod("nan",NULL),strtod("-nan",NULL));
print_format_float("%- 10.2g",strtod("nan",NULL),strtod("-nan",NULL));
print_format_float("%-+10.2g",strtod("nan",NULL),strtod("-nan",NULL));
print_format_float("%g",strtod("nan",NULL),strtod("-nan",NULL));
print_format_float("%10g",strtod("nan",NULL),strtod("-nan",NULL));
print_format_float("%10.0g",strtod("nan",NULL),strtod("-nan",NULL));
return(0);
}

View File

@@ -1,20 +0,0 @@
#include <stdlib.h>
#include <stdio.h>
int
main(int argc,char **argv)
{
int n = 10,i,x;
if(argc > 1)
n = atoi(argv[1]);
for(i = 0 ; i < n ; i++)
{
x = rand();
printf("0x%08lx %d\n",x,x);
}
return(0);
}

View File

@@ -1,29 +0,0 @@
#include <stdio.h>
#include <locale.h>
/* uncomment to fix corruption
#include <dos.h>
BOOL __open_locale = FALSE;
*/
int
main(void)
{
char *loc;
time_t t;
struct tm *m;
char buf[200];
int len;
loc = setlocale(LC_ALL, "");
printf("loc=%p (%s)\n", loc, loc);
time(&t);
m = gmtime(&t);
len = strftime(buf, sizeof(buf), "%a %b", m);
printf("len=%d buf=%s\n", len, buf);
return 0;
}

View File

@@ -1,13 +0,0 @@
/*
* $Id: simple.c,v 1.1 2005-03-03 15:12:18 obarthel Exp $
*
* :ts=4
*/
/****************************************************************************/
int
main(int argc,char ** argv)
{
return(0);
}

View File

@@ -1,99 +0,0 @@
/*
* $Id: simple_sprintf.c,v 1.2 2005-05-18 07:22:52 obarthel Exp $
*
* :ts=4
*/
#include <exec/execbase.h>
/****************************************************************************/
#define __NOLIBBASE__
#define __USE_INLINE__
#define __NOGLOBALIFACE__
/****************************************************************************/
#include <proto/exec.h>
#include <proto/dos.h>
/****************************************************************************/
#include <string.h>
#include <stdio.h>
#include <dos.h>
/****************************************************************************/
struct Library * SysBase;
struct Library * DOSBase;
/****************************************************************************/
#if defined(__amigaos4__)
struct ExecIFace * IExec;
struct DOSIFace * IDOS;
#endif /* __amigaos4__ */
/****************************************************************************/
BOOL __check_abort_enabled = FALSE;
/****************************************************************************/
int _start(void);
/****************************************************************************/
int
_start(void)
{
char string[80];
SysBase = *(struct Library **)4;
#if defined(__amigaos4__)
{
IExec = (struct ExecIFace *)((struct ExecBase *)SysBase)->MainInterface;
}
#endif /* __amigaos4__ */
DOSBase = OpenLibrary("dos.library",37);
if(DOSBase == NULL)
goto out;
#if defined(__amigaos4__)
{
IDOS = (struct DOSIFace *)GetInterface(DOSBase, "main", 1, 0);
if(IDOS == NULL)
goto out;
}
#endif /* __amigaos4__ */
sprintf(string,"a %s c\n","b");
Write(Output(),string,(LONG)strlen(string));
out:
#if defined(__amigaos4__)
{
if(IDOS != NULL)
DropInterface((struct Interface *)IDOS);
}
#endif /* __amigaos4__ */
if(DOSBase != NULL)
CloseLibrary(DOSBase);
return(0);
}
/****************************************************************************/
void
__check_abort(void)
{
}

View File

@@ -1,172 +0,0 @@
#
# $Id: smakefile,v 1.9 2006-01-02 13:11:39 obarthel Exp $
#
# :ts=8
#
##############################################################################
.c.o:
@echo "Compiling $<"
@sc nover $(CFLAGS) $<
.asm.o:
@echo "Assembling $<"
@asm $(AFLAGS) $<
##############################################################################
# You might want to change this to the directory where your operating system
# header files are stored. On my system, that's "V:include", but you might
# get lucky with "sc:include" instead, which is the default for SAS/C.
INCLUDE_DIR = V:include
#INCLUDE_DIR = sc:include
##############################################################################
# This is where the header files, the startup code and the c.lib files are
# stored; see below how this prefix is used.
LIB = /library/
##############################################################################
OPTIMIZE = optimize opttime optschedule optinline
#DEBUG = debug=line noopt define=CHECK_FOR_NULL_POINTERS
#DEBUG = debug=line
#DEBUG = debug=line define=NDEBUG
DEBUG = debug=sf noopt
#DEBUG = debug=sf noopt define=CHECK_FOR_NULL_POINTERS
#PROFILE = profile
DATA = data=faronly
#CODE = code=far
CPU = cpu=060
MATH = define=IEEE_FLOATING_POINT_SUPPORT math=IEEE
SUPPORT = define=UNIX_PATH_SEMANTICS define=SOCKET_SUPPORT define=USERGROUP_SUPPORT \
define=__C_MACROS__
##############################################################################
CFLAGS = \
resopt \
nover \
memorysize=huge \
idlen=64 \
commentnest \
nostackcheck \
stringmerge \
errorrexx \
$(PROFILE) $(OPTIMIZE) $(CODE) $(DATA) $(CPU) $(MATH) \
$(SUPPORT) $(DEBUG)
AFLAGS = \
-d -m2
##############################################################################
all: \
setup \
test fgets_test iotest sscanf_test printf_test sprintf_test \
stack_size_test translate_test strtok_test uname simple \
fstat_stdout_test simple_sprintf date_test factorial \
cleanup
clean:
-delete \#?.o \#?.map \
test fgets_test iotest sscanf_test printf_test sprintf_test \
stack_size_test translate_test strtok_test uname simple \
simple_sprintf date_test factorial
##############################################################################
setup:
@echo "Setting up include: assignment"
@assign include: $(LIB)include V:include
cleanup:
@echo "Cleaning up include: assignment"
@assign include: sc:include
##############################################################################
test: test.o
@echo "Linking $@"
@slink $(LIB)startup.o test.o to $@ lib $(LIB)c.lib addsym \
map $@.map,fhx fwidth 32 pwidth 32 swidth 32
date_test: date_test.o
@echo "Linking $@"
@slink $(LIB)startup.o date_test.o to $@ lib $(LIB)c.lib addsym \
map $@.map,fhx fwidth 32 pwidth 32 swidth 32
fgets_test: fgets_test.o
@echo "Linking $@"
@slink $(LIB)startup.o fgets_test.o to $@ lib $(LIB)c.lib addsym \
map $@.map,fhx fwidth 32 pwidth 32 swidth 32
strtok_test: strtok_test.o
@echo "Linking $@"
@slink $(LIB)startup.o strtok_test.o to $@ lib $(LIB)c.lib addsym \
map $@.map,fhx fwidth 32 pwidth 32 swidth 32
iotest: iotest.o
@echo "Linking $@"
@slink $(LIB)startup.o iotest.o to $@ lib $(LIB)c.lib addsym \
map $@.map,fhx fwidth 32 pwidth 32 swidth 32
sscanf_test: sscanf_test.o
@echo "Linking $@"
@slink $(LIB)startup.o sscanf_test.o to $@ lib $(LIB)c.lib addsym \
map $@.map,fhx fwidth 32 pwidth 32 swidth 32
printf_test: printf_test.o
@echo "Linking $@"
@slink $(LIB)startup.o printf_test.o to $@ lib $(LIB)c.lib addsym \
map $@.map,fhx fwidth 32 pwidth 32 swidth 32
sprintf_test: sprintf_test.o
@echo "Linking $@"
@slink $(LIB)startup.o sprintf_test.o to $@ lib $(LIB)c.lib addsym \
map $@.map,fhx fwidth 32 pwidth 32 swidth 32
stack_size_test: stack_size_test.o
@echo "Linking $@"
@slink $(LIB)startup.o stack_size_test.o to $@ lib $(LIB)c.lib addsym \
map $@.map,fhx fwidth 32 pwidth 32 swidth 32
translate_test: translate_test.o
@echo "Linking $@"
@slink $(LIB)startup.o translate_test.o to $@ lib $(LIB)c.lib addsym \
map $@.map,fhx fwidth 32 pwidth 32 swidth 32
uname: uname.o
@echo "Linking $@"
@slink $(LIB)startup.o uname.o to $@ lib $(LIB)c.lib addsym \
map $@.map,fhx fwidth 32 pwidth 32 swidth 32
simple: simple.o
@echo "Linking $@"
@slink $(LIB)startup.o simple.o to $@ lib $(LIB)c.lib addsym \
map $@.map,fhx fwidth 32 pwidth 32 swidth 32
fstat_stdout_test: fstat_stdout_test.o
@echo "Linking $@"
@slink $(LIB)startup.o fstat_stdout_test.o to $@ lib $(LIB)c.lib addsym \
map $@.map,fhx fwidth 32 pwidth 32 swidth 32
simple_sprintf: simple_sprintf.o
@echo "Linking $@"
@slink simple_sprintf.o to $@ lib $(LIB)c.lib addsym \
map $@.map,fhx fwidth 32 pwidth 32 swidth 32
factorial: factorial.o
@echo "Linking $@"
@slink $(LIB)startup.o factorial.o to $@ lib $(LIB)c.lib addsym \
map $@.map,fhx fwidth 32 pwidth 32 swidth 32
##############################################################################
mkid:
mkid \#?.(c|h|asm|i) include/\#?.(c|h|asm|i) include/sys/\#?.(c|h|asm|i)
update:
mkid -v -u

View File

@@ -1,25 +0,0 @@
#include <string.h>
#include <stdio.h>
static char buf[256];
void addsomething(void)
{
char *p = &buf[strlen(buf)];
sprintf(p, "yeah");
}
int main(void)
{
buf[0] = '\0';
addsomething();
printf("1: [%s]\n", buf);
sprintf(buf, "");
addsomething();
printf("2: [%s]\n", buf);
return (0);
}

View File

@@ -1,22 +0,0 @@
#include <stdio.h>
/*extern int __debug_level;*/
int
main (int argc, char **argv)
{
long long int l;
char * arg;
/*__debug_level = 2;*/
if(argc > 1)
arg = argv[1];
else
arg = "123456789012";
sscanf (arg, "%lld", &l);
printf ("number = %lld = 0x%llX\n", l, l);
return(0);
}

View File

@@ -1,135 +0,0 @@
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
int
main(void)
{
int first, second, third, num;
int n,a,b,c;
char str[4];
double f;
a = 0;
n = sscanf("060206","%x",&a);
printf("%s:%d:",__FILE__,__LINE__);printf("n = %d, a = %d\n",n,a);
num = sscanf("day-month-year", "%d-%d-%d", &first, &second, &third);
printf("%s:%d:",__FILE__,__LINE__);printf("%d %d %d %d\n", num, first, second, third);
num = sscanf("8-11-2004", "%d-%d-%d", &first, &second, &third);
printf("%s:%d:",__FILE__,__LINE__);printf("%d %d %d %d\n", num, first, second, third);
num = sscanf("", "%d-%d-%d", &first, &second, &third);
printf("%s:%d:",__FILE__,__LINE__);printf("%d %d %d %d\n", num, first, second, third);
num = sscanf("6", "%d %d", &first, &second);
printf("%s:%d:",__FILE__,__LINE__);printf("%d %d\n", num, first);
a = b = c = 0;
n = sscanf("","%*d,%d,%d",&a,&b,&c);
printf("%s:%d:",__FILE__,__LINE__);printf("n = %d, a = %d, b = %d, c = %d\n",n,a,b,c);
a = b = c = 0;
n = sscanf("1,2,3","%*d,%d,%d",&a,&b,&c);
printf("%s:%d:",__FILE__,__LINE__);printf("n = %d, a = %d, b = %d, c = %d\n",n,a,b,c);
a = b = c = 0;
n = sscanf("1,2","%*d,%d,%d",&a,&b,&c);
printf("%s:%d:",__FILE__,__LINE__);printf("n = %d, a = %d, b = %d, c = %d\n",n,a,b,c);
a = b = c = 0;
n = sscanf("asdf","*d,d,d",&a,&b,&c);
printf("%s:%d:",__FILE__,__LINE__);printf("n = %d, a = %d, b = %d, c = %d\n",n,a,b,c);
memset(str,0,sizeof(str));
n = sscanf("asdf","%[abc]",str);
printf("%s:%d:",__FILE__,__LINE__);printf("n = %d, str = '%s'\n",n,str);
memset(str,0,sizeof(str));
n = sscanf("asdbbfc","%[abc]",str);
printf("%s:%d:",__FILE__,__LINE__);printf("n = %d, str = '%s'\n",n,str);
memset(str,0,sizeof(str));
n = sscanf("","%[abc]",str);
printf("%s:%d:",__FILE__,__LINE__);printf("n = %d, str = '%s'\n",n,str);
memset(str,0,sizeof(str));
n = sscanf("abcdef","%[abc]",str);
printf("%s:%d:",__FILE__,__LINE__);printf("n = %d, str = '%s'\n",n,str);
a = b = c = 0;
n = sscanf("-","%d",&a);
printf("%s:%d:",__FILE__,__LINE__);printf("n = %d, a = %d\n",n,a);
a = b = c = 0;
n = sscanf("-4,-","%d,%d",&a,&b);
printf("%s:%d:",__FILE__,__LINE__);printf("n = %d, a = %d, b = %d\n",n,a,b);
memset(str,0,sizeof(str));
n = sscanf("1 abc","%d %4c",&a,str);
printf("%s:%d:",__FILE__,__LINE__);printf("n = %d, a = %d, str = '%s'\n",n,a,str);
memset(str,0,sizeof(str));
n = sscanf("abc","%4c",&a,str);
printf("%s:%d:",__FILE__,__LINE__);printf("n = %d, str = '%s'\n",n,str);
a = 0;
n = sscanf("17","%i",&a);
printf("%s:%d:",__FILE__,__LINE__);printf("n = %d, a = %d\n",n,a);
a = 0;
n = sscanf("017","%i",&a);
printf("%s:%d:",__FILE__,__LINE__);printf("n = %d, a = %d\n",n,a);
a = 0;
n = sscanf("0x17","%i",&a);
printf("%s:%d:",__FILE__,__LINE__);printf("n = %d, a = %d\n",n,a);
a = 0;
n = sscanf("0x017","%i",&a);
printf("%s:%d:",__FILE__,__LINE__);printf("n = %d, a = %d\n",n,a);
a = 0;
n = sscanf("0x017","%x",&a);
printf("%s:%d:",__FILE__,__LINE__);printf("n = %d, a = %d\n",n,a);
a = 0;
n = sscanf("0017","%x",&a);
printf("%s:%d:",__FILE__,__LINE__);printf("n = %d, a = %d\n",n,a);
a = 0;
n = sscanf("0x80000000","%i",&a);
printf("%s:%d:",__FILE__,__LINE__);printf("n = %d, a = %u\n",n,a);
memset(str,0,sizeof(str));
n = sscanf("1,e","%*d,%[abc]",str);
printf("%s:%d:",__FILE__,__LINE__);printf("n = %d, str = '%s'\n",n,str);
n = sscanf("1","%lf",&f);
printf("%s:%d:",__FILE__,__LINE__);printf("n = %d, f = '%f' (%f)\n",n,f,atof("1"));
n = sscanf("1234.567","%lf",&f);
printf("%s:%d:",__FILE__,__LINE__);printf("n = %d, f = '%f' (%f)\n",n,f,atof("1234.567"));
n = sscanf("inf","%lf",&f);
printf("%s:%d:",__FILE__,__LINE__);printf("n = %d, f = '%f' (%f)\n",n,f,atof("inf"));
n = sscanf("infinity","%lf",&f);
printf("%s:%d:",__FILE__,__LINE__);printf("n = %d, f = '%f' (%f)\n",n,f,atof("infinity"));
n = sscanf("nan","%lf",&f);
printf("%s:%d:",__FILE__,__LINE__);printf("n = %d, f = '%f' (%f)\n",n,f,atof("nan"));
n = sscanf("nan(23)","%lf",&f);
printf("%s:%d:",__FILE__,__LINE__);printf("n = %d, f = '%f' (%f)\n",n,f,atof("nan(23)"));
n = sscanf("0xabc.defp+101","%lf",&f);
printf("%s:%d:",__FILE__,__LINE__);printf("n = %d, f = '%f' (%f)\n",n,f,atof("0xabc.defp+101"));
return(0);
}

View File

@@ -1,31 +0,0 @@
/* gcc -mstackextend -o stack_extension_test stack_extension_test.c */
#include <stdio.h>
#include <ctype.h>
void
recursive_function(char *data,int data_size,int level)
{
char local_data[10000];
char line[10];
int c;
data_size += sizeof(local_data);
level++;
printf("recursion level=%d, size=%d; continue? ",level,data_size);
fgets(line,sizeof(line),stdin);
c = toupper(line[0]);
if(c == 'Y')
recursive_function(local_data,data_size,level);
}
int
main(int argc,char ** argv)
{
recursive_function(NULL,0,0);
return(0);
}

View File

@@ -1,15 +0,0 @@
#include <stdio.h>
int __stack_size = 60000;
int
main(void)
{
int first, second, num;
num = sscanf("6", "%d %d", &first, &second);
printf("%d %d\n", num, first);
return(0);
}

View File

@@ -1,35 +0,0 @@
/*
* $Id: strtok_test.c,v 1.1 2004-10-25 19:50:33 obarthel Exp $
*
* :ts=4
*/
/****************************************************************************/
#include <string.h>
#include <stdio.h>
/****************************************************************************/
int
main(int argc,char ** argv)
{
char test[256];
char * one;
char * two;
char * three;
strcpy(test," one two three");
strtok(test," ");
one = strtok(NULL," ");
two = strtok(NULL," ");
three = strtok(NULL," ");
printf("one = %p '%s'\n",one,one);
printf("two = %p '%s'\n",two,two);
printf("three = %p '%s'\n",three,three);
return(0);
}

View File

@@ -1,282 +0,0 @@
/*
* $Id: test.c,v 1.6 2005-08-26 12:21:51 obarthel Exp $
*
* :ts=4
*/
/****************************************************************************/
#define __USE_INLINE__
#include <proto/exec.h>
#include <time.h>
#include <stdio.h>
#include <unistd.h>
#include <dirent.h>
#include <stdlib.h>
#include <math.h>
#include <sys/stat.h>
/****************************************************************************/
/*int __stack_size = 20000;*/
/****************************************************************************/
#if defined(__GNUC__)
void __attribute__ ((constructor))
constructor_test1(void)
{
fprintf(stderr,"constructor #1 called\n");
}
void __attribute__ ((constructor))
constructor_test2(void)
{
fprintf(stderr,"constructor #2 called\n");
}
void __attribute__ ((destructor))
destructor_test1(void)
{
fprintf(stderr,"destructor #1 called\n");
}
void __attribute__ ((destructor))
destructor_test2(void)
{
fprintf(stderr,"destructor #2 called\n");
}
void __attribute__ ((destructor))
destructor_test3(void)
{
/*DebugPrintF("__iob = 0x%08lx\n",__iob);*/
fprintf(stderr,"destructor #3 called\n");
}
#endif /* __GNUC__ */
/****************************************************************************/
int foo = 3;
int bar = 9;
/****************************************************************************/
#if 1
int
main(int argc,char ** argv)
{
struct timeval tv;
time_t now;
struct tm tm;
int i,j,k;
long n,r;
char time_buffer[100];
for(i = 0 ; i < argc ; i++)
printf("%2d) \"%s\"\n",i,argv[i]);
printf("div %d mod %d\n",foo / 2,bar % 4);
time(&now);
printf("%s",ctime(&now));
tm = (*localtime(&now));
strftime(time_buffer,sizeof(time_buffer),"%c",&tm);
printf("local time = %s\n",time_buffer);
tm = (*gmtime(&now));
strftime(time_buffer,sizeof(time_buffer),"%c",&tm);
printf("gmt = %s\n",time_buffer);
tm = (*gmtime(&now));
strftime(time_buffer,sizeof(time_buffer),"%c %U %W %j",&tm);
printf("%s\n",time_buffer);
tm.tm_year = 105;
tm.tm_mon = 0;
tm.tm_mday = 25;
tm.tm_hour = 12;
tm.tm_min = 3;
tm.tm_sec = 53;
tm.tm_isdst = -1;
now = mktime(&tm);
tm = (*localtime(&now));
strftime(time_buffer,sizeof(time_buffer),"%c",&tm);
printf("2005-01-25 12:03:53 -> local time = %s\n",time_buffer);
tm = (*gmtime(&now));
strftime(time_buffer,sizeof(time_buffer),"%c",&tm);
printf("2005-01-25 12:03:53 -> gmt = %s\n",time_buffer);
#if defined(IEEE_FLOATING_POINT_SUPPORT) || defined(M68881_FLOATING_POINT_SUPPORT)
{
const double pi = 3.14159265358979323846;
const double ten = 10.0;
const double quarter = 0.25;
const double thousand = 1000.0;
const double foo = 4 * atan((double)1);
float f1;
double d1;
printf("pi=%3.1f (float)\n",pi);
printf("pi=%.21e (exponential)\n",pi);
printf("pi=%g (float/exponential)\n",pi);
printf("ten=%f (float)\n",ten);
printf("ten=%.21e (exponential)\n",ten);
printf("ten=%g (float/exponential)\n",ten);
printf("thousand=%f (float)\n",thousand);
printf("thousand=%.21e (exponential)\n",thousand);
printf("thousand=%g (float/exponential)\n",thousand);
printf("quarter=%f (float)\n",quarter);
printf("quarter=%.21e (exponential)\n",quarter);
printf("quarter=%g (float/exponential)\n",quarter);
printf("foo=%f (float)\n",foo);
printf("foo=%.21e (exponential)\n",foo);
printf("foo=%g (float/exponential)\n",foo);
printf("32 bit float = %f\n",4294967295.0);
printf("32+1 bit float = %f\n",-4294967295.0);
printf("big float on the edge = %f\n",4294967296.0);
printf("big float = %f\n",429496729654321.0);
printf("small float = %f\n",-429496729654321.0);
f1 = d1 = 9;
r = sscanf("13.24 1.324","%f %lf",&f1,&d1);
printf("r = %ld, f1 = %f, d1 = %f\n",r,f1,d1);
}
#endif
#ifndef NDEBUG
{
char * allocation;
allocation = malloc(4);
if(allocation != NULL)
{
strcpy(allocation,"....FOO");
strcpy(allocation-3,"bar");
}
}
#endif /* NDEBUG */
printf("hex 0x%08x\n",1);
printf("hex 0x%08x\n",1);
printf("hex 0x%08x\n",2);
printf("big int %d\n",0x80000000L);
printf("converted big int %d\n",atoi("-2147483648"));
r = sscanf("1324","%lx",&n);
printf("r = %ld, n = %ld\n",r,n);
r = sscanf("1234567890","%4d%3d%3d",&i,&j,&k);
printf("r = %ld, i = %d, j = %d, k = %d\n",r,i,j,k);
/*#if defined(IEEE_FLOATING_POINT_SUPPORT) || defined(M68881_FLOATING_POINT_SUPPORT)
{
const char *arg = "100x100";
float xres = 0, yres = 0;
printf("%d: ", sscanf(arg, "%fx%f", &xres, &yres));
printf("%.02fx%.02f\n", xres, yres);
}
#endif*/
gettimeofday(&tv,0);
printf("time = %d.%06d\n",tv.tv_sec,tv.tv_usec);
if(argc > 1)
{
DIR * dir;
dir = opendir(argv[1]);
if(dir != NULL)
{
struct dirent *d;
struct stat st;
chdir(argv[1]);
while((d = readdir(dir)) != NULL)
{
if(stat(d->d_name,&st) == 0)
printf("%s%s\n",d->d_name,S_ISDIR(st.st_mode) ? " (dir)" : "");
}
closedir(dir);
}
}
return(0);
}
#endif
/****************************************************************************/
#if 0
#define LINEBUFLENGTH 180
#define STRIP_LF(str) (str[strlen(str)-1]=0)
void invert_str(char * in)
{
char t;
while(t=*in)
{
*in++=~t;
}
}
int main(int i, char *c[])
{
char dest_fname[80], in_linebuffer[LINEBUFLENGTH];
FILE * fileout, * filein;
if(i>1)
{
sprintf(dest_fname, "%s.c", c[1]);
fileout=fopen(dest_fname, "w");
filein =fopen(c[1], "r");
if(fileout && filein)
{
fgets(in_linebuffer, LINEBUFLENGTH, filein);
STRIP_LF(in_linebuffer);
invert_str(in_linebuffer);
fputs("char *s_leading=\"", fileout);
fputs(in_linebuffer, fileout);
fputs("\";\n", fileout);
fputs("char *s_messages[]={\n", fileout);
while(fgets(in_linebuffer, LINEBUFLENGTH, filein))
{
STRIP_LF(in_linebuffer);
invert_str(in_linebuffer);
fputs("\"", fileout);
fputs(in_linebuffer, fileout);
fputs("\",\n", fileout);
}
fputs("};\n", fileout);
fputs("unsigned s_mess_num = sizeof(s_messages)/sizeof(char *);\n", fileout);
fclose(filein);
fclose(fileout);
}
}
return 0;
}
#endif

View File

@@ -1,39 +0,0 @@
/*
* $Id: translate_test.c,v 1.1.1.1 2004-07-26 16:36:08 obarthel Exp $
*
* :ts=4
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <dos.h>
extern char __current_path_name[];
int
main(int argc,char ** argv)
{
struct name_translation_info nti;
char * name;
int error;
int i;
/*strcpy(__current_path_name,"/absolute_path_name/whatever");*/
for(i = 1 ; i < argc ; i++)
{
name = argv[i];
printf("'%s' -> ",name);
error = __translate_unix_to_amiga_path_name(&name,&nti);
/*error = __translate_amiga_to_unix_path_name(&name,&nti);*/
if(error == 0)
printf("'%s'\n",name);
else
printf("%s\n",strerror(error));
}
return(0);
}

View File

@@ -1,56 +0,0 @@
/*
* $Id: uname.c,v 1.2 2005-03-03 15:12:18 obarthel Exp $
*
* :ts=4
*/
/****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/utsname.h>
int main(int cnt,char *arg[])
{
struct utsname uinfo;
int Ret=EXIT_SUCCESS;
if(cnt>1 && (!strcmp(arg[1],"-h") || !strcmp(arg[1],"--help"))) {
printf(
" -a\tPrint all information.\n"
" -m\tPrint the machine type.\n"
" -n\tPrint the node (host) name.\n"
" -r\tPrint the OS release.\n"
" -s\tPrint the OS name.\n"
" -v\tPrint the OS version.\n\n"
" -h or --help displays this message.\n\n"
);
} else {
if(!uname(&uinfo)) {
if(cnt<2 || !strcmp(arg[1],"-s")) {
printf("%s\n",uinfo.sysname);
} else if(!strcmp(arg[1],"-a")) {
printf("%s %s %s %s %s\n",uinfo.sysname,uinfo.version,uinfo.release,uinfo.nodename,uinfo.machine);
} else if(!strcmp(arg[1],"-m")) {
printf("%s\n",uinfo.machine);
} else if(!strcmp(arg[1],"-n")) {
printf("%s\n",uinfo.nodename);
} else if(!strcmp(arg[1],"-r")) {
printf("%s\n",uinfo.release);
} else if(!strcmp(arg[1],"-v")) {
printf("%s\n",uinfo.version);
} else {
printf("Unknown option \"%s\"!\nTry -h or --help.\n",arg[1]);
Ret=EXIT_FAILURE;
}
} else {
printf("Unknown error!\n");
}
}
return(Ret);
}
/* vi:set ts=3: */