2007-02-02 00:33:05 +08:00
|
|
|
/*
|
|
|
|
Copyright (C) 2007 Sony Computer Entertainment Inc.
|
|
|
|
Copyright 2007 Sony Corp.
|
|
|
|
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions are met:
|
|
|
|
|
|
|
|
* Redistributions of source code must retain the above copyright notice,
|
|
|
|
this list of conditions and the following disclaimer.
|
|
|
|
* 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.
|
|
|
|
* Neither the names of the copyright holders nor the names of their
|
|
|
|
contributors may be used to endorse or promote products derived from this
|
|
|
|
software without specific prior written permission.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
Author: Kazunori Asayama <asayama@sm.sony.co.jp>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "c99ppe.h"
|
|
|
|
|
|
|
|
|
|
|
|
static FILE __fp[SPE_FOPEN_MAX];
|
|
|
|
|
|
|
|
FILE *
|
2017-12-04 11:43:30 +08:00
|
|
|
__sfp (struct _reent *d)
|
2007-02-02 00:33:05 +08:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < SPE_FOPEN_MAX; i++) {
|
|
|
|
if (!__fp[i]._fp) {
|
|
|
|
return &__fp[i];
|
|
|
|
}
|
|
|
|
}
|
2022-01-18 17:13:04 +08:00
|
|
|
_REENT_ERRNO(d) = EMFILE;
|
2007-02-02 00:33:05 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2017-12-04 11:12:33 +08:00
|
|
|
static void
|
2017-12-04 11:43:30 +08:00
|
|
|
__cleanup (struct _reent *s)
|
2007-02-02 00:33:05 +08:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < SPE_FOPEN_MAX; i++) {
|
|
|
|
if (__fp[i]._fp) {
|
|
|
|
fclose(&__fp[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-04 11:12:33 +08:00
|
|
|
void
|
2017-12-04 11:43:30 +08:00
|
|
|
__sinit (struct _reent *s)
|
2007-02-02 00:33:05 +08:00
|
|
|
{
|
|
|
|
s->__cleanup = __cleanup;
|
|
|
|
|
2022-01-28 17:58:36 +08:00
|
|
|
_REENT_STDIN(s) = &s->__sf[0];
|
|
|
|
_REENT_STDIN(s)->_fp = SPE_STDIN;
|
2007-02-02 00:33:05 +08:00
|
|
|
|
2022-02-01 19:37:46 +08:00
|
|
|
_REENT_STDOUT(s) = &s->__sf[1];
|
|
|
|
_REENT_STDOUT(s)->_fp = SPE_STDOUT;
|
2007-02-02 00:33:05 +08:00
|
|
|
|
2022-02-01 20:05:53 +08:00
|
|
|
_REENT_STDERR(s) = &s->__sf[2];
|
|
|
|
_REENT_STDERR(s)->_fp = SPE_STDERR;
|
2007-02-02 00:33:05 +08:00
|
|
|
}
|
2007-08-24 02:45:22 +08:00
|
|
|
|
2017-12-04 11:12:33 +08:00
|
|
|
void
|
2017-12-04 11:00:43 +08:00
|
|
|
__check_init (void)
|
2007-08-24 02:45:22 +08:00
|
|
|
{
|
|
|
|
CHECK_INIT(_REENT);
|
|
|
|
}
|