Bugzilla – Attachment 56161 Details for
Bug 131700
ntpdate prints garbage as time offset
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
IDP Log In
|
Forgot Password
testcase - -O1 or higher exposes the bug, -O0 works fine
ntp.c (text/plain), 1.56 KB, created by
Dirk Mueller
on 2005-11-01 17:59:29 UTC
(
hide
)
Description:
testcase - -O1 or higher exposes the bug, -O0 works fine
Filename:
MIME Type:
Creator:
Dirk Mueller
Created:
2005-11-01 17:59:29 UTC
Size:
1.56 KB
patch
obsolete
>#include <assert.h> >#include <stdio.h> > >typedef unsigned int u_int32; > >typedef struct { > union { > u_int32 Xl_ui; > } Ul_i; > union { > u_int32 Xl_uf; > } Ul_f; >} l_fp; > >#define l_ui Ul_i.Xl_ui >#define l_uf Ul_f.Xl_uf > >#define M_LSHIFT(v_i, v_f) /* v <<= 1 */ \ > do { \ > (v_i) <<= 1; \ > if ((v_f) & 0x80000000) \ > (v_i) |= 0x1; \ > (v_f) <<= 1; \ > } while (0) > >#define M_ADD(r_i, r_f, a_i, a_f) /* r += a */ \ > do { \ > u_int32 lo_tmp; \ > u_int32 hi_tmp; \ > \ > lo_tmp = ((r_f) & 0xffff) + ((a_f) & 0xffff); \ > hi_tmp = (((r_f) >> 16) & 0xffff) + (((a_f) >> 16) & 0xffff); \ > if (lo_tmp & 0x10000) \ > hi_tmp++; \ > (r_f) = ((hi_tmp & 0xffff) << 16) | (lo_tmp & 0xffff); \ > \ > (r_i) += (a_i); \ > if (hi_tmp & 0x10000) \ > (r_i)++; \ > } while (0) > > >void dolfptoa(short ndec) >{ > l_fp work; > > work.l_ui = 0; > work.l_uf = 0x535f3d8; > while (ndec > 0) { > l_fp ftmp; > > ndec--; > work.l_ui = 0; > M_LSHIFT(work.l_ui, work.l_uf); > printf("%d\t", work.l_ui); > ftmp = work; > M_LSHIFT(work.l_ui, work.l_uf); > M_LSHIFT(work.l_ui, work.l_uf); > printf("%d\t", work.l_ui); > M_ADD(work.l_ui, work.l_uf, ftmp.l_ui, ftmp.l_uf); > printf("%d\n", work.l_ui); > assert(work.l_ui < 10); > } >} > >int main() >{ > dolfptoa(6); > > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
Attachments on
bug 131700
: 56161