Diff for /gforth/prim between versions 1.232 and 1.246

version 1.232, 2008/08/09 13:24:25 version 1.246, 2010/04/05 22:17:56
Line 1 Line 1
 \ Gforth primitives  \ Gforth primitives
   
 \ Copyright (C) 1995,1996,1997,1998,2000,2003,2004,2005,2006,2007,2008 Free Software Foundation, Inc.  \ Copyright (C) 1995,1996,1997,1998,2000,2003,2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc.
   
 \ This file is part of Gforth.  \ This file is part of Gforth.
   
Line 233  SET_IP(DOES_CODE1(CFA)); Line 233  SET_IP(DOES_CODE1(CFA));
 ""just a slot to have an encoding for the DOESJUMP,   ""just a slot to have an encoding for the DOESJUMP, 
 which is no longer used anyway (!! eliminate this)""  which is no longer used anyway (!! eliminate this)""
   
   (doabicode) ( s:... f:... -- s:... f:...)       gforth-internal paren_doabicode
   ""run-time routine for ABI-CODE definitions""
   struct abi_code_ret_t {  
       Cell *sp; 
       double * fp; 
   } ret = ((struct abi_code_ret_t(*)(Cell *, double *))(PFA(CFA)))(sp, fp);
   sp = ret.sp;
   fp = ret.fp;
   #ifdef NO_IP
   INST_TAIL;
   goto *next_code;
   #endif /* defined(NO_IP) */
   
 \F [endif]  \F [endif]
   
 \g control  \g control
