[commit: ghc] master: Remove obsolete/redundant FLEXIBLE_ARRAY macro (32ddd96)

git at git.haskell.org git at git.haskell.org
Mon Apr 18 22:01:07 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/32ddd96972301a03dc0d594bda76da426785e722/ghc

>---------------------------------------------------------------

commit 32ddd96972301a03dc0d594bda76da426785e722
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date:   Mon Apr 18 22:26:02 2016 +0200

    Remove obsolete/redundant FLEXIBLE_ARRAY macro
    
    This macro is doubly redundant, first off all, ancient GCCs prior to
    version 3.0 are not supported anymore, but more importantly, we require
    a ISO C99 compliant compiler, so we can use the proper ISO C syntax
    without worrying about compatibility.
    
    Reviewers: austin, bgamari
    
    Reviewed By: bgamari
    
    Subscribers: carter, thomie
    
    Differential Revision: https://phabricator.haskell.org/D2121


>---------------------------------------------------------------

32ddd96972301a03dc0d594bda76da426785e722
 includes/Rts.h                    |  9 ---------
 includes/rts/storage/Closures.h   | 20 ++++++++++----------
 includes/rts/storage/InfoTables.h |  4 ++--
 includes/rts/storage/TSO.h        |  2 +-
 4 files changed, 13 insertions(+), 22 deletions(-)

diff --git a/includes/Rts.h b/includes/Rts.h
index 6f4f33e..1ad1bba 100644
--- a/includes/Rts.h
+++ b/includes/Rts.h
@@ -41,15 +41,6 @@ extern "C" {
 #include "rts/Types.h"
 
 #if __GNUC__ >= 3
-/* Assume that a flexible array member at the end of a struct
- * can be defined thus: T arr[]; */
-#define FLEXIBLE_ARRAY
-#else
-/* Assume that it must be defined thus: T arr[0]; */
-#define FLEXIBLE_ARRAY 0
-#endif
-
-#if __GNUC__ >= 3
 #define ATTRIBUTE_ALIGNED(n) __attribute__((aligned(n)))
 #else
 #define ATTRIBUTE_ALIGNED(n) /*nothing*/
diff --git a/includes/rts/storage/Closures.h b/includes/rts/storage/Closures.h
index 2ce1a27..f880b5c 100644
--- a/includes/rts/storage/Closures.h
+++ b/includes/rts/storage/Closures.h
@@ -79,12 +79,12 @@ typedef struct {
 
 typedef struct StgClosure_ {
     StgHeader   header;
-    struct StgClosure_ *payload[FLEXIBLE_ARRAY];
+    struct StgClosure_ *payload[];
 } *StgClosurePtr; // StgClosure defined in rts/Types.h
 
 typedef struct {
     StgThunkHeader  header;
-    struct StgClosure_ *payload[FLEXIBLE_ARRAY];
+    struct StgClosure_ *payload[];
 } StgThunk;
 
 typedef struct {
@@ -97,7 +97,7 @@ typedef struct {
     StgHalfWord arity;          /* zero if it is an AP */
     StgHalfWord n_args;
     StgClosure *fun;            /* really points to a fun */
-    StgClosure *payload[FLEXIBLE_ARRAY];
+    StgClosure *payload[];
 } StgPAP;
 
 typedef struct {
@@ -105,14 +105,14 @@ typedef struct {
     StgHalfWord arity;          /* zero if it is an AP */
     StgHalfWord n_args;
     StgClosure *fun;            /* really points to a fun */
-    StgClosure *payload[FLEXIBLE_ARRAY];
+    StgClosure *payload[];
 } StgAP;
 
 typedef struct {
     StgThunkHeader   header;
     StgWord     size;                    /* number of words in payload */
     StgClosure *fun;
-    StgClosure *payload[FLEXIBLE_ARRAY]; /* contains a chunk of *stack* */
+    StgClosure *payload[]; /* contains a chunk of *stack* */
 } StgAP_STACK;
 
 typedef struct {
@@ -138,21 +138,21 @@ typedef struct StgBlockingQueue_ {
 typedef struct {
     StgHeader  header;
     StgWord    bytes;
-    StgWord    payload[FLEXIBLE_ARRAY];
+    StgWord    payload[];
 } StgArrBytes;
 
 typedef struct {
     StgHeader   header;
     StgWord     ptrs;
     StgWord     size; // ptrs plus card table
-    StgClosure *payload[FLEXIBLE_ARRAY];
+    StgClosure *payload[];
     // see also: StgMutArrPtrs macros in ClosureMacros.h
 } StgMutArrPtrs;
 
 typedef struct {
     StgHeader   header;
     StgWord     ptrs;
-    StgClosure *payload[FLEXIBLE_ARRAY];
+    StgClosure *payload[];
 } StgSmallMutArrPtrs;
 
 typedef struct {
@@ -241,7 +241,7 @@ typedef struct {
     StgMutArrPtrs *ptrs;        /* a pointer to a  MutArrPtrs */
     StgHalfWord   arity;        /* arity of this BCO */
     StgHalfWord   size;         /* size of this BCO (in words) */
-    StgWord       bitmap[FLEXIBLE_ARRAY];  /* an StgLargeBitmap */
+    StgWord       bitmap[];  /* an StgLargeBitmap */
 } StgBCO;
 
 #define BCO_BITMAP(bco)      ((StgLargeBitmap *)((StgBCO *)(bco))->bitmap)
@@ -261,7 +261,7 @@ typedef struct {
     const StgInfoTable* info;
     StgWord        size;
     StgClosure *   fun;
-    StgClosure *   payload[FLEXIBLE_ARRAY];
+    StgClosure *   payload[];
 } StgRetFun;
 
 /* Concurrent communication objects */
diff --git a/includes/rts/storage/InfoTables.h b/includes/rts/storage/InfoTables.h
index 228369b..3de63c8 100644
--- a/includes/rts/storage/InfoTables.h
+++ b/includes/rts/storage/InfoTables.h
@@ -125,7 +125,7 @@ extern StgWord16 closure_flags[];
  */
 typedef struct {
   StgWord size;
-  StgWord bitmap[FLEXIBLE_ARRAY];
+  StgWord bitmap[];
 } StgLargeBitmap;
 
 /* -----------------------------------------------------------------------------
@@ -206,7 +206,7 @@ typedef struct StgInfoTable_ {
        */
 
 #ifdef TABLES_NEXT_TO_CODE
-    StgCode         code[FLEXIBLE_ARRAY];
+    StgCode         code[];
 #endif
 } *StgInfoTablePtr;
 
diff --git a/includes/rts/storage/TSO.h b/includes/rts/storage/TSO.h
index 9bddfca..aa3d057 100644
--- a/includes/rts/storage/TSO.h
+++ b/includes/rts/storage/TSO.h
@@ -191,7 +191,7 @@ typedef struct StgStack_ {
     StgWord32  stack_size;     // stack size in *words*
     StgWord32  dirty;          // non-zero => dirty
     StgPtr     sp;             // current stack pointer
-    StgWord    stack[FLEXIBLE_ARRAY];
+    StgWord    stack[];
 } StgStack;
 
 // Calculate SpLim from a TSO (reads tso->stackobj, but no fields from



More information about the ghc-commits mailing list