Преглед на файлове

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/log/IZ_log.h
src/packages/timer/IZ_timer.c src/packages/timer/IZ_timer.c
src/packages/timer/IZ_timer.h 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.c
src/packages/stdinc/IZ_stdlib.h 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 #define IZ_STRING_MOCK_C


#include <bdd-for-c-mocks.h> #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(IZ_memset) void* IZ_memset(void* dst, int c, size_t len) {
mock_return(IZ_memset) 0; 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 #ifndef IZ_IO_H
#define 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> #include <sys/stat.h>
#elif defined IZ_MACOS #elif defined IZ_MACOS
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h>
#endif #endif


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

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


errno_t IZ_fopen(FILE**, const char*, 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_WARN
#define IZ_LOG_LEVEL_FLAG_ERROR #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 <stdbool.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>


+ 6
- 1
src/packages/stdinc/IZ_string.h Целия файл

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


#include <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); errno_t IZ_memcpy(void*, rsize_t, const void*, rsize_t);




Зареждане…
Отказ
Запис