소스 검색

More compat work.

Move syscall to int 0x82 since using int 0x80 was kinda prone to fork bombs
when building things on Linux. :^)
Andreas Kling 6 년 전
부모
커밋
cccc8d8aeb
17개의 변경된 파일81개의 추가작업 그리고 9개의 파일을 삭제
  1. 2 2
      Kernel/Process.cpp
  2. 2 2
      Kernel/Syscall.cpp
  3. 4 4
      Kernel/Syscall.h
  4. 5 0
      LibC/locale.cpp
  5. 2 0
      LibC/locale.h
  6. 17 0
      LibC/stdio.cpp
  7. 3 0
      LibC/stdio.h
  8. 5 0
      LibC/stdlib.cpp
  9. 1 0
      LibC/stdlib.h
  10. 7 0
      LibC/string.cpp
  11. 3 1
      LibC/sys/select.h
  12. 5 0
      LibC/sys/types.h
  13. 1 0
      LibC/sys/wait.h
  14. 12 0
      LibC/termios.cpp
  15. 2 0
      LibC/termios.h
  16. 5 0
      LibC/unistd.cpp
  17. 5 0
      LibC/unistd.h

+ 2 - 2
Kernel/Process.cpp

@@ -886,8 +886,8 @@ ShouldUnblockProcess Process::dispatch_signal(byte signal)
         *code_ptr++ = 0xb8; // mov eax, <dword>
         *(dword*)code_ptr = Syscall::SC_sigreturn;
         code_ptr += sizeof(dword);
-        *code_ptr++ = 0xcd; // int 0x80
-        *code_ptr++ = 0x80;
+        *code_ptr++ = 0xcd; // int 0x82
+        *code_ptr++ = 0x82;
         *code_ptr++ = 0x0f; // ud2
         *code_ptr++ = 0x0b;
 

+ 2 - 2
Kernel/Syscall.cpp

@@ -40,8 +40,8 @@ namespace Syscall {
 
 void initialize()
 {
-    register_user_callable_interrupt_handler(0x80, syscall_trap_handler);
-    kprintf("Syscall: int 0x80 handler installed\n");
+    register_user_callable_interrupt_handler(0x82, syscall_trap_handler);
+    kprintf("Syscall: int 0x82 handler installed\n");
 }
 
 int sync()

+ 4 - 4
Kernel/Syscall.h

@@ -131,7 +131,7 @@ int sync();
 inline dword invoke(Function function)
 {
     dword result;
-    asm volatile("int $0x80":"=a"(result):"a"(function):"memory");
+    asm volatile("int $0x82":"=a"(result):"a"(function):"memory");
     return result;
 }
 
@@ -139,7 +139,7 @@ template<typename T1>
 inline dword invoke(Function function, T1 arg1)
 {
     dword result;
-    asm volatile("int $0x80":"=a"(result):"a"(function),"d"((dword)arg1):"memory");
+    asm volatile("int $0x82":"=a"(result):"a"(function),"d"((dword)arg1):"memory");
     return result;
 }
 
@@ -147,7 +147,7 @@ template<typename T1, typename T2>
 inline dword invoke(Function function, T1 arg1, T2 arg2)
 {
     dword result;
-    asm volatile("int $0x80":"=a"(result):"a"(function),"d"((dword)arg1),"c"((dword)arg2):"memory");
+    asm volatile("int $0x82":"=a"(result):"a"(function),"d"((dword)arg1),"c"((dword)arg2):"memory");
     return result;
 }
 
@@ -155,7 +155,7 @@ template<typename T1, typename T2, typename T3>
 inline dword invoke(Function function, T1 arg1, T2 arg2, T3 arg3)
 {
     dword result;
-    asm volatile("int $0x80":"=a"(result):"a"(function),"d"((dword)arg1),"c"((dword)arg2),"b"((dword)arg3):"memory");
+    asm volatile("int $0x82":"=a"(result):"a"(function),"d"((dword)arg1),"c"((dword)arg2),"b"((dword)arg3):"memory");
     return result;
 }
 #endif

+ 5 - 0
LibC/locale.cpp

@@ -10,4 +10,9 @@ char* setlocale(int category, const char* locale)
     return nullptr;
 }
 
+struct lconv* localeconv()
+{
+    assert(false);
+}
+
 }

+ 2 - 0
LibC/locale.h

@@ -9,9 +9,11 @@ enum {
     LC_NUMERIC,
     LC_CTYPE,
     LC_COLLATE,
+    LC_TIME,
 };
 
 struct lconv {
+    char *decimal_point;
 };
 
 struct lconv* localeconv();

+ 17 - 0
LibC/stdio.cpp

@@ -384,5 +384,22 @@ int rename(const char* oldpath, const char* newpath)
     ASSERT_NOT_REACHED();
 }
 
