Skip to content

Commit

Permalink
fix: avoid limits.h
Browse files Browse the repository at this point in the history
  • Loading branch information
hannes14 committed Nov 15, 2011
1 parent 4e855a7 commit a2cdd62
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Singular/walk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#include <unistd.h>
#include <stdio.h>
#include <float.h>
#include <limits.h>
#include <misc/mylimits.h>
#include <sys/types.h>


Expand Down
4 changes: 2 additions & 2 deletions kernel/semic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ int spectrum::mult_spectrum( spectrum &t )
Rational alpha1 = -2;
Rational alpha2 = -1;

int mult=INT_MAX,nthis,nt;
int mult=MAX_INT_VAL,nthis,nt;

while( u.next_interval( &alpha1,&alpha2 ) )
{
Expand Down Expand Up @@ -441,7 +441,7 @@ int spectrum::mult_spectrumh( spectrum &t )
Rational alpha1 = -2;
Rational alpha2 = -1;

int mult=INT_MAX,nthis,nt;
int mult=MAX_INT_VAL,nthis,nt;

while( u.next_interval( &alpha1,&alpha2 ) )
{
Expand Down
2 changes: 1 addition & 1 deletion libpolys/coeffs/ffields.cc
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ static const char* nfEati(const char *s, int *i, const coeffs r)
{
*i *= 10;
*i += *s++ - '0';
if (*i > (INT_MAX / 10)) *i = *i % r->m_nfCharP;
if (*i > (MAX_INT_VAL / 10)) *i = *i % r->m_nfCharP;
}
while (*s >= '0' && *s <= '9');
if (*i >= r->m_nfCharP) *i = *i % r->m_nfCharP;
Expand Down
2 changes: 1 addition & 1 deletion libpolys/coeffs/shortfl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ int nrInt(number &n, const coeffs r)

int i;
float f = nf(n).F();
if (((float)INT_MIN <= f) || ((float)INT_MAX >= f))
if (((float)(-MAX_INT_VAL-1) <= f) || ((float)MAX_INT_VAL >= f))
i = (int)f;
else
i = 0;
Expand Down
10 changes: 8 additions & 2 deletions libpolys/misc/mylimits.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@
#ifndef _MYLIMITS_H
#define _MYLIMITS_H

#include <limits.h>
static const int MAX_INT_VAL = 2147483647;

static const int MAX_INT_VAL = INT_MAX;
#define ULONG_MAX (~0L)

#if ~0UL == 4294967295UL
#define LONG_MAX 9223372036854775807L
#else
#define LONG_MAX 2147483647L
#endif

#endif /* _MYLIMITS_H */
2 changes: 1 addition & 1 deletion libpolys/polys/matpol.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static poly mp_Select (poly fro, poly what, const ring);
matrix mpNew(int r, int c)
{
if (r<=0) r=1;
if ( (((int)(INT_MAX/sizeof(poly))) / r) <= c)
if ( (((int)(MAX_INT_VAL/sizeof(poly))) / r) <= c)
{
Werror("internal error: creating matrix[%d][%d]",r,c);
return NULL;
Expand Down
2 changes: 1 addition & 1 deletion libpolys/polys/monomials/ring.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3803,7 +3803,7 @@ void rUnComplete(ring r)
// set r->VarL_Size, r->VarL_Offset, r->VarL_LowIndex
static void rSetVarL(ring r)
{
int min = INT_MAX, min_j = -1;
int min = MAX_INT_VAL, min_j = -1;
int* VarL_Number = (int*) omAlloc0(r->ExpL_Size*sizeof(int));

int i,j;
Expand Down

0 comments on commit a2cdd62

Please sign in to comment.