History

Delete a = (a > = 0)? A: -a; \

jiang committed 12 years ago

Commit 3d608d41 parent 01991232 files · +40 −26Browse files

Unified · Split

2 files
  1. lib/libtcc1.c +24 −21
  2. tests/tcctest.c +16 −5
lib/libtcc1.c+24−21
@@ -533,21 +533,22 @@ unsigned long long __fixunssfdi (float a1) · 532 unmodified lines
533533 register union float_long fl1;
534534 register int exp;
535535 register unsigned long l;
536−
536+ int s;
537537 fl1.f = a1;
538538
539539 if (fl1.l == 0)
540− return (0);
540+ return 0;
541541
542542 exp = EXP (fl1.l) - EXCESS - 24;
543543
544544 l = MANT(fl1.l);
545− if (exp >= 41)
546− return (unsigned long long)-1;
545+ s = SIGN(fl1.l)? -1: 1;
546+ if (exp >= 64)
547+ return (unsigned long long)-1;
547548 else if (exp >= 0)
548− return (unsigned long long)l << exp;
549+ return ((unsigned long long)l << exp)*s;
549550 else if (exp >= -23)
550− return l >> -exp;
551+ return (l >> -exp)*s;
551552 else
552553 return 0;
553554 }
@@ -557,22 +558,22 @@ unsigned long long __fixunsdfdi (double a1) · 3 unmodified lines
557558 register union double_long dl1;
558559 register int exp;
559560 register unsigned long long l;
560−
561+ int s;
561562 dl1.d = a1;
562563
563564 if (dl1.ll == 0)
564− return (0);
565+ return (0);
565566
566567 exp = EXPD (dl1) - EXCESSD - 53;
567568
568569 l = MANTD_LL(dl1);
569−
570− if (exp >= 12)
571− return (unsigned long long)-1;
570+ s = SIGND(dl1)? -1: 1;
571+ if (exp >= 64)
572+ return (unsigned long long)-1;
572573 else if (exp >= 0)
573− return l << exp;
574+ return (l << exp)*s;
574575 else if (exp >= -52)
575− return l >> -exp;
576+ return (l >> -exp)*s;
576577 else
577578 return 0;
578579 }
@@ -582,20 +583,22 @@ unsigned long long __fixunsxfdi (long double a1) · 3 unmodified lines
582583 register union ldouble_long dl1;
583584 register int exp;
584585 register unsigned long long l;
585−
586+ int s;
586587 dl1.ld = a1;
587588
588589 if (dl1.l.lower == 0 && dl1.l.upper == 0)
589− return (0);
590+ return (0);
590591
591592 exp = EXPLD (dl1) - EXCESSLD - 64;
592−
593+ s = SIGNLD(dl1)? -1: 1;
593594 l = dl1.l.lower;
594595
595− if (exp > 0)
596− return (unsigned long long)-1;
597− else if (exp >= -63)
598− return l >> -exp;
596+ if (exp >= 64)
597+ return (unsigned long long)-1;
598+ else if (exp >= 0)
599+ return ((unsigned long long)l << exp)*s;
600+ else if (exp >= -64)
601+ return (l >> -exp)*s;
599602 else
600603 return 0;
601604 }
@@ -637,7 +640,7 @@ extern void abort(void); · 35 unmodified lines
637640 #endif
638641
639642 enum __va_arg_type {
640− __va_gen_reg, __va_float_reg, __va_stack
643+ __va_gen_reg, __va_float_reg, __va_ld_reg, __va_stack
641644 };
642645
643646 //This should be in sync with the declaration on our include/stdarg.h
tests/tcctest.c+16−5
@@ -1729,7 +1729,6 @@ void prefix ## fcast(type a)\ · 1728 unmodified lines
17291729 printf("ftof: %f %f %Lf\n", fa, da, la);\
17301730 ia = (int)a;\
17311731 llia = (long long)a;\
1732− a = (a >= 0) ? a : -a;\
17331732 ua = (unsigned int)a;\
17341733 llua = (unsigned long long)a;\
17351734 printf("ftoi: %d %u %lld %llu\n", ia, ua, llia, llua);\
@@ -1759,6 +1758,18 @@ void prefix ## call(void)\ · 23 unmodified lines
17591758 printf("strto%s: %f\n", #prefix, (double)strto ## prefix("1.2", NULL));\
17601759 }\
17611760 \
1761+void prefix ## calc(type x, type y)\
1762+{\
1763+ x=x*x;y=y*y;\
1764+ printf("%d, %d\n", (int)x, (int)y);\
1765+ x=x-y;y=y-x;\
1766+ printf("%d, %d\n", (int)x, (int)y);\
1767+ x=x/y;y=y/x;\
1768+ printf("%d, %d\n", (int)x, (int)y);\
1769+ x=x+x;y=y+y;\
1770+ printf("%d, %d\n", (int)x, (int)y);\
1771+}\
1772+\
17621773 void prefix ## signed_zeros(void) \
17631774 {\
17641775 type x = 0.0, y = -0.0, n, p;\
@@ -1781,7 +1792,7 @@ void prefix ## signed_zeros(void) \ · 16 unmodified lines
17811792 1.0 / x != 1.0 / p);\
17821793 else\
17831794 printf ("x != +y; this is wrong!\n");\
1784− p = -y;\
1795+ p = -y;\
17851796 if (x == p)\
17861797 printf ("Test 1.0 / x != 1.0 / -y returns %d (should be 0).\n",\
17871798 1.0 / x != 1.0 / p);\
@@ -1797,6 +1808,7 @@ void prefix ## test(void)\ · 9 unmodified lines
17971808 prefix ## fcast(234.6);\
17981809 prefix ## fcast(-2334.6);\
17991810 prefix ## call();\
1811+ prefix ## calc(1, 1.0000000000000001);\
18001812 prefix ## signed_zeros();\
18011813 }
18021814
@@ -2623,7 +2635,6 @@ int constant_p_var; · 820 unmodified lines
26232635
26242636 void builtin_test(void)
26252637 {
2626−#if GCC_MAJOR >= 3
26272638 COMPAT_TYPE(int, int);
26282639 COMPAT_TYPE(int, unsigned int);
26292640 COMPAT_TYPE(int, char);
@@ -2633,9 +2644,9 @@ void builtin_test(void) · 3 unmodified lines
26332644 COMPAT_TYPE(int *, void *);
26342645 COMPAT_TYPE(int *, const int *);
26352646 COMPAT_TYPE(char *, unsigned char *);
2647+ COMPAT_TYPE(char, unsigned char);
26362648 /* space is needed because tcc preprocessor introduces a space between each token */
2637− COMPAT_TYPE(char * *, void *);
2638−#endif
2649+ COMPAT_TYPE(char **, void *);
26392650 printf("res = %d\n", __builtin_constant_p(1));
26402651 printf("res = %d\n", __builtin_constant_p(1 + 2));
26412652 printf("res = %d\n", __builtin_constant_p(&constant_p_var));

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t