?login_element?

Subversion Repositories NedoOS

Rev

Rev 539 | Blame | Compare with Previous | Last modification | View Log | Download

  1. /*
  2.  
  3.   SjASMPlus Z80 Cross Compiler
  4.  
  5.   This is modified sources of SjASM by Aprisobal - aprisobal@tut.by
  6.  
  7.   Copyright (c) 2005 Sjoerd Mastijn
  8.  
  9.   This software is provided 'as-is', without any express or implied warranty.
  10.   In no event will the authors be held liable for any damages arising from the
  11.   use of this software.
  12.  
  13.   Permission is granted to anyone to use this software for any purpose,
  14.   including commercial applications, and to alter it and redistribute it freely,
  15.   subject to the following restrictions:
  16.  
  17.   1. The origin of this software must not be misrepresented; you must not claim
  18.          that you wrote the original software. If you use this software in a product,
  19.          an acknowledgment in the product documentation would be appreciated but is
  20.          not required.
  21.  
  22.   2. Altered source versions must be plainly marked as such, and must not be
  23.          misrepresented as being the original software.
  24.  
  25.   3. This notice may not be removed or altered from any source distribution.
  26.  
  27. */
  28.  
  29. // support.h
  30.  
  31. constexpr char pathBadSlash = '\\';
  32. constexpr char pathGoodSlash = '/';
  33.  
  34. constexpr uint16_t sj_bswap16(const uint16_t v) {
  35.         return ((v>>8)&0xFF) | ((v<<8)&0xFF00);
  36. }
  37.  
  38. constexpr uint32_t sj_bswap32(const uint32_t v) {
  39.         return ((v>>24)&0xFF) | ((v>>8)&0xFF00) | ((v<<8)&0xFF0000) | ((v<<24)&0xFF000000);
  40. }
  41.  
  42. static_assert(0x3412 == sj_bswap16(0x1234), "internal error in bswap16 implementation");
  43. static_assert(0x78563412 == sj_bswap32(0x12345678), "internal error in bswap32 implementation");
  44.  
  45. #if defined (_MSC_VER)
  46.  
  47. #define _CRT_SECURE_NO_WARNINGS 1
  48.  
  49. // #define FOPEN(pFile, filename, mode) fopen_s(&pFile, filename, mode)
  50. // #define FOPEN_ISOK(pFile, filename, mode) (fopen_s(&pFile, filename, mode) == 0)
  51.  
  52. #define strcasecmp(s1, s2) stricmp(s1, s2)
  53.  
  54. #else
  55.  
  56. #include <sys/time.h>
  57. #if !defined(__MINGW32__)
  58. #include <sys/wait.h>
  59. #endif
  60. #include <unistd.h>
  61.  
  62. #endif
  63.  
  64. #ifndef TCHAR
  65. #define TCHAR char
  66. #endif
  67. #ifndef WIN32
  68. long GetTickCount();
  69. #endif
  70.  
  71. FILE* SJ_fopen(const char* fname, const char* mode);
  72. void SJ_GetCurrentDirectory(int, char*);
  73. int SJ_SearchPath(const char* oudzp, const char* filename, const char* /*extension*/, int maxlen, char* nieuwzp, char** ach);
  74.  
  75. // FILE* dbg_fopen(const char* fname, const char* modes);
  76.  
  77. #define FOPEN_ISOK(pFile, filename, mode) ((pFile = SJ_fopen(filename, mode)) != NULL)
  78.  
  79. #define STRDUP strdup
  80. #define STRCAT(strDestination, sizeInBytes, strSource) strncat(strDestination, strSource, sizeInBytes)
  81. #define STRCPY(strDestination, sizeInBytes, strSource) strcpy(strDestination, strSource)
  82. #define STRNCPY(strDestination, sizeInBytes, strSource, count) strncpy(strDestination, strSource, count)
  83. #define SPRINTF1(buffer, sizeOfBuffer, format, arg1) snprintf(buffer, sizeOfBuffer, format, arg1)
  84. #define SPRINTF2(buffer, sizeOfBuffer, format, arg1, arg2) snprintf(buffer, sizeOfBuffer, format, arg1, arg2)
  85. #define SPRINTF3(buffer, sizeOfBuffer, format, arg1, arg2, arg3) snprintf(buffer, sizeOfBuffer, format, arg1, arg2, arg3)
  86. #define SPRINTF4(buffer, sizeOfBuffer, format, arg1, arg2, arg3, arg4) snprintf(buffer, sizeOfBuffer, format, arg1, arg2, arg3, arg4)
  87. #define STRNCAT(strDest, bufferSizeInBytes, strSource, count) strncat(strDest, strSource, count)
  88. #define STRSTR(str, strSearch) strstr(str, strSearch)
  89. #define STRCHR(str, charToSearch) strchr(str, charToSearch)
  90.  
  91. void switchStdOutIntoBinaryMode();
  92.  
  93. #ifdef USE_LUA
  94. void LuaShellExec(const char *command);
  95. #endif //USE_LUA
  96.  
  97. #ifndef WEXITSTATUS
  98. # define WEXITSTATUS(exitstatus) (exitstatus)
  99. #endif
  100.  
  101. //eof support.h
  102.