mirror of
				https://github.com/janet-lang/janet
				synced 2025-10-31 07:33:01 +00:00 
			
		
		
		
	Remove pthreads from shell.c and update bsd build.
This commit is contained in:
		| @@ -126,28 +126,21 @@ https://github.com/antirez/linenoise/blob/master/linenoise.c | ||||
| #define JANET_LINE_MAX 1024 | ||||
| #define JANET_MATCH_MAX 256 | ||||
| #define JANET_HISTORY_MAX 100 | ||||
| static int gbl_israwmode = 0; | ||||
| static const char *gbl_prompt = "> "; | ||||
| static int gbl_plen = 2; | ||||
| static char gbl_buf[JANET_LINE_MAX]; | ||||
| static int gbl_len = 0; | ||||
| static int gbl_pos = 0; | ||||
| static int gbl_cols = 80; | ||||
| static char *gbl_history[JANET_HISTORY_MAX]; | ||||
| static int gbl_history_count = 0; | ||||
| static int gbl_historyi = 0; | ||||
| static int gbl_sigint_flag = 0; | ||||
| static struct termios gbl_termios_start; | ||||
| static JanetByteView gbl_matches[JANET_MATCH_MAX]; | ||||
| static int gbl_match_count = 0; | ||||
| static int gbl_lines_below = 0; | ||||
|  | ||||
| /* Put a lock around this global state so we don't screw up | ||||
|  * the terminal in a multithreaded situation */ | ||||
| #ifndef JANET_SINGLE_THREADED | ||||
| #include <pthread.h> | ||||
| static pthread_mutex_t gbl_lock = PTHREAD_MUTEX_INITIALIZER; | ||||
| #endif | ||||
| JANET_THREAD_LOCAL static int gbl_israwmode = 0; | ||||
| JANET_THREAD_LOCAL static const char *gbl_prompt = "> "; | ||||
| JANET_THREAD_LOCAL static int gbl_plen = 2; | ||||
| JANET_THREAD_LOCAL static char gbl_buf[JANET_LINE_MAX]; | ||||
| JANET_THREAD_LOCAL static int gbl_len = 0; | ||||
| JANET_THREAD_LOCAL static int gbl_pos = 0; | ||||
| JANET_THREAD_LOCAL static int gbl_cols = 80; | ||||
| JANET_THREAD_LOCAL static char *gbl_history[JANET_HISTORY_MAX]; | ||||
| JANET_THREAD_LOCAL static int gbl_history_count = 0; | ||||
| JANET_THREAD_LOCAL static int gbl_historyi = 0; | ||||
| JANET_THREAD_LOCAL static int gbl_sigint_flag = 0; | ||||
| JANET_THREAD_LOCAL static struct termios gbl_termios_start; | ||||
| JANET_THREAD_LOCAL static JanetByteView gbl_matches[JANET_MATCH_MAX]; | ||||
| JANET_THREAD_LOCAL static int gbl_match_count = 0; | ||||
| JANET_THREAD_LOCAL static int gbl_lines_below = 0; | ||||
|  | ||||
| /* Unsupported terminal list from linenoise */ | ||||
| static const char *badterms[] = { | ||||
| @@ -169,9 +162,6 @@ static char *sdup(const char *s) { | ||||
| /* Ansi terminal raw mode */ | ||||
| static int rawmode(void) { | ||||
|     struct termios t; | ||||
| #ifndef JANET_SINGLE_THREADED | ||||
|     pthread_mutex_lock(&gbl_lock); | ||||
| #endif | ||||
|     if (!isatty(STDIN_FILENO)) goto fatal; | ||||
|     if (tcgetattr(STDIN_FILENO, &gbl_termios_start) == -1) goto fatal; | ||||
|     t = gbl_termios_start; | ||||
| @@ -185,9 +175,6 @@ static int rawmode(void) { | ||||
|     return 0; | ||||
| fatal: | ||||
|     errno = ENOTTY; | ||||
| #ifndef JANET_SINGLE_THREADED | ||||
|     pthread_mutex_unlock(&gbl_lock); | ||||
| #endif | ||||
|     return -1; | ||||
| } | ||||
|  | ||||
| @@ -195,9 +182,6 @@ fatal: | ||||
| static void norawmode(void) { | ||||
|     if (gbl_israwmode && tcsetattr(STDIN_FILENO, TCSADRAIN, &gbl_termios_start) != -1) | ||||
|         gbl_israwmode = 0; | ||||
| #ifndef JANET_SINGLE_THREADED | ||||
|     pthread_mutex_unlock(&gbl_lock); | ||||
| #endif | ||||
| } | ||||
|  | ||||
| static int curpos(void) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Calvin Rose
					Calvin Rose