Create new OS module

This module will contain all functions that perform OS calls such as IO,
filesystem access, etc.
This commit is contained in:
Thiago de Arruda
2014-02-24 22:17:46 -03:00
parent 0f438e42a8
commit c067e5580b
11 changed files with 19 additions and 13 deletions

View File

@@ -10,9 +10,9 @@ endforeach()
list(REMOVE_ITEM NEOVIM_SOURCES ${to_remove}) list(REMOVE_ITEM NEOVIM_SOURCES ${to_remove})
list(APPEND NEOVIM_SOURCES "${PROJECT_BINARY_DIR}/config/auto/pathdef.c") list(APPEND NEOVIM_SOURCES "${PROJECT_BINARY_DIR}/config/auto/pathdef.c")
file( GLOB IO_SOURCES io/*.c ) file( GLOB OS_SOURCES os/*.c )
add_executable (nvim ${NEOVIM_SOURCES} ${IO_SOURCES}) add_executable (nvim ${NEOVIM_SOURCES} ${OS_SOURCES})
target_link_libraries (nvim m uv ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries (nvim m uv ${CMAKE_THREAD_LIBS_INIT})

View File

@@ -12,6 +12,7 @@
*/ */
#include "vim.h" #include "vim.h"
#include "os/os.h"
static int diff_busy = FALSE; /* ex_diffgetput() is busy */ static int diff_busy = FALSE; /* ex_diffgetput() is busy */

View File

@@ -12,6 +12,7 @@
*/ */
#include "vim.h" #include "vim.h"
#include "os/os.h"
static int quitmore = 0; static int quitmore = 0;
static int ex_pressedreturn = FALSE; static int ex_pressedreturn = FALSE;

View File

@@ -13,6 +13,7 @@
#include "vim.h" #include "vim.h"
#include "version.h" #include "version.h"
#include "os/os.h"
static char_u *vim_version_dir __ARGS((char_u *vimdir)); static char_u *vim_version_dir __ARGS((char_u *vimdir));
static char_u *remove_tail __ARGS((char_u *p, char_u *pend, char_u *name)); static char_u *remove_tail __ARGS((char_u *p, char_u *pend, char_u *name));

View File

@@ -11,6 +11,7 @@
* misc2.c: Various functions. * misc2.c: Various functions.
*/ */
#include "vim.h" #include "vim.h"
#include "os/os.h"
static char_u *username = NULL; /* cached result of mch_get_user_name() */ static char_u *username = NULL; /* cached result of mch_get_user_name() */

View File

@@ -8,15 +8,14 @@
*/ */
/* /*
* io.c -- filesystem access, event loop etc. * fs.c -- filesystem access
*/ */
#include "vim.h" #include <uv.h>
#include "uv.h" #include "os.h"
int mch_chdir(char *path) int mch_chdir(char *path) {
{
if (p_verbose >= 5) { if (p_verbose >= 5) {
verbose_enter(); verbose_enter();
smsg((char_u *)"chdir(%s)", path); smsg((char_u *)"chdir(%s)", path);

View File

@@ -11,16 +11,15 @@
* os.c -- OS-level calls to query hardware, etc. * os.c -- OS-level calls to query hardware, etc.
*/ */
#include "vim.h" #include <uv.h>
#include "uv.h" #include "os.h"
/* /*
* Return total amount of memory available in Kbyte. * Return total amount of memory available in Kbyte.
* Doesn't change when memory has been allocated. * Doesn't change when memory has been allocated.
*/ */
long_u mch_total_mem(int special) long_u mch_total_mem(int special) {
{
/* We need to return memory in *Kbytes* but uv_get_total_memory() returns the /* We need to return memory in *Kbytes* but uv_get_total_memory() returns the
* number of bytes of total memory. */ * number of bytes of total memory. */
return uv_get_total_memory() >> 10; return uv_get_total_memory() >> 10;

4
src/os/os.h Normal file
View File

@@ -0,0 +1,4 @@
#include "../vim.h"
long_u mch_total_mem(int special);
int mch_chdir(char *path);

View File

@@ -28,6 +28,7 @@
# define select select_declared_wrong # define select select_declared_wrong
#include "vim.h" #include "vim.h"
#include "os/os.h"
#include "os_unixx.h" /* unix includes for os_unix.c only */ #include "os_unixx.h" /* unix includes for os_unix.c only */

View File

@@ -1,9 +1,7 @@
/* os_unix.c */ /* os_unix.c */
int mch_chdir __ARGS((char *path));
void mch_write __ARGS((char_u *s, int len)); void mch_write __ARGS((char_u *s, int len));
int mch_inchar __ARGS((char_u *buf, int maxlen, long wtime, int tb_change_cnt)); int mch_inchar __ARGS((char_u *buf, int maxlen, long wtime, int tb_change_cnt));
int mch_char_avail __ARGS((void)); int mch_char_avail __ARGS((void));
long_u mch_total_mem __ARGS((int special));
void mch_delay __ARGS((long msec, int ignoreinput)); void mch_delay __ARGS((long msec, int ignoreinput));
int mch_stackcheck __ARGS((char *p)); int mch_stackcheck __ARGS((char *p));
void mch_startjmp __ARGS((void)); void mch_startjmp __ARGS((void));

View File

@@ -8,6 +8,7 @@
*/ */
#include "vim.h" #include "vim.h"
#include "os/os.h"
static int path_is_url __ARGS((char_u *p)); static int path_is_url __ARGS((char_u *p));
static void win_init __ARGS((win_T *newp, win_T *oldp, int flags)); static void win_init __ARGS((win_T *newp, win_T *oldp, int flags));