-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce header arb-defs.h #416
Open
albinahlback
wants to merge
3
commits into
flintlib:master
Choose a base branch
from
albinahlback:arb_defs_header
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
/* | ||
Copyright (C) 2022 Albin Ahlbäck | ||
Copyright (C) 2022 Fredrik Johansson | ||
|
||
This file is part of Arb. | ||
|
||
Arb is free software: you can redistribute it and/or modify it under | ||
the terms of the GNU Lesser General Public License (LGPL) as published | ||
by the Free Software Foundation; either version 2.1 of the License, or | ||
(at your option) any later version. See <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "flint/flint.h" | ||
|
||
#ifndef ARB_DEFS_H | ||
#define ARB_DEFS_H | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#define __ARB_VERSION 2 | ||
#define __ARB_VERSION_MINOR 22 | ||
#define __ARB_VERSION_PATCHLEVEL 1 | ||
|
||
#define ARB_VERSION "2.22.1" | ||
|
||
#define __ARB_RELEASE (__ARB_VERSION * 10000 + \ | ||
__ARB_VERSION_MINOR * 100 + \ | ||
__ARB_VERSION_PATCHLEVEL) | ||
|
||
|
||
#define TLS_PREFIX FLINT_TLS_PREFIX | ||
|
||
#if defined(_MSC_VER) && defined(ARB_BUILD_DLL) | ||
#define ARB_DLL __declspec(dllexport) | ||
#else | ||
#define ARB_DLL FLINT_DLL | ||
#endif | ||
|
||
|
||
#ifndef flint_abort | ||
#if __FLINT_RELEASE <= 20502 | ||
#define flint_abort abort | ||
#endif | ||
#endif | ||
|
||
#if __FLINT_RELEASE < 20600 | ||
#define flint_bitcnt_t ulong | ||
#endif | ||
|
||
|
||
#define LIMB_ONE ((mp_limb_t) 1) | ||
#define LIMB_ONES (-(mp_limb_t) 1) | ||
#define LIMB_TOP (((mp_limb_t) 1) << (FLINT_BITS - 1)) | ||
#define MASK_LIMB(n, c) ((n) & (LIMB_ONES << (c))) | ||
|
||
|
||
/* FLINT_ABS is unsafe for x = WORD_MIN */ | ||
#define UI_ABS_SI(x) (((slong)(x) < 0) ? (-(ulong)(x)) : ((ulong)(x))) | ||
|
||
|
||
#define nn_mul_2x1(r2, r1, r0, a1, a0, b0) \ | ||
do { \ | ||
mp_limb_t t1; \ | ||
umul_ppmm(r1, r0, a0, b0); \ | ||
umul_ppmm(r2, t1, a1, b0); \ | ||
add_ssaaaa(r2, r1, r2, r1, 0, t1); \ | ||
} while (0) | ||
|
||
#define nn_mul_2x2(r3, r2, r1, r0, a1, a0, b1, b0) \ | ||
do { \ | ||
mp_limb_t t1, t2, t3; \ | ||
umul_ppmm(r1, r0, a0, b0); \ | ||
umul_ppmm(r2, t1, a1, b0); \ | ||
add_ssaaaa(r2, r1, r2, r1, 0, t1); \ | ||
umul_ppmm(t1, t2, a0, b1); \ | ||
umul_ppmm(r3, t3, a1, b1); \ | ||
add_ssaaaa(r3, t1, r3, t1, 0, t3); \ | ||
add_ssaaaa(r2, r1, r2, r1, t1, t2); \ | ||
r3 += r2 < t1; \ | ||
} while (0) | ||
|
||
|
||
#ifndef NEWTON_INIT | ||
|
||
#define NEWTON_INIT(from, to) \ | ||
{ \ | ||
slong __steps[FLINT_BITS], __i, __from, __to; \ | ||
__steps[__i = 0] = __to = (to); \ | ||
__from = (from); \ | ||
while (__to > __from) \ | ||
__steps[++__i] = (__to = (__to + 1) / 2); \ | ||
|
||
#define NEWTON_BASECASE(bc_to) { slong bc_to = __to; | ||
|
||
#define NEWTON_END_BASECASE } | ||
|
||
#define NEWTON_LOOP(step_from, step_to) \ | ||
{ \ | ||
for (__i--; __i >= 0; __i--) \ | ||
{ \ | ||
slong step_from = __steps[__i+1]; \ | ||
slong step_to = __steps[__i]; \ | ||
|
||
#define NEWTON_END_LOOP }} | ||
|
||
#define NEWTON_END } | ||
|
||
#endif | ||
|
||
|
||
ARB_DLL extern const char * arb_version; | ||
|
||
double arb_test_multiplier(void); | ||
|
||
/* counts zero bits in the binary representation of e */ | ||
static __inline__ | ||
int | ||
n_zerobits(mp_limb_t e) | ||
{ | ||
#ifdef __GMP_SHORT_LIMB | ||
return FLINT_BITS - __builtin_popcount(e) - __builtin_clz(e); | ||
#else | ||
# ifdef _LONG_LONG_LIMB | ||
return FLINT_BITS - __builtin_popcountll(e) - __builtin_clzll(e); | ||
# else | ||
return FLINT_BITS - __builtin_popcountl(e) - __builtin_clzl(e); | ||
# endif | ||
#endif | ||
} | ||
|
||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I really haven't contributed to this file's content, feel free to remove me here. Also feel free to change the order (I simply did alphabetical order (gissa vem som alltid var högst upp på klasslistan 😉)).