瀏覽代碼

Genericize compatibility

Extract additional platform-specific imports to basic compatibility
header.
master
TheoryOfNekomata 1 年之前
父節點
當前提交
a6ddf68c8a
共有 7 個檔案被更改,包括 44 行新增31 行删除
  1. +1
    -1
      CMakeLists.txt
  2. +1
    -1
      __mocks__/src/packages/stdinc/IZ_string.mock.h
  3. +18
    -0
      src/packages/compat/IZ_compat.h
  4. +0
    -22
      src/packages/compat/IZ_windows.h
  5. +10
    -5
      src/packages/io/IZ_io.h
  6. +8
    -1
      src/packages/log/IZ_log.h
  7. +6
    -1
      src/packages/stdinc/IZ_string.h

+ 1
- 1
CMakeLists.txt 查看文件

@@ -179,7 +179,7 @@ add_executable(
src/packages/log/IZ_log.h
src/packages/timer/IZ_timer.c
src/packages/timer/IZ_timer.h
src/packages/compat/IZ_windows.h
src/packages/compat/IZ_compat.h
src/packages/stdinc/IZ_stdlib.c
src/packages/stdinc/IZ_stdlib.h
)


+ 1
- 1
__mocks__/src/packages/stdinc/IZ_string.mock.h 查看文件

@@ -2,7 +2,7 @@
#define IZ_STRING_MOCK_C

#include <bdd-for-c-mocks.h>
#include "../../../src/packages/compat/IZ_windows.h"
#include "../../../src/packages/compat/IZ_compat.h"

mock(IZ_memset) void* IZ_memset(void* dst, int c, size_t len) {
mock_return(IZ_memset) 0;


+ 18
- 0
src/packages/compat/IZ_compat.h 查看文件

@@ -0,0 +1,18 @@
#ifndef IZ_COMPAT_H
#define IZ_COMPAT_H

#if defined IZ_WINDOWS
#define isatty _isatty
#define fileno _fileno
#endif

#if defined IZ_UNIX
typedef size_t rsize_t;
typedef int errno_t;
#endif

#if defined IZ_MACOS
typedef int errno_t;
#endif

#endif //IZ_COMPAT_H

+ 0
- 22
src/packages/compat/IZ_windows.h 查看文件

@@ -1,22 +0,0 @@
#ifndef IZ_WINDOWS_H
#define IZ_WINDOWS_H

#if defined IZ_WINDOWS
#include <io.h>
#include <SDL_syswm.h>
#define _isatty isatty
#define _fileno fileno
#endif

#if defined IZ_UNIX
typedef size_t rsize_t;
typedef int errno_t;
#endif

#if defined IZ_MACOS
#include <unistd.h>

typedef int errno_t;
#endif

#endif //IZ_WINDOWS_H

+ 10
- 5
src/packages/io/IZ_io.h 查看文件

@@ -1,16 +1,21 @@
#ifndef IZ_IO_H
#define IZ_IO_H

#include <stdio.h>
#include <stdbool.h>
#include <stdarg.h>
#include "../compat/IZ_windows.h"
#ifdef IZ_UNIX
#if defined IZ_WINDOWS
#include <io.h>
#include <SDL_syswm.h>
#elif defined IZ_UNIX
#include <sys/stat.h>
#elif defined IZ_MACOS
#include <sys/stat.h>
#include <unistd.h>
#endif

#include <stdio.h>
#include <stdbool.h>
#include <stdarg.h>
#include "../compat/IZ_compat.h"

int IZ_sprintf(char*, size_t, const char*, ...);

errno_t IZ_fopen(FILE**, const char*, const char*);


+ 8
- 1
src/packages/log/IZ_log.h 查看文件

@@ -16,7 +16,14 @@
#define IZ_LOG_LEVEL_FLAG_WARN
#define IZ_LOG_LEVEL_FLAG_ERROR

#include "../compat/IZ_windows.h"
#if defined IZ_WINDOWS
#include <io.h>
#include <SDL_syswm.h>
#elif defined IZ_MACOS
#include <unistd.h>
#endif

#include "../compat/IZ_compat.h"
#include <stdbool.h>
#include <stdarg.h>
#include <stdio.h>


+ 6
- 1
src/packages/stdinc/IZ_string.h 查看文件

@@ -2,7 +2,12 @@
#define IZ_STRING_H

#include <string.h>
#include "../compat/IZ_windows.h"
#if defined IZ_WINDOWS
#include <io.h>
#include <SDL_syswm.h>
#elif defined IZ_MACOS
#include <unistd.h>
#endif

errno_t IZ_memcpy(void*, rsize_t, const void*, rsize_t);



Loading…
取消
儲存