mirror of
https://github.com/neovim/neovim.git
synced 2025-09-18 17:28:23 +00:00
os: remove legacy mch_libcall
Remove as much leftover cruft as possible. Tried to see which globals are now not used anymore.
This commit is contained in:

committed by
Justin M. Keyes

parent
99163c9f13
commit
bbb649ac69
@@ -599,19 +599,6 @@ EXTERN int orig_line_count INIT(= 0); /* Line count when "gR" started */
|
||||
EXTERN int vr_lines_changed INIT(= 0); /* #Lines changed by "gR" so far */
|
||||
|
||||
|
||||
/*
|
||||
* Stuff for setjmp() and longjmp().
|
||||
* Used to protect areas where we could crash.
|
||||
*/
|
||||
EXTERN JMP_BUF lc_jump_env; /* argument to SETJMP() */
|
||||
# ifdef SIGHASARG
|
||||
/* volatile because it is used in signal handlers. */
|
||||
EXTERN volatile int lc_signal; /* caught signal number, 0 when no was signal
|
||||
caught; used for mch_libcall() */
|
||||
# endif
|
||||
/* volatile because it is used in signal handler deathtrap(). */
|
||||
EXTERN volatile int lc_active INIT(= FALSE); /* TRUE when lc_jump_env is valid. */
|
||||
|
||||
/*
|
||||
* These flags are set based upon 'fileencoding'.
|
||||
* Note that "enc_utf8" is also set for "unicode", because the characters are
|
||||
|
@@ -101,36 +101,6 @@ void mch_write(char_u *s, int len)
|
||||
os_microdelay(p_wd, false);
|
||||
}
|
||||
|
||||
/*
|
||||
* A simplistic version of setjmp() that only allows one level of using.
|
||||
* Don't call twice before calling mch_endjmp()!.
|
||||
* Usage:
|
||||
* mch_startjmp();
|
||||
* if (SETJMP(lc_jump_env) != 0)
|
||||
* {
|
||||
* mch_didjmp();
|
||||
* EMSG("crash!");
|
||||
* }
|
||||
* else
|
||||
* {
|
||||
* do_the_work;
|
||||
* mch_endjmp();
|
||||
* }
|
||||
* Note: Can't move SETJMP() here, because a function calling setjmp() must
|
||||
* not return before the saved environment is used.
|
||||
* Returns OK for normal return, FAIL when the protected code caused a
|
||||
* problem and LONGJMP() was used.
|
||||
*/
|
||||
void mch_startjmp()
|
||||
{
|
||||
lc_active = TRUE;
|
||||
}
|
||||
|
||||
void mch_endjmp()
|
||||
{
|
||||
lc_active = FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* If the machine has job control, use it to suspend the program,
|
||||
* otherwise fake it by starting a new shell.
|
||||
@@ -1490,158 +1460,3 @@ static int have_dollars(int num, char_u **file)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#if defined(FEAT_LIBCALL) || defined(PROTO)
|
||||
typedef char_u * (*STRPROCSTR)(char_u *);
|
||||
typedef char_u * (*INTPROCSTR)(int);
|
||||
typedef int (*STRPROCINT)(char_u *);
|
||||
typedef int (*INTPROCINT)(int);
|
||||
|
||||
/*
|
||||
* Call a DLL routine which takes either a string or int param
|
||||
* and returns an allocated string.
|
||||
*/
|
||||
int mch_libcall(char_u *libname,
|
||||
char_u *funcname,
|
||||
char_u *argstring, /* NULL when using an argint */
|
||||
int argint,
|
||||
char_u **string_result, /* NULL when using number_result */
|
||||
int *number_result)
|
||||
{
|
||||
# if defined(USE_DLOPEN)
|
||||
void *hinstLib;
|
||||
char *dlerr = NULL;
|
||||
# else
|
||||
shl_t hinstLib;
|
||||
# endif
|
||||
STRPROCSTR ProcAdd;
|
||||
INTPROCSTR ProcAddI;
|
||||
char_u *retval_str = NULL;
|
||||
int retval_int = 0;
|
||||
int success = FALSE;
|
||||
|
||||
/*
|
||||
* Get a handle to the DLL module.
|
||||
*/
|
||||
# if defined(USE_DLOPEN)
|
||||
/* First clear any error, it's not cleared by the dlopen() call. */
|
||||
(void)dlerror();
|
||||
|
||||
hinstLib = dlopen((char *)libname, RTLD_LAZY
|
||||
# ifdef RTLD_LOCAL
|
||||
| RTLD_LOCAL
|
||||
# endif
|
||||
);
|
||||
if (hinstLib == NULL) {
|
||||
/* "dlerr" must be used before dlclose() */
|
||||
dlerr = (char *)dlerror();
|
||||
if (dlerr != NULL)
|
||||
EMSG2(_("dlerror = \"%s\""), dlerr);
|
||||
}
|
||||
# else
|
||||
hinstLib = shl_load((const char*)libname, BIND_IMMEDIATE|BIND_VERBOSE, 0L);
|
||||
# endif
|
||||
|
||||
/* If the handle is valid, try to get the function address. */
|
||||
if (hinstLib != NULL) {
|
||||
/*
|
||||
* Catch a crash when calling the library function. For example when
|
||||
* using a number where a string pointer is expected.
|
||||
*/
|
||||
mch_startjmp();
|
||||
if (SETJMP(lc_jump_env) != 0) {
|
||||
success = FALSE;
|
||||
# if defined(USE_DLOPEN)
|
||||
dlerr = NULL;
|
||||
# endif
|
||||
} else
|
||||
{
|
||||
retval_str = NULL;
|
||||
retval_int = 0;
|
||||
|
||||
if (argstring != NULL) {
|
||||
# if defined(USE_DLOPEN)
|
||||
ProcAdd = (STRPROCSTR)dlsym(hinstLib, (const char *)funcname);
|
||||
dlerr = (char *)dlerror();
|
||||
# else
|
||||
if (shl_findsym(&hinstLib, (const char *)funcname,
|
||||
TYPE_PROCEDURE, (void *)&ProcAdd) < 0)
|
||||
ProcAdd = NULL;
|
||||
# endif
|
||||
if ((success = (ProcAdd != NULL
|
||||
# if defined(USE_DLOPEN)
|
||||
&& dlerr == NULL
|
||||
# endif
|
||||
))) {
|
||||
if (string_result == NULL)
|
||||
retval_int = ((STRPROCINT)ProcAdd)(argstring);
|
||||
else
|
||||
retval_str = (ProcAdd)(argstring);
|
||||
}
|
||||
} else {
|
||||
# if defined(USE_DLOPEN)
|
||||
ProcAddI = (INTPROCSTR)dlsym(hinstLib, (const char *)funcname);
|
||||
dlerr = (char *)dlerror();
|
||||
# else
|
||||
if (shl_findsym(&hinstLib, (const char *)funcname,
|
||||
TYPE_PROCEDURE, (void *)&ProcAddI) < 0)
|
||||
ProcAddI = NULL;
|
||||
# endif
|
||||
if ((success = (ProcAddI != NULL
|
||||
# if defined(USE_DLOPEN)
|
||||
&& dlerr == NULL
|
||||
# endif
|
||||
))) {
|
||||
if (string_result == NULL)
|
||||
retval_int = ((INTPROCINT)ProcAddI)(argint);
|
||||
else
|
||||
retval_str = (ProcAddI)(argint);
|
||||
}
|
||||
}
|
||||
|
||||
/* Save the string before we free the library. */
|
||||
/* Assume that a "1" or "-1" result is an illegal pointer. */
|
||||
if (string_result == NULL)
|
||||
*number_result = retval_int;
|
||||
else if (retval_str != NULL
|
||||
&& retval_str != (char_u *)1
|
||||
&& retval_str != (char_u *)-1)
|
||||
*string_result = vim_strsave(retval_str);
|
||||
}
|
||||
|
||||
mch_endjmp();
|
||||
# ifdef SIGHASARG
|
||||
if (lc_signal != 0) {
|
||||
int i;
|
||||
|
||||
/* try to find the name of this signal */
|
||||
for (i = 0; signal_info[i].sig != -1; i++)
|
||||
if (lc_signal == signal_info[i].sig)
|
||||
break;
|
||||
EMSG2("E368: got SIG%s in libcall()", signal_info[i].name);
|
||||
}
|
||||
# endif
|
||||
|
||||
# if defined(USE_DLOPEN)
|
||||
/* "dlerr" must be used before dlclose() */
|
||||
if (dlerr != NULL)
|
||||
EMSG2(_("dlerror = \"%s\""), dlerr);
|
||||
|
||||
/* Free the DLL module. */
|
||||
(void)dlclose(hinstLib);
|
||||
# else
|
||||
(void)shl_unload(hinstLib);
|
||||
# endif
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
EMSG2(_(e_libcall), funcname);
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
@@ -262,17 +262,6 @@
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#include <setjmp.h>
|
||||
#ifdef HAVE_SIGSETJMP
|
||||
# define JMP_BUF sigjmp_buf
|
||||
# define SETJMP(x) sigsetjmp((x), 1)
|
||||
# define LONGJMP siglongjmp
|
||||
#else
|
||||
# define JMP_BUF jmp_buf
|
||||
# define SETJMP(x) setjmp(x)
|
||||
# define LONGJMP longjmp
|
||||
#endif
|
||||
|
||||
#define HAVE_DUP /* have dup() */
|
||||
|
||||
/* We have three kinds of ACL support. */
|
||||
|
Reference in New Issue
Block a user