Advertisement
uaa

[wip:20221204] run68: stand up *BSD guys!

uaa
Dec 14th, 2022
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.99 KB | None | 0 0
  1. diff --git a/CMakeLists.txt b/CMakeLists.txt
  2. index 2045978..62c9dae 100644
  3. --- a/CMakeLists.txt
  4. +++ b/CMakeLists.txt
  5. @@ -1,17 +1,18 @@
  6. cmake_minimum_required(VERSION 3.13)
  7. option(USE_ICONV "Use iconv for converting Shift-JIS to UTF-8." ON)
  8.  
  9. +project(run68 C)
  10. +
  11. #add_definitions(-DFNC_TRACE -DENV_FROM_INI)
  12. add_definitions(-DENV_FROM_INI)
  13.  
  14. if(USE_ICONV)
  15. + find_package(Iconv REQUIRED)
  16. add_definitions(-DUSE_ICONV)
  17. else()
  18. endif()
  19.  
  20.  
  21. -project(run68 C)
  22. -
  23. if (EMSCRIPTEN)
  24. set(CMAKE_EXE_LINKER_FLAGS "--embed-file ./fs@ -sFORCE_FILESYSTEM")
  25. endif()
  26. @@ -58,10 +59,8 @@ add_executable(run68 ${SRC})
  27. set(LIBS m) # math lib
  28.  
  29. if(USE_ICONV)
  30. -
  31. - if(APPLE)
  32. - set(LIBS ${LIBS} "iconv")
  33. - endif()
  34. + include_directories(${Iconv_INCLUDE_DIRS})
  35. + set(LIBS ${LIBS} ${Iconv_LIBRARIES})
  36. endif()
  37.  
  38. target_link_libraries(run68 PUBLIC ${LIBS})
  39. diff --git a/src/doscall.c b/src/doscall.c
  40. index dc94f98..3c1c8e5 100644
  41. --- a/src/doscall.c
  42. +++ b/src/doscall.c
  43. @@ -70,9 +70,6 @@
  44. #include <dos.h>
  45. #include <direct.h>
  46. #include <io.h>
  47. -#elif defined(__APPLE__) || defined(__EMSCRIPTEN__)
  48. - #include <time.h>
  49. - #include <dirent.h>
  50. #else
  51. #include <time.h>
  52. #include <dirent.h>
  53. @@ -136,7 +133,7 @@ static Long gets2( char *, int );
  54.  
  55. Long Getenv_common(const char *name_p, char *buf_p);
  56.  
  57. -#if defined(__APPLE__) || defined(__linux__) || defined(__EMSCRIPTEN__)
  58. +#if defined(__APPLE__) || defined(__linux__) || defined(__EMSCRIPTEN__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__)
  59. void CloseHandle( FILE* fp ) {
  60. fclose( fp );
  61. }
  62. @@ -368,7 +365,7 @@ int dos_call( UChar code )
  63. #elif defined(DOSX)
  64. _dos_write( fileno(finfo[ 1 ].fh), data_ptr,
  65. (unsigned)len, &drv );
  66. -#elif defined(__APPLE__) || defined(__linux__) || defined(__EMSCRIPTEN__)
  67. +#elif defined(__APPLE__) || defined(__linux__) || defined(__EMSCRIPTEN__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__)
  68. // _dos_write( fileno(finfo[ 1 ].fh), data_ptr, (unsigned)len, &drv );
  69. #if defined (USE_ICONV)
  70. {
  71. @@ -1573,7 +1570,7 @@ static Long Create( char *p, short atr )
  72. int len;
  73.  
  74.  
  75. -#if defined(__APPLE__) || defined(__linux__) || defined(__EMSCRIPTEN__)
  76. +#if defined(__APPLE__) || defined(__linux__) || defined(__EMSCRIPTEN__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__)
  77. char* name = p;
  78. int namelen = strlen(name);
  79. for (int i=0;i<namelen;++i) {
  80. @@ -1719,7 +1716,7 @@ static Long Open( char *p, short mode )
  81. Long ret;
  82. Long i;
  83.  
  84. -#if defined(__APPLE__) || defined(__linux__) || defined(__EMSCRIPTEN__)
  85. +#if defined(__APPLE__) || defined(__linux__) || defined(__EMSCRIPTEN__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__)
  86. char* name = p;
  87. int namelen = strlen(name);
  88. for (int i=0;i<namelen;++i) {
  89. @@ -1985,15 +1982,10 @@ static Long Write( short hdl, Long buf, Long len )
  90. }
  91. if (finfo [ hdl ].fh == stdout)
  92. fflush( stdout );
  93. -#elif defined(__APPLE__) || defined(__linux__) || defined(__EMSCRIPTEN__)
  94. - write_len = fwrite( write_buf, 1, len, finfo [ hdl ].fh );
  95. - if (finfo [ hdl ].fh == stdout)
  96. - fflush( stdout );
  97. #else
  98. write_len = fwrite( write_buf, 1, len, finfo [ hdl ].fh );
  99. if (finfo [ hdl ].fh == stdout)
  100. fflush( stdout );
  101. -// #error NOTIMPLEMENTED
  102. #endif
  103.  
  104. return( write_len );
  105. @@ -2553,8 +2545,6 @@ static Long Nfiles( Long buf )
  106. strncpy(&buf_ptr[30], f_data.cFileName, 22);
  107. buf_ptr[30+22] = 0;
  108.  
  109. -#elif defined(__APPLE__) || defined(__linux__) || defined(__EMSCRIPTEN__)
  110. - printf("DOSCALL NFILES:not defined yet %s %d\n", __FILE__, __LINE__ );
  111. #else
  112. printf("DOSCALL NFILES:not defined yet %s %d\n", __FILE__, __LINE__ );
  113. #endif
  114. @@ -2567,7 +2557,7 @@ static Long Nfiles( Long buf )
  115. */
  116. static Long Filedate( short hdl, Long dt )
  117. {
  118. -#if defined(__APPLE__) || defined(__linux__) || defined(__EMSCRIPTEN__)
  119. +#if defined(__APPLE__) || defined(__linux__) || defined(__EMSCRIPTEN__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__)
  120. printf("DOSCALL FILEDATE:not defined yet %s %d\n", __FILE__, __LINE__ );
  121. #else
  122. #if defined(WIN32)
  123. diff --git a/src/iocscall.c b/src/iocscall.c
  124. index 7da92b6..f296d42 100644
  125. --- a/src/iocscall.c
  126. +++ b/src/iocscall.c
  127. @@ -26,8 +26,7 @@
  128. #include <windows.h>
  129. #elif defined(DOSX)
  130. #include <dos.h>
  131. -#elif defined(__APPLE__)
  132. -#else
  133. +#elif defined(__linux__)
  134. #include <sys/sysinfo.h>
  135. #endif
  136.  
  137. @@ -177,11 +176,11 @@ int iocs_call()
  138. ul = time( NULL );
  139. rd [ 0 ] = (ul % (60 * 60 * 24)) * 100;
  140. rd [ 1 ] = ((ul / (60 * 60 * 24)) & 0xFFFF);
  141. -#elif defined(__APPLE__) || defined(__EMSCRIPTEN__)
  142. +#elif !defined(__linux__)
  143. ul = time( NULL );
  144. rd [ 0 ] = (ul % (60 * 60 * 24)) * 100;
  145. rd [ 1 ] = ((ul / (60 * 60 * 24)) & 0xFFFF);
  146. -#else
  147. +#else //__linux__
  148. {
  149. struct sysinfo info;
  150. sysinfo(&info);
  151.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement