Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/gpl2/grep/dist/lib Make the alignof() usage more po...



details:   https://anonhg.NetBSD.org/src/rev/bf1773fd45d2
branches:  trunk
changeset: 319863:bf1773fd45d2
user:      kamil <kamil%NetBSD.org@localhost>
date:      Thu Jun 14 10:14:39 2018 +0000

description:
Make the alignof() usage more portable in grep(1)

Remove NetBSD specific check and replace it with GCC extension __alignof__
that is available since GCC 2.x.

Requested by <kre>

diffstat:

 external/gpl2/grep/dist/lib/obstack.c |  20 ++------------------
 1 files changed, 2 insertions(+), 18 deletions(-)

diffs (34 lines):

diff -r c816f1dd2463 -r bf1773fd45d2 external/gpl2/grep/dist/lib/obstack.c
--- a/external/gpl2/grep/dist/lib/obstack.c     Thu Jun 14 09:29:55 2018 +0000
+++ b/external/gpl2/grep/dist/lib/obstack.c     Thu Jun 14 10:14:39 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: obstack.c,v 1.2 2018/06/13 17:32:29 kamil Exp $        */
+/*     $NetBSD: obstack.c,v 1.3 2018/06/14 10:14:39 kamil Exp $        */
 
 /* obstack.c - subroutines used implicitly by object stack macros
    Copyright (C) 1988-1994,96,97,98,99 Free Software Foundation, Inc.
@@ -61,23 +61,7 @@
 
 /* Determine default alignment.  */
 struct fooalign {char x; double d;};
-
-#if defined(__NetBSD__)
-#include <sys/param.h>
-#endif
-
-#ifndef __NetBSD_Prereq__
-#define __NetBSD_Prereq__(a,b,c) 0
-#endif
-
-#if __NetBSD_Prereq__(8,0,0)
-#include <stdalign.h>
-// Avoid Undefined Behavior
-#define DEFAULT_ALIGNMENT ((int)alignof(struct fooalign))
-#else
-#define DEFAULT_ALIGNMENT  \
-  ((PTR_INT_TYPE) ((char *) &((struct fooalign *) 0)->d - (char *) 0))
-#endif
+#define DEFAULT_ALIGNMENT ((int)__alignof__(struct fooalign))
 /* If malloc were really smart, it would round addresses to DEFAULT_ALIGNMENT.
    But in fact it might be less smart and round addresses to as much as
    DEFAULT_ROUNDING.  So we prepare for it to do that.  */



Home | Main Index | Thread Index | Old Index