1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: rvct_stdio.cpp 4 5 Copyright (C)2009-2012 Nintendo Co., Ltd. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Rev: 48158 $ 14 *---------------------------------------------------------------------------*/ 15 16 #include <nn/types.h> 17 #include <nn/config.h> 18 #include <nn/assert.h> 19 #include <nn/os/CTR/os_ThreadLocalRegion.h> 20 21 #include <rt_sys.h> 22 #include <rt_misc.h> 23 #include <time.h> 24 #include <stdio.h> 25 #include <typeinfo> 26 #include <cstring> 27 28 #ifndef NN_DEBUGGER_ARM_REALVIEW 29 30 #pragma import(__use_no_semihosting_swi) 31 #pragma import(__use_c99_matherr) 32 33 extern "C" 34 { 35 // rt_sys.h 36 const char __stdin_name[] = ""; 37 const char __stdout_name[] = ""; 38 const char __stderr_name[] = ""; 39 _sys_open(const char * name,int openmode)40 FILEHANDLE _sys_open(const char * name, int openmode) { NN_UNUSED_VAR(name); NN_UNUSED_VAR(openmode); return -1; } _sys_close(FILEHANDLE fh)41 int _sys_close(FILEHANDLE fh) { NN_UNUSED_VAR(fh); return -1; } _sys_write(FILEHANDLE fh,const unsigned char * buf,unsigned len,int mode)42 int _sys_write(FILEHANDLE fh, const unsigned char *buf, unsigned len, int mode) { NN_UNUSED_VAR(fh); NN_UNUSED_VAR(buf); NN_UNUSED_VAR(len); NN_UNUSED_VAR(mode); return -1; } _sys_read(FILEHANDLE fh,unsigned char * buf,unsigned len,int mode)43 int _sys_read(FILEHANDLE fh, unsigned char * buf, unsigned len, int mode) { NN_UNUSED_VAR(fh); NN_UNUSED_VAR(buf); NN_UNUSED_VAR(len); NN_UNUSED_VAR(mode); return len; } _ttywrch(int ch)44 void _ttywrch(int ch) { NN_UNUSED_VAR(ch); } _sys_istty(FILEHANDLE fh)45 int _sys_istty(FILEHANDLE fh) { NN_UNUSED_VAR(fh); return -1; } _sys_seek(FILEHANDLE fh,long pos)46 int _sys_seek(FILEHANDLE fh, long pos) { NN_UNUSED_VAR(fh); NN_UNUSED_VAR(pos); return -1; } _sys_ensure(FILEHANDLE fh)47 int _sys_ensure(FILEHANDLE fh) { NN_UNUSED_VAR(fh); return -1; } _sys_flen(FILEHANDLE fh)48 long _sys_flen(FILEHANDLE fh) { NN_UNUSED_VAR(fh); return -1; } _sys_tmpnam(char * name,int fileno,unsigned maxlength)49 int _sys_tmpnam(char *name, int fileno, unsigned maxlength) { NN_UNUSED_VAR(name); NN_UNUSED_VAR(fileno); NN_UNUSED_VAR(maxlength); return -1; } _sys_exit(int return_code)50 void _sys_exit(int return_code) { NN_UNUSED_VAR(return_code); } _sys_command_string(char * cmd,int len)51 char* _sys_command_string (char* cmd, int len) { NN_UNUSED_VAR(cmd); NN_UNUSED_VAR(len); return NULL; } 52 53 // rt_misc.h 54 // void _getenv_init(void) {} 55 // void _clock_init(void) {} __raise(int signal,int type)56 int __raise(int signal, int type) { NN_UNUSED_VAR(signal); NN_UNUSED_VAR(type); return 0; } __rt_raise(int sig,int type)57 void __rt_raise(int sig, int type) { NN_UNUSED_VAR(sig); NN_UNUSED_VAR(type); } 58 59 // Standard functions abort()60 void abort() { NN_PANIC("abort() called\n"); } 61 // clock_t clock(void) { return 0; } 62 // time_t time(time_t* timer){ NN_UNUSED_VAR(timer); return 0; } 63 // char* getenv(const char* name) { NN_UNUSED_VAR(name); return NULL; } 64 // int remove(const char* filename) { NN_UNUSED_VAR(filename); return -1; } 65 // int rename(const char* old, const char* newname) { NN_UNUSED_VAR(old); NN_UNUSED_VAR(newname); return -1; } 66 // int system(const char* string) { NN_UNUSED_VAR(string); return -1; } 67 68 // Other __aeabi_atexit()69 void __aeabi_atexit() {} __cxa_finalize()70 void __cxa_finalize() {} __rt_SIGTMEM()71 void __rt_SIGTMEM() {} __rt_SIGABRT()72 void __rt_SIGABRT() {} __rt_div0()73 void __rt_div0() {} 74 75 __rt_eh_globals_addr()76 void** __rt_eh_globals_addr() 77 { 78 return &nn::os::CTR::GetThreadLocalRegion()->ehGlobalsAddr; 79 } 80 } 81 82 namespace std 83 { operator ==(const type_info & rhs) const84 bool type_info::operator==(const type_info& rhs) const 85 { 86 return std::strcmp(this->name(), rhs.name()) == 0; 87 } operator !=(const type_info & rhs) const88 bool type_info::operator!=(const type_info& rhs) const 89 { 90 return std::strcmp(this->name(), rhs.name()) != 0; 91 } before(const type_info & rhs) const92 bool type_info::before(const type_info& rhs) const 93 { 94 return std::strcmp(this->name(), rhs.name()) < 0; 95 } 96 } 97 98 99 #else 100 101 extern "C" 102 { __aeabi_atexit()103 void __aeabi_atexit() {} 104 } 105 106 #endif 107