now runs with -O2
This commit is contained in:
@ -3,10 +3,10 @@
|
||||
#include <dirent.h>
|
||||
#include <stdlib.h>
|
||||
#include <strings.h>
|
||||
#include <signal.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "defines.h"
|
||||
#include "config.h"
|
||||
|
||||
@ -246,7 +246,7 @@ void move_right(){
|
||||
cmd = concat(cmd, "\"");
|
||||
btm_buffer = malloc(strlen(cmd));
|
||||
|
||||
strcpy(btm_buffer, cmd);
|
||||
strcpy(btm_buffer, cmd-1);
|
||||
|
||||
|
||||
if (system(cmd) == -1) {
|
||||
|
16
main.c
16
main.c
@ -75,19 +75,19 @@ int main(){
|
||||
pthread_cancel(thread_t);
|
||||
}
|
||||
if (threading) {
|
||||
pthread_join(thread_t, NULL);
|
||||
pthread_join(thread_l, NULL);
|
||||
pthread_join(thread_m, NULL);
|
||||
pthread_join(thread_b, NULL);
|
||||
pthread_join(thread_r, NULL);
|
||||
pthread_join(thread_m, NULL);
|
||||
pthread_join(thread_l, NULL);
|
||||
pthread_join(thread_t, NULL);
|
||||
threading = 0;
|
||||
}
|
||||
if (status & STATUS_RUN_BACKEND) {
|
||||
pthread_create(&thread_t, NULL, thread_top, win_t); /*top bar*/
|
||||
pthread_create(&thread_l, NULL, thread_lft, win_l); /*current_content slash win_m*/
|
||||
pthread_create(&thread_m, NULL, thread_mid, win_m); /*parent_content slash win_l*/
|
||||
pthread_create(&thread_r, NULL, thread_rgt, win_r); /*child_content slash win_r*/
|
||||
pthread_create(&thread_b, NULL, thread_btm, win_b); /*bottom bar*/
|
||||
pthread_create(&thread_t, NULL, thread_top, &status); /*top bar*/
|
||||
pthread_create(&thread_l, NULL, thread_lft, &status); /*parent_content slash win_l*/
|
||||
pthread_create(&thread_m, NULL, thread_mid, &status); /*current_content slash win_m*/
|
||||
pthread_create(&thread_b, NULL, thread_btm, &status); /*bottom bar*/
|
||||
pthread_create(&thread_r, NULL, thread_rgt, &status); /*child_content slash win_r*/
|
||||
status &= ~(STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
||||
status |= STATUS_UPDATE_SCREEN_0;
|
||||
threading = 1;
|
||||
|
38
threading.c
38
threading.c
@ -18,7 +18,7 @@ pthread_mutex_t mutex_rgt;
|
||||
pthread_mutex_t mutex_selection;
|
||||
pthread_mutex_t mutex_wait;
|
||||
pthread_cond_t cond_wait;
|
||||
int wait_count; /* this is used to determine how many threads are waiting for cont_wait */
|
||||
volatile char wait_count; /* this is used to determine how many threads are waiting for cont_wait */
|
||||
|
||||
file *rgt_content;
|
||||
file *mid_content;
|
||||
@ -39,12 +39,11 @@ unsigned long top_width;
|
||||
|
||||
unsigned long selected_file_current=0;
|
||||
unsigned long selected_file_last=0;
|
||||
unsigned int status_mid;
|
||||
extern unsigned int status;
|
||||
extern unsigned int terminal_width;
|
||||
|
||||
|
||||
void *thread_mid(void *data){
|
||||
unsigned int status = *(unsigned int*)data;
|
||||
pthread_mutex_lock(&mutex_mid);
|
||||
|
||||
|
||||
@ -98,10 +97,9 @@ void *thread_mid(void *data){
|
||||
|
||||
|
||||
pthread_mutex_lock(&mutex_selection);
|
||||
while(1) { /* this useless while loop exists for the singular purpose of making valgrind happy */
|
||||
if (selected_file_current >= mid_file_count) {
|
||||
selected_file_current = mid_file_count-1;
|
||||
} else {
|
||||
}
|
||||
mid_content[selected_file_current].status |= FILE_STATUS_HOVER;
|
||||
if (selected_file_current != selected_file_last) {
|
||||
mid_content[selected_file_last].status &= ~FILE_STATUS_HOVER;
|
||||
@ -116,16 +114,14 @@ void *thread_mid(void *data){
|
||||
file_current->permissions = mid_content[selected_file_current].permissions;
|
||||
file_current->status = mid_content[selected_file_current].status;
|
||||
|
||||
pthread_mutex_unlock(&mutex_selection);
|
||||
|
||||
while(wait_count < 2){
|
||||
/*wait for thread_rgt and thread_btm to lock*/
|
||||
}
|
||||
pthread_mutex_lock(&mutex_wait);
|
||||
pthread_cond_broadcast(&cond_wait);
|
||||
pthread_mutex_unlock(&mutex_wait);
|
||||
break;
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&mutex_selection);
|
||||
|
||||
}
|
||||
free(path);
|
||||
@ -133,6 +129,7 @@ void *thread_mid(void *data){
|
||||
pthread_exit(0);
|
||||
}
|
||||
void *thread_lft(void *data){
|
||||
unsigned int status = *(unsigned int*)data;
|
||||
pthread_mutex_lock(&mutex_lft);
|
||||
|
||||
char *path;
|
||||
@ -162,6 +159,7 @@ void *thread_lft(void *data){
|
||||
|
||||
}
|
||||
void *thread_rgt(void *data){
|
||||
unsigned int status = *(unsigned int*)data;
|
||||
pthread_mutex_lock(&mutex_rgt);
|
||||
pthread_mutex_lock(&mutex_wait);
|
||||
wait_count++;
|
||||
@ -170,7 +168,7 @@ void *thread_rgt(void *data){
|
||||
pthread_mutex_unlock(&mutex_wait);
|
||||
|
||||
|
||||
pthread_mutex_lock(&mutex_mid);
|
||||
pthread_mutex_lock(&mutex_selection);
|
||||
free(rgt_content);
|
||||
rgt_content = malloc(sizeof(file));
|
||||
rgt_content->file_name = malloc(file_current->file_name_width + 1);
|
||||
@ -179,7 +177,7 @@ void *thread_rgt(void *data){
|
||||
rgt_content->file_size = file_current->file_size;
|
||||
rgt_content->file_type = file_current->file_type;
|
||||
rgt_content->status = file_current->status;
|
||||
pthread_mutex_unlock(&mutex_mid);
|
||||
pthread_mutex_unlock(&mutex_selection);
|
||||
|
||||
if (rgt_content->file_type == FILE_TYPE_DIR || rgt_content->file_type == FILE_TYPE_SYMLINK) {
|
||||
char *path = malloc(rgt_content[0].file_name_width + 1);
|
||||
@ -213,6 +211,7 @@ void *thread_rgt(void *data){
|
||||
pthread_exit(0);
|
||||
}
|
||||
void *thread_top(void *data){
|
||||
unsigned int status = *(unsigned int*)data;
|
||||
pthread_mutex_lock(&mutex_top);
|
||||
free(top_buffer);
|
||||
|
||||
@ -231,6 +230,7 @@ void *thread_top(void *data){
|
||||
pthread_exit(0);
|
||||
}
|
||||
void *thread_btm(void *data){
|
||||
unsigned int status = *(unsigned int*)data;
|
||||
pthread_mutex_lock(&mutex_btm);
|
||||
pthread_mutex_lock(&mutex_wait);
|
||||
wait_count++;
|
||||
@ -284,12 +284,16 @@ void threading_init(){
|
||||
file_current->file_name = malloc(sizeof("a"));
|
||||
strcpy(file_current->file_name, "a");
|
||||
|
||||
pthread_mutex_init(&mutex_top, NULL);
|
||||
pthread_mutex_init(&mutex_mid, NULL);
|
||||
pthread_mutex_init(&mutex_lft, NULL);
|
||||
pthread_mutex_init(&mutex_selection, NULL);
|
||||
pthread_mutex_init(&mutex_wait, NULL);
|
||||
pthread_cond_init(&cond_wait, NULL);
|
||||
volatile char vol; /* needed to make sure higher optimization steps dont move these around */
|
||||
vol = pthread_mutex_init(&mutex_top, NULL);
|
||||
vol = pthread_mutex_init(&mutex_mid, NULL);
|
||||
vol = pthread_mutex_init(&mutex_lft, NULL);
|
||||
vol = pthread_mutex_init(&mutex_btm, NULL);
|
||||
vol = pthread_mutex_init(&mutex_rgt, NULL);
|
||||
vol = pthread_mutex_init(&mutex_selection, NULL);
|
||||
vol = pthread_mutex_init(&mutex_wait, NULL);
|
||||
vol = pthread_cond_init(&cond_wait, NULL);
|
||||
vol;
|
||||
selected_file_current = 0;
|
||||
selected_file_last = 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user