Changeset 3866
- Timestamp:
- Jun 26, 2014, 11:52:22 PM (11 years ago)
- Location:
- trunk/libc
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libc/include/386/builtin.h
r3861 r3866 874 874 875 875 876 #ifndef __WATCOMC__ /** @todo port me later. */877 876 878 877 /* Quick routines similar to div() and friends, but inline */ 879 878 879 #ifdef __WATCOMC__ 880 long __ldivmod (long num, long den, long *rem); 881 # pragma aux __ldivmod = \ 882 "cdq" \ 883 "idiv ecx" \ 884 "mov [ebx], edx" \ 885 parm [eax] [ecx] [ebx] value [eax] 886 #else 880 887 static __inline__ long __ldivmod (long num, long den, long *rem) 881 888 { 889 # ifdef _MSC_VER /* No intrisic idiv, but this will be /O2'ed into the gcc code. */ 890 *rem = num % den; 891 return num / den; 892 # else 882 893 long q, r; 883 894 __asm__ ("cltd; idivl %2" … … 886 897 *rem = r; 887 898 return q; 888 } 889 899 # endif 900 } 901 #endif 902 903 #ifdef __WATCOMC__ 904 unsigned __uldivmod (unsigned long num, unsigned long den, unsigned long *rem); 905 # pragma aux __uldivmod = \ 906 "xor edx, edx" \ 907 "div ecx" \ 908 "mov [ebx], edx" \ 909 parm [eax] [ecx] [ebx] value [eax] 910 #else 890 911 static __inline__ unsigned long __uldivmod (unsigned long num, 891 912 unsigned long den, unsigned long *rem) 892 913 { 914 # ifdef _MSC_VER /* No intrisic div, but this will be /O2'ed into the gcc code. */ 915 *rem = num % den; 916 return num / den; 917 # else 893 918 unsigned long q, r; 894 919 __asm__ ("xorl %%edx,%%edx; divl %2" … … 897 922 *rem = r; 898 923 return q; 899 } 924 #endif 925 } 926 #endif 900 927 901 928 /* … … 908 935 static __inline__ long long __lldivmod (long long num, long den, long *rem) 909 936 { 937 #if !defined(__GNUC__) 938 /* Not bothering with doing this as inline for now. */ 939 *rem = num % den; 940 return num / den; 941 #else 910 942 long long q; 911 943 long r; … … 981 1013 *rem = r; 982 1014 return q; 1015 #endif 983 1016 } 984 1017 … … 987 1020 instead of two because the result is always a 32-bit integer. 988 1021 */ 1022 #ifdef __WATCOMC__ 1023 unsigned long long __ulldivmod (unsigned long long num, unsigned long den, unsigned long *rem); 1024 # pragma aux __ulldivmod = \ 1025 "xor edx, edx" \ 1026 "div ebx" \ 1027 "xchg esi, eax" \ 1028 "div ebx" \ 1029 "mov [ecx], edx" \ 1030 "mov edx, esi" \ 1031 parm [esi eax] [ebx] [ecx] value [eax edx] modify exact [esi eax edx] 1032 #else 989 1033 static __inline__ unsigned long long __ulldivmod (unsigned long long num, 990 1034 unsigned long den, unsigned long *rem) 991 1035 { 1036 # ifdef _MSC_VER 1037 unsigned long long q; 1038 __asm { 1039 mov ecx, [den] 1040 mov eax, dword ptr [num + 4] 1041 xor edx, edx 1042 DIV ecx ; capitalized DIV because of _STD(div). 1043 mov dword ptr [q + 4], eax 1044 mov eax, dword ptr [num] 1045 DIV ecx 1046 mov dword ptr [q], eax 1047 mov ecx, [rem] 1048 mov [ecx], edx 1049 }; 1050 return q; 1051 # else 992 1052 unsigned long long q; 993 1053 unsigned long r; … … 1003 1063 *rem = r; 1004 1064 return q; 1005 } 1006 1007 #endif /* ! __WATCOM__ */1065 # endif 1066 } 1067 #endif 1008 1068 1009 1069 __END_DECLS -
trunk/libc/src/libc/conv/Makefile.kmk
r3845 r3866 65 65 $(PATH_LIBC_SRC)/libc/conv/ulltoa.c \ 66 66 $(PATH_LIBC_SRC)/libc/conv/ultoa.c \ 67 $(PATH_LIBC_SRC)/libc/conv/__digits.c \67 $(PATH_LIBC_SRC)/libc/conv/__digits.c 68 68 69 libc_libc_conv_SOURCES.x86 = \ 69 if defined(CFG_LIBC_USE_WATCOM) || "$(KBUILD_TARGET)" != "os2" 70 libc_libc_conv_SOURCES += \ 71 $(PATH_LIBC_SRC)/libc/conv/c/biaddbb.c \ 72 $(PATH_LIBC_SRC)/libc/conv/c/bidivbw.c \ 73 $(PATH_LIBC_SRC)/libc/conv/c/bidivhlp.c \ 74 $(PATH_LIBC_SRC)/libc/conv/c/bimulbb.c \ 75 $(PATH_LIBC_SRC)/libc/conv/c/bimulbw.c \ 76 $(PATH_LIBC_SRC)/libc/conv/c/bisubmbw.c 77 else 78 ## @todo convert to nasm. 79 libc_libc_conv_SOURCES.x86 = \ 70 80 $(PATH_LIBC_SRC)/libc/conv/386/biaddbb.s \ 71 81 $(PATH_LIBC_SRC)/libc/conv/386/bidivbw.s \ … … 73 83 $(PATH_LIBC_SRC)/libc/conv/386/bimulbb.s \ 74 84 $(PATH_LIBC_SRC)/libc/conv/386/bimulbw.s \ 75 $(PATH_LIBC_SRC)/libc/conv/386/bisubmbw.s \ 85 $(PATH_LIBC_SRC)/libc/conv/386/bisubmbw.s 86 endif 76 87 77 88 $(PATH_LIBC_SRC)/libc/conv/bipow5.c_DEPS = $(PATH_TARGET)/bipow5.tab -
trunk/libc/src/libc/conv/lltoa.c
r494 r3866 19 19 char digits[64]; 20 20 unsigned long long x; 21 unsigned long rem; 21 22 int i; 22 long rem;23 23 24 24 dst = string;
Note:
See TracChangeset
for help on using the changeset viewer.