Add platform-specific fixes file

Create a new file, platform.h, for platform-specific hacks

for MSVC, this includes defining strncasecmp to _stricmp and
strdup to _strdup, among other things like defining missing
stat macros

Change some things not supported in MSVC, like _Static_assert,
to their counterparts (in this case, static_assert)

Replace usage of VLAs with malloc and free

Update getopt_long and use the getopt implementation from musl
on Windows.

Use comments to show which functions from platform.h are being used
This commit is contained in:
James Larrowe
2020-07-21 14:24:22 -04:00
parent 0793e9effe
commit e51701acaa
11 changed files with 167 additions and 39 deletions

View File

@@ -15,7 +15,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include "asm/asm.h"
#include "asm/charmap.h"
@@ -34,6 +33,7 @@
#include "extern/utf8decoder.h"
#include "linkdefs.h"
#include "platform.h" // strncasecmp, strdup
uint32_t nListCountEmpty;
char *tzNewMacro;

View File

@@ -19,7 +19,6 @@
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "asm/fstack.h"
#include "asm/lexer.h"
@@ -30,6 +29,7 @@
#include "extern/err.h"
#include "platform.h" // S_ISDIR (stat macro)
#include "types.h"
static struct sContext *pFileStack;

View File

@@ -13,7 +13,6 @@
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include "asm/asm.h"
#include "asm/fstack.h"
@@ -27,6 +26,7 @@
#include "extern/err.h"
#include "asmy.h"
#include "platform.h" // strncasecmp, strdup
struct sLexString {
char *tzName;

View File

@@ -30,6 +30,7 @@
#include "extern/err.h"
#include "linkdefs.h"
#include "platform.h" // strdup
struct Patch {
char tzFilename[_MAX_PATH + 1];

View File

@@ -14,6 +14,7 @@
#include "asm/warning.h"
#include "extern/err.h"
#include "platform.h" // strdup
struct SectionStackEntry {
struct Section *pSection;