Added more functions to msvcrt.
authorEric Kohl <eric.kohl@reactos.org>
Thu, 12 Jul 2001 16:31:03 +0000 (16:31 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Thu, 12 Jul 2001 16:31:03 +0000 (16:31 +0000)
svn path=/trunk/; revision=2055

12 files changed:
reactos/include/msvcrt/locale.h [new file with mode: 0644]
reactos/include/msvcrt/search.h [new file with mode: 0644]
reactos/lib/msvcrt/Makefile
reactos/lib/msvcrt/locale/locale.c [new file with mode: 0644]
reactos/lib/msvcrt/misc/dllmain.c
reactos/lib/msvcrt/msvcrt.def
reactos/lib/msvcrt/process/_cwait.c [new file with mode: 0644]
reactos/lib/msvcrt/process/_system.c [new file with mode: 0644]
reactos/lib/msvcrt/search/lfind.c [new file with mode: 0644]
reactos/lib/msvcrt/search/lsearch.c [new file with mode: 0644]
reactos/lib/msvcrt/setjmp/setjmp.c [new file with mode: 0644]
reactos/lib/msvcrt/time/ctime.c

diff --git a/reactos/include/msvcrt/locale.h b/reactos/include/msvcrt/locale.h
new file mode 100644 (file)
index 0000000..ca7f797
--- /dev/null
@@ -0,0 +1,84 @@
+/* 
+ * locale.h
+ *
+ * Functions and types for localization (ie. changing the appearance of
+ * output based on the standards of a certain country).
+ *
+ * This file is part of the Mingw32 package.
+ *
+ * Contributors:
+ *  Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
+ *
+ *  THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ *  This source code is offered for use in the public domain. You may
+ *  use, modify or distribute it freely.
+ *
+ *  This code is distributed in the hope that it will be useful but
+ *  WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ *  DISCLAMED. This includes but is not limited to warranties of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * $Revision: 1.1 $
+ * $Author: ekohl $
+ * $Date: 2001/07/12 16:25:53 $
+ *
+ */
+
+#ifndef        _LOCALE_H_
+#define        _LOCALE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * NOTE: I have tried to test this, but I am limited by my knowledge of
+ *       locale issues. The structure does not bomb if you look at the
+ *       values, and 'decimal_point' even seems to be correct. But the
+ *       rest of the values are, by default, not particularly useful
+ *       (read meaningless and not related to the international settings
+ *       of the system).
+ */
+
+#define        LC_ALL          0
+#define LC_COLLATE     1
+#define LC_CTYPE       2
+#define        LC_MONETARY     3
+#define        LC_NUMERIC      4
+#define        LC_TIME         5
+
+/*
+ * The structure returned by 'localeconv'.
+ */
+struct lconv
+{
+       char*   decimal_point;
+       char*   thousands_sep;
+       char*   grouping;
+       char*   int_curr_symbol;
+       char*   currency_symbol;
+       char*   mon_decimal_point;
+       char*   mon_thousands_sep;
+       char*   mon_grouping;
+       char*   positive_sign;
+       char*   negative_sign;
+       char    int_frac_digits;
+       char    frac_digits;
+       char    p_cs_precedes;
+       char    p_sep_by_space;
+       char    n_cs_precedes;
+       char    n_sep_by_space;
+       char    p_sign_posn;
+       char    n_sign_posn;
+};
+
+char*          setlocale (int nCategory, const char* locale);
+struct lconv*  localeconv (void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/reactos/include/msvcrt/search.h b/reactos/include/msvcrt/search.h
new file mode 100644 (file)
index 0000000..985e144
--- /dev/null
@@ -0,0 +1,35 @@
+
+#ifndef _SEARCH_H_
+#define _SEARCH_H_
+
+//char    *key
+//void    *data
+
+//enum { FIND, ENTER } ACTION;
+//enum { preorder, postorder, endorder, leaf } VISIT;
+
+#include <msvcrt/stddef.h>
+#include <msvcrt/sys/types.h>
+
+
+//The Single UNIX ® Specification, Version 2 Copyright © 1997 The Open Group 
+
+//int    hcreate(size_t);
+//void   hdestroy(void);
+//ENTRY *hsearch(ENTRY, ACTION);
+//void   insque(void *, void *);
+void  *_lfind(const void *, const void *, size_t *,
+               size_t, int (*)(const void *, const void *));
+void  *_lsearch(const void *, void *, size_t *,
+               size_t, int (*)(const void *, const void *));
+//void   remque(void *);
+//void  *tdelete(const void *, void **,
+//               int(*)(const void *, const void *));
+//void  *tfind(const void *, void *const *,
+//               int(*)(const void *, const void *));
+//void  *tsearch(const void *, void **,
+//               int(*)(const void *, const void *));
+//void   twalk(const void *,
+//             void (*)(const void *, VISIT, int ));
+
+#endif
\ No newline at end of file
index e847932..1b8509d 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.16 2001/07/06 12:53:03 ekohl Exp $
+# $Id: Makefile,v 1.17 2001/07/12 16:31:03 ekohl Exp $
 #
 # ReactOS Operating System
 #
@@ -102,6 +102,9 @@ OBJECTS_IO = \
        io/utime.o \
        io/write.o
 
+OBJECTS_LOCALE = \
+       locale/locale.o
+
 OBJECTS_MATH = \
        math/acos.o \
        math/adjust.o \
@@ -145,13 +148,22 @@ OBJECTS_MISC = \
        misc/tls.o
 
 OBJECTS_PROCESS = \
+       process/_cwait.o \
+       process/_system.o \
        process/dll.o \
        process/procid.o \
        process/thread.o \
        process/threadid.o
+
+OBJECTS_SEARCH = \
+       search/lfind.o \
+       search/lsearch.o
+
+OBJECTS_SETJMP = \
+       setjmp/setjmp.o
        
 OBJECTS_SIGNAL = \
-       signal/signal.o \
+       signal/signal.o
 
 OBJECTS_STDIO = \
        stdio/allocfil.o \
@@ -215,7 +227,6 @@ OBJECTS_STDIO = \
        stdio/vsprintf.o \
        stdio/vsscanf.o
 
-#incomplete
 OBJECTS_STDLIB = \
        stdlib/_exit.o \
        stdlib/abort.o \
@@ -339,9 +350,12 @@ OBJECTS = \
        $(OBJECTS_EXCEPT) \
        $(OBJECTS_FLOAT) \
        $(OBJECTS_IO) \
+       $(OBJECTS_LOCALE) \
        $(OBJECTS_MATH) \
        $(OBJECTS_MISC) \
        $(OBJECTS_PROCESS) \
+       $(OBJECTS_SEARCH) \
+       $(OBJECTS_SETJMP) \
        $(OBJECTS_SIGNAL) \
        $(OBJECTS_STDIO) \
        $(OBJECTS_STDLIB) \
@@ -359,9 +373,12 @@ CLEAN_FILES = \
        except\*.o \
        float\*.o \
        io\*.o \
+       locale\*.o \
        math\*.o \
        misc\*.o \
        process\*.o \
+       search\*.o \
+       setjmp\*.o \
        signal\*.o \
        stdio\*.o \
        stdlib\*.o \
@@ -383,9 +400,12 @@ CLEAN_FILES = \
        except/*.o \
        float/*.o \
        io/*.o \
+       locale/*.o \
        math/*.o \
        misc/*.o \
        process/*.o \
+       search/*.o \
+       setjmp/*.o \
        signal/*.o \
        stdio/*.o \
        stdlib/*.o \
diff --git a/reactos/lib/msvcrt/locale/locale.c b/reactos/lib/msvcrt/locale/locale.c
new file mode 100644 (file)
index 0000000..971c706
--- /dev/null
@@ -0,0 +1,141 @@
+#include <msvcrt/stdio.h>
+#include <msvcrt/locale.h>
+#include <msvcrt/string.h>
+#include <limits.h>
+
+
+int _current_category; /* used by setlocale */
+const char *_current_locale;
+
+int parse_locale(char *locale, char *lang, char *country, char *code_page);
+
+char *setlocale(int category, const char *locale)
+{
+       char lang[100];
+       char country[100];
+       char code_page[100];
+       parse_locale((char *)locale,lang,country,code_page);    
+
+       //printf("%s %s %s %s\n",locale,lang,country,code_page);
+
+
+       switch ( category )
+       {
+               case LC_COLLATE:
+               break;
+               case LC_CTYPE:
+               break;
+               case LC_MONETARY:
+               break;
+               case LC_NUMERIC:
+               break;
+               case LC_TIME:
+               break;
+               case LC_ALL:
+               break;
+               default:
+               break;
+       }
+
+       return "C";
+
+}
+
+/*
+
+locale  "lang[_country[.code_page]]"
+            | ".code_page"
+            | ""
+            | NULL
+            
+*/
+int parse_locale(char *locale, char *lang, char *country, char *code_page)
+{
+       while ( *locale != 0 && *locale != '.' && *locale != '_' )
+       {
+               *lang = *locale;
+               lang++;
+               locale++;
+       }
+       *lang = 0;
+       if ( *locale == '_' ) {
+               locale++;
+               while ( *locale != 0 && *locale != '.' )
+               {
+                       *country = *locale;
+                       country++;
+                       locale++;
+               }
+       }
+       *country = 0;
+       
+       
+       if ( *locale == '.' ) {
+               locale++;
+               while ( *locale != 0 && *locale != '.' )
+               {
+                       *code_page = *locale;
+                       code_page++;
+                       locale++;
+               }
+       }
+       
+       *code_page = 0;
+       return 0;       
+}
+
+const struct map_lcid2str {
+        short            langid;
+        const char      *langname;
+       const char      *country;
+} languages[]={
+        {0x0409,"English", "United States"},
+        {0x0809,"English", "United Kingdom"},
+        {0x0000,"Unknown", "Unknown"}
+    
+};
+
+const struct map_cntr {
+       const char *abrev;
+       const char  *country;
+} abrev[] = {
+       {"britain", "united kingdom"},
+       {"england", "united kingdom"},
+       {"gbr", "united kingdom"},
+       {"great britain", "united kingdom"},
+       {"uk", "united kingdom"},
+       {"united kingdom", "united kingdom"},
+       {"united-kingdom", "united kingdom"},
+       {"america", "united states" },
+       {"united states", "united states"},
+       {"united-states", "united states"},
+       {"us", "united states"},
+       {"usa" "united states"}
+};
+
+
+struct lconv _lconv = {
+".",   // decimal_point
+",",   // thousands_sep
+"",    // grouping;
+"DOL", // int_curr_symbol
+"$",   // currency_symbol
+".",   // mon_decimal_point
+",",   // mon_thousands_sep
+"",    // mon_grouping;
+"+",   // positive_sign
+"-",   // negative_sign
+127,     // int_frac_digits
+127,     // frac_digits
+127,     // p_cs_precedes
+127,     // p_sep_by_space
+127,     // n_cs_precedes
+127,     // n_sep_by_space
+127,     // p_sign_posn;
+127      // n_sign_posn;
+};
+
+struct lconv *localeconv(void)
+{
+  return (struct lconv *) &_lconv;
+}
index c0ea719..63244df 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: dllmain.c,v 1.7 2001/04/10 19:18:59 ekohl Exp $
+/* $Id: dllmain.c,v 1.8 2001/07/12 16:28:24 ekohl Exp $
  * 
  * ReactOS MSVCRT.DLL Compatibility Library
  */
@@ -25,6 +25,8 @@ char *_pgmptr = NULL;         /* pointer to program name */
 
 int __app_type = 0; //_UNKNOWN_APP;    /* application type */
 
+int __mb_cur_max = 1;
+
 static int envAlloced = 0;
 
 
@@ -127,6 +129,11 @@ char ***__p___initenv(void)
    return &__initenv;
 }
 
+int *__p___mb_cur_max(void)
+{
+   return &__mb_cur_max;
+}
+
 unsigned int *__p__osver(void)
 {
    return &_osver;
index da91275..72e03d2 100644 (file)
@@ -1,4 +1,4 @@
-; $Id: msvcrt.def,v 1.12 2001/07/06 21:17:36 ekohl Exp $
+; $Id: msvcrt.def,v 1.13 2001/07/12 16:31:03 ekohl Exp $
 ;
 ; ReactOS MSVCRT Compatibility Library
 ;
@@ -89,8 +89,8 @@ _XcptFilter
 ; __RTDynamicCast
 ; __RTtypeid
 ; __STRINGTOLD
-__argc
-__argv
+__argc DATA
+__argv DATA
 ; __badioinfo
 ; __crtCompareStringA
 ; __crtGetLocaleInfoW
@@ -99,7 +99,7 @@ __dllonexit
 ; __doserrno
 __fpecode
 __getmainargs
-; __initenv
+__initenv DATA
 __isascii
 __iscsym
 __iscsymf
@@ -107,11 +107,11 @@ __iscsymf
 ; __lc_collate_cp
 ; __lc_handle
 ; __lconv_init
-; __mb_cur_max
+__mb_cur_max DATA
 __p___argc
 __p___argv
 __p___initenv
-__p___mb_cur_max
+__p___mb_cur_max
 ; __p___wargv
 ; __p___winitenv
 __p__acmdln
@@ -200,8 +200,8 @@ _cputs
 _creat
 _cscanf
 _ctype DATA
-_cwait
-; _daylight
+_cwait
+_daylight DATA
 ; _dstbias
 _dup
 _dup2
@@ -229,7 +229,7 @@ _fdopen
 _fgetchar
 _fgetwchar
 _filbuf
-; _fileinfo
+; _fileinfo DATA
 _filelength
 _filelengthi64
 _fileno
@@ -324,7 +324,7 @@ _j0
 _j1
 _jn
 _kbhit
-_lfind
+_lfind
 _loaddll
 _local_unwind2
 ; _lock
@@ -333,7 +333,7 @@ _logb
 ; _longjmpex
 _lrotl
 _lrotr
-_lsearch
+_lsearch
 _lseek
 _lseeki64
 _ltoa
@@ -433,7 +433,7 @@ _searchenv
 ; _set_error_mode
 ; _set_sbh_threshold
 _seterrormode
-_setjmp
+_setjmp
 ; _setjmp3
 ; _setmaxstdio
 ; _setmbcp
@@ -476,10 +476,10 @@ _sys_nerr DATA
 _tell
 _telli64
 _tempnam
-; _timezone
+_timezone DATA
 _tolower
 _toupper
-; _tzname
+_tzname DATA
 _tzset
 _ui64toa
 _ui64tow
@@ -662,11 +662,11 @@ isxdigit
 labs
 ldexp
 ldiv
-localeconv
+localeconv
 localtime
 log
 log10
-longjmp
+longjmp
 malloc
 ; mblen
 ; mbstowcs
@@ -695,7 +695,7 @@ rename
 rewind
 scanf
 setbuf
-setlocale
+setlocale
 setvbuf
 signal
 sin
@@ -727,7 +727,7 @@ strtoul
 strxfrm
 swprintf
 swscanf
-system
+system
 tan
 tanh
 time
diff --git a/reactos/lib/msvcrt/process/_cwait.c b/reactos/lib/msvcrt/process/_cwait.c
new file mode 100644 (file)
index 0000000..d1a71ce
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * COPYRIGHT:   See COPYING in the top level directory
+ * PROJECT:     ReactOS system libraries
+ * FILE:        lib/crtdll/process/cwait.c
+ * PURPOSE:     Waits for a process to exit 
+ * PROGRAMER:   Boudewijn Dekker
+ * UPDATE HISTORY:
+ *              04/03/99: Created
+ */
+#include <windows.h>
+#include <msvcrt/process.h>
+#include <msvcrt/errno.h>
+#include <msvcrt/internal/file.h>
+
+int _cwait(int* pnStatus, int hProc, int nAction)
+{
+  DWORD ExitCode;
+
+  nAction = 0;
+  if (WaitForSingleObject((void *)hProc,INFINITE) != WAIT_OBJECT_0)
+    {
+      __set_errno(ECHILD);
+      return -1;
+    }
+
+  if (!GetExitCodeProcess((void *)hProc,&ExitCode))
+    return -1;
+  if (pnStatus != NULL)
+    *pnStatus = (int)ExitCode;
+  return hProc;
+}
diff --git a/reactos/lib/msvcrt/process/_system.c b/reactos/lib/msvcrt/process/_system.c
new file mode 100644 (file)
index 0000000..e09085d
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * COPYRIGHT:   See COPYING in the top level directory
+ * PROJECT:     ReactOS system libraries
+ * FILE:        lib/crtdll/process/system.c
+ * PURPOSE:     Excutes a shell command
+ * PROGRAMER:   Boudewijn Dekker
+ * UPDATE HISTORY:
+ *              04/03/99: Created
+ */
+#include <windows.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/string.h>
+#include <msvcrt/process.h>
+
+int system(const char *command)
+{
+  char szCmdLine[MAX_PATH];
+  char *szComSpec=NULL;
+
+  PROCESS_INFORMATION ProcessInformation;
+  STARTUPINFOA StartupInfo;
+
+  int nStatus;
+
+  szComSpec = getenv("COMSPEC");
+
+// system should return 0 if command is null and the shell is found
+
+  if (command == NULL)
+    {
+      if (szComSpec == NULL)
+       return 0;
+      else
+       return -1;
+    }
+
+// should return 127 or 0 ( MS ) if the shell is not found
+// __set_errno(ENOENT);
+
+  if (szComSpec == NULL)
+    szComSpec = "cmd.exe";
+
+  strcpy(szCmdLine, " /C ");
+
+  strncat(szCmdLine, command, MAX_PATH-5);
+
+//check for a too long argument E2BIG
+
+//command file has invalid format ENOEXEC
+
+
+  StartupInfo.cb = sizeof(STARTUPINFOA);
+  StartupInfo.lpReserved= NULL;
+  StartupInfo.dwFlags = 0;
+  StartupInfo.wShowWindow = SW_SHOWDEFAULT;
+  StartupInfo.lpReserved2 = NULL;
+  StartupInfo.cbReserved2 = 0;
+
+// According to ansi standards the new process should ignore  SIGINT and SIGQUIT
+// In order to disable ctr-c the process is created with CREATE_NEW_PROCESS_GROUP,
+// thus SetConsoleCtrlHandler(NULL,TRUE) is made on behalf of the new process.
+
+
+//SIGCHILD should be blocked aswell
+
+  if (CreateProcessA(szComSpec,szCmdLine,NULL,NULL,TRUE,CREATE_NEW_PROCESS_GROUP,NULL,NULL,&StartupInfo,&ProcessInformation) == FALSE)
+    {
+      return -1;
+    }
+
+// system should wait untill the calling process is finished
+
+  _cwait(&nStatus,(int)ProcessInformation.hProcess,0);
+
+// free the comspec [ if the COMSPEC == NULL provision is removed
+//  free(szComSpec);
+
+  return nStatus;
+}
diff --git a/reactos/lib/msvcrt/search/lfind.c b/reactos/lib/msvcrt/search/lfind.c
new file mode 100644 (file)
index 0000000..6d0a7d8
--- /dev/null
@@ -0,0 +1,18 @@
+#include <msvcrt/search.h>
+#include <msvcrt/stdlib.h>
+
+
+void *_lfind(const void *key, const void *base, size_t *nelp,
+         size_t width, int (*compar)(const void *, const void *))
+{
+  char *char_base = (char *)base;
+  int i;
+
+  for (i=0;i<*nelp;i++)
+    {
+      if (compar(key,char_base) == 0)
+       return char_base;
+      char_base += width;
+    }
+  return NULL;
+}
diff --git a/reactos/lib/msvcrt/search/lsearch.c b/reactos/lib/msvcrt/search/lsearch.c
new file mode 100644 (file)
index 0000000..fe3e767
--- /dev/null
@@ -0,0 +1,16 @@
+#include <msvcrt/search.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/string.h>
+
+void *_lsearch(const void *key, void *base, size_t *nelp, size_t width,
+         int (*compar)(const void *, const void *))
+{
+  void *ret_find = _lfind(key,base,nelp,width,compar);
+
+  if (ret_find != NULL)
+    return ret_find;
+
+  memcpy(base + (*nelp*width), key, width);
+  (*nelp)++;
+  return base;
+}
\ No newline at end of file
diff --git a/reactos/lib/msvcrt/setjmp/setjmp.c b/reactos/lib/msvcrt/setjmp/setjmp.c
new file mode 100644 (file)
index 0000000..65a7050
--- /dev/null
@@ -0,0 +1,137 @@
+/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
+/* modified by Boudewijn Dekker */
+/* ms uses a smaller jmp_buf structure */
+/* might do a realloc in setjmp */
+
+typedef struct {
+  unsigned int __eax, __ebx, __ecx, __edx, __esi;
+  unsigned int __edi, __ebp, __esp, __eip, __eflags;
+  unsigned short __cs, __ds, __es, __fs, __gs, __ss;
+  unsigned long __sigmask; /* for POSIX signals only */
+  unsigned long __signum; /* for expansion */
+  unsigned long __exception_ptr; /* pointer to previous exception */
+  unsigned char __fpu_state[108]; /* for future use */
+} jmp_buf[1];
+
+
+/* jumps back to position specified in jmp_buf */
+
+int longjmp( jmp_buf env, int value )
+{
+  //push ebp             generated by the compiler
+  //mov ebp, esp
+
+  __asm__ __volatile__ (
+       "movl   8(%ebp),%edi\n\t"       /* get jmp_buf */
+       "movl   12(%ebp),%eax\n\t"      /* store retval in j->eax */
+       "movl   %eax,0(%edi)\n\t"
+
+       "movw   46(%edi),%fs\n\t"
+       "movw   48(%edi),%gs\n\t"
+       "movl   4(%edi),%ebx\n\t"
+       "movl   8(%edi),%ecx\n\t"
+       "movl   12(%edi),%edx\n\t"
+       "movl   24(%edi),%ebp\n\t"
+
+       /* Now for some uglyness.  The jmp_buf structure may be ABOVE the
+          point on the new SS:ESP we are moving to.  We don't allow overlap,
+          but do force that it always be valid.  We will use ES:ESI for
+          our new stack before swapping to it.  */
+
+       "movw   50(%edi),%es\n\t"
+       "movl   28(%edi),%esi\n\t"
+       "subl   $28,%esi\n\t"   /* We need 7 working longwords on stack */
+
+       "movl   60(%edi),%eax\n\t"
+       "es\n\t"
+       "movl   %eax,(%esi)\n\t"        /* Exception pointer */
+
+       "movzwl 42(%edi),%eax\n\t"
+       "es\n\t"
+       "movl   %eax,4(%esi)\n\t"       /* DS */
+
+       "movl   20(%edi),%eax\n\t"
+       "es\n\t"
+       "movl   %eax,8(%esi)\n\t"       /* EDI */
+
+       "movl   16(%edi),%eax\n\t"
+       "es\n\t"
+       "movl   %eax,12(%esi)\n\t"      /* ESI */
+
+       "movl   32(%edi),%eax\n\t"
+       "es\n\t"
+       "movl   %eax,16(%esi)\n\t"      /* EIP - start of IRET frame */
+
+       "movl   40(%edi),%eax\n\t"
+       "es\n\t"
+       "movl   %eax,20(%esi)\n\t"      /* CS */
+
+       "movl   36(%edi),%eax\n\t"
+       "es\n\t"
+       "movl   %eax,24(%esi)\n\t"      /* EFLAGS */
+
+       "movl   0(%edi),%eax\n\t"
+       "movw   44(%edi),%es\n\t"
+
+       "movw   50(%edi),%ss\n\t"
+       "movl   %esi,%esp\n\t"
+
+       //"popl ___djgpp_exception_state_ptr\n\t"
+       "popl   %edi\n\t"       // dummy popl instead of djgpp_exception_state_ptr
+       "popl   %ds\n\t"
+       "popl   %edi\n\t"
+       "popl   %esi\n\t"
+
+       "iret\n\t"              /* actually jump to new cs:eip loading flags */
+       );
+
+  return value; // dummy return never reached
+}
+
+
+int _setjmp( jmp_buf env )
+{
+  //push ebp             generated by the compiler
+  //mov ebp, esp
+
+  __asm__ __volatile__ (
+       "pushl  %edi\n\t"
+       "movl   8(%ebp),%edi\n\t"
+
+       "movl   %eax, (%edi)\n\t"
+       "movl   %ebx,4(%edi)\n\t"
+       "movl   %ecx,8(%edi)\n\t"
+       "movl   %edx,12(%edi)\n\t"
+       "movl   %esi,16(%edi)\n\t"
+
+       "movl   -4(%ebp),%eax\n\t"
+       "movl   %eax,20(%edi)\n\t"
+
+       "movl   (%ebp),%eax\n\t"
+       "movl   %eax,24(%edi)\n\t"
+
+       "movl   %esp,%eax\n\t"
+       "addl   $12,%eax\n\t"
+       "movl   %eax,28(%edi)\n\t"
+
+       "movl   4(%ebp),%eax\n\t"
+       "movl   %eax,32(%edi)\n\t"
+
+       "pushfl\n\t"
+       "popl   36(%edi)\n\t"
+
+       "movw   %cs, 40(%edi)\n\t"
+       "movw   %ds, 42(%edi)\n\t"
+       "movw   %es, 44(%edi)\n\t"
+       "movw   %fs, 46(%edi)\n\t"
+       "movw   %gs, 48(%edi)\n\t"
+       "movw   %ss, 50(%edi)\n\t"
+
+       //movl  ___djgpp_exception_state_ptr, %eax
+       //movl  %eax, 60(%edi)
+
+       "popl   %edi\n\t"
+       );
+
+  return 0;
+}
index 40cf9ed..3443012 100644 (file)
@@ -84,8 +84,8 @@ static char sccsid[] = "@(#)ctime.c   5.23 (Berkeley) 6/22/90";
 ** manual page of what this "time zone abbreviation" means (doing this so
 ** that tzname[0] has the "normal" length of three characters).
 */
-int _daylight_dll;
-int _timezone_dll;
+int _daylight;
+int _timezone;
 
 static char WILDABBR[] = "   ";