From bbfd2b2cf86c901ec10d02b0665955bc277fb44b Mon Sep 17 00:00:00 2001 From: "Sergey Semyonov (Serge)" Date: Thu, 10 Mar 2011 05:38:16 +0000 Subject: [PATCH] newlib: update includes git-svn-id: svn://kolibrios.org@1903 a494cfbc-eb01-0410-851d-a64ba20cac60 --- .../develop/libraries/newlib/include/reent.h | 10 ++- .../libraries/newlib/include/sys/kos_io.h | 88 +++++++++++++++++++ 2 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 programs/develop/libraries/newlib/include/sys/kos_io.h diff --git a/programs/develop/libraries/newlib/include/reent.h b/programs/develop/libraries/newlib/include/reent.h index a11d4bb59e..8386c7513b 100644 --- a/programs/develop/libraries/newlib/include/reent.h +++ b/programs/develop/libraries/newlib/include/reent.h @@ -150,7 +150,15 @@ extern int _execve_r _PARAMS ((struct _reent *, const char *, char *const *, cha extern int _fcntl_r _PARAMS ((struct _reent *, int, int, int)); extern int _fork_r _PARAMS ((struct _reent *)); extern int _fstat_r _PARAMS ((struct _reent *, int, struct stat *)); -extern int _getpid_r _PARAMS ((struct _reent *)); +static inline int _getpid_r (struct _reent *r) +{ + int pid; + (void)r; + __asm__ __volatile__( + "movl %%fs:0, %0 \n\t" + :"=r"(pid)); + return pid; +} extern int _isatty_r _PARAMS ((struct _reent *, int)); extern int _kill_r _PARAMS ((struct _reent *, int, int)); extern int _link_r _PARAMS ((struct _reent *, const char *, const char *)); diff --git a/programs/develop/libraries/newlib/include/sys/kos_io.h b/programs/develop/libraries/newlib/include/sys/kos_io.h new file mode 100644 index 0000000000..373d341a26 --- /dev/null +++ b/programs/develop/libraries/newlib/include/sys/kos_io.h @@ -0,0 +1,88 @@ + +#ifndef __KOS_IO_H__ +#define __KOS_IO_H__ + +#pragma pack(push, 1) +typedef struct +{ + char sec; + char min; + char hour; + char rsv; +}detime_t; + +typedef struct +{ + char day; + char month; + short year; +}dedate_t; + +typedef struct +{ + unsigned attr; + unsigned flags; + union + { + detime_t ctime; + unsigned cr_time; + }; + union + { + dedate_t cdate; + unsigned cr_date; + }; + union + { + detime_t atime; + unsigned acc_time; + }; + union + { + dedate_t adate; + unsigned acc_date; + }; + union + { + detime_t mtime; + unsigned mod_time; + }; + union + { + dedate_t mdate; + unsigned mod_date; + }; + unsigned size; + unsigned size_high; +} fileinfo_t; + +#pragma pack(pop) + +int create_file(const char *path); +int get_fileinfo(const char *path, fileinfo_t *info); +int read_file(const char *path, void *buff, + size_t offset, size_t count, size_t *reads); +int write_file(const char *path,const void *buff, + size_t offset, size_t count, size_t *writes); +int set_file_size(const char *path, unsigned size); +void *load_file(const char *path, size_t *len); +void __stdcall unpack(void* packed_data, void* unpacked_data); + +static inline int user_free(void *mem) +{ + int val; + __asm__ __volatile__( + "int $0x40" + :"=eax"(val) + :"a"(68),"b"(12),"c"(mem)); + return val; +} + +static inline void set_cwd(const char* cwd) +{ + __asm__ __volatile__( + "int $0x40" + ::"a"(30),"b"(1),"c"(cwd)); +}; + +#endif