Compare commits
4 commits
e0dc93f61d
...
603b5a4cb6
| Author | SHA1 | Date | |
|---|---|---|---|
| 603b5a4cb6 | |||
| c10a3decd0 | |||
| 144312744c | |||
| 7026872240 |
4 changed files with 38 additions and 14 deletions
21
colla.c
21
colla.c
|
|
@ -961,6 +961,10 @@ bool rg__match_here(instream_t r, instream_t t) {
|
|||
if (rc == '$' && rcn == '\0') {
|
||||
return istr_peek(&t) == '\0';
|
||||
}
|
||||
// if (rc == '\\') {
|
||||
// istr_skip(&r, 1);
|
||||
// return istr_peek(&r) == istr_peek(&t);
|
||||
// }
|
||||
if (!istr_is_finished(&t) && (rc == '.' || rc == istr_peek(&t))) {
|
||||
istr_skip(&r, 1);
|
||||
istr_skip(&t, 1);
|
||||
|
|
@ -1475,6 +1479,10 @@ static arena_t arena__make_static(u8 *buf, usize len) {
|
|||
|
||||
// == HANDLE ====================================
|
||||
|
||||
str_t os_get_last_error_string(void) {
|
||||
return os_get_error_string(os_get_last_error());
|
||||
}
|
||||
|
||||
oshandle_t os_handle_zero(void) {
|
||||
return (oshandle_t){0};
|
||||
}
|
||||
|
|
@ -1612,13 +1620,20 @@ void os_log_printv(const char *file, int line, os_log_level_e level, const char
|
|||
log_event_t ev = {
|
||||
.level = level,
|
||||
.line = line,
|
||||
.args = args,
|
||||
// .args = args,
|
||||
.fmt = fmt,
|
||||
.file = file,
|
||||
.time = &log_time,
|
||||
// .time = &log_time,
|
||||
};
|
||||
|
||||
va_copy(ev.args, args);
|
||||
|
||||
#if COLLA_WIN
|
||||
localtime_s(&log_time, &t);
|
||||
ev.time = &log_time;
|
||||
#else
|
||||
ev.time = localtime(&t);
|
||||
#endif
|
||||
for (int i = 0; i < os__log_cbs_count; ++i) {
|
||||
if (os__log_cbs[i].level > level) {
|
||||
continue;
|
||||
|
|
@ -1803,6 +1818,7 @@ usize os_pad_to_page(usize byte_count) {
|
|||
|
||||
// == THREAD ====================================
|
||||
|
||||
#if !COLLA_NO_ATOMICS
|
||||
void os_barrier_sync(os_barrier_t *b) {
|
||||
atomic_inc_i64(&b->thread_value);
|
||||
|
||||
|
|
@ -1843,6 +1859,7 @@ i64range_t os_lane_range(u64 values_count) {
|
|||
|
||||
return (i64range_t){ thread_first_value, thread_last_value };
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !COLLA_NO_CONDITION_VARIABLE
|
||||
|
||||
|
|
|
|||
6
colla.h
6
colla.h
|
|
@ -331,6 +331,8 @@ for_each (chunk, arr) {
|
|||
(arr)->items[(arr)->count++] = (item); \
|
||||
} while (0)
|
||||
|
||||
#define darr_pop(arr) if ((arr) && (arr)->count) --(arr)->count
|
||||
|
||||
// STRING TYPES /////////////////////////////////
|
||||
|
||||
#define STR_NONE SIZE_MAX
|
||||
|
|
@ -733,6 +735,7 @@ void os_abort(int code);
|
|||
iptr os_get_last_error(void);
|
||||
// NOT thread safe
|
||||
str_t os_get_error_string(iptr error);
|
||||
str_t os_get_last_error_string(void);
|
||||
|
||||
// == HANDLE ====================================
|
||||
|
||||
|
|
@ -1050,6 +1053,8 @@ job_t *jq_pop_job(job_queue_t *queue);
|
|||
|
||||
// == ATOMICS ========================================
|
||||
|
||||
#if !COLLA_NO_ATOMICS
|
||||
|
||||
i64 atomic_set_i64(i64 *dest, i64 val);
|
||||
i64 atomic_add_i64(i64 *dest, i64 val);
|
||||
i64 atomic_and_i64(i64 *dest, i64 val);
|
||||
|
|
@ -1059,6 +1064,7 @@ i64 atomic_inc_i64(i64 *dest);
|
|||
i64 atomic_dec_i64(i64 *dest);
|
||||
i64 atomic_or_i64(i64 *dest, i64 val);
|
||||
i64 atomic_xor_i64(i64 *dest, i64 val);
|
||||
#endif
|
||||
|
||||
// PARSERS //////////////////////////////////////
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@
|
|||
#define ntohll(x) be64toh(x)
|
||||
#endif
|
||||
|
||||
void os__log_init(void);
|
||||
|
||||
strview_t os__fg_colours[LOG_COL__COUNT] = {
|
||||
[LOG_COL_BLACK] = cstrv("\x1b[30m"),
|
||||
[LOG_COL_BLUE] = cstrv("\x1b[34m"),
|
||||
|
|
@ -132,6 +134,8 @@ void os_init(void) {
|
|||
struct utsname name = {0};
|
||||
uname(&name);
|
||||
lin_data.info.machine_name = str(&lin_data.arena, name.nodename);
|
||||
|
||||
os__log_init();
|
||||
}
|
||||
|
||||
void os_cleanup(void) {
|
||||
|
|
|
|||
|
|
@ -789,7 +789,7 @@ oshandle_t os_run_cmd_async(arena_t scratch, os_cmd_t *cmd, os_cmd_options_t *op
|
|||
|
||||
if (options && options->in) {
|
||||
CreatePipe(&hstdin_read, &hstdin_write, &sa_attr, 0);
|
||||
options->in->data = (uptr)hstdin_read;
|
||||
options->in->data = (uptr)hstdin_write;
|
||||
SetHandleInformation(hstdin_write, HANDLE_FLAG_INHERIT, 0);
|
||||
}
|
||||
|
||||
|
|
@ -839,17 +839,11 @@ oshandle_t os_run_cmd_async(arena_t scratch, os_cmd_t *cmd, os_cmd_options_t *op
|
|||
&proc_info
|
||||
);
|
||||
|
||||
if (hstdout_write) {
|
||||
CloseHandle(hstdout_write);
|
||||
}
|
||||
#define CLOSE_IF(x) if (x) CloseHandle(x)
|
||||
|
||||
if (hstderr_write) {
|
||||
CloseHandle(hstderr_write);
|
||||
}
|
||||
|
||||
if (hstdin_read) {
|
||||
CloseHandle(hstdin_read);
|
||||
}
|
||||
CLOSE_IF(hstdout_write);
|
||||
CLOSE_IF(hstderr_write);
|
||||
CLOSE_IF(hstdin_read);
|
||||
|
||||
if (env) {
|
||||
FreeEnvironmentStringsW(env);
|
||||
|
|
@ -858,10 +852,13 @@ oshandle_t os_run_cmd_async(arena_t scratch, os_cmd_t *cmd, os_cmd_options_t *op
|
|||
|
||||
if (!success && !quiet) {
|
||||
err("couldn't create process (%v): %v", cmd_str, os_get_error_string(os_get_last_error()));
|
||||
CLOSE_IF(hstdout_read);
|
||||
CLOSE_IF(hstderr_read);
|
||||
CLOSE_IF(hstdin_write);
|
||||
return os_handle_zero();
|
||||
}
|
||||
|
||||
CloseHandle(proc_info.hThread);
|
||||
CLOSE_IF(proc_info.hThread);
|
||||
|
||||
return (oshandle_t) {
|
||||
.data = (uptr)proc_info.hProcess
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue