Skip to content

Instantly share code, notes, and snippets.

@maki-rxrz
Last active August 30, 2019 11:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maki-rxrz/ccb8db1400de3d9000e88d778489c486 to your computer and use it in GitHub Desktop.
Save maki-rxrz/ccb8db1400de3d9000e88d778489c486 to your computer and use it in GitHub Desktop.
NASM patches. [target] branch: git-master, revision: r4333-6a4353c4 (, tag: nasm-2.14.03rc2)
diff --git a/Makefile.in b/Makefile.in
index 68ec9d45..e9923c75 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -441,9 +441,9 @@ install_everything: everything install install_doc install_rdf
dist:
$(MAKE) alldeps
- $(MAKE) spotless perlreq manpages spec
- autoheader
- autoconf
+ $(MAKE) manpages spec
+ $(RM_F) config.log config.status config/config.h
+ $(RM_F) Makefile *.dep
$(RM_RF) ./autom4te*.cache
tar: dist
diff --git a/include/compiler.h b/include/compiler.h
index 04cab173..4317bf7e 100644
--- a/include/compiler.h
+++ b/include/compiler.h
@@ -57,6 +57,7 @@
#ifdef HAVE_CONFIG_H
# include "config/config.h"
#else
+# include "config/unconfig.h"
# if defined(_MSC_VER) && (_MSC_VER >= 1310)
# include "config/msvc.h"
# elif defined(__WATCOMC__)
@@ -65,7 +66,6 @@
# include "config/unknown.h"
# endif
/* This unconditionally defines some macros we really want */
-# include "config/unconfig.h"
#endif /* Configuration file */
/* This is required to get the standard <inttypes.h> macros when compiling
@@ -306,8 +306,13 @@ static inline void *mempcpy(void *dst, const void *src, size_t n)
/*
* How to tell the compiler that a function takes a printf-like string
*/
+#ifdef __MINGW32__
+#define printf_func(fmt, list) format_func3(__MINGW_PRINTF_FORMAT,fmt,list)
+#define printf_func_ptr(fmt, list) format_func3_ptr(__MINGW_PRINTF_FORMAT,fmt,list)
+#else
#define printf_func(fmt, list) format_func3(printf,fmt,list)
#define printf_func_ptr(fmt, list) format_func3_ptr(printf,fmt,list)
+#endif
/* Determine probabilistically if something is a compile-time constant */
#ifdef HAVE___BUILTIN_CONSTANT_P
diff --git a/nasmlib/file.h b/nasmlib/file.h
index 4f0420ec..d36aa73d 100644
--- a/nasmlib/file.h
+++ b/nasmlib/file.h
@@ -195,7 +195,7 @@ static inline int os_stat(os_filename osfname, os_struct_stat *st)
#ifndef os_fstat
static inline int os_fstat(int fd, os_struct_stat *st)
{
- (void)osfname;
+ (void)fd;
(void)st;
return -1;
}
diff --git a/nasmlib/mmap.c b/nasmlib/mmap.c
index 5fc5646f..b3fae457 100644
--- a/nasmlib/mmap.c
+++ b/nasmlib/mmap.c
@@ -42,6 +42,10 @@
* System page size
*/
+#if defined(HAVE_GETPAGESIZE) && defined(__MINGW32__) && !defined(getpagesize)
+int getpagesize (void); /* defined in MinGW's libgcc.a */
+#endif
+
/* File scope since not all compilers like static data in inline functions */
static size_t nasm_pagemask;
From 78e45851323d556adb43d75681f4a02ed6cc0cda Mon Sep 17 00:00:00 2001
From: Masaki Tanaka <maki.rxrz@gmail.com>
Date: Thu, 29 Aug 2019 00:00:00 +0900
Subject: [PATCH 1/5] nasmlib/file.h: Fix wrong code
---
nasmlib/file.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/nasmlib/file.h b/nasmlib/file.h
index 4f0420ec..d36aa73d 100644
--- a/nasmlib/file.h
+++ b/nasmlib/file.h
@@ -195,7 +195,7 @@ static inline int os_stat(os_filename osfname, os_struct_stat *st)
#ifndef os_fstat
static inline int os_fstat(int fd, os_struct_stat *st)
{
- (void)osfname;
+ (void)fd;
(void)st;
return -1;
}
--
2.23.0.windows.1
From 431b90a7d928a8cffff253a49a7a80c7f3d4c31a Mon Sep 17 00:00:00 2001
From: Masaki Tanaka <maki.rxrz@gmail.com>
Date: Fri, 30 Aug 2019 00:00:00 +0900
Subject: [PATCH 2/5] include/compiler.h: Change include order of unconfig.h
---
include/compiler.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/compiler.h b/include/compiler.h
index 04cab173..2922d15f 100644
--- a/include/compiler.h
+++ b/include/compiler.h
@@ -57,6 +57,7 @@
#ifdef HAVE_CONFIG_H
# include "config/config.h"
#else
+# include "config/unconfig.h"
# if defined(_MSC_VER) && (_MSC_VER >= 1310)
# include "config/msvc.h"
# elif defined(__WATCOMC__)
@@ -65,7 +66,6 @@
# include "config/unknown.h"
# endif
/* This unconditionally defines some macros we really want */
-# include "config/unconfig.h"
#endif /* Configuration file */
/* This is required to get the standard <inttypes.h> macros when compiling
--
2.23.0.windows.1
From 8263aaeac2241d27b9e45d52b063891f3e78c759 Mon Sep 17 00:00:00 2001
From: Masaki Tanaka <maki.rxrz@gmail.com>
Date: Sat, 25 Feb 2017 00:00:00 +0900
Subject: [PATCH 3/5] nasmlib/mmap.c: Add prototype definition for mingw(-w64)
getpagesize() is defined in MinGW's libgcc.a.
---
nasmlib/mmap.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/nasmlib/mmap.c b/nasmlib/mmap.c
index 5fc5646f..b3fae457 100644
--- a/nasmlib/mmap.c
+++ b/nasmlib/mmap.c
@@ -42,6 +42,10 @@
* System page size
*/
+#if defined(HAVE_GETPAGESIZE) && defined(__MINGW32__) && !defined(getpagesize)
+int getpagesize (void); /* defined in MinGW's libgcc.a */
+#endif
+
/* File scope since not all compilers like static data in inline functions */
static size_t nasm_pagemask;
--
2.23.0.windows.1
From 32391cc614ee63f2dca96a01399813097457ecd6 Mon Sep 17 00:00:00 2001
From: Yuta Nakai <nak5124@live.jp>
Date: Sat, 12 Mar 2016 22:52:42 +0900
Subject: [PATCH 4/5] include/compiler.h: mingw printf
Customized by: Masaki Tanaka <maki.rxrz@gmail.com>
---
include/compiler.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/include/compiler.h b/include/compiler.h
index 2922d15f..4317bf7e 100644
--- a/include/compiler.h
+++ b/include/compiler.h
@@ -306,8 +306,13 @@ static inline void *mempcpy(void *dst, const void *src, size_t n)
/*
* How to tell the compiler that a function takes a printf-like string
*/
+#ifdef __MINGW32__
+#define printf_func(fmt, list) format_func3(__MINGW_PRINTF_FORMAT,fmt,list)
+#define printf_func_ptr(fmt, list) format_func3_ptr(__MINGW_PRINTF_FORMAT,fmt,list)
+#else
#define printf_func(fmt, list) format_func3(printf,fmt,list)
#define printf_func_ptr(fmt, list) format_func3_ptr(printf,fmt,list)
+#endif
/* Determine probabilistically if something is a compile-time constant */
#ifdef HAVE___BUILTIN_CONSTANT_P
--
2.23.0.windows.1
From c20cc463d74c177eefea17b2db9fc0d1eae4b5f1 Mon Sep 17 00:00:00 2001
From: Masaki Tanaka <maki.rxrz@gmail.com>
Date: Wed, 28 Aug 2019 00:00:00 +0900
Subject: [PATCH 5/5] Makefile.in: Modify 'make dist' for msys2 environment
---
Makefile.in | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/Makefile.in b/Makefile.in
index 68ec9d45..e9923c75 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -441,9 +441,9 @@ install_everything: everything install install_doc install_rdf
dist:
$(MAKE) alldeps
- $(MAKE) spotless perlreq manpages spec
- autoheader
- autoconf
+ $(MAKE) manpages spec
+ $(RM_F) config.log config.status config/config.h
+ $(RM_F) Makefile *.dep
$(RM_RF) ./autom4te*.cache
tar: dist
--
2.23.0.windows.1
From 21208afe68a5437cb0448e4dc56d7eb3044113de Mon Sep 17 00:00:00 2001
From: Masaki Tanaka <maki.rxrz@gmail.com>
Date: Tue, 4 Apr 2017 00:00:00 +0900
Subject: [PATCH 1/2] msvc.mak: Use '/nologo' option
---
Mkfiles/msvc.mak | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Mkfiles/msvc.mak b/Mkfiles/msvc.mak
index 25667a37..d6713b07 100644
--- a/Mkfiles/msvc.mak
+++ b/Mkfiles/msvc.mak
@@ -26,8 +26,8 @@ CFLAGS = /O2 /Zi
LDFLAGS = /DEBUG /OPT:REF /OPT:ICF # (latter two undoes /DEBUG harm)
!ENDIF
-CC = cl
-AR = lib
+CC = cl /nologo
+AR = lib /nologo
CFLAGS = $(CFLAGS) /W2
BUILD_CFLAGS = $(CFLAGS)
INTERNAL_CFLAGS = /I$(srcdir) /I. \
--
2.23.0.windows.1
From 1efc345cc4a2de6aa2ab52fa12ab95535d4c739c Mon Sep 17 00:00:00 2001
From: Masaki Tanaka <maki.rxrz@gmail.com>
Date: Fri, 7 Apr 2017 00:00:00 +0900
Subject: [PATCH 2/2] msvc.mak: Fix wildcard handling for perl script
---
Mkfiles/msvc.mak | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Mkfiles/msvc.mak b/Mkfiles/msvc.mak
index d6713b07..d7a85223 100644
--- a/Mkfiles/msvc.mak
+++ b/Mkfiles/msvc.mak
@@ -188,8 +188,8 @@ nsis\version.nsh: version version.pl
# standard distribution.
macros\macros.c: macros\macros.pl asm\pptok.ph version.mac \
$(srcdir)\macros\*.mac $(srcdir)\output\*.mac
- $(RUNPERL) $(srcdir)\macros\macros.pl version.mac \
- $(srcdir)\macros\*.mac $(srcdir)\output\*.mac
+ $(RUNPERL) $(srcdir)/macros/macros.pl version.mac \
+ $(srcdir)/macros/*.mac $(srcdir)/output/*.mac
# These source files are generated from regs.dat by yet another
# perl script.
--
2.23.0.windows.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment