sdm: Add sys wrappers for read, write, eventfd system calls
Add function pointers for read, write, and eventfd in Sys wrapper and call these instead of directly calling system calls. CRs-Fixed: 814136 Change-Id: I9964df85be2f6eaa83371b71971c642a768830f8
This commit is contained in:
committed by
Gerrit - the friendly Code Review server
parent
ad4cc06a17
commit
352a0baeab
@@ -25,6 +25,8 @@
|
|||||||
#ifndef __SYS_H__
|
#ifndef __SYS_H__
|
||||||
#define __SYS_H__
|
#define __SYS_H__
|
||||||
|
|
||||||
|
#include <sys/eventfd.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
@@ -46,6 +48,9 @@ class Sys {
|
|||||||
typedef ssize_t (*getline)(char **lineptr, size_t *linelen, FILE *stream);
|
typedef ssize_t (*getline)(char **lineptr, size_t *linelen, FILE *stream);
|
||||||
typedef int (*pthread_cancel)(pthread_t thread);
|
typedef int (*pthread_cancel)(pthread_t thread);
|
||||||
typedef int (*dup)(int fd);
|
typedef int (*dup)(int fd);
|
||||||
|
typedef ssize_t (*read)(int, void *, size_t);
|
||||||
|
typedef ssize_t (*write)(int, const void *, size_t);
|
||||||
|
typedef int (*eventfd)(unsigned int, int);
|
||||||
|
|
||||||
static ioctl ioctl_;
|
static ioctl ioctl_;
|
||||||
static open open_;
|
static open open_;
|
||||||
@@ -58,6 +63,9 @@ class Sys {
|
|||||||
static getline getline_;
|
static getline getline_;
|
||||||
static pthread_cancel pthread_cancel_;
|
static pthread_cancel pthread_cancel_;
|
||||||
static dup dup_;
|
static dup dup_;
|
||||||
|
static read read_;
|
||||||
|
static write write_;
|
||||||
|
static eventfd eventfd_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace sdm
|
} // namespace sdm
|
||||||
|
|||||||
@@ -54,6 +54,9 @@ Sys::fclose Sys::fclose_ = ::fclose;
|
|||||||
Sys::getline Sys::getline_ = ::getline;
|
Sys::getline Sys::getline_ = ::getline;
|
||||||
Sys::pthread_cancel Sys::pthread_cancel_ = PthreadCancel;
|
Sys::pthread_cancel Sys::pthread_cancel_ = PthreadCancel;
|
||||||
Sys::dup Sys::dup_ = ::dup;
|
Sys::dup Sys::dup_ = ::dup;
|
||||||
|
Sys::read Sys::read_ = ::read;
|
||||||
|
Sys::write Sys::write_ = ::write;
|
||||||
|
Sys::eventfd Sys::eventfd_ = ::eventfd;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@@ -68,6 +71,9 @@ extern FILE* virtual_fopen(const char *fname, const char *mode);
|
|||||||
extern int virtual_fclose(FILE* fileptr);
|
extern int virtual_fclose(FILE* fileptr);
|
||||||
extern ssize_t virtual_getline(char **lineptr, size_t *linelen, FILE *stream);
|
extern ssize_t virtual_getline(char **lineptr, size_t *linelen, FILE *stream);
|
||||||
extern int virtual_dup(int fd);
|
extern int virtual_dup(int fd);
|
||||||
|
extern ssize_t virtual_read(int fd, void *data, size_t count);
|
||||||
|
extern ssize_t virtual_write(int fd, const void *data, size_t count);
|
||||||
|
extern int virtual_eventfd(unsigned int initval, int flags);
|
||||||
|
|
||||||
Sys::ioctl Sys::ioctl_ = virtual_ioctl;
|
Sys::ioctl Sys::ioctl_ = virtual_ioctl;
|
||||||
Sys::open Sys::open_ = virtual_open;
|
Sys::open Sys::open_ = virtual_open;
|
||||||
@@ -80,6 +86,9 @@ Sys::fclose Sys::fclose_ = virtual_fclose;
|
|||||||
Sys::getline Sys::getline_ = virtual_getline;
|
Sys::getline Sys::getline_ = virtual_getline;
|
||||||
Sys::pthread_cancel Sys::pthread_cancel_ = ::pthread_cancel;
|
Sys::pthread_cancel Sys::pthread_cancel_ = ::pthread_cancel;
|
||||||
Sys::dup Sys::dup_ = virtual_dup;
|
Sys::dup Sys::dup_ = virtual_dup;
|
||||||
|
Sys::read Sys::read_ = virtual_read;
|
||||||
|
Sys::write Sys::write_ = virtual_write;
|
||||||
|
Sys::eventfd Sys::eventfd_ = virtual_eventfd;
|
||||||
|
|
||||||
#endif // SDM_VIRTUAL_DRIVER
|
#endif // SDM_VIRTUAL_DRIVER
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user