diff options
author | Erik de Castro Lopo <erikd@mega-nerd.com> | 2016-05-12 15:45:00 +0200 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2016-05-12 17:33:39 +0200 |
commit | 995cf0f356ef3a8b7a394de640a853fd6ca9c2b5 (patch) | |
tree | 54cac37b35be9896ea94e8db806a2bd5cf8ae431 /includes | |
parent | 69c974fef825cfc286c9cad17ed8f4e138bf84fc (diff) | |
download | haskell-995cf0f356ef3a8b7a394de640a853fd6ca9c2b5.tar.gz |
rts: Make function pointer parameters `const` where possible
If a function takes a pointer parameter and doesn't update what
the pointer points to, we can add `const` to the parameter
declaration to document that no updates occur.
Test Plan: Validate on Linux, OS X and Windows
Reviewers: austin, Phyx, bgamari, simonmar, hsyl20
Reviewed By: bgamari, simonmar, hsyl20
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2200
Diffstat (limited to 'includes')
-rw-r--r-- | includes/rts/storage/ClosureMacros.h | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/includes/rts/storage/ClosureMacros.h b/includes/rts/storage/ClosureMacros.h index d7ae5ea122..5ed692871e 100644 --- a/includes/rts/storage/ClosureMacros.h +++ b/includes/rts/storage/ClosureMacros.h @@ -194,13 +194,13 @@ INLINE_HEADER P_ INTLIKE_CLOSURE(int n) { ------------------------------------------------------------------------- */ static inline StgWord -GET_CLOSURE_TAG(StgClosure * p) +GET_CLOSURE_TAG(const StgClosure * p) { return (StgWord)p & TAG_MASK; } static inline StgClosure * -UNTAG_CLOSURE(StgClosure * p) +UNTAG_CLOSURE(const StgClosure * p) { return (StgClosure*)((StgWord)p & ~TAG_MASK); } @@ -247,7 +247,7 @@ INLINE_HEADER rtsBool LOOKS_LIKE_INFO_PTR (StgWord p) return (p && (IS_FORWARDING_PTR(p) || LOOKS_LIKE_INFO_PTR_NOT_NULL(p))) ? rtsTrue : rtsFalse; } -INLINE_HEADER rtsBool LOOKS_LIKE_CLOSURE_PTR (void *p) +INLINE_HEADER rtsBool LOOKS_LIKE_CLOSURE_PTR (const void *p) { return LOOKS_LIKE_INFO_PTR((StgWord)(UNTAG_CLOSURE((StgClosure *)(p)))->header.info); } @@ -337,9 +337,9 @@ EXTERN_INLINE StgWord bco_sizeW ( StgBCO *bco ) * * (Also for 'closure_sizeW' below) */ -EXTERN_INLINE uint32_t closure_sizeW_ (StgClosure *p, StgInfoTable *info); +EXTERN_INLINE uint32_t closure_sizeW_ (const StgClosure *p, StgInfoTable *info); EXTERN_INLINE uint32_t -closure_sizeW_ (StgClosure *p, StgInfoTable *info) +closure_sizeW_ (const StgClosure *p, StgInfoTable *info) { switch (info->type) { case THUNK_0_1: @@ -399,8 +399,8 @@ closure_sizeW_ (StgClosure *p, StgInfoTable *info) } // The definitive way to find the size, in words, of a heap-allocated closure -EXTERN_INLINE uint32_t closure_sizeW (StgClosure *p); -EXTERN_INLINE uint32_t closure_sizeW (StgClosure *p) +EXTERN_INLINE uint32_t closure_sizeW (const StgClosure *p); +EXTERN_INLINE uint32_t closure_sizeW (const StgClosure *p) { return closure_sizeW_(p, get_itbl(p)); } @@ -505,7 +505,7 @@ INLINE_HEADER StgWord8 *mutArrPtrsCard (StgMutArrPtrs *a, W_ n) #endif #ifdef PROFILING -void LDV_recordDead (StgClosure *c, uint32_t size); +void LDV_recordDead (const StgClosure *c, uint32_t size); #endif EXTERN_INLINE void overwritingClosure (StgClosure *p); |