Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

No point of using _open_r

Altera_Forum
Honored Contributor II
1,060 Views

I read about reentrant function versions and I was goint to use them (in fact I have them already converted in my code). During the debugging I entered accidently into the _read_r function and I have seen its body: 

 

ssize_t 

_DEFUN (_read_r, (ptr, fd, buf, cnt), 

struct _reent *ptr _AND 

int fd _AND 

_PTR buf _AND 

size_t cnt) 

_ssize_t ret; 

 

errno = 0; 

if ((ret = (_ssize_t)_read (fd, buf, cnt)) == -1 && errno != 0) 

ptr->_errno = errno; 

return ret; 

 

Looking at this source code I find this function NOT REENTRANT! 

Nothing stops an interrupt to arrive between seting global errno and copying its value to a struct _reent. Such intterupt would cause reschedule in MicroC/OS and the other task can use global errno variable for its own and modify its value before the scheduler returns control to the previous task. 

 

I see no point of using these functions - am I correct thinking they do not do any good ?
0 Kudos
0 Replies
Reply