Line 625  k ( R:w R:w1 R:w2 R:w3 R:w4 -- w R:w R:w Line 638  k ( R:w R:w1 R:w2 R:w3 R:w4 -- w R:w R:w
   
 \ digit is high-level: 0/0%  \ digit is high-level: 0/0%
   
   abi-call        ( #a_callee s:... f:... -- s:... f:... )        gforth  abi_call
   struct abi_code_ret_t {  
       Cell *sp; 
       double * fp; 
   } ret = ((struct abi_code_ret_t(*)(Cell *, double *))(a_callee))(sp, fp);
   sp = ret.sp;
   fp = ret.fp;
   
 \g strings  \g strings
   
 move    ( c_from c_to ucount -- )               core  move    ( c_from c_to ucount -- )               core
Line 1662  ucols=cols; Line 1683  ucols=cols;
   
 wcwidth ( u -- n )      gforth  wcwidth ( u -- n )      gforth
 ""The number of fixed-width characters per unicode character u""  ""The number of fixed-width characters per unicode character u""
   #ifdef HAVE_WCWIDTH
 n = wcwidth(u);  n = wcwidth(u);
   #else
   n = 1;
   #endif
   
 flush-icache    ( c_addr u -- ) gforth  flush_icache  flush-icache    ( c_addr u -- ) gforth  flush_icache
 ""Make sure that the instruction cache of the processor (if there is  ""Make sure that the instruction cache of the processor (if there is
Line 1674  supported on your machine (take a look a Line 1699  supported on your machine (take a look a
 your machine has a separate instruction cache. In such cases,  your machine has a separate instruction cache. In such cases,
 @code{flush-icache} does nothing instead of flushing the instruction  @code{flush-icache} does nothing instead of flushing the instruction
 cache.""  cache.""
 FLUSH_ICACHE(c_addr,u);  FLUSH_ICACHE((caddr_t)c_addr,u);
   
 (bye)   ( n -- )        gforth  paren_bye  (bye)   ( n -- )        gforth  paren_bye
 SUPER_END;  SUPER_END;
Line 1694  c_addr2 = (Char *)getenv(cstr(c_addr1,u1 Line 1719  c_addr2 = (Char *)getenv(cstr(c_addr1,u1
 u2 = (c_addr2 == NULL ? 0 : strlen((char *)c_addr2));  u2 = (c_addr2 == NULL ? 0 : strlen((char *)c_addr2));
   
 open-pipe       ( c_addr u wfam -- wfileid wior )       gforth  open_pipe  open-pipe       ( c_addr u wfam -- wfileid wior )       gforth  open_pipe
   fflush(stdout);
 wfileid=(Cell)popen(cstr(c_addr,u,1),pfileattr[wfam]); /* ~ expansion of 1st arg? */  wfileid=(Cell)popen(cstr(c_addr,u,1),pfileattr[wfam]); /* ~ expansion of 1st arg? */
 wior = IOR(wfileid==0); /* !! the man page says that errno is not set reliably */  wior = IOR(wfileid==0); /* !! the man page says that errno is not set reliably */
   
Line 1782  gforth_FP=fp; Line 1808  gforth_FP=fp;
 gforth_SP=sp;  gforth_SP=sp;
 gforth_RP=rp;  gforth_RP=rp;
 gforth_LP=lp;  gforth_LP=lp;
   #ifdef HAS_LINKBACK
 ((void (*)())w)();  ((void (*)())w)();
   #else
   ((void (*)(void *))w)(gforth_pointers);
   #endif
 sp=gforth_SP;  sp=gforth_SP;
 fp=gforth_FP;  fp=gforth_FP;
 rp=gforth_RP;  rp=gforth_RP;
Line 1827  wior = IOR(ftruncate(fileno((FILE *)wfil Line 1857  wior = IOR(ftruncate(fileno((FILE *)wfil
 read-file       ( c_addr u1 wfileid -- u2 wior )        file    read_file  read-file       ( c_addr u1 wfileid -- u2 wior )        file    read_file
 /* !! fread does not guarantee enough */  /* !! fread does not guarantee enough */
 u2 = fread(c_addr, sizeof(Char), u1, (FILE *)wfileid);  u2 = fread(c_addr, sizeof(Char), u1, (FILE *)wfileid);
   if (u2>0)
      gf_regetc((FILE *)wfileid);
 wior = FILEIO(u2<u1 && ferror((FILE *)wfileid));  wior = FILEIO(u2<u1 && ferror((FILE *)wfileid));
 /* !! is the value of ferror errno-compatible? */  /* !! is the value of ferror errno-compatible? */
 if (wior)  if (wior)
   clearerr((FILE *)wfileid);    clearerr((FILE *)wfileid);
   
 (read-line)     ( c_addr u1 wfileid -- u2 flag u3 wior ) file   paren_read_line  (read-line)     ( c_addr u1 wfileid -- u2 flag u3 wior ) file   paren_read_line
 struct Cellquad r = read_line(c_addr, u1, wfileid);  struct Cellquad r = read_line(c_addr, u1, (FILE *)wfileid);
 u2   = r.n1;  u2   = r.n1;
 flag = r.n2;  flag = r.n2;
 u3   = r.n3;  u3   = r.n3;
Line 1925  Return an error if this is not possible" Line 1957  Return an error if this is not possible"
 wior = IOR(chdir(tilde_cstr(c_addr, u, 1)));  wior = IOR(chdir(tilde_cstr(c_addr, u, 1)));
   
 get-dir ( c_addr1 u1 -- c_addr2 u2 )    gforth get_dir  get-dir ( c_addr1 u1 -- c_addr2 u2 )    gforth get_dir
 ""Store the current directory in the buffer specified by @{c-addr1, u1}.  ""Store the current directory in the buffer specified by @i{c-addr1, u1}.
 If the buffer size is not sufficient, return 0 0""  If the buffer size is not sufficient, return 0 0""
 c_addr2 = (Char *)getcwd((char *)c_addr1, u1);  c_addr2 = (Char *)getcwd((char *)c_addr1, u1);
 if(c_addr2 != NULL) {  if(c_addr2 != NULL) {
Line 1934  if(c_addr2 != NULL) { Line 1966  if(c_addr2 != NULL) {
   u2 = 0;    u2 = 0;
 }  }
   
   =mkdir ( c_addr u wmode -- wior )        gforth equals_mkdir
   ""Create directory @i{c-addr u} with mode @i{wmode}.""
   wior = IOR(mkdir(tilde_cstr(c_addr,u,1),wmode));
   
 \+  \+
   
 newline ( -- c_addr u ) gforth  newline ( -- c_addr u ) gforth
Line 2137  int flag; Line 2173  int flag;
 int decpt;  int decpt;
 sig=ecvt(r, u, &decpt, &flag);  sig=ecvt(r, u, &decpt, &flag);
 n=(r==0. ? 1 : decpt);  n=(r==0. ? 1 : decpt);
   flag=signbit(r); /* not all ecvt()s do this as desired */
 f1=FLAG(flag!=0);  f1=FLAG(flag!=0);
 f2=FLAG(isdigit((unsigned)(sig[0]))!=0);  f2=FLAG(isdigit((unsigned)(sig[0]))!=0);
 siglen=strlen((char *)sig);  siglen=strlen((char *)sig);
Line 2399  r = fp[u]; Line 2436  r = fp[u];
 \g syslib  \g syslib
   
 open-lib        ( c_addr1 u1 -- u2 )    gforth  open_lib  open-lib        ( c_addr1 u1 -- u2 )    gforth  open_lib
 #if 1  u2 = gforth_dlopen(c_addr1, u1);
 u2 = (UCell)lt_dlopen(tilde_cstr(c_addr1, u1, 1));  
 #elif defined(HAVE_LIBDL) || defined(HAVE_DLOPEN)  
 #ifndef RTLD_GLOBAL  
 #define RTLD_GLOBAL 0  
 #endif  
 u2=(UCell) dlopen(tilde_cstr(c_addr1, u1, 1), RTLD_GLOBAL | RTLD_LAZY);  
 #else  
 #  ifdef _WIN32  
 u2 = (Cell) GetModuleHandle(tilde_cstr(c_addr1, u1, 1));  
 #  else  
 #warning Define open-lib!  
 u2 = 0;  
 #  endif  
 #endif  
   
 lib-sym ( c_addr1 u1 u2 -- u3 ) gforth  lib_sym  lib-sym ( c_addr1 u1 u2 -- u3 ) gforth  lib_sym
 #if 1  #ifdef HAVE_LIBLTDL
 u3 = (UCell) lt_dlsym((lt_dlhandle)u2, cstr(c_addr1, u1, 1));  u3 = (UCell) lt_dlsym((lt_dlhandle)u2, cstr(c_addr1, u1, 1));
 #elif defined(HAVE_LIBDL) || defined(HAVE_DLOPEN)  #elif defined(HAVE_LIBDL) || defined(HAVE_DLOPEN)
 u3 = (UCell) dlsym((void*)u2,cstr(c_addr1, u1, 1));  u3 = (UCell) dlsym((void*)u2,cstr(c_addr1, u1, 1));
Line 2460  l! ( w c_addr -- ) gforth l_store Line 2483  l! ( w c_addr -- ) gforth l_store
   
 lib-error ( -- c_addr u )       gforth  lib_error  lib-error ( -- c_addr u )       gforth  lib_error
 ""Error message for last failed @code{open-lib} or @code{lib-sym}.""  ""Error message for last failed @code{open-lib} or @code{lib-sym}.""
   #ifdef HAVE_LIBLTDL
 c_addr = (Char *)lt_dlerror();  c_addr = (Char *)lt_dlerror();
 u = (c_addr == NULL) ? 0 : strlen((char *)c_addr);  u = (c_addr == NULL) ? 0 : strlen((char *)c_addr);
   #elif defined(HAVE_LIBDL) || defined(HAVE_DLOPEN)
   c_addr = dlerror();
   u = strlen(c_addr);
   #else
   c_addr = "libltdl is not configured";
   u = strlen(c_addr);
   #endif
   
 \+  \+
 \g peephole  \g peephole

Removed from v.1.232  
changed lines
  Added in v.1.246


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>