@@ -290,7 +290,7 @@ static FileHandle *get_console(int fd)
290290}
291291
292292/* Deal with the fact C library may not _open descriptors 0, 1, 2 - auto bind */
293- static FileHandle *get_fhc (int fd)
293+ FileHandle *mbed::mbed_file_handle (int fd)
294294{
295295 if (fd >= OPEN_MAX) {
296296 return NULL ;
@@ -490,13 +490,13 @@ extern "C" FILEHANDLE PREFIX(_open)(const char *name, int openflags)
490490 /* Use the posix convention that stdin,out,err are filehandles 0,1,2.
491491 */
492492 if (std::strcmp (name, __stdin_name) == 0 ) {
493- get_fhc (STDIN_FILENO);
493+ mbed_file_handle (STDIN_FILENO);
494494 return STDIN_FILENO;
495495 } else if (std::strcmp (name, __stdout_name) == 0 ) {
496- get_fhc (STDOUT_FILENO);
496+ mbed_file_handle (STDOUT_FILENO);
497497 return STDOUT_FILENO;
498498 } else if (std::strcmp (name, __stderr_name) == 0 ) {
499- get_fhc (STDERR_FILENO);
499+ mbed_file_handle (STDERR_FILENO);
500500 return STDERR_FILENO;
501501 }
502502#endif
@@ -555,7 +555,7 @@ extern "C" int PREFIX(_close)(FILEHANDLE fh)
555555
556556extern " C" int close (int fildes)
557557{
558- FileHandle *fhc = get_fhc (fildes);
558+ FileHandle *fhc = mbed_file_handle (fildes);
559559 filehandles[fildes] = NULL ;
560560 if (fhc == NULL ) {
561561 errno = EBADF;
@@ -667,7 +667,7 @@ extern "C" int PREFIX(_write)(FILEHANDLE fh, const unsigned char *buffer, unsign
667667extern " C" ssize_t write (int fildes, const void *buf, size_t length)
668668{
669669
670- FileHandle *fhc = get_fhc (fildes);
670+ FileHandle *fhc = mbed_file_handle (fildes);
671671 if (fhc == NULL ) {
672672 errno = EBADF;
673673 return -1 ;
@@ -761,8 +761,7 @@ extern "C" int PREFIX(_read)(FILEHANDLE fh, unsigned char *buffer, unsigned int
761761
762762extern " C" ssize_t read (int fildes, void *buf, size_t length)
763763{
764-
765- FileHandle *fhc = get_fhc (fildes);
764+ FileHandle *fhc = mbed_file_handle (fildes);
766765 if (fhc == NULL ) {
767766 errno = EBADF;
768767 return -1 ;
@@ -789,7 +788,7 @@ extern "C" int _isatty(FILEHANDLE fh)
789788
790789extern " C" int isatty (int fildes)
791790{
792- FileHandle *fhc = get_fhc (fildes);
791+ FileHandle *fhc = mbed_file_handle (fildes);
793792 if (fhc == NULL ) {
794793 errno = EBADF;
795794 return 0 ;
@@ -828,7 +827,7 @@ int _lseek(FILEHANDLE fh, int offset, int whence)
828827
829828extern " C" off_t lseek (int fildes, off_t offset, int whence)
830829{
831- FileHandle *fhc = get_fhc (fildes);
830+ FileHandle *fhc = mbed_file_handle (fildes);
832831 if (fhc == NULL ) {
833832 errno = EBADF;
834833 return -1 ;
@@ -844,7 +843,7 @@ extern "C" off_t lseek(int fildes, off_t offset, int whence)
844843
845844extern " C" int ftruncate (int fildes, off_t length)
846845{
847- FileHandle *fhc = get_fhc (fildes);
846+ FileHandle *fhc = mbed_file_handle (fildes);
848847 if (fhc == NULL ) {
849848 errno = EBADF;
850849 return -1 ;
@@ -868,7 +867,7 @@ extern "C" int PREFIX(_ensure)(FILEHANDLE fh)
868867
869868extern " C" int fsync (int fildes)
870869{
871- FileHandle *fhc = get_fhc (fildes);
870+ FileHandle *fhc = mbed_file_handle (fildes);
872871 if (fhc == NULL ) {
873872 errno = EBADF;
874873 return -1 ;
@@ -886,7 +885,7 @@ extern "C" int fsync(int fildes)
886885#ifdef __ARMCC_VERSION
887886extern " C" long PREFIX (_flen)(FILEHANDLE fh)
888887{
889- FileHandle *fhc = get_fhc (fh);
888+ FileHandle *fhc = mbed_file_handle (fh);
890889 if (fhc == NULL ) {
891890 errno = EBADF;
892891 return -1 ;
@@ -936,7 +935,7 @@ extern "C" int _fstat(int fh, struct stat *st)
936935
937936extern " C" int fstat (int fildes, struct stat *st)
938937{
939- FileHandle *fhc = get_fhc (fildes);
938+ FileHandle *fhc = mbed_file_handle (fildes);
940939 if (fhc == NULL ) {
941940 errno = EBADF;
942941 return -1 ;
@@ -949,7 +948,7 @@ extern "C" int fstat(int fildes, struct stat *st)
949948
950949extern " C" int fcntl (int fildes, int cmd, ...)
951950{
952- FileHandle *fhc = get_fhc (fildes);
951+ FileHandle *fhc = mbed_file_handle (fildes);
953952 if (fhc == NULL ) {
954953 errno = EBADF;
955954 return -1 ;
@@ -994,7 +993,7 @@ extern "C" int poll(struct pollfd fds[], nfds_t nfds, int timeout)
994993 for (nfds_t n = 0 ; n < nfds; n++) {
995994 // Underlying FileHandle poll returns POLLNVAL if given NULL, so
996995 // we don't need to take special action.
997- fhs[n].fh = get_fhc (fds[n].fd );
996+ fhs[n].fh = mbed_file_handle (fds[n].fd );
998997 fhs[n].events = fds[n].events ;
999998 }
1000999 int ret = poll (fhs, nfds, timeout);
0 commit comments