OSDN Git Service

Factor BSD non-standard type definitions into common header.
authorKeith Marshall <keithmarshall@users.sourceforge.net>
Sat, 9 Sep 2017 13:22:45 +0000 (14:22 +0100)
committerKeith Marshall <keithmarshall@users.sourceforge.net>
Sat, 9 Sep 2017 13:22:45 +0000 (14:22 +0100)
mingwrt/ChangeLog
mingwrt/include/sys/bsdtypes.h [new file with mode: 0644]
mingwrt/profile/gmon.c
mingwrt/profile/gmon.h
mingwrt/profile/mcount.c

index e606b1b..4e7500d 100644 (file)
@@ -1,3 +1,15 @@
+2017-09-09  Keith Marshall  <keithmarshall@users.sourceforge.net>
+
+       Factor BSD non-standard type definitions into common header.
+
+       * profile/gmon.h [_BSDTYPES_DEFINED]: Delete block; include...
+       * include/sys/bsdtypes.h: ...this new file instead; it defines...
+       (u_char, u_int, u_long, u_short): ...these non-standard data types.
+
+       * profile/gmon.c profile/mcount.c [_BSD_SOURCE]: Declare it;
+       it suppresses warnings from <sys/bsdtypes.h>, about ill-advised
+       non-standard BSD typedef usage.
+
 2017-07-30  Keith Marshall  <keithmarshall@users.sourceforge.net>
 
        Prepare and tag for release of MinGW.org WSL-5.0.1
diff --git a/mingwrt/include/sys/bsdtypes.h b/mingwrt/include/sys/bsdtypes.h
new file mode 100644 (file)
index 0000000..44d1a3a
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * bsdtypes.h
+ *
+ * Defines non-standard data types, typically used in BSD source code,
+ * and adopted by the Windows sockets implementation; users are advised
+ * to avoid using these data types, and use standard types instead.
+ *
+ * $Id$
+ *
+ * Abstracted from MinGW.org's WinSock implementation
+ * Copyright (C) 2017, MinGW.org Project
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ */
+#ifndef _SYS_BSDTYPES_H
+#pragma  GCC system_header
+#define _SYS_BSDTYPES_H
+
+/* This additional guard macro is required, to co-operate with newlib's
+ * <sys/types.h>, which also defines the data types defined herein.
+ */
+#ifndef _BSDTYPES_DEFINED
+
+/* All MinGW.org headers are required to include <_mingw.h>
+ */
+#include <_mingw.h>
+
+#if ! (defined _BSD_SOURCE || defined _WINSOCK_H)
+/* Users are STRONGLY recommended to avoid using the non-standard BSD
+ * data types defined herein, unless compiling code which proclaims its
+ * _BSD_SOURCE heritage, or which uses the Windows Sockets API, (which
+ * has ill-advisedly adopted them).
+ */
+#warning "Use of non-standard BSD type definitions is ill-advised."
+#endif
+
+/* Use "unsigned foo" instead of these "u_foo" shorthand aliases.
+ */
+typedef unsigned char  u_char;
+typedef unsigned short u_short;
+typedef unsigned int   u_int;
+typedef unsigned long  u_long;
+
+#define _BSDTYPES_DEFINED
+#endif /* !_BSDTYPES_DEFINED */
+#endif /* _SYS_BSDTYPES_H: $RCSfile$: end of file */
index a20c337..3f6223b 100644 (file)
@@ -30,6 +30,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
+#define _BSD_SOURCE
 
 #if !defined(lint) && defined(LIBC_SCCS)
 static char rcsid[] = "$OpenBSD: gmon.c,v 1.8 1997/07/23 21:11:27 kstailey Exp $";
index 1f01bf4..6827e89 100644 (file)
 #include <profile.h>
 
 #ifdef __MINGW32__
-#ifndef _BSDTYPES_DEFINED
-typedef unsigned char u_char;
-typedef unsigned short u_short;
-typedef unsigned int u_int;
-typedef unsigned long u_long;
-#define _BSDTYPES_DEFINED
-#endif /* _BSDTYPES_DEFINED */
+#include <sys/bsdtypes.h>
 #endif /* __MINGW32__*/
 
 /*
index 9f1736d..296b4fb 100644 (file)
@@ -30,6 +30,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
+#define _BSD_SOURCE
 
 #if !defined(lint) && !defined(_KERNEL) && defined(LIBC_SCCS)
 static char rcsid[] = "$OpenBSD: mcount.c,v 1.6 1997/07/23 21:11:27 kstailey Exp $";