# Include configuration rules
include MCONFIG
-LIBOBJS = \
- abort.o \
- atexit.o \
- atoi.o \
- atol.o \
- atoll.o \
- calloc.o \
- creat.o \
- ctypes.o \
- errno.o \
- fgetc.o \
- fgets.o \
- fopen.o \
- fprintf.o \
- fputc.o \
- fputs.o \
- fread2.o \
- fread.o \
- free.o \
- fwrite2.o \
- fwrite.o \
- getopt.o \
- lrand48.o \
- malloc.o \
- memccpy.o \
- memchr.o \
- memcmp.o \
- memcpy.o \
- memmem.o \
- memmove.o \
- memset.o \
- memswap.o \
- onexit.o \
- perror.o \
- printf.o \
- puts.o \
- qsort.o \
- realloc.o \
- seed48.o \
- snprintf.o \
- sprintf.o \
- srand48.o \
- sscanf.o \
- stack.o \
- strcasecmp.o \
- strcat.o \
- strchr.o \
- strcmp.o \
- strcpy.o \
- strdup.o \
- strerror.o \
- strlen.o \
- strncasecmp.o \
- strncat.o \
- strncmp.o \
- strncpy.o \
- strndup.o \
- strntoimax.o \
- strntoumax.o \
- strrchr.o \
- strsep.o \
- strspn.o \
- strstr.o \
- strtoimax.o \
- strtok.o \
- strtol.o \
- strtoll.o \
- strtoul.o \
- strtoull.o \
- strtoumax.o \
- vfprintf.o \
- vprintf.o \
- vsnprintf.o \
- vsprintf.o \
- vsscanf.o \
- sys/entry.o sys/exit.o \
- sys/fileinfo.o sys/opendev.o sys/read.o sys/write.o sys/close.o \
- sys/open.o sys/fileread.o sys/fileclose.o \
- sys/isatty.o sys/openconsole.o sys/line_input.o \
- sys/stdcon.o sys/stdcon_write.o sys/stdcon_read.o \
- sys/rawcon.o sys/rawcon_write.o sys/rawcon_read.o
+LIBOBJS = abort.o atexit.o atoi.o atol.o atoll.o calloc.o creat.o \
+ ctypes.o errno.o fgetc.o fgets.o fopen.o fprintf.o fputc.o \
+ fputs.o fread2.o fread.o free.o fwrite2.o fwrite.o getopt.o \
+ lrand48.o malloc.o memccpy.o memchr.o memcmp.o memcpy.o \
+ memmem.o memmove.o memset.o memswap.o onexit.o perror.o \
+ printf.o puts.o qsort.o realloc.o seed48.o snprintf.o \
+ sprintf.o srand48.o sscanf.o stack.o strcasecmp.o strcat.o \
+ strchr.o strcmp.o strcpy.o strdup.o strerror.o strlen.o \
+ strncasecmp.o strncat.o strncmp.o strncpy.o strndup.o \
+ strntoimax.o strntoumax.o strrchr.o strsep.o strspn.o strstr.o \
+ strtoimax.o strtok.o strtol.o strtoll.o strtoul.o strtoull.o \
+ strtoumax.o vfprintf.o vprintf.o vsnprintf.o vsprintf.o \
+ vsscanf.o libgcc/__ashldi3.o libgcc/__udivdi3.o \
+ libgcc/__negdi2.o \
+ libgcc/__ashrdi3.o libgcc/__lshrdi3.o libgcc/__muldi3.o \
+ libgcc/__udivmoddi4.o libgcc/__umoddi3.o libgcc/__divdi3.o \
+ libgcc/__moddi3.o sys/entry.o sys/exit.o sys/fileinfo.o \
+ sys/opendev.o sys/read.o sys/write.o sys/close.o sys/open.o \
+ sys/fileread.o sys/fileclose.o sys/isatty.o sys/openconsole.o \
+ sys/line_input.o sys/stdcon.o sys/stdcon_write.o \
+ sys/stdcon_read.o sys/rawcon.o sys/rawcon_write.o \
+ sys/rawcon_read.o
all: libcom32.a
--- /dev/null
+/*
+ * arch/i386/libgcc/__ashldi3.S
+ *
+ * 64-bit shl
+ */
+ .text
+ .align 4
+ .globl __ashldi3
+ .type __ashldi3,@function
+__ashldi3:
+#ifndef REGPARM
+ movl 4(%esp),%eax
+ movl 8(%esp),%edx
+ movb 12(%esp),%cl
+#endif
+ cmpb $32,%cl
+ jae 1f
+
+ shldl %cl,%eax,%edx
+ shl %cl,%eax
+ ret
+
+1:
+ xorl %edx,%edx
+ shl %cl,%eax
+ xchgl %edx,%eax
+ ret
+
+ .size __ashldi3,.-__ashldi3
--- /dev/null
+/*
+ * arch/i386/libgcc/__ashrdi3.S
+ *
+ * 64-bit sar
+ */
+ .text
+ .align 4
+ .globl __ashrdi3
+ .type __ashrdi3,@function
+__ashrdi3:
+#ifndef REGPARM
+ movl 4(%esp),%eax
+ movl 8(%esp),%edx
+ movb 12(%esp),%cl
+#endif
+ cmpb $32,%cl
+ jae 1f
+
+ shrdl %cl,%edx,%eax
+ sarl %cl,%edx
+ ret
+
+1:
+ sarl %cl,%edx
+ movl %edx,%eax
+ cdq
+ ret
+
+ .size __ashrdi3,.-__ashrdi3
--- /dev/null
+/*
+ * arch/i386/libgcc/__divdi3.c
+ */
+
+#include <stdint.h>
+#include <stddef.h>
+
+extern uint64_t __udivmoddi4(uint64_t num, uint64_t den, uint64_t *rem);
+
+int64_t __divdi3(int64_t num, int64_t den)
+{
+ int minus = 0;
+ int64_t v;
+
+ if ( num < 0 ) {
+ num = -num;
+ minus = 1;
+ }
+ if ( den < 0 ) {
+ den = -den;
+ minus ^= 1;
+ }
+
+ v = __udivmoddi4(num, den, NULL);
+ if ( minus )
+ v = -v;
+
+ return v;
+}
--- /dev/null
+/*
+ * arch/i386/libgcc/__lshrdi3.S
+ *
+ * 64-bit shr
+ */
+ .text
+ .align 4
+ .globl __lshrdi3
+ .type __lshrdi3,@function
+__lshrdi3:
+#ifndef REGPARM
+ movl 4(%esp),%eax
+ movl 8(%esp),%edx
+ movb 12(%esp),%cl
+#endif
+ cmpb $32,%cl
+ jae 1f
+
+ shrdl %cl,%edx,%eax
+ shrl %cl,%edx
+ ret
+
+1:
+ shrl %cl,%edx
+ xorl %eax,%eax
+ xchgl %edx,%eax
+ ret
+
+ .size __lshrdi3,.-__lshrdi3
--- /dev/null
+/*
+ * arch/i386/libgcc/__moddi3.c
+ */
+
+#include <stdint.h>
+#include <stddef.h>
+
+extern uint64_t __udivmoddi4(uint64_t num, uint64_t den, uint64_t *rem);
+
+int64_t __moddi3(int64_t num, int64_t den)
+{
+ int minus = 0;
+ int64_t v;
+
+ if ( num < 0 ) {
+ num = -num;
+ minus = 1;
+ }
+ if ( den < 0 ) {
+ den = -den;
+ minus ^= 1;
+ }
+
+ (void) __udivmoddi4(num, den, &v);
+ if ( minus )
+ v = -v;
+
+ return v;
+}
--- /dev/null
+/*
+ * arch/i386/libgcc/__muldi3.S
+ *
+ * 64*64 = 64 bit unsigned multiplication
+ */
+
+ .text
+ .align 4
+ .globl __muldi3
+ .type __muldi3,@function
+__muldi3:
+ push %esi
+#ifndef REGPARM
+ movl 8(%esp),%eax
+ movl %eax,%esi
+ movl 16(%esp),%ecx
+ mull %ecx
+ imull 12(%esp),%ecx
+ imull 20(%esp),%esi
+ addl %ecx,%edx
+ addl %esi,%edx
+#else
+ movl %eax,%esi
+ push %edx
+ mull %ecx
+ imull 8(%esp),%esi
+ addl %esi,%edx
+ pop %esi
+ imull %esi,%ecx
+ addl %ecx,%edx
+#endif
+ pop %esi
+ ret
+ .size __muldi3,.-__muldi3
--- /dev/null
+/*
+ * arch/i386/libgcc/__negdi2.S
+ *
+ * 64-bit negation
+ */
+
+ .text
+ .align 4
+ .globl __negdi2
+ .type __negdi2,@function
+__negdi2:
+#ifndef REGPARM
+ movl 4(%esp),%eax
+ movl 8(%esp),%edx
+#endif
+ negl %edx
+ negl %eax
+ sbbl $0,%edx
+ ret
+
+ .size __negdi2,.-__negdi2
--- /dev/null
+/*
+ * arch/i386/libgcc/__divdi3.c
+ */
+
+#include <stdint.h>
+#include <stddef.h>
+
+extern uint64_t __udivmoddi4(uint64_t num, uint64_t den, uint64_t *rem);
+
+uint64_t __udivdi3(uint64_t num, uint64_t den)
+{
+ return __udivmoddi4(num, den, NULL);
+}
--- /dev/null
+#include <klibc/diverr.h>
+#include <stdint.h>
+
+uint64_t __udivmoddi4(uint64_t num, uint64_t den, uint64_t *rem_p)
+{
+ uint64_t quot = 0, qbit = 1;
+
+ if ( den == 0 ) {
+ __divide_error();
+ return 0; /* If trap returns... */
+ }
+
+ /* Left-justify denominator and count shift */
+ while ( (int64_t)den >= 0 ) {
+ den <<= 1;
+ qbit <<= 1;
+ }
+
+ while ( qbit ) {
+ if ( den <= num ) {
+ num -= den;
+ quot += qbit;
+ }
+ den >>= 1;
+ qbit >>= 1;
+ }
+
+ if ( rem_p )
+ *rem_p = num;
+
+ return quot;
+}
--- /dev/null
+/*
+ * arch/i386/libgcc/__umoddi3.c
+ */
+
+#include <stdint.h>
+#include <stddef.h>
+
+extern uint64_t __udivmoddi4(uint64_t num, uint64_t den, uint64_t *rem);
+
+uint64_t __umoddi3(uint64_t num, uint64_t den)
+{
+ uint64_t v;
+
+ (void) __udivmoddi4(num, den, &v);
+ return v;
+}