OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /openrisc/trunk/rtos/ecos-2.0/packages/language/c/libc/stdio
    from Rev 27 to Rev 174
    Reverse comparison

Rev 27 → Rev 174

/v2_0/ChangeLog.libc
0,0 → 1,2736
This ChangeLog file is now obsolete. This is the original ChangeLog from when
libc was one large package, before being separated. It is included for
historical reasons.
 
2000-04-05 Jesper Skov <jskov@redhat.com>
 
* src/time/settime.cxx:
* src/time/time.cxx:
Wallclock moved to io/.
2000-03-28 John Dallaway <jld@cygnus.co.uk>
 
* cdl/string.cdl,
cdl/stdlib.cdl,
cdl/stdio.cdl,
cdl/libc.cdl:
 
Adjust documentation URLs.
 
2000-03-27 Jesper Skov <jskov@redhat.com>
 
* src/clibincl/stream.inl (check_this): Use cyb_bool instead of bool.
 
2000-03-06 Jesper Skov <jskov@redhat.com>
 
* tests/time/strftime.c (test): Adjust test to match below change.
 
2000-03-02 Jonathan Larmour <jlarmour@redhat.co.uk>
 
* src/time/strftime.cxx (do_format): Make sure %m counts from
1..12 rather than 0..11. Fix for case 103300
 
2000-02-29 Jonathan Larmour <jlarmour@redhat.co.uk>
 
* src/stdio/output/vfnprintf.cxx: Correctly use 'n' parameter to
restrict length. Credit due to Andrew Lunn here as well.
Resolves 103057-CR-1
 
* tests/stdio/sprintf2.c (test):
Add snprintf tests to verify the correct behaviour of restricting
output length
 
2000-02-10 Jesper Skov <jskov@redhat.com>
 
* tests/signal/signal2.c (main):
Also reclaim DATA_TLB_MISS vector if available.
 
2000-01-31 Simon FitzMaurice <sdf@cygnus.co.uk>
* cdl/*.cdl:
 
Adjust help URLs in line with new doc layout.
2000-01-28 Simon FitzMaurice <sdf@cygnus.co.uk>
* cdl/*.cdl:
 
Adjust help URLs in line with new doc layout.
2000-01-19 Hugo Tyson <hmt@cygnus.co.uk>
 
* cdl/*.cdl: Add descriptions to a number of options &c which were
lacking same, also tidied up other typos as noticed en passant.
 
1999-11-11 Bart Veer <bartv@cygnus.co.uk>
 
* cdl/string.cdl:
Switch to a single boolean configuration option for code size vs.
speed optimization.
 
1999-11-03 John Dallaway <jld@cygnus.co.uk>
 
* cdl/libc.cdl: Define tests.
 
1999-10-19 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/stdio/output/vfnprintf.cxx: We can now remove Berkeley
advertising clause
* src/stdlib/div.cxx: ditto
* src/stdlib/ldiv.cxx: ditto
* src/stdlib/strtol.cxx: ditto
* src/stdlib/strtoul.cxx: ditto
* src/string/strtok.cxx: ditto
 
1999-10-19 John Dallaway <jld@cygnus.co.uk>
 
* cdl/libc.cdl:
 
Define CDL options for package-specific CFLAGS.
 
1999-10-08 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/pkgconf/libc.h (CYGNUM_LIBC_MAIN_THREAD_PRIORITY): Change
default to 10 to keep test farm happy
* cdl/startup.cdl: Likewise
 
1999-10-07 John Dallaway <jld@cygnus.co.uk>
 
* cdl/stdlib.cdl, cdl/string.cdl:
 
Specify radio buttons using CDL interfaces.
 
1999-10-06 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* cdl/stdio.cdl: Change default to /dev/ttydiag as per 1999-10-01
change below
* cdl/startup.cdl: Add new form CDL for the startup changes as
per 1999-10-05
 
1999-10-05 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/libc.h: Add CYGSEM_LIBC_MAIN_STACK_FROM_SYSTEM to allow
the user to supply their own stack.
Rename CYGNUM_LIBC_MAIN_STACK_SIZE to
CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE and reparent under
CYGSEM_LIBC_MAIN_STACK_FROM_SYSTEM
Add CYGNUM_LIBC_MAIN_THREAD_PRIORITY to provide main() thread
priority
* src/support/mainthread.cxx: Add support for user-supplied stack
Allow user to specify thread priority
 
These changes fix CR 101069
 
1999-10-01 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/pkgconf/libc.h (CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE): Change
default to /dev/ttydiag to get correct console-like behaviour
Also don't preclude use if haldiag package isn't included
(case 102065)
 
1999-09-15 Jesper Skov <jskov@cygnus.co.uk>
 
* tests/signal/signal2.c (cause_fpe): Try both float and integer
division by zero.
 
1999-09-10 Jesper Skov <jskov@cygnus.co.uk>
 
* src/stdlib/malloc.cxx (cyg_libc_get_malloc_pool): Added for
stress_threads test.
 
1999-09-07 Jesper Skov <jskov@cygnus.co.uk>
PRs 20243, 20433
* tests/signal/signal2.c: Disabled test3 on ARM.
 
1999-09-02 Hugo Tyson <hmt@cygnus.co.uk>
 
* include/assert.h: Make the sense of NDEBUG correct; it is "set"
when NOT debugging. Fix for CR 101983-CR-1
See Stroustrup, "The C++ Programming Language."
 
1999-08-18 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/stdio/common/fopen.cxx (_fopen): Set buffer size 0 when not
buffering
Fix for case 101868
 
1999-08-17 John Dallaway <jld@cygnus.co.uk>
 
* cdl/stdlib.cdl, cdl/string.cdl:
 
Implement radio buttons using "FIXME radio" hack in
description field for now.
 
1999-08-12 John Dallaway <jld@cygnus.co.uk>
 
* cdl/stdlib.cdl:
Take advantage of MACRONAME_ENUMVAL macros output by CDL.
 
1999-08-06 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* tests/stdio/sprintf2.c (test): Don't rely on 2.345 being exactly
representable in binary as a difference of 1 ulp will make it round
the wrong way.
 
1999-07-16 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/stdio/input/fgetc.cxx:
Include outline versions of getc() (actually just a symbol alias for
fgetc() ) and getchar()
Some minor clean-ups
Add tracing/assertions
 
* src/stdio/input/fputc.cxx:
Likewise (except applied to putc() and putchar())
 
* src/stdio/common/stdioinlines.cxx (_puts):
Call fputc() not _fputc()
 
* src/clibincl/stdiosupp.hxx:
Remove now obsolete prototypes for _fgetc() and _fputc()
 
* include/stdio.h:
Don't bother with getc()/putc() macros any more, just call
them as functions
Include protos for getc(), putc(), getchar() and putchar() functions
 
1999-06-21 Jesper Skov <jskov@cygnus.co.uk>
 
* tests/signal/signal2.c: Disabled test 3 for SH EDK7708.
 
1999-06-11 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/stdio.h: Make FILEs array types so they won't be
given $gp relocations on MIPS targets
 
1999-05-27 Jesper Skov <jskov@cygnus.co.uk>
 
* tests/time/ctime.c: Fixed compiler warning.
 
1999-05-25 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* tests/signal/signal2.c (main):
Update CYGPKG_HAL_TX39 -> CYGPKG_HAL_MIPS_TX39 due to recent MIPS
HAL changes
Fix for PR 20116
 
1999-04-30 Jesper Skov <jskov@lassi.cygnus.co.uk>
PR 19945/19946 workaround
* tests/signal/signal2.c: Disabled test 3 for PowerPC sim.
 
1999-04-19 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/time.inl:
Ensure all calls to cyg_libc_time_year_is_leap() are with the full
year, and not the direct contents of a struct tm, which are (year-1900)
 
1999-04-19 Jesper Skov <jskov@cygnus.co.uk>
PR 19308, 19410, 19528
* tests/time/clock.c (test): Also disable data cache which may
affect timing when tracing/assertions are enabled.
 
1999-04-15 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/clibincl/stdiosupp.hxx:
Add prototype for new cyg_libc_stdio_flush_all_but() function
 
* src/clibincl/stream.hxx:
Don't include stdiosupp.hxx any more to prevent circular dependency,
therefore manually provide _setvbuf prototype
Make sure pkgconf/kernel.h is included before mutex.hxx
 
* src/clibincl/stream.inl (Cyg_StdioStream::set_error()):
Add missing unlock_me()
 
* src/stdio/common/fflush.cxx:
Separate most of code for fflush(NULL) into separate
cyg_libc_stdio_flush_all_but() function, which has the extra
capability of omitting one stream
 
* src/stdio/common/stderr.cxx:
* src/stdio/common/stdin.cxx:
* src/stdio/common/stdout.cxx:
* src/stdio/common/vsnprintf.cxx:
* src/stdio/common/vsscanf.cxx:
Add missing clibincl/stdiosupp.hxx include
 
* src/stdio/common/stream.cxx (Cyg_StdioStream::read()):
When reading, ensure we flush all output streams
 
* src/stdio/common/stream.cxx (Cyg_StdioStream::flush_output_unlocked):
Flush the device as well
 
1999-04-15 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/stdio/common/streambuf.cxx (set_buffer):
* src/stdio/common/stdioinlines.cxx (_setbuf):
* src/clibincl/streambuf.inl:
* src/clibincl/streambuf.hxx:
* src/clibincl/stream.hxx (class Cyg_StdioStream):
* include/pkgconf/libc.h:
* include/stdio.inl (setbuf):
Fix dumb typo: BUFSIZE -> BUFSIZ
This fixes PR19837
 
1999-04-15 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/stdio/common/stdioinlines.cxx (_setbuf):
* include/stdio.inl (setbuf):
Use _IONBF when buf==NULL, and _IOLBF otherwise.
Fix for PR 19836
 
1999-04-15 John Dallaway <jld@cygnus.co.uk>
 
* include/pkgconf/libc.h: Tidy display string capitalization.
 
1999-04-12 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/pkgconf/libc.h:
Clarify CDL description of CYGNUM_LIBC_MALLOC_MEMPOOL_SIZE
 
* tests/signal/signal2.c: Try harder to generate an exception by
accessing a misaligned address
Don't handle SIGTRAP any more
Part of fix for PRs 19731/19607
 
1999-04-07 Jesper Skov <jskov@cygnus.co.uk>
PR 19667
* src/support/mainthread.cxx:
Changed to use the new Cyg_Thread constructor.
 
1999-04-07 Hugo Tyson <hmt@cygnus.co.uk>
 
* tests/signal/signal2.c (main): Use new macro
HAL_VSR_SET_TO_ECOS_HANDLER if defined, to wrest control from
CygMon, for example, by reinstalling eCos' default VSRs for
exceptions that we are provoking.
 
1999-03-29 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/signal/siginit.cxx: Include stdlib.h for exit()
Fix for PR 19720
 
1999-03-29 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* tests/time/clock.c (test): Disable instruction cache
Hopefully fixes PR 19308
 
1999-03-29 Jesper Skov <jskov@cygnus.co.uk>
 
* tests/signal/signal2.c: Disabled test 3 for PPC as it cannot
trap division by zero.
 
1999-03-26 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/support/main.cxx (main): Invoke cyg_user_start() if no kernel
Only sensible thing to do in our default main in a non-kernel config
 
1999-03-25 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* tests/time/time.c:
Increase MAX_TIMEOUT since the sparclite gets very close to overrunning
it even when working.
Should return -1 iff CYGSEM_LIBC_TIME_TIME_WORKING isn't defined
Cosmetic changes
 
1999-03-25 Hugo Tyson <hmt@cygnus.co.uk>
 
* tests/time/time.c (test): Take into account setting of
CYGSEM_LIBC_TIME_SETTIME_WORKING ie. does cyg_libc_time_settime()
work? If not, check that it returns an error.
This was exposed by the random combo in PR#19479.
 
1999-03-23 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/pkgconf/libc.h:
Rename CYGSEM_LIBC_RAND_SIMPLEST and CYGSEM_LIBC_RAND_KNUTH1 to
CYGIMP_...
 
Add another rand implementation CYGIMP_LIBC_RAND_SIMPLE1 which is
the default
 
Part of fix for PR 19562
 
* include/sys/cstartup.h:
Tidy and remove unnecessary dependencies
 
* src/stdlib/rand.cxx:
Rename algorithms from CYGSEM_... to CYGIMP_...
Add new "simple1" algorithm
 
* tests/ctype/ctype.c:
Tidy
 
* tests/stdlib/rand3.c:
Fix so that 0..RAND_MAX is split evenly over buckets, which it wasn't
before
Deal with case of RAND_MAX not being divisible by NUM_BUCKETS
exactly
Increase TEST_LENGTH to 200000 to provide more representative sample
Add CYG_TEST_INFO output to help ensure it doesn't time out
Tidy
 
* tests/stdlib/rand4.c:
Only fail if more than _two_ thirds (rather than one third) match.
This is because half would match for a perfectly random distribution
This is the rest of the fix for PR 19562
Cosmetic changes
 
1999-03-22 Hugo Tyson <hmt@cygnus.co.uk>
 
* src/support/mainthread.cxx (CYGNUM_LIBC_MAIN_STACK_SIZE):
Use CYGNUM_HAL_STACK_SIZE_TYPICAL for the stack size instead of
CYGNUM_HAL_MINIMUM_STACK_SIZE.
 
1999-03-22 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* tests/PKGconf.mak: Add -Wno-format when building strftime otherwise
it generates warnings for things that we do want to test (null
string, and %y format)
 
1999-03-19 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/pkgconf/libc.h (CYGNUM_LIBC_TIME_DST_DEFAULT_STATE):
Put brackets back round negative number since sdf says the config
tool is fixed now (PR 19537)
 
Add new CYGSEM_LIBC_RAND_SIMPLEST and CYGSEM_LIBC_RAND_KNUTH1
options for different rand() algorithms in a so far failed attempt
to fix PR 19562
 
* src/stdlib/rand.cxx:
Add new optional algorithm from Knuth vol.2
 
* tests/stdlib/rand4.c:
Some tidies
Don't run test when using simplest algorithm
 
* tests/signal/signal2.c (main):
Don't try to make an FPE on tx39 - its possible to detect but requires
too much HAL work to be sensible
 
1999-03-18 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/signal/siginit.cxx (cyg_libc_signals_hwexcept_handler):
Use HAL_ENABLE_INTERRUPTS() rather than kernel to enable interrupts
 
1999-03-18 Mark Galassi <rosalia@cygnus.com>
 
* tests/PKGconf.mak (TESTS): added rand4 compilation.
 
* tests/stdlib/rand4.c: added this test for periodicity in the
least significant bit of rand().
 
1999-03-18 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/pkgconf/libc.h: Remove CYGFUN_LIBC_TIME_POSIX dependency
on CYGPKG_LIBC_STDIO
 
* src/stdlib/itoa.cxx:
New file to convert integers to ascii
 
* include/stdlib.h:
Add proto for new cyg_libc_itoa() function
 
* include/time.inl:
Rework __asctime_r() to use memcpy() and cyg_libc_itoa() rather than
sprintf()
 
* src/PKGconf.mak:
Build stdlib/itoa.cxx
 
The above changes fix PR 19448
 
1999-03-17 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/time.h: Add #define of __time_t_defined to placate newlib
if it is used by accident. This is just a temporary workaround though.
 
1999-03-16 Gary Thomas <gthomas@cygnus.co.uk>
 
* src/PKGconf.mak: Add compile option to step around ARM compiler bug.
 
1999-03-16 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/pkgconf/libc.h (CYGNUM_LIBC_TIME_DST_DEFAULT_STATE):
Don't use parentheses for now
 
* src/stdio/common/stream.cxx (refill_read_buffer):
Silence bogus compiler warning
 
1999-03-16 Jesper Skov <jskov@cygnus.co.uk>
 
* tests/signal/signal2.c (main): Enable SIGSEGV test for
i386/Linux.
 
 
1999-03-15 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/signal/siginit.cxx (cyg_libc_signals_hwexcept_handler):
Only enable interrupts if they were disabled
 
* include/sys/timeutil.h:
* src/time/timeutil.cxx:
Add FIX ME line as a reminder that the workaround there can go away
in future
 
* include/pkgconf/libc.h:
Add proper define for CYGSEM_LIBC_EXIT_CALLS_FFLUSH
Put brackets round negative CYGNUM_LIBC_TIME_DST_DEFAULT_STATE define
Fix run time typo
* include/time.inl (__localtime_r):
Include sys/timeutil.h before this to get
cyg_libc_time_normalize_structtm()
 
1999-03-12 Gary Thomas <gthomas@cygnus.co.uk>
 
* include/sys/timeutil.h:
* src/time/timeutil.cxx: Remove 'const' from char arrays since
this fails [silently] on ARM when -fwritable-strings (PR19440)
 
1999-03-12 Jesper Skov <jskov@cygnus.co.uk>
 
* tests/signal/signal2.c (main): Compiler warnings fix was
slightly broken.
 
1999-03-12 Jesper Skov <jskov@cygnus.co.uk>
PR 19473
* tests/signal/signal2.c (main):
Disabling SIGTRAP handling on i386/Linux is not a good idea.
1999-03-11 Jesper Skov <jskov@cygnus.co.uk>
PR 19473
* tests/signal/signal2.c:
Added compiler warnings fix.
Added N/A handling for i386/Linux.
 
1999-03-10 Gary Thomas <gthomas@cygnus.co.uk>
 
* include/pkgconf/libc.h: Force "haldiag" device to be present.
'asctime' and friends need 'stdio' as well.
 
* include/time.inl: Fix syntax error on difftime() declaration.
 
1999-03-08 Gary Thomas <gthomas@cygnus.co.uk>
 
* src/clibincl/stream.hxx: <cyg/infra/cyg_ass.h> needed for this file.
 
* src/stdio/common/vsscanf.cxx (str_read): Fix problem with string
pointer [created by merge with new I/O package].
 
1999-03-05 John Dallaway <jld@cygnus.co.uk>
 
* include/pkgconf/libc.h:
Add legal values for CYGNUM_LIBC_TIME_STD_DEFAULT_OFFSET
and CYGNUM_LIBC_TIME_DST_DEFAULT_OFFSET.
 
1999-03-05 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/time.inl (cyg_libc_time_year_is_leap):
Fix bug with modulo year 400
Fix typo in asctime_r macro
Fix gmtime_r, and mktime as a result of testing
 
* tests/time/asctime.c, tests/time/ctime.c, tests/time/gmtime.c,
tests/time/gmtime.c, tests/time/localtime.c, tests/time/mktime.c,
tests/time/strftime.c, tests/time/time.c:
New tests
 
* tests/PKGconf.mak:
Build above new tests
 
* include/pkgconf/libc.h:
Add reminder FIX ME about extra config option
 
* src/time/strftime.cxx:
Fix %w and %Y parameters as a result of testing
 
* src/time/timeutil.cxx:
Fix cyg_libc_time_normalize_structtm() as a result of testing
of mktime()
 
* tests/time/clock.c:
Reformat, remove obsolete bits and tidy
 
* include/time.h:
Add Cyg_libc_time_dst type and new functions
cyg_libc_time_setzoneoffsets(), cyg_libc_time_setdst(),
cyg_libc_time_getzoneoffsets(), cyg_libc_time_settime()
 
* include/time.inl:
Implement the above functions. This allows us to adjust for timezone
diffences and set the time.
Change localtime() to adjust for STD/DST
Change mktime() to adjust for STD/DST
 
* include/libc.h:
Add new config options CYGSEM_LIBC_TIME_SETTIME_WORKING
and component CYGPKG_LIBC_TIME_ZONES containing options
CYGNUM_LIBC_TIME_DST_DEFAULT_STATE,
CYGNUM_LIBC_TIME_STD_DEFAULT_OFFSET,
CYGNUM_LIBC_TIME_DST_DEFAULT_OFFSET
 
* src/strftime.cxx:
Adjust handling of %Z to _not_ deal with STD/DST
 
* src/time/settime.cxx:
New file to implement cyg_libc_time_settime()
 
* src/PKGconf.mak:
Build settime.cxx
 
* src/time/timeutil.cxx:
Supply outline versions of cyg_libc_time_setzoneoffsets(),
cyg_libc_time_setdst(), and cyg_libc_time_getzoneoffsets()
Add variables for STD/DST state
Some minor comment changes
 
* include/errno.h:
Use CYGBLD_ATTRIB_CONST instead of __attribute__((const)) directly
 
* include/signal.h:
Change format of function comment headers
 
* include/signal.inl:
Restrict errno.h inclusion to when its actually used
Fix a spelling typo
 
* include/stdlib.h:
Add CYGBLD_ATTRIB_CONST to abs, div, labs, ldiv
 
* include/stdlib.inl:
Reformat and tidy
Include new versions of div and ldiv which are more portable and
are cleanly rewritten so aren't covered by the BSD licence, which
is now removed
 
* src/stdlib/div.cxx, src/stdlib/ldiv.cxx:
Non-inline, non-BSD and portable versions of the new versions of div
and ldiv from stdlib.inl
* include/time.h:
Much reformatting, tidying and improving comments
Change CLOCKS_PER_SEC from 1000 to 1000000
Add new functions asctime_r, ctime_r, gmtime_r, localtime_r, clock,
difftime, mktime, time, asctime, ctime, gmtime, localtime, strftime
Include new time.inl file
 
* include/pkgconf/libc.h:
Add new options CYGSEM_LIBC_TIME_CLOCK_WORKING,
CYGSEM_LIBC_TIME_TIME_WORKING, CYGFUN_LIBC_TIME_POSIX,
CYGNUM_LIBC_TIME_CLOCK_TRACE_LEVEL, CYGIMP_LIBC_TIME_ASCTIME_INLINE,
CYGIMP_LIBC_TIME_CTIME_INLINE, CYGIMP_LIBC_TIME_DIFFTIME_INLINE,
CYGIMP_LIBC_TIME_GMTIME_INLINE, CYGIMP_LIBC_TIME_LOCALTIME_INLINE,
CYGIMP_LIBC_TIME_MKTIME_INLINE, CYGIMP_LIBC_TIME_ASCTIME_R_INLINE,
CYGIMP_LIBC_TIME_CTIME_R_INLINE, CYGIMP_LIBC_TIME_GMTIME_R_INLINE,
and CYGIMP_LIBC_TIME_LOCALTIME_R_INLINE
 
* time/asctime.cxx, time/asctime_r.cxx, time/clock.cxx, time/ctime.cxx,
time/ctime_r.cxx, time/difftime.cxx, time/gmtime.cxx,
time/gmtime_r.cxx, time/localtime.cxx, time/localtime_r.cxx,
time/mktime.cxx, time/strftime.cxx, time/time.cxx, time/timeutil.cxx,
include/time.inl:
New files to implement the new time functions. Many of them simply
provide the outline definitions, but the real body of the function
comes from time.inl
 
* src/PKGconf.mak:
Build new .cxx files
 
* src/clibincl/stdlibsupp.hxx:
Remove _div and _ldiv prototypes since they're no longer needed
 
* src/clibincl/timesupp.hxx:
Delete as its now obsolete
 
* src/time/clock.cxx:
Use new CYGSEM_LIBC_TIME_CLOCK_WORKING option to control whether it
just returns (clock_t)-1 or not.
Much reformatting and tidying
Change real imlpementation from _clock to __clock
Use CYGBLD_ATTRIB_WEAK_ALIAS now
 
* tests/stdlib/div.c, tests/stdlib/ldiv.c:
Add some extra tests for handling of negative numbers
Reformat and tidy a bit, including removing the test for CYGPKG_LIBC
since its now always defined if the test is to be compiled
 
* tests/time/clock.c:
Remove duplication CYG_TEST_INFO line
Check if unimplemented using "(clock_t)-1" and not just "-1"
 
1999-03-04 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/stdlib/system.cxx:
Make sure system() is a weak alias for __system()
 
* include/pkgconf/libc.h: Rework CDL description for
CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE and change its default to
"/dev/haldiag"
 
* src/stdio/common/stream.cxx:
Check that dev is valid when passed to stream constructor
 
* src/stdio/common/stdiosupp.cxx:
Tidy
 
* src/support/mainthread.cxx: Make this depend on
CYGSEM_LIBC_STARTUP_MAIN_THREAD rather than just CYGPKG_KERNEL
 
1999-03-04 Gary Thomas <gthomas@cygnus.co.uk>
 
Merged in changes from 'ecos-new_devs-19990216-branch'
(1999-02-24 Jonathan Larmour <jlarmour@cygnus.co.uk>)
 
* src/stdio/common/stream.cxx:
Add "fix me" comments and remove a couple of commented out lines
 
* src/stdio/common/vsnprintf.cxx:
* src/stdio/common/vsscanf.cxx:
Revert to using pointer to string for private data, not just string.
This preserves the state across multiple calls
 
(1999-02-24 Gary Thomas <gthomas@cygnus.co.uk>)
 
* src/stdio/common/vsscanf.cxx:
* src/stdio/common/vsnprintf.cxx:
* src/stdio/common/stream.cxx:
* src/stdio/common/stdiosupp.cxx:
* src/stdio/common/fopen.cxx:
* src/clibincl/stream.inl:
* src/clibincl/stream.hxx:
* src/clibincl/stdiosupp.hxx:
* include/pkgconf/libc.h: Changes for new I/O system.
 
1999-03-03 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* tests/stdlib/atexit.c: Forgot to config atexit test for
CYGFUN_LIBC_ATEXIT option
 
* include/pkgconf/libc.h:
Require CYGVAR_KERNEL_THREADS_DATA for CYGSEM_LIBC_PER_THREAD_STRTOK
This fixes PR 19362
Require CYGPKG_KERNEL for thread safe streams
Also don't need "requires CYGPKG_KERNEL" for per-thread rand and errno
if we already require a finer granularity kernel option
 
1999-02-25 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/pkgconf/libc.h: Fix CYGNUM_LIBC_MAIN_STACK_SIZE by changing
CYGPKG_LIBC_STARTUP_MAIN_THREAD -> CYGSEM_LIBC_STARTUP_MAIN_THREAD
Fix for PR 19304
 
1999-02-23 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/stdlib/system.cxx: Add to implement trivial system() call
* include/stdlib.h: Add system() prototype
* src/PKGconf.mak: Build system.cxx
 
* tests/ctype/ctype.c, tests/i18n/setlocale.c, tests/setjmp/setjmp.c,
tests/signal/signal1.c, tests/signal/signal2.c,
tests/stdio/sprintf1.c, tests/stdio/sprintf2.c, tests/stdio/sscanf.c,
tests/stdio/stdiooutput.c, tests/stdlib/atexit.c,
tests/stdlib/atoi.c, tests/stdlib/atol.c, tests/stdlib/bsearch.c,
tests/stdlib/div.c, tests/stdlib/getenv.c, tests/stdlib/labs.c,
tests/stdlib/ldiv.c, tests/stdlib/malloc1.c, tests/stdlib/malloc2.c,
tests/stdlib/malloc3.c, tests/stdlib/qsort.c, tests/stdlib/rand1.c,
tests/stdlib/rand2.c, tests/stdlib/rand3.c, tests/stdlib/realloc.c,
tests/stdlib/srand.c, tests/stdlib/strtol.c, tests/stdlib/strtoul.c,
tests/string/memchr.c, tests/string/memcmp1.c,
tests/string/memcmp2.c, tests/string/memcpy1.c,
tests/string/memcpy2.c, tests/string/memmove1.c,
tests/string/memmove2.c, tests/string/memset.c,
tests/string/strcat1.c, tests/string/strcat2.c,
tests/string/strchr.c, tests/string/strcmp1.c,
tests/string/strcmp2.c, tests/string/strcoll1.c,
tests/string/strcpy1.c, tests/string/strcpy2.c,
tests/string/strcspn.c, tests/string/strlen.c,
tests/string/strncat1.c, tests/string/strncat2.c,
tests/string/strncpy1.c, tests/string/strncpy2.c,
tests/string/strpbrk.c, tests/string/strrchr.c,
tests/string/strspn.c, tests/string/strstr.c, tests/string/strtok.c,
tests/string/strxfrm1.c, tests/string/strxfrm2.c, tests/time/clock.c:
Use CYG_TEST_NA() macro for non-applicable test configurations
 
1999-02-20 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/signal.h:
* include/signal.inl:
* src/signal/raise.cxx:
* src/signal/siginit.cxx:
* src/signal/signal.cxx:
* tests/signal/signal1.c
* tests/signal/signal2.c:
New files to implement ISO standard signals
 
* src/PKGconf.mak (TESTS):
* tests/PKGconf.mak (TESTS):
Update to build new files above
* include/stdlib.h:
* src/clibincl/stdlibsupp.hxx:
Comment and QA changes (including giving better names to some types)
 
* include/libc.h:
Add new configuration options for signals
Add new CYGSEM_LIBC_STARTUP_MAIN_THREAD option
Add a note to CYGNUM_LIBC_MAIN_STACK_SIZE option that it may be
overriden by HAL
Add new CYGFUN_LIBC_ATEXIT option and move ...ATEXIT_HANDLERS under
it
Add new CYGSEM_LIBC_EXIT_CALLS_FFLUSH option
Require CYGSEM_LIBC_STARTUP_MAIN_THREAD for "Invoke default static
constructors" option
 
* src/stdlib/atexit.cxx:
Support above CYGFUN_LIBC_ATEXIT and QA changes
 
* src/stdlib/exit.cxx:
Support for above new libc.h options, and some QA changes
 
* src/support/cstartup.cxx:
Add support for new CYGSEM_LIBC_STARTUP_MAIN_THREAD option
 
* src/support/mainthread.cxx:
Override main stack size if the HAL has a minimum
 
* src/string/strncpy.cxx:
Use improved algorithm for aligned copies - imported from newlib
QA changes
 
* src/stdlib/abort.cxx:
Support raise(SIGABRT), and some QA
* include/errno.h:
Add const attribute
 
* tests/stdlib/abs.c:
QA improvements
 
1999-02-04 Jesper Skov <jskov@cygnus.co.uk>
 
* src/support/cstartup.cxx: Only define cyg_libc_main_thread when
the kernel is around.
 
1999-02-01 Jesper Skov <jskov@cygnus.co.uk>
 
* tests/time/clock.c: Joined the two test/NOP checks into
one.
Increased tolerance in attempt to fix PRs 18737,18787,18846.
Fixed typo.
 
1999-01-28 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/string/strtok.cxx:
* src/stdlib/rand.cxx:
Include <pkgconf/kernel.h> if we use kernel header files
 
1999-01-25 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* tests/stdio/sscanf.c (test):
CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT should be
CYGSEM_LIBC_STDIO_SCANF_FLOATING_POINT
Fix for PR 18786
 
* src/string/strtok.cxx:
* src/stdio/common/stdiofiles.cxx:
* src/errno/errno.cxx:
* src/stdlib/rand.cxx:
Give mutex protection objects a libc constructor priority
 
* src/support/invokemain.cxx:
Add prototype for cyg_hal_invoke_constructors()
 
* src/support/mainthread.cxx:
Give cyg_libc_dummy_constructor_obj a libc constructor priority,
and make its class have a public constructor
 
* src/stdio/common/stderr.cxx:
* src/stdio/common/stdout.cxx:
* src/stdio/common/stdin.cxx:
Give cyg_libc_stdio_stdin/out/err static objects a libc constructor
priority
* src/clibincl/streambuf.hxx (class Cyg_StdioStreamBuffer):
* src/clibincl/stream.hxx (class Cyg_StdioStream):
Remove private copy constructor. Needed to make prioritised
static constructors work. Fix for PR 18898
 
1999-01-22 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/errno/errno.cxx:
Include pkgconf/kernel.h otherwise it fails with per-thread errno
enabled
 
* include/pkgconf/libc.h:
Enable per-thread errno by default since that is what POSIX would
want
 
* tests/time/clock.c (test):
Placate compiler by initializing clock_first/second/third anyway,
even though they won't be in practice. This is only a test program
so adding an extra instruction doesn't matter.
 
* src/i18n/locale.cxx (_setlocale):
Placate compiler, since it is dumb, by nesting, not serializing, if's
This is an idempotent change, but screws up the formatting :-(.
 
* src/string/strpbrk.cxx (_strpbrk):
Change while loop to do loop to placate compiler. It'll even save an
instruction too (wow!)
1999-01-22 John Dallaway <jld@cygnus.co.uk>
 
* include/pkgconf/libc.h:
Add closing curly brace to CYGPKG_LIBC_STRING_STRTOK definition
 
1999-01-21 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/errno.h:
Tidy up and add to header description
Change cyg_get_errno_p() to cyg_libc_get_errno_p()
Remove ifdef CYGPKG_LIBC
 
* include/sys/file_if.h:
Remove - move contents to stdio.h
 
* include/stdio.h:
Tidy up header description
Move FILE typedef here from sys/file_if.h
SEEK_SET, SEEK_CUR, SEEK_END defined to 0, 1, 2 respectively
for backwards compatibility with old UNIX
Change definitions of stdin/out/err to be addresses of FILE
globals - even though they're actually Cyg_StdioStream it'll work
 
* include/pkgconf/libc.h:
Make CYGPRI_LIBC_WEAK et al macros depend on new ones in infra
Reorganise trace options under the individual components they are
associated with.
Reorganise thread-safety options under the individual components
they are associated with.
Add new CYGSEM_LIBC_INVOKE_DEFAULT_STATIC_CONSTRUCTORS option
Misc. reformatting
Remove dependency on pkgconf/kernel.h - Configuration Tool will
generate check macros anyway.
Remove CYGPKG_LIBC_TRACE, CYGFUN_LIBC_strtok, CYGPKG_LIBC_RAND
options
Tidy up description header
 
* src/clibincl/clibdata.hxx:
* src/clibincl/clibdata.inl:
* src/support/clibdata.cxx:
Remove and instead rely on each component to initialise its own data
 
* src/clibincl/stdiofiles.hxx, src/clibincl/stdiofiles.inl:
New files to contain global file list and lock (if applicable).
Implemented as class with member access functions
 
* src/errno/errno.cxx:
Reorganise with self-contained per-thread data, if applicable
Remove ifdef CYGPKG_LIBC
Tidy up description header
Rename cyg_get_errno_p() to cyg_libc_get_errno_p()
 
* src/stdio/common/fclose.cxx:
* src/stdio/common/fflush.cxx:
* src/stdio/common/fopen.cxx:
* src/stdio/common/freopen.cxx:
Remove ifdef CYGPKG_LIBC
Use new global file access method from stdiofiles.hxx
Tidy up description header
Use new CYGBLD_ATTRIB_WEAK_ALIAS
Access errno "normally" rather than clibdata way
 
* src/stdio/common/stdin.cxx:
* src/stdio/common/stdout.cxx
* src/stdio/common/stderr.cxx:
New files. Implement Cyg_StdioStream objects for each stream. In
separate self-contained files so using one doesn't bring in the
others
 
* src/stdio/common/stdiofiles.cxx:
New file. Implements global files array and lock
 
* src/stdlib/_exit.cxx:
Tidy up description header
Remove ifdef CYGPKG_LIBC
Use infra CYGBLD* macros
 
* src/stdlib/malloc.cxx:
Tidy up description header
Remove ifdef CYGPKG_LIBC
Add pkgconf/kernel.h now that pkgconf/libc.h doesn't have it
Use infra CYGBLD* macros
Make pool visible externally with weak attribute and new name
cyg_libc_malloc_memorypool
 
* src/stdlib/rand.cxx:
* src/stdlib/strtok.cxx:
Reorganise with self-contained per-thread data, if applicable
Remove ifdef CYGPKG_LIBC
Tidy up description header
Use infra CYGBLD* macros
 
* src/support/cstartup.cxx:
Split into smaller files to make selective linking work better,
fix i386 port problem and make GDB happy
 
* src/support/environ.cxx:
* src/support/invokemain.cxx:
* src/support/main.cxx:
* src/support/mainthread.cxx:
New files from bits of the old cstartup.cxx
Add support for CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG
 
* src/PKGconf.mak:
Update to reflect file additions/deletion
 
* tests/stdlib/rand1.c:
* tests/stdlib/rand2.c:
* tests/stdlib/rand3.c:
* tests/stdlib/srand.c:
Make conform to coding standards
Remove ifdef CYGPKG_LIBC_RAND
Tidy up description header
 
* tests/string/strtok.c:
Make conform to coding standards
Remove ifdef CYGFUN_LIBC_strtok
Tidy up description header
 
1999-01-15 Mark Galassi <rosalia@cygnus.com>
 
* tests/stdlib/getenv.c (main): added tests for the case in which
the user does not supply environ and in which the user supplies a
NULL environ.
 
1999-01-15 Jesper Skov <jskov@cygnus.co.uk>
 
* src/support/cstartup.cxx: Added workaround for weak aliasing
problem in i386 gcc.
 
 
1999-01-15 Gary Thomas <gthomas@cygnus.co.uk>
 
* include/pkgconf/libc.h (CYGNUM_LIBC_MAIN_STACK_SIZE):
(CYGNUM_LIBC_MALLOC_MEMPOOL_SIZE): Change defaults to be
more reasonable on small systems.
 
1999-01-04 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/support/clibdata.cxx:
Minor bug with environ not being initialised correctly by
default
 
1998-12-24 Bart Veer <bartv@cygnus.co.uk>
 
* src/clibincl/stream.inl (Cyg_StdioStream):
check_this() member functions should now be const
 
1998-12-22 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/string/memchr.cxx (_memchr):
treat search value parameter to memchr as an unsigned byte,
not a signed int - copied fix from newlib PR 18471
 
1998-12-21 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* tests/stdlib/realloc.c:
* tests/stdlib/malloc3.c:
* tests/stdlib/malloc2.c:
Warning cleanup
 
1998-12-14 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* tests/stdlib/malloc2.c, tests/stdlib/malloc3.c,
tests/stdlib/realloc.c:
Only run these tests when we have a coalescing memory allocator
 
1998-12-14 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/stdio/common/stream.cxx:
Only check buffer init success if buffering
 
* src/stdio/common/streambuf.cxx (set_buffer):
Check for diff of requested size against buffer_size, not
get_buffer_size(), since this may return -1, which won't be
equal to size, and will cause malloc to be called
 
1998-12-01 Jesper Skov <jskov@cygnus.co.uk>
 
* tests/stdlib/getenv.c (main): Don't declare variables when they
are not used.
 
Thu Nov 26 17:59:12 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* tests/string/strncpy1.c:
Fix off-by-one error since it called my_strcmp() and not
my_strncmp(), which meant in included the trailing NULL when it
shouldn't have.
 
1998-11-26 Jesper Skov <jskov@cygnus.co.uk>
 
* src/stdlib/qsort.cxx (_qsort):
* src/stdlib/rand.cxx (_srand):
Changed CYG_REPORT_FUNCNAMETYPE to CYG_REPORT_FUNCNAME in void
functions.
 
Mon Oct 26 18:49:00 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/support/cstartup.cxx (cyg_libc_dummy_main):
Silence compiler warning with cast of char * to CYG_ADDRWORD
 
Wed Oct 28 17:31:21 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/time/clock.cxx (_clock):
Reorder scaling expression as it was both incorrect and risked
overflow.
Fix for PR 18076
 
Mon Oct 19 14:40:06 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/stdio.h (EOF):
Change from -64 to (-1), to allow broken code to work :-/
Also change other negative defines to be within parentheses
 
1998-10-19 Mark Galassi <rosalia@cygnus.com>
 
* include/pkgconf/libc.h: updated the doc URL
 
Thu Oct 15 21:33:44 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/clibincl/clibdata.hxx:
Only include kernel thread headers when we're in thread-safe mode
 
* src/time/clock.cxx:
Only include kernel clock headers if there's a kernel with the
right functionality available
 
* tests/time/clock.c:
Remove unnecessary inclusion of <pkgconf/kernel.h>
 
Above changes are required for PR 17229
 
Wed Oct 14 16:38:55 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl:
Conditionalise inclusion of clibincl/stdiosupp.hxx and
clibincl/stream.hxx. Tidying up PR 17502
 
Wed Oct 14 14:08:56 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/pkgconf/libc.h:
Rename CYGPKG_LIBC_STRING_OPTIMISATIONS to
CYGPKG_LIBC_STRING_OPTIMIZATIONS to make it truely merkin.
 
Tue Oct 13 19:34:41 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/pkgconf/libc.h (CYGDAT_LIBC_ARGUMENTS):
Add a default argv[0] of "" as many programs assume argc>0
The standard allows argv[0] to be "" if the program name
is not available
 
1998-09-26 Bart Veer <bartv@cygnus.co.uk>
 
* src/clibincl/stdiosupp.hxx:
PR 17502: this header file now does nothing if the stdio option
is disabled completely. This is the same behaviour is
clibincl/stream.hxx, although arguably the #ifdef protection
should happen wherever the header file is #include'd rather than
in the header file itself.
* src/clibincl/clibdata.hxx:
PR 17502: this header file still #include's internal stdio-related
header files and references the FILE structure, even if stdio is
disabled. There were some #ifdef's for CYGPKG_LIBC_STDIO already.
One more has been added for _fopen() and _fclose().
 
1998-09-25 Bart Veer <bartv@cygnus.co.uk>
 
* src/clibincl/streambuf.inl (Cyg_StdioStreamBuffer):
PR 17487: Reorder the calls to initialize member fields, to
eliminate a compiler warning.
 
Fri Sep 25 19:04:29 1998 Jonathan Larmour <jlarmour@peshwari.cygnus.co.uk>
 
* src/errno/errno.cxx, src/stdlib/bsearch.cxx,
src/stdlib/qsort.cxx, src/stdlib/rand.cxx, src/string/strtok.cxx,
src/time/clock.cxx:
Only define tracing variable and tracing level macro when
the relevant tracing level config options are set. Otherwise
keep the tracing level fixed at 0
Fix for PR 17476
 
* include/pkgconf/libc.h:
Define trace levels only if parent CYGPKG_LIBC_TRACE is defined
for consistency with Configuration Tool
 
Fri Sep 25 17:24:45 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/stdio/common/stdioinlines.cxx:
Make definition of vscanf() dependent on CYGFUN_LIBC_STDIO_ungetc
otherwise _vfscanf() won't be compiled. This therefore would
cause a link fail iff selective linking is not enabled.
Fix for PR 17455
 
Fri Sep 25 17:23:17 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/stdlib/rand.cxx:
Make compilation dependent on CYGPKG_LIBC_RAND
Fix for PR 17473
 
* tests/stdlib/srand.c:
Make definition of dummy test pass conditional on CYGPKG_LIBC_RAND
not being defined, as well as CYGPKG_LIBC
Caused compilation failure when testing PR 17473 fix
 
Mon Sep 21 17:11:04 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* tests/stdio/sscanf.c:
Make sscanf test conditional on CYGFUN_LIBC_STDIO_ungetc since
_vfscanf() only gets compiled if this is defined
Fix for PR 17346
 
1998-09-20 Mark Galassi <rosalia@cygnus.com>
 
* include/pkgconf/libc.h: updated CDL doc strings.
 
Fri Sep 18 22:18:47 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/clibincl/clibdata.inl (get_errno_p):
Rather than this function only being available in thread-safe mode,
instead make what it returns be either the per-thread errno, or
global errno depending on the configuration.
Include <errno.h> (conditionally) to support this change
 
Wed Sep 16 11:20:31 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/pkgconf/libc.h:
Remove "fix me" comment which I forgot to remove before
 
Tue Sep 15 19:27:57 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/pkgconf/libc.h:
Updated descriptions and a few other minor things after review.
Notably though, the NDEBUG config option has been removed
 
1998-09-15 Bart Veer <bartv@cygnus.co.uk>
 
* include/pkgconf/libc.h:
PR 17201: removed dependency on CYGPKG_KERNEL in the option
CYGNUM_LIBC_MAIN_STACK_SIZE, since the actual dependencies cannot
be expressed sensibly in the current system.
 
1998-09-11 Bart Veer <bartv@cygnus.co.uk>
 
* include/pkgconf/libc.h:
Sorting out dependencies for error package.
 
1998-09-10 Mark Galassi <rosalia@cygnus.com>
 
* include/pkgconf/libc.h: started adding doc fields to the
cdl_package data, as a pilot for now.
 
Wed Sep 9 17:41:23 1998 Hugo Tyson <hmt@cygnus.co.uk>
 
* include/pkgconf/libc.h:
Add option CYGIMP_LIBC_MALLOC_CXX_DELETE_CALLS_FREE to explicitly
control whether the empty delete functions (currently) in
kernel/.../common/delete.cxx are enabled; controls code bloat, see
the comments in delete.cxx.
 
Fri Sep 4 16:43:38 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* tests/stdio/stdiooutput.c:
Add a default CYG_TEST_PASS() to make sure the test infra doesn't
complain.
Also remove the unused string functionsa
 
Fri Sep 4 15:43:48 1998 Hugo Tyson <hmt@cygnus.co.uk>
 
* src/stdlib/exit.cxx (__libc_exit):
* src/stdlib/_exit.cxx (__libc__exit):
* src/stdlib/malloc.cxx (_free):
* src/stdlib/abort.cxx (abort):
* src/support/cstartup.cxx (invoke_main):
Tracing system asserted cos it was being called incorrectly; these
are void functions so you shouldn't give a type to the function
reporting call.
 
Fri Sep 4 15:03:10 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/pkgconf/libc.h:
Fix CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE description to refer to
the table.cxx file, not table.h
 
Fri Sep 4 14:38:52 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/pkgconf/libc.h:
Add description for CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE since
Proven won't be making any changes to the device driver
implementation after all.
Fix for PR 17148
 
* src/clibincl/stream.inl (set_position):
Remove "fix me" line. It is obvious that this will have to change
with a filesystem interface
Fix for PR 17147
* src/stdio/common/freopen.cxx:
Remove "fix me" - I know about this issue
Fix for PR 17145
 
* src/stdio/common/stream.cxx (read):
Remove "fix me" and change to use memcpy
Fix for PR 17144
 
Fri Sep 4 14:36:47 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* tests/stdio/stdiooutput.c:
Actually add it this time!
 
Fri Sep 4 13:48:13 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* tests/stdio/stdiooutput.c:
Add new tests for misc stdio output functions
 
* tests/PKGconf.mak:
Build stdiooutput.c test
 
Fri Sep 4 12:52:10 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/clibincl/stream.inl (write_byte):
Remove bogus assert
 
* tests/stdlib/getenv.c (main):
Check whether str is NULL before doing a strcmp()
 
* tests/stdio/sprintf2.c (main):
Reformat to 76 columns
 
Fri Sep 4 02:10:54 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/clibincl/stream.hxx, src/stdio/common/stream.cxx:
Add new peek_byte method to Cyg_StdioStream
 
* src/stdio/input/vfscanf.cxx (_vfscanf):
Fix up buffer access to work with new peek_byte method above
Fix for PR 16954
 
Thu Sep 3 19:40:11 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* tests/stdlib/rand1.c, tests/stdlib/rand2.c,
tests/stdlib/rand3.c:
Add extra check for CYGPKG_LIBC_RAND to decide whether the test
is applicable or not
 
* tests/stdlib/rand2.c (test):
Use CYGNUM_LIBC_RAND_SEED for default seed, not 1
 
* tests/string/strtok.c:
Add extra check for CYGFUN_LIBC_strtok to decide whether the
test is applicable or not
 
Wed Sep 2 19:11:40 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/stdio/input/fread.cxx, src/stdio/output/fwrite.cxx:
Add fread() and fwrite() functions
 
* src/PKGconf.mak:
Build fread.cxx and fwrite.cxx from above
 
* src/stdio/common/stream.cxx:
Reformat to 76 columns
In write(), move initialisation of *bytes_written to start
In read(), move initialisation of *bytes_read to start
 
* include/stdio.h:
Reformat to 76 columns
 
Replace all references to the ANSI
standard to instead by the ISO C standard
 
Add commented argument names for "documentation"
 
Add fread() and fwrite() prototypes
 
* src/clibincl/stdiosupp.hxx:
Copy the above changes from stdio.h, and add _fread() and _fwrite()
prototypes
 
* src/stdio/output/fputs.cxx, src/stdio/input/fgets.cxx:
Reformat to 76 columns
 
Wed Sep 2 15:41:15 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/stdio/input/vfscanf.cxx:
Reformat to 76 columns
 
Wed Sep 2 14:46:18 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/stdio/common/fflush.cxx:
Use trylock_me() instead of lock_me(), and loop to prevent
deadlocks
* src/clibincl/stream.hxx, src/clibincl/stream.inl:
Add trylock_me() method
 
* src/clibincl/stream.hxx, src/clibincl/stream.inl,
src/stdio/common/fflush.cxx:
Reformat to 76 columns
 
Wed Sep 2 12:24:27 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/pkgconf/libc.h:
Change 0x7fff to 0x7fffffff. Oops!
give main stack size option a legal_values field
Undefine tracing by default
Add some more description in the header
 
Tue Sep 1 20:02:07 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* tests/i18n/setlocale.c (cyg_package_start):
Fix typo - extra "x" for no reason at all! :-)
 
Tue Sep 1 19:44:58 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/i18n/locale.cxx:
Fix bug in find_locale_data() that miscalculated size of
all_locales
Make find_locale_data() match the locale "" and add some
other things in _setlocale() to ensure that "C" gets returned
when the default locale "" is passed.
 
Only check the locale pointer when it is non-NULL
 
* tests/i18n/setlocale.c:
New tests for setlocale()
 
* tests/PKGconf.mak:
Update to build setlocale.c test
 
* src/support/cstartup.cxx:
Don't actually call system default main() "main" otherwise GDB
gets confused and thinks its the entry point. Instead make a weak
alias and call the real function something different.
 
Tue Sep 1 18:31:42 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/i18n/locale.cxx (_setlocale):
Fix tracing macro name and remove "str maybe used before
initialised" warning
 
* tests/stdlib/qsort.c:
Correct file description header
 
Tue Sep 1 17:04:32 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/locale.h, src/clibincl/i18nsupp.hxx, src/i18n/locale.cxx:
New files to add support for locales as defined by the ISO C
standard. i.e. setlocale() and localeconv() functions and some
other bits
 
* include/pkgconf/libc.h:
Add CYGNUM_LIBC_MAX_LOCALE_NAME_SIZE config option for locale
support
 
* src/PKGconf.mak:
build locale.cxx
* include/errno.h, src/clibincl/ctypesupp.hxx:
Tidy up to 76 columns
 
Tue Sep 1 00:24:22 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/pkgconf/libc.h:
Move environment-related options from stdlib into new
CYGPKG_LIBC_STARTUP component. Also add options for main()'s
arguments (CYGPKG_LIBC_ARGUMENTS), main()'s default stack size
(CYGNUM_LIBC_MAIN_STACK_SIZE), number of atexit handlers
(CYGNUM_LIBC_ATEXIT_HANDLERS), and whether _exit() stops the
system (CYGSEM_LIBC_EXIT_STOPS_SYSTEM).
 
* src/clibincl/stdlibsupp.hxx:
Fix a few comment bugs, and add new
cyg_libc_invoke_atexit_handlers() function prototype
 
* src/stdlib/_exit.cxx, src/stdlib/atexit.cxx, src/stdlib/exit.cxx:
Implement exit(), atexit() and _exit() correctly now. Also
includes cyg_libc_invoke_atexit_handlers() in atexit.cxx. Now
we get the correct behaviour of atexit(), and exit() invokes the
atexit handlers and fflushs all the stdio streams. Add plenty of
tracing of asserts too.
 
* src/support/cstartup.cxx:
Make main_thread object an exported global. Allow user-settable
arguments. Add MUCH more tracing and asserts. Improve comments.
Tidy up to 76 columns
 
* tests/stdlib/atexit.c:
Add simple test for atexit() and it calling registered functions
 
* tests/PKGconf.mak:
Build atexit.c test
 
Mon Aug 31 18:54:48 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/stdlib/getenv.cxx, tests/stdlib/getenv.c:
Add support for getenv(), and some tests to ensure it works
 
* src/PKGconf.mak, tests/PKGconf.mak:
Update to include getenv.cxx and getenv.c test
 
* src/clibincl/clibdata.hxx:
remove prototype for environ - we expect files needing it to
define it themselves
 
* src/support/clibdata.cxx:
Tidy up to 76 columns and add definition of char **environ, but
with a configurable initialiser (see libc.h below)
 
* tests/stdlib/abs.c (main):
Tidy up to 76 columns
 
* src/stdlib/malloc.cxx:
Tidy up to 76 columns and remove warning for undefined _memcpy()
by changing to memcpy(), and casting away signedness
 
* include/pkgconf/libc.h:
Add CYGPKG_LIBC_ENVIRONMENT and CYGDAT_LIBC_DEFAULT_ENVIRONMENT
configuration options
 
* include/pkgconf/libc.h, src/clibincl/clibdata.hxx:
Tidy up to 76 columns
 
* include/stdlib.h:
Add getenv() prototype and tidy up to 76 columns
 
* src/clibincl/stdlibsupp.hxx:
Add _getenv() prototype
Mon Aug 31 13:37:08 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/stdlib/malloc.cxx:
Add realloc()
 
* tests/stdlib/realloc.c:
Add this file to test new realloc() functionality
 
* tests/PKGconf.mak:
Build realloc test
 
* tests/stdlib/malloc3.c (main), tests/stdlib/malloc2.c (main),
tests/stdlib/malloc1.c (main):
Conditionalise local vars to prevent warnings
 
* tests/stdlib/malloc3.c (fill_with_data):
Move '{' into "verb" line
 
* include/pkgconf/libc.h:
Require infra tracing support to allow tracing
 
* include/stdlib.h:
Add realloc()
 
* src/clibincl/stdlibsupp.hxx:
Update the commented argument names from stdlib.h, including realloc()
 
1998-08-28 Bart Veer <bartv@cygnus.co.uk>
 
* include/pkgconf/libc.h:
* src/clibincl/clibdata.hxx, src/time/clock.cxx:
Updated for new kernel configuration option symbol names
 
Fri Aug 28 19:18:25 1998 Hugo Tyson <hmt@cygnus.co.uk>
 
Changed the entry below to sat "tx39" instead of "mn10300".
It's been a long week.
 
Fri Aug 28 18:59:20 1998 Hugo Tyson <hmt@cygnus.co.uk>
 
* src/support/cstartup.cxx: Add a weakly named main to allow the
default configuration to link on the tx39 which has no
scalextric linking yet. The static Cyg_Thread main_thread object
below continues to exist, though unreferenced, so all its
descendants must exist too.
 
Fri Aug 28 08:54:29 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/stdlib.h:
Add commented argument names Add exit(), and atexit(). And move
these along with abort() and _exit() to a new section.
 
* src/stdlib/atexit.cxx, src/stdlib/exit.cxx:
Add trivial versions of atexit() and exit()
 
* include/pkgconf/libc.h:
Add CYGNUM_LIBC_MAIN_STACK_SIZE config option
 
* include/sys/cstartup.h, src/support/cstartup.cxx, src/PKGconf.mak:
New files to provide a new function cyg_iso_c_support(), which
invokes main "correctly".
 
* tests/ctype/ctype.c, tests/setjmp/setjmp.c, tests/stdio/sprintf1.c,
tests/stdio/sprintf2.c, tests/stdio/sscanf.c, tests/stdlib/abs.c,
tests/stdlib/atoi.c, tests/stdlib/atol.c, tests/stdlib/bsearch.c,
tests/stdlib/div.c, tests/stdlib/labs.c, tests/stdlib/ldiv.c,
tests/stdlib/malloc1.c, tests/stdlib/malloc2.c,
tests/stdlib/malloc3.c, tests/stdlib/qsort.c, tests/stdlib/rand1.c,
tests/stdlib/rand2.c, tests/stdlib/rand3.c, tests/stdlib/srand.c,
tests/stdlib/strtol.c, tests/stdlib/strtoul.c,
tests/string/memchr.c, tests/string/memcmp1.c,
tests/string/memcmp2.c, tests/string/memcpy1.c,
tests/string/memcpy2.c, tests/string/memmove1.c,
tests/string/memmove2.c, tests/string/memset.c,
tests/string/strcat1.c, tests/string/strcat2.c,
tests/string/strchr.c, tests/string/strcmp1.c,
tests/string/strcmp2.c, tests/string/strcoll1.c,
tests/string/strcoll2.c, tests/string/strcpy1.c,
tests/string/strcpy2.c, tests/string/strcspn.c,
tests/string/strlen.c, tests/string/strncat1.c,
tests/string/strncat2.c, tests/string/strncpy1.c,
tests/string/strncpy2.c, tests/string/strpbrk.c,
tests/string/strrchr.c, tests/string/strspn.c,
tests/string/strstr.c, tests/string/strtok.c,
tests/string/strxfrm1.c, tests/string/strxfrm2.c,
tests/time/clock.c:
 
Modify all tests to use new startup mechanism, and cyg_iso_c_start()
 
Fri Aug 28 00:29:38 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/stdio/common/stream.cxx:
Add #ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO around all accesses to
flags.last_buffer_op_was_read. Fix for PR 16997
 
Thu Aug 27 01:12:42 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/sys/file_if.h:
Fix comments and remove cyg_get_file_star()
 
Wed Aug 26 20:24:32 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/pkgconf/libc.h:
Remove #define CYGPKG_LIBC is that is meant to live in
<pkgconf/system.h> after all
 
Wed Aug 26 19:39:23 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/pkgconf/libc.h:
More fixes to CDL stuff to make it work better, and look better on
the screen
 
Tue Aug 25 20:21:41 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/pkgconf/libc.h:
Make some fixes after running the ConfigTool
 
Tue Aug 25 16:46:28 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/pkgconf/libc.h (CYGNUM_LIBC_STDIO_BUFSIZE):
Fix typo of CYGNUM_LIBC_STDIO_BUFSIZE
 
Tue Aug 25 15:10:57 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/pkgconf/libc.h:
Tidy up CDL stuff a bit more, prior to checking it actually works.
 
Tue Aug 25 11:38:52 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* tests/stdlib/malloc2.c (main):
Prevent calls to CYG_TEST_STILL_ALIVE for now
 
Tue Aug 25 05:39:28 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/pkgconf/libc.h:
Change cosmetic paragraph alignment.
Tue Aug 25 03:11:34 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/support/clibdata.cxx:
Make stderr initialise with buffer size 0.
For PR 16955
 
Mon Aug 24 17:38:46 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/pkgconf/libc.h:
First pass at CDL-ifying the C library configuration. Currently
deliberately disabled as there a few outstanding issues.
 
Mon Aug 24 16:14:22 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/stdio/output/vfnprintf.cxx (_vfnprintf):
clear up warning for unused argument
 
* tests/stdlib/malloc2.c (NUM_ITERATIONS):
Lower to 100 from 50000 so it won't take too long under the simulator
 
Thu Aug 20 17:48:43 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/stdlib/malloc.cxx:
Remove now unnecessary inclusion of kernel/ktypes.h
 
Wed Aug 19 19:19:14 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* tests/stdio/sprintf1.c, tests/stdio/sprintf2.c,
tests/stdio/sscanf.c, tests/stdlib/atoi.c, tests/stdlib/atol.c,
tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c,
tests/stdlib/srand.c, tests/stdlib/strtol.c,
tests/stdlib/strtoul.c, tests/string/strtok.c,
tests/time/clock.c:
Add parameters to "main()" to silence warnings
 
Wed Aug 19 18:52:59 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/stdio/common/stream.cxx (refill_read_buffer):
Put conditional error check into same #ifdef and if as what was being
checked in the first place!
 
Wed Aug 19 18:49:19 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/clibincl/stream.inl:
Reorder Cyg_StdioStream::check_this() to be first to silence
warnings
 
Tue Aug 18 16:10:03 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* ecc/language/c/libc/current/src/clibincl/clibdata.hxx,
ecc/language/c/libc/current/src/errno/errno.cxx,
ecc/language/c/libc/current/src/stdio/common/fopen.cxx,
ecc/language/c/libc/current/src/stdlib/rand.cxx,
ecc/language/c/libc/current/src/string/strtok.cxx:
Rename CYGIMP_LIBC_INTERNAL_DATA_PREAMBLE,
CYGIMP_LIBC_INTERNAL_DATA_ALLOC_CHECK_PREAMBLE,
CYGVAR_LIBC_INTERNAL_DATA, and
CYGIMP_LIBC_INTERNAL_DATA_CHECK to all have CYGPRI_ prefix instead
as recommended by the config name rules
 
 
Tue Aug 18 14:31:19 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/stdio/common/setvbuf.cxx (_setvbuf):
Rename variable names in assert line, otherwise doesn't build
with asserts on!
 
Sun Aug 16 18:15:12 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/stdio/input/vfscanf.cxx (_vfscanf):
Fix some bugs, although there are some left to fix still. Unrelated
to the rest of the checkins, so I will check the partial fix in now.
 
* src/clibincl/stream.hxx, src/clibincl/stream.inl,
src/stdio/common/stream.cxx:
Add parameters to constructor to allow more things to be done at
construction time.
 
Now we have "new", remove separate "construct" method
 
Add more documentation on constructor
 
As requested by code review, where possible, move boolean flags
into separate packed bitfield structure for space efficiency
 
Make readbuf_char be usable all the time rather than when configured
not to be buffering, as it is also needed for non-buffered mode i.e.
_IONBF
 
* src/stdio/common/fopen.cxx:
Change to use new method of construction from above, using new
 
Use thread-specific data, rather than global. And so change errnos
to access errno entry specifically
 
Make process_mode() check for append mode too
 
Reformat for coding standards to have { in same line as "verb"
 
* src/stdio/common/setvbuf.cxx:
 
Change to cope with different way of dealing with buffering policy
flags etc. in Cyg_StdioStream
 
* src/stdio/common/vsnprintf.cxx, src/stdio/common/vsscanf.cxx,
src/support/clibdata.cxx:
Change construction of streams to use new parameters added above,
and change to use _IONBF mode for string stdio functions,
otherwise its a waste of memory. And use _IONBF for stderr as the
ISO standard tells us to!
 
Reformat for coding standards to have { in same line as "verb"
 
* src/clibincl/streambuf.hxx, src/clibincl/streambuf.inl:
Change constructor so that it can be set with default size and
dynamic buffer (if applicable)
 
Fix minor bug in destructor - should only call free when allocated
dynamically
 
Change get_buffer_size to return -1 if the buffer was not allowed
to be set up
 
* src/stdio/common/streambuf.cxx:
Remove unnecessary stdio.h include and add extra comment to whether
to free bit in set_buffer()
 
* src/stdio/common/freopen.cxx:
Change @@@ to standard fix me string
 
* src/stdio/output/fputc.cxx:
Remove unnecessary "written" variable
 
Thu Aug 13 15:37:28 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/stdlib/_exit.cxx:
Included use of "fix me" line to ensure this is discussed before
release
 
* include/stdlib.h, src/stdlib/abort.cxx, src/PKGconf.mak:
Add abort.cxx to implement abort(), albeit naively
 
Thu Jul 30 18:03:09 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/stdio/common/vsscanf.cxx (_vsscanf),
src/stdio/common/vsnprintf.cxx (_vsnprintf):
Fix initialiser of pseudo string device table that didn't get updated
when the table changed (Bad proven, no biscuit).
 
* src/clibincl/stream.inl (~Cyg_StdioStream):
Move invalidation of magic_validity_word to after unlock_me(),
otherwise it always fails!
 
Tue Jul 28 21:29:53 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/clibincl/clibdata.hxx:
Shorten over-long lines
 
Tue Jul 28 20:28:23 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/clibincl/stream.hxx (class Cyg_StdioStream),
src/clibincl/stream.inl, src/stdio/common/stream.cxx:
Clarify some comments and get the CYGDBG_DEFINE_CHECK_THIS and
CYG_ASSERTCLASS stuff going
 
* src/clibincl/stream.inl:
Put '{'s on same line as "action" as per coding standards
Shorten over-long lines
 
Tue Jul 28 15:31:06 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/clibincl/streambuf.inl, src/stdio/common/streambuf.cxx:
Move set_buffer() from streambuf.inl to new file streambuf.cxx
 
* src/PKGconf.mak (COMPILE):
Build new file streambuf.cxx
 
* src/clibincl/streambuf.hxx (class Cyg_StdioStreamBuffer):
Add METHODS comment
 
* src/stdio/common/stream.cxx:
Put '{'s on same line as "action" as per coding standards
Shorten over-long lines
 
Tue Jul 28 00:26:36 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/stdlib.inl, src/stdio/input/vfscanf.cxx,
src/stdio/output/vfnprintf.cxx, src/stdlib/div.cxx,
src/stdlib/ldiv.cxx, src/stdlib/qsort.cxx, src/stdlib/strtol.cxx,
src/stdlib/strtoul.cxx, src/string/strtok.cxx:
 
Include proper Berkeley license inline in the file, rather than
referring to an external file
 
* doc/COPYING.UCB:
Remove, now that it isn't referred to any more
 
Mon Jul 27 23:34:26 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/ctype.h, include/ctype.inl, include/errno.h,
include/stdio.h, include/stdio.inl, include/stdlib.h,
include/stdlib.inl, include/string.h, include/string.inl,
include/time.h, include/sys/file_if.h, src/PKGconf.mak,
src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl,
src/clibincl/ctypesupp.hxx, src/clibincl/stdiosupp.hxx,
src/clibincl/stream.hxx, src/clibincl/streambuf.hxx,
src/clibincl/streambuf.inl, src/clibincl/stringsupp.hxx,
src/clibincl/timesupp.hxx, src/ctype/isalnum.cxx,
src/ctype/isalpha.cxx, src/ctype/iscntrl.cxx,
src/ctype/isdigit.cxx, src/ctype/isgraph.cxx,
src/ctype/islower.cxx, src/ctype/isprint.cxx,
src/ctype/ispunct.cxx, src/ctype/isspace.cxx,
src/ctype/isupper.cxx, src/ctype/isxdigit.cxx,
src/ctype/tolower.cxx, src/ctype/toupper.cxx,
src/errno/errno.cxx, src/stdio/common/snprintf.cxx,
src/stdio/common/sprintf.cxx, src/stdio/common/sscanf.cxx,
src/stdio/common/stdioinlines.cxx, src/stdio/common/stream.cxx,
src/stdio/common/ungetc.cxx, src/stdio/common/vsnprintf.cxx,
src/stdio/common/vsscanf.cxx, src/stdio/input/fgetc.cxx,
src/stdio/input/fgets.cxx, src/stdio/input/fscanf.cxx,
src/stdio/input/gets.cxx, src/stdio/input/scanf.cxx,
src/stdio/output/fnprintf.cxx, src/stdio/output/fprintf.cxx,
src/stdio/output/fputc.cxx, src/stdio/output/fputs.cxx,
src/stdio/output/printf.cxx, src/stdlib/_exit.cxx,
src/stdlib/abs.cxx, src/stdlib/atof.cxx, src/stdlib/atoi.cxx,
src/stdlib/atol.cxx, src/stdlib/div.cxx, src/stdlib/labs.cxx,
src/stdlib/ldiv.cxx, src/stdlib/rand.cxx, src/stdlib/strtod.cxx,
src/string/memchr.cxx, src/string/memcmp.cxx,
src/string/memmove.cxx, src/string/strcat.cxx,
src/string/strchr.cxx, src/string/strcmp.cxx,
src/string/strcoll.cxx, src/string/strcpy.cxx,
src/string/strcspn.cxx, src/string/strlen.cxx,
src/string/strncat.cxx, src/string/strncmp.cxx,
src/string/strncpy.cxx, src/string/strpbrk.cxx,
src/string/strrchr.cxx, src/string/strspn.cxx,
src/string/strstr.cxx, src/string/strsuppt.cxx,
src/string/strtok.cxx, src/string/strxfrm.cxx,
src/support/clibdata.cxx, src/time/clock.cxx:
Untabify
 
Mon Jul 27 23:14:18 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/errno/errno.cxx, src/stdio/input/vfscanf.cxx,
src/stdio/output/vfnprintf.cxx, src/stdlib/strtol.cxx,
src/stdlib/strtoul.cxx, src/stdlib/malloc.cxx, src/stdlib/qsort.cxx,
tests/ctype/ctype.c, tests/stdlib/rand3.c, tests/stdlib/malloc3.c:
Remove all mentions of "register" in variable declarations. Also
untabify where needed
 
* src/stdlib/bsearch.cxx:
Untabify this too
 
Mon Jul 27 22:18:51 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/stdio/output/fputc.cxx (_fputc):
Replace call to stream write() with call to write_byte()
 
* src/clibincl/stream.inl (write_byte):
Add asserts for stream write() returning odd values for how much has
been written
(bytes_available_to_read):
Remove "register" def for variable declaration
 
Mon Jul 27 22:06:22 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/stdio/common/stdiosupp.cxx:
Remove #if 0'd cyg_get_file_star() and unnecessary pseudo string
device definition
 
Mon Jul 27 21:57:25 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/pkgconf/libc.h, src/support/clibdata.cxx:
Change CYGXXX_LIBC_STDIO_DEFAULT_CONSOLE to
CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE
 
Mon Jul 27 21:49:23 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl,
src/clibincl/ctypesupp.hxx, src/clibincl/setjmpsupp.hxx,
src/clibincl/stdiosupp.hxx, src/clibincl/stdlibsupp.hxx,
src/clibincl/stream.hxx, src/clibincl/stream.inl,
src/clibincl/streambuf.hxx, src/clibincl/streambuf.inl,
src/clibincl/stringsupp.hxx, src/clibincl/timesupp.hxx:
 
Change CYGONCE_LIBC_*_{HXX,INL} to CYGONCE_LIBC_CLIBINCL_*_{HXX,INL}
 
Mon Jul 27 21:34:05 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/pkgconf/libc.h:
Change #define XXXXX 1 to #define XXXXX where applicable as per code
review
 
Also remove obsolete CYGIMP_LIBC_THREAD_START_SUSPENDS_SELF
 
Mon Jul 27 19:42:27 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/stdio/common/fopen.cxx (_fopen):
Use #ifdef, not #if for config options
 
Mon Jul 27 15:01:51 BST 1998 Chris Provenzano <proven@cygnus.com>
 
* src/stdio/common/stream.cxx, src/stdio/common/vsnprintf.cxx
* src/stdio/common/vsscanf.cxx:
Fixes to compile with the new Cyg_IORB field names.
Thu Jul 9 03:40:21 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* tests/stdlib/atoi.c, tests/stdlib/atol.c,
tests/stdlib/strtol.c, tests/stdlib/strtoul.c:
Adjust starting of tests to possibly start scheduler since
strtol/stroul rely on errno, which may be a per-thread variable
 
Thu Jul 9 03:06:25 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/clibincl/stream.hxx, src/clibincl/stream.inl,
src/stdio/common/stream.cxx, src/stdio/common/setvbuf.cxx:
Consolidate read and write buffers into single buffer, as it should
have been all along
 
* src/clibincl/streambuf.hxx, src/clibincl/streambuf.inl:
Add drain_buffer() method to speed up the case when we want the
buffer completely emptied
 
Tue Jul 7 21:26:33 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* tests/stdio/sprintf1.c:
Add a couple of new tests that check that very long strings work too
 
Wed Jul 1 19:52:39 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/clibincl/stream.hxx, src/clibincl/streambuf.hxx:
Do not permit copy constructors
 
* src/clibincl/stream.inl, src/stdio/common/fclose.cxx:
Make sure we use #ifdef and not #if
 
* src/clibincl/streambuf.inl:
Use member initialisation list rather than explicit initialisation to
reduce warnings
 
Wed Jul 1 19:17:55 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/pkgconf/libc.h and all files using config options:
Rename configuration defines to make them more standard
 
Thu Jun 25 20:09:30 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/string/strcat.cxx:
Add parentheses on check to silence warning
(Verified by proven)
 
Thu Jun 25 19:30:01 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/stdlib/malloc.cxx:
Make sure that the malloc pool is initialised before other things
can use it. This is done with the hot new constructor ordering
feature.
 
Thu Jun 25 18:27:03 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/stdio/input/vfscanf.cxx:
Remove bogus ifdef if floating point is _not_ wanted
 
Thu Jun 25 17:31:42 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/string/strtok.cxx:
Fix argument checking to allow first argument of NULL
 
Thu Jun 25 04:18:50 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/clibincl/clibdata.inl (get_strtok_last_p):
Remove bogus assertion
 
* src/stdlib/malloc.cxx:
Got sense of alignment check assertion the wrong way round, so negate
it
 
Thu Jun 25 03:56:35 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/string/strxfrm.cxx:
Fix argument checking assertions with legitimate nulls here too
 
Thu Jun 25 03:46:32 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/stdlib/strtoul.cxx, src/stdlib/strtol.cxx:
Fix argument checking assertions to cope with legitimate nulls
 
Wed Jun 24 09:01:45 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* tests/stdio/sprintf1.c:
Remove extraneous info messages
 
Wed Jun 24 05:59:17 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* tests/stdio/sprintf1.c, tests/stdio/sprintf2.c, tests/stdio/sscanf.c,
tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c,
tests/stdlib/srand.c:
 
Change large automatic arrays to static arrays to prevent overuse
of a potentially small stack
 
Wed Jun 24 05:45:28 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* tests/stdio/sprintf1.c, tests/stdio/sprintf2.c, tests/stdio/sscanf.c,
tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c,
tests/stdlib/srand.c, tests/string/strtok.c, tests/time/clock.c:
 
Increase thread stack size from 4K to 32K as in some cases it was
too small.
 
 
Tue Jun 23 20:12:31 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* tests/stdio/sscanf.c:
Add extra tests, including floating point conversion testing
 
Tue Jun 23 17:01:06 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/string/strtok.cxx:
Make sure this is only compiled if CYGFUN_LIBC_strtok is defined
 
Tue Jun 23 06:10:13 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/pkgconf/libc.h:
add some comments - that's all
 
* src/stdio/common/stream.cxx:
fix case in refill_read_buffer() for what to do when there's nothing
left. Now return EAGAIN
 
* src/stdio/common/vsscanf.cxx, src/stdio/input/vfscanf.cxx:
Get sscanf working properly and passing tests. Also make sure it
ignores FP when its not configured
 
* src/stdlib/atof.cxx:
Only compile at all if strtod() is present
 
Mon Jun 22 19:13:42 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl:
Conditionalise strtok_last and rand_seed better
 
Mon Jun 22 14:14:12 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* tests/stdlib/malloc3.c:
Add test for checking that mallocing and freeing repeatedly works
 
* tests/PKGconf.mak:
Update to reflect addition of the above
 
Mon Jun 22 13:09:33 BST 1998 Chris Provenzano <proven@cygnus.com>
 
* src/stdio/common/fopen.cxx
* src/stdio/common/stream.cxx
* src/stdio/common/vsnprintf.cxx
* src/stdio/common/vsscanf.cxx
Include cyg/devs/common/iorb.h instead of iorb.hxx
 
* src/stdio/common/stream.cxx
Use read_blocking and write_blocking instead of just read and
write when accessing devices through the virtual device table.
 
Sun Jun 21 18:19:13 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/stdio/common/stdioinlines.cxx:
Propagate change of return code handling for puts from stdio.inl
into here
 
* src/stdio/output/fputc.cxx:
make sure the right type is used for output - byte not int
 
* src/support/clibdata.cxx:
Fix #define config mistook. #endif was in wrong place
 
Sun Jun 21 16:11:04 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/clibincl/clibdata.hxx, src/clibincl/clibdata.inl:
Allow explicit construction to get around a bug when
dynamically allocating per-thread structure
 
Sun Jun 21 16:02:51 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* tests/ctype/ctype.c, tests/setjmp/setjmp.c, tests/stdio/sprintf1.c,
tests/stdio/sprintf2.c, tests/stdio/sscanf.c, tests/stdlib/abs.c,
tests/stdlib/atoi.c, tests/stdlib/atol.c, tests/stdlib/bsearch.c,
tests/stdlib/div.c, tests/stdlib/labs.c, tests/stdlib/ldiv.c,
tests/stdlib/malloc1.c, tests/stdlib/malloc2.c, tests/stdlib/qsort.c,
tests/stdlib/rand1.c, tests/stdlib/rand2.c, tests/stdlib/rand3.c,
tests/stdlib/srand.c, tests/stdlib/strtol.c, tests/stdlib/strtoul.c,
tests/string/memchr.c, tests/string/memcmp1.c,
tests/string/memcmp2.c, tests/string/memcpy1.c,
tests/string/memcpy2.c, tests/string/memmove1.c,
tests/string/memmove2.c, tests/string/memset.c,
tests/string/strcat1.c, tests/string/strcat2.c,
tests/string/strchr.c, tests/string/strcmp1.c,
tests/string/strcmp2.c, tests/string/strcoll1.c,
tests/string/strcpy1.c, tests/string/strcpy2.c,
tests/string/strcspn.c, tests/string/strlen.c,
tests/string/strncat1.c, tests/string/strncat2.c,
tests/string/strncpy1.c, tests/string/strncpy2.c,
tests/string/strpbrk.c, tests/string/strrchr.c,
tests/string/strspn.c, tests/string/strstr.c, tests/string/strtok.c,
tests/string/strxfrm1.c, tests/string/strxfrm2.c, tests/time/clock.c:
 
Update tests to "do the right thing" with all configuration settings
 
 
Sun Jun 21 04:54:14 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* tests/setjmp/setjmp.c:
I have to be careful not to use setjmp() in a way not exactly
defined by the standard, so make sure I do, and add a comment
documenting these ways.
 
Also ensure this test does the right thing in all configurations
 
Sun Jun 21 04:38:15 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/pkgconf/libc.h:
Add extra checks for invalid configurations
Also make default for thread safety OFF
 
* src/clibincl/clibdata.inl:
Adjust indentation
 
* src/stdio/output/vfnprintf.cxx:
Make printf of -0.0 floating point do the right thing
 
Sun Jun 21 04:28:00 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/stdio/common/snprintf.cxx, src/stdio/common/sprintf.cxx,
src/stdio/common/sscanf.cxx, src/stdio/input/fscanf.cxx,
src/stdio/input/scanf.cxx, src/stdio/output/fnprintf.cxx,
src/stdio/output/fprintf.cxx, src/stdio/output/printf.cxx:
 
Had to remove inline functions with varargs. Which means separating
out each function from stdioinlines.cxx into a separate file, as they
no longer belong there. So all the above files were created.
 
* include/stdio.inl, src/PKGconf.mak,
src/stdio/common/stdioinlines.cxx:
Changed to take account of the above
 
 
Sun Jun 21 03:58:42 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* tests/stdio/sprintf1.c, tests/stdio/sprintf2.c:
Update with floating-point tests. Also make sure they DTRT in all
configurations
 
Fri Jun 19 19:33:06 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/support/clibdata.cxx:
accidentally initialised stdin/out/err twice
 
Fri Jun 19 19:09:29 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/support/clibdata.cxx:
Another typo
 
Fri Jun 19 18:59:07 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/support/clibdata.cxx:
Missing #endif typo
 
Fri Jun 19 18:51:42 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/support/clibdata.cxx:
Fix initialisation of static data members. Unsure how it worked at
all before!
 
Fri Jun 19 18:01:01 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/stdio.inl:
puts should check whether fputs returns non-negative, rather than
non-zero
 
Fri Jun 19 17:22:52 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/clibincl/clibdata.inl:
Make inclusion of get_errno_p conditional on thread-safety
 
Wed Jun 17 10:55:32 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/stdio/input/vfscanf.cxx:
Add weak alias of vfscanf() to _vfscanf()
 
Wed Jun 17 09:10:41 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/stdio/common/fflush.cxx:
Initialise err to silence compiler warning
 
Wed Jun 17 08:59:20 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* Most important is the addition of floating point support in
src/stdio/output/vfnprintf.cxx and src/stdio/input/vfscanf.cxx. This
also required the addition of atof() and strtod() in stdlib which is
definitely no bad thing! Other than that...
* Fix a whole bunch of stuff I messed up first time round. Also the
sprintf and sscanf tests are included again.
 
Tue Jun 16 16:38:02 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* tests/PKGconf.mak:
Typo with not putting comment character at the beginning. Sigh.
 
Tue Jun 16 14:53:09 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* tests/PKGconf.mak:
Forgot to (temporarily) remove fputs test for now
 
Mon Jun 15 20:40:03 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
Everything to do with stdio has almost completely changed, so there's
not much point documenting individual changes.
 
Mon Jun 15 18:36:01 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* tests/stdlib/malloc2.c:
Stop it moaning quite as much when it fails by making it exit sooner
 
* tests/time/clock.c :
This isn't a compound testcase
 
Thu Jun 11 17:59:13 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/assert.h
Reverse sense of NDEBUG ifdef, that was left in accidentally due
to testing
 
Thu Jun 11 04:58:08 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/errno.h, include/string.h, src/clibincl/stringsupp.hxx:
Modify as I've now added an "error" package which defines the error
codes and strerror()
 
* src/errno/strerror.cxx:
Moved to new error package and thus deleted
 
Wed Jun 10 18:37:37 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/assert.h:
create this header and add assert() function
 
Wed Jun 10 16:23:57 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/stdlib.h, src/clibincl/stdlibsupp.hxx, src/stdlib/malloc.cxx:
Add malloc(), calloc() and free() functions
 
* include/pkgconf/libc.h:
Add malloc memory pool size option
 
* tests/stdlib/malloc1.c, tests/stdlib/malloc2.c:
new tests for malloc
 
* src/PKGconf.mak, tests/PKGconf.mak:
Update for new files
Wed Jun 10 15:06:16 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* tests/setjmp/setjmp.c:
Add another test
 
Tue Jun 9 18:20:31 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/pkgconf/libc.h:
Add some setjmp config's and a macro for the noreturn attribute
 
* include/setjmp.h, include/setjmp.inl, src/clibincl/setjmpsupp.hxx,
src/setjmp/longjmp.cxx, tests/setjmp/setjmp.c:
Added to implement and test setjmp() and longjmp()
 
* src/PKGconf.mak, tests/PKGconf.mak:
Update for newly added files
 
Thu Jun 4 01:29:18 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/string/memchr.cxx, src/string/memcmp.cxx, src/string/strcat.cxx,
src/string/strchr.cxx, src/string/strcmp.cxx, src/string/strcpy.cxx,
src/string/strlen.cxx, src/string/strncat.cxx,
src/string/strncmp.cxx, src/string/strncpy.cxx:
Rename CYGIMP_LIBC_PREFER_SMALL_TO_FAST to
CYGIMP_LIBC_STRING_PREFER_SMALL_TO_FAST
 
Also use slower but smaller version when __OPTIMIZE_SIZE__ is
defined (which comes from using gcc -Os)
 
Fri May 29 16:15:04 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/ctype.inl, src/ctype/isxdigit.cxx:
Fix bug that numerals aren't considered hex digits
 
* include/time.h:
Change clock_t and time_t to be signed so that they can accept -1, as
required by other libc functions
 
* src/clibincl/clibdata.hxx:
Fix typo that CYGIMP_LIBC_THREAD_SUPPORT should be ..._SAFETY
Also fix macro to allocate thread-specific data to not set variables
in a different stack-frame
 
* tests/ctype/ctype.c:
Fix some misunderstandings in tests, and add a few new ones
 
* tests/stdlib/qsort.c:
make ctr unsigned to prevent warnings
 
* tests/stdlib/strtol.c, tests/stdlib/strtoul.c:
Fix some misunderstandings in tests, and add a few new ones
 
* tests/string/strrchr.c:
Fix off by one error
 
* tests/string/strspn.c:
Fix case-sensitivity problem, and off-by-one error
 
* tests/string/strxfrm1.c:
Remove bogus bit of test that doesn't apply to strxfrm, and fix typo
 
 
Fri May 22 16:33:04 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/PKGconf.mak
Remove CXXFLAGS line now that its redundant
* tests/everything!
Do a blitz change of all tests - break some of them down into
different files, add new tests, standardize format, fix bugs,
update for recent header file changes and much more!
 
Wed May 20 17:50:04 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* tests/PKGconf.mak:
interim checkin for different dir structure for Bart
 
Fri May 15 20:30:46 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* Tidy up some loose ends I forgot: rename src/include directory to
src/clibincl. And add clibdata.inl and timesupp.hxx in there.
 
Thu May 14 19:56:32 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* Basically everything has changed in the C library. Files have
been moved, renamed, deleted and reworked. This is a major
revision, and now starts from this new baseline rather than doing
incremental changes.
 
Fri Apr 17 18:43:02 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/ECCconf.mak:
added for new build system (actually Bart did this, but didn't
update this ChangeLog)
 
Fri Apr 17 15:03:25 1998 Hugo Tyson <hmt@cygnus.co.uk>
 
* src/stdio/device/sim.cxx:
Make it build with CYG_EMPTY_STATEMENT; the unadorned one is being
removed.
 
Thu Apr 16 00:24:24 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* All source files:
replace ECCIMP_LIBC_* conditional ifdef with CYGIMP_LIBC_*
 
* include/eccconf/libc.h:
improve comments and reorder a bit
 
Wed Apr 8 14:35:20 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* Makefile.am, src/Makefile.am, tests/Makefile.am, configure.in:
many changes to integrate build structure from release tree
 
* src/ctype/Makefile.am, src/ctype/Makefile.in, src/errno/Makefile.am,
src/errno/Makefile.in, src/stdio/Makefile.am, src/stdio/Makefile.in,
src/stdio/common/Makefile.am, src/stdio/common/Makefile.in,
src/stdio/device/Makefile.am, src/stdio/device/Makefile.in,
src/stdio/output/Makefile.am, src/stdio/output/Makefile.in,
src/stdio/input/Makefile.am, src/stdio/input/Makefile.in,
src/stdlib/Makefile.am, src/stdlib/Makefile.in,
src/string/Makefile.am, src/string/Makefile.in,
src/support/Makefile.am, src/support/Makefile.in,
src/time/Makefile.am, src/time/Makefile.in:
Remove as they are now redundant with above changes
* include/Makefile.am:
Add to support above changes
 
* include/eccconf/libc.h:
Change include file for configuration from kernel to system
 
* src/include/kerndiag.hxx, src/stdio/device/kerndiag.cxx,
src/time/clockfn.cxx:
Change kernel include file to eccconf/kernel.h
 
* src/include/strngdev.h:
remove unnecessary kernel include
* Makefile.in, aclocal.m4, configure, src/Makefile.in,
tests/Makefile.in, include/Makefile.in:
regenerate
 
Mon Apr 6 20:55:07 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/stdlib/abs.cxx, src/stdlib/atoi.cxx, src/stdlib/atol.cxx,
src/stdlib/div.cxx, src/stdlib/labs.cxx, src/stdlib/ldiv.cxx:
Separated out functions from stdlib.cxx into separate files
 
* src/stdlib/stdlib.cxx:
removed to be replaced by above files
* Makefile.am, src/stdlib/Makefile.am:
modified to support building above and not building stdlib.cxx
 
* src/support/tsd.cxx:
Remove unnecessary header file includes
 
* Makefile.in, src/stdlib/Makefile.in:
regenerated
 
Mon Apr 6 19:19:42 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/support/tsd.cxx, include/eccconf/libc.h:
remove lame hack for tx39 compiler now that its fixed
 
* src/include/sim.hxx:
define constants as static to placate compiler
 
Thu Apr 2 21:01:21 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/ctype/ctype.cxx:
deleted and separated out into below files
* src/ctype/isalnum.cxx, src/ctype/isalpha.cxx, src/ctype/iscntrl.cxx,
src/ctype/isdigit.cxx, src/ctype/isgraph.cxx, src/ctype/islower.cxx,
src/ctype/isprint.cxx, src/ctype/ispunct.cxx, src/ctype/isspace.cxx,
src/ctype/isupper.cxx, src/ctype/isxdigit.cxx, src/ctype/tolower.cxx,
src/ctype/toupper.cxx:
Separated out individual ctype functions from ctype.cxx into separate
files
 
* Makefile.am, src/ctype/Makefile.am:
modified to reflect above deletion/additions
 
* Makefile.in, src/ctype/Makefile.in:
regenerated
Thu Apr 2 19:08:26 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/string/strxfrm.cxx: optimise using prefix increments
 
Thu Apr 2 15:18:15 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/string/strchr.cxx: optimise setting of mask a little
 
Thu Mar 26 14:07:01 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/support/tsd.cxx: fixed some typos
 
Thu Mar 26 11:58:47 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/eccconf/libc.h, src/support/tsd.cxx:
Implement workaround for tx39 compiler bug.
 
* src/include/strsuppt.hxx:
remove prototypes for _memcpy() and _memset() as they are now in the
kernel
 
Wed Mar 25 18:31:53 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* Makefile.am, src/string/Makefile.am: memcpy() and memset() are
now in the kernel so remove them from build
* include/string.h: add a comment to say as much
* Makefile.in, src/string/Makefile.in: regenerate
 
Wed Mar 25 15:30:42 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/stdlib/_exit.cxx, src/include/file_if.inl:
Change _exit workaround to not cause a compiler optimisation
problem. Now just references _exit rather than calls it.
 
Wed Mar 25 14:59:49 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/string/strxfrm.cxx: Fix bug causing tests to fail completely
for this function
 
Wed Mar 25 12:55:53 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/include/sim.hxx: add types to constants (oops!)
* Makefile.am: link src/stdio/device/sim.cxx
* Makefile.in: regenerated
 
Wed Mar 25 04:14:30 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/include/file_if.hxx, src/include/file_if.inl,
src/include/kerndiag.hxx, src/include/sim.hxx,
src/include/stdio_if.hxx, src/include/strngdev.hxx,
src/include/tsd.hxx, src/stdio/common/clearerr.cxx,
src/stdio/common/clearerr.cxx, src/stdio/common/feof.cxx,
src/stdio/common/ferror.cxx, src/stdio/common/file_if.cxx,
src/stdio/common/vsprintf.cxx,
src/stdio/device/kerndiag.cxx, src/stdio/device/sim.cxx,
src/stdio/device/strngdev.cxx, src/stdio/output/fputc.cxx,
src/stdio/output/fputs.cxx, src/stdio/output/puts.cxx,
src/stdio/output/vfnprintf.cxx, src/support/tsd.cxx:
Modified to support buffered reads including renaming
_EccInternalFileStruct to __EccStdioStream which is what affects
most of these files
* src/include/file_if.inl, src/stdio/common/file_if.cxx: added for
the above reason
* src/stdio/common/sscanf.cxx, src/stdio/input/vfscanf.cxx,
src/stdio/input/Makefile.am: added to provide sscanf() functionality
* include/ctype.h, include/stdio.h, include/stdlib.h,
include/string.h, include/eccconf/libc.h, src/ctype/ctype.cxx,
src/stdlib/stdlib.cxx, src/string/strcoll.cxx,
src/stdio/common/stdio.cxx:
rename *_INLINES macros with prefix CYG rather than ECC
* include/errno.h, src/errno/errno.cxx, src/errno/strerror.cxx:
rename ErrNo to _ErrNo and add EAGAIN and EWOULDBLOCK error codes
* configure.in, Makefile.am, src/stdio/Makefile.am,
src/stdio/input/Makefile.am: add support for building
file_if.cxx sscanf.cxx and vfscanf.cxx
* src/stdio/Makefile.in, src/stdio/common/Makefile.in,
src/stdio/input/Makefile.in, configure, Makefile.in: regenerated
 
Tue Mar 24 19:51:40 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/time/clockfn.cxx, src/time/clock.cxx:
Renamed clock.cxx to clockfn.cxx (preserving CVS history)
* Makefile.am, src/time/Makefile.am: updated to reflect name change
* Makefile.in, src/time/Makefile.in: regenerated
 
Tue Mar 24 16:28:06 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/ctype.inl: Swap around definitions to get right order so
inlining works
 
Tue Mar 24 14:43:05 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/ctype.h, include/stdio.h, include/stdlib.h, include/string.h:
modify to only conditionally include inlines
* src/ctype/ctype.cxx, src/stdio/common/stdio.cxx,
src/stdlib/stdlib.cxx, src/string/strcoll.cxx,
src/ctype/Makefile.am: Add to provide real linkable alternatives
to inline functions
* Makefile.am, configure.in, src/Makefile.am,
src/stdio/common/Makefile.am, src/stdlib/Makefile.am,
src/string/Makefile.am: modified to support previous additions
* include/eccconf/libc.h: redefine inline macro to add extern inline,
and add conditional defines for inline functions. Also rename
space vs. speed macro to have CYG instead of ECC prefix
* include/stdio.inl: fix comment typo
* src/stdlib/qsort.cxx: fix to define inline functions properly
* src/string/memchr.cxx, src/string/memcmp.cxx, src/string/memcpy.cxx,
src/string/memset.cxx, src/string/strcat.cxx, src/string/strchr.cxx,
src/string/strcmp.cxx, src/string/strcpy.cxx, src/string/strlen.cxx,
src/string/strncat.cxx, src/string/strncmp.cxx,
src/string/strncpy.cxx
* Makefile.in, configure, src/Makefile.in, src/ctype/Makefile.in,
src/stdio/common/Makefile.in, src/stdlib/Makefile.in,
src/string/Makefile.in: regenerate
 
Mon Mar 23 19:19:49 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/stdlib/_exit.cxx: added to support temporary _exit
* include/stdlib.h, include/stdlib.inl: added support for _exit and
added abs(), labs(), div() and ldiv() functions
* src/include/file_if.hxx: added support for _exit kludge
* src/stdlib/qsort.cxx: Added Berkeley copyright message
* src/time/clock.cxx: Include correct kernel config header as
CYG_CONFIGURATION rather than <config.h>
* Makefile.am src/stdlib/Makefile.am: added support for _exit
* Makefile.in, src/stdlib/Makefile.in: regenerated
 
Mon Mar 23 14:41:07 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* Replace ECCPKG_ANSI_LIBC with CYGPKG_ANSI_LIBC in all source files
 
Mon Mar 23 14:28:44 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/string.inl: add file to provide strcoll()
* include/string.h: include string.inl
* ctype.h: include ctype.inl (oops!)
* include/stdlib.h: include stdlib.inl (oops!)
 
Mon Mar 23 13:30:38 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/ctype.h, include/ctype.inl: added to provide ANSI ctype
functionality
* include/stdlib.h, include/stdlib.inl, src/include/stdlibbsp.hxx,
src/stdlib/Makefile.am, src/stdlib/bsearch.cxx,
src/stdlib/qsort.cxx, src/stdlib/rand.cxx, src/stdlib/srand.cxx,
src/stdlib/strtol.cxx, src/stdlib/strtoul.cxx: Added to provide
many stdlib functions
* src/include/tsd.hxx: modified to support rand() random number
seed, and added some comments
* configure.in, Makefile.am, src/Makefile.am: modified to support
addition of above new sources
* include/eccconf/libc.h: Add extra helpful comments, and #include
kernel config file
* src/time/clock.cxx: #include clock.inl and fix to call
get_resolution() properly now
* Makefile.in, configure, src/Makefile.in, src/errno/Makefile.in,
src/stdio/Makefile.in, src/stdio/common/Makefile.in,
src/stdio/device/Makefile.in, src/stdio/output/Makefile.in,
src/stdlib/Makefile.in, src/strings/Makefile.in,
src/support/Makefile.in, src/time/Makefile.in,
tests/Makefile.in: regenerated
 
Sun Mar 22 21:29:25 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* include/time.h, src/include/timesupp.hxx, src/time/clock.cxx,
src/time/Makefile.am: added to provide clock() function
* src/Makefile.am: modified to try to build in src/time directory
* include/eccconf/libc.h: added and is now the main configuration
file for this package
* acconfig.h, include/libcconf.h.in, include/stamp-h.in: removed
due to usage of libc.h above instead
* Almost all *.h, *.hxx and *.cxx: replaced LIBC_CONFIG_HEADER
defined include with simple <pkgconf/libc.h>
* configure.in: remove AM_CONFIG_HEADER of libcconf.h and
LIBC_CONFIG_HEADER definition. Also remove usage of builtin
memcpy() etc. from gcc, and generate src/time/Makefile
* Makefile.am: link in src/time/clock.o
* src/include/file_if.hxx, src/include/sim.hxx: use config header
to decide whether C library is to be used
* Makefile.in, aclocal.m4, configure, src/Makefile.in: regenerated
 
Fri Mar 20 18:08:10 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* src/string/strxfrm.cxx: Fixed bug with ignoring terminating NULL
 
1998-03-20 Chris Tarpy <ctarpy@bhaji.cygnus.co.uk>
 
* configure: - regenerated
* Makefile.am: - Support added for libc testcases
* Makefile.in: regenerated
* configure.in: set c compiler, descend test dir
* tests/Makefile.in: added
* tests/Makefile.am: added
* tests/tcdiag.cxx : added
 
 
Thu Mar 19 11:41:56 1998 Jonathan Larmour <jlarmour@cygnus.co.uk>
 
* Initial check-in of everything
 
//===========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//===========================================================================
/v2_0/cdl/stdio.cdl
0,0 → 1,412
# ====================================================================
#
# stdio.cdl
#
# C library stdio related configuration data
#
# ====================================================================
#####ECOSGPLCOPYRIGHTBEGIN####
## -------------------------------------------
## This file is part of eCos, the Embedded Configurable Operating System.
## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
##
## eCos is free software; you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free
## Software Foundation; either version 2 or (at your option) any later version.
##
## eCos is distributed in the hope that it will be useful, but WITHOUT ANY
## WARRANTY; without even the implied warranty of MERCHANTABILITY or
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
## for more details.
##
## You should have received a copy of the GNU General Public License along
## with eCos; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
##
## As a special exception, if other files instantiate templates or use macros
## or inline functions from this file, or you compile this file and link it
## with other works to produce a work based on this file, this file does not
## by itself cause the resulting work to be covered by the GNU General Public
## License. However the source code for this file must still be made available
## in accordance with section (3) of the GNU General Public License.
##
## This exception does not invalidate any other reasons why a work based on
## this file might be covered by the GNU General Public License.
##
## Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
## at http://sources.redhat.com/ecos/ecos-license/
## -------------------------------------------
#####ECOSGPLCOPYRIGHTEND####
# ====================================================================
######DESCRIPTIONBEGIN####
#
# Author(s): jlarmour
# Contributors:
# Date: 2000-04-14
#
#####DESCRIPTIONEND####
#
# ====================================================================
 
cdl_package CYGPKG_LIBC_STDIO {
display "ISO C library standard input/output functions"
description "
This package provides standard input/output functions associated
with the header file <stdio.h> as specified by the
ISO C standard - ISO/IEC 9899:1990."
doc ref/libc.html
include_dir cyg/libc/stdio
parent CYGPKG_LIBC
requires CYGPKG_IO
requires CYGPKG_IO_SERIAL_HALDIAG
requires CYGPKG_LIBC_I18N
implements CYGINT_ISO_STDIO_FILETYPES
implements CYGINT_ISO_STDIO_FILEACCESS
implements CYGINT_ISO_STDIO_FORMATTED_IO
implements CYGINT_ISO_STDIO_CHAR_IO
implements CYGINT_ISO_STDIO_DIRECT_IO
implements CYGINT_ISO_STDIO_ERROR
implements CYGINT_ISO_STDIO_STREAMS
requires { CYGBLD_ISO_STDIO_FILETYPES_HEADER == \
"<cyg/libc/stdio/stdio.h>" }
requires { CYGBLD_ISO_STDIO_FILEACCESS_HEADER == \
"<cyg/libc/stdio/stdio.h>" }
requires { CYGBLD_ISO_STDIO_FORMATTED_IO_HEADER == \
"<cyg/libc/stdio/stdio.h>" }
requires { CYGBLD_ISO_STDIO_CHAR_IO_HEADER == \
"<cyg/libc/stdio/stdio.h>" }
requires { CYGBLD_ISO_STDIO_DIRECT_IO_HEADER == \
"<cyg/libc/stdio/stdio.h>" }
requires { CYGBLD_ISO_STDIO_ERROR_HEADER == \
"<cyg/libc/stdio/stdio.h>" }
requires { CYGBLD_ISO_STDIO_STREAMS_HEADER == \
"<cyg/libc/stdio/stdio.h>" }
requires CYGPKG_ISOINFRA
requires CYGINT_ISO_ERRNO_CODES
requires CYGINT_ISO_ERRNO
requires CYGINT_ISO_STRERROR
requires CYGINT_ISO_STRING_STRFUNCS
requires CYGINT_ISO_STRING_MEMFUNCS
# The following is for scanf only. We could express this better,
# particularly since scanf is also dependent on the optional ungetc.
requires CYGINT_ISO_STDLIB_STRCONV
 
compile common/fclose.cxx common/feof.cxx \
common/fflush.cxx common/fopen.cxx \
common/freopen.cxx common/setvbuf.cxx \
common/snprintf.cxx common/sprintf.cxx \
common/sscanf.cxx common/stderr.cxx \
common/stdin.cxx common/stdiofiles.cxx \
common/fseek.cxx common/stdioinlines.cxx\
common/stdiosupp.cxx common/stdout.cxx \
common/stream.cxx common/streambuf.cxx \
common/ungetc.cxx common/vsnprintf.cxx \
common/vsscanf.cxx \
\
input/fgetc.cxx input/fgets.cxx \
input/fread.cxx input/fscanf.cxx \
input/gets.cxx input/scanf.cxx \
input/vfscanf.cxx \
\
output/fnprintf.cxx output/fprintf.cxx \
output/fputc.cxx output/fputs.cxx \
output/fwrite.cxx output/printf.cxx \
output/vfnprintf.cxx
 
# ====================================================================
 
cdl_option CYGIMP_LIBC_STDIO_INLINES {
display "Inline versions of <stdio.h> functions"
default_value 1
description "
This option chooses whether some of the
particularly simple functions from
<stdio.h> are available as inline
functions. This may improve performance, and as
the functions are small, may even improve code
size."
}
cdl_option FOPEN_MAX {
display "Permitted number of open files"
flavor data
legal_values 3 to 0x7fffffff
default_value 8
description "
This option controls the guaranteed minimum
number of simultaneously open files. The ISO
C standard requires it to be defined (para
7.9.1), and if strictly compliant, it must be
at least 8 (para 7.9.3). In practice it can be
as low as 3 - for stdin, stdout and stderr."
}
cdl_option FILENAME_MAX {
display "Maximum length of filename"
flavor data
legal_values 1 to 0x7fffffff
default_value 16
description "
This option defines the maximum allowed size of
a filename in characters. The ISO C standard
requires it to be defined (para 7.9.1)."
}
cdl_option L_tmpnam {
display "Maximum length of filenames for temporary files"
flavor data
legal_values 1 to 0x7fffffff
default_value 16
description "
This option defines the maximum allowed size of
filenames for temporary files as generated by
tmpnam(). It is measured in characters, and the
ISO C standard requires it to be defined (para
7.9.1)."
}
cdl_option TMP_MAX {
display "Unique file names generated by tmpnam()"
flavor data
legal_values 0 to 0x7fffffff
default_value 0
description "
This option defines the minimum number of
unique file names generated by tmpnam(). The
ISO C standard requires it to be defined (para
7.9.1)."
}
cdl_component CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO {
display "Buffered I/O"
flavor bool
default_value 1
description "
This option controls whether input/output
through the <stdio.h> functions is buffered.
This may save some memory per file. It
is equivalent to putting every file into
non-buffered mode (_IONBF) through setvbuf(),
except now it can never be altered back to
buffered mode. Disabling buffering is strictly
non-compliant with the ISO C standard."
cdl_option CYGNUM_LIBC_STDIO_BUFSIZE {
display "Default buffer size"
flavor data
legal_values 1 to 0x7fffffff
default_value 256
description "
This option defines the default size of buffer
used with calls to setbuf(), and is the default
size for buffered streams that have not had
either setbuf() or setvbuf() invoked on them.
It is exactly equivalent to the standard
constant BUFSIZ, except that it is 0 if
CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO is disabled.
The ISO C standard requires this to be defined
(para 7.9.1), and says it must be at least 256
(para 7.9.2)."
}
cdl_option CYGSEM_LIBC_STDIO_DYNAMIC_SETVBUF {
display "setbuf()/setvbuf() allows dynamic setting"
default_value 1
description "
This option controls whether I/O buffers are
implemented dynamically within the stdio
implementation. Otherwise they will be static,
and cannot be changed by setbuf()/setvbuf(). If
they are static (i.e. this option is disabled),
any attempt to use an arbitrary buffer size, or
to pass a user-supplied buffer to setbuf() or
setvbuf() will fail - the buffer is implemented
internally as a static array taking the size
of the configuration option BUFSIZ. The only
exception is if a user buffer is not supplied,
and the buffer size requested is less than
BUFSIZ. In this case, the buffer will
be configured to only use that amount of
buffering. However the unused memory left over
will NOT be freed. If this option is enabled,
then setvbuf() can be used to assign a user supplied
buffer to the stream.
Either setting can be considered to
be compliant with the ISO C standard."
}
 
cdl_option CYGSEM_LIBC_STDIO_SETVBUF_MALLOC {
display "setbuf()/setvbuf() uses malloc()"
requires CYGINT_ISO_MALLOC
requires CYGSEM_LIBC_STDIO_DYNAMIC_SETVBUF
default_value { 0 != CYGINT_ISO_MALLOC }
description "
This option controls whether buffers set by setbuf() and
setvbuf() may be allocated using malloc()."
}
 
}
# Define BUFSIZ with same value as ..._BUFSIZE or 0
cdl_option BUFSIZ {
display "Default buffer size (BUFSIZ)"
flavor data
calculated CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO \
? "CYGNUM_LIBC_STDIO_BUFSIZE" : 0
}
cdl_option CYGFUN_LIBC_STDIO_ungetc {
display "Support for ungetc()"
default_value 1
description "
This option controls whether ungetc() is
supported. If not, then some space can be
saved, and speed is improved. Note that you
MUST have this defined if you want to use the
scanf() family of functions."
}
cdl_option CYGPKG_LIBC_STDIO_OPEN {
display "Dynamic opening/closing of files"
requires CYGINT_ISO_MALLOC
implements CYGINT_ISO_STDIO_POSIX_FDFUNCS
default_value { 0 != CYGINT_ISO_MALLOC }
description "
fopen() and fclose() use dynamic memory
allocation routines to allocate memory for
new FILE structure pointers. If a malloc
implementation is available, this option
may be enabled to use
fopen() and fclose(). If disabled, only the
default console streams - stdin, stdout and
stderr - will be available."
}
cdl_option CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE {
display "Default console device"
flavor data
default_value CYGDAT_IO_SERIAL_TTY_CONSOLE
description "
This option allows you to choose the
default console device. In the current
implementation, all these devices begin
with the prefix /dev/ and are followed by
the name of a device. The name of the device
depends on the device drivers you have
configured in your system. For example,
/dev/ttydiag could be the HAL diagnostic output
pseudo-device, or /dev/tty0 could be your
first serial driver, depending on your
configuration."
}
cdl_component CYGPKG_LIBC_STDIO_FLOATING_POINT {
display "Floating point support"
flavor none
description "
This component allows floating point support
to be enabled in certain standard I/O
functions."
cdl_option CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT {
display "printf() family"
requires CYGPKG_LIBM
default_value { 0 != CYGPKG_LIBM }
description "
This option enables the use of floating point
number output in the printf() family (i.e.
printf(), sprintf(), vprintf(), etc.) of
functions. A substantial amount of code space
can be saved if this option is disabled. If it
is disabled then floating point specifiers
(%e, %f, %g) are ignored, and nothing is
output."
}
cdl_option CYGSEM_LIBC_STDIO_SCANF_FLOATING_POINT {
display "scanf() family"
requires CYGPKG_LIBM
requires CYGINT_ISO_STDLIB_STRCONV_FLOAT
default_value { 0 != CYGPKG_LIBM &&
0 != CYGINT_ISO_STDLIB_STRCONV_FLOAT }
description "
This option enables the use of floating point
number conversion in the scanf() family (i.e.
scanf(), sscanf(), vscanf(), etc.) of
functions. A substantial amount of code space
can be saved if this option is disabled. If it
is disabled then floating point specifiers
(%e, %f, %g) are ignored, and nothing is
converted."
}
}
cdl_option CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS {
display "Thread safe I/O streams"
doc ref/libc-thread-safety.html
requires CYGPKG_KERNEL
default_value { 0 != CYGPKG_KERNEL }
description "
This option controls whether standard I/O streams
are thread-safe. Having this option set allows
the streams to be locked when accessed by
multiple threads simultaneously."
}
 
# ====================================================================
 
cdl_component CYGPKG_LIBC_STDIO_OPTIONS {
display "C library stdio functions build options"
flavor none
no_define
description "
Package specific build options including control over
compiler flags used only in building this package,
and details of which tests are built."
 
 
cdl_option CYGPKG_LIBC_STDIO_CFLAGS_ADD {
display "Additional compiler flags"
flavor data
no_define
default_value { "" }
description "
This option modifies the set of compiler flags for
building the C library. These flags are used in addition
to the set of global flags."
}
 
cdl_option CYGPKG_LIBC_STDIO_CFLAGS_REMOVE {
display "Suppressed compiler flags"
flavor data
no_define
default_value { "" }
description "
This option modifies the set of compiler flags for
building the C library. These flags are removed from
the set of global flags if present."
}
 
cdl_option CYGPKG_LIBC_STDIO_TESTS {
display "C library stdio function tests"
flavor data
no_define
calculated { "tests/sprintf1 tests/sprintf2 tests/sscanf tests/stdiooutput" }
description "
This option specifies the set of tests for the C library
stdio functions."
}
}
 
# ====================================================================
 
cdl_option CYGPKG_LIBC_STDIO_FILEIO {
display "Enable use of FILEIO package for IO operations."
active_if CYGPKG_IO_FILEIO
requires CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO
calculated 1
}
}
 
# ====================================================================
# EOF stdio.cdl
/v2_0/tests/stdiooutput.c
0,0 → 1,208
//=================================================================
//
// stdiooutput.c
//
// Testcase for miscellaneous C library output functions
//
//=================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//=================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-20
// Description: Contains testcode for C library stdio output
// functions
//
//
//####DESCRIPTIONEND####
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
// INCLUDES
 
#include <stdio.h> // All the stdio functions
#include <errno.h> // errno
#include <cyg/infra/testcase.h> // Testcase API
 
// FUNCTIONS
 
static void
test( CYG_ADDRWORD data )
{
int i;
 
 
// Check 1
CYG_TEST_INFO("Expect: Hello printf world 42!");
printf("Hello printf %s %d!\n", "world", 42);
 
// Check 2
CYG_TEST_INFO("Expect: This is fprintf 0x07f!");
fprintf(stdout, "This is fprintf 0x%03x!\n", 0x7f);
 
// Check 3
CYG_TEST_INFO("Expect: char tests");
fputc( 'c', stderr );
putc( 'h', stdout );
putchar( 'a' );
fputc( 'r', stdout );
putchar( ' ' );
fflush(stdout);
putc( 't', stderr );
fputc( 'e', stdout );
putchar( 's' );
fflush( NULL );
putc( 't', stderr );
fputc( 's', stderr );
putchar( '\n' );
 
// Check 4
CYG_TEST_INFO("Expect: puts test");
puts("puts test");
 
// Check 5
CYG_TEST_INFO("Expect: fputs test");
fputs( "fputs test\n", stdout );
 
// Check 6
CYG_TEST_INFO("Expect: fwrite test");
fwrite( "fwrite test\n", 6, 2, stderr );
 
// Check 7
CYG_TEST_INFO("Expect: wibble: No error");
errno = ENOERR;
perror( "wibble" );
 
// Check 8
CYG_TEST_INFO("Expect: Long string test!\nSitting on the side of the "
"highway waiting to catch speeding drivers, a State "
"Police Officer sees a car puttering along at 22 MPH. "
"He thinks to himself, \"This driver is just as "
"dangerous as a speeder!\" So he turns on his lights "
"and pulls the driver over. Approaching the car, "
"he notices that there are five old ladies-two in "
"the front seat and three in the back-wide eyed and "
"white as ghosts. The driver, obviously confused, says "
"to him, \"Officer, I don't understand, I was doing "
"exactly the speed limit! What seems to be the "
"problem?\" \"Ma'am,\" the officer replies, \"you "
"weren't speeding, but you should know that driving "
"slower than the speed limit can also be a danger to "
"other drivers.\" \"Slower than the speed limit? No "
"sir, I was doing the speed limit exactly...Twenty-two "
"miles an hour!\" the old woman says a bit proudly. "
"The State Police officer, trying to contain a "
"chuckle explains to her that \"22\" was the route "
"number, not the speed limit. A bit embarrassed, the "
"woman grinned and thanked the officer for pointing "
"out her error. \"But before I let you go, Ma'am, I "
"have to ask... Is everyone in this car OK? These "
"women seem awfully shaken and they haven't muttered a "
"single peep this whole time,\" the officer asks. \"Oh, "
"they'll be all right in a minute officer. We just got "
"off Route 119\".");
 
printf("Long string test!\nSitting on the side of the "
"highway waiting to catch speeding drivers, a State "
"Police Officer sees a car puttering along at %d MPH. "
"He thinks to himself, \"This driver is just as "
"dangerous as a speeder!\" So he turns on his lights "
"and pulls the driver over. Approaching the car, "
"he notices that there are five old ladies-two in "
"the front seat and three in the back-wide eyed and "
"white as ghosts. The driver, obviously confused, says "
"to him, \"Officer, I don't understand, I was doing "
"exactly the speed limit! What seems to be the "
"problem?\" \"Ma'am,\" the officer replies, \"you "
"weren't speeding, but you should know that driving "
"slower than the speed limit can also be a danger to "
"other drivers.\" \"Slower than the speed limit? No "
"sir, I was doing the speed limit exactly...Twenty-two "
"miles an hour!\" the old woman says a bit proudly. "
"The State Police officer, trying to contain a "
"chuckle explains to her that \"%d\" was the route "
"number, not the speed limit. A bit embarrassed, the "
"%coman grinned and thanked the officer for pointing "
"out her error. \"But before I let you go, Ma'am, I "
"have to ask... Is everyone in this car OK? These "
"women seem awfully shaken and they haven't muttered a "
"single peep this whole time,\" the officer asks. \"Oh, "
"they'll be all right in a minute officer. We just got "
"off Route %d\".\n", 22, 22, 'w', 119);
 
// Check 9
CYG_TEST_INFO("Expect: Another puts test, just for fun");
puts("Another puts test, just for fun");
 
// Check 10
CYG_TEST_INFO("Expect: more fputs testing");
fputs( "more fputs testing\n", stderr );
 
// Check 11
CYG_TEST_INFO("Expect all the numbers from 1 to 100 in 5 columns");
for (i=1; i<101; ++i) {
 
printf("%5d ", i);
if (i%5 == 0)
fputc( '\n', stdout);
} // for
 
CYG_TEST_PASS("Stdio output tests completed");
CYG_TEST_FINISH("Finished tests from testcase " __FILE__
" for C library stdio output functions");
 
} // test()
 
int
main(int argc, char *argv[])
{
CYG_TEST_INIT();
 
CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C "
"library stdio output functions");
CYG_TEST_INFO("The output of these tests needs to be manually "
"verified.");
 
test(0);
 
return 0;
 
} // main()
 
// EOF stdiooutput.c
/v2_0/tests/sprintf1.c
0,0 → 1,593
//=================================================================
//
// sprintf1.c
//
// Testcase for C library sprintf()
//
//=================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//=================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): ctarpy, jlarmour
// Contributors:
// Date: 2000-04-20
// Description: Contains testcode for C library sprintf() function
//
//
//####DESCRIPTIONEND####
 
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
 
// INCLUDES
 
#include <stdio.h>
#include <cyg/infra/testcase.h>
 
// FUNCTIONS
 
// Functions to avoid having to use libc strings
 
static int my_strlen(const char *s)
{
const char *ptr;
 
ptr = s;
for ( ptr=s ; *ptr != '\0' ; ptr++ )
;
 
return (int)(ptr-s);
} // my_strlen()
 
 
static int my_strcmp(const char *s1, const char *s2)
{
for ( ; *s1 == *s2 ; s1++,s2++ )
{
if ( *s1 == '\0' )
break;
} // for
 
return (*s1 - *s2);
} // my_strcmp()
 
 
static char *my_strcpy(char *s1, const char *s2)
{
while (*s2 != '\0') {
*(s1++) = *(s2++);
}
*s1 = '\0';
 
return s1;
} // my_strcpy()
 
 
 
static void test(CYG_ADDRWORD data)
{
static char x[500];
static char y[500];
int ret;
int tmp;
int *ptr;
 
 
// Check 1
ret = sprintf(x, "%d", 20);
CYG_TEST_PASS_FAIL(my_strcmp(x, "20")==0, "%d test");
CYG_TEST_PASS_FAIL(ret==my_strlen(x), "%d test return code");
 
// Check 2
my_strcpy(y, "Pigs noses. Get 'em while there 'ot");
ret = sprintf(x, "%s", y);
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "%s test");
CYG_TEST_PASS_FAIL(ret==my_strlen(x), "%s test return code");
 
// Check 3
ret = sprintf(x, "||%7d||", 2378);
CYG_TEST_PASS_FAIL(my_strcmp(x, "|| 2378||")==0, "padding test");
CYG_TEST_PASS_FAIL(ret==my_strlen(x), "padding test return code");
 
// Check 4
ret = sprintf(x, "%x", 3573);
CYG_TEST_PASS_FAIL(my_strcmp(x, "df5")==0, "hex conversion (lowercase)");
CYG_TEST_PASS_FAIL(ret==my_strlen(x), "hex conv (lowercase) return code");
 
// Check 5
ret = sprintf(x, "%X", 3573);
CYG_TEST_PASS_FAIL(my_strcmp(x, "DF5")==0, "hex conversion (uppercase)");
CYG_TEST_PASS_FAIL(ret==my_strlen(x), "hex conv (upperbase ) return code");
 
// Check 6
ret = sprintf(x, "%c", 65);
CYG_TEST_PASS_FAIL(my_strcmp(x, "A")==0, "%c test");
CYG_TEST_PASS_FAIL(ret==my_strlen(x), "%c test return code");
 
// Check 7
ret = sprintf(x, "%o",4628);
CYG_TEST_PASS_FAIL(my_strcmp(x, "11024")==0, "octal conversion");
CYG_TEST_PASS_FAIL(ret==my_strlen(x), "octal conversion return code");
 
// Check 8
ret = sprintf(x, "%u", (unsigned int) 4738);
CYG_TEST_PASS_FAIL(my_strcmp(x, "4738")==0, "%u test");
CYG_TEST_PASS_FAIL(ret==my_strlen(x), "%u test return code");
 
// Check 9
ptr = &tmp;
ret = sprintf(x, "1234567x%n||", ptr);
CYG_TEST_PASS_FAIL(tmp==8, "%n test");
CYG_TEST_PASS_FAIL(ret==10, "%n test return code");
 
// Check 10
ret = sprintf(x, "%%");
CYG_TEST_PASS_FAIL(my_strcmp(x, "%")==0, "%% test");
CYG_TEST_PASS_FAIL(ret==my_strlen(x), "%% test return code");
 
// Check 11
ret = sprintf(x, "%ld", (long)1<<30);
CYG_TEST_PASS_FAIL(my_strcmp(x, "1073741824")==0, "%ld test");
CYG_TEST_PASS_FAIL(ret==my_strlen(x), "%ld test return code");
 
// Check 12
ret = sprintf(x, "%lu", (unsigned long)(1<<31) + 100);
CYG_TEST_PASS_FAIL(my_strcmp(x, "2147483748")==0, "%lu test");
CYG_TEST_PASS_FAIL(ret==my_strlen(x), "%lu test return code");
 
// Check 13
ret = sprintf(x, "%x", 0x789a);
CYG_TEST_PASS_FAIL(my_strcmp(x, "789a")==0, "%x test");
CYG_TEST_PASS_FAIL(ret==my_strlen(x), "%x test return code");
 
// Check 14
ret = sprintf(x, "%X", 0x789ab2);
CYG_TEST_PASS_FAIL(my_strcmp(x, "789AB2")==0, "%X test");
CYG_TEST_PASS_FAIL(ret==my_strlen(x), "%x test return code");
 
// Check 15
ret = sprintf(x, "%08x", 0xdea2f2);
CYG_TEST_PASS_FAIL(my_strcmp(x, "00dea2f2")==0, "%0x test");
CYG_TEST_PASS_FAIL(ret==my_strlen(x), "%0x test return code");
 
// Check 16
ret = sprintf(x, "%09X", 0x12fa1c);
CYG_TEST_PASS_FAIL(my_strcmp(x, "00012FA1C")==0, "%0X test");
CYG_TEST_PASS_FAIL(ret==my_strlen(x), "%0X test return code");
 
// Check 17
ptr=&tmp;
ret = sprintf(x, "%p", (void *)ptr);
// just check _something_ was returned
CYG_TEST_PASS_FAIL((ret==my_strlen(x)) && (ret > 0),
"%p test return code");
 
#ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT
 
CYG_TEST_INFO("Starting floating point specific tests");
 
// Check 18
ret = sprintf(x, "%f", 2.5);
my_strcpy( y, "2.500000" );
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "simple %f test #1");
CYG_TEST_PASS_FAIL(ret == my_strlen(y), "simple %f test #1 return code");
 
// Check 19
ret = sprintf(x, "hello %f world", 1.234);
my_strcpy( y, "hello 1.234000 world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "simple %f test #2");
CYG_TEST_PASS_FAIL(ret == my_strlen(y), "simple %f test #2 return code");
 
// Check 20
ret = sprintf(x, "hello%fworld", 2.3456781);
my_strcpy( y, "hello2.345678world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "simple %f test #3");
CYG_TEST_PASS_FAIL(ret == my_strlen(y), "simple %f test #3 return code");
 
// Check 21
ret = sprintf(x, "%s%f%d%s", "testing", -0.591, 3, "123");
my_strcpy( y, "testing-0.5910003123");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "%f mixed with others");
CYG_TEST_PASS_FAIL(ret == my_strlen(y),"%f mixed with others return code");
 
// Check 22
ret = sprintf(x, "%s%f%d%s", "testing", -0.591, 3, "123");
my_strcpy( y, "testing-0.5910003123");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "%f mixed with others");
CYG_TEST_PASS_FAIL(ret == my_strlen(y),"%f mixed with others return code");
 
// Check 23
ret = sprintf(x, "hello%fworld", 2.3456786);
my_strcpy( y, "hello2.345679world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "rounding test #1");
CYG_TEST_PASS_FAIL(ret == my_strlen(y), "rounding test #1 return code");
 
// Check 24
ret = sprintf(x, "hello%fworld", -2.3456786);
my_strcpy( y, "hello-2.345679world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "rounding test #2");
CYG_TEST_PASS_FAIL(ret == my_strlen(y), "rounding test #2 return code");
 
// Check 25
ret = sprintf(x, "hello%+fworld", -6.54321);
my_strcpy( y, "hello-6.543210world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "+ modifier #1");
CYG_TEST_PASS_FAIL(ret == my_strlen(y), "+ modifier #1 return code");
 
// Check 26
ret = sprintf(x, "hello%+fworld", 6.54321);
my_strcpy( y, "hello+6.543210world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "+ modifier #2");
CYG_TEST_PASS_FAIL(ret == my_strlen(y), "+ modifier #2 return code");
 
// Check 27
ret = sprintf(x, "hello%5fworld", 6.5);
my_strcpy( y, "hello6.500000world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "width modifier #1");
CYG_TEST_PASS_FAIL(ret == my_strlen(y), "width modifier #1 return code");
 
// Check 28
ret = sprintf(x, "hello%2fworld", 4.3);
my_strcpy( y, "hello4.300000world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "width modifier #2");
CYG_TEST_PASS_FAIL(ret == my_strlen(y), "width modifier #2 return code");
 
// Check 29
ret = sprintf(x, "hello%2.1fworld", 5.6);
my_strcpy( y, "hello5.6world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "width and precision modifier #1");
CYG_TEST_PASS_FAIL(ret == my_strlen(y),
"width and precision modifier #1 return code");
 
// Check 30
ret = sprintf(x, "hello%5.1fworld", 6.7);
my_strcpy( y, "hello 6.7world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "width and precision modifier #2");
CYG_TEST_PASS_FAIL(ret == my_strlen(y),
"width and precision modifier #2 return code");
 
// Check 31
ret = sprintf(x, "hello%3.1fworld", 7.8);
my_strcpy( y, "hello7.8world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "width and precision modifier #3");
CYG_TEST_PASS_FAIL(ret == my_strlen(y),
"width and precision modifier #3 return code");
 
// Check 32
ret = sprintf(x, "hello%3.2fworld", 7.8);
my_strcpy( y, "hello7.80world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "width and precision modifier #4");
CYG_TEST_PASS_FAIL(ret == my_strlen(y),
"width and precision modifier #4 return code");
 
// Check 33
ret = sprintf(x, "hello%05.1fworld", 6.5);
my_strcpy( y, "hello006.5world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "0 modifier #1");
CYG_TEST_PASS_FAIL(ret == my_strlen(y), "0 modifier #1 return code");
 
// Check 34
ret = sprintf(x, "hello%03.0fworld", 6.2);
my_strcpy( y, "hello006world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "0 modifier #2");
CYG_TEST_PASS_FAIL(ret == my_strlen(y), "0 modifier #2 return code");
 
// Check 35
ret = sprintf(x, "hello%05.*fworld",2, 7.5);
my_strcpy( y, "hello07.50world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "0 modifier plus *");
CYG_TEST_PASS_FAIL(ret == my_strlen(y),
"0 modifier plus * return code");
 
// Check 36
ret = sprintf(x, "hello%03.1fworld",-1.232);
my_strcpy( y, "hello-1.2world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "-ve number with 0 modifier #1");
CYG_TEST_PASS_FAIL(ret == my_strlen(y),
"-ve number with 0 modifier #1 return code");
 
// Check 37
ret = sprintf(x, "hello%04.1fworld",-1.232);
my_strcpy( y, "hello-1.2world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "-ve number with 0 modifier #2");
CYG_TEST_PASS_FAIL(ret == my_strlen(y),
"-ve number with 0 modifier #2 return code");
 
// Check 38
ret = sprintf(x, "hello%05.1fworld",-1.232);
my_strcpy( y, "hello-01.2world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "-ve number with 0 modifier #3");
CYG_TEST_PASS_FAIL(ret == my_strlen(y),
"-ve number with 0 modifier #3 return code");
 
// Check 39
ret = sprintf(x, "hello%fworld",0.0);
my_strcpy( y, "hello0.000000world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "0.0 test #1");
CYG_TEST_PASS_FAIL(ret == my_strlen(y), "0.0 test #1 return code");
 
// Check 40
ret = sprintf(x, "hello%1.0fworld",0.0);
my_strcpy( y, "hello0world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "0.0 test #2");
CYG_TEST_PASS_FAIL(ret == my_strlen(y), "0.0 test #2 return code");
 
// Check 41
ret = sprintf(x, "hello%1.1fworld",0.0);
my_strcpy( y, "hello0.0world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "0.0 test #3");
CYG_TEST_PASS_FAIL(ret == my_strlen(y), "0.0 test #3 return code");
 
// Check 42
ret = sprintf(x, "hello%5.1fworld",0.0);
my_strcpy( y, "hello 0.0world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "0.0 test #4");
CYG_TEST_PASS_FAIL(ret == my_strlen(y), "0.0 test #4 return code");
 
// Check 43
ret = sprintf(x, "hello%fworld",-0.0);
my_strcpy( y, "hello-0.000000world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "-0.0 test #1");
CYG_TEST_PASS_FAIL(ret == my_strlen(y), "-0.0 test #1 return code");
 
// Check 44
ret = sprintf(x, "hello%fworld",0.234);
my_strcpy( y, "hello0.234000world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "number less than 1 #1");
CYG_TEST_PASS_FAIL(ret == my_strlen(y),
"number less than 1 #1 return code");
 
// Check 45
ret = sprintf(x, "hello%02fworld",-0.234);
my_strcpy( y, "hello-0.234000world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "number less than 1 #2");
CYG_TEST_PASS_FAIL(ret == my_strlen(y),
"number less than 1 #2 return code");
 
// Check 46
ret = sprintf(x, "hello%02.2fworld",-0.234);
my_strcpy( y, "hello-0.23world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "number less than 1 #3");
CYG_TEST_PASS_FAIL(ret == my_strlen(y),
"number less than 1 #3 return code");
 
// Check 47
ret = sprintf(x, "hello%06.2fworld",-0.234);
my_strcpy( y, "hello-00.23world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "number less than 1 #4");
CYG_TEST_PASS_FAIL(ret == my_strlen(y),
"number less than 1 #4 return code");
 
// Check 48
ret = sprintf(x, "hello%-6.2fworld",2.345);
my_strcpy( y, "hello2.35 world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "left justification #1");
CYG_TEST_PASS_FAIL(ret == my_strlen(y),
"left justification #1 return code");
 
// Check 49
ret = sprintf(x, "hello%-6.2fworld",2.345);
my_strcpy( y, "hello2.35 world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "left justification #2");
CYG_TEST_PASS_FAIL(ret == my_strlen(y),
"left justification #2 return code");
 
// Check 50
ret = sprintf(x, "hello%-3.2fworld",2.345);
my_strcpy( y, "hello2.35world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "left justification #3");
CYG_TEST_PASS_FAIL(ret == my_strlen(y),
"left justification #3 return code");
 
// Check 51
ret = sprintf(x, "hello%#1.0fworld",2.12);
my_strcpy( y, "hello2.world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "# modifier #1");
CYG_TEST_PASS_FAIL(ret == my_strlen(y), "# modifier #1 return code");
 
// Check 52
ret = sprintf(x, "hello%#1.2fworld",2.0);
my_strcpy( y, "hello2.00world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "# modifier #2");
CYG_TEST_PASS_FAIL(ret == my_strlen(y), "# modifier #2 return code");
 
// Check 53
ret = sprintf(x, "hello%eworld",2.3456);
my_strcpy( y, "hello2.345600e+00world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "%e #1");
CYG_TEST_PASS_FAIL(ret == my_strlen(y), "%e #1 return code");
 
// Check 54
ret = sprintf(x, "hello%4.3eworld",-2.3456e-1);
my_strcpy( y, "hello-2.346e-01world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "%e #2");
CYG_TEST_PASS_FAIL(ret == my_strlen(y), "%e #2 return code");
 
// Check 55
ret = sprintf(x, "hello%4.2eworld",2.56e2);
my_strcpy( y, "hello2.56e+02world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "%e #3");
CYG_TEST_PASS_FAIL(ret == my_strlen(y), "%e #3 return code");
 
// Check 56
ret = sprintf(x, "hello%09.2eworld",2.56e2);
my_strcpy( y, "hello02.56e+02world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "%e #4");
CYG_TEST_PASS_FAIL(ret == my_strlen(y), "%e #4 return code");
 
// Check 57
ret = sprintf(x, "hello%09.2Eworld",4.23e19);
my_strcpy( y, "hello04.23E+19world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "%e #5");
CYG_TEST_PASS_FAIL(ret == my_strlen(y), "%e #5 return code");
 
// Check 58
ret = sprintf(x, "hello%gworld",4.0);
my_strcpy( y, "hello4world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "%g #1");
CYG_TEST_PASS_FAIL(ret == my_strlen(y), "%g #1 return code");
 
// Check 59
ret = sprintf(x, "hello%gworld",4.56);
my_strcpy( y, "hello4.56world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "%g #2");
CYG_TEST_PASS_FAIL(ret == my_strlen(y), "%g #2 return code");
 
// Check 60
ret = sprintf(x, "hello%5.2gworld",4.56);
my_strcpy( y, "hello 4.6world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "%g #3");
CYG_TEST_PASS_FAIL(ret == my_strlen(y), "%g #3 return code");
 
// Check 61
ret = sprintf(x, "hello%gworld",0.002);
my_strcpy( y, "hello0.002world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "%g #4");
CYG_TEST_PASS_FAIL(ret == my_strlen(y), "%g #4 return code");
 
// Check 62
ret = sprintf(x, "hello%06.1gworld",0.0026);
my_strcpy( y, "hello00.003world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "%g #5");
CYG_TEST_PASS_FAIL(ret == my_strlen(y), "%g #5 return code");
 
// Check 63
ret = sprintf(x, "hello%06gworld",0.000026);
my_strcpy( y, "hello2.6e-05world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "%g #5");
CYG_TEST_PASS_FAIL(ret == my_strlen(y), "%g #5 return code");
 
// Check 64
ret = sprintf(x, "hello%06Gworld",0.000037);
my_strcpy( y, "hello3.7E-05world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "%g #6");
CYG_TEST_PASS_FAIL(ret == my_strlen(y), "%g #6 return code");
 
// Check 65
ret = sprintf(x, "hello%08Gworld",-123456.0);
my_strcpy( y, "hello-0123456world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "%g #7");
CYG_TEST_PASS_FAIL(ret == my_strlen(y), "%g #7 return code");
 
// Check 66
ret = sprintf(x, "hello%07gworld",-1234567.0);
my_strcpy( y, "hello-1.23457e+06world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "%g #8");
CYG_TEST_PASS_FAIL(ret == my_strlen(y), "%g #8 return code");
 
// Check 67
ret = sprintf(x, "hello%013Gworld",-1234567.0);
my_strcpy( y, "hello-01.23457E+06world");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "%g #9");
CYG_TEST_PASS_FAIL(ret == my_strlen(y), "%g #9 return code");
 
 
#else
CYG_TEST_PASS("Floating point tests skipped - not configured");
#endif // ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT
 
// Long string tests
ret = sprintf(x, "This is a very long string so I hope this works as "
"otherwise I would be very, very, sad. The cat sat on the "
"hat, and the mat sat on the rat. Quick brown fax, etc.etc. "
"blah, blah and all that jazz. Isn't he finished yet? My "
"old man's a dustman, why do I have to think up this "
"drivel, isn't that what summer students are for, if "
"anything that seems thinking up mindless drivel seems to "
"be their occupation in life. Yoof of today, eh? What, "
"what? %s So there.",
"And this is a middly bit.");
my_strcpy(y, "This is a very long string so I hope this works as "
"otherwise I would be very, very, sad. The cat sat on the "
"hat, and the mat sat on the rat. Quick brown fax, etc.etc. "
"blah, blah and all that jazz. Isn't he finished yet? My "
"old man's a dustman, why do I have to think up this "
"drivel, isn't that what summer students are for, if "
"anything that seems thinking up mindless drivel seems to "
"be their occupation in life. Yoof of today, eh? What, "
"what? And this is a middly bit. So there.");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "long (480 char) string output #1");
CYG_TEST_PASS_FAIL(ret == my_strlen(y),
"long (480 char) string output #1 return code");
 
ret = sprintf(x, "Boo! This %s So there.",
"is a very long string so I hope this works as "
"otherwise I would be very, very, sad. The cat sat on the "
"hat, and the mat sat on the rat. Quick brown fax, etc.etc. "
"blah, blah and all that jazz. Isn't he finished yet? My "
"old man's a dustman, why do I have to think up this "
"drivel, isn't that what summer students are for, if "
"anything that seems thinking up mindless drivel seems to "
"be their occupation in life. Yoof of today, eh? What, "
"what? And this is a middly bit.");
my_strcpy(y, "Boo! This is a very long string so I hope this works as "
"otherwise I would be very, very, sad. The cat sat on the "
"hat, and the mat sat on the rat. Quick brown fax, etc.etc. "
"blah, blah and all that jazz. Isn't he finished yet? My "
"old man's a dustman, why do I have to think up this "
"drivel, isn't that what summer students are for, if "
"anything that seems thinking up mindless drivel seems to "
"be their occupation in life. Yoof of today, eh? What, "
"what? And this is a middly bit. So there.");
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "long (485 char) string output #2");
CYG_TEST_PASS_FAIL(ret == my_strlen(y),
"long (485 char) string output #2 return code");
 
 
 
 
CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library "
"sprintf() function");
 
} // test()
 
int
main(int argc, char *argv[])
{
CYG_TEST_INIT();
 
CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library "
"sprintf() function");
CYG_TEST_INFO("These test individual features separately");
 
test(0);
 
return 0;
} // main()
 
// EOF sprintf1.c
/v2_0/tests/sprintf2.c
0,0 → 1,196
//=================================================================
//
// sprintf2.c
//
// Testcase for C library sprintf()
//
//=================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//=================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): ctarpy, jlarmour
// Contributors:
// Date: 2000-04-20
// Description: Contains testcode for C library sprintf() function
//
//
//####DESCRIPTIONEND####
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
// INCLUDES
 
#include <stdio.h>
#include <cyg/infra/testcase.h>
 
// FUNCTIONS
 
// Functions to avoid having to use libc strings
 
static int
my_strlen(const char *s)
{
const char *ptr;
 
ptr = s;
for ( ptr=s ; *ptr != '\0' ; ptr++ )
;
 
return (int)(ptr-s);
} // my_strlen()
 
 
static int
my_strcmp(const char *s1, const char *s2)
{
for ( ; *s1 == *s2 ; s1++,s2++ )
{
if ( *s1 == '\0' )
break;
} // for
 
return (*s1 - *s2);
} // my_strcmp()
 
 
static char *
my_strcpy(char *s1, const char *s2)
{
while (*s2 != '\0') {
*(s1++) = *(s2++);
}
*s1 = '\0';
 
return s1;
} // my_strcpy()
 
 
 
static void
test( CYG_ADDRWORD data )
{
static char x[200];
static char y[200];
static char z[200];
int ret;
int tmp;
int *ptr;
 
// Check 1
my_strcpy(x, "I'm afraid the shield generator");
ptr = &tmp;
ret = sprintf(y, "%s%n will be quite operational - %5d%%%c%05X", x,
ptr, 13, '5', 0x89ab);
my_strcpy( z, "I'm afraid the shield generator will be "
"quite operational - 13%5089AB" );
CYG_TEST_PASS_FAIL(my_strcmp(y,z) == 0, "%s%n%d%%%c%0X test");
 
CYG_TEST_PASS_FAIL(ret == my_strlen(z),
"%s%n%d%%%c%0X test return code" );
 
CYG_TEST_PASS_FAIL(tmp==31, "%n test");
 
// Check 2
ret = sprintf(y, "|%5d|%10s|%03d|%c|%o|", 2, "times", 6, '=', 10 );
my_strcpy(z, "| 2| times|006|=|12|");
 
CYG_TEST_PASS_FAIL(my_strcmp(y,z) == 0, "|%5d|%10s|%03d|%c|%o| test");
 
CYG_TEST_PASS_FAIL(ret == my_strlen(z),
"|%5d|%10s|%03d|%c|%o| test return code" );
 
// Check 3
ret = snprintf(y, 19, "print up to here >< and not this bit" );
my_strcpy(z, "print up to here >");
CYG_TEST_PASS_FAIL(my_strcmp(y,z) == 0, "simple snprintf test #1");
CYG_TEST_PASS_FAIL(ret == my_strlen(z),
"simple snprintf test #1 return code" );
// Check 4
ret = snprintf(y, 31, "print a bit of this number: %05d nyer", 1234);
my_strcpy(z, "print a bit of this number: 01");
CYG_TEST_PASS_FAIL(my_strcmp(y,z) == 0, "simple snprintf test #2");
CYG_TEST_PASS_FAIL(ret == my_strlen(z),
"simple snprintf test #2 return code" );
#ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT
 
CYG_TEST_INFO("Starting floating point specific tests");
 
// Check 5
ret = sprintf(y, "|%5f|%10s|%03d|%c|%+-5.2G|%010.3G|",
2.0, "times", 6, '=', 12.0, -2.3451e-6 );
my_strcpy(z, "|2.000000| times|006|=|+12 |-02.35E-06|");
 
CYG_TEST_PASS_FAIL(my_strcmp(y,z) == 0,
"|%5f|%10s|%03d|%c|%+-5.2G|%010.3G| test");
 
CYG_TEST_PASS_FAIL(ret == my_strlen(z),
"|%5f|%10s|%03d|%c|%+-5.2G|%010.3G| test "
"return code" );
 
// Check 6
ret = snprintf(y, 20, "bit of this: %g double", 6.431e8);
my_strcpy(z, "bit of this: 6.431e");
CYG_TEST_PASS_FAIL(my_strcmp(y,z) == 0,
"snprintf double test #1");
 
CYG_TEST_PASS_FAIL(ret == my_strlen(z),
"snprintf double test #1 return code");
 
#endif // ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT
 
CYG_TEST_FINISH("Finished tests from testcase " __FILE__
" for C library sprintf() function");
 
} // test()
 
int
main(int argc, char *argv[])
{
CYG_TEST_INIT();
 
CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C "
"library sprintf() function");
CYG_TEST_INFO("These test combinations of sprintf() features");
 
test(0);
 
return 0;
} // main()
 
// EOF sprintf2.c
/v2_0/tests/sscanf.c
0,0 → 1,316
//=================================================================
//
// sscanf.c
//
// Testcase for C library sscanf()
//
//=================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//=================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): ctarpy, jlarmour
// Contributors:
// Date: 2000-04-20
// Description: Contains testcode for C library sscanf() function
//
//
//####DESCRIPTIONEND####
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
// INCLUDES
 
#include <stdio.h>
#include <cyg/infra/testcase.h>
 
// HOW TO START TESTS
 
#if defined(CYGFUN_LIBC_STDIO_ungetc)
 
# define START_TEST( test ) test(0)
 
#else
 
# define START_TEST( test ) CYG_EMPTY_STATEMENT
 
#endif
 
// FUNCTIONS
 
#if defined(CYGFUN_LIBC_STDIO_ungetc)
 
// Functions to avoid having to use libc strings
 
static int
my_strcmp(const char *s1, const char *s2)
{
for ( ; *s1 == *s2 ; s1++,s2++ )
{
if ( *s1 == '\0')
break;
} // for
 
return (*s1 - *s2);
} // my_strcmp()
 
 
static char *
my_strcpy(char *s1, const char *s2)
{
while (*s2 != '\0') {
*(s1++) = *(s2++);
}
*s1 = '\0';
 
return s1;
} // my_strcpy()
 
 
static void
test( CYG_ADDRWORD data )
{
static char x[300];
static char y[300];
char z[20];
int ret;
int int_test, int_test2, int_test3, int_test4;
 
// Check 1
my_strcpy(x, "20");
ret = sscanf(x, "%d", &int_test);
CYG_TEST_PASS_FAIL(int_test==20, "%d test");
CYG_TEST_PASS_FAIL(ret == 1, "%d test return code");
 
// Check 2
my_strcpy(y, "PigsNoses");
ret = sscanf(y, "%s", x);
CYG_TEST_PASS_FAIL(my_strcmp(x, y)==0, "%s test");
CYG_TEST_PASS_FAIL(ret == 1, "%s test return code");
 
// Check 3
my_strcpy(x, "FE8C");
ret = sscanf(x, "%X", &int_test);
CYG_TEST_PASS_FAIL(int_test == 65164, "hex read leading zeroes");
CYG_TEST_PASS_FAIL(ret == 1, "hex read leading zeroes return code");
 
// Check 4
my_strcpy(x, "000053Ba");
ret = sscanf(x, "%x", &int_test);
CYG_TEST_PASS_FAIL(int_test == 21434, "hex read leading zeroes");
CYG_TEST_PASS_FAIL(ret == 1, "hex read leading zeros return code");
 
// Check 5
my_strcpy(x, "53Ba");
ret = sscanf(x, "%3x", &int_test);
CYG_TEST_PASS_FAIL(int_test == 1339, "hex read constrained width");
CYG_TEST_PASS_FAIL(ret == 1, "hex read constrained width return code");
 
// Check 6
my_strcpy(x, "get the first char test");
ret = sscanf(x, "%c", &y[0]);
CYG_TEST_PASS_FAIL(y[0] == 'g', "%c test");
CYG_TEST_PASS_FAIL(ret == 1, "%c test return code");
 
// Check 7
my_strcpy(x, "-5");
ret = sscanf(x, "%d", &int_test);
CYG_TEST_PASS_FAIL(int_test == -5, "negative integer");
CYG_TEST_PASS_FAIL(ret == 1, "negative integer return code");
// Check 8
my_strcpy(x, "53");
ret = sscanf(x, "%o", &int_test);
CYG_TEST_PASS_FAIL(int_test == 43, "%o test");
CYG_TEST_PASS_FAIL(ret == 1, "%o test return code");
// Check 9
int_test=10;
my_strcpy(x, "-5 0");
ret = sscanf(x, "%*d %d", &int_test);
CYG_TEST_PASS_FAIL(int_test == 0, "assignment suppression");
CYG_TEST_PASS_FAIL(ret == 1, "assignment suppression return code");
// Check 10
int_test=0;
my_strcpy(x, "052");
ret = sscanf(x, "%i", &int_test);
CYG_TEST_PASS_FAIL(int_test == 42, "octal with %i");
CYG_TEST_PASS_FAIL(ret == 1, "octal with %i return code");
// Check 10
int_test=0;
my_strcpy(x, "0x05f");
ret = sscanf(x, "%i", &int_test);
CYG_TEST_PASS_FAIL(int_test == 95, "hex with %i");
CYG_TEST_PASS_FAIL(ret == 1, "hex with %i return code");
// Check 11
int_test=0;
my_strcpy(x, "+023456");
ret = sscanf(x, "%u", &int_test);
CYG_TEST_PASS_FAIL(int_test == 23456, "unsigned int with %u");
CYG_TEST_PASS_FAIL(ret == 1, "unsigned int with %u return code");
// Check 12
my_strcpy(x, "aString 2747 D");
ret = sscanf(x, "%s %d %c", y, &int_test, z);
CYG_TEST_PASS_FAIL( (my_strcmp(y, "aString")==0) &&
(int_test == 2747) &&
(z[0] == 'D'), "A few combinations #1");
CYG_TEST_PASS_FAIL(ret == 3, "Combinations #1 return code");
 
// Check 13
my_strcpy(x, "-6 52 awurble 2747 xxx");
ret = sscanf(x, "%d %u %s %2d %n %c",
&int_test, &int_test2, y, &int_test3, &int_test4, z);
CYG_TEST_PASS_FAIL( (int_test == -6) && (int_test2 == 52) &&
(my_strcmp(y, "awurble")==0) &&
(int_test3 == 27) &&
(int_test4 == 16) &&
(z[0] == '4'), "A few combinations #2");
CYG_TEST_PASS_FAIL(ret == 5, "Combinations #2 return code");
 
 
#ifdef CYGSEM_LIBC_STDIO_SCANF_FLOATING_POINT
 
// How much _relative_ error do we allow?
#define FLT_TOLERANCE 1.0e-3
 
#define MY_FABS(x) ((x) < 0.0 ? -(x) : (x))
 
CYG_TEST_INFO("Starting floating point specific tests");
 
{
float flt_test, wanted;
 
// Check 14
my_strcpy(x, "2.5");
wanted = 2.5;
ret = sscanf(x, "%f", &flt_test);
CYG_TEST_PASS_FAIL( MY_FABS(flt_test - wanted) <
MY_FABS(wanted * FLT_TOLERANCE),
"Simple %f test #1" );
CYG_TEST_PASS_FAIL( ret == 1, "Simple %f test #1 return code" );
 
 
// Check 15
my_strcpy(x, "-23.472345");
wanted = -23.472345;
ret = sscanf(x, "%f", &flt_test);
CYG_TEST_PASS_FAIL( MY_FABS(flt_test - wanted) <
MY_FABS(wanted * FLT_TOLERANCE),
"Simple %f test #2" );
CYG_TEST_PASS_FAIL( ret == 1, "Simple %f test #2 return code" );
 
// Check 16
my_strcpy(x, "0.0");
ret = sscanf(x, "%f", &flt_test);
CYG_TEST_PASS_FAIL( flt_test==0.0, "Simple %f test 0.0" );
CYG_TEST_PASS_FAIL( ret == 1, "Simple %f test 0.0 return code" );
 
 
// Check 17
my_strcpy(x, "-2.6334e00");
wanted = -2.6334;
ret = sscanf(x, "%e", &flt_test);
CYG_TEST_PASS_FAIL( MY_FABS(flt_test - wanted) <
MY_FABS(wanted * FLT_TOLERANCE),
"Simple %e test #1" );
CYG_TEST_PASS_FAIL( ret == 1, "Simple %e test #1 return code" );
 
 
// Check 18
my_strcpy(x, "-2.56789e-06");
wanted = -2.56789e-06;
ret = sscanf(x, "%e", &flt_test);
CYG_TEST_PASS_FAIL( MY_FABS(flt_test-wanted) <
MY_FABS(wanted * FLT_TOLERANCE),
"Simple %e test #2" );
CYG_TEST_PASS_FAIL( ret == 1, "Simple %e test #2 return code" );
 
// Check 19
my_strcpy(x, "-2.12389e-06");
wanted = -2.12389e-06;
ret = sscanf(x, "%g", &flt_test);
CYG_TEST_PASS_FAIL( MY_FABS(flt_test-wanted) <
MY_FABS(wanted * FLT_TOLERANCE),
"Simple %g test #1" );
CYG_TEST_PASS_FAIL( ret == 1, "Simple %g test #1 return code" );
 
// Check 20
my_strcpy(x, "1.3423345");
wanted = 1.342335;
ret = sscanf(x, "%g", &flt_test);
CYG_TEST_PASS_FAIL( MY_FABS(flt_test-wanted) <
MY_FABS(wanted * FLT_TOLERANCE),
"Simple %g test #2" );
CYG_TEST_PASS_FAIL( ret == 1, "Simple %g test #2 return code" );
 
} // compound
 
#else
CYG_TEST_PASS("Floating point tests skipped - not configured");
#endif // ifdef CYGSEM_LIBC_STDIO_SCANF_FLOATING_POINT
 
 
CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library "
"sscanf() function");
 
} // test()
 
#endif // defined(CYGFUN_LIBC_STDIO_ungetc)
 
 
int
main(int argc, char *argv[])
{
CYG_TEST_INIT();
 
CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C library "
"sscanf() function");
 
START_TEST( test );
 
CYG_TEST_NA("Testing is not applicable to this configuration");
} // main()
 
 
// EOF sscanf.c
/v2_0/include/stdiosupp.hxx
0,0 → 1,83
#ifndef CYGONCE_LIBC_STDIO_STDIOSUPP_HXX
#define CYGONCE_LIBC_STDIO_STDIOSUPP_HXX
//========================================================================
//
// stdiosupp.hxx
//
// Support for C library standard I/O routines
//
//========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-19
// Purpose:
// Description:
// Usage: #include <cyg/libc/stdio/stdiosupp.hxx>
//
//####DESCRIPTIONEND####
//
//========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // common type definitions and support
#include <stdio.h> // Main standard I/O header
#include <cyg/libc/stdio/stream.hxx>// Cyg_StdioStream
 
// FUNCTION PROTOTYPES
 
//========================================================================
 
// Miscellaneous support functions
 
externC cyg_stdio_handle_t
Cyg_libc_stdio_find_filename( const char *filename,
const Cyg_StdioStream::OpenMode rw,
const cyg_bool binary,
const cyg_bool append );
 
externC Cyg_ErrNo
cyg_libc_stdio_flush_all_but( Cyg_StdioStream *not_this_stream );
 
#endif // CYGONCE_LIBC_STDIOL_STDIOSUPP_HXX multiple inclusion protection
 
// EOF stdiosupp.hxx
/v2_0/include/stream.hxx
0,0 → 1,321
#ifndef CYGONCE_LIBC_STDIO_STREAM_HXX
#define CYGONCE_LIBC_STDIO_STREAM_HXX
//========================================================================
//
// stream.hxx
//
// Internal C library stdio stream interface definitions
//
//========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2001-03-16
// Purpose:
// Description:
// Usage: #include <cyg/libc/stdio/stream.hxx>
//
//####DESCRIPTIONEND####
//
//========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // Common project-wide type definitions
#include <cyg/infra/cyg_ass.h> // Get assertion macros, as appropriate
#include <errno.h> // Cyg_ErrNo
#include <stdio.h> // fpos_t and IOBUF defines
#include <cyg/libc/stdio/io.hxx> // Physical IO support
#include <cyg/libc/stdio/streambuf.hxx> // Stdio stream file buffers
 
#ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS
#include <pkgconf/kernel.h>
#include <cyg/kernel/mutex.hxx> // Cyg_Mutex
#endif
 
// TYPE DEFINITIONS
 
class Cyg_StdioStream;
__externC Cyg_ErrNo
cyg_libc_stdio_flush_all_but( Cyg_StdioStream * );
 
class Cyg_StdioStream
{
friend int setvbuf( FILE *, char *, int, size_t );
friend Cyg_ErrNo
cyg_libc_stdio_flush_all_but( Cyg_StdioStream * );
 
private:
 
// error status for this file
Cyg_ErrNo error;
 
 
cyg_stdio_handle_t my_device;
 
#ifdef CYGFUN_LIBC_STDIO_ungetc
cyg_uint8 unread_char_buf;
#endif
 
#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO
Cyg_StdioStreamBuffer io_buf; // read/write buffer
#endif
cyg_uint8 readbuf_char; // a one character emergency "buffer"
// only used when configured to not buffer
// (i.e. !CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO)
// or set at runtime to not buffer (i.e.
// buffering mode is _IONBF)
 
// some flags indicating the state of the file. Some of it is internal
// state, which should not be public. Use bitfields to save
// space, which means using "unsigned int" rather than cyg_uintX
struct {
unsigned int at_eof : 1; // Have we reached eof?
 
unsigned int opened_for_read : 1; // opened_for_read and
 
unsigned int opened_for_write : 1; // opened_for_write can
// be set simultaneously
 
unsigned int binary : 1; // opened for binary or
// text mode?
#ifdef CYGFUN_LIBC_STDIO_ungetc
unsigned int unread_char_buf_in_use : 1; // unget buf in use?
#endif
 
#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO
unsigned int buffering : 1; // Is this file buffered?
 
unsigned int line_buffering : 1; // If so, is it line
// buffered? If it is
// buffered, but NOT line
// buffered, it must be
// fully buffered
 
unsigned int last_buffer_op_was_read : 1; // did we last read from
// the buffer. If not we
// must have written
#endif
unsigned int readbuf_char_in_use : 1; // is the above
// readbuf_char in use?
} flags;
 
// current position for reading/writing
fpos_t position;
 
#ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS
Cyg_Mutex stream_lock; // used for locking this stream
#endif // ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS
 
#ifdef CYGDBG_USE_ASSERTS
// a value to check that this class is hopefully valid
cyg_ucount32 magic_validity_word;
#endif
 
public:
// different modes when constructing (i.e. opening).
typedef enum {
CYG_STREAM_READ,
CYG_STREAM_WRITE,
CYG_STREAM_READWRITE
} OpenMode;
 
// CONSTRUCTORS
 
// This constructs the stream - effectively opens the file. This is
// used for static initialisation, and actually calls construct below
//
// dev is a valid Cyg_Device_Table_t, although it does not have to
// be a member of the device table object itself
//
// open_mode is one of CYG_STREAM_READ, CYG_STREAM_WRITE or
// CYG_STREAM_READWRITE
//
// append is true if the file position should be set at EOF on opening
//
// binary is true if this is a binary stream. Otherwise it is a text
// stream and character conversions (especially newline) may occur
//
// buffer_mode is one of _IONBF, _IOLBF, _IOFBF (from <stdio.h>)
// If buffer_mode is _IONBF, buffer_size should still be set to 0
// and buffer_addr to NULL. If buffering is not configured, none
// of buffer_mode, buffer_size and buffer_addr have any effect
//
// buffer_size is the size of buffer to use
//
// buffer_addr is the address of a user supplied buffer. By default
// (when NULL) a system one is provided.
//
// The "return code" is set by assignment to the error member of this
// stream - use the get_error() method to check
 
Cyg_StdioStream( cyg_stdio_handle_t dev, OpenMode open_mode,
cyg_bool append, cyg_bool binary, int buffer_mode,
cyg_ucount32 buffer_size=BUFSIZ,
cyg_uint8 *buffer_addr=NULL );
 
Cyg_StdioStream( OpenMode open_mode,
cyg_ucount32 buffer_size=BUFSIZ,
cyg_uint8 *buffer_addr=NULL );
 
private:
void initialize( cyg_stdio_handle_t dev, OpenMode open_mode,
cyg_bool append, cyg_bool binary, int buffer_mode,
cyg_ucount32 buffer_size=BUFSIZ,
cyg_uint8 *buffer_addr=NULL );
public:
// DESTRUCTOR
 
~Cyg_StdioStream();
 
 
// MEMBER FUNCTIONS
 
// Close the stream. This should be called before the destructor,
// so we can see and report any errors produced.
Cyg_ErrNo close();
 
// Refill read buffer from the stream - note this blocks until
// something arrives on the stream
Cyg_ErrNo
refill_read_buffer( void );
 
 
// Read not more than buffer_length bytes from the read buffer into the
// user buffer.
// The number of bytes put into the user buffer is written
// into *bytes_read
Cyg_ErrNo
read( cyg_uint8 *user_buffer, cyg_ucount32 buffer_length,
cyg_ucount32 *bytes_read );
 
 
// Read a single byte from the stream. Returns EAGAIN if no character
// available or EEOF if end of file (as well as setting the EOF state)
Cyg_ErrNo
read_byte( cyg_uint8 *c );
 
// Read a single byte from the stream, but don't remove it. Returns
// EAGAIN if no character available or EEOF if end of file (as well
// as setting the EOF state)
Cyg_ErrNo
peek_byte( cyg_uint8 *c );
 
 
// Return a byte into the stream - basically the same as ungetc()
Cyg_ErrNo
unread_byte( cyg_uint8 c );
 
// the number of bytes available to read without needing to refill the
// buffer
cyg_ucount32
bytes_available_to_read( void );
 
Cyg_ErrNo
write( const cyg_uint8 *buffer, cyg_ucount32 buffer_length,
cyg_ucount32 *bytes_written );
 
Cyg_ErrNo
write_byte( cyg_uint8 c );
 
 
Cyg_ErrNo
flush_output( void );
 
Cyg_ErrNo
flush_output_unlocked( void );
 
// prevent multiple access in thread safe mode
 
// lock_me() returns false if it couldn't be locked, which could
// happen if the file descriptor is bad
 
cyg_bool
lock_me( void );
 
// trylock_me() returns false if it couldn't be locked, probably
// because it is already locked
cyg_bool
trylock_me( void );
 
void
unlock_me( void );
 
// get error status for this file
Cyg_ErrNo
get_error( void );
 
// set error status for this file.
void
set_error( Cyg_ErrNo errno_to_set );
 
// are we at EOF? true means we are, false means no
cyg_bool
get_eof_state( void );
 
// Set whether we are at EOF.
void
set_eof_state( cyg_bool eof_to_set );
 
// retrieve position
Cyg_ErrNo
get_position( fpos_t *pos );
 
// set absolute position. whence is SEEK_SET, SEEK_CUR, or SEEK_END
Cyg_ErrNo
set_position( fpos_t pos, int whence );
 
// Return my_device
cyg_stdio_handle_t get_dev() { return my_device; };
CYGDBG_DEFINE_CHECK_THIS
};
 
// INLINE FUNCTIONS
 
#include <cyg/libc/stdio/stream.inl>
 
#endif // CYGONCE_LIBC_STDIO_STREAM_HXX multiple inclusion protection
 
// EOF stream.hxx
/v2_0/include/stdio.inl
0,0 → 1,159
#ifndef CYGONCE_LIBC_STDIO_STDIO_INL
#define CYGONCE_LIBC_STDIO_STDIO_INL
//===========================================================================
//
// stdio.inl
//
// ANSI standard I/O routines - inlined functions
//
//===========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//===========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-19
// Purpose:
// Description:
// Usage: Do not include this file directly - use #include <stdio.h>
//
//####DESCRIPTIONEND####
//
//===========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // Common type definitions and support
#include <stddef.h> // NULL and size_t from compiler
#include <stdarg.h> // va_list
#include <stdio.h> // Just be sure it has been included
#include <errno.h> // Definition of error codes and errno
#include <string.h> // Definition of strerror() for perror()
#include <limits.h> // INT_MAX
 
// INLINE FUNCTION DEFINITIONS
 
//===========================================================================
 
// 7.9.5 File access functions
 
extern __inline__ void
setbuf( FILE *stream, char *buf )
{
if (buf == NULL)
setvbuf( stream, NULL, _IONBF, 0 );
else
// NB: Should use full buffering by default ordinarily, but in
// the current system we're always connected to an interactive
// terminal, so use line buffering
setvbuf( stream, buf, _IOLBF, BUFSIZ );
 
} // setbuf()
 
//===========================================================================
 
// 7.9.6 Formatted input/output functions
 
extern __inline__ int
vfprintf( FILE *stream, const char *format, va_list arg )
{
return vfnprintf(stream, INT_MAX, format, arg);
} // vfprintf()
 
 
extern __inline__ int
vprintf( const char *format, va_list arg )
{
return vfnprintf(stdout, INT_MAX, format, arg);
} // vprintf()
 
 
extern __inline__ int
vsprintf( char *s, const char *format, va_list arg )
{
return vsnprintf(s, INT_MAX, format, arg);
} // vsprintf()
 
 
//===========================================================================
 
// 7.9.7 Character input/output functions
 
extern __inline__ int
puts( const char *s )
{
int rc;
 
rc = fputs( s, stdout );
 
if (rc >= 0)
rc = fputc('\n', stdout );
 
return rc;
} // puts()
 
 
//===========================================================================
 
// 7.9.10 Error-handling functions
 
extern __inline__ void
perror( const char *s )
{
if (s && *s)
fprintf( stderr, "%s: %s\n", s, strerror(errno) );
else
fputs( strerror(errno), stderr );
 
} // perror()
 
//===========================================================================
 
// Other non-ANSI functions
 
extern __inline__ int
vscanf( const char *format, va_list arg )
{
return vfscanf( stdin, format, arg );
} // vscanf()
 
 
#endif // CYGONCE_LIBC_STDIO_STDIO_INL multiple inclusion protection
 
// EOF stdio.inl
/v2_0/include/stdiofiles.inl
0,0 → 1,126
#ifndef CYGONCE_LIBC_STDIO_STDIOFILES_INL
#define CYGONCE_LIBC_STDIO_STDIOFILES_INL
//========================================================================
//
// stdiofiles.inl
//
// ISO C library stdio central file inlines
//
//========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-19
// Purpose:
// Description:
// Usage: Do not include this file directly. Instead use:
// #include <cyg/libc/stdio/stdiofiles.hxx>
//
//####DESCRIPTIONEND####
//
//========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // libc stdio configuration
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // cyg_bool
#include <cyg/infra/cyg_ass.h> // Assert interface
#include <cyg/libc/stdio/stdiofiles.hxx> // header for this file
#include <cyg/libc/stdio/stream.hxx> // Cyg_StdioStream
 
#ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS
# include <cyg/kernel/mutex.hxx> // mutexes
#endif
 
// INLINE METHODS
 
inline Cyg_StdioStream *
Cyg_libc_stdio_files::get_file_stream( fd_t fd )
{
CYG_PRECONDITION( (fd < FOPEN_MAX),
"Attempt to open larger file descriptor than FOPEN_MAX!" );
 
return files[fd];
 
} // Cyg_libc_stdio_files::get_file_stream()
inline void
Cyg_libc_stdio_files::set_file_stream( fd_t fd, Cyg_StdioStream *stream )
{
CYG_PRECONDITION( (fd < FOPEN_MAX),
"Attempt to set larger file descriptor than FOPEN_MAX!" );
 
files[fd] = stream;
 
} // Cyg_libc_stdio_files::set_file_stream()
 
 
inline cyg_bool
Cyg_libc_stdio_files::lock(void)
{
# ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS
return files_lock.lock();
# else
return true;
# endif
} // Cyg_libc_stdio_files::lock()
 
inline cyg_bool
Cyg_libc_stdio_files::trylock(void)
{
# ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS
return files_lock.trylock();
# else
return true;
# endif
} // Cyg_libc_stdio_files::trylock()
 
inline void
Cyg_libc_stdio_files::unlock(void)
{
# ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS
files_lock.unlock();
# endif
} // Cyg_libc_stdio_files::unlock()
 
 
#endif // CYGONCE_LIBC_STDIO_STDIOFILES_INL multiple inclusion protection
 
// EOF stdiofiles.inl
/v2_0/include/io.inl
0,0 → 1,255
#ifndef CYGONCE_LIBC_STDIO_IO_INL
#define CYGONCE_LIBC_STDIO_IO_INL
//========================================================================
//
// io.inl
//
// Internal C library stdio io interface inlines
//
//========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): nickg
// Contributors:
// Date: 2000-06-30
// Purpose:
// Description:
// Usage: #include <cyg/libc/stdio/io.hxx>
//
//####DESCRIPTIONEND####
//
//========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
//========================================================================
// INCLUDES
 
#include <cyg/libc/stdio/io.hxx>
 
//========================================================================
// FileIO versions of IO functions
 
#ifdef CYGPKG_LIBC_STDIO_FILEIO
 
inline Cyg_ErrNo cyg_stdio_open( const char *filename,
const Cyg_StdioStream::OpenMode rw,
const cyg_bool binary,
const cyg_bool append,
cyg_stdio_handle_t *dev)
{
mode_t mode = 0;
int fd;
switch( rw )
{
case Cyg_StdioStream::CYG_STREAM_WRITE:
mode = O_WRONLY|O_CREAT|O_TRUNC;
break;
case Cyg_StdioStream::CYG_STREAM_READ:
mode = O_RDONLY;
break;
case Cyg_StdioStream::CYG_STREAM_READWRITE:
mode = O_RDWR;
break;
}
 
if( append )
{
mode |= O_APPEND;
mode &= ~O_TRUNC;
}
 
fd = open( filename, mode );
 
if( fd < 0 )
return errno;
 
*dev = fd;
return ENOERR;
}
 
inline Cyg_ErrNo cyg_stdio_close( cyg_stdio_handle_t dev )
{
if( close( dev ) != ENOERR )
return errno;
return ENOERR;
}
 
inline Cyg_ErrNo cyg_stdio_read( cyg_stdio_handle_t dev,
void *buffer, cyg_uint32 *len )
{
if( dev != CYG_STDIO_HANDLE_NULL )
{
ssize_t done = read( dev, buffer, *len );
 
if( done < 0 )
{
*len = 0;
return errno;
}
 
*len = done;
}
// If the device is NULL, just return EOF indication
else *len = 0;
return ENOERR;
}
 
inline Cyg_ErrNo cyg_stdio_write( cyg_stdio_handle_t dev,
const void *buffer, cyg_uint32 *len )
{
if( dev != CYG_STDIO_HANDLE_NULL )
{
ssize_t done = write( dev, buffer, *len );
 
if( done < 0 )
{
*len = 0;
return errno;
}
 
*len = done;
}
// if the device is NULL, just absorb all writes.
return ENOERR;
}
 
inline Cyg_ErrNo cyg_stdio_lseek( cyg_stdio_handle_t dev,
off_t *pos, int whence )
{
off_t newpos = lseek( dev, *pos, whence );
 
if( newpos < 0 )
return errno;
 
*pos = newpos;
 
return ENOERR;
}
 
inline Cyg_ErrNo cyg_stdio_flush( cyg_stdio_handle_t dev )
{
int err = fsync( dev );
 
if( err < 0 )
return errno;
 
return ENOERR;
}
 
inline cyg_bool cyg_stdio_interactive( cyg_stdio_handle_t dev )
{
struct stat buf;
int err;
 
err = fstat( dev, &buf );
 
// If we get an error, assume interactive.
if( err < 0 )
return true;
 
if( S_ISCHR(buf.st_mode) )
return true;
 
return false;
}
 
 
#endif // CYGPKG_LIBC_STDIO_FILEIO
 
//========================================================================
// Direct IO versions of IO functions
 
#ifndef CYGPKG_LIBC_STDIO_FILEIO
 
inline Cyg_ErrNo cyg_stdio_open( const char *filename,
const Cyg_StdioStream::OpenMode rw,
const cyg_bool binary,
const cyg_bool append,
cyg_stdio_handle_t *dev)
{
return cyg_io_lookup( filename, dev );
}
 
inline Cyg_ErrNo cyg_stdio_close( cyg_stdio_handle_t dev )
{
// Devices do not get closed
return ENOERR;
}
 
inline Cyg_ErrNo cyg_stdio_read( cyg_stdio_handle_t dev,
void *buffer, cyg_uint32 *len )
{
return cyg_io_read( dev, buffer, len );
}
 
inline Cyg_ErrNo cyg_stdio_write( cyg_stdio_handle_t dev,
const void *buffer, cyg_uint32 *len )
{
return cyg_io_write( dev, buffer, len );
}
 
inline cyg_uint32 cyg_stdio_lseek( cyg_stdio_handle_t dev,
cyg_uint32 *pos, int whence )
{
// No seeking in raw devices, just return fake success
return ENOERR;
}
 
inline Cyg_ErrNo cyg_stdio_flush( cyg_stdio_handle_t dev )
{
return cyg_io_get_config(dev,
CYG_IO_GET_CONFIG_SERIAL_OUTPUT_DRAIN,
NULL, NULL);
}
 
inline cyg_bool cyg_stdio_interactive( cyg_stdio_handle_t dev )
{
return true;
}
 
 
#endif // !CYGPKG_LIBC_STDIO_FILEIO
 
//========================================================================
#endif // CYGONCE_LIBC_STDIO_IO_INL multiple inclusion protection
// EOF io.inl
 
/v2_0/include/stdio.h
0,0 → 1,308
#ifndef CYGONCE_LIBC_STDIO_STDIO_H
#define CYGONCE_LIBC_STDIO_STDIO_H
//========================================================================
//
// stdio.h
//
// ISO C standard I/O routines - with some POSIX 1003.1 extensions
//
//========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-19
// Purpose: ISO C standard I/O routines
// Description:
// Usage: Do not include this file directly - use #include <stdio.h>
//
//####DESCRIPTIONEND####
//
//========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // common type definitions and support
#include <stdarg.h> // va_list from compiler
 
// CONSTANTS
 
// Some of these values are odd to ensure that asserts have better effect
// should spurious values be passed to functions expecting these constants.
 
// _IOFBF, _IOLBF, and _IONBF specify full, line or no buffering when used
// with setvbuf() - ISO C standard chap 7.9.1
 
#define _IOFBF (-2)
#define _IOLBF (-4)
#define _IONBF (-8)
 
// EOF is a macro defined to any negative integer constant - ISO C standard
// chap. 7.9.1
#define EOF (-1)
 
// SEEK_CUR, SEEK_END and SEEK_SET are used with fseek() as position
// anchors - ISO C standard chap. 7.9.1
#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2
 
 
// TYPE DEFINITIONS
 
// A type capable of specifying uniquely every file position - ISO C
// standard chap 7.9.1
typedef cyg_ucount32 fpos_t;
 
 
// FILE is just cast to an address here. It is uncast internally to the
// C library in stream.hxx as the C++ Cyg_StdioStream class.
// Optional run-time checking can be enabled to ensure that the cast is
// valid, using the standard assertion functionality.
//
// The array size is irrelevant other than being more than 8, and is present
// to stop references to FILEs being marked as able to be put in the small
// data section. We can't just mark it as in the ".data" section as on some
// targets it may actually be ".common".
typedef CYG_ADDRESS FILE[9999];
 
// EXTERNAL VARIABLES
 
// Default file streams for input/output. These only need to be
// expressions, not l-values - ISO C standard chap. 7.9.1
//
// CYGPRI_LIBC_STDIO_NO_DEFAULT_STREAMS is used when initializing
// stdin/out/err privately inside the C library
 
#ifndef CYGPRI_LIBC_STDIO_NO_DEFAULT_STREAMS
__externC FILE *stdin, *stdout, *stderr;
#endif
 
// FUNCTION PROTOTYPES
 
//========================================================================
 
// ISO C 7.9.5 File access functions
 
externC int
fclose( FILE * /* stream */ );
 
externC int
fflush( FILE * /* stream */ );
 
externC FILE *
fopen( const char * /* filename */, const char * /* mode */ );
 
externC FILE *
freopen( const char * /* filename */, const char * /* mode */,
FILE * /* stream */ );
 
externC void
setbuf( FILE * /* stream */, char * /* buffer */ );
 
externC int
setvbuf( FILE * /* stream */, char * /* buffer */, int /* mode */,
size_t /* size */ );
 
//========================================================================
 
// ISO C 7.9.6 Formatted input/output functions
 
externC int
fprintf( FILE * /* stream */, const char * /* format */, ... );
 
externC int
fscanf( FILE * /* stream */, const char * /* format */, ... );
 
externC int
printf( const char * /* format */, ... );
 
externC int
scanf( const char * /* format */, ... );
 
externC int
sprintf( char * /* str */, const char * /* format */, ... );
 
externC int
sscanf( const char * /* str */, const char * /* format */, ... );
 
externC int
vfprintf( FILE * /* stream */, const char * /* format */,
va_list /* args */ );
 
externC int
vprintf( const char * /* format */, va_list /* args */ );
 
externC int
vsprintf( char * /* str */, const char * /* format */,
va_list /* args */ );
 
//========================================================================
 
// ISO C 7.9.7 Character input/output functions
 
externC int
fgetc( FILE * /* stream */ );
 
externC char *
fgets( char * /* str */, int /* length */, FILE * /* stream */ );
 
externC int
fputc( int /* c */, FILE * /* stream */ );
 
externC int
putc( int /* c */, FILE * /* stream */ );
 
externC int
putchar( int /* c */ );
 
externC int
fputs( const char * /* str */, FILE * /* stream */ );
 
externC char *
gets( char * );
 
externC int
getc( FILE * /* stream */ );
 
externC int
getchar( void );
 
externC int
puts( const char * /* str */ );
 
externC int
ungetc( int /* c */, FILE * /* stream */ );
 
// no function equivalent is required for getchar() or putchar(), so we can
// just #define them
 
#define getchar() fgetc( stdin )
 
#define putchar(__c) fputc(__c, stdout)
 
//========================================================================
 
// ISO C 7.9.8 Direct input/output functions
 
externC size_t
fread( void * /* ptr */, size_t /* object_size */,
size_t /* num_objects */, FILE * /* stream */ );
 
externC size_t
fwrite( const void * /* ptr */, size_t /* object_size */,
size_t /* num_objects */, FILE * /* stream */ );
 
//========================================================================
 
// ISO C 7.9.9 File positioning functions
 
externC int
fgetpos( FILE * /* stream */, fpos_t * /* pos */ );
 
externC int
fseek( FILE * /* stream */, long int /* offset */, int /* whence */ );
 
externC int
fsetpos( FILE * /* stream */, const fpos_t * /* pos */ );
 
externC long int
ftell( FILE * /* stream */ );
 
externC void
rewind( FILE * /* stream */ );
 
//========================================================================
 
// ISO C 7.9.10 Error-handling functions
 
externC void
clearerr( FILE * /* stream */ );
 
externC int
feof( FILE * /* stream */ );
 
externC int
ferror( FILE * /* stream */ );
 
externC void
perror( const char * /* prefix_str */ );
 
//========================================================================
 
// Other non-ISO C functions
 
externC int
fnprintf( FILE * /* stream */, size_t /* length */,
const char * /* format */, ... ) CYGBLD_ATTRIB_PRINTF_FORMAT(3, 4);
 
externC int
snprintf( char * /* str */, size_t /* length */, const char * /* format */,
... ) CYGBLD_ATTRIB_PRINTF_FORMAT(3, 4);
 
externC int
vfnprintf( FILE * /* stream */, size_t /* length */,
const char * /* format */, va_list /* args */ );
 
externC int
vsnprintf( char * /* str */, size_t /* length */,
const char * /* format */, va_list /* args */ );
 
externC int
vscanf( const char * /* format */, va_list /* args */ );
 
externC int
vsscanf( const char * /* str */, const char * /* format */,
va_list /* args */ );
 
externC int
vfscanf( FILE * /* stream */, const char * /* format */,
va_list /* args */ );
 
 
// INLINE FUNCTIONS
 
#ifdef CYGIMP_LIBC_STDIO_INLINES
# include <cyg/libc/stdio/stdio.inl>
#endif
 
#endif // CYGONCE_LIBC_STDIO_STDIO_H multiple inclusion protection
 
// EOF stdio.h
/v2_0/include/streambuf.inl
0,0 → 1,186
#ifndef CYGONCE_LIBC_STDIO_STREAMBUF_INL
#define CYGONCE_LIBC_STDIO_STREAMBUF_INL
//===========================================================================
//
// streambuf.inl
//
// Internal C library stdio stream buffer inline functions
//
//===========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//===========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-19
// Purpose:
// Description:
// Usage: Do not include this file directly, instead
// #include <cyg/libc/stdio/streambuf.hxx>
//
//####DESCRIPTIONEND####
//
//===========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
// Include buffered I/O?
#if defined(CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO)
 
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // Common project-wide type definitions
#include <cyg/infra/cyg_ass.h> // Assertion support
#include <errno.h> // Cyg_ErrNo
#include <stdio.h> // fpos_t and iobuf defines
#include <stdlib.h> // free()
#include <cyg/libc/stdio/streambuf.hxx> // header for this file, just in case
#include <limits.h> // INT_MAX
 
// FUNCTIONS
inline
Cyg_StdioStreamBuffer::Cyg_StdioStreamBuffer( cyg_ucount32 size,
cyg_uint8 *new_buffer ) :
#if defined(CYGSEM_LIBC_STDIO_SETVBUF_MALLOC)
call_free(false),
buffer_bottom( NULL ),
buffer_size(0),
#else
buffer_bottom( static_buffer ),
buffer_size(sizeof(static_buffer)),
#endif
buffer_top(NULL),
current_buffer_position(NULL)
{
// NB Many of the above members in the initialisation list may seem
// unnecessary, but it is to ensure a defined state if e.g. the malloc
// in set_buffer() should fail
 
(void)set_buffer(size, new_buffer);
} // Cyg_StdioStreamBuffer constructor
 
 
inline
Cyg_StdioStreamBuffer::~Cyg_StdioStreamBuffer()
{
#ifdef CYGSEM_LIBC_STDIO_SETVBUF_MALLOC
if ((buffer_bottom != NULL) && call_free)
free( buffer_bottom );
#endif
} // Cyg_StdioStreamBuffer destructor
 
 
inline cyg_ucount32
Cyg_StdioStreamBuffer::get_buffer_space_used( void )
{
return (buffer_top - current_buffer_position);
} // get_buffer_space_used()
 
 
inline cyg_count32
Cyg_StdioStreamBuffer::get_buffer_size( void )
{
#ifdef CYGSEM_LIBC_STDIO_DYNAMIC_SETVBUF
if (buffer_bottom==NULL)
return -1;
#endif
return buffer_size;
} // get_buffer_size()
 
 
inline cyg_ucount32
Cyg_StdioStreamBuffer::get_buffer_addr_to_read( cyg_uint8 **buffer )
{
*buffer = current_buffer_position;
return (buffer_top - current_buffer_position);
} // get_buffer_addr_to_read()
 
inline void
Cyg_StdioStreamBuffer::set_bytes_read( cyg_ucount32 bytes )
{
cyg_uint8 *buffer_max = &buffer_bottom[ get_buffer_size() ];
 
current_buffer_position += bytes;
 
// INT_MAX is used by some callers to mean infinite.
CYG_ASSERT( (current_buffer_position <= buffer_top)
|| (get_buffer_size() == INT_MAX),
"read too many bytes from buffer" );
 
if (current_buffer_position == buffer_max)
current_buffer_position = buffer_top = &buffer_bottom[0];
} // set_bytes_read()
 
 
inline cyg_ucount32
Cyg_StdioStreamBuffer::get_buffer_addr_to_write( cyg_uint8 **buffer )
{
cyg_uint8 *buffer_max = &buffer_bottom[ get_buffer_size() ];
*buffer = buffer_top;
return (buffer_max - buffer_top);
} // get_buffer_addr_to_write()
 
 
inline void
Cyg_StdioStreamBuffer::set_bytes_written( cyg_ucount32 bytes )
{
buffer_top += bytes;
 
// INT_MAX is used by some callers to mean infinite.
CYG_ASSERT( (buffer_top <= &buffer_bottom[ get_buffer_size() ])
|| (get_buffer_size() == INT_MAX),
"wrote too many bytes into buffer" );
} // set_bytes_written()
 
 
inline void
Cyg_StdioStreamBuffer::drain_buffer( void )
{
buffer_top = current_buffer_position = &buffer_bottom[0];
} // drain_buffer()
 
#endif // if defined(CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO)
 
#endif // CYGONCE_LIBC_STDIO_STREAMBUF_INL multiple inclusion protection
 
// EOF streambuf.inl
/v2_0/include/stdiofiles.hxx
0,0 → 1,117
#ifndef CYGONCE_LIBC_STDIO_STDIOFILES_HXX
#define CYGONCE_LIBC_STDIO_STDIOFILES_HXX
//========================================================================
//
// stdiofiles.hxx
//
// ISO C library stdio central file access
//
//========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-19
// Purpose:
// Description:
// Usage: #include <cyg/libc/stdio/stdiosupp.hxx>
//
//####DESCRIPTIONEND####
//
//========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // libc stdio configuration
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // cyg_bool, cyg_ucount8, cyg_ucount16
#include <cyg/libc/stdio/stream.hxx> // Cyg_StdioStream
 
#ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS
# include <cyg/kernel/mutex.hxx> // mutexes
#endif
 
// CLASSES
 
class Cyg_libc_stdio_files
{
// List of open files - global for now
static
Cyg_StdioStream *files[FOPEN_MAX];
 
# ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS
// lock for the above
static
Cyg_Mutex files_lock;
# endif
 
public:
 
# if FOPEN_MAX < 256
typedef cyg_ucount8 fd_t;
# else
typedef cyg_ucount16 fd_t;
# endif
 
static Cyg_StdioStream *
get_file_stream( fd_t fd );
 
static void
set_file_stream( fd_t fd, Cyg_StdioStream *stream );
 
 
// the following functions lock(), trylock() and unlock() do nothing
// if we haven't got thread-safe streams
static cyg_bool
lock(void);
 
static cyg_bool
trylock(void);
 
static void
unlock(void);
}; // class Cyg_libc_stdio_files
 
 
// Inline functions for this class
#include <cyg/libc/stdio/stdiofiles.inl>
 
#endif // CYGONCE_LIBC_STDIO_STDIOFILES_HXX multiple inclusion protection
 
// EOF stdiofiles.hxx
/v2_0/include/stream.inl
0,0 → 1,482
#ifndef CYGONCE_LIBC_STDIO_STREAM_INL
#define CYGONCE_LIBC_STDIO_STREAM_INL
//========================================================================
//
// stream.inl
//
// Inline functions for internal C library stdio stream interface
//
//========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-19
// Purpose:
// Description:
// Usage: Do not include this file -
// #include <cyg/libc/stdio/stream.hxx> instead.
//
//####DESCRIPTIONEND####
//
//========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // Common project-wide type definitions
#include <stddef.h> // NULL and size_t from compiler
#include <errno.h> // Error codes
#include <cyg/libc/stdio/stream.hxx> // Just be sure that this really is
// included
 
#include <cyg/libc/stdio/io.inl> // I/O system inlines
 
// FUNCTIONS
 
#ifdef CYGDBG_USE_ASSERTS
inline cyg_bool
Cyg_StdioStream::check_this( cyg_assert_class_zeal zeal ) const
{
// check that it has the magic word set meaning it is valid.
if ( magic_validity_word != 0x7b4321ce )
return false;
return true;
} // check_this()
 
#endif // ifdef CYGDBG_USE_ASSERTS
 
 
 
// LOCKING FUNCTIONS
 
// returns true on success
inline cyg_bool
Cyg_StdioStream::lock_me( void )
{
CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" );
#ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS
return stream_lock.lock();
#else
// otherwise it "worked"
return true;
#endif
} // lock_me()
 
 
// returns true on success
inline cyg_bool
Cyg_StdioStream::trylock_me( void )
{
CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" );
#ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS
return stream_lock.trylock();
#else
// otherwise it "worked"
return true;
#endif
} // lock_me()
 
 
inline void
Cyg_StdioStream::unlock_me( void )
{
CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" );
#ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS
stream_lock.unlock();
#endif
} // unlock_me()
 
 
// DESTRUCTOR
 
inline Cyg_ErrNo
Cyg_StdioStream::close()
{
Cyg_ErrNo err = ENOERR;
if (!lock_me())
return EBADF;
 
if( my_device != CYG_STDIO_HANDLE_NULL )
{
flush_output_unlocked();
 
err = cyg_stdio_close( my_device );
if( err == ENOERR )
my_device = CYG_STDIO_HANDLE_NULL;
}
unlock_me();
return err;
} // close()
 
inline
Cyg_StdioStream::~Cyg_StdioStream()
{
CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" );
 
// Close the device if it has not already been closed.
if( my_device != CYG_STDIO_HANDLE_NULL )
close();
#ifdef CYGDBG_USE_ASSERTS
magic_validity_word = 0xbadbad;
#endif
} // Cyg_StdioStream destructor
 
 
// MEMBER FUNCTIONS
 
 
// this is currently just a wrapper around write, but having this interface
// leaves scope for optimisations in future
inline Cyg_ErrNo
Cyg_StdioStream::write_byte( cyg_uint8 c )
{
cyg_ucount32 dummy_bytes_written;
Cyg_ErrNo err;
 
CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" );
err = write( &c, 1, &dummy_bytes_written );
 
CYG_ASSERT( (err!=ENOERR) || (dummy_bytes_written==1),
"Single byte not written, but no error returned!" );
 
return err;
} // write_byte()
 
 
inline Cyg_ErrNo
Cyg_StdioStream::unread_byte( cyg_uint8 c )
{
CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" );
#ifdef CYGFUN_LIBC_STDIO_ungetc
if (!lock_me())
return EBADF; // assume file is now invalid
 
if (flags.unread_char_buf_in_use) {
unlock_me();
return ENOMEM;
} // if
 
flags.unread_char_buf_in_use = true;
unread_char_buf = c;
 
// can't be at EOF any more
flags.at_eof = false;
 
if (position) // position is always 0 for certain devices
--position;
unlock_me();
 
return ENOERR;
 
#else // ifdef CYGFUN_LIBC_STDIO_ungetc
 
return ENOSYS;
#endif // ifdef CYGFUN_LIBC_STDIO_ungetc
} // unread_byte()
 
 
inline cyg_ucount32
Cyg_StdioStream::bytes_available_to_read( void )
{
cyg_ucount32 bytes=0;
 
CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" );
#ifdef CYGFUN_LIBC_STDIO_ungetc
if (flags.unread_char_buf_in_use)
++bytes;
#endif
 
#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO
 
// either the last operation was a read, which attempted to read bytes
// into the buffer, or there are no bytes in the buffer
 
if (flags.buffering) {
if (flags.last_buffer_op_was_read == true)
bytes += io_buf.get_buffer_space_used();
}
else
 
#endif
 
if (flags.readbuf_char_in_use)
++bytes;
 
return bytes;
} // bytes_available_to_read()
 
 
 
inline Cyg_ErrNo
Cyg_StdioStream::flush_output( void )
{
Cyg_ErrNo err;
 
CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" );
if (!lock_me())
return EBADF; // assume file is now invalid
err = flush_output_unlocked();
 
unlock_me();
return err;
} // flush_output()
 
 
// get error status for this file
inline Cyg_ErrNo
Cyg_StdioStream::get_error( void )
{
Cyg_ErrNo err_temp;
CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" );
if (!lock_me())
return EBADF; // well, we've certainly got an error now!
err_temp = error;
 
unlock_me();
 
return err_temp;
} // get_error()
 
 
// set error status for this file
inline void
Cyg_StdioStream::set_error( Cyg_ErrNo errno_to_set )
{
CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" );
if (!lock_me())
{
errno = EBADF; // best we can do - we can't trust error to be there
return;
} // if
errno = error = errno_to_set;
 
if ( EEOF == error )
flags.at_eof = 1;
 
unlock_me();
} // set_error()
 
 
// are we at EOF? true means we are, false means no
inline cyg_bool
Cyg_StdioStream::get_eof_state( void )
{
cyg_bool eof_temp;
 
CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" );
if (!lock_me())
return false; // not much we can do here
eof_temp = flags.at_eof;
 
unlock_me();
return eof_temp;
} // get_eof_state()
 
 
// Set whether we are at EOF.
inline void
Cyg_StdioStream::set_eof_state( cyg_bool eof_to_set )
{
CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" );
if (!lock_me())
return; // not much we can do here
flags.at_eof = eof_to_set;
 
unlock_me();
} // set_eof_state()
 
 
// retrieve position
inline Cyg_ErrNo
Cyg_StdioStream::get_position( fpos_t *pos )
{
CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" );
if (!lock_me())
return EBADF; // assume file is now invalid
 
*pos = position;
 
unlock_me();
 
return ENOERR;
 
} // get_position()
 
 
// set absolute position
inline Cyg_ErrNo
Cyg_StdioStream::set_position( fpos_t pos, int whence )
{
CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" );
#ifndef CYGPKG_LIBC_STDIO_FILEIO
// this is currently a workaround until we have real files
// this will be corrected when we decide the true filesystem interface
 
Cyg_ErrNo err;
cyg_uint8 c;
 
if ((whence != SEEK_CUR) || pos < 0)
return ENOSYS;
 
if (!lock_me())
return EBADF; // assume file is now invalid
 
// Drain read buffer
for ( ; pos > 0 ; pos-- ) {
err = read_byte( &c );
if (err == EAGAIN)
err=refill_read_buffer();
 
// if read_byte retured error, or refill_read_buffer returned error
if (err) {
unlock_me();
return err;
} // if
} // for
 
unlock_me();
 
return ENOERR;
#else
 
if (!lock_me())
return EBADF; // assume file is now invalid
 
if ( whence != SEEK_END ) {
off_t bytesavail = (off_t)bytes_available_to_read();
off_t abspos = (whence == SEEK_CUR) ? position + pos : pos;
off_t posdiff = abspos - position;
 
if ( posdiff >= 0 && bytesavail > posdiff ) {
// can just "seek" within the existing buffer
#ifdef CYGFUN_LIBC_STDIO_ungetc
if (posdiff>0 && flags.unread_char_buf_in_use) {
flags.unread_char_buf_in_use = false;
posdiff--;
}
#endif
#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO
if (posdiff>0 && flags.buffering) {
io_buf.set_bytes_read(posdiff);
posdiff=0;
} else
#endif
if (posdiff>0 && flags.readbuf_char_in_use) {
flags.readbuf_char_in_use = false;
posdiff--;
}
CYG_ASSERT(posdiff==0, "Failed to seek within buffer correctly");
 
position = abspos;
unlock_me();
return ENOERR;
} // endif (bytesavail > posdiff)
 
if (whence == SEEK_CUR) {
position += bytesavail;
}
} //endif (whence != SEEK_END)
 
Cyg_ErrNo err;
off_t newpos=pos;
 
err = cyg_stdio_lseek( my_device, &newpos, whence );
 
if( err == ENOERR )
{
// Clean out the buffer. Flush output if any present,
// and clear any input out of input buffer and any ungot
// chars from unread buffer.
err = flush_output_unlocked();
io_buf.drain_buffer();
#ifdef CYGFUN_LIBC_STDIO_ungetc
flags.unread_char_buf_in_use = false;
#endif
 
// Clear EOF indicator.
flags.at_eof = false;
// update stream pos
position = newpos;
}
unlock_me();
 
return err;
#endif
} // set_position()
 
 
#endif // CYGONCE_LIBC_STDIO_STREAM_INL multiple inclusion protection
 
// EOF stream.inl
/v2_0/include/io.hxx
0,0 → 1,90
#ifndef CYGONCE_LIBC_STDIO_IO_HXX
#define CYGONCE_LIBC_STDIO_IO_HXX
//========================================================================
//
// io.hxx
//
// Internal C library stdio io interface definitions
//
//========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): nickg
// Contributors:
// Date: 2000-06-30
// Purpose:
// Description:
// Usage: #include <cyg/libc/stdio/io.hxx>
//
//####DESCRIPTIONEND####
//
//========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
//========================================================================
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // Common project-wide type definitions
#include <cyg/infra/cyg_ass.h> // Get assertion macros, as appropriate
#include <errno.h> // Cyg_ErrNo
 
#ifdef CYGPKG_LIBC_STDIO_FILEIO
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <errno.h>
#else
#include <cyg/io/io.h> // Device I/O support
#include <cyg/io/config_keys.h> // CYG_IO_GET_CONFIG_SERIAL_OUTPUT_DRAIN
#endif
 
//========================================================================
// Stream handle type
 
#ifdef CYGPKG_LIBC_STDIO_FILEIO
typedef int cyg_stdio_handle_t;
#define CYG_STDIO_HANDLE_NULL -1
#else
typedef cyg_io_handle_t cyg_stdio_handle_t;
#define CYG_STDIO_HANDLE_NULL 0
#endif
 
//========================================================================
#endif // CYGONCE_LIBC_STDIO_IO_HXX multiple inclusion protection
// EOF io.hxx
/v2_0/include/streambuf.hxx
0,0 → 1,164
#ifndef CYGONCE_LIBC_STDIO_STREAMBUF_HXX
#define CYGONCE_LIBC_STDIO_STREAMBUF_HXX
//===========================================================================
//
// streambuf.hxx
//
// Internal C library stdio stream buffer interface definitions
//
//===========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//===========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-19
// Purpose:
// Description: This file implements the buffer class used by Cyg_StdioStream
// for file buffers. It is simple, and not thread-safe - that
// is better done at a higher level for our purposes.
// Usage: #include <cyg/libc/stdio/streambuf.hxx>
//
//####DESCRIPTIONEND####
//
//===========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
// Include buffered I/O?
#if defined(CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO)
 
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // Common project-wide type definitions
#include <errno.h> // Cyg_ErrNo
 
 
// TYPE DEFINITIONS
 
 
class Cyg_StdioStreamBuffer
{
private:
// Buffering data
 
#if defined(CYGSEM_LIBC_STDIO_SETVBUF_MALLOC)
cyg_bool call_free; // should we free the old buffer if set_buffer is
// called?
#else
cyg_uint8 static_buffer[BUFSIZ]; // Static buffer used when we cannot
// use malloc()/free().
#endif
 
cyg_uint8 *buffer_bottom;
cyg_ucount32 buffer_size;
 
cyg_uint8 *buffer_top;
 
cyg_uint8 *current_buffer_position;
 
public:
 
// CONSTRUCTORS
// You can change the size, or even supply your own buffer, although
// this only has an effect with dynamic buffers. Otherwise it is
// silently ignored
Cyg_StdioStreamBuffer( cyg_ucount32 size=BUFSIZ,
cyg_uint8 *new_buffer=NULL );
 
 
// DESTRUCTORS
 
~Cyg_StdioStreamBuffer();
 
// METHODS
 
// Set up the buffer. As with the constructor, supplying a new_buffer
// only has an effect with dynamic buffers, although EINVAL is returned
// in that case. ENOMEM may also be returned
Cyg_ErrNo
set_buffer( cyg_ucount32 size=BUFSIZ, cyg_uint8 *new_buffer=NULL );
 
// Find out how much buffer space is in use
cyg_ucount32
get_buffer_space_used( void );
 
 
// What total size is the current buffer set to be. Can be -1 if the
// the buffer is invalid
cyg_count32
get_buffer_size( void );
 
// get buffer address to read from, and return the number of bytes
// available to read
cyg_ucount32
get_buffer_addr_to_read( cyg_uint8 **buffer );
 
// when finished reading from said space, tell the buffer how much was
// actually read
void
set_bytes_read( cyg_ucount32 bytes );
 
// return address of buffer that can be used to write into, and its
// available capacity
cyg_ucount32
get_buffer_addr_to_write( cyg_uint8 **buffer );
 
// when finished writing into said space, tell the buffer how much was
// actually written
void
set_bytes_written( cyg_ucount32 bytes );
 
// just empty the whole buffer contents
void
drain_buffer( void );
}; // class Cyg_StdioStreamBuffer
 
// INLINE FUNCTIONS
 
#include <cyg/libc/stdio/streambuf.inl>
 
 
#endif // if defined(CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO)
 
#endif // CYGONCE_LIBC_STDIO_STREAMBUF_HXX multiple inclusion protection
 
// EOF streambuf.hxx
/v2_0/ChangeLog
0,0 → 1,362
2003-02-24 Jonathan Larmour <jifl@eCosCentric.com>
 
* cdl/stdio.cdl: Fix doc link.
 
2003-02-15 Fabrice Gautier <Fabrice_Gautier@sdesigns.com>
 
* include/stdio.inl (setbuf): Don't supply size with _IONBF.
* src/common/stdioinlines.cxx (setbuf): Ditto.
 
2003-01-29 Jonathan Larmour <jifl@eCosCentric.com>
 
* src/output/vfnprintf.cxx: Add support for C99 'z' flag (size_t).
 
2002-09-02 Andrew Lunn <andrew.lunn@ascom.ch>
 
* include/stream.inl (set_position): Fixed typo in none buffered
case. Seek pos bytes, not whence bytes.
 
2002-05-17 Martin Buck <martin.buck@ascom.ch>
* include/stdio.h (fnprintf): Added printf-format-checking using
CYGBLD_ATTRIB_PRINTF_FORMAT, since gcc does it automatically only for
ISO C90 functions.
(snprintf) Likewise.
2002-04-24 Yoshinori Sato <qzb04471@nifty.ne.jp>
 
* include/streambuf.inl (Cyg_StdioStreamBuffer constructor):
Don't set default args in func definition.
(set_buffer): Ditto.
 
2002-04-05 Jonathan Larmour <jlarmour@redhat.com>
 
* src/input/fgetc.cxx (fgetc): Silence conversion warning.
 
2002-04-04 Jonathan Larmour <jlarmour@redhat.com>
 
* src/common/fopen.cxx (fopen_inner): Allocate memory using malloc and
placement new, not default new.
 
* src/input/fgetc.cxx (fgetc): Don't set error on true EOF.
 
2002-04-04 Jurica Baricevic <jura@INTESIS.hr>
 
* src/common/fclose.cxx (fclose): Use delete if we can.
 
2002-02-06 Jonathan Larmour <jlarmour@redhat.com>
 
* src/input/fread.cxx (fread): when looping read into ptrc, not ptr!
 
2002-01-25 Jonathan Larmour <jlarmour@redhat.com>
 
* include/stream.inl (set_position): Fix the seek backwards case again.
Doh!
 
2002-01-24 Jonathan Larmour <jlarmour@redhat.com>
 
* include/stream.inl (set_position): Fix the posdiff == 0 case.
 
2002-01-24 Jesper Skov <jskov@redhat.com>
 
* include/stream.inl (set_position): Check that posdiff is >0
before taking the code path that assumes so.
 
2002-01-17 Jonathan Larmour <jlarmour@redhat.com>
 
* include/stream.inl (set_position): Use an off_t for bytesavail to
prevent warnings.
 
2001-12-05 Jonathan Larmour <jlarmour@redhat.com>
 
* src/common/fflush.cxx (cyg_libc_stdio_flush_all_but): Fix starvation
problem when waiting for threads to unlock of lower priority.
Fix for bug #57014.
 
2001-11-23 Jonathan Larmour <jlarmour@redhat.com>
 
* cdl/stdio.cdl: Add dependency on stdlib string conversion functions
for *scanf.
 
2001-08-10 Robin Farine <robin.farine@terminus.org>
 
* src/output/vfnprintf.cxx (cvt): Handles the cases of finite,
NaN and infinite numbers separately.
 
* src/common/stream.cxx (read): Read correct number of bytes when
a character has been "ungot".
 
2001-08-03 Jonathan Larmour <jlarmour@redhat.com>
 
* include/streambuf.inl (~Cyg_StdioStreamBuffer): use correct configury
to decide when to call free.
 
2001-07-27 Jesper Skov <jskov@redhat.com>
 
* src/common/fflush.cxx (cyg_libc_stdio_flush_all_but): The check
for last operation being a read is only valid in buffered IO mode.
 
2001-07-20 Jonathan Larmour <jlarmour@redhat.com>
 
* include/stream.inl (set_position): Take read buffer into account
when seeking. Thanks to jjtsai <jjtsai@itri.org.tw> for the
help.
 
2001-07-12 Jonathan Larmour <jlarmour@redhat.com>
 
* src/common/fflush.cxx (cyg_libc_stdio_flush_all_but): Don't
flush a stream that was last used for reading - it doesn't need it.
* include/stream.hxx: cyg_libc_stdio_flush_all_but needs to be a
friend of class Cyg_StdioStream to do the above.
 
2001-06-18 Jonathan Larmour <jlarmour@redhat.com>
 
* src/input/fread.cxx (fread): Fix compilation problem with below
change.
 
2001-06-15 Rob Jansen <rwjansen@planet.nl>
 
* src/input/fread.cxx (fread): Changed to read the requested amount
of data items instead of stopping on CYG_LIBC_STDIO_BUFSIZE boundaries.
 
2001-06-08 Jeff Johnston <jjohnstn@redhat.com>
 
* src/input/vfscanf.cxx (vfscanf)[CYGINT_LIBC_I18N_MB_REQUIRED]: Added
call to mbtowc_fn for current locale to process format string.
Also added variable definitions needed in this circumstance.
* src/output/vfnprintf.cxx (vfnprintf)[CYGINT_LIBC_I18N_MB_REQUIRED]: Ditto.
(vfnprintf): Changed non-multibyte path to simply use the current
character rather than call the C mbtowc function since only
single byte characters would be possible.
 
2001-03-19 Jonathan Larmour <jlarmour@redhat.com>
 
* src/common/stream.cxx (refill_read_buffer): Flush all streams here...
(read): ...rather than here, or...
(read_byte): ...here.
This means less flushing, which improves performance.
 
* src/input/fgets.cxx: Add a reminder comment to improve this later.
* src/input/gets.cxx: Ditto.
 
 
2001-03-16 Jonathan Larmour <jlarmour@redhat.com>
 
* include/stream.hxx (class Cyg_StdioStream): Improve member visibility.
 
* src/common/stream.cxx (refill_read_buffer): Ensure eof is set.
* src/common/feof.cxx: New file. Implements the long lost
feof(), ferror() and clearerr() functions which were MIA for
no good reason.
* cdl/stdio.cdl: Build it.
 
2001-03-15 Jonathan Larmour <jlarmour@redhat.com>
 
* cdl/stdio.cdl (CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE): Default to
tty default console.
 
* src/input/fgets.cxx (fgets): Reimplement to work with EOF properly.
Add tracing.
* src/input/gets.cxx (gets): Ditto.
 
* include/io.hxx, include/io.inl, include/stream.hxx,
include/stream.inl, include/streambuf.hxx, include/streambuf.inl:
Silence warnings from recent compilers.
 
2001-02-01 Jonathan Larmour <jlarmour@redhat.com>
 
* cdl/stdio.cdl (CYGPKG_LIBC_STDIO_OPEN): Implements
CYGINT_ISO_STDIO_POSIX_FDFUNCS ( fileno() and fdopen() ).
 
2000-11-01 Jonathan Larmour <jlarmour@redhat.com>
 
* include/stdio.h: Make FILE array type larger to be more resistant
against small data sections.
Lose the cyg_libc_stdio_stdin/out/err definitions with macros for
stdin/stdout/err since it can cause problems with libgcc exception
code. Instead just make these extern FILE *s.
* src/common/stderr.cxx:
* src/common/stdin.cxx:
* src/common/stdout.cxx:
Define objects with init priority corresponding to order the fd's
should be allocated where applicable.
Define actual stdin, stdout, stderr externally visible constants to
point to the streams.
 
* cdl/stdio.cdl: Support CYGINT_ISO_STDIO_STREAMS interface
 
* src/common/fopen.cxx (fdopen): return f as intended
 
2000-10-23 Jesper Skov <jskov@redhat.com>
 
* include/streambuf.inl: Adjust assertions to cope with buffers
generated by sprintf and similar non-bound-buffer calls.
 
2000-08-09 Jonathan Larmour <jlarmour@redhat.co.uk>
 
* include/io.inl: No need to include string.h
 
* cdl/stdio.cdl: Add some more requires statements
 
2000-08-07 Jonathan Larmour <jlarmour@redhat.co.uk>
 
* src/common/stream.cxx (Cyg_StdioStream::Cyg_StdioStream):
Only call io_buf members conditionally.
 
2000-08-03 Jonathan Larmour <jlarmour@redhat.co.uk>
 
* src/common/fseek.cxx: Include assertion and tracing support since
they are used.
 
2000-07-20 Nick Garnett <nickg@cygnus.co.uk>
 
* include/stream.hxx (class Cyg_StdioStream): Added get_dev()
accessor member function to return underlying device handle.
 
* src/common/fopen.cxx: Added fdopen() and fileno(). Reorganized
fopen() so that code common with fdopen() is now in a separate
function.
 
* src/common/stdiosupp.cxx (Cyg_libc_stdio_find_filename): Removed
compiler warning.
 
2000-07-13 Nick Garnett <nickg@cygnus.co.uk>
 
* cdl/stdio.cdl: Added common/fseek.cxx to compile list.
Reorganized options for stream buffering:
CYGSEM_LIBC_STDIO_DYNAMIC_SETVBUF now controls whether the user
can attach their own buffer to the stream.
CYGSEM_LIBC_STDIO_SETVBUF_MALLOC controls whether buffers can be
malloced or only statically defined.
Added CYGPKG_LIBC_STDIO_FILEIO option to control whether the STDIO
package uses the FILEIO package for all IO, or goes directly to
the device drivers as before.
 
* include/stdio.h: Added file positioning calls defined in section
7.9.9 of the standard.
 
* include/io.hxx:
* include/io.inl:
Added these files to define an abstraction layer for access to the
real device underlying an IO stream. Depending on
CYGPKG_LIBC_STDIO_FILEIO this either goes to the FILEIO package or
directly to the device drivers.
* include/stream.hxx:
Modifications to use io.hxx abstractions.
Added second constructor for creating a buffer-only stream.
Added initialize() function which contains most of the common
stream initialization code.
Added a close() member function.
 
* include/stream.inl:
Modifications to use io.hxx abstractions.
Moved most of the work of the destructor into close() member.
Added FILEIO version of set_position() member function.
* include/streambuf.hxx:
* include/streambuf.inl:
* src/common/streambuf.cxx:
Rearranged to match new buffering configuration options.
 
* src/common/stream.cxx:
Modifications to use io.hxx abstractions.
Added second constructor, and moved common initialization code to
initialize() member function.
Added code to make position member correctly track current file
position.
 
* src/common/fopen.cxx:
Fixed handling of write/append in process_mode().
Moved call of process_mode() to before call to cyg_stdio_open() so
that stream modes may be passed in.
Added code to detect an interactive stream and choose non-buffered
mode - fully buffered is now the default.
Added calls to cyg_stdio_close() where appropriate.
 
* src/output/vfnprintf.cxx: Removed FLUSH() macro and its
uses. Deciding to flush should be in the hands of the buffer code,
or the user calling fflush().
 
* src/common/vsscanf.cxx:
Added FILEIO variant of vsscanf(). This uses a precharged stream
object to emulate input.
 
* src/common/vsnprintf.cxx:
Added FILEIO variant of vsnprintf(). This uses the standard stream
object to print into the supplied buffer.
* src/common/fseek.cxx:
Added this file to implement file positioning functions.
 
* src/common/fclose.cxx (fclose):
Added call to Cyg_StdioStream::close().
 
* include/stdiosupp.hxx:
* src/common/stdiosupp.cxx:
Modified Cyg_libc_stdio_find_filename() to take mode, binary and
append arguments.
 
* src/common/stdin.cxx:
* src/common/stdout.cxx:
* src/common/stderr.cxx:
Modified calls to Cyg_libc_stdio_find_filename() to pass
appropriate values for mode, binary and append arguments.
 
2000-06-18 Jonathan Larmour <jlarmour@redhat.co.uk>
 
* src/common/vsscanf.cxx: Add NULL select entry to DEVIO_TABLE
* src/common/vsnprintf.cxx: Likewise
 
2000-05-25 Hugo Tyson <hmt@cygnus.co.uk>
* include/stream.inl (set_error): If the error is EEOF, set
the EOF flag (flags.at_eof) so that clients know.
* src/input/fgetc.cxx (__fgetc):
* src/input/fgets.cxx (_fgets):
* src/input/fread.cxx (_fread): Correctly handle an error,
or EOF indication, from real_stream->refill_read_buffer().
 
2000-05-02 Jonathan Larmour <jlarmour@redhat.co.uk>
 
* New package
Separated original libc out into separate packages on functional
boundaries.
Header files are now managed by isoinfra package
Plenty of cleanups done, but no major functionality changes
 
//===========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//===========================================================================
/v2_0/src/input/fscanf.cxx
0,0 → 1,82
//===========================================================================
//
// fscanf.cxx
//
// ANSI Stdio fscanf() function
//
//===========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//===========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-20
// Purpose:
// Description:
// Usage:
//
//####DESCRIPTIONEND####
//
//===========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // Common project-wide type definitions
#include <stddef.h> // NULL and size_t from compiler
#include <stdio.h> // header for this file
#include <limits.h> // INT_MAX
 
// FUNCTIONS
 
externC int
fscanf( FILE *stream, const char *format, ... )
{
int rc; // return code
va_list ap; // for variable args
 
va_start(ap, format); // init specifying last non-var arg
 
rc = vfscanf( stream, format, ap );
 
va_end(ap); // end var args
 
return rc;
} // fscanf()
 
// EOF fscanf.cxx
/v2_0/src/input/fread.cxx
0,0 → 1,123
//========================================================================
//
// fread.cxx
//
// ANSI Stdio fread() function
//
//========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-20
// Purpose:
// Description:
// Usage:
//
//####DESCRIPTIONEND####
//
//=======================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // Common project-wide type definitions
#include <cyg/infra/cyg_ass.h> // Assertion support
#include <cyg/infra/cyg_trac.h> // Tracing support
#include <stddef.h> // NULL and size_t from compiler
#include <stdio.h> // header for this file
#include <errno.h> // error codes
#include <cyg/libc/stdio/stream.hxx>// Cyg_StdioStream
 
// FUNCTIONS
 
externC size_t
fread( void *ptr, size_t object_size, size_t num_objects, FILE *stream )
{
Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream;
cyg_ucount32 bytes_read;
cyg_ucount32 bytes_to_read;
cyg_ucount32 total_read;
Cyg_ErrNo err;
cyg_uint8 *ptrc = (cyg_uint8 *)ptr;
 
CYG_REPORT_FUNCNAMETYPE( "fread", "read %d objects" );
CYG_REPORT_FUNCARG4( "ptr=%08x, object_size=%d, num_objects=%d, "
"stream=%08x", ptr, object_size, num_objects,
stream );
 
bytes_to_read = object_size*num_objects;
total_read = 0;
 
if ( !bytes_to_read ) {
CYG_REPORT_RETVAL(0);
return 0;
} // if
 
err = real_stream->read( (cyg_uint8 *)ptr, bytes_to_read,
&bytes_read );
bytes_to_read -= bytes_read;
total_read += bytes_read;
ptrc += bytes_read;
 
while (!err && bytes_to_read) { // if no err, but not finished - get next
err = real_stream->refill_read_buffer();
if ( !err ) {
err = real_stream->read( (cyg_uint8 *)ptrc, bytes_to_read,
&bytes_read );
bytes_to_read -= bytes_read;
total_read += bytes_read;
ptrc += bytes_read;
} // if
} // while
 
if (err) {
real_stream->set_error( err );
errno = err;
} // if
// we return the number of _objects_ read. Simple division is
// sufficient as this returns the quotient rather than rounding
CYG_REPORT_RETVAL( bytes_read/object_size );
return total_read/object_size;
 
} // fread()
 
// EOF fread.cxx
/v2_0/src/input/gets.cxx
0,0 → 1,124
//===========================================================================
//
// gets.cxx
//
// ISO C standard I/O gets() function
//
//===========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//===========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2001-03-15
// Purpose: Implementation of ISO C standard I/O gets() function
// Description:
// Usage:
//
//####DESCRIPTIONEND####
//
//===========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // Common type definitions
#include <cyg/infra/cyg_ass.h> // Assertion support
#include <cyg/infra/cyg_trac.h> // Tracing support
#include <stddef.h> // NULL and size_t from compiler
#include <stdio.h> // header for this file
#include <errno.h> // error codes
#include <cyg/libc/stdio/stream.hxx>// Cyg_StdioStream
 
// FUNCTIONS
 
// FIXME: should be reworked to read buffer at a time, and scan that
// for newlines, rather than reading byte at a time.
 
externC char *
gets( char *s )
{
Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stdin;
Cyg_ErrNo err=ENOERR;
cyg_uint8 c;
cyg_uint8 *str=(cyg_uint8 *)s;
int nch;
 
CYG_CHECK_DATA_PTRC( s );
CYG_CHECK_DATA_PTRC( real_stream );
 
CYG_REPORT_FUNCTYPE( "returning string %08x");
CYG_REPORT_FUNCARG1( "s=%08x", s );
for (nch=1;; nch++) {
err = real_stream->read_byte( &c );
// if nothing to read, try again ONCE after refilling buffer
if (EAGAIN == err) {
err = real_stream->refill_read_buffer();
if ( !err )
err = real_stream->read_byte( &c );
 
if (EAGAIN == err) {
if (1 == nch) { // indicates EOF at start
CYG_REPORT_RETVAL( NULL );
return NULL;
} else
break; // EOF
} // if
} // if
if ('\n' == c) // discard newlines
break;
*str++ = c;
} // while
*str = '\0'; // NULL terminate it
if (err && EAGAIN != err) {
real_stream->set_error( err );
errno = err;
CYG_REPORT_RETVAL( NULL );
return NULL;
} // if
 
CYG_REPORT_RETVAL( s );
return s;
} // gets()
 
// EOF gets.cxx
/v2_0/src/input/vfscanf.cxx
0,0 → 1,1002
//========================================================================
//
// vfscanf.cxx
//
// I/O routines for vfscanf() for use with ANSI C library
//
//========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-20
// Purpose:
// Description:
// Usage:
//
//####DESCRIPTIONEND####
//
//========================================================================
//
// This code is based on original code with the following copyright:
//
/*
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
 
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
#include <pkgconf/libc_i18n.h> // Configuration header for mb support
 
// We have to have ungetc for this to work
#if defined(CYGFUN_LIBC_STDIO_ungetc)
 
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // Common type definitions and support
#include <stdarg.h> // Variable argument definitions
#include <stdio.h> // Standard header for all stdio files
#include <ctype.h> // isspace() and isupper()
#include <stdlib.h> // standard utility functions e.g. strtol
#include <cyg/libc/stdio/stream.hxx> // C library streams
 
#ifdef CYGSEM_LIBC_STDIO_SCANF_FLOATING_POINT
 
#include <float.h>
 
# define MAXFRACT DBL_DIG
# define MAXEXP DBL_MAX_10_EXP
 
# define BUF (MAXEXP+MAXFRACT+3) /* 3 = sign + decimal point + NUL */
 
#else // ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT
 
# define BUF 40
 
#endif // ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT
 
/*
* Flags used during conversion.
*/
 
#define LONG 0x01 /* l: long or double */
#define LONGDBL 0x02 /* L: long double; unimplemented */
#define SHORT 0x04 /* h: short */
#define SUPPRESS 0x08 /* suppress assignment */
#define POINTER 0x10 /* weird %p pointer (`fake hex') */
#define NOSKIP 0x20 /* do not skip blanks */
 
/*
* The following are used in numeric conversions only:
* SIGNOK, NDIGITS, DPTOK, and EXPOK are for floating point;
* SIGNOK, NDIGITS, PFXOK, and NZDIGITS are for integral.
*/
 
#define SIGNOK 0x40 /* +/- is (still) legal */
#define NDIGITS 0x80 /* no digits detected */
 
#define DPTOK 0x100 /* (float) decimal point is still legal */
#define EXPOK 0x200 /* (float) exponent (e+3, etc) still
legal */
 
#define PFXOK 0x100 /* 0x prefix is (still) legal */
#define NZDIGITS 0x200 /* no zero digits detected */
 
/*
* Conversion types.
*/
 
#define CT_CHAR 0 /* %c conversion */
#define CT_CCL 1 /* %[...] conversion */
#define CT_STRING 2 /* %s conversion */
#define CT_INT 3 /* integer, i.e., strtol or strtoul */
#define CT_FLOAT 4 /* floating, i.e., strtod */
 
#if 0
#define u_char unsigned char
#endif
#define u_char char
#define u_long unsigned long
 
typedef unsigned long (*strtoul_t)(const char *, char **endptr, int base);
 
static u_char *
__sccl (char *tab, u_char *fmt);
 
 
/*
* vfscanf
*/
 
#define _CAST_VOID
 
#define CURR_POS (file->peek_byte( (cyg_uint8 *)&curr_byte),&curr_byte )
 
#define INC_CURR_POS ( file->read_byte( (cyg_uint8 *)&curr_byte ) )
 
#define MOVE_CURR_POS(x) (file->set_position( (x), SEEK_CUR ))
 
#define SPACE_LEFT (file->bytes_available_to_read())
 
#define REFILL (file->refill_read_buffer())
 
#define BufferEmpty ( !SPACE_LEFT && \
(REFILL, (!SPACE_LEFT)) )
 
#ifdef CYGINT_LIBC_I18N_MB_REQUIRED
typedef int (*mbtowc_fn_type)(wchar_t *, const char *, size_t, int *);
externC mbtowc_fn_type __get_current_locale_mbtowc_fn();
#endif
 
externC int
vfscanf (FILE *fp, const char *fmt0, va_list ap)
{
u_char *fmt = (u_char *) fmt0;
int c; /* character from format, or conversion */
wchar_t wc; /* wide character from format */
size_t width; /* field width, or 0 */
char *p; /* points into all kinds of strings */
int n; /* handy integer */
int flags; /* flags as defined above */
char *p0; /* saves original value of p when necessary */
char *lptr; /* literal pointer */
int nassigned; /* number of fields assigned */
int nread; /* number of characters consumed from fp */
int base = 0; /* base argument to strtol/strtoul */
int nbytes = 1; /* number of bytes processed */
 
#ifdef CYGINT_LIBC_I18N_MB_REQUIRED
mbtowc_fn_type mbtowc_fn;
int state = 0; /* used for mbtowc_fn */
#endif
strtoul_t ccfn = NULL; /* conversion function (strtol/strtoul) */
char ccltab[256]; /* character class table for %[...] */
char buf[BUF]; /* buffer for numeric conversions */
 
Cyg_StdioStream *file = (Cyg_StdioStream *)fp;
char curr_byte;
 
short *sp;
int *ip;
float *flp;
long double *ldp;
double *dp;
long *lp;
 
/* `basefix' is used to avoid `if' tests in the integer scanner */
static const short basefix[17] =
{10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
 
#ifdef CYGINT_LIBC_I18N_MB_REQUIRED
mbtowc_fn = __get_current_locale_mbtowc_fn();
#endif
 
nassigned = 0;
nread = 0;
for (;;)
{
#ifndef CYGINT_LIBC_I18N_MB_REQUIRED
wc = *fmt;
#else
nbytes = mbtowc_fn (&wc, fmt, MB_CUR_MAX, &state);
#endif
fmt += nbytes;
 
if (wc == 0)
return nassigned;
if (nbytes == 1 && isspace (wc))
{
for (;;)
{
if (BufferEmpty)
return nassigned;
if (!isspace (*CURR_POS))
break;
nread++, INC_CURR_POS;
}
continue;
}
if (wc != '%')
goto literal;
width = 0;
flags = 0;
 
/*
* switch on the format. continue if done; break once format
* type is derived.
*/
again:
c = *fmt++;
switch (c)
{
case '%':
literal:
lptr = fmt - nbytes;
for (n = 0; n < nbytes; ++n)
{
if (BufferEmpty)
goto input_failure;
if (*CURR_POS != *lptr)
goto match_failure;
INC_CURR_POS;
nread++;
++lptr;
}
continue;
 
case '*':
flags |= SUPPRESS;
goto again;
case 'l':
flags |= LONG;
goto again;
case 'L':
flags |= LONGDBL;
goto again;
case 'h':
flags |= SHORT;
goto again;
 
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
width = width * 10 + c - '0';
goto again;
 
/*
* Conversions. Those marked `compat' are for
* 4.[123]BSD compatibility.
*
* (According to ANSI, E and X formats are supposed to
* the same as e and x. Sorry about that.)
*/
 
case 'D': /* compat */
flags |= LONG;
/* FALLTHROUGH */
case 'd':
c = CT_INT;
ccfn = (strtoul_t)strtol;
base = 10;
break;
 
case 'i':
c = CT_INT;
ccfn = (strtoul_t)strtol;
base = 0;
break;
 
case 'O': /* compat */
flags |= LONG;
/* FALLTHROUGH */
case 'o':
c = CT_INT;
ccfn = strtoul;
base = 8;
break;
 
case 'u':
c = CT_INT;
ccfn = strtoul;
base = 10;
break;
 
case 'X': /* compat XXX */
case 'x':
flags |= PFXOK; /* enable 0x prefixing */
c = CT_INT;
ccfn = strtoul;
base = 16;
break;
 
case 'E': /* compat XXX */
case 'G': /* compat XXX */
/* ANSI says that E,G and X behave the same way as e,g,x */
/* FALLTHROUGH */
case 'e':
case 'f':
case 'g':
c = CT_FLOAT;
break;
 
case 's':
c = CT_STRING;
break;
 
case '[':
fmt = __sccl (ccltab, fmt);
flags |= NOSKIP;
c = CT_CCL;
break;
 
case 'c':
flags |= NOSKIP;
c = CT_CHAR;
break;
 
case 'p': /* pointer format is like hex */
flags |= POINTER | PFXOK;
c = CT_INT;
ccfn = strtoul;
base = 16;
break;
 
case 'n':
if (flags & SUPPRESS) /* ??? */
continue;
if (flags & SHORT)
{
sp = va_arg (ap, short *);
*sp = nread;
}
else if (flags & LONG)
{
lp = va_arg (ap, long *);
*lp = nread;
}
else
{
ip = va_arg (ap, int *);
*ip = nread;
}
continue;
 
/*
* Disgusting backwards compatibility hacks. XXX
*/
case '\0': /* compat */
return EOF;
 
default: /* compat */
if (isupper (c))
flags |= LONG;
c = CT_INT;
ccfn = (strtoul_t)strtol;
base = 10;
break;
}
 
/*
* We have a conversion that requires input.
*/
if (BufferEmpty)
goto input_failure;
 
/*
* Consume leading white space, except for formats that
* suppress this.
*/
if ((flags & NOSKIP) == 0)
{
while (isspace (*CURR_POS))
{
nread++;
INC_CURR_POS;
if (SPACE_LEFT == 0)
#ifndef REDHAT_NEC
if (REFILL)
#endif
goto input_failure;
}
/*
* Note that there is at least one character in the
* buffer, so conversions that do not set NOSKIP ca
* no longer result in an input failure.
*/
}
 
/*
* Do the conversion.
*/
switch (c)
{
 
case CT_CHAR:
/* scan arbitrary characters (sets NOSKIP) */
if (width == 0)
width = 1;
if (flags & SUPPRESS)
{
size_t sum = 0;
 
for (;;)
{
if ((n = SPACE_LEFT) < (signed)width)
{
sum += n;
width -= n;
MOVE_CURR_POS(n-1);
INC_CURR_POS;
#ifndef REDHAT_NEC
if (REFILL)
{
#endif
if (sum == 0)
goto input_failure;
break;
#ifndef REDHAT_NEC
}
#endif
}
else
{
sum += width;
MOVE_CURR_POS(width - 1);
INC_CURR_POS;
break;
}
}
nread += sum;
}
else
{
/* Kludge city for the moment */
char *dest = va_arg (ap, char *);
int n = width;
if (SPACE_LEFT == 0)
#ifndef REDHAT_NEC
if (REFILL)
#endif
goto input_failure;
 
while (n && !BufferEmpty)
{
*dest++ = *CURR_POS;
INC_CURR_POS;
n--;
nread++;
}
nassigned++;
}
break;
 
case CT_CCL:
/* scan a (nonempty) character class (sets NOSKIP) */
if (width == 0)
width = ~0; /* `infinity' */
/* take only those things in the class */
if (flags & SUPPRESS)
{
n = 0;
while (ccltab[*CURR_POS])
{
n++, INC_CURR_POS;
if (--width == 0)
break;
if (BufferEmpty)
{
if (n == 0)
goto input_failure;
break;
}
}
if (n == 0)
goto match_failure;
}
else
{
p0 = p = va_arg (ap, char *);
while (ccltab[*CURR_POS])
{
*p++ = *CURR_POS;
INC_CURR_POS;
if (--width == 0)
break;
if (BufferEmpty)
{
if (p == p0)
goto input_failure;
break;
}
}
n = p - p0;
if (n == 0)
goto match_failure;
*p = 0;
nassigned++;
}
nread += n;
break;
 
case CT_STRING:
/* like CCL, but zero-length string OK, & no NOSKIP */
if (width == 0)
width = ~0;
if (flags & SUPPRESS)
{
n = 0;
while (!isspace (*CURR_POS))
{
n++, INC_CURR_POS;
if (--width == 0)
break;
if (BufferEmpty)
break;
}
nread += n;
}
else
{
p0 = p = va_arg (ap, char *);
while (!isspace (*CURR_POS))
{
*p++ = *CURR_POS;
INC_CURR_POS;
if (--width == 0)
break;
if (BufferEmpty)
break;
}
*p = 0;
nread += p - p0;
nassigned++;
}
continue;
 
case CT_INT:
/* scan an integer as if by strtol/strtoul */
#ifdef hardway
if (width == 0 || width > sizeof (buf) - 1)
width = sizeof (buf) - 1;
#else
/* size_t is unsigned, hence this optimisation */
if (--width > sizeof (buf) - 2)
width = sizeof (buf) - 2;
width++;
#endif
flags |= SIGNOK | NDIGITS | NZDIGITS;
for (p = buf; width; width--)
{
c = *CURR_POS;
/*
* Switch on the character; `goto ok' if we
* accept it as a part of number.
*/
switch (c)
{
/*
* The digit 0 is always legal, but is special.
* For %i conversions, if no digits (zero or nonzero)
* have been scanned (only signs), we will have base==0
* In that case, we should set it to 8 and enable 0x
* prefixing. Also, if we have not scanned zero digits
* before this, do not turn off prefixing (someone else
* will turn it off if we have scanned any nonzero
* digits).
*/
case '0':
if (base == 0)
{
base = 8;
flags |= PFXOK;
}
if (flags & NZDIGITS)
flags &= ~(SIGNOK | NZDIGITS | NDIGITS);
else
flags &= ~(SIGNOK | PFXOK | NDIGITS);
goto ok;
 
/* 1 through 7 always legal */
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
base = basefix[base];
flags &= ~(SIGNOK | PFXOK | NDIGITS);
goto ok;
 
/* digits 8 and 9 ok iff decimal or hex */
case '8':
case '9':
base = basefix[base];
if (base <= 8)
break; /* not legal here */
flags &= ~(SIGNOK | PFXOK | NDIGITS);
goto ok;
 
/* letters ok iff hex */
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
/* no need to fix base here */
if (base <= 10)
break; /* not legal here */
flags &= ~(SIGNOK | PFXOK | NDIGITS);
goto ok;
 
/* sign ok only as first character */
case '+':
case '-':
if (flags & SIGNOK)
{
flags &= ~SIGNOK;
goto ok;
}
break;
 
/* x ok iff flag still set & 2nd char */
case 'x':
case 'X':
if (flags & PFXOK && p == buf + 1)
{
base = 16;/* if %i */
flags &= ~PFXOK;
goto ok;
}
break;
}
 
/*
* If we got here, c is not a legal character
* for a number. Stop accumulating digits.
*/
break;
ok:
/*
* c is legal: store it and look at the next.
*/
*p++ = c;
INC_CURR_POS;
if (SPACE_LEFT == 0)
#ifndef REDHAT_NEC
if (REFILL)
#endif
break; /* EOF */
}
/*
* If we had only a sign, it is no good; push back the sign.
* If the number ends in `x', it was [sign] '0' 'x', so push
* back the x and treat it as [sign] '0'.
*/
if (flags & NDIGITS)
{
if (p > buf)
_CAST_VOID ungetc (*(u_char *)-- p, fp);
goto match_failure;
}
c = ((u_char *) p)[-1];
if (c == 'x' || c == 'X')
{
--p;
/*(void)*/ ungetc (c, fp);
}
if ((flags & SUPPRESS) == 0)
{
u_long res;
 
*p = 0;
res = (*ccfn) (buf, (char **) NULL, base);
if (flags & POINTER)
*(va_arg (ap, char **)) = (char *) (CYG_ADDRESS) res;
else if (flags & SHORT)
{
sp = va_arg (ap, short *);
*sp = res;
}
else if (flags & LONG)
{
lp = va_arg (ap, long *);
*lp = res;
}
else
{
ip = va_arg (ap, int *);
*ip = res;
}
nassigned++;
}
nread += p - buf;
break;
 
case CT_FLOAT:
/* scan a floating point number as if by strtod */
 
#ifdef hardway
if (width == 0 || width > sizeof (buf) - 1)
width = sizeof (buf) - 1;
#else
/* size_t is unsigned, hence this optimisation */
if (--width > sizeof (buf) - 2)
width = sizeof (buf) - 2;
width++;
#endif // ifdef hardway
 
flags |= SIGNOK | NDIGITS | DPTOK | EXPOK;
for (p = buf; width; width--)
{
c = *CURR_POS;
/*
* This code mimicks the integer conversion
* code, but is much simpler.
*/
switch (c)
{
 
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
flags &= ~(SIGNOK | NDIGITS);
goto fok;
 
case '+':
case '-':
if (flags & SIGNOK)
{
flags &= ~SIGNOK;
goto fok;
}
break;
case '.':
if (flags & DPTOK)
{
flags &= ~(SIGNOK | DPTOK);
goto fok;
}
break;
case 'e':
case 'E':
/* no exponent without some digits */
if ((flags & (NDIGITS | EXPOK)) == EXPOK)
{
flags =
(flags & ~(EXPOK | DPTOK)) |
SIGNOK | NDIGITS;
goto fok;
}
break;
}
break;
fok:
*p++ = c;
INC_CURR_POS;
if (SPACE_LEFT == 0)
#ifndef REDHAT_NEC
if (REFILL)
#endif
break; /* EOF */
}
/*
* If no digits, might be missing exponent digits
* (just give back the exponent) or might be missing
* regular digits, but had sign and/or decimal point.
*/
if (flags & NDIGITS)
{
if (flags & EXPOK)
{
/* no digits at all */
while (p > buf)
ungetc (*(u_char *)-- p, fp);
goto match_failure;
}
/* just a bad exponent (e and maybe sign) */
c = *(u_char *)-- p;
if (c != 'e' && c != 'E')
{
_CAST_VOID ungetc (c, fp); /* sign */
c = *(u_char *)-- p;
}
_CAST_VOID ungetc (c, fp);
}
if ((flags & SUPPRESS) == 0)
{
double res;
 
*p = 0;
#ifdef CYGSEM_LIBC_STDIO_SCANF_FLOATING_POINT
res = atof (buf);
#else
res = 0.0;
#endif
if (flags & LONG)
{
dp = va_arg (ap, double *);
*dp = res;
}
else if (flags & LONGDBL)
{
ldp = va_arg (ap, long double *);
*ldp = res;
}
else
{
flp = va_arg (ap, float *);
*flp = res;
}
nassigned++;
}
nread += p - buf;
break;
}
}
 
input_failure:
return nassigned ? nassigned : -1;
match_failure:
return nassigned;
} // vfscanf()
 
/*
* Fill in the given table from the scanset at the given format
* (just after `['). Return a pointer to the character past the
* closing `]'. The table has a 1 wherever characters should be
* considered part of the scanset.
*/
 
/*static*/
u_char *
__sccl (char *tab, u_char *fmt)
{
int c, n, v;
 
/* first `clear' the whole table */
c = *fmt++; /* first char hat => negated scanset */
if (c == '^')
{
v = 1; /* default => accept */
c = *fmt++; /* get new first char */
}
else
v = 0; /* default => reject */
/* should probably use memset here */
for (n = 0; n < 256; n++)
tab[n] = v;
if (c == 0)
return fmt - 1; /* format ended before closing ] */
 
/*
* Now set the entries corresponding to the actual scanset to the
* opposite of the above.
*
* The first character may be ']' (or '-') without being special; the
* last character may be '-'.
*/
 
v = 1 - v;
for (;;)
{
tab[c] = v; /* take character c */
doswitch:
n = *fmt++; /* and examine the next */
switch (n)
{
 
case 0: /* format ended too soon */
return fmt - 1;
 
case '-':
/*
* A scanset of the form [01+-] is defined as `the digit 0, the
* digit 1, the character +, the character -', but the effect
* of a scanset such as [a-zA-Z0-9] is implementation defined.
* The V7 Unix scanf treats `a-z' as `the letters a through z',
* but treats `a-a' as `the letter a, the character -, and the
* letter a'.
*
* For compatibility, the `-' is not considerd to define a
* range if the character following it is either a close
* bracket (required by ANSI) or is not numerically greater
* than the character we just stored in the table (c).
*/
n = *fmt;
if (n == ']' || n < c)
{
c = '-';
break; /* resume the for(;;) */
}
fmt++;
do
{ /* fill in the range */
tab[++c] = v;
}
while (c < n);
#if 1 /* XXX another disgusting compatibility hack */
/*
* Alas, the V7 Unix scanf also treats formats such
* as [a-c-e] as `the letters a through e'. This too
* is permitted by the standard....
*/
goto doswitch;
#else
c = *fmt++;
if (c == 0)
return fmt - 1;
if (c == ']')
return fmt;
#endif
 
break;
 
 
case ']': /* end of scanset */
return fmt;
 
default: /* just another character */
c = n;
break;
}
}
/* NOTREACHED */
} // __sccl()
 
#endif // if defined(CYGFUN_LIBC_STDIO_ungetc)
 
// EOF vfscanf.cxx
/v2_0/src/input/fgetc.cxx
0,0 → 1,131
//===========================================================================
//
// fgetc.cxx
//
// ISO C standard I/O get character functions
//
//===========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//===========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-20
// Purpose: Provide the fgetc() function. Also provides the function
// version of getc() and getchar()
// Description:
// Usage:
//
//####DESCRIPTIONEND####
//
//===========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // Common project-wide type definitions
#include <cyg/infra/cyg_ass.h> // Standard eCos assertion support
#include <cyg/infra/cyg_trac.h> // Standard eCos tracing support
#include <stddef.h> // NULL and size_t from compiler
#include <stdio.h> // header for this file
#include <errno.h> // error codes
#include <cyg/libc/stdio/stream.hxx>// Cyg_StdioStream
 
// FUNCTIONS
 
externC int
fgetc( FILE *stream )
{
Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream;
cyg_ucount32 bytes_read;
Cyg_ErrNo err;
cyg_uint8 c;
 
CYG_REPORT_FUNCNAMETYPE("fgetc", "returning char %d");
CYG_REPORT_FUNCARG1XV( stream );
CYG_CHECK_DATA_PTR( stream, "stream is not a valid pointer" );
 
err = real_stream->read( &c, 1, &bytes_read );
 
// Why do we need this? Because the buffer might be empty.
if (!err && !bytes_read) { // if no err, but nothing to read, try again
err = real_stream->refill_read_buffer();
if ( !err )
err = real_stream->read( &c, 1, &bytes_read );
} // if
 
CYG_ASSERT( (ENOERR != err) || (1 == bytes_read), "Didn't read 1 byte!" );
 
if (err)
{
if ( EAGAIN != err ) {
real_stream->set_error( err );
errno = err;
}
CYG_REPORT_RETVAL(EOF);
return EOF;
} // if
CYG_REPORT_RETVAL((int)c);
return (int)c;
 
} // fgetc()
 
 
// Also define getc() even though it can be a macro.
// Undefine it first though
#undef getchar
 
externC int
getchar( void )
{
return fgetc( stdin );
} // getchar()
 
 
// EXPORTED SYMBOLS
 
// Also define getc() even though it can be a macro.
// Undefine it first though
#undef getc
 
externC int
getc( FILE * ) CYGBLD_ATTRIB_WEAK_ALIAS(fgetc);
 
// EOF fgetc.cxx
/v2_0/src/input/fgets.cxx
0,0 → 1,126
//========================================================================
//
// fgets.cxx
//
// ISO C standard I/O fgets() function
//
//========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2001-03-14
// Purpose: Implementation of ISO C standard I/O fgets() function
// Description:
// Usage:
//
//####DESCRIPTIONEND####
//
//=======================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // Common type definitions
#include <cyg/infra/cyg_ass.h> // Assertion support
#include <cyg/infra/cyg_trac.h> // Tracing support
#include <stddef.h> // NULL and size_t from compiler
#include <stdio.h> // header for this file
#include <errno.h> // error codes
#include <cyg/libc/stdio/stream.hxx>// Cyg_StdioStream
 
// FUNCTIONS
 
// FIXME: should be reworked to read buffer at a time, and scan that
// for newlines, rather than reading byte at a time.
 
externC char *
fgets( char *s, int n, FILE *stream )
{
Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream;
Cyg_ErrNo err=ENOERR;
cyg_uint8 c;
cyg_uint8 *str=(cyg_uint8 *)s;
int nch;
 
CYG_CHECK_DATA_PTRC( s );
CYG_CHECK_DATA_PTRC( stream );
CYG_PRECONDITION( n > 0, "requested 0 or negative chars");
 
CYG_REPORT_FUNCTYPE( "returning string %08x");
CYG_REPORT_FUNCARG3( "s=%08x, n=%d, stream=%08x", s, n, stream );
for (nch=1; nch < n; nch++) {
err = real_stream->read_byte( &c );
// if nothing to read, try again ONCE after refilling buffer
if (EAGAIN == err) {
err = real_stream->refill_read_buffer();
if ( !err )
err = real_stream->read_byte( &c );
 
if (EAGAIN == err) {
if (1 == nch) { // indicates EOF at start
CYG_REPORT_RETVAL( NULL );
return NULL;
} else
break; // EOF
} // if
} // if
*str++ = c;
if ('\n' == c)
break;
} // while
*str = '\0'; // NULL terminate it
if (err && EAGAIN != err) {
real_stream->set_error( err );
errno = err;
CYG_REPORT_RETVAL( NULL );
return NULL;
} // if
 
CYG_REPORT_RETVAL( s );
return s;
 
} // fgets()
 
// EOF fgets.cxx
/v2_0/src/input/scanf.cxx
0,0 → 1,82
//===========================================================================
//
// scanf.cxx
//
// ANSI Stdio scanf() function
//
//===========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//===========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-20
// Purpose:
// Description:
// Usage:
//
//####DESCRIPTIONEND####
//
//===========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // Common project-wide type definitions
#include <stddef.h> // NULL and size_t from compiler
#include <stdio.h> // header for this file
 
// FUNCTIONS
 
 
externC int
scanf( const char *format, ... )
{
int rc; // return code
va_list ap; // for variable args
 
va_start(ap, format); // init specifying last non-var arg
 
rc = vfscanf( stdin, format, ap );
 
va_end(ap); // end var args
 
return rc;
} // scanf()
 
// EOF scanf.cxx
/v2_0/src/output/fwrite.cxx
0,0 → 1,103
//========================================================================
//
// fwrite.cxx
//
// ANSI Stdio fwrite() function
//
//========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-20
// Purpose:
// Description:
// Usage:
//
//####DESCRIPTIONEND####
//
//========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // Common project-wide type definitions
#include <cyg/infra/cyg_ass.h> // Assertion support
#include <cyg/infra/cyg_trac.h> // Tracing support
#include <stddef.h> // NULL and size_t from compiler
#include <stdio.h> // header for this file
#include <errno.h> // error codes
#include <cyg/libc/stdio/stream.hxx>// Cyg_StdioStream
 
// FUNCTIONS
 
externC size_t
fwrite( const void *ptr, size_t object_size, size_t num_objects,
FILE *stream )
{
Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream;
cyg_ucount32 written;
Cyg_ErrNo err;
CYG_REPORT_FUNCNAMETYPE( "fwrite", "wrote %d objects" );
CYG_REPORT_FUNCARG4( "ptr=%08x, object_size=%d, num_objects=%d, "
"stream=%08x", ptr, object_size, num_objects,
stream );
 
if ( (object_size==0) || (num_objects==0) ) {
CYG_REPORT_RETVAL(0);
return 0;
} // if
 
err = real_stream->write( (cyg_uint8 *)ptr, num_objects*object_size,
&written );
 
if (err) {
real_stream->set_error( err );
errno = err;
} // if
// we return the number of _objects_ written. Simple division is
// sufficient as this returns the quotient rather than rounding
 
CYG_REPORT_RETVAL( written/object_size );
return written/object_size;
} // fwrite()
 
// EOF fwrite.cxx
/v2_0/src/output/fputc.cxx
0,0 → 1,116
//===========================================================================
//
// fputc.cxx
//
// ISO Standard I/O character output functions
//
//===========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//===========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-20
// Purpose: Provide the fputc() function. Also provides the function
// versions of putc() and putchar()
// Description:
// Usage:
//
//####DESCRIPTIONEND####
//
//===========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // Common project-wide type definitions
#include <cyg/infra/cyg_ass.h> // Standard eCos assertion support
#include <cyg/infra/cyg_trac.h> // Standard eCos tracing support
#include <stddef.h> // NULL and size_t from compiler
#include <stdio.h> // header for this file
#include <errno.h> // error codes
#include <cyg/libc/stdio/stream.hxx>// Cyg_StdioStream
 
// FUNCTIONS
 
externC int
fputc( int c, FILE *stream )
{
Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream;
Cyg_ErrNo err;
cyg_uint8 real_c = (cyg_uint8) c;
CYG_REPORT_FUNCNAMETYPE("fputc", "wrote char %d");
CYG_REPORT_FUNCARG2( "c = %d, stream=%08x", c, stream );
CYG_CHECK_DATA_PTR( stream, "stream is not a valid pointer" );
 
err = real_stream->write_byte( real_c );
 
if (err)
{
real_stream->set_error( err );
errno = err;
CYG_REPORT_RETVAL(EOF);
return EOF;
} // if
CYG_REPORT_RETVAL((int)real_c);
return (int)real_c;
 
} // fputc()
 
 
// Also define putchar() even though it can be a macro.
// Undefine the macro first though
#undef putchar
 
externC int
putchar( int c )
{
return fputc( c, stdout );
} // putchar()
 
// Also define putc() even though it can be a macro.
// Undefine the macro first though
#undef putc
 
externC int
putc( int, FILE * ) CYGBLD_ATTRIB_WEAK_ALIAS(fputc);
 
// EOF fputc.cxx
/v2_0/src/output/fputs.cxx
0,0 → 1,90
//========================================================================
//
// fputs.cxx
//
// ANSI Stdio fputs() function
//
//========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-20
// Purpose:
// Description:
// Usage:
//
//####DESCRIPTIONEND####
//
//========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // Common project-wide type definitions
#include <stddef.h> // NULL and size_t from compiler
#include <stdio.h> // header for this file
#include <errno.h> // error codes
#include <cyg/libc/stdio/stream.hxx>// Cyg_StdioStream
#include <string.h> // strlen()
 
// FUNCTIONS
 
externC int
fputs( const char *s, FILE *stream )
{
Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream;
cyg_ucount32 size = strlen(s);
cyg_ucount32 written;
Cyg_ErrNo err;
err = real_stream->write( (cyg_uint8 *)s, size, &written );
 
if (err) {
real_stream->set_error( err );
errno = err;
return EOF;
} // if
return written;
 
} // fputs()
 
// EOF fputs.cxx
/v2_0/src/output/printf.cxx
0,0 → 1,82
//===========================================================================
//
// printf.cxx
//
// ANSI Stdio printf() function
//
//===========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//===========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-20
// Purpose:
// Description:
// Usage:
//
//####DESCRIPTIONEND####
//
//===========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // Common project-wide type definitions
#include <stddef.h> // NULL and size_t from compiler
#include <stdio.h> // header for this file
#include <limits.h> // INT_MAX
 
// FUNCTIONS
 
externC int
printf( const char *format, ... )
{
int rc; // return code
va_list ap; // for variable args
 
va_start(ap, format); // init specifying last non-var arg
 
rc = vfnprintf(stdout, INT_MAX, format, ap);
 
va_end(ap); // end var args
 
return rc;
} // printf()
 
// EOF printf.cxx
/v2_0/src/output/fnprintf.cxx
0,0 → 1,81
//===========================================================================
//
// fnprintf.cxx
//
// ANSI Stdio fnprintf() function
//
//===========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//===========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-20
// Purpose:
// Description:
// Usage:
//
//####DESCRIPTIONEND####
//
//===========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // Common project-wide type definitions
#include <stddef.h> // NULL and size_t from compiler
#include <stdio.h> // header for this file
 
// FUNCTIONS
 
externC int
fnprintf( FILE *stream, size_t size, const char *format, ... )
{
int rc; // return code
va_list ap; // for variable args
 
va_start(ap, format); // init specifying last non-var arg
 
rc = vfnprintf(stream, size, format, ap);
 
va_end(ap); // end var args
 
return rc;
} // fnprintf()
 
// EOF fnprintf.cxx
/v2_0/src/output/fprintf.cxx
0,0 → 1,82
//===========================================================================
//
// fprintf.cxx
//
// ANSI Stdio fprintf() function
//
//===========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//===========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-20
// Purpose:
// Description:
// Usage:
//
//####DESCRIPTIONEND####
//
//===========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // Common project-wide type definitions
#include <stddef.h> // NULL and size_t from compiler
#include <stdio.h> // header for this file
#include <limits.h> // INT_MAX
 
// FUNCTIONS
 
externC int
fprintf( FILE *stream, const char *format, ... )
{
int rc; // return code
va_list ap; // for variable args
 
va_start(ap, format); // init specifying last non-var arg
 
rc = vfnprintf(stream, INT_MAX, format, ap);
 
va_end(ap); // end var args
 
return rc;
} // fprintf()
 
// EOF fprintf.cxx
/v2_0/src/output/vfnprintf.cxx
0,0 → 1,966
//===========================================================================
//
// vfnprintf.c
//
// I/O routines for vfnprintf() for use with ANSI C library
//
//===========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//===========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-20
// Purpose:
// Description:
// Usage:
//
//####DESCRIPTIONEND####
//
//===========================================================================
//
// This code is based on original code with the following copyright:
//
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Chris Torek.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
*/
 
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
#include <pkgconf/libc_i18n.h> // Configuration header for mb support
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // Common type definitions and support
#include <stdarg.h> // Variable argument definitions
#include <stdio.h> // Standard header for all stdio files
#include <string.h> // memchr() and strlen() functions
#include <cyg/libc/stdio/stream.hxx> // C library streams
 
#ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT
 
# include <float.h> // for DBL_DIG etc. below
# include <math.h> // for modf()
# include <sys/ieeefp.h> // Cyg_libm_ieee_double_shape_type
 
# define MAXFRACT DBL_DIG
# define MAXEXP DBL_MAX_10_EXP
 
# define BUF (MAXEXP+MAXFRACT+1) /* + decimal point */
# define DEFPREC 6
 
static int
cvt( double, int, int, char *, int, char *, char * );
 
#else // ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT
 
# define BUF 40
 
#endif // ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT
 
/*
* Actual printf innards.
*
* This code is large and complicated...
*/
 
#ifdef CYGINT_LIBC_I18N_MB_REQUIRED
typedef int (*mbtowc_fn_type)(wchar_t *, const char *, size_t, int *);
externC mbtowc_fn_type __get_current_locale_mbtowc_fn();
#endif
 
/*
* Macros for converting digits to letters and vice versa
*/
#define to_digit(c) ((c) - '0')
#define is_digit(c) ((unsigned)to_digit(c) <= 9)
#define to_char(n) ((n) + '0')
 
/*
* Flags used during conversion.
*/
#define ALT 0x001 /* alternate form */
#define HEXPREFIX 0x002 /* add 0x or 0X prefix */
#define LADJUST 0x004 /* left adjustment */
#define LONGDBL 0x008 /* long double; unimplemented */
#define LONGINT 0x010 /* long integer */
#define QUADINT 0x020 /* quad integer */
#define SHORTINT 0x040 /* short integer */
#define ZEROPAD 0x080 /* zero (as opposed to blank) pad */
#define FPT 0x100 /* Floating point number */
#define SIZET 0x200 /* size_t */
 
externC int
vfnprintf ( FILE *stream, size_t n, const char *format, va_list arg)
{
char *fmt; /* format string */
int ch; /* character from fmt */
int x, y; /* handy integers (short term usage) */
char *cp; /* handy char pointer (short term usage) */
int flags; /* flags as above */
 
#ifdef CYGINT_LIBC_I18N_MB_REQUIRED
int state = 0; /* state for mbtowc conversion */
mbtowc_fn_type mbtowc_fn;
#endif
 
int ret; /* return value accumulator */
int width; /* width from format (%8d), or 0 */
int prec; /* precision from format (%.3d), or -1 */
char sign; /* sign prefix (' ', '+', '-', or \0) */
wchar_t wc;
 
#define quad_t long long
#define u_quad_t unsigned long long
 
u_quad_t _uquad; /* integer arguments %[diouxX] */
enum { OCT, DEC, HEX } base;/* base for [diouxX] conversion */
int dprec; /* a copy of prec if [diouxX], 0 otherwise */
int fieldsz; /* field size expanded by sign, etc */
int realsz; /* field size expanded by dprec */
int size; /* size of converted field or string */
char *xdigs; /* digits for [xX] conversion */
#define NIOV 8
char buf[BUF]; /* space for %c, %[diouxX], %[eEfgG] */
char ox[2]; /* space for 0x hex-prefix */
#ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT
char softsign; /* temporary negative sign for floats */
double _double; /* double precision arguments %[eEfgG] */
int fpprec; /* `extra' floating precision in [eEfgG] */
#endif
 
/*
* Choose PADSIZE to trade efficiency vs. size. If larger printf
* fields occur frequently, increase PADSIZE and make the initialisers
* below longer.
*/
#define PADSIZE 16 /* pad chunk size */
static char blanks[PADSIZE] =
{' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '};
static char zeroes[PADSIZE] =
{'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'};
 
#define MIN(a, b) ((a) < (b) ? (a) : (b))
 
/*
* BEWARE, these `goto error' on error, and PAD uses `n'.
*/
#define PRINT(ptr, len) \
CYG_MACRO_START \
cyg_ucount32 length = MIN( (cyg_ucount32) len, n - ret - 1); \
if (((Cyg_StdioStream *)stream)->write( (const cyg_uint8 *)ptr, \
length, &length )) \
goto error; \
if (length < (cyg_ucount32)len) { \
ret += length; \
goto done; \
} \
CYG_MACRO_END
 
 
#define PAD(howmany, with) \
CYG_MACRO_START \
if ((x = (howmany)) > 0) { \
while (x > PADSIZE) { \
PRINT(with, PADSIZE); \
x -= PADSIZE; \
} \
PRINT(with, x); \
} \
CYG_MACRO_END
 
/*
* To extend shorts properly, we need both signed and unsigned
* argument extraction methods.
*/
 
#define SARG() \
(flags&QUADINT ? va_arg(arg, cyg_int64) : \
flags&LONGINT ? va_arg(arg, long) : \
flags&SHORTINT ? (long)(short)va_arg(arg, int) : \
flags&SIZET ? va_arg(arg, size_t) : \
(long)va_arg(arg, int))
#define UARG() \
(flags&QUADINT ? va_arg(arg, cyg_uint64) : \
flags&LONGINT ? va_arg(arg, unsigned long) : \
flags&SHORTINT ? (unsigned long)(unsigned short)va_arg(arg, int) : \
flags&SIZET ? va_arg(arg, size_t) : \
(unsigned long)va_arg(arg, unsigned int))
 
 
xdigs = NULL; // stop compiler whinging
fmt = (char *)format;
ret = 0;
#ifdef CYGINT_LIBC_I18N_MB_REQUIRED
mbtowc_fn = __get_current_locale_mbtowc_fn();
#endif
 
/*
* Scan the format for conversions (`%' character).
*/
for (;;) {
cp = (char *)fmt;
#ifndef CYGINT_LIBC_I18N_MB_REQUIRED
while ((x = ((wc = *fmt) != 0))) {
#else
while ((x = mbtowc_fn (&wc, fmt, MB_CUR_MAX, &state)) > 0) {
#endif
fmt += x;
if (wc == '%') {
fmt--;
break;
}
}
if ((y = fmt - cp) != 0) {
PRINT(cp, y);
ret += y;
}
if ((x <= 0) || (ret >= (int)n)) // @@@ this check with n isn't good enough
goto done;
fmt++; /* skip over '%' */
 
flags = 0;
dprec = 0;
#ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT
fpprec = 0;
#endif
width = 0;
prec = -1;
sign = '\0';
 
rflag: ch = *fmt++;
reswitch: switch (ch) {
case ' ':
/*
* ``If the space and + flags both appear, the space
* flag will be ignored.''
* -- ANSI X3J11
*/
if (!sign)
sign = ' ';
goto rflag;
case '#':
flags |= ALT;
goto rflag;
case '*':
/*
* ``A negative field width argument is taken as a
* - flag followed by a positive field width.''
* -- ANSI X3J11
* They don't exclude field widths read from args.
*/
if ((width = va_arg(arg, int)) >= 0)
goto rflag;
width = -width;
/* FALLTHROUGH */
case '-':
flags |= LADJUST;
goto rflag;
case '+':
sign = '+';
goto rflag;
case '.':
if ((ch = *fmt++) == '*') {
x = va_arg(arg, int);
prec = x < 0 ? -1 : x;
goto rflag;
}
x = 0;
while (is_digit(ch)) {
x = 10 * x + to_digit(ch);
ch = *fmt++;
}
prec = x < 0 ? -1 : x;
goto reswitch;
case '0':
/*
* ``Note that 0 is taken as a flag, not as the
* beginning of a field width.''
* -- ANSI X3J11
*/
flags |= ZEROPAD;
goto rflag;
case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
x = 0;
do {
x = 10 * x + to_digit(ch);
ch = *fmt++;
} while (is_digit(ch));
width = x;
goto reswitch;
#ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT
case 'L':
flags |= LONGDBL;
goto rflag;
#endif
case 'h':
flags |= SHORTINT;
goto rflag;
case 'l':
if (*fmt == 'l') {
fmt++;
flags |= QUADINT;
} else {
flags |= LONGINT;
}
goto rflag;
case 'q':
flags |= QUADINT;
goto rflag;
case 'c':
*(cp = buf) = va_arg(arg, int);
size = 1;
sign = '\0';
break;
case 'D':
flags |= LONGINT;
/*FALLTHROUGH*/
case 'd':
case 'i':
_uquad = SARG();
#ifndef _NO_LONGLONG
if ((quad_t)_uquad < 0)
#else
if ((long) _uquad < 0)
#endif
{
 
_uquad = -_uquad;
sign = '-';
}
base = DEC;
goto number;
 
#ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT
case 'e':
case 'E':
case 'f':
case 'g':
case 'G':
_double = va_arg(arg, double);
/*
* don't do unrealistic precision; just pad it with
* zeroes later, so buffer size stays rational.
*/
if (prec > MAXFRACT) {
if ((ch != 'g' && ch != 'G') || (flags&ALT))
fpprec = prec - MAXFRACT;
prec = MAXFRACT;
} else if (prec == -1)
prec = DEFPREC;
/*
* cvt may have to round up before the "start" of
* its buffer, i.e. ``intf("%.2f", (double)9.999);'';
* if the first character is still NUL, it did.
* softsign avoids negative 0 if _double < 0 but
* no significant digits will be shown.
*/
cp = buf;
*cp = '\0';
size = cvt(_double, prec, flags, &softsign, ch,
cp, buf + sizeof(buf));
if (softsign)
sign = '-';
if (*cp == '\0')
cp++;
break;
#else
case 'e':
case 'E':
case 'f':
case 'g':
case 'G':
// Output nothing at all
(void) va_arg(arg, double); // take off arg anyway
cp = "";
size = 0;
sign = '\0';
break;
#endif // ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT
 
case 'n':
#ifndef _NO_LONGLONG
if (flags & QUADINT)
*va_arg(arg, quad_t *) = ret;
else
#endif
if (flags & LONGINT)
*va_arg(arg, long *) = ret;
else if (flags & SHORTINT)
*va_arg(arg, short *) = ret;
else if (flags & SIZET)
*va_arg(arg, size_t *) = ret;
else
*va_arg(arg, int *) = ret;
continue; /* no output */
case 'O':
flags |= LONGINT;
/*FALLTHROUGH*/
case 'o':
_uquad = UARG();
base = OCT;
goto nosign;
case 'p':
/*
* ``The argument shall be a pointer to void. The
* value of the pointer is converted to a sequence
* of printable characters, in an implementation-
* defined manner.''
* -- ANSI X3J11
*/
/* NOSTRICT */
_uquad = (unsigned long)va_arg(arg, void *);
base = HEX;
xdigs = "0123456789abcdef";
flags |= HEXPREFIX;
ch = 'x';
goto nosign;
case 's':
if ((cp = va_arg(arg, char *)) == NULL)
cp = "(null)";
if (prec >= 0) {
/*
* can't use strlen; can only look for the
* NUL in the first `prec' characters, and
* strlen() will go further.
*/
char *p = (char *)memchr(cp, 0, prec);
 
if (p != NULL) {
size = p - cp;
if (size > prec)
size = prec;
} else
size = prec;
} else
size = strlen(cp);
sign = '\0';
break;
case 'U':
flags |= LONGINT;
/*FALLTHROUGH*/
case 'u':
_uquad = UARG();
base = DEC;
goto nosign;
case 'X':
xdigs = "0123456789ABCDEF";
goto hex;
case 'x':
xdigs = "0123456789abcdef";
hex: _uquad = UARG();
base = HEX;
/* leading 0x/X only if non-zero */
if (flags & ALT && _uquad != 0)
flags |= HEXPREFIX;
 
/* unsigned conversions */
nosign: sign = '\0';
/*
* ``... diouXx conversions ... if a precision is
* specified, the 0 flag will be ignored.''
* -- ANSI X3J11
*/
number: if ((dprec = prec) >= 0)
flags &= ~ZEROPAD;
 
/*
* ``The result of converting a zero value with an
* explicit precision of zero is no characters.''
* -- ANSI X3J11
*/
cp = buf + BUF;
if (_uquad != 0 || prec != 0) {
/*
* Unsigned mod is hard, and unsigned mod
* by a constant is easier than that by
* a variable; hence this switch.
*/
switch (base) {
case OCT:
do {
*--cp = to_char(_uquad & 7);
_uquad >>= 3;
} while (_uquad);
/* handle octal leading 0 */
if (flags & ALT && *cp != '0')
*--cp = '0';
break;
 
case DEC:
/* many numbers are 1 digit */
while (_uquad >= 10) {
*--cp = to_char(_uquad % 10);
_uquad /= 10;
}
*--cp = to_char(_uquad);
break;
 
case HEX:
do {
*--cp = xdigs[_uquad & 15];
_uquad >>= 4;
} while (_uquad);
break;
 
default:
cp = "bug in vfprintf: bad base";
size = strlen(cp);
goto skipsize;
}
}
size = buf + BUF - cp;
skipsize:
break;
case 'z':
flags |= SIZET;
goto rflag;
default: /* "%?" prints ?, unless ? is NUL */
if (ch == '\0')
goto done;
/* pretend it was %c with argument ch */
cp = buf;
*cp = ch;
size = 1;
sign = '\0';
break;
}
 
/*
* All reasonable formats wind up here. At this point, `cp'
* points to a string which (if not flags&LADJUST) should be
* padded out to `width' places. If flags&ZEROPAD, it should
* first be prefixed by any sign or other prefix; otherwise,
* it should be blank padded before the prefix is emitted.
* After any left-hand padding and prefixing, emit zeroes
* required by a decimal [diouxX] precision, then print the
* string proper, then emit zeroes required by any leftover
* floating precision; finally, if LADJUST, pad with blanks.
*
* Compute actual size, so we know how much to pad.
* fieldsz excludes decimal prec; realsz includes it.
*/
#ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT
fieldsz = size + fpprec;
#else
fieldsz = size;
#endif
if (sign)
fieldsz++;
else if (flags & HEXPREFIX)
fieldsz+= 2;
realsz = dprec > fieldsz ? dprec : fieldsz;
 
/* right-adjusting blank padding */
if ((flags & (LADJUST|ZEROPAD)) == 0) {
if (width - realsz > 0) {
PAD(width - realsz, blanks);
ret += width - realsz;
}
}
 
/* prefix */
if (sign) {
PRINT(&sign, 1);
ret++;
} else if (flags & HEXPREFIX) {
ox[0] = '0';
ox[1] = ch;
PRINT(ox, 2);
ret += 2;
}
 
/* right-adjusting zero padding */
if ((flags & (LADJUST|ZEROPAD)) == ZEROPAD) {
if (width - realsz > 0) {
PAD(width - realsz, zeroes);
ret += width - realsz;
}
}
 
if (dprec - fieldsz > 0) {
/* leading zeroes from decimal precision */
PAD(dprec - fieldsz, zeroes);
ret += dprec - fieldsz;
}
 
/* the string or number proper */
PRINT(cp, size);
ret += size;
 
#ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT
/* trailing f.p. zeroes */
PAD(fpprec, zeroes);
ret += fpprec;
#endif
 
/* left-adjusting padding (always blank) */
if (flags & LADJUST) {
if (width - realsz > 0) {
PAD(width - realsz, blanks);
ret += width - realsz;
}
}
 
}
done:
error:
return (((Cyg_StdioStream *) stream)->get_error() ? EOF : ret);
/* NOTREACHED */
}
 
 
#ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT
 
static char *
round(double fract, int *exp, char *start, char *end, char ch, char *signp)
{
double tmp;
 
if (fract)
(void)modf(fract * 10, &tmp);
else
tmp = to_digit(ch);
if (tmp > 4)
for (;; --end) {
if (*end == '.')
--end;
if (++*end <= '9')
break;
*end = '0';
if (end == start) {
if (exp) { /* e/E; increment exponent */
*end = '1';
++*exp;
}
else { /* f; add extra digit */
*--end = '1';
--start;
}
break;
}
}
/* ``"%.3f", (double)-0.0004'' gives you a negative 0. */
else if (*signp == '-')
for (;; --end) {
if (*end == '.')
--end;
if (*end != '0')
break;
if (end == start)
*signp = 0;
}
return (start);
} // round()
 
 
static char *
exponent(char *p, int exp, int fmtch)
{
char *t;
char expbuf[MAXEXP];
 
*p++ = fmtch;
if (exp < 0) {
exp = -exp;
*p++ = '-';
}
else
*p++ = '+';
t = expbuf + MAXEXP;
if (exp > 9) {
do {
*--t = to_char(exp % 10);
} while ((exp /= 10) > 9);
*--t = to_char(exp);
for (; t < expbuf + MAXEXP; *p++ = *t++);
}
else {
*p++ = '0';
*p++ = to_char(exp);
}
return (p);
} // exponent()
 
 
static int
cvt(double number, int prec, int flags, char *signp, int fmtch, char *startp,
char *endp)
{
Cyg_libm_ieee_double_shape_type ieeefp;
char *t = startp;
 
ieeefp.value = number;
*signp = 0;
if ( ieeefp.number.sign ){ // this checks for <0.0 and -0.0
number = -number;
*signp = '-';
}
 
if (finite(number)) {
char *p;
double fract;
int dotrim, expcnt, gformat;
double integer, tmp;
 
dotrim = expcnt = gformat = 0;
fract = modf(number, &integer);
 
/* get an extra slot for rounding. */
t = ++startp;
 
/*
* get integer portion of number; put into the end of the buffer; the
* .01 is added for modf(356.0 / 10, &integer) returning .59999999...
*/
for (p = endp - 1; integer; ++expcnt) {
tmp = modf(integer / 10, &integer);
*p-- = to_char((int)((tmp + .01) * 10));
}
switch (fmtch) {
case 'f':
/* reverse integer into beginning of buffer */
if (expcnt)
for (; ++p < endp; *t++ = *p);
else
*t++ = '0';
/*
* if precision required or alternate flag set, add in a
* decimal point.
*/
if (prec || flags&ALT)
*t++ = '.';
/* if requires more precision and some fraction left */
if (fract) {
if (prec)
do {
fract = modf(fract * 10, &tmp);
*t++ = to_char((int)tmp);
} while (--prec && fract);
if (fract)
startp = round(fract, (int *)NULL, startp,
t - 1, (char)0, signp);
}
for (; prec--; *t++ = '0');
break;
case 'e':
case 'E':
eformat: if (expcnt) {
*t++ = *++p;
if (prec || flags&ALT)
*t++ = '.';
/* if requires more precision and some integer left */
for (; prec && ++p < endp; --prec)
*t++ = *p;
/*
* if done precision and more of the integer component,
* round using it; adjust fract so we don't re-round
* later.
*/
if (!prec && ++p < endp) {
fract = 0;
startp = round((double)0, &expcnt, startp,
t - 1, *p, signp);
}
/* adjust expcnt for digit in front of decimal */
--expcnt;
}
/* until first fractional digit, decrement exponent */
else if (fract) {
/* adjust expcnt for digit in front of decimal */
for (expcnt = -1;; --expcnt) {
fract = modf(fract * 10, &tmp);
if (tmp)
break;
}
*t++ = to_char((int)tmp);
if (prec || flags&ALT)
*t++ = '.';
}
else {
*t++ = '0';
if (prec || flags&ALT)
*t++ = '.';
}
/* if requires more precision and some fraction left */
if (fract) {
if (prec)
do {
fract = modf(fract * 10, &tmp);
*t++ = to_char((int)tmp);
} while (--prec && fract);
if (fract)
startp = round(fract, &expcnt, startp,
t - 1, (char)0, signp);
}
/* if requires more precision */
for (; prec--; *t++ = '0');
 
/* unless alternate flag, trim any g/G format trailing 0's */
if (gformat && !(flags&ALT)) {
while (t > startp && *--t == '0');
if (*t == '.')
--t;
++t;
}
t = exponent(t, expcnt, fmtch);
break;
case 'g':
case 'G':
/* a precision of 0 is treated as a precision of 1. */
if (!prec)
++prec;
/*
* ``The style used depends on the value converted; style e
* will be used only if the exponent resulting from the
* conversion is less than -4 or greater than the precision.''
* -- ANSI X3J11
*/
if (expcnt > prec || (!expcnt && fract && fract < .0001)) {
/*
* g/G format counts "significant digits, not digits of
* precision; for the e/E format, this just causes an
* off-by-one problem, i.e. g/G considers the digit
* before the decimal point significant and e/E doesn't
* count it as precision.
*/
--prec;
fmtch -= 2; /* G->E, g->e */
gformat = 1;
goto eformat;
}
/*
* reverse integer into beginning of buffer,
* note, decrement precision
*/
if (expcnt)
for (; ++p < endp; *t++ = *p, --prec);
else
*t++ = '0';
/*
* if precision required or alternate flag set, add in a
* decimal point. If no digits yet, add in leading 0.
*/
if (prec || flags&ALT) {
dotrim = 1;
*t++ = '.';
}
else
dotrim = 0;
/* if requires more precision and some fraction left */
if (fract) {
if (prec) {
do {
fract = modf(fract * 10, &tmp);
*t++ = to_char((int)tmp);
} while(!tmp);
while (--prec && fract) {
fract = modf(fract * 10, &tmp);
*t++ = to_char((int)tmp);
}
}
if (fract)
startp = round(fract, (int *)NULL, startp,
t - 1, (char)0, signp);
}
/* alternate format, adds 0's for precision, else trim 0's */
if (flags&ALT)
for (; prec--; *t++ = '0');
else if (dotrim) {
while (t > startp && *--t == '0');
if (*t != '.')
++t;
}
}
} else {
unsigned case_adj;
switch (fmtch) {
case 'f':
case 'g':
case 'e':
case_adj = 'a' - 'A';
break;
default:
case_adj = 0;
}
if (isnan(number)) {
*t++ = 'N' + case_adj;
*t++ = 'A' + case_adj;
*t++ = 'N' + case_adj;
} else { // infinite
*t++ = 'I' + case_adj;
*t++ = 'N' + case_adj;
*t++ = 'F' + case_adj;
}
}
return (t - startp);
} // cvt()
 
#endif // ifdef CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT
 
// EOF vfnprintf.cxx
/v2_0/src/common/setvbuf.cxx
0,0 → 1,129
//===========================================================================
//
// setvbuf.cxx
//
// Implementation of C library buffering setup as per ANSI 7.9.5.6
//
//===========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//===========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-20
// Purpose:
// Description:
// Usage:
//
//####DESCRIPTIONEND####
//
//===========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // Common project-wide type definitions
#include <stddef.h> // NULL and size_t from compiler
#include <errno.h> // Error codes
#include <stdio.h> // header for setvbuf()
#include <cyg/libc/stdio/stream.hxx>// C libray streams
 
// FUNCTIONS
 
 
externC int
setvbuf( FILE *stream, char *buf, int mode, size_t size )
{
#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO
 
Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream;
Cyg_ErrNo err;
#ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS
if ( !real_stream->lock_me() ) {
errno = EBADF;
return EBADF;
} // if
#endif
 
err = real_stream->io_buf.set_buffer( (cyg_ucount32) size,
(cyg_uint8 *) buf );
if (!err) {
switch (mode) {
case _IONBF:
CYG_ASSERT( (size == 0) && (buf == NULL),
"No buffering wanted but size/address specified!" );
real_stream->flags.buffering = false;
real_stream->flags.line_buffering = false;
break;
case _IOLBF:
real_stream->flags.buffering = true;
real_stream->flags.line_buffering = true;
break;
case _IOFBF:
real_stream->flags.buffering = true;
real_stream->flags.line_buffering = false;
break;
default:
err = EINVAL;
break;
} // switch
} // if
 
#ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS
real_stream->unlock_me();
#endif
if (err) {
errno = err;
return err;
} // if
return 0;
 
#else // ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO
 
errno = ENOSUPP;
return ENOSUPP;
 
#endif // ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO
 
} // setvbuf()
 
// EOF setvbuf.cxx
/v2_0/src/common/feof.cxx
0,0 → 1,92
//========================================================================
//
// feof.cxx
//
// Implementations of ISO C feof(), ferror(), clearerr() functions
//
//========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2001-03-16
// Purpose: Implementations of ISO C feof(), ferror(), clearerr()
// functions
// Description:
// Usage:
//
//####DESCRIPTIONEND####
//
//========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // Common type definitions and support
#include <stdio.h> // Header for this file
#include <cyg/libc/stdio/stream.hxx> // Cyg_StdioStream class
 
externC int
feof( FILE *stream )
{
Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream;
 
return (real_stream->get_eof_state() != 0);
} // feof()
 
externC int
ferror( FILE *stream )
{
Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream;
 
return (real_stream->get_error() != 0);
} // ferror()
 
externC void
clearerr( FILE *stream )
{
Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream;
 
real_stream->set_error(0);
real_stream->set_eof_state(false);
} // clearerr()
 
 
 
// EOF feof.cxx
/v2_0/src/common/stdin.cxx
0,0 → 1,110
//========================================================================
//
// stdin.cxx
//
// Initialization of stdin stream for ISO C library
//
//========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-20
// Purpose: Initialization of stdin stream for ISO C library
// Description: We put all this in a separate file in the hope that if
// no-one uses stdin, then it is not included in the image
// Usage:
//
//####DESCRIPTIONEND####
//
//========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
// Don't let us get the stream definitions of stdin/out/err from stdio.h
// since we are going to break the type safety :-(
#define CYGPRI_LIBC_STDIO_NO_DEFAULT_STREAMS
 
// And we don't need the stdio inlines, which will otherwise complain if
// stdin/out/err are not available
#ifdef CYGIMP_LIBC_STDIO_INLINES
# undef CYGIMP_LIBC_STDIO_INLINES
#endif
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // Common type definitions and support
#include <cyg/libc/stdio/stream.hxx> // Cyg_StdioStream class
#include <cyg/libc/stdio/stdiofiles.hxx> // C library files
#include <cyg/libc/stdio/stdiosupp.hxx> // Cyg_libc_stdio_find_filename()
 
// CONSTANTS
 
// Use default libc priority to allow it to be the fd 0 if necessary
#define PRIO (CYG_INIT_LIBC)
 
// STATICS
 
Cyg_StdioStream
cyg_libc_stdio_stdin CYGBLD_ATTRIB_INIT_PRI(PRIO) = Cyg_StdioStream(
Cyg_libc_stdio_find_filename(CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE,
Cyg_StdioStream::CYG_STREAM_READ, false, false),
Cyg_StdioStream::CYG_STREAM_READ, false, false, _IOLBF );
 
 
// CLASSES
 
// This is a dummy class just so we can execute arbitrary code when
// stdin is requested
 
class cyg_libc_dummy_stdin_init_class {
public:
cyg_libc_dummy_stdin_init_class(void) {
Cyg_libc_stdio_files::set_file_stream(0, &cyg_libc_stdio_stdin);
}
};
 
// And here's an instance of the class just to make the code run
static cyg_libc_dummy_stdin_init_class cyg_libc_dummy_stdin_init
CYGBLD_ATTRIB_INIT_PRI(PRIO);
 
// and finally stdin itself
__externC Cyg_StdioStream * const stdin;
Cyg_StdioStream * const stdin=&cyg_libc_stdio_stdin;
 
// EOF stdin.cxx
/v2_0/src/common/stdout.cxx
0,0 → 1,110
//========================================================================
//
// stdout.cxx
//
// Initialization of stdout stream for ISO C library
//
//========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-20
// Purpose: Initialization of stdout stream for ISO C library
// Description: We put all this in a separate file in the hope that if
// no-one uses stdout, then it is not included in the image
// Usage:
//
//####DESCRIPTIONEND####
//
//========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
// Don't let us get the stream definitions of stdin/out/err from stdio.h
// since we are going to break the type safety :-(
#define CYGPRI_LIBC_STDIO_NO_DEFAULT_STREAMS
 
// And we don't need the stdio inlines, which will otherwise complain if
// stdin/out/err are not available
#ifdef CYGIMP_LIBC_STDIO_INLINES
# undef CYGIMP_LIBC_STDIO_INLINES
#endif
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // Common type definitions and support
#include <cyg/libc/stdio/stream.hxx> // Cyg_StdioStream class
#include <cyg/libc/stdio/stdiofiles.hxx> // C library files
#include <cyg/libc/stdio/stdiosupp.hxx> // Cyg_libc_stdio_find_filename()
 
// CONSTANTS
 
// add 1 to the priority to allow it to be the fd 1 if necessary
#define PRIO (CYG_INIT_LIBC+1)
 
// STATICS
 
Cyg_StdioStream
cyg_libc_stdio_stdout CYGBLD_ATTRIB_INIT_PRI(PRIO) = Cyg_StdioStream(
Cyg_libc_stdio_find_filename(CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE,
Cyg_StdioStream::CYG_STREAM_WRITE,
false, false),
Cyg_StdioStream::CYG_STREAM_WRITE, false, false, _IOLBF );
 
// CLASSES
 
// This is a dummy class just so we can execute arbitrary code when
// stdout is requested
 
class cyg_libc_dummy_stdout_init_class {
public:
cyg_libc_dummy_stdout_init_class(void) {
Cyg_libc_stdio_files::set_file_stream(1, &cyg_libc_stdio_stdout);
}
};
 
// And here's an instance of the class just to make the code run
static cyg_libc_dummy_stdout_init_class cyg_libc_dummy_stdout_init
CYGBLD_ATTRIB_INIT_PRI(PRIO);
 
// and finally stdout itself
__externC Cyg_StdioStream * const stdout;
Cyg_StdioStream * const stdout=&cyg_libc_stdio_stdout;
 
// EOF stdout.cxx
/v2_0/src/common/ungetc.cxx
0,0 → 1,94
//===========================================================================
//
// ungetc.cxx
//
// ANSI Stdio ungetc() function
//
//===========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//===========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-20
// Purpose:
// Description:
// Usage:
//
//####DESCRIPTIONEND####
//
//===========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // Common project-wide type definitions
#include <stddef.h> // NULL and size_t from compiler
#include <stdio.h> // header for this file
#include <errno.h> // error codes
#include <cyg/libc/stdio/stream.hxx> // Cyg_StdioStream
 
 
// FUNCTIONS
 
externC int
ungetc( int c, FILE *stream )
{
Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream;
Cyg_ErrNo err;
cyg_uint8 real_c;
if (c == EOF)
return EOF;
 
real_c = (cyg_uint8) c;
 
err = real_stream->unread_byte( real_c );
 
if (err)
{
errno = err;
return EOF;
} // if
return (int)real_c;
 
} // ungetc()
 
// EOF ungetc.cxx
/v2_0/src/common/sprintf.cxx
0,0 → 1,82
//===========================================================================
//
// sprintf.cxx
//
// ANSI Stdio sprintf() function
//
//===========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//===========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-20
// Purpose:
// Description:
// Usage:
//
//####DESCRIPTIONEND####
//
//===========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // Common project-wide type definitions
#include <stddef.h> // NULL and size_t from compiler
#include <stdio.h> // header for this file
#include <limits.h> // INT_MAX
 
// FUNCTIONS
 
externC int
sprintf( char *s, const char *format, ... )
{
int rc; // return code
va_list ap; // for variable args
 
va_start(ap, format); // init specifying last non-var arg
 
rc = vsnprintf(s, INT_MAX, format, ap);
 
va_end(ap); // end var args
 
return rc;
} // sprintf()
 
// EOF sprintf.cxx
/v2_0/src/common/fflush.cxx
0,0 → 1,151
//========================================================================
//
// fflush.cxx
//
// Implementation of C library file flush function as per ANSI 7.9.5.2
//
//========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-20
// Purpose: Provides ISO C fflush() function
// Description:
// Usage:
//
//####DESCRIPTIONEND####
//
//========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // Common project-wide type definitions
#include <stddef.h> // NULL and size_t from compiler
#include <errno.h> // Error codes
#include <stdio.h> // header for fflush()
#include <cyg/libc/stdio/stream.hxx>// C library streams
#include <cyg/libc/stdio/stdiofiles.hxx> // C library files
#include <cyg/libc/stdio/stdiosupp.hxx> // support for stdio
 
// FUNCTIONS
 
// flush all but one stream
externC Cyg_ErrNo
cyg_libc_stdio_flush_all_but( Cyg_StdioStream *not_this_stream )
{
cyg_bool files_flushed[FOPEN_MAX] = { false }; // sets all to 0
cyg_bool loop_again, looped = false;
cyg_ucount32 i;
Cyg_ErrNo err=ENOERR;
Cyg_StdioStream *stream;
 
do {
loop_again = false;
 
for (i=0; (i<FOPEN_MAX) && !err; i++) {
if (files_flushed[i] == false) {
stream = Cyg_libc_stdio_files::get_file_stream(i);
if ((stream == NULL) || (stream == not_this_stream)) {
// if it isn't a valid stream, set its entry in the
// list of files flushed since we don't want to
// flush it
// Ditto if its the one we're meant to miss
files_flushed[i] = true;
} // if
else {
// valid stream
#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO
// only buffers which we've written to need flushing
if ( !stream->flags.last_buffer_op_was_read)
#endif
{
// we try to flush the first time through so that
// everything is flushed that can be flushed.
// The second time through we should just wait
// in case some other lowerpri thread has locked the
// stream, otherwise we will spin needlessly and
// never let the lower pri thread run!
if ( (looped && stream->lock_me()) ||
stream->trylock_me() ) {
err = stream->flush_output_unlocked();
stream->unlock_me();
files_flushed[i] = true;
} // if
else {
loop_again = true;
looped = true;
}
}
} // else
} // if
} // for
} // do
while(loop_again && !err);
return err;
} // cyg_libc_stdio_flush_all_but()
 
externC int
fflush( FILE *stream )
{
Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream;
Cyg_ErrNo err;
 
if (stream == NULL) { // tells us to flush ALL streams
err = cyg_libc_stdio_flush_all_but(NULL);
} // if
else {
err = real_stream->flush_output();
} // else
 
if (err) {
errno = err;
return EOF;
} // if
 
return 0;
 
} // fflush()
// EOF fflush.cxx
/v2_0/src/common/streambuf.cxx
0,0 → 1,141
//===========================================================================
//
// streambuf.cxx
//
// C library stdio stream buffer functions
//
//===========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//===========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-20
// Purpose:
// Description:
// Usage:
//
//####DESCRIPTIONEND####
//
//===========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
// Include buffered I/O?
#if defined(CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO)
 
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // Common project-wide type definitions
#include <cyg/infra/cyg_ass.h> // Assertion support
#include <errno.h> // Cyg_ErrNo
#include <stdlib.h> // malloc() and free()
#include <cyg/libc/stdio/streambuf.hxx> // header for this file, just in case
 
// FUNCTIONS
Cyg_ErrNo
Cyg_StdioStreamBuffer::set_buffer( cyg_ucount32 size,
cyg_uint8 *new_buffer )
{
#ifdef CYGSEM_LIBC_STDIO_DYNAMIC_SETVBUF
// user-supplied buffer?
if (new_buffer != NULL) {
CYG_CHECK_DATA_PTR(new_buffer, "new_buffer not valid");
#ifdef CYGSEM_LIBC_STDIO_SETVBUF_MALLOC
// first check if we were responsible for the old buffer
if (call_free) {
free(buffer_bottom);
call_free = false;
}
#endif
buffer_bottom = new_buffer;
}
#ifdef CYGSEM_LIBC_STDIO_SETVBUF_MALLOC
else if ( size != buffer_size ) { // as long as its different from
// what we've got now
cyg_uint8 *malloced_buf;
 
malloced_buf = (cyg_uint8 * )malloc( size );
if (malloced_buf == NULL)
return ENOMEM;
 
// should the old buffer be freed? This waits till after we know
// whether the malloc succeeded
if (call_free)
free( buffer_bottom );
buffer_bottom = malloced_buf;
 
call_free=true;
 
} // else if
#else
// Here we have not been given a new buffer, but have been given
// a new buffer size. If possible, we just shrink what we already
// have.
else if( size > buffer_size )
return EINVAL;
#endif
#else // ifdef CYGSEM_LIBC_STDIO_DYNAMIC_SETVBUF
// In this config we can't use a different buffer, or set a
// size greater than now. We can pretend to shrink it though
// Note on the next line we compare it with the size of static_buffer
// and not the current size, as that's what is the limiting factor
if ( (new_buffer != NULL) || (size > sizeof(static_buffer)) )
return EINVAL;
#endif // ifdef CYGSEM_LIBC_STDIO_DYNAMIC_SETVBUF
buffer_top = current_buffer_position = &buffer_bottom[0];
buffer_size = size;
return ENOERR;
} // set_buffer()
 
 
#endif // if defined(CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO)
 
 
// EOF streambuf.cxx
/v2_0/src/common/vsnprintf.cxx
0,0 → 1,152
//===========================================================================
//
// vsnprintf.cxx
//
// ANSI Stdio vsnprintf() function
//
//===========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//===========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors: jlarmour
// Date: 1998-02-13
// Purpose:
// Description:
// Usage:
//
//####DESCRIPTIONEND####
//
//===========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // Common project-wide type definitions
#include <stddef.h> // NULL and size_t from compiler
#include <stdio.h> // header for this file
#include <errno.h> // error codes
#include <cyg/io/devtab.h> // Device table
#include <cyg/libc/stdio/stream.hxx>// Cyg_StdioStream
 
#include <cyg/libc/stdio/io.inl> // I/O system inlines
 
#ifndef CYGPKG_LIBC_STDIO_FILEIO
 
// FUNCTIONS
 
static Cyg_ErrNo
str_write(cyg_stdio_handle_t handle, const void *buf, cyg_uint32 *len)
{
cyg_devtab_entry_t *dev = (cyg_devtab_entry_t *)handle;
cyg_uint8 **str_p = (cyg_uint8 **)dev->priv;
cyg_ucount32 i;
 
// I suspect most strings passed to vsnprintf will be relatively short,
// so we just take the simple approach rather than have the overhead
// of calling memcpy etc.
 
// simply copy string until we run out of user space
 
for (i = 0; i < *len; i++, (*str_p)++ )
{
**str_p = *((cyg_uint8 *)buf + i);
} // for
 
*len = i;
 
return ENOERR;
} // str_write()
 
static DEVIO_TABLE(devio_table,
str_write, // write
NULL, // read
NULL, // select
NULL, // get_config
NULL); // set_config
 
externC int
vsnprintf( char *s, size_t size, const char *format, va_list arg )
{
int rc;
// construct a fake device with the address of the string we've
// been passed as its private data. This way we can use the data
// directly
DEVTAB_ENTRY_NO_INIT(strdev,
"strdev", // Name
NULL, // Dependent name (layered device)
&devio_table, // I/O function table
NULL, // Init
NULL, // Lookup
&s); // private
Cyg_StdioStream my_stream( &strdev, Cyg_StdioStream::CYG_STREAM_WRITE,
false, false, _IONBF, 0, NULL );
rc = vfnprintf( (FILE *)&my_stream, size, format, arg );
 
// Null-terminate it, but note that s has been changed by str_write(), so
// that it now points to the end of the string
s[0] = '\0';
 
return rc;
 
} // vsnprintf()
 
#else
 
externC int
vsnprintf( char *s, size_t size, const char *format, va_list arg )
{
int rc;
 
Cyg_StdioStream my_stream( Cyg_StdioStream::CYG_STREAM_WRITE,
size, (cyg_uint8 *)s );
rc = vfnprintf( (FILE *)&my_stream, size, format, arg );
 
if( rc > 0 )
s[rc] = '\0';
 
return rc;
 
} // vsnprintf()
 
#endif
 
// EOF vsnprintf.cxx
/v2_0/src/common/stdiosupp.cxx
0,0 → 1,83
//===========================================================================
//
// stdiosupp.cxx
//
// Helper C library functions for standard I/O
//
//===========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//===========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-20
// Purpose:
// Description:
// Usage:
//
//####DESCRIPTIONEND####
//
//===========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // Common project-wide type definitions
#include <stddef.h> // NULL and size_t from compiler
#include <cyg/libc/stdio/io.hxx> // I/O system
#include <cyg/libc/stdio/stdiosupp.hxx> // Header for this file
 
#include <cyg/libc/stdio/io.inl> // I/O system inlines
 
//externC void cyg_io_init(void);
 
cyg_stdio_handle_t
Cyg_libc_stdio_find_filename( const char *filename,
const Cyg_StdioStream::OpenMode rw,
const cyg_bool binary,
const cyg_bool append )
{
cyg_stdio_handle_t dev = CYG_STDIO_HANDLE_NULL;
 
cyg_stdio_open(filename, rw, binary, append, &dev);
return dev;
} // Cyg_libc_stdio_find_filename()
 
 
// EOF stdiosupp.cxx
/v2_0/src/common/stream.cxx
0,0 → 1,692
//========================================================================
//
// stream.cxx
//
// Implementations of internal C library stdio stream functions
//
//========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-20
// Purpose:
// Description:
// Usage:
//
//####DESCRIPTIONEND####
//
//========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // Common project-wide type definitions
#include <cyg/infra/cyg_ass.h> // Assertion infrastructure
#include <stddef.h> // NULL and size_t from compiler
#include <errno.h> // Error codes
#include <string.h> // memcpy() and memset()
#include <cyg/libc/stdio/stream.hxx> // Header for this file
#include <cyg/libc/stdio/stdiosupp.hxx> // Stdio support functions
 
 
#include <cyg/libc/stdio/io.inl> // I/O system inlines
 
 
// FUNCTIONS
 
Cyg_StdioStream::Cyg_StdioStream(cyg_stdio_handle_t dev,
OpenMode open_mode,
cyg_bool append, cyg_bool binary,
int buffer_mode, cyg_ucount32 buffer_size,
cyg_uint8 *buffer_addr )
#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO
: io_buf( buffer_size, buffer_addr )
#endif
{
initialize( dev, open_mode, append, binary, buffer_mode,
buffer_size, buffer_addr);
}
 
void Cyg_StdioStream::initialize(cyg_stdio_handle_t dev,
OpenMode open_mode,
cyg_bool append, cyg_bool binary,
int buffer_mode, cyg_ucount32 buffer_size,
cyg_uint8 *buffer_addr )
{
 
#ifdef CYGDBG_USE_ASSERTS
magic_validity_word = 0xbadbad;
#endif
 
my_device = dev;
 
// Clear all flags
memset( &flags, 0, sizeof(flags) );
 
switch (open_mode) {
case CYG_STREAM_READ:
flags.opened_for_read = true;
break;
case CYG_STREAM_WRITE:
flags.opened_for_write = true;
break;
case CYG_STREAM_READWRITE:
flags.opened_for_read = true;
flags.opened_for_write = true;
break;
default:
error=EINVAL;
return;
} // switch
if (flags.opened_for_write) {
#if 0
// FIXME: need some replacement for this
if (!my_device->write_blocking) {
error = EDEVNOSUPP;
return;
} // if
#endif
#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO
flags.last_buffer_op_was_read = false;
#endif
} // if
 
 
if (flags.opened_for_read) {
#if 0
// FIXME: need some replacement for this
if (!my_device->read_blocking) {
error = EDEVNOSUPP;
return;
} // if
#endif
 
// NB also if opened for read AND write, then say last op was read
#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO
flags.last_buffer_op_was_read = true;
#endif
} // if
 
flags.binary = binary ? 1 : 0;
 
error = ENOERR;
// in due course we would do an equivalent to fseek(...,0, SEEK_END);
// when appending. for now, there's nothing, except set eof
flags.at_eof = append ? 1 : 0;
 
position = 0;
 
#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO
 
switch (buffer_mode) {
case _IONBF:
CYG_ASSERT( (buffer_size == 0) && (buffer_addr == NULL),
"No buffering wanted but size/address specified!" );
flags.buffering = flags.line_buffering = false;
break;
case _IOLBF:
flags.buffering = true;
flags.line_buffering = true;
break;
case _IOFBF:
flags.buffering = true;
flags.line_buffering = false;
break;
default:
error = EINVAL;
return;
} // switch
 
// one way of checking the buffer was set up correctly
if (flags.buffering && io_buf.get_buffer_size()==-1) {
error = ENOMEM;
return;
}
 
#endif
 
#if 0 // FIXME - Need to set binary mode.
if (my_device->open) {
error = (*my_device->open)( my_device->cookie,
binary ? CYG_DEVICE_OPEN_MODE_RAW
: CYG_DEVICE_OPEN_MODE_TEXT );
if (error != ENOERR)
return; // keep error code the same
} // if
#endif
 
#ifdef CYGDBG_USE_ASSERTS
magic_validity_word = 0x7b4321ce;
#endif
} // Cyg_StdioStream constructor
 
 
Cyg_StdioStream::Cyg_StdioStream( OpenMode open_mode,
cyg_ucount32 buffer_size,
cyg_uint8 *buffer_addr )
#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO
: io_buf( buffer_size, buffer_addr )
#endif
{
initialize( CYG_STDIO_HANDLE_NULL, open_mode, false, false, _IOFBF,
buffer_size, buffer_addr );
 
if( error != ENOERR )
return;
switch( open_mode )
{
case CYG_STREAM_READ:
// Fix up the stream so it looks like the buffer contents has just
// been read in.
#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO
io_buf.set_bytes_written( buffer_size );
#endif
break;
case CYG_STREAM_WRITE:
// Fix up the stream so it looks like the buffer is ready to accept
// new data.
break;
 
default:
error = EINVAL;
return;
}
}
 
 
Cyg_ErrNo
Cyg_StdioStream::refill_read_buffer( void )
{
Cyg_ErrNo read_err;
cyg_uint8 *buffer;
cyg_uint32 len;
 
CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" );
if (!lock_me())
return EBADF; // assume file is now invalid
 
// first just check that we _can_ read this device!
if (!flags.opened_for_read) {
unlock_me();
return EINVAL;
}
#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO
// If there is pending output to write, then this will check and
// write it
if (flags.buffering) {
read_err = flush_output_unlocked();
 
// we're now reading
flags.last_buffer_op_was_read = true;
 
// flush ALL streams
if (read_err == ENOERR)
read_err = cyg_libc_stdio_flush_all_but(this);
 
if (read_err != ENOERR) {
unlock_me();
return read_err;
} // if
 
len = io_buf.get_buffer_addr_to_write( (cyg_uint8**)&buffer );
if (!len) { // no buffer space available
unlock_me();
return ENOERR; // isn't an error, just needs user to read out data
} // if
}
else
#endif
 
if (!flags.readbuf_char_in_use) {
len = 1;
buffer = &readbuf_char;
}
else {
// no buffer space available
unlock_me();
return ENOERR; // isn't an error, just needs user to read out data
} // else
 
read_err = cyg_stdio_read(my_device, buffer, &len);
 
 
#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO
if (flags.buffering)
io_buf.set_bytes_written( len );
else
#endif
flags.readbuf_char_in_use = len ? 1 : 0;
 
unlock_me();
 
if (read_err == ENOERR) {
if (len == 0) {
read_err = EAGAIN;
flags.at_eof = true;
}
else
flags.at_eof = false;
} // if
return read_err;
} // refill_read_buffer()
 
 
Cyg_ErrNo
Cyg_StdioStream::read( cyg_uint8 *user_buffer, cyg_ucount32 buffer_length,
cyg_ucount32 *bytes_read )
{
CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" );
*bytes_read = 0;
 
if (!lock_me())
return EBADF; // assume file is now invalid
 
if (!flags.opened_for_read) {
unlock_me();
return EINVAL;
}
 
#ifdef CYGFUN_LIBC_STDIO_ungetc
if (flags.unread_char_buf_in_use && buffer_length) {
*user_buffer++ = unread_char_buf;
++*bytes_read;
flags.unread_char_buf_in_use = false;
--buffer_length;
} // if
 
#endif // ifdef CYGFUN_LIBC_STDIO_ungetc
 
#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO
if (flags.buffering) {
 
// need to flush output if we were writing before
if (!flags.last_buffer_op_was_read) {
Cyg_ErrNo err = flush_output_unlocked();
 
if (ENOERR != err) {
unlock_me();
return err;
}
}
cyg_uint8 *buff_to_read_from;
cyg_ucount32 bytes_available;
bytes_available = io_buf.get_buffer_addr_to_read(
(cyg_uint8 **)&buff_to_read_from );
cyg_ucount32 count =
(bytes_available < buffer_length) ? bytes_available : buffer_length;
 
if (count) {
memcpy( user_buffer, buff_to_read_from, count );
io_buf.set_bytes_read( count );
*bytes_read += count;
} // if
 
} // if
else
#endif
 
if (flags.readbuf_char_in_use && buffer_length) {
*user_buffer = readbuf_char;
*bytes_read = 1;
flags.readbuf_char_in_use = false;
}
 
position += *bytes_read;
unlock_me();
 
return ENOERR;
} // read()
 
 
Cyg_ErrNo
Cyg_StdioStream::read_byte( cyg_uint8 *c )
{
Cyg_ErrNo err=ENOERR;
 
CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" );
if (!lock_me())
return EBADF; // assume file is now invalid
 
if (!flags.opened_for_read) {
unlock_me();
return EINVAL;
}
 
# ifdef CYGFUN_LIBC_STDIO_ungetc
if (flags.unread_char_buf_in_use) {
*c = unread_char_buf;
flags.unread_char_buf_in_use = false;
position++;
unlock_me();
return ENOERR;
} // if
# endif // ifdef CYGFUN_LIBC_STDIO_ungetc
 
#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO
if (flags.buffering) {
// need to flush output if we were writing before
if (!flags.last_buffer_op_was_read)
err = flush_output_unlocked();
 
if (ENOERR != err) {
unlock_me();
return err;
}
cyg_uint8 *buff_to_read_from;
cyg_ucount32 bytes_available;
bytes_available=io_buf.get_buffer_addr_to_read(&buff_to_read_from);
 
if (bytes_available) {
*c = *buff_to_read_from;
io_buf.set_bytes_read(1);
position++;
}
else
err = EAGAIN;
} // if
else
#endif
 
 
if (flags.readbuf_char_in_use) {
*c = readbuf_char;
flags.readbuf_char_in_use = false;
position++;
}
else
err = EAGAIN;
 
unlock_me();
 
return err;
} // read_byte()
 
 
Cyg_ErrNo
Cyg_StdioStream::peek_byte( cyg_uint8 *c )
{
Cyg_ErrNo err=ENOERR;
 
CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" );
if (!lock_me())
return EBADF; // assume file is now invalid
 
if (!flags.opened_for_read) {
unlock_me();
return EINVAL;
}
 
// this should really only be called after refill_read_buffer, but just
// in case
#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO
if (flags.buffering)
err = flush_output_unlocked();
 
if (err != ENOERR)
return err;
 
// we're now reading
flags.last_buffer_op_was_read = true;
#endif
 
# ifdef CYGFUN_LIBC_STDIO_ungetc
if (flags.unread_char_buf_in_use) {
*c = unread_char_buf;
unlock_me();
return ENOERR;
} // if
# endif // ifdef CYGFUN_LIBC_STDIO_ungetc
 
#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO
if (flags.buffering) {
cyg_uint8 *buff_to_read_from;
cyg_ucount32 bytes_available;
bytes_available=io_buf.get_buffer_addr_to_read(&buff_to_read_from);
 
if (bytes_available) {
*c = *buff_to_read_from;
}
else
err = EAGAIN;
} // if
else
#endif
 
 
if (flags.readbuf_char_in_use) {
*c = readbuf_char;
}
else
err = EAGAIN;
 
unlock_me();
 
return err;
} // peek_byte()
 
 
Cyg_ErrNo
Cyg_StdioStream::flush_output_unlocked( void )
{
#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO
Cyg_ErrNo write_err=ENOERR;
cyg_uint8 *buffer;
cyg_uint32 len;
 
CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" );
if ( flags.last_buffer_op_was_read )
return ENOERR;
 
// first just check that we _can_ write to the device!
if ( !flags.opened_for_write )
return EINVAL;
 
// shortcut if nothing to do
if (io_buf.get_buffer_space_used() == 0)
return ENOERR;
len = io_buf.get_buffer_addr_to_read( (cyg_uint8 **)&buffer );
CYG_ASSERT( len > 0,
"There should be data to read but there isn't!");
 
write_err = cyg_stdio_write(my_device, buffer, &len);
 
// since we're doing a concerted flush, we tell the I/O layer to
// flush too, otherwise output may just sit there forever
if (!write_err)
cyg_stdio_flush( my_device );
// we've just read it all, so just wipe it out
io_buf.drain_buffer();
 
return write_err;
 
#else // ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO
 
CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" );
return ENOERR;
 
#endif // ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO
} // flush_output_unlocked()
 
 
 
Cyg_ErrNo
Cyg_StdioStream::write( const cyg_uint8 *buffer,
cyg_ucount32 buffer_length,
cyg_ucount32 *bytes_written )
{
Cyg_ErrNo write_err = ENOERR;
 
CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" );
*bytes_written = 0;
 
if (!lock_me())
return EBADF; // assume file is now invalid
 
// first just check that we _can_ write to the device!
if ( !flags.opened_for_write ) {
unlock_me();
return EINVAL;
}
 
#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO
if (flags.last_buffer_op_was_read == true)
io_buf.drain_buffer(); // nuke input bytes to prevent confusion
 
flags.last_buffer_op_was_read = false;
 
if (!flags.buffering) {
#endif
cyg_uint32 len = buffer_length;
 
write_err = cyg_stdio_write(my_device, buffer, &len);
 
*bytes_written = len;
 
#ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO
} // if
else {
cyg_ucount32 bytes_available;
cyg_ucount32 bytes_to_write;
cyg_ucount32 newline_pos;
cyg_uint8 *write_addr;
cyg_bool must_flush = false;
while ( buffer_length > 0 ) {
bytes_available =
io_buf.get_buffer_addr_to_write( &write_addr );
// we need to flush if we've no room or the buffer has an up
// and coming newline
if ( !bytes_available || must_flush ) {
write_err = flush_output_unlocked();
// harmless even if there was an error
bytes_available =
io_buf.get_buffer_addr_to_write( &write_addr );
 
CYG_ASSERT( bytes_available > 0,
"Help! still no bytes available in "
"write buffer" );
} // if
if (write_err) {
unlock_me();
return write_err;
} // if
// choose the lower of the buffer available and the length
// to write
bytes_to_write=(bytes_available < buffer_length)
? bytes_available
: buffer_length;
// if we're line buffered, we may want want to flush if there's
// a newline character, so lets find out
if (flags.line_buffering) {
for (newline_pos=0;
newline_pos<bytes_to_write;
newline_pos++) {
if (buffer[newline_pos] == '\n') {
break;
} // if
} // for
// if we didn't reach the end
if (newline_pos != bytes_to_write) {
// shrink bytes_to_write down to the bit we need to
// flush including the newline itself
bytes_to_write = newline_pos + 1;
must_flush = true;
} // if
} // if
memcpy( write_addr, buffer, bytes_to_write );
*bytes_written += bytes_to_write;
buffer += bytes_to_write;
buffer_length -= bytes_to_write;
io_buf.set_bytes_written( bytes_to_write );
 
position += bytes_to_write;
} // while
if ( must_flush ) {
write_err = flush_output_unlocked();
} // if
} // else
#endif // ifdef CYGSEM_LIBC_STDIO_WANT_BUFFERED_IO
 
unlock_me();
 
return write_err;
} // write()
 
// EOF stream.cxx
/v2_0/src/common/fseek.cxx
0,0 → 1,167
//===========================================================================
//
// fseek.cxx
//
// Implementation of C library file positioning functions as per ANSI 7.9.9
//
//===========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//===========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): nickg
// Contributors:
// Date: 2000-07-12
// Purpose: Implements ISO C file positioning functions
// Description:
// Usage:
//
//####DESCRIPTIONEND####
//
//===========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
#include <cyg/infra/cyg_type.h> // Common project-wide type definitions
#include <cyg/infra/cyg_ass.h> // Assertion support
#include <cyg/infra/cyg_trac.h> // Tracing support
#include <stddef.h> // NULL and size_t from compiler
#include <errno.h> // Error codes
#include <stdio.h> // header for fseek() etc.
#include <cyg/libc/stdio/stdiofiles.hxx> // C library files
#include <cyg/libc/stdio/stream.hxx> // C library streams
 
//========================================================================
 
// ISO C 7.9.9 File positioning functions
 
externC int
fgetpos( FILE * stream , fpos_t *pos )
{
Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream;
Cyg_ErrNo err;
int ret = 0;
CYG_REPORT_FUNCNAME( "fgetpos" );
 
err = real_stream->get_position( pos );
if( err != ENOERR )
{
errno = err;
ret = -1;
}
CYG_REPORT_RETVAL( ret );
return ret;
}
 
externC int
fseek( FILE * stream , long int offset , int whence )
{
Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream;
Cyg_ErrNo err;
int ret = 0;
CYG_REPORT_FUNCNAME( "fgetpos" );
 
err = real_stream->set_position( (fpos_t)offset, whence );
if( err != ENOERR )
{
errno = err;
ret = -1;
}
CYG_REPORT_RETVAL( ret );
return ret;
}
 
externC int
fsetpos( FILE * stream , const fpos_t * pos )
{
Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream;
Cyg_ErrNo err;
int ret = 0;
CYG_REPORT_FUNCNAME( "fgetpos" );
 
err = real_stream->set_position( *pos, SEEK_SET );
if( err != ENOERR )
{
errno = err;
ret = -1;
}
CYG_REPORT_RETVAL( ret );
return ret;
}
 
externC long int
ftell( FILE * stream )
{
Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream;
Cyg_ErrNo err;
long int ret = 0;
fpos_t pos;
CYG_REPORT_FUNCNAME( "ftell" );
 
err = real_stream->get_position( &pos );
if( err != ENOERR )
{
errno = err;
ret = -1;
}
else ret = pos;
CYG_REPORT_RETVAL( ret );
return ret;
}
 
externC void
rewind( FILE * stream )
{
Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream;
(void)fseek( stream, 0L, SEEK_SET );
 
real_stream->set_error( ENOERR );
}
 
 
// EOF fseek.cxx
/v2_0/src/common/freopen.cxx
0,0 → 1,79
//========================================================================
//
// freopen.cxx
//
// Implementation of C library freopen() function
//
//========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-20
// Purpose: Provides ISO C freopen() function
// Description: Implementation of C library freopen() function as per
// ISO C standard chap. 7.9.5.4
// Usage:
//
//####DESCRIPTIONEND####
//
//========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
// We only want freopen() if we have fopen()
#if defined(CYGPKG_LIBC_STDIO_OPEN)
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // Common project-wide type definitions
#include <stddef.h> // NULL and size_t from compiler
#include <stdio.h> // header for freopen()
 
// FUNCTIONS
 
 
externC FILE *
freopen( const char *, const char *, FILE * )
{
return NULL; // Returning NULL is valid! FIXME
} // freopen()
 
#endif // defined(CYGPKG_LIBC_STDIO_OPEN)
 
// EOF freopen.cxx
/v2_0/src/common/vsscanf.cxx
0,0 → 1,155
//===========================================================================
//
// vsscanf.cxx
//
// ANSI Stdio vsscanf() function
//
//===========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//===========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-20
// Purpose:
// Description:
// Usage:
//
//####DESCRIPTIONEND####
//
//===========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // Common project-wide type definitions
#include <stddef.h> // NULL and size_t from compiler
#include <stdio.h> // header for this file
#include <errno.h> // error codes
#include <cyg/io/devtab.h> // Device table
#include <cyg/libc/stdio/stream.hxx>// Cyg_StdioStream
 
#include <cyg/libc/stdio/io.inl> // I/O system inlines
 
#ifndef CYGPKG_LIBC_STDIO_FILEIO
 
// FUNCTIONS
 
static Cyg_ErrNo
str_read(cyg_stdio_handle_t handle, void *buf, cyg_uint32 *len)
{
cyg_devtab_entry_t *dev = (cyg_devtab_entry_t *)handle;
cyg_uint8 *str_p = (cyg_uint8 *)dev->priv;
cyg_ucount32 i;
 
// we set str_p to NULL further down when the string has finished being
// read
if (str_p == NULL)
{
*len = 0;
return ENOERR;
} // if
 
// I suspect most strings passed to sprintf will be relatively short,
// so we just take the simple approach rather than have the overhead
// of calling memcpy etc.
 
// copy string until run out of user space, or we reach its end
for (i = 0; i < *len ; ++i)
{
*((cyg_uint8 *)buf + i) = *str_p;
 
if (*str_p++ == '\0')
{
str_p = NULL;
++i;
break;
} // if
 
} // for
 
*len = i;
dev->priv = (void *)str_p;
 
return ENOERR;
} // str_read()
 
static DEVIO_TABLE(devio_table,
NULL, // write
str_read, // read
NULL, // select
NULL, // get_config
NULL); // set_config
 
 
externC int
vsscanf( const char *s, const char *format, va_list arg )
{
// construct a fake device with the address of the string we've
// been passed as its private data. This way we can use the data
// directly
DEVTAB_ENTRY_NO_INIT(strdev,
"strdev", // Name
NULL, // Dependent name (layered device)
&devio_table, // I/O function table
NULL, // Init
NULL, // Lookup
(void *)s); // private
Cyg_StdioStream my_stream( &strdev, Cyg_StdioStream::CYG_STREAM_READ,
false, false, _IONBF, 0, NULL );
return vfscanf( (FILE *)&my_stream, format, arg );
 
} // vsscanf()
 
#else
 
externC int
vsscanf( const char *s, const char *format, va_list arg )
{
Cyg_StdioStream my_stream( Cyg_StdioStream::CYG_STREAM_READ,
strlen(s), (cyg_uint8 *)s );
return vfscanf( (FILE *)&my_stream, format, arg );
 
} // vsscanf()
 
#endif
 
// EOF vsscanf.cxx
/v2_0/src/common/snprintf.cxx
0,0 → 1,81
//===========================================================================
//
// snprintf.cxx
//
// ANSI Stdio snprintf() function
//
//===========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//===========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-20
// Purpose:
// Description:
// Usage:
//
//####DESCRIPTIONEND####
//
//===========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // Common project-wide type definitions
#include <stddef.h> // NULL and size_t from compiler
#include <stdio.h> // header for this file
 
// FUNCTIONS
 
externC int
snprintf( char *s, size_t size, const char *format, ... )
{
int rc; // return code
va_list ap; // for variable args
 
va_start(ap, format); // init specifying last non-var arg
 
rc = vsnprintf(s, size, format, ap);
 
va_end(ap); // end var args
 
return rc;
} // snprintf()
 
// EOF snprintf.cxx
/v2_0/src/common/stderr.cxx
0,0 → 1,110
//========================================================================
//
// stderr.cxx
//
// Initialization of stderr stream for ISO C library
//
//========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-20
// Purpose: Initialization of stderr stream for ISO C library
// Description: We put all this in a separate file in the hope that if
// no-one uses stderr, then it is not included in the image
// Usage:
//
//####DESCRIPTIONEND####
//
//========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
// Don't let us get the stream definitions of stdin/out/err from stdio.h
// since we are going to break the type safety :-(
#define CYGPRI_LIBC_STDIO_NO_DEFAULT_STREAMS
 
// And we don't need the stdio inlines, which will otherwise complain if
// stdin/out/err are not available
#ifdef CYGIMP_LIBC_STDIO_INLINES
# undef CYGIMP_LIBC_STDIO_INLINES
#endif
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // Common type definitions and support
#include <cyg/libc/stdio/stream.hxx> // Cyg_StdioStream class
#include <cyg/libc/stdio/stdiofiles.hxx> // C library files
#include <cyg/libc/stdio/stdiosupp.hxx> // Cyg_libc_stdio_find_filename()
 
// CONSTANTS
 
// add 2 to the priority to allow it to be the fd 2 if necessary
#define PRIO (CYG_INIT_LIBC+2)
 
// STATICS
 
Cyg_StdioStream
cyg_libc_stdio_stderr CYGBLD_ATTRIB_INIT_PRI(PRIO) = Cyg_StdioStream(
Cyg_libc_stdio_find_filename(CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE,
Cyg_StdioStream::CYG_STREAM_WRITE,
false, false),
Cyg_StdioStream::CYG_STREAM_WRITE, false, false, _IONBF, 0, NULL );
 
// CLASSES
 
// This is a dummy class just so we can execute arbitrary code when
// stderr is requested
 
class cyg_libc_dummy_stderr_init_class {
public:
cyg_libc_dummy_stderr_init_class(void) {
Cyg_libc_stdio_files::set_file_stream(2, &cyg_libc_stdio_stderr);
}
};
 
// And here's an instance of the class just to make the code run
static cyg_libc_dummy_stderr_init_class cyg_libc_dummy_stderr_init
CYGBLD_ATTRIB_INIT_PRI(PRIO);
 
// and finally stderr itself
__externC Cyg_StdioStream * const stderr;
Cyg_StdioStream * const stderr=&cyg_libc_stdio_stderr;
 
// EOF stderr.cxx
/v2_0/src/common/stdioinlines.cxx
0,0 → 1,164
//===========================================================================
//
// stdioinlines.cxx
//
// ANSI standard I/O routines - real alternatives for inlined functions
//
//===========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//===========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-20
// Purpose:
// Description:
// Usage:
//
//####DESCRIPTIONEND####
//
//===========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
// INCLUDES
 
// We don't want the inline versions of stdio functions defined here
 
#ifdef CYGIMP_LIBC_STDIO_INLINES
#undef CYGIMP_LIBC_STDIO_INLINES
#endif
 
#include <cyg/infra/cyg_type.h> // Common type definitions and support
#include <stddef.h> // NULL and size_t from compiler
#include <stdarg.h> // va_list
#include <stdio.h> // Header for this file
#include <errno.h> // Definition of error codes and errno
#include <string.h> // Definition of strerror() for perror()
#include <limits.h> // INT_MAX
 
 
// FUNCTIONS
 
//===========================================================================
 
// 7.9.5 File access functions
 
externC void
setbuf( FILE *stream, char *buf )
{
if (buf == NULL)
setvbuf( stream, NULL, _IONBF, 0 );
else
// NB: Should use full buffering by default ordinarily, but in
// the current system we're always connected to an interactive
// terminal, so use line buffering
setvbuf( stream, buf, _IOLBF, BUFSIZ );
 
} // setbuf()
 
//===========================================================================
 
// 7.9.6 Formatted input/output functions
 
 
externC int
vfprintf( FILE *stream, const char *format, va_list arg )
{
return vfnprintf(stream, INT_MAX, format, arg);
} // vfprintf()
 
 
externC int
vprintf( const char *format, va_list arg)
{
return vfnprintf( stdout, INT_MAX, format, arg );
} // vprintf()
 
 
externC int
vsprintf( char *s, const char *format, va_list arg )
{
return vsnprintf(s, INT_MAX, format, arg);
} // vsprintf()
 
 
//===========================================================================
 
// 7.9.7 Character input/output functions
 
externC int
puts( const char *s )
{
int rc;
 
rc = fputs( s, stdout );
 
if (rc >= 0)
rc = fputc('\n', stdout );
 
return rc;
} // puts()
 
 
//===========================================================================
 
// 7.9.10 Error-handling functions
 
externC void
perror( const char *s )
{
if (s && *s)
fprintf( stderr, "%s: %s\n", s, strerror(errno) );
else
fputs( strerror(errno), stderr );
 
} // perror()
 
//===========================================================================
 
// Other non-ANSI functions
 
#ifdef CYGFUN_LIBC_STDIO_ungetc
externC int
vscanf( const char *format, va_list arg )
{
return vfscanf( stdin, format, arg );
} // vscanf()
#endif
 
// EOF stdioinlines.cxx
/v2_0/src/common/stdiofiles.cxx
0,0 → 1,82
//========================================================================
//
// stdiofiles.cxx
//
// ISO C library stdio central file data
//
//========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-20
// Purpose: Allocate storage for central file data object
// Description: This file allocates the actual objects used by the
// Cyg_libc_stdio_files class defined in
// <cyg/libc/stdio/stdiofiles.hxx>
// Usage:
//
//####DESCRIPTIONEND####
//
//=========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // C library configuration
 
// INCLUDES
 
#include <stddef.h> // NULL
#include <cyg/libc/stdio/stream.hxx> // Cyg_StdioStream
#include <cyg/libc/stdio/stdiofiles.hxx> // Class definition for
// Cyg_libc_stdio_files
 
#ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS
# include <cyg/infra/cyg_type.h> // CYGBLD_ATTRIB_INIT_PRI
# include <cyg/kernel/mutex.hxx> // mutexes
#endif
 
 
// GLOBAL VARIABLES
 
Cyg_StdioStream *Cyg_libc_stdio_files::files[FOPEN_MAX] = { NULL };
 
# ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS
Cyg_Mutex Cyg_libc_stdio_files::files_lock
CYGBLD_ATTRIB_INIT_PRI(CYG_INIT_LIBC);
# endif
 
// EOF stdiofiles.cxx
/v2_0/src/common/fopen.cxx
0,0 → 1,267
//===========================================================================
//
// fopen.cxx
//
// Implementation of C library file open function as per ANSI 7.9.5.3
//
//===========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//===========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-20
// Purpose: Implements ISO C fopen() function
// Description:
// Usage:
//
//####DESCRIPTIONEND####
//
//===========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
 
// Do we want fopen()?
#if defined(CYGPKG_LIBC_STDIO_OPEN)
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // Common project-wide type definitions
#include <stddef.h> // NULL and size_t from compiler
#include <errno.h> // Error codes
#include <stdio.h> // header for fopen()
#include <stdlib.h> // malloc()
#include <string.h> // strncmp() and strcmp()
#include <cyg/libc/stdio/stdiofiles.hxx> // C library files
#include <cyg/libc/stdio/stream.hxx> // C library streams
 
#include <cyg/libc/stdio/io.inl> // I/O system inlines
 
// FUNCTIONS
 
// placement new
inline void *operator new(size_t size, void *ptr)
{
CYG_CHECK_DATA_PTR( ptr, "Bad pointer" );
return ptr;
}
 
// process the mode string. Return true on error
static cyg_bool
process_mode( const char *mode, Cyg_StdioStream::OpenMode *rw,
cyg_bool *binary, cyg_bool *append )
{
*binary = *append = false; // default
 
switch (mode[0]) {
case 'r':
*rw = Cyg_StdioStream::CYG_STREAM_READ;
break;
 
case 'a':
*append = true;
case 'w':
*rw = Cyg_StdioStream::CYG_STREAM_WRITE;
break;
default:
return true;
} // switch
 
// ANSI says additional characters may follow the sequences, that we
// don't necessarily recognise so we just ignore them, and pretend that
// its the end of the string
 
switch (mode[1]) {
case 'b':
*binary = true;
break;
case '+':
*rw = Cyg_StdioStream::CYG_STREAM_READWRITE;
break;
default:
return false;
} // switch
 
switch (mode[2]) {
case 'b':
*binary = true;
break;
case '+':
*rw = Cyg_StdioStream::CYG_STREAM_READWRITE;
break;
default:
return false;
} // switch
return false;
} // process_mode()
 
 
static FILE *fopen_inner( cyg_stdio_handle_t dev,
Cyg_StdioStream::OpenMode open_mode,
cyg_bool binary,
cyg_bool append)
{
Cyg_StdioStream *curr_stream;
int i;
Cyg_ErrNo err;
int bufmode = _IOFBF;
cyg_ucount32 bufsize = BUFSIZ;
Cyg_libc_stdio_files::lock();
 
// find an empty slot
for (i=0; i < FOPEN_MAX; i++) {
curr_stream = Cyg_libc_stdio_files::get_file_stream(i);
if (curr_stream == NULL)
break;
} // for
 
if (i == FOPEN_MAX) { // didn't find an empty slot
errno = EMFILE;
cyg_stdio_close( dev );
return NULL;
} // if
 
// Decide the buffering mode. The default is fully buffered, but if
// this is an interactive stream then set it to non buffered.
if( (dev != CYG_STDIO_HANDLE_NULL) &&
cyg_stdio_interactive( dev ) )
bufmode = _IONBF, bufsize = 0;
// Allocate it some memory and construct it.
curr_stream = (Cyg_StdioStream *)malloc(sizeof(*curr_stream));
if (curr_stream == NULL) {
cyg_stdio_close( dev );
errno = ENOMEM;
return NULL;
} // if
 
curr_stream = new ((void *)curr_stream) Cyg_StdioStream( dev, open_mode,
append, binary,
bufmode, bufsize );
// it puts any error in its own error flag
if (( err=curr_stream->get_error() )) {
 
Cyg_libc_stdio_files::unlock();
free( curr_stream );
 
cyg_stdio_close( dev );
errno = err;
 
return NULL;
 
} // if
 
Cyg_libc_stdio_files::set_file_stream(i, curr_stream);
Cyg_libc_stdio_files::unlock();
 
return (FILE *)(curr_stream);
 
} // fopen_inner()
 
externC FILE *
fopen( const char *filename, const char *mode )
{
cyg_stdio_handle_t dev;
Cyg_ErrNo err;
Cyg_StdioStream::OpenMode open_mode;
cyg_bool binary, append;
// process_mode returns true on error
if (process_mode( mode, &open_mode, &binary, &append )) {
errno = EINVAL;
return NULL;
} // if
 
err = cyg_stdio_open( filename, open_mode, binary, append, &dev );
 
// if not found
if (err != ENOERR) {
errno = ENOENT;
return NULL;
} // if
 
return fopen_inner( dev, open_mode, binary, append );
} // fopen()
 
 
#endif // defined(CYGPKG_LIBC_STDIO_OPEN)
 
#ifdef CYGPKG_LIBC_STDIO_FILEIO
 
externC int fileno( FILE *stream )
{
Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream;
 
return real_stream->get_dev();
}
 
externC FILE *fdopen( int fd, const char *mode )
{
Cyg_StdioStream::OpenMode open_mode;
cyg_bool binary, append;
FILE *f;
// process_mode returns true on error
if (process_mode( mode, &open_mode, &binary, &append )) {
errno = EINVAL;
return NULL;
} // if
 
f = fopen_inner( (cyg_stdio_handle_t)fd, open_mode, binary, append );
 
if( f == NULL )
return f;
 
// Do a null seek to initialize the file position.
Cyg_StdioStream *real_stream = (Cyg_StdioStream *)f;
fpos_t pos = 0;
real_stream->set_position( pos, SEEK_CUR );
return f;
}
 
#endif // def CYGPKG_LIBC_STDIO_FILEIO
 
 
// EOF fopen.cxx
/v2_0/src/common/fclose.cxx
0,0 → 1,129
//===========================================================================
//
// fclose.cxx
//
// Implementation of C library file close function as per ANSI 7.9.5.1
//
//===========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//===========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-20
// Purpose: Implements ISO C fclose() function
// Description:
// Usage:
//
//####DESCRIPTIONEND####
//
//===========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
#include <pkgconf/infra.h>
 
// We can't have fclose() without fopen()
#if defined(CYGPKG_LIBC_STDIO_OPEN)
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // Common project-wide type definitions
#include <stddef.h> // NULL and size_t from compiler
#include <errno.h> // Error codes
#include <stdio.h> // header for fclose()
#include <stdlib.h> // free()
#include <cyg/libc/stdio/stdiofiles.hxx> // C library files
#include <cyg/libc/stdio/stream.hxx> // C library streams
 
#include <cyg/libc/stdio/io.inl> // I/O system inlines
 
// FUNCTIONS
 
 
externC int
fclose( FILE *stream )
{
Cyg_StdioStream *real_stream = (Cyg_StdioStream *)stream;
int i;
Cyg_ErrNo err;
Cyg_libc_stdio_files::lock();
 
// find the stream in the table
for (i=0; i < FOPEN_MAX; i++)
{
if (real_stream == Cyg_libc_stdio_files::get_file_stream(i))
break;
} // for
 
if (i == FOPEN_MAX) // didn't find it
{
errno = EBADF;
 
return EOF;
} // if
 
err = real_stream->close();
 
if( err != ENOERR )
{
errno = err;
return EOF;
}
#ifdef CYGFUN_INFRA_EMPTY_DELETE_FUNCTIONS
// Explicitly call destructor - this flushes the output too
real_stream->~Cyg_StdioStream();
 
// and free it
free(real_stream);
#else
delete real_stream;
#endif // CYGFUN_INFRA_EMPTY_DELETE_FUNCTIONS
 
// and mark the stream available for use
Cyg_libc_stdio_files::set_file_stream(i, NULL);
Cyg_libc_stdio_files::unlock();
 
return 0;
 
} // fclose()
#endif // if defined(CYGPKG_LIBC_STDIO_OPEN)
 
// EOF fclose.cxx
/v2_0/src/common/sscanf.cxx
0,0 → 1,81
//===========================================================================
//
// sscanf.cxx
//
// ANSI Stdio sscanf() function
//
//===========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//===========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors:
// Date: 2000-04-20
// Purpose:
// Description:
// Usage:
//
//####DESCRIPTIONEND####
//
//===========================================================================
 
// CONFIGURATION
 
#include <pkgconf/libc_stdio.h> // Configuration header
 
// INCLUDES
 
#include <cyg/infra/cyg_type.h> // Common project-wide type definitions
#include <stddef.h> // NULL and size_t from compiler
#include <stdio.h> // header for this file
 
// FUNCTIONS
 
externC int
sscanf( const char *s, const char *format, ... )
{
int rc; // return code
va_list ap; // for variable args
 
va_start(ap, format); // init specifying last non-var arg
 
rc = vsscanf(s, format, ap);
 
va_end(ap); // end var args
 
return rc;
} // sscanf()
 
// EOF sscanf.cxx

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.