22| This file contains various utility routines that may be used by gwnum
33| routines, prime95, or other consumers of gwnum.
44|
5- | Copyright 2004-2020 Mersenne Research, Inc. All rights reserved.
5+ | Copyright 2004-2021 Mersenne Research, Inc. All rights reserved.
66+---------------------------------------------------------------------*/
77
88#ifndef _GWUTIL_H
@@ -17,12 +17,12 @@ extern "C" {
1717
1818/* Handy macros to improve readability */
1919
20- #define CONST_LOG2 0.69314718055994530941723212145818
21- #define CONST_ONE_OVER_LOG2 1.4426950408889634073599246810019
22- #define log2 ( n ) (log((double)(n)) * CONST_ONE_OVER_LOG2)
23- #define log2f (n ) (logf((float )(n)) * (float) CONST_ONE_OVER_LOG2)
24- #define logb (n ) (log((double )(n)) / log ((double)(b)) )
25- #define divide_rounding_up (a ,b ) ((a + (b) - 1) / (b))
20+ //These are now included in math.h
21+ // #define CONST_LOG2 0.69314718055994530941723212145818
22+ // #define CONST_ONE_OVER_LOG2 1.4426950408889634073599246810019
23+ // #define log2 (n) (log((double )(n)) * CONST_ONE_OVER_LOG2)
24+ // #define log2f (n) (logf((float )(n)) * (float) CONST_ONE_OVER_LOG2 )
25+ #define divide_rounding_up (a ,b ) (((a) + (b) - 1) / (b))
2626#define divide_rounding_down (a ,b ) ((a) / (b))
2727#define round_up_to_multiple_of (a ,b ) (divide_rounding_up (a, b) * (b))
2828#define round_down_to_multiple_of (a ,b ) (divide_rounding_down (a, b) * (b))
@@ -39,11 +39,7 @@ extern "C" {
3939
4040/* Align a pointer to the given boundary (boundary must be a power of 2) */
4141
42- #ifdef _WIN64
43- #define align_ptr (p ,n ) (void *) (((uint64_t)(p) + (n)-1) & ~((n)-1))
44- #else
45- #define align_ptr (p ,n ) (void *) (((long)(p) + (n)-1) & ~((n)-1))
46- #endif
42+ #define align_ptr (p ,n ) (void *) (((intptr_t)(p) + (n)-1) & ~((n)-1))
4743
4844/* Aligned malloc routines. MSVC 8 supports these in the C runtime library. */
4945/* Emulate these routines for other ports. */
@@ -57,6 +53,9 @@ void aligned_free (void *ptr);
5753int large_pages_supported ();
5854void * large_pages_malloc (size_t size );
5955void large_pages_free (void * ptr );
56+ void * aligned_offset_large_pages_malloc (size_t size , size_t alignment , size_t mod );
57+ void * aligned_large_pages_malloc (size_t size , size_t alignment );
58+ void aligned_large_pages_free (void * ptr );
6059
6160/* Utility string routines */
6261
0 commit comments