include: posix: unistd: Fix prototypes and dependency

For read/write/lseek, use size_t and off_t types, as mandated by
POSIX:
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html

Also, prototypes of unistd.h functions should not depend on
CONFIG_POSIX_FS, as (many) of them deal with generic I/O, not with
files in filesystem per se.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
This commit is contained in:
Paul Sokolovsky 2018-10-08 18:48:22 +03:00 committed by Anas Nashif
commit 7f9127578b
2 changed files with 7 additions and 7 deletions

View file

@ -13,7 +13,7 @@ extern "C" {
#include "sys/types.h" #include "sys/types.h"
#include "sys/stat.h" #include "sys/stat.h"
#ifdef CONFIG_POSIX_FS #ifdef CONFIG_POSIX_API
#include <fs.h> #include <fs.h>
typedef unsigned int mode_t; typedef unsigned int mode_t;
@ -21,9 +21,9 @@ typedef unsigned int mode_t;
/* File related operations */ /* File related operations */
extern int open(const char *name, int flags); extern int open(const char *name, int flags);
extern int close(int file); extern int close(int file);
extern ssize_t write(int file, char *buffer, unsigned int count); extern ssize_t write(int file, const void *buffer, size_t count);
extern ssize_t read(int file, char *buffer, unsigned int count); extern ssize_t read(int file, void *buffer, size_t count);
extern int lseek(int file, int offset, int whence); extern off_t lseek(int file, off_t offset, int whence);
/* File System related operations */ /* File System related operations */
extern int rename(const char *old, const char *newp); extern int rename(const char *old, const char *newp);

View file

@ -151,7 +151,7 @@ int close(int fd)
* *
* See IEEE 1003.1 * See IEEE 1003.1
*/ */
ssize_t write(int fd, char *buffer, unsigned int count) ssize_t write(int fd, const void *buffer, size_t count)
{ {
ssize_t rc; ssize_t rc;
struct fs_file_t *ptr = NULL; struct fs_file_t *ptr = NULL;
@ -175,7 +175,7 @@ ssize_t write(int fd, char *buffer, unsigned int count)
* *
* See IEEE 1003.1 * See IEEE 1003.1
*/ */
ssize_t read(int fd, char *buffer, unsigned int count) ssize_t read(int fd, void *buffer, size_t count)
{ {
ssize_t rc; ssize_t rc;
struct fs_file_t *ptr = NULL; struct fs_file_t *ptr = NULL;
@ -199,7 +199,7 @@ ssize_t read(int fd, char *buffer, unsigned int count)
* *
* See IEEE 1003.1 * See IEEE 1003.1
*/ */
int lseek(int fd, int offset, int whence) off_t lseek(int fd, off_t offset, int whence)
{ {
int rc; int rc;
struct fs_file_t *ptr = NULL; struct fs_file_t *ptr = NULL;