[PATCH] libgloss/libnosys: Add fcntl and ioctl.

Jeff Johnston jjohnstn@redhat.com
Fri May 19 05:43:00 GMT 2006


What is the reasoning for adding this?

The calls to _fcntl and _fcntl_r in the newlib library are protected 
with HAVE_FCNTL.  For user code, libc/syscalls adds an fcntl stub 
routine in the case where HAVE_FCNTL is not set.

Nothing in shared newlib calls _ioctl.  The sys directories that 
reference _ioctl supply the syscall.  That said, you reference a 
sys/ioctl.h header file which doesn't exist in newlib/include/sys so 
this won't build on most platforms.

-- Jeff J.

Shaun Jackman wrote:
> 2006-05-10  Shaun Jackman  <sjackman@gmail.com>
> 
>     * libnosys/Makefile.in (OBJS): Add fcntl.o and ioctl.o.
>     * libnosys/fcntl.c: New file.
>     * libnosys/ioctl.c: Ditto.
> 
> Index: libnosys/Makefile.in
> ===================================================================
> RCS file: /cvs/src/src/libgloss/libnosys/Makefile.in,v
> retrieving revision 1.6
> diff -u -r1.6 Makefile.in
> --- libnosys/Makefile.in    30 Nov 2005 23:43:57 -0000    1.6
> +++ libnosys/Makefile.in    10 May 2006 20:03:09 -0000
> @@ -65,10 +65,10 @@
>     else t='$(program_transform_name)'; echo objcopy | sed -e $$t ; fi`
> 
> # object files needed
> -OBJS = chown.o close.o environ.o errno.o execve.o fork.o fstat.o \
> -    getpid.o gettod.o isatty.o kill.o link.o lseek.o open.o \
> -    read.o readlink.o sbrk.o stat.o symlink.o times.o unlink.o \
> -    wait.o write.o _exit.o
> +OBJS = chown.o close.o environ.o errno.o execve.o fcntl.o fork.o \
> +    fstat.o getpid.o gettod.o ioctl.o isatty.o kill.o link.o lseek.o \
> +    open.o read.o readlink.o sbrk.o stat.o symlink.o times.o \
> +    unlink.o wait.o write.o _exit.o
> 
> # Object files specific to particular targets.
> EVALOBJS = ${OBJS}
> --- /dev/null    2006-05-06 15:33:38.911298368 -0600
> +++ libnosys/fcntl.c    2006-05-10 14:00:06.000000000 -0600
> @@ -0,0 +1,27 @@
> +/*
> + * Stub version of fcntl.
> + */
> +
> +#include "config.h"
> +#include <_ansi.h>
> +#include <_syslist.h>
> +#include <errno.h>
> +#include <fcntl.h>
> +#include <unistd.h>
> +
> +#undef errno
> +extern int errno;
> +#include "warning.h"
> +
> +int
> +_DEFUN (_fcntl, (fildes, cmd),
> +        int          fildes _AND
> +        int cmd _DOTS)
> +{
> +    (void)fildes;
> +    (void)cmd;
> +    errno = ENOSYS;
> +    return -1;
> +}
> +
> +stub_warning(_fcntl)
> --- /dev/null    2006-05-06 15:33:38.911298368 -0600
> +++ libnosys/ioctl.c    2006-05-10 14:01:11.000000000 -0600
> @@ -0,0 +1,32 @@
> +/*
> + * Stub version of ioctl.
> + */
> +
> +#include "config.h"
> +#include <_ansi.h>
> +#include <_syslist.h>
> +#include <errno.h>
> +#if HAVE_STROPTS_H
> +/* SUSv3 says stropts.h is the correct header... */
> +# include <stropts.h>
> +#else
> +/* ... but sys/ioctl.h is typical. */
> +# include <sys/ioctl.h>
> +#endif
> +
> +#undef errno
> +extern int errno;
> +#include "warning.h"
> +
> +int
> +_DEFUN (_ioctl, (fildes, request),
> +        int          fildes _AND
> +        int request _DOTS)
> +{
> +    (void)fildes;
> +    (void)request;
> +    errno = ENOSYS;
> +    return -1;
> +}
> +
> +stub_warning(_ioctl)



More information about the Newlib mailing list