summaryrefslogtreecommitdiff
path: root/strings
diff options
context:
space:
mode:
authormonty@mysql.com <>2005-10-06 17:54:43 +0300
committermonty@mysql.com <>2005-10-06 17:54:43 +0300
commit78e828d32f4c94a7135b7ddcf749ddc9e5bd0d3d (patch)
treed92cfa6fa6040c06b41cafe2869f42c993c0ab2b /strings
parentff4a6e139e2a0b8d382dfadeff2cdc06b19c72a7 (diff)
downloadmariadb-git-78e828d32f4c94a7135b7ddcf749ddc9e5bd0d3d.tar.gz
Review of code pushed since last 5.0 pull:
Ensure that ccache is also used for C programs mysql: Ensure that 'delimiter' works the same way in batch mode as in normal mode mysqldump: Change to use ;; (instead of //) as a stored procedure/trigger delimiter Fixed test cases by adding missing DROP's and rename views to be of type 'v#' Removed MY_UNIX_PATH from fn_format() Removed current_db_used from TABLE_LIST Removed usage of 'current_thd' in Item_splocal Removed some compiler warnings A bit faster longlong2str code
Diffstat (limited to 'strings')
-rw-r--r--strings/decimal.c2
-rw-r--r--strings/longlong2str-x86.s141
-rw-r--r--strings/my_strtoll10.c4
3 files changed, 70 insertions, 77 deletions
diff --git a/strings/decimal.c b/strings/decimal.c
index 7816f340eef..b7ad81ab53c 100644
--- a/strings/decimal.c
+++ b/strings/decimal.c
@@ -2018,7 +2018,7 @@ int decimal_mul(decimal_t *from1, decimal_t *from2, decimal_t *to)
if (to->buf < buf1)
{
dec1 *cur_d= to->buf;
- for (; d_to_move; d_to_move--, cur_d++, buf1++)
+ for (; d_to_move--; cur_d++, buf1++)
*cur_d= *buf1;
}
return error;
diff --git a/strings/longlong2str-x86.s b/strings/longlong2str-x86.s
index 1840bab3f47..168dab38a85 100644
--- a/strings/longlong2str-x86.s
+++ b/strings/longlong2str-x86.s
@@ -26,95 +26,88 @@
.type longlong2str_with_dig_vector,@function
longlong2str_with_dig_vector:
- subl $80,%esp
+ subl $80,%esp # Temporary buffer for up to 64 radix-2 digits
pushl %ebp
pushl %esi
pushl %edi
pushl %ebx
- movl 100(%esp),%esi # Lower part of val
- movl 112(%esp),%ebx # Radix
- movl 104(%esp),%ebp # Higher part of val
- movl %ebx,%eax
- movl 108(%esp),%edi # get dst
- testl %eax,%eax
- jge .L144
+ movl 100(%esp),%esi # esi = Lower part of val
+ movl 112(%esp),%ebx # ebx = Radix
+ movl 104(%esp),%ebp # ebp = Higher part of val
+ movl 108(%esp),%edi # edi = dst
- addl $36,%eax
- cmpl $34,%eax
- ja .Lerror # Wrong radix
- testl %ebp,%ebp
- jge .L146
+ testl %ebx,%ebx
+ jge .L144 # Radix was positive
+ negl %ebx # Change radix to positive
+ testl %ebp,%ebp # Test if given value is negative
+ jge .L144
movb $45,(%edi) # Add sign
incl %edi # Change sign of val
negl %esi
adcl $0,%ebp
negl %ebp
-.L146:
- negl %ebx # Change radix to positive
- jmp .L148
- .align 4
-.L144:
- addl $-2,%eax
+
+.L144: # Test that radix is between 2 and 36
+ movl %ebx, %eax
+ addl $-2,%eax # Test that radix is between 2 and 36
cmpl $34,%eax
- ja .Lerror # Radix in range
-
-.L148:
- movl %esi,%eax # Test if zero (for easy loop)
- orl %ebp,%eax
- jne .L150
- movb $48,(%edi)
- incl %edi
- jmp .L10_end
- .align 4
+ ja .Lerror # Radix was not in range
-.L150:
leal 92(%esp),%ecx # End of buffer
movl %edi, 108(%esp) # Store possible modified dest
movl 116(%esp), %edi # dig_vec_upper
- jmp .L155
- .align 4
-
-.L153:
- # val is stored in in ebp:esi
+ testl %ebp,%ebp # Test if value > 0xFFFFFFFF
+ jne .Llongdiv
+ cmpl %ebx, %esi # Test if <= radix, for easy loop
+ movl %esi, %eax # Value in eax (for Llow)
+ jae .Llow
+
+ # Value is one digit (negative or positive)
+ movb (%eax,%edi),%bl
+ movl 108(%esp),%edi # get dst
+ movb %bl,(%edi)
+ incl %edi # End null here
+ jmp .L10_end
- movl %ebp,%eax # High part of value
+.Llongdiv:
+ # Value in ebp:esi. div the high part by the radix,
+ # then div remainder + low part by the radix.
+ movl %ebp,%eax # edx=0,eax=high(from ebp)
xorl %edx,%edx
+ decl %ecx
divl %ebx
- movl %eax,%ebp
+ movl %eax,%ebp # edx=result of last, eax=low(from esi)
movl %esi,%eax
divl %ebx
- decl %ecx
- movl %eax,%esi # quotent in ebp:esi
- movb (%edx,%edi),%al # al is faster than dl
- movb %al,(%ecx) # store value in buff
- .align 4
-.L155:
+ movl %eax,%esi # ebp:esi = quotient
+ movb (%edx,%edi),%dl # Store result number in temporary buffer
testl %ebp,%ebp
- ja .L153
- testl %esi,%esi # rest value
- jl .L153
- je .L160 # Ready
- movl %esi,%eax
+ movb %dl,(%ecx) # store value in buff
+ ja .Llongdiv # (Higher part of val still > 0)
+
.align 4
-
-.L154: # Do rest with integer precision
- cltd
- divl %ebx
+.Llow: # Do rest with integer precision
+ # Value in 0:eax. div 0 + low part by the radix.
+ xorl %edx,%edx
decl %ecx
+ divl %ebx
movb (%edx,%edi),%dl # bh is always zero as ebx=radix < 36
testl %eax,%eax
movb %dl,(%ecx)
- jne .L154
+ jne .Llow
.L160:
movl 108(%esp),%edi # get dst
-
-.L10_mov:
- movl %ecx,%esi
- leal 92(%esp),%ecx # End of buffer
- subl %esi,%ecx
- rep
- movsb
+
+.Lcopy_end:
+ leal 92(%esp),%esi # End of buffer
+.Lmov: # mov temporary buffer to result (%ecx -> %edi)
+ movb (%ecx), %al
+ movb %al, (%edi)
+ incl %ecx
+ incl %edi
+ cmpl %ecx,%esi
+ jne .Lmov
.L10_end:
movl %edi,%eax # Pointer to end null
@@ -166,21 +159,23 @@ longlong10_to_str:
negl %esi # Change sign of val (ebp:esi)
adcl $0,%ebp
negl %ebp
- .align 4
.L10_10:
leal 92(%esp),%ecx # End of buffer
- movl %esi,%eax # Test if zero (for easy loop)
- orl %ebp,%eax
- jne .L10_30 # Not zero
-
- # Here when value is zero
- movb $48,(%edi)
+ testl %ebp,%ebp # Test if value > 0xFFFFFFFF
+ jne .L10_longdiv
+ cmpl $10, %esi # Test if <= radix, for easy loop
+ movl %esi, %ebx # Value in eax (for L10_low)
+ jae .L10_low
+
+ # Value is one digit (negative or positive)
+ addb $48, %bl
+ movb %bl,(%edi)
incl %edi
jmp .L10_end
.align 4
-.L10_20:
+.L10_longdiv:
# val is stored in in ebp:esi
movl %ebp,%eax # High part of value
xorl %edx,%edx
@@ -195,17 +190,15 @@ longlong10_to_str:
.L10_30:
testl %ebp,%ebp
- ja .L10_20
- testl %esi,%esi # rest value
- jl .L10_20 # Unsigned, do ulonglong div once more
- je .L10_mov # Ready
+ ja .L10_longdiv
movl %esi,%ebx # Move val to %ebx
+.L10_low:
# The following code uses some tricks to change division by 10 to
# multiplication and shifts
movl $0xcccccccd,%esi
-.L10_40:
+.L10_40: # Divide %ebx with 10
movl %ebx,%eax
mull %esi
decl %ecx
@@ -218,7 +211,7 @@ longlong10_to_str:
movl %edx,%ebx
testl %ebx,%ebx
jne .L10_40
- jmp .L10_mov # Shared end with longlong10_to_str
+ jmp .Lcopy_end # Shared end with longlong2str
.L10end:
.size longlong10_to_str,.L10end-longlong10_to_str
diff --git a/strings/my_strtoll10.c b/strings/my_strtoll10.c
index 1f4cf1435fe..c1ad9bf1027 100644
--- a/strings/my_strtoll10.c
+++ b/strings/my_strtoll10.c
@@ -21,8 +21,8 @@
#undef ULONGLONG_MAX
/* Needed under MetroWerks Compiler, since MetroWerks compiler does not properly handle a constant expression containing a mod operator */
#if defined(__NETWARE__) && defined(__MWERKS__)
-ulonglong tmp;
-#define ULONGLONG_MAX (tmp =(~(ulonglong) 0))
+static ulonglong ulonglong_max= ~(ulonglong) 0;
+#define ULONGLONG_MAX ulonglong_max
#else
#define ULONGLONG_MAX (~(ulonglong) 0)
#endif /* __NETWARE__ && __MWERKS__ */