no-more-MemSet.patch
text/x-diff
Patch
Format: unified
| File | + | − |
|---|---|---|
| src/include/c.h | 0 | 0 |
diff --git a/src/include/c.h b/src/include/c.h
index b6a9697..f7ea3a5 100644
*** a/src/include/c.h
--- b/src/include/c.h
*************** typedef NameData *Name;
*** 843,874 ****
* memset() functions. More research needs to be done, perhaps with
* MEMSET_LOOP_LIMIT tests in configure.
*/
! #define MemSet(start, val, len) \
! do \
! { \
! /* must be void* because we don't know if it is integer aligned yet */ \
! void *_vstart = (void *) (start); \
! int _val = (val); \
! Size _len = (len); \
! \
! if ((((uintptr_t) _vstart) & LONG_ALIGN_MASK) == 0 && \
! (_len & LONG_ALIGN_MASK) == 0 && \
! _val == 0 && \
! _len <= MEMSET_LOOP_LIMIT && \
! /* \
! * If MEMSET_LOOP_LIMIT == 0, optimizer should find \
! * the whole "if" false at compile time. \
! */ \
! MEMSET_LOOP_LIMIT != 0) \
! { \
! long *_start = (long *) _vstart; \
! long *_stop = (long *) ((char *) _start + _len); \
! while (_start < _stop) \
! *_start++ = 0; \
! } \
! else \
! memset(_vstart, _val, _len); \
! } while (0)
/*
* MemSetAligned is the same as MemSet except it omits the test to see if
--- 843,849 ----
* memset() functions. More research needs to be done, perhaps with
* MEMSET_LOOP_LIMIT tests in configure.
*/
! #define MemSet(start, val, len) memset(start, val, len)
/*
* MemSetAligned is the same as MemSet except it omits the test to see if
*************** typedef NameData *Name;
*** 876,901 ****
* that the pointer is suitably aligned (typically, because he just got it
* from palloc(), which always delivers a max-aligned pointer).
*/
! #define MemSetAligned(start, val, len) \
! do \
! { \
! long *_start = (long *) (start); \
! int _val = (val); \
! Size _len = (len); \
! \
! if ((_len & LONG_ALIGN_MASK) == 0 && \
! _val == 0 && \
! _len <= MEMSET_LOOP_LIMIT && \
! MEMSET_LOOP_LIMIT != 0) \
! { \
! long *_stop = (long *) ((char *) _start + _len); \
! while (_start < _stop) \
! *_start++ = 0; \
! } \
! else \
! memset(_start, _val, _len); \
! } while (0)
!
/*
* MemSetTest/MemSetLoop are a variant version that allow all the tests in
--- 851,857 ----
* that the pointer is suitably aligned (typically, because he just got it
* from palloc(), which always delivers a max-aligned pointer).
*/
! #define MemSetAligned(start, val, len) memset(start, val, len)
/*
* MemSetTest/MemSetLoop are a variant version that allow all the tests in
*************** typedef NameData *Name;
*** 911,925 ****
MEMSET_LOOP_LIMIT != 0 && \
(val) == 0 )
! #define MemSetLoop(start, val, len) \
! do \
! { \
! long * _start = (long *) (start); \
! long * _stop = (long *) ((char *) _start + (Size) (len)); \
! \
! while (_start < _stop) \
! *_start++ = 0; \
! } while (0)
/*
--- 867,873 ----
MEMSET_LOOP_LIMIT != 0 && \
(val) == 0 )
! #define MemSetLoop(start, val, len) memset(start, val, len)
/*