0001-Fix-conflicting-round-function.patch 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. From 39ac7268c4350040976005da98daf10edf676d3e Mon Sep 17 00:00:00 2001
  2. From: Stephan Hoffmann <sho@relinux.de>
  3. Date: Mon, 28 Jan 2013 17:32:10 +0100
  4. Subject: [PATCH] Fix conflicting round() function
  5. calibrator.c defines a local round() function that conflicts
  6. with the one from the standard library.
  7. This is fixed by renaming the local function.
  8. Signed-off-by: Stephan Hoffmann <sho@relinux.de>
  9. ---
  10. calibrator.c | 30 +++++++++++++++---------------
  11. 1 files changed, 15 insertions(+), 15 deletions(-)
  12. diff --git a/calibrator.c b/calibrator.c
  13. index e045dfd..8471c04 100644
  14. --- a/calibrator.c
  15. +++ b/calibrator.c
  16. @@ -128,7 +128,7 @@ void ErrXit(char *format, ...) {
  17. exit(1);
  18. }
  19. -lng round(dbl x)
  20. +lng lng_round(dbl x)
  21. {
  22. return (lng)(x + 0.5);
  23. }
  24. @@ -890,16 +890,16 @@ void plotCache(cacheInfo *cache, lng **result, lng MHz, char *fn, FILE *fp, lng
  25. fprintf(fp, ")\n");
  26. fprintf(fp, "set y2tics");
  27. for (l = 0, s = " ("; l <= cache->levels; l++, s = ", ") {
  28. - if (!delay) fprintf(fp, "%s'(%ld)' %f", s, round(CYperIt(cache->latency1[l] - delay)), NSperIt(cache->latency1[l] - delay));
  29. - else fprintf(fp, "%s'(%ld)' %f", s, round(CYperIt(cache->latency2[l] - delay)), NSperIt(cache->latency2[l] - delay));
  30. + if (!delay) fprintf(fp, "%s'(%ld)' %f", s, lng_round(CYperIt(cache->latency1[l] - delay)), NSperIt(cache->latency1[l] - delay));
  31. + else fprintf(fp, "%s'(%ld)' %f", s, lng_round(CYperIt(cache->latency2[l] - delay)), NSperIt(cache->latency2[l] - delay));
  32. }
  33. for (y = 1; y <= yh; y *= 10) {
  34. fprintf(fp, "%s'%1.3g' %ld", s, (dbl)(y * MHz) / 1000.0, y);
  35. }
  36. fprintf(fp, ")\n");
  37. for (l = 0; l <= cache->levels; l++) {
  38. - if (!delay) z = (dbl)round(CYperIt(cache->latency1[l] - delay)) * 1000.0 / (dbl)MHz;
  39. - else z = (dbl)round(CYperIt(cache->latency2[l] - delay)) * 1000.0 / (dbl)MHz;
  40. + if (!delay) z = (dbl)lng_round(CYperIt(cache->latency1[l] - delay)) * 1000.0 / (dbl)MHz;
  41. + else z = (dbl)lng_round(CYperIt(cache->latency2[l] - delay)) * 1000.0 / (dbl)MHz;
  42. fprintf(fp, "set label %ld '(%1.3g) ' at %f,%f right\n", l + 1, z, xl, z);
  43. fprintf(fp, "set arrow %ld from %f,%f to %f,%f nohead lt 0\n", l + 1, xl, z, xh, z);
  44. }
  45. @@ -986,16 +986,16 @@ void plotTLB(TLBinfo *TLB, lng **result, lng MHz, char *fn, FILE *fp, lng delay)
  46. fprintf(fp, "%s'<L1>' %ld)\n", s, TLB->mincachelines);
  47. fprintf(fp, "set y2tics");
  48. for (l = 0, s = " ("; l <= TLB->levels; l++, s = ", ") {
  49. - if (!delay) fprintf(fp, "%s'(%ld)' %f", s, round(CYperIt(TLB->latency1[l] - delay)), NSperIt(TLB->latency1[l] - delay));
  50. - else fprintf(fp, "%s'(%ld)' %f", s, round(CYperIt(TLB->latency2[l] - delay)), NSperIt(TLB->latency2[l] - delay));
  51. + if (!delay) fprintf(fp, "%s'(%ld)' %f", s, lng_round(CYperIt(TLB->latency1[l] - delay)), NSperIt(TLB->latency1[l] - delay));
  52. + else fprintf(fp, "%s'(%ld)' %f", s, lng_round(CYperIt(TLB->latency2[l] - delay)), NSperIt(TLB->latency2[l] - delay));
  53. }
  54. for (y = 1; y <= yh; y *= 10) {
  55. fprintf(fp, "%s'%1.3g' %ld", s, (dbl)(y * MHz) / 1000.0, y);
  56. }
  57. fprintf(fp, ")\n");
  58. for (l = 0; l <= TLB->levels; l++) {
  59. - if (!delay) z = (dbl)round(CYperIt(TLB->latency1[l] - delay)) * 1000.0 / (dbl)MHz;
  60. - else z = (dbl)round(CYperIt(TLB->latency2[l] - delay)) * 1000.0 / (dbl)MHz;
  61. + if (!delay) z = (dbl)lng_round(CYperIt(TLB->latency1[l] - delay)) * 1000.0 / (dbl)MHz;
  62. + else z = (dbl)lng_round(CYperIt(TLB->latency2[l] - delay)) * 1000.0 / (dbl)MHz;
  63. fprintf(fp, "set label %ld '(%1.3g) ' at %f,%f right\n", l + 1, z, xl, z);
  64. fprintf(fp, "set arrow %ld from %f,%f to %f,%f nohead lt 0\n", l + 1, xl, z, xh, z);
  65. }
  66. @@ -1023,9 +1023,9 @@ void printCPU(cacheInfo *cache, lng MHz, lng delay)
  67. FILE *fp = stdout;
  68. fprintf(fp, "CPU loop + L1 access: ");
  69. - fprintf(fp, " %6.2f ns = %3ld cy\n", NSperIt(cache->latency1[0]), round(CYperIt(cache->latency1[0])));
  70. + fprintf(fp, " %6.2f ns = %3ld cy\n", NSperIt(cache->latency1[0]), lng_round(CYperIt(cache->latency1[0])));
  71. fprintf(fp, " ( delay: ");
  72. - fprintf(fp, " %6.2f ns = %3ld cy )\n", NSperIt(delay), round(CYperIt(delay)));
  73. + fprintf(fp, " %6.2f ns = %3ld cy )\n", NSperIt(delay), lng_round(CYperIt(delay)));
  74. fprintf(fp, "\n");
  75. fflush(fp);
  76. }
  77. @@ -1047,8 +1047,8 @@ void printCache(cacheInfo *cache, lng MHz)
  78. fprintf(fp, " %3ld KB ", cache->size[l] / 1024);
  79. }
  80. fprintf(fp, " %3ld bytes ", cache->linesize[l + 1]);
  81. - fprintf(fp, " %6.2f ns = %3ld cy " , NSperIt(cache->latency2[l + 1] - cache->latency2[l]), round(CYperIt(cache->latency2[l + 1] - cache->latency2[l])));
  82. - fprintf(fp, " %6.2f ns = %3ld cy\n", NSperIt(cache->latency1[l + 1] - cache->latency1[l]), round(CYperIt(cache->latency1[l + 1] - cache->latency1[l])));
  83. + fprintf(fp, " %6.2f ns = %3ld cy " , NSperIt(cache->latency2[l + 1] - cache->latency2[l]), lng_round(CYperIt(cache->latency2[l + 1] - cache->latency2[l])));
  84. + fprintf(fp, " %6.2f ns = %3ld cy\n", NSperIt(cache->latency1[l + 1] - cache->latency1[l]), lng_round(CYperIt(cache->latency1[l + 1] - cache->latency1[l])));
  85. }
  86. fprintf(fp, "\n");
  87. fflush(fp);
  88. @@ -1075,9 +1075,9 @@ void printTLB(TLBinfo *TLB, lng MHz)
  89. } else {
  90. fprintf(fp, " %3ld KB ", TLB->pagesize[l + 1] / 1024);
  91. }
  92. - fprintf(fp, " %6.2f ns = %3ld cy ", NSperIt(TLB->latency2[l + 1] - TLB->latency2[l]), round(CYperIt(TLB->latency2[l + 1] - TLB->latency2[l])));
  93. + fprintf(fp, " %6.2f ns = %3ld cy ", NSperIt(TLB->latency2[l + 1] - TLB->latency2[l]), lng_round(CYperIt(TLB->latency2[l + 1] - TLB->latency2[l])));
  94. /*
  95. - fprintf(fp, " %6.2f ns = %3ld cy" , NSperIt(TLB->latency1[l + 1] - TLB->latency1[l]), round(CYperIt(TLB->latency1[l + 1] - TLB->latency1[l])));
  96. + fprintf(fp, " %6.2f ns = %3ld cy" , NSperIt(TLB->latency1[l + 1] - TLB->latency1[l]), lng_round(CYperIt(TLB->latency1[l + 1] - TLB->latency1[l])));
  97. */
  98. fprintf(fp, "\n");
  99. }
  100. --
  101. 1.7.0.4