+char* tmpnam(char*)
+{
+    assert(false);
+}
+
+FILE* popen(const char* command, const char* type)
+{
+    (void)command;
+    (void)type;
+    assert(false);
+}
+
+int pclose(FILE*)
+{
+    assert(false);
+}
+
 }
 

+ 3 - 0
LibC/stdio.h

@@ -83,6 +83,9 @@ void setbuf(FILE*, char* buf);
 void setlinebuf(FILE*);
 int rename(const char* oldpath, const char* newpath);
 FILE* tmpfile();
+char* tmpnam(char*);
+FILE* popen(const char* command, const char* type);
+int pclose(FILE*);
 
 __END_DECLS
 

+ 5 - 0
LibC/stdlib.cpp

@@ -201,6 +201,11 @@ char* getenv(const char* name)
     return nullptr;
 }
 
+int putenv(char*)
+{
+    assert(false);
+}
+
 double atof(const char*)
 {
     assert(false);

+ 1 - 0
LibC/stdlib.h

@@ -14,6 +14,7 @@ __attribute__((malloc)) __attribute__((alloc_size(1, 2))) void* calloc(size_t nm
 void free(void*);
 void* realloc(void *ptr, size_t);
 char* getenv(const char* name);
+int putenv(char*);
 int atoi(const char*);
 long atol(const char*);
 double strtod(const char*, char** endptr);

+ 7 - 0
LibC/string.cpp

@@ -293,5 +293,12 @@ char* strpbrk(const char* s, const char* accept)
     return nullptr;
 }
 
+char *strtok(char* str, const char* delim)
+{
+    (void)str;
+    (void)delim;
+    assert(false);
+}
+
 }
 

+ 3 - 1
LibC/sys/select.h

@@ -12,10 +12,12 @@ __BEGIN_DECLS
 #define FD_SET(fd, set) ((set)->bits[(fd / 8)] |= (1 << (fd) % 8))
 #define FD_ISSET(fd, set) ((set)->bits[(fd / 8)] & (1 << (fd) % 8))
 
-struct fd_set {
+struct __fd_set {
     unsigned char bits[FD_SETSIZE / 8];
 };
 
+typedef struct __fd_set fd_set;
+
 int select(int nfds, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, struct timeval* timeout);
 
 __END_DECLS

+ 5 - 0
LibC/sys/types.h

@@ -55,6 +55,11 @@ struct stat {
     time_t    st_ctime;   /* time of last status change */
 };
 
+struct utimbuf {
+    time_t actime;
+    time_t modtime;
+};
+
 #ifdef __cplusplus
 #define NULL nullptr
 #else

+ 1 - 0
LibC/sys/wait.h

@@ -5,6 +5,7 @@
 
 __BEGIN_DECLS
 
+#define WNOHANG 1
 pid_t wait(int* wstatus);
 
 __END_DECLS

+ 12 - 0
LibC/termios.cpp

@@ -32,5 +32,17 @@ int tcflow(int fd, int action)
     assert(false);
 }
 
+int tcflush(int fd, int queue_selector)
+{
+    (void)fd;
+    (void)queue_selector;
+    assert(false);
+}
+
+speed_t cfgetospeed(const struct termios*)
+{
+    assert(false);
+}
+
 }
 

+ 2 - 0
LibC/termios.h

@@ -9,6 +9,7 @@ __BEGIN_DECLS
 
 typedef uint32_t tcflag_t;
 typedef uint8_t cc_t;
+typedef uint32_t speed_t;
 
 struct termios {
     tcflag_t c_iflag;
@@ -21,6 +22,7 @@ struct termios {
 int tcgetattr(int fd, struct termios*);
 int tcsetattr(int fd, int optional_actions, const struct termios*);
 int tcflow(int fd, int action);
+int tcflush(int fd, int queue_selector);
 
 /* c_cc characters */
 #define VINTR 0

+ 5 - 0
LibC/unistd.cpp

@@ -379,4 +379,9 @@ int release_shared_buffer(int shared_buffer_id)
     __RETURN_WITH_ERRNO(rc, rc, -1);
 }
 
+char* getlogin()
+{
+    assert(false);
+}
+
 }

+ 5 - 0
LibC/unistd.h

@@ -3,10 +3,14 @@
 #include <sys/cdefs.h>
 #include <sys/types.h>
 #include <limits.h>
+#include <errno.h>
 
 __BEGIN_DECLS
 
 #define HZ 1000
+#define STDIN_FILENO 0
+#define STDOUT_FILENO 1
+#define STDERR_FILENO 2
 
 extern char** environ;
 
@@ -68,6 +72,7 @@ int isatty(int fd);
 int mknod(const char* pathname, mode_t, dev_t);
 long fpathconf(int fd, int name);
 long pathconf(const char *path, int name);
+char* getlogin();
 
 enum {
     _PC_NAME_MAX,