@@ -291,7 +291,7 @@ static FileHandle *get_console(int fd)
291291}
292292
293293/* Deal with the fact C library may not _open descriptors 0, 1, 2 - auto bind */
294- static FileHandle *get_fhc (int fd)
294+ FileHandle *mbed::mbed_file_handle (int fd)
295295{
296296 if (fd >= OPEN_MAX) {
297297 return NULL ;
@@ -491,13 +491,13 @@ extern "C" FILEHANDLE PREFIX(_open)(const char *name, int openflags)
491491 /* Use the posix convention that stdin,out,err are filehandles 0,1,2.
492492 */
493493 if (std::strcmp (name, __stdin_name) == 0 ) {
494- get_fhc (STDIN_FILENO);
494+ mbed_file_handle (STDIN_FILENO);
495495 return STDIN_FILENO;
496496 } else if (std::strcmp (name, __stdout_name) == 0 ) {
497- get_fhc (STDOUT_FILENO);
497+ mbed_file_handle (STDOUT_FILENO);
498498 return STDOUT_FILENO;
499499 } else if (std::strcmp (name, __stderr_name) == 0 ) {
500- get_fhc (STDERR_FILENO);
500+ mbed_file_handle (STDERR_FILENO);
501501 return STDERR_FILENO;
502502 }
503503#endif
@@ -556,7 +556,7 @@ extern "C" int PREFIX(_close)(FILEHANDLE fh)
556556
557557extern " C" int close (int fildes)
558558{
559- FileHandle *fhc = get_fhc (fildes);
559+ FileHandle *fhc = mbed_file_handle (fildes);
560560 filehandles[fildes] = NULL ;
561561 if (fhc == NULL ) {
562562 errno = EBADF;
@@ -668,7 +668,7 @@ extern "C" int PREFIX(_write)(FILEHANDLE fh, const unsigned char *buffer, unsign
668668extern " C" ssize_t write (int fildes, const void *buf, size_t length)
669669{
670670
671- FileHandle *fhc = get_fhc (fildes);
671+ FileHandle *fhc = mbed_file_handle (fildes);
672672 if (fhc == NULL ) {
673673 errno = EBADF;
674674 return -1 ;
@@ -762,8 +762,7 @@ extern "C" int PREFIX(_read)(FILEHANDLE fh, unsigned char *buffer, unsigned int
762762
763763extern " C" ssize_t read (int fildes, void *buf, size_t length)
764764{
765-
766- FileHandle *fhc = get_fhc (fildes);
765+ FileHandle *fhc = mbed_file_handle (fildes);
767766 if (fhc == NULL ) {
768767 errno = EBADF;
769768 return -1 ;
@@ -790,7 +789,7 @@ extern "C" int _isatty(FILEHANDLE fh)
790789
791790extern " C" int isatty (int fildes)
792791{
793- FileHandle *fhc = get_fhc (fildes);
792+ FileHandle *fhc = mbed_file_handle (fildes);
794793 if (fhc == NULL ) {
795794 errno = EBADF;
796795 return 0 ;
@@ -829,7 +828,7 @@ int _lseek(FILEHANDLE fh, int offset, int whence)
829828
830829extern " C" off_t lseek (int fildes, off_t offset, int whence)
831830{
832- FileHandle *fhc = get_fhc (fildes);
831+ FileHandle *fhc = mbed_file_handle (fildes);
833832 if (fhc == NULL ) {
834833 errno = EBADF;
835834 return -1 ;
@@ -845,7 +844,7 @@ extern "C" off_t lseek(int fildes, off_t offset, int whence)
845844
846845extern " C" int ftruncate (int fildes, off_t length)
847846{
848- FileHandle *fhc = get_fhc (fildes);
847+ FileHandle *fhc = mbed_file_handle (fildes);
849848 if (fhc == NULL ) {
850849 errno = EBADF;
851850 return -1 ;
@@ -869,7 +868,7 @@ extern "C" int PREFIX(_ensure)(FILEHANDLE fh)
869868
870869extern " C" int fsync (int fildes)
871870{
872- FileHandle *fhc = get_fhc (fildes);
871+ FileHandle *fhc = mbed_file_handle (fildes);
873872 if (fhc == NULL ) {
874873 errno = EBADF;
875874 return -1 ;
@@ -887,7 +886,7 @@ extern "C" int fsync(int fildes)
887886#ifdef __ARMCC_VERSION
888887extern " C" long PREFIX (_flen)(FILEHANDLE fh)
889888{
890- FileHandle *fhc = get_fhc (fh);
889+ FileHandle *fhc = mbed_file_handle (fh);
891890 if (fhc == NULL ) {
892891 errno = EBADF;
893892 return -1 ;
@@ -965,7 +964,7 @@ extern "C" int _fstat(int fh, struct stat *st)
965964
966965extern " C" int fstat (int fildes, struct stat *st)
967966{
968- FileHandle *fhc = get_fhc (fildes);
967+ FileHandle *fhc = mbed_file_handle (fildes);
969968 if (fhc == NULL ) {
970969 errno = EBADF;
971970 return -1 ;
@@ -978,7 +977,7 @@ extern "C" int fstat(int fildes, struct stat *st)
978977
979978extern " C" int fcntl (int fildes, int cmd, ...)
980979{
981- FileHandle *fhc = get_fhc (fildes);
980+ FileHandle *fhc = mbed_file_handle (fildes);
982981 if (fhc == NULL ) {
983982 errno = EBADF;
984983 return -1 ;
@@ -1023,7 +1022,7 @@ extern "C" int poll(struct pollfd fds[], nfds_t nfds, int timeout)
10231022 for (nfds_t n = 0 ; n < nfds; n++) {
10241023 // Underlying FileHandle poll returns POLLNVAL if given NULL, so
10251024 // we don't need to take special action.
1026- fhs[n].fh = get_fhc (fds[n].fd );
1025+ fhs[n].fh = mbed_file_handle (fds[n].fd );
10271026 fhs[n].events = fds[n].events ;
10281027 }
10291028 int ret = poll (fhs, nfds, timeout);
0 commit